New string-lines word
parent
528e0e5d5d
commit
5d1f025e54
|
@ -76,7 +76,7 @@ M: ping handle-irc ( line -- )
|
|||
: factorbot-loop [ factorbot ] try 30000 sleep factorbot-loop ;
|
||||
|
||||
: multiline-respond ( string -- )
|
||||
<string-reader> lines [ respond ] each ;
|
||||
string-lines [ respond ] each ;
|
||||
|
||||
: object-href
|
||||
"http://factorcode.org" swap browser-link-href append ;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
! Copyright (C) 2004, 2005 Slava Pestov.
|
||||
! Copyright (C) 2004, 2006 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
IN: io
|
||||
USING: errors generic io kernel math namespaces sequences
|
||||
|
|
|
@ -53,3 +53,6 @@ M: sbuf stream-read
|
|||
|
||||
: contents ( stream -- str )
|
||||
<string-writer> [ stream-copy ] keep >string ;
|
||||
|
||||
: string-lines ( string -- seq )
|
||||
CHAR: \n add <string-reader> lines ;
|
||||
|
|
|
@ -40,7 +40,7 @@ C: source-file ( path -- source-file )
|
|||
: parse-lines ( lines -- quot )
|
||||
[ f [ (parse) ] reduce >quotation ] with-parser ;
|
||||
|
||||
: parse ( str -- quot ) <string-reader> lines parse-lines ;
|
||||
: parse ( str -- quot ) string-lines parse-lines ;
|
||||
|
||||
: eval ( str -- ) parse call ;
|
||||
|
||||
|
|
|
@ -6,3 +6,15 @@ USE: generic
|
|||
USE: kernel
|
||||
|
||||
[ "xyzzy" ] [ [ "xyzzy" write ] string-out ] unit-test
|
||||
|
||||
[ { "" } ] [ "" string-lines ] unit-test
|
||||
[ { "" "" } ] [ "\n" string-lines ] unit-test
|
||||
[ { "" "" } ] [ "\r" string-lines ] unit-test
|
||||
[ { "" "" } ] [ "\r\n" string-lines ] unit-test
|
||||
[ { "hello" } ] [ "hello" string-lines ] unit-test
|
||||
[ { "hello" "" } ] [ "hello\n" string-lines ] unit-test
|
||||
[ { "hello" "" } ] [ "hello\r" string-lines ] unit-test
|
||||
[ { "hello" "" } ] [ "hello\r\n" string-lines ] unit-test
|
||||
[ { "hello" "hi" } ] [ "hello\nhi" string-lines ] unit-test
|
||||
[ { "hello" "hi" } ] [ "hello\rhi" string-lines ] unit-test
|
||||
[ { "hello" "hi" } ] [ "hello\r\nhi" string-lines ] unit-test
|
||||
|
|
|
@ -13,7 +13,7 @@ TUPLE: label text font color ;
|
|||
|
||||
: set-label-string ( string label -- )
|
||||
CHAR: \n pick memq? [
|
||||
>r "\n" split r> set-label-text
|
||||
>r string-lines r> set-label-text
|
||||
] [
|
||||
set-label-text
|
||||
] if ; inline
|
||||
|
|
|
@ -63,10 +63,10 @@ M: pane-stream stream-write1
|
|||
[ pane-current stream-write1 ] do-pane-stream ;
|
||||
|
||||
M: pane-stream stream-write
|
||||
[ swap "\n" split pane-write ] do-pane-stream ;
|
||||
[ swap string-lines pane-write ] do-pane-stream ;
|
||||
|
||||
M: pane-stream stream-format
|
||||
[ rot "\n" split pane-format ] do-pane-stream ;
|
||||
[ rot string-lines pane-format ] do-pane-stream ;
|
||||
|
||||
M: pane-stream stream-close drop ;
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ C: document ( -- document )
|
|||
|
||||
: set-doc-range ( str startloc endloc document -- )
|
||||
[
|
||||
>r >r >r "\n" split r> [ text+loc ] 2keep r> r>
|
||||
>r >r >r string-lines r> [ text+loc ] 2keep r> r>
|
||||
[ (set-doc-range) ] change-model
|
||||
] keep update-locs ;
|
||||
|
||||
|
@ -123,7 +123,7 @@ C: document ( -- document )
|
|||
[ set-model ] keep dup doc-end swap update-locs ;
|
||||
|
||||
: set-doc-text ( string document -- )
|
||||
>r "\n" split r> set-doc-lines ;
|
||||
>r string-lines r> set-doc-lines ;
|
||||
|
||||
: clear-doc ( document -- )
|
||||
"" swap set-doc-text ;
|
||||
|
|
Loading…
Reference in New Issue