"/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"
#! -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.
+++ /dev/null
-! 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 ;
: comment-style
#! Feel free to redefine this!
[
- [[ "ansi-fg" "0" ]]
- [[ "ansi-bg" "2" ]]
[[ "fg" [ 255 0 0 ] ]]
[[ foreground [ 192 0 0 ] ]]
] ;
! 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.
(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
: 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.
\ 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