diff mbox series

[v7,1/2] Fix output word

Message ID 20180517131604.30368-2-lvivier@redhat.com
State Accepted
Headers show
Series Fix output word | expand

Commit Message

Laurent Vivier May 17, 2018, 1:16 p.m. UTC
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.

Resolve xt-handle and ihandle in the output command.

Use them in the new term-io-emit function.

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

Comments

Thomas Huth May 17, 2018, 2:28 p.m. UTC | #1
On 17.05.2018 15:16, 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.
> 
> Resolve xt-handle and ihandle in the output command.
> 
> Use them in the new term-io-emit function.
> 
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> ---
>  slof/fs/term-io.fs | 36 +++++++++++++++++++++++++++++++-----
>  1 file changed, 31 insertions(+), 5 deletions(-)

Reviewed-by: Thomas Huth <thuth@redhat.com>
Segher Boessenkool May 17, 2018, 3:12 p.m. UTC | #2
Hi!

On Thu, May 17, 2018 at 03:16:03PM +0200, 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.
> 
> Resolve xt-handle and ihandle in the output command.

Just "xt", not "xt-handle"?

>  : output  ( dev-str dev-len -- )
>     open-dev ?dup IF

  open-dev dup 0= IF drop EXIT THEN

is easier to read.

Looks good modulo those nits :-)


Segher
Laurent Vivier May 17, 2018, 3:29 p.m. UTC | #3
On 17/05/2018 17:12, Segher Boessenkool wrote:
> Hi!
> 
> On Thu, May 17, 2018 at 03:16:03PM +0200, 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.
>>
>> Resolve xt-handle and ihandle in the output command.
> 
> Just "xt", not "xt-handle"?
> 
>>  : output  ( dev-str dev-len -- )
>>     open-dev ?dup IF
> 
>   open-dev dup 0= IF drop EXIT THEN
> 
> is easier to read.

I keep the original code to keep the original indentation in the body of
the IF-THEN: it was a comment from Thomas for the v5 to get easier to
review.

> Looks good modulo those nits :-)

Thank you :)

Laurent
diff mbox series

Patch

diff --git a/slof/fs/term-io.fs b/slof/fs/term-io.fs
index 52ce12a..f13ae87 100644
--- a/slof/fs/term-io.fs
+++ b/slof/fs/term-io.fs
@@ -10,6 +10,17 @@ 
 \ *     IBM Corporation - initial implementation
 \ ****************************************************************************/
 
+0 VALUE write-xt
+
+VARIABLE stdout
+
+: set-stdout ( ihandle -- )
+   \ Close old stdout:
+   stdout @ ?dup IF close-dev THEN
+   \ Now set the new stdout:
+   dup stdout !
+   encode-int s" stdout" set-chosen
+;
 
 : input  ( dev-str dev-len -- )
    open-dev ?dup IF
@@ -24,12 +35,15 @@ 
 
 : output  ( dev-str dev-len -- )
    open-dev ?dup IF
-      \ Close old stdout:
-      s" stdout" get-chosen IF
-         decode-int nip nip ?dup IF close-dev THEN
+      \ find new ihandle and xt handle
+      dup s" write" rot ihandle>phandle find-method
+      0= IF
+         drop
+         cr ." Cannot find the write method for the given output console " cr
+         EXIT
       THEN
-      \ Now set the new stdout:
-      encode-int s" stdout" set-chosen
+      to write-xt
+      set-stdout
    THEN
 ;
 
@@ -40,6 +54,18 @@ 
 
 1 BUFFER: (term-io-char-buf)
 
+: term-io-emit ( char -- )
+    write-xt IF
+       (term-io-char-buf) c!
+       (term-io-char-buf) 1 write-xt stdout @ call-package
+       drop
+    ELSE
+       serial-emit
+    THEN
+;
+
+' term-io-emit to emit
+
 : term-io-key  ( -- char )
    s" stdin" get-chosen IF
       decode-int nip nip dup 0= IF 0 EXIT THEN