- Only 2 generations are used by default now, since there seems to be no
performance benefit to having 3 after running some brief benchmarks.
-- Many improvements to the matrices library.
+- The following formely list-specific words are now generic:
+
+ all? all-with? subset subset-with fiber? prune
+
+- The contains? word for testing membership in a sequence has been
+ renamed to member?.
-- String input streams.
+- The some? and some-with? combinators are gone. Their replacements
+ are contains?, contains-with?, find, find*, find-with, and find-with*.
+ See the documentation for details.
- with-string is now string-out ( quot -- string )
+- The nreverse word has been removed.
- new string-in ( string quot -- ) word, calls quot with stdio bound to
+- reversed ( seq -- seq ) outputs a new sequence that shares structure
+ with the given sequence, but presents elements in reverse order.
+
+- Many improvements to the matrices library.
+
+- with-string word renamed to string-out ( quot -- string )
+
+- new string-in ( string quot -- ) word, calls quot with stdio bound to
a stream that reads from the given string.
- Improved inspector. Call it with inspect ( obj -- ).
+- Fixed bug where images saved from the jEdit plugin would fail to
+ start.
+
- md5 hashing algorithm in contrib/crypto/ (Doug Coleman).
Factor 0.75:
-+ bugs to fix soon\r
+76:\r
+---\r
\r
-<magnus--> http://developer.apple.com/technotes/tn2004/tn2123.html#SECLIMITATIONS\r
-<magnus--> http://www.caddr.com/macho/archives/sbcl-devel/2005-3/4742.html\r
-<magnus--> not *too* long\r
-<magnus--> but we'd need to longjmp the main thread from the exception handler thread\r
-<magnus--> or cause a signal in the main thread\r
-<magnus--> http://www.caddr.com/macho/archives/sbcl-devel/2005-3/4764.html\r
-<magnus--> http://clozure.com/cgi-bin/viewcvs.cgi/ccl/lisp-kernel/lisp-exceptions.c?rev=1.9&content-type=text/vnd.viewcvs-markup\r
-\r
-- i/o: don't keep creating new sbufs\r
- set-length should not shorten the underlying sequence\r
-- there is a problem with hashcodes of words and bootstrapping\r
-- http keep alive, and range get\r
-- sleep word\r
-- fix i/o on generic x86/ppc unix\r
-- code walker & exceptions\r
-- if two tasks write to a unix stream, the buffer can overflow\r
-- rename prettyprint* to pprint, prettyprint to pp\r
-- reader syntax for arrays, byte arrays, displaced aliens\r
-- images saved from plugin do not work\r
-- investigate orphans\r
+- i/o: don't keep creating new sbufs\r
+- [ EAX 0 ] --> [ EAX ]\r
+- rollovers broken with menus\r
+- menu dragging\r
+- fix up the min thumb size hack\r
+- bevel borders\r
+- nicer scrollbars with up/down buttons\r
+- gaps in pack layout\r
+- fix listener prompt display after presentation commands invoked\r
+- stack display bugs\r
+- simple tutorial\r
+- parser::skip clean up\r
\r
-+ plugin:\r
++ misc\r
\r
-- word preview for parsing words\r
-- plugin: supportsBackspace\r
-- if external factor is down, don't add tons of random shit to the \r
- dictionary\r
+Investigate:\r
\r
-+ ui:\r
+ http://developer.apple.com/technotes/tn2004/tn2123.html#SECLIMITATIONS\r
+ http://www.caddr.com/macho/archives/sbcl-devel/2005-3/4742.html\r
+ http://www.caddr.com/macho/archives/sbcl-devel/2005-3/4764.html\r
+ http://clozure.com/cgi-bin/viewcvs.cgi/ccl/lisp-kernel/lisp-exceptions.c?rev=1.9&content-type=text/vnd.viewcvs-markup\r
\r
-- faster layout\r
+- http keep alive, and range get\r
+- code walker & exceptions\r
- faster repaint\r
-- ui browser\r
-- mouse enter onto overlapping with interior, but not child, gadget\r
-- rollovers broken in inspector\r
-- menu dragging\r
-- fix up the min thumb size hack\r
\r
+ ffi:\r
\r
-- alien primitives need a more general input type\r
- smarter out parameter handling\r
- clarify powerpc passing of value struct parameters\r
-- box/unbox_signed/unsigned_8\r
- ffi unicode strings: null char security hole\r
- utf16 string boxing\r
- value type structs\r
- simplifier:\r
- kill replace after a peek\r
- merge inc-d's across VOPs that don't touch the stack\r
-- [ EAX 0 ] --> [ EAX ]\r
- intrinsic char-slot set-char-slot integer-slot set-integer-slot\r
- [ [ dup call ] dup call ] infer hangs\r
- more accurate types for various words\r
- array sort\r
- nappend: instead of using push, enlarge the sequence with set-length\r
then add set the elements with set-nth\r
-- faster sequence operations\r
- specialized arrays\r
- phase out sbuf-append\r
\r
+ kernel:\r
\r
+- sleep word\r
+- there is a problem with hashcodes of words and bootstrapping\r
- delegating generic words with a non-standard picker\r
- powerpc has weird callstack residue\r
- instances: do not use make-list\r
\r
- faster stream-copy\r
- reading and writing byte arrays\r
-- merge unix and win32 io where appropriate\r
+- clean up line reading code in win32-io\r
- unix io: handle \n\r and \n\0\r
- separate words for writing characters and strings\r
-- perhaps:\r
- GENERIC: set-style ( style stream -- )\r
- GENERIC: stream-write\r
- GENERIC: stream-write-char\r
- stream server can hang because of exception handler limitations\r
- better i/o scheduler\r
- unify unparse and prettyprint\r
- utf16, utf8 encoding\r
+- fix i/o on generic x86/ppc unix\r
+- if two tasks write to a unix stream, the buffer can overflow\r
+- rename prettyprint* to pprint, prettyprint to pp\r
+- reader syntax for arrays, byte arrays, displaced aliens\r
+- print parsing words in bold\r
\r
+ nice to have libraries:\r
\r
! Copyright (C) 2004, 2005 Slava Pestov.
! See http://factor.sf.net/license.txt for BSD license.
IN: alien
-USING: hashtables kernel lists math namespaces parser io ;
+USING: hashtables io kernel kernel-internals lists math
+namespaces parser ;
DEFER: dll?
BUILTIN: dll 15 dll? [ 1 "dll-path" f ] ;
DEFER: displaced-alien?
BUILTIN: displaced-alien 20 displaced-alien? ;
+UNION: c-ptr byte-array alien displaced-alien ;
+
: NULL ( -- null )
#! C null value.
0 <alien> ;
[ emit ] each ;
: word-error ( word msg -- )
- [
- ,
- dup word-vocabulary ,
- " " ,
- word-name ,
- ] make-string throw ;
+ [ % dup word-vocabulary % " " % word-name % ] make-string
+ throw ;
: transfer-word ( word -- word )
#! This is a hack. See doc/bootstrap.txt.
[ "dlclose" "alien" [ [ dll ] [ ] ] ]
[ "<alien>" "alien" [ [ integer ] [ alien ] ] ]
[ "<byte-array>" "kernel-internals" [ [ integer ] [ byte-array ] ] ]
- [ "<displaced-alien>" "alien" [ [ integer object ] [ displaced-alien ] ] ]
- [ "alien-signed-cell" "alien" [ [ alien integer ] [ integer ] ] ]
- [ "set-alien-signed-cell" "alien" [ [ integer alien integer ] [ ] ] ]
- [ "alien-unsigned-cell" "alien" [ [ alien integer ] [ integer ] ] ]
- [ "set-alien-unsigned-cell" "alien" [ [ integer alien integer ] [ ] ] ]
- [ "alien-signed-8" "alien" [ [ alien integer ] [ integer ] ] ]
- [ "set-alien-signed-8" "alien" [ [ integer alien integer ] [ ] ] ]
- [ "alien-unsigned-8" "alien" [ [ alien integer ] [ integer ] ] ]
- [ "set-alien-unsigned-8" "alien" [ [ integer alien integer ] [ ] ] ]
- [ "alien-signed-4" "alien" [ [ alien integer ] [ integer ] ] ]
- [ "set-alien-signed-4" "alien" [ [ integer alien integer ] [ ] ] ]
- [ "alien-unsigned-4" "alien" [ [ alien integer ] [ integer ] ] ]
- [ "set-alien-unsigned-4" "alien" [ [ integer alien integer ] [ ] ] ]
- [ "alien-signed-2" "alien" [ [ alien integer ] [ integer ] ] ]
- [ "set-alien-signed-2" "alien" [ [ integer alien integer ] [ ] ] ]
- [ "alien-unsigned-2" "alien" [ [ alien integer ] [ integer ] ] ]
- [ "set-alien-unsigned-2" "alien" [ [ integer alien integer ] [ ] ] ]
- [ "alien-signed-1" "alien" [ [ alien integer ] [ integer ] ] ]
- [ "set-alien-signed-1" "alien" [ [ integer alien integer ] [ ] ] ]
- [ "alien-unsigned-1" "alien" [ [ alien integer ] [ integer ] ] ]
- [ "set-alien-unsigned-1" "alien" [ [ integer alien integer ] [ ] ] ]
- [ "alien-float" "alien" [ [ alien integer ] [ float ] ] ]
- [ "set-alien-float" "alien" [ [ float alien integer ] [ ] ] ]
- [ "alien-double" "alien" [ [ alien integer ] [ float ] ] ]
- [ "set-alien-double" "alien" [ [ float alien integer ] [ ] ] ]
- [ "alien-c-string" "alien" [ [ alien integer ] [ string ] ] ]
- [ "set-alien-c-string" "alien" [ [ string alien integer ] [ ] ] ]
+ [ "<displaced-alien>" "alien" [ [ integer c-ptr ] [ displaced-alien ] ] ]
+ [ "alien-signed-cell" "alien" [ [ c-ptr integer ] [ integer ] ] ]
+ [ "set-alien-signed-cell" "alien" [ [ integer c-ptr integer ] [ ] ] ]
+ [ "alien-unsigned-cell" "alien" [ [ c-ptr integer ] [ integer ] ] ]
+ [ "set-alien-unsigned-cell" "alien" [ [ integer c-ptr integer ] [ ] ] ]
+ [ "alien-signed-8" "alien" [ [ c-ptr integer ] [ integer ] ] ]
+ [ "set-alien-signed-8" "alien" [ [ integer c-ptr integer ] [ ] ] ]
+ [ "alien-unsigned-8" "alien" [ [ c-ptr integer ] [ integer ] ] ]
+ [ "set-alien-unsigned-8" "alien" [ [ integer c-ptr integer ] [ ] ] ]
+ [ "alien-signed-4" "alien" [ [ c-ptr integer ] [ integer ] ] ]
+ [ "set-alien-signed-4" "alien" [ [ integer c-ptr integer ] [ ] ] ]
+ [ "alien-unsigned-4" "alien" [ [ c-ptr integer ] [ integer ] ] ]
+ [ "set-alien-unsigned-4" "alien" [ [ integer c-ptr integer ] [ ] ] ]
+ [ "alien-signed-2" "alien" [ [ c-ptr integer ] [ integer ] ] ]
+ [ "set-alien-signed-2" "alien" [ [ integer c-ptr integer ] [ ] ] ]
+ [ "alien-unsigned-2" "alien" [ [ c-ptr integer ] [ integer ] ] ]
+ [ "set-alien-unsigned-2" "alien" [ [ integer c-ptr integer ] [ ] ] ]
+ [ "alien-signed-1" "alien" [ [ c-ptr integer ] [ integer ] ] ]
+ [ "set-alien-signed-1" "alien" [ [ integer c-ptr integer ] [ ] ] ]
+ [ "alien-unsigned-1" "alien" [ [ c-ptr integer ] [ integer ] ] ]
+ [ "set-alien-unsigned-1" "alien" [ [ integer c-ptr integer ] [ ] ] ]
+ [ "alien-float" "alien" [ [ c-ptr integer ] [ float ] ] ]
+ [ "set-alien-float" "alien" [ [ float c-ptr integer ] [ ] ] ]
+ [ "alien-double" "alien" [ [ c-ptr integer ] [ float ] ] ]
+ [ "set-alien-double" "alien" [ [ float c-ptr integer ] [ ] ] ]
+ [ "alien-c-string" "alien" [ [ c-ptr integer ] [ string ] ] ]
+ [ "set-alien-c-string" "alien" [ [ string c-ptr integer ] [ ] ] ]
[ "throw" "errors" [ [ object ] [ ] ] ]
[ "string>memory" "kernel-internals" [ [ string integer ] [ ] ] ]
[ "memory>string" "kernel-internals" [ [ integer integer ] [ string ] ] ]
: run-user-init ( -- )
#! Run user init file if it exists
- "user-init" get [
- [ "~" get , "/" , ".factor-" , "rc" , ] make-string
- ?run-file
- ] when ;
+ "user-init" get
+ [ "~" get "/.factor-rc" append ?run-file ] when ;
: set-path ( value list -- )
unswons over [ nest [ set-path ] bind ] [ nip set ] ifte ;
#! -no-<flag> CLI switch
"user-init" on
"compile" on
+ "null-stdio" off
os "win32" = "ui" "tty" ? "shell" set ;
: parse-command-line ( -- )
: unique, ( obj -- )
#! Add the object to the sequence being built with make-seq
#! unless an equal object has already been added.
- building get 2dup index -1 = [ push ] [ 2drop ] ifte ;
+ building get 2dup member? [ 2drop ] [ push ] ifte ;
: % ( seq -- )
#! Append to the sequence being built with make-seq.
: empty-sbuf ( len -- sbuf )
dup <sbuf> [ set-length ] keep ;
-: sbuf-append ( ch/str sbuf -- )
- over string? [ swap nappend ] [ push ] ifte ;
-
: fill ( count char -- string ) <repeated> >string ;
: padding ( string count char -- string )
>r word-name "-" r> append3 create-in ;
: writer-word ( class name -- word )
- [ swap "set-" , word-name , "-" , , ] make-string create-in ;
+ [ swap "set-" % word-name % "-" % % ] make-string create-in ;
: simple-slot ( class name -- [ reader writer ] )
[ reader-word ] 2keep writer-word 2list ;
#! Build a string that can evaluate the string 'to-eval'
#! by first doing an 'IN: vocab' and a 'USE:' of all
#! necessary vocabs for existing words in that vocab.
- [ >r "IN: " , dup , "\n" ,
- vocabulary-uses [ "USE: " , , "\n" , ] each
- r> , "\n" , ] make-string ;
+ [ >r "IN: " % dup % "\n" %
+ vocabulary-uses [ "USE: " % % "\n" % ] each
+ r> % "\n" % ] make-string ;
: show-parse-error ( error -- )
#! Show an error page describing the parse error.
#! URL which, when requested, will display the source to that
#! word.
[
- ".?word=" , url-encode ,
- "&vocab=" , url-encode ,
+ ".?word=" % url-encode %
+ "&vocab=" % url-encode %
] make-string ;
: browse ( <browser> -- )
: get-random-id ( -- id )
#! Generate a random id to use for continuation URL's
- [ 32 [ 0 9 random-int unparse , ] times ] make-string str>number 36 >base ;
+ [ 32 [ 0 9 random-int unparse % ] times ] make-string str>number 36 >base ;
#! Name of variable holding the table of continuations.
SYMBOL: table
#! HTTP 302 to occur to instruct the browser to forward to
#! the request URL.
[
- "HTTP/1.1 302 Document Moved\nLocation: " , ,
- "\nContent-Length: 0\nContent-Type: text/plain\n\n" ,
+ "HTTP/1.1 302 Document Moved\nLocation: " % %
+ "\nContent-Length: 0\nContent-Type: text/plain\n\n" %
] make-string call-exit-continuation ;
: redirect-to-here ( -- )
! <a href= "http://" swap append a> "click" write </a>
!
! (url -- )
-! <a href= [ "http://" , , ] make-string a> "click" write </a>
+! <a href= [ "http://" % % ] make-string a> "click" write </a>
!
! Tags that have no 'closing' equivalent have a trailing tag/> form:
!
#! Convert the attrs alist to a string
#! suitable for embedding in an html tag.
reverse [
- [ dup car , "='" , cdr , "'" , ] each
+ [ dup car % "='" % cdr % "'" % ] each
] make-string ;
: write-attributes ( n: namespace -- )
: def-for-html-word-</foo> ( name -- name quot )
#! Return the name and code for the </foo> patterned
#! word.
- [ "</" , , ">" , ] make-string dup [ write ] cons ;
+ [ "</" % % ">" % ] make-string dup [ write ] cons ;
: def-for-html-word-<foo/> ( name -- name quot )
#! Return the name and code for the <foo/> patterned
#! word.
- [ "<" , dup , "/>" , ] make-string swap
- [ "<" , , ">" , ] make-string
+ [ "<" % dup % "/>" % ] make-string swap
+ [ "<" % % ">" % ] make-string
[ write ] cons ;
: def-for-html-word-foo/> ( name -- name quot )
TUPLE: html-stream ;
+M: html-stream stream-write1 ( char stream -- )
+ [
+ dup html-entities assoc [ write ] [ write1 ] ?ifte
+ ] with-wrapper ;
+
M: html-stream stream-write-attr ( str style stream -- )
[
[
: infer-fail ( quot error -- )
"! " , dup string? [ unparse ] unless , "\n" ,
- [ [ infer ] cons . \ unit-test-fails . ] string-out , ;
+ [ [ infer ] cons . \ unit-test-fails . ] string-out % ;
: infer-pass ( quot effect -- )
- [ unit . [ infer ] cons . \ unit-test . ] string-out , ;
+ [ unit . [ infer ] cons . \ unit-test . ] string-out % ;
: infer>test ( quot -- str )
#! Make a string representing a unit test for the stack
: failing-class-and ( class class -- class )
2dup class-and dup null = [
-rot [
- word-name , " and " , word-name ,
- " do not intersect" ,
+ word-name % " and " % word-name %
+ " do not intersect" %
] make-string inference-warning
] [
2nip
TUPLE: c-stream in out flush? ;
+M: c-stream stream-write1 ( char stream -- )
+ >r ch>string r> c-stream-out fwrite ;
+
M: c-stream stream-write-attr ( str style stream -- )
nip >r dup string? [ ch>string ] unless r>
c-stream-out fwrite ;
M: duplex-stream stream-readln
duplex-stream-in stream-readln ;
+M: duplex-stream stream-read1
+ duplex-stream-in stream-read1 ;
+
M: duplex-stream stream-read
duplex-stream-in stream-read ;
-M: duplex-stream stream-read1
- duplex-stream-in stream-read1 ;
+M: duplex-stream stream-write1
+ duplex-stream-out stream-write1 ;
M: duplex-stream stream-write-attr
duplex-stream-out stream-write-attr ;
: read1 ( -- char ) stdio get stream-read1 ;
: read ( count -- string ) stdio get stream-read ;
: write ( string -- ) stdio get stream-write ;
+: write1 ( char -- ) stdio get stream-write1 ;
: write-attr ( string style -- ) stdio get stream-write-attr ;
: print ( string -- ) stdio get stream-print ;
: terpri ( -- ) "\n" write ;
GENERIC: stream-flush ( stream -- )
GENERIC: stream-auto-flush ( stream -- )
GENERIC: stream-readln ( stream -- string )
-GENERIC: stream-read ( count stream -- string )
GENERIC: stream-read1 ( stream -- char/f )
+GENERIC: stream-read ( count stream -- string )
+GENERIC: stream-write1 ( char stream -- )
GENERIC: stream-write-attr ( string style stream -- )
GENERIC: stream-close ( stream -- )
GENERIC: set-timeout ( timeout stream -- )
M: null-stream stream-readln drop f ;
M: null-stream stream-read 2drop f ;
M: null-stream stream-read1 drop f ;
+M: null-stream stream-write1 2drop ;
M: null-stream stream-write-attr 3drop ;
M: null-stream stream-close drop ;
: with-wrapper ( stream quot -- )
>r wrapper-stream-scope r> bind ;
-
-! Standard actions protocol for presentations output to
-! attributed streams.
-: <actions> ( path alist -- alist )
- #! For each element of the alist, change the value to
- #! path " " value
- [ uncons >r swap " " r> append3 cons ] map-with ;
USING: io kernel math namespaces sequences strings ;
! String buffers support the stream output protocol.
-M: sbuf stream-write-attr nip sbuf-append ;
+M: sbuf stream-write1 push ;
+
+M: sbuf stream-write-attr
+ nip over string? [ swap nappend ] [ push ] ifte ;
+
M: sbuf stream-close drop ;
M: sbuf stream-flush drop ;
M: sbuf stream-auto-flush drop ;
\ parsing prettyprint-prop
\ inline prettyprint-prop ;
-: comment-style
- #! Feel free to redefine this!
- [
- [[ "fg" [ 255 0 0 ] ]]
- [[ foreground [ 192 0 0 ] ]]
- ] ;
-
-: comment. ( comment -- ) comment-style write-attr ;
+: comment. ( comment -- )
+ [ [[ font-style italic ]] ] write-attr ;
: infer-effect. ( effect -- )
[
- "(" ,
- 2unlist >r [ " " , unparse , ] each r>
- " --" ,
- [ " " , unparse , ] each
- " )" ,
+ "(" %
+ 2unlist >r [ " " % unparse % ] each r>
+ " --" %
+ [ " " % unparse % ] each
+ " )" %
] make-string comment. ;
: stack-effect. ( word -- )
dup "stack-effect" word-prop [
- [ CHAR: ( , , CHAR: ) , ] make-string
+ [ CHAR: ( , % CHAR: ) , ] make-string
comment.
] [
"infer-effect" word-prop dup [
GENERIC: unparse ( obj -- str )
M: object unparse ( obj -- str )
- [
- "#<" ,
- dup class unparse ,
- " @ " ,
- address unparse ,
- ">" ,
- ] make-string ;
+ "( " swap class word-name " )" append3 ;
: >digit ( n -- ch )
dup 10 < [ CHAR: 0 + ] [ 10 - CHAR: a + ] ifte ;
M: ratio unparse ( num -- str )
[
dup
- numerator unparse ,
+ numerator unparse %
CHAR: / ,
- denominator unparse ,
+ denominator unparse %
] make-string ;
: fix-float ( str -- str )
M: complex unparse ( num -- str )
[
- "#{ " ,
+ "#{ " %
dup
- real unparse ,
- " " ,
- imaginary unparse ,
- " }#" ,
+ real unparse %
+ " " %
+ imaginary unparse %
+ " }#" %
] make-string ;
: ch>ascii-escape ( ch -- esc )
[ CHAR: " , unparse-string CHAR: " , ] make-string ;
M: sbuf unparse ( str -- str )
- [ "SBUF\" " , unparse-string CHAR: " , ] make-string ;
+ [ "SBUF\" " % unparse-string CHAR: " , ] make-string ;
-M: word unparse ( obj -- str ) word-name dup "#<unnamed>" ? ;
+M: word unparse ( obj -- str ) word-name dup "( unnamed )" ? ;
M: t unparse drop "t" ;
M: f unparse drop "f" ;
M: dll unparse ( obj -- str )
- [ "DLL\" " , dll-path unparse-string CHAR: " , ] make-string ;
+ [ "DLL\" " % dll-path unparse-string CHAR: " , ] make-string ;
: hex-string ( str -- str )
[ [ >hex 2 CHAR: 0 pad-left % ] each ] make-string ;
: string-step ( n str -- )
2dup length > [
- dup [ "123" , , "456" , , "789" , ] make-string
+ dup [ "123" % % "456" % % "789" % ] make-string
dup dup length 2 /i 0 swap rot subseq
swap dup length 2 /i 1 + 1 swap rot subseq append
string-step
#! execute it.
millis >r gc-time >r call gc-time r> - millis r> -
[
- unparse , " ms run / " , unparse , " ms GC time" ,
+ unparse % " ms run / " % unparse % " ms GC time" %
] make-string print ;
: unit-test ( output input -- )
: make-jedit-request ( files params -- code )
[
- "EditServer.handleClient(false,false,false,null," ,
- "new String[] {" ,
- [ unparse , "," , ] each
- "null});\n" ,
+ "EditServer.handleClient(false,false,false,null," %
+ "new String[] {" %
+ [ unparse % "," % ] each
+ "null});\n" %
] make-string ;
: send-jedit-request ( request -- )
: button-gestures ( button quot -- )
over f reverse-video set-paint-prop
+ over << solid f >> interior set-paint-prop
dupd [ action ] set-action
dup [ dup button-update button-clicked ] [ button-up 1 ] set-action
dup [ button-update ] [ button-down 1 ] set-action
dup editor-caret swap caret-loc swap set-shape-loc ;
M: editor draw-gadget* ( editor -- )
+ dup delegate draw-gadget*
dup editor-text draw-string ;
dup label-text label-size ;
M: label draw-gadget* ( label -- )
+ dup delegate draw-gadget*
dup label-text draw-string ;
M: pane stream-readln ( stream -- line )
[ over set-pane-continuation stop ] callcc1 nip ;
+M: pane stream-write1 ( string style stream -- )
+ [ rot ch>string unit pane-write ] keep scroll>bottom ;
+
M: pane stream-write-attr ( string style stream -- )
[ rot "\n" split pane-write ] keep scroll>bottom ;
M: write-task task-container drop write-tasks get ;
-: write-fin ( str writer -- )
- dup pending-error >buffer ;
-
: add-write-io-task ( callback task -- )
dup io-task-fd write-tasks get hash [
dup write-task? [
M: port stream-auto-flush ( stream -- ) drop ;
: wait-to-write ( len port -- )
- tuck can-write? [ drop ] [ stream-flush ] ifte ;
+ tuck can-write? [ dup stream-flush ] unless pending-error ;
+
+: blocking-write1 ( str writer -- )
+ 1 over wait-to-write >buffer ;
+
+M: port stream-write1 ( char writer -- )
+ nip >r dup string? [ ch>string ] unless r> blocking-write ;
: blocking-write ( str writer -- )
- over length over wait-to-write write-fin ;
+ over length over wait-to-write >buffer ;
M: port stream-write-attr ( string style writer -- )
nip >r dup string? [ ch>string ] unless r> blocking-write ;
: do-read-count ( sbuf count -- str )
dup 0 = [
- drop sbuf>string
+ drop >string
] [
dup consume-input
dup length dup 0 = [
3drop >string-or-f
] [
- >r swap r> - >r swap [ sbuf-append ] keep r> do-read-count
+ >r swap r> - >r swap [ swap nappend ] keep r> do-read-count
] ifte
] ifte ;
peek-input "\r" = [ 1 consume-input drop ] when
drop >string
] [
- over sbuf-append do-read-line
+ dupd nappend do-read-line
] ifte
] ifte
] ifte ;