]> gitweb.factorcode.org Git - factor.git/commitdiff
removed ansi streams, and simplified listener code
authorSlava Pestov <slava@factorcode.org>
Mon, 27 Jun 2005 07:54:43 +0000 (07:54 +0000)
committerSlava Pestov <slava@factorcode.org>
Mon, 27 Jun 2005 07:54:43 +0000 (07:54 +0000)
library/bootstrap/boot-stage3.factor
library/cli.factor
library/io/ansi.factor [deleted file]
library/syntax/see.factor
library/tools/listener.factor
library/tools/walker.factor

index 46c4764d0459a267b2d01e8e7edb5ff6cd47ab15..d28cabfad865a5de000251ae8169f951fe779b31 100644 (file)
@@ -62,7 +62,6 @@ t [
     
     "/library/eval-catch.factor"
     "/library/tools/listener.factor"
-    "/library/io/ansi.factor"
     "/library/tools/word-tools.factor"
     "/library/syntax/see.factor"
     "/library/test/test.factor"
index 59521fc017e19f7e7f2ef21664a4e14a29d161f5..6a5406ca521d8fe036a37f67ca6f4c5bb4a91525 100644 (file)
@@ -55,7 +55,7 @@ sequences strings ;
     #! -no-<flag> CLI switch
     "user-init" on
     "compile" on
-    os "win32" = "ui" "ansi" ? "shell" set ;
+    os "win32" = "ui" "tty" ? "shell" set ;
 
 : parse-command-line ( -- )
     #! Parse command line arguments.
diff --git a/library/io/ansi.factor b/library/io/ansi.factor
deleted file mode 100644 (file)
index 6d80233..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-! Copyright (C) 2004, 2005 Slava Pestov.
-! See http://factor.sf.net/license.txt for BSD license.
-IN: ansi
-USING: lists kernel namespaces io strings
-presentation generic sequences ;
-
-! <ansi-stream> raps the given stream in an ANSI stream. ANSI
-! streams support the following character attributes:
-! bold    - if not f, text is boldface.
-! ansi-fg - foreground color
-! ansi-bg - background color
-
-! black   0
-! red     1
-! green   2
-! yellow  3
-! blue    4
-! magenta 5
-! cyan    6
-! white   7
-
-TUPLE: ansi-stream ;
-C: ansi-stream ( stream -- stream ) [ set-delegate ] keep ;
-
-: reset ( -- code )
-    #! Reset ANSI color codes.
-    "\e[0m" ; inline
-
-: bold ( -- code )
-    #! Switch on boldface.
-    "\e[1m" ; inline
-
-: fg ( color -- code )
-    #! Set foreground color.
-    "\e[3" swap "m" append3 ; inline
-
-: bg ( color -- code )
-    #! Set foreground color.
-    "\e[4" swap "m" append3 ; inline
-
-: ansi-attrs ( style -- )
-    "bold"    over assoc [ bold , ] when
-    "ansi-fg" over assoc [ fg , ] when*
-    "ansi-bg" swap assoc [ bg , ] when* ;
-
-M: ansi-stream stream-write-attr ( string style stream -- )
-    >r [ ansi-attrs , reset , ] make-string r>
-    delegate stream-write ;
-
-IN: shells
-
-: ansi
-    stdio [ <ansi-stream> ] change tty ;
index 7a13b41fb06e7ac878640b79346ce787c4023543..52f9a9474f954aecc305249964373fc38747ce24 100644 (file)
@@ -37,8 +37,6 @@ streams strings styles unparser words ;
 : comment-style
     #! Feel free to redefine this!
     [
-        [[ "ansi-fg" "0" ]]
-        [[ "ansi-bg" "2" ]]
         [[ "fg" [ 255 0 0 ] ]]
         [[ foreground [ 192 0 0 ] ]]
     ] ;
index bf3fb64c5b56effbb6aa708f6e92a3bd13fd053d..be84cc157df6d531cd602b0930ac6f0fa0e3f9be 100644 (file)
@@ -1,24 +1,13 @@
 ! Copyright (C) 2003, 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: listener
-USING: ansi errors io kernel lists math memory namespaces parser
+USING: errors io kernel lists math memory namespaces parser
 presentation sequences strings styles unparser vectors words ;
 
-SYMBOL: cont-prompt
 SYMBOL: listener-prompt
 SYMBOL: quit-flag
 
-global [
-    "..." cont-prompt set
-    "ok" listener-prompt set
-] bind
-
-: prompt. ( text -- )
-    [ [[ "bold" t ]] [[ font-style bold ]] ] write-attr
-    ! Print the space without a style, to workaround a bug in
-    ! the GUI listener where the style from the prompt carries
-    ! over to the input
-    bl flush ;
+global [ "  " listener-prompt set ] bind
 
 : bye ( -- )
     #! Exit the current listener.
@@ -30,8 +19,7 @@ global [
         (parse) depth r> dup >r <= [
             ( we're done ) r> drop t
         ] [
-            ( more input needed ) r> cont-prompt get prompt.
-            (read-multiline)
+            ( more input needed ) r> (read-multiline)
         ] ifte
     ] [
         ( EOF ) r> 2drop f
@@ -44,8 +32,8 @@ global [
 
 : listen ( -- )
     #! Wait for user input, and execute.
-    listener-prompt get prompt.
-    [ read-multiline [ call ] [ bye ] ifte ] try ;
+    listener-prompt get write flush
+    [ read-multiline [ terpri flush call ] [ bye ] ifte ] try ;
 
 : listener ( -- )
     #! Run a listener loop that executes user input.
index f956a878a400dd844e23c206919c9bad2427fde7..4d925502cd53bf49d45146f58ddeb609210ebf7a 100644 (file)
@@ -60,7 +60,7 @@ sequences io strings vectors words ;
     \ bye word. " -- exit single-stepper" print
     report ;
 
-: walk-listener walk-banner "walk" listener-prompt set listener ;
+: walk-listener walk-banner "walk " listener-prompt set listener ;
 
 : init-walk ( quot callstack namestack -- )
     init-interpreter