[v2,1/1] Fix output word

Message ID 20171018083230.24435-2-lvivier@redhat.com
State Superseded
Headers show
Series
  • Fix output word
Related show

Commit Message

Laurent Vivier Oct. 18, 2017, 8:32 a.m.
We can select the console output, but it does not really work

Implement term-io-emit, as we have term-io-key to really
send characters to the output selected by stdout.

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
 slof/fs/term-io.fs | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Comments

Laurent Vivier Nov. 10, 2017, 11:01 a.m. | #1
Ping?

Laurent

On 18/10/2017 10:32, Laurent Vivier wrote:
> We can select the console output, but it does not really work
> 
> Implement term-io-emit, as we have term-io-key to really
> send characters to the output selected by stdout.
> 
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> ---
>  slof/fs/term-io.fs | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/slof/fs/term-io.fs b/slof/fs/term-io.fs
> index 52ce12a..f801f8b 100644
> --- a/slof/fs/term-io.fs
> +++ b/slof/fs/term-io.fs
> @@ -22,6 +22,9 @@
>     THEN
>  ;
>  
> +0 VALUE stdout_ihandle
> +0 VALUE write_xt
> +
>  : output  ( dev-str dev-len -- )
>     open-dev ?dup IF
>        \ Close old stdout:
> @@ -29,7 +32,10 @@
>           decode-int nip nip ?dup IF close-dev THEN
>        THEN
>        \ Now set the new stdout:
> +      dup to stdout_ihandle
>        encode-int s" stdout" set-chosen
> +      s" write" stdout_ihandle ihandle>phandle find-method
> +      0= IF 0 THEN to write_xt
>     THEN
>  ;
>  
> @@ -40,6 +46,15 @@
>  
>  1 BUFFER: (term-io-char-buf)
>  
> +: term-io-emit ( char -- )
> +    write_xt 0= IF [ ' emit behavior compile, ] EXIT THEN
> +    (term-io-char-buf) c!
> +    (term-io-char-buf) 1 write_xt stdout_ihandle call-package
> +    drop
> +;
> +
> +' term-io-emit to emit
> +
>  : term-io-key  ( -- char )
>     s" stdin" get-chosen IF
>        decode-int nip nip dup 0= IF 0 EXIT THEN
>
Laurent Vivier Nov. 23, 2017, 9:26 a.m. | #2
Someone to review?

Thanks,
Laurent

On 10/11/2017 12:01, Laurent Vivier wrote:
> Ping?
> 
> Laurent
> 
> On 18/10/2017 10:32, Laurent Vivier wrote:
>> We can select the console output, but it does not really work
>>
>> Implement term-io-emit, as we have term-io-key to really
>> send characters to the output selected by stdout.
>>
>> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
>> ---
>>  slof/fs/term-io.fs | 15 +++++++++++++++
>>  1 file changed, 15 insertions(+)
>>
>> diff --git a/slof/fs/term-io.fs b/slof/fs/term-io.fs
>> index 52ce12a..f801f8b 100644
>> --- a/slof/fs/term-io.fs
>> +++ b/slof/fs/term-io.fs
>> @@ -22,6 +22,9 @@
>>     THEN
>>  ;
>>  
>> +0 VALUE stdout_ihandle
>> +0 VALUE write_xt
>> +
>>  : output  ( dev-str dev-len -- )
>>     open-dev ?dup IF
>>        \ Close old stdout:
>> @@ -29,7 +32,10 @@
>>           decode-int nip nip ?dup IF close-dev THEN
>>        THEN
>>        \ Now set the new stdout:
>> +      dup to stdout_ihandle
>>        encode-int s" stdout" set-chosen
>> +      s" write" stdout_ihandle ihandle>phandle find-method
>> +      0= IF 0 THEN to write_xt
>>     THEN
>>  ;
>>  
>> @@ -40,6 +46,15 @@
>>  
>>  1 BUFFER: (term-io-char-buf)
>>  
>> +: term-io-emit ( char -- )
>> +    write_xt 0= IF [ ' emit behavior compile, ] EXIT THEN
>> +    (term-io-char-buf) c!
>> +    (term-io-char-buf) 1 write_xt stdout_ihandle call-package
>> +    drop
>> +;
>> +
>> +' term-io-emit to emit
>> +
>>  : term-io-key  ( -- char )
>>     s" stdin" get-chosen IF
>>        decode-int nip nip dup 0= IF 0 EXIT THEN
>>
> 
> _______________________________________________
> SLOF mailing list
> SLOF@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/slof
>
Segher Boessenkool Nov. 23, 2017, 4:53 p.m. | #3
On Thu, Nov 23, 2017 at 10:26:13AM +0100, Laurent Vivier wrote:
> >> We can select the console output, but it does not really work

It used to work, what broke?

> >> Implement term-io-emit, as we have term-io-key to really
> >> send characters to the output selected by stdout.

This is a nice optimisation of course (caching the xt), but term-io-key
should do the same thing then.

> >> +0 VALUE stdout_ihandle
> >> +0 VALUE write_xt

Please use dashes instead of underscores.

> >>  : output  ( dev-str dev-len -- )
> >>     open-dev ?dup IF
> >>        \ Close old stdout:
> >> @@ -29,7 +32,10 @@
> >>           decode-int nip nip ?dup IF close-dev THEN
> >>        THEN
> >>        \ Now set the new stdout:
> >> +      dup to stdout_ihandle
> >>        encode-int s" stdout" set-chosen
> >> +      s" write" stdout_ihandle ihandle>phandle find-method
> >> +      0= IF 0 THEN to write_xt
> >>     THEN
> >>  ;

An xt of zero will crash the system if you try to execute it.  Use
['] 2drop   instead?  Or similar.  Or don't do a term-io-emit but
just a term-io-type.

> >>  
> >> @@ -40,6 +46,15 @@
> >>  
> >>  1 BUFFER: (term-io-char-buf)
> >>  
> >> +: term-io-emit ( char -- )
> >> +    write_xt 0= IF [ ' emit behavior compile, ] EXIT THEN

That is very problematic.  If the xt of term-io-emit already is the
behaviour of emit, this will loop.  It sounds like you just want the
"system emit"; just assign that to the hook, don't do extra redirections?


Segher

Patch

diff --git a/slof/fs/term-io.fs b/slof/fs/term-io.fs
index 52ce12a..f801f8b 100644
--- a/slof/fs/term-io.fs
+++ b/slof/fs/term-io.fs
@@ -22,6 +22,9 @@ 
    THEN
 ;
 
+0 VALUE stdout_ihandle
+0 VALUE write_xt
+
 : output  ( dev-str dev-len -- )
    open-dev ?dup IF
       \ Close old stdout:
@@ -29,7 +32,10 @@ 
          decode-int nip nip ?dup IF close-dev THEN
       THEN
       \ Now set the new stdout:
+      dup to stdout_ihandle
       encode-int s" stdout" set-chosen
+      s" write" stdout_ihandle ihandle>phandle find-method
+      0= IF 0 THEN to write_xt
    THEN
 ;
 
@@ -40,6 +46,15 @@ 
 
 1 BUFFER: (term-io-char-buf)
 
+: term-io-emit ( char -- )
+    write_xt 0= IF [ ' emit behavior compile, ] EXIT THEN
+    (term-io-char-buf) c!
+    (term-io-char-buf) 1 write_xt stdout_ihandle call-package
+    drop
+;
+
+' term-io-emit to emit
+
 : term-io-key  ( -- char )
    s" stdin" get-chosen IF
       decode-int nip nip dup 0= IF 0 EXIT THEN