ui.tools.listener: tried to simplify stream-read-quot and handle-interactive

db4
Björn Lindqvist 2015-10-22 06:57:27 +02:00
parent 0795d21e46
commit d15c5bced4
1 changed files with 15 additions and 22 deletions

View File

@ -336,30 +336,23 @@ M: object accept-completion-hook 2drop ;
error-continuation get error-continuation get
debugger-popup ; debugger-popup ;
: try-parse ( lines interactor -- quot/error/f ) : try-parse ( lines -- quot/f/error )
[ drop parse-lines-interactive ] [ [ read-quot-step ] [ nip ] recover ;
2nip
dup lexer-error? [
dup error>> unexpected-eof? [ drop f ] when
] when
] recover ;
: handle-interactive ( lines interactor -- quot/f ? ) : handle-interactive ( interactor lines -- quot/f )
[ nip ] [ try-parse ] 2bi { try-parse dup quotation? [ nip ] [
{ [ dup quotation? ] [ nip t ] } dup not [ drop insert-newline ] [
{ [ dup not ] [ drop insert-newline f f ] } handle-parse-error
[ handle-parse-error f f ] ] if f
} cond ; ] if ;
M: interactor stream-read-quot M: interactor stream-read-quot ( stream -- quot/f )
[ interactor-yield ] keep { dup interactor-yield dup [ not ] [ callable? ] bi or
{ [ over not ] [ drop ] } [ nip ] [
{ [ over callable? ] [ drop ] } dupd handle-interactive dup quotation? [
[ swap interactor-finish
[ handle-interactive ] keep swap ] [ drop stream-read-quot ] if
[ interactor-finish ] [ nip stream-read-quot ] if ] if ;
]
} cond ;
: interactor-operation ( gesture interactor -- ? ) : interactor-operation ( gesture interactor -- ? )
[ token-model>> value>> ] keep word-at-caret [ token-model>> value>> ] keep word-at-caret