interactor-busy? flag added
parent
a891cb2c08
commit
e30871f4a5
|
@ -1,10 +1,5 @@
|
||||||
+ 0.84:
|
+ 0.84:
|
||||||
|
|
||||||
+ remaining walker tasks:
|
|
||||||
- <input> handled by walker itself
|
|
||||||
- ^W in interactor
|
|
||||||
- ^I in interactor
|
|
||||||
|
|
||||||
- windows native i/o
|
- windows native i/o
|
||||||
- fix contribs: parser-combinators, boids, automata, space-invaders
|
- fix contribs: parser-combinators, boids, automata, space-invaders
|
||||||
- unix i/o: problems with passing f to syscalls
|
- unix i/o: problems with passing f to syscalls
|
||||||
|
@ -22,8 +17,6 @@
|
||||||
- services do not launch if factor not running
|
- services do not launch if factor not running
|
||||||
- integrated error documentation
|
- integrated error documentation
|
||||||
- roundoff is still not quite right with tracks
|
- roundoff is still not quite right with tracks
|
||||||
- 'show' doesn't work if invoked from a listener on an object which is
|
|
||||||
itself inspected in the listener
|
|
||||||
- fix top level window positioning
|
- fix top level window positioning
|
||||||
- nasty inference regressions
|
- nasty inference regressions
|
||||||
- [ [ dup call ] dup call ] infer hangs
|
- [ [ dup call ] dup call ] infer hangs
|
||||||
|
@ -56,6 +49,12 @@
|
||||||
|
|
||||||
+ ui:
|
+ ui:
|
||||||
|
|
||||||
|
- remaining walker tasks:
|
||||||
|
- <input> handled by walker itself
|
||||||
|
- ^W in interactor
|
||||||
|
- ^I in interactor
|
||||||
|
- error handling is still screwy
|
||||||
|
- continuation handling is also screwy
|
||||||
- add-gadget, model-changed, set-model should compile
|
- add-gadget, model-changed, set-model should compile
|
||||||
- shortcuts:
|
- shortcuts:
|
||||||
- find a listener
|
- find a listener
|
||||||
|
|
|
@ -9,7 +9,10 @@ namespaces queues sequences vectors ;
|
||||||
|
|
||||||
: run-queue ( -- queue ) \ run-queue get-global ;
|
: run-queue ( -- queue ) \ run-queue get-global ;
|
||||||
|
|
||||||
: schedule-thread ( continuation -- ) run-queue enque ;
|
: schedule-thread ( continuation0 -- ) run-queue enque ;
|
||||||
|
|
||||||
|
: schedule-thread-with ( obj continuation1 -- )
|
||||||
|
2array schedule-thread ;
|
||||||
|
|
||||||
: sleep-queue ( -- vec ) \ sleep-queue get-global ;
|
: sleep-queue ( -- vec ) \ sleep-queue get-global ;
|
||||||
|
|
||||||
|
@ -19,7 +22,9 @@ namespaces queues sequences vectors ;
|
||||||
: sleep-time ( sorted-queue -- ms )
|
: sleep-time ( sorted-queue -- ms )
|
||||||
dup empty? [ drop 1000 ] [ peek first millis [-] ] if ;
|
dup empty? [ drop 1000 ] [ peek first millis [-] ] if ;
|
||||||
|
|
||||||
: stop ( -- ) run-queue deque continue ;
|
: stop ( -- )
|
||||||
|
run-queue deque dup array?
|
||||||
|
[ first2 continue-with ] [ continue ] if ;
|
||||||
|
|
||||||
: yield ( -- ) [ schedule-thread stop ] callcc0 ;
|
: yield ( -- ) [ schedule-thread stop ] callcc0 ;
|
||||||
|
|
||||||
|
|
|
@ -105,7 +105,7 @@ SYMBOL: callframe-end
|
||||||
: restore-harness ( obj -- )
|
: restore-harness ( obj -- )
|
||||||
dup array? [
|
dup array? [
|
||||||
init-meta-interp [ ] (meta-call)
|
init-meta-interp [ ] (meta-call)
|
||||||
[ first2 continue-with ] in-thread drop
|
first2 schedule-thread-with
|
||||||
] [
|
] [
|
||||||
set-meta-interp
|
set-meta-interp
|
||||||
] if ;
|
] if ;
|
||||||
|
|
|
@ -1,29 +1,36 @@
|
||||||
! Copyright (C) 2006 Slava Pestov.
|
! Copyright (C) 2006 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
IN: gadgets-text
|
IN: gadgets-text
|
||||||
USING: gadgets gadgets-controls gadgets-panes hashtables help io
|
USING: gadgets gadgets-controls gadgets-panes generic hashtables
|
||||||
kernel namespaces prettyprint styles threads ;
|
help io kernel namespaces prettyprint styles threads ;
|
||||||
|
|
||||||
TUPLE: interactor output continuation ;
|
TUPLE: interactor output continuation busy? ;
|
||||||
|
|
||||||
C: interactor ( output -- gadget )
|
C: interactor ( output -- gadget )
|
||||||
[ set-interactor-output ] keep
|
[ set-interactor-output ] keep
|
||||||
f <field> over set-gadget-delegate
|
f <field> over set-gadget-delegate
|
||||||
dup dup set-control-self ;
|
dup dup set-control-self ;
|
||||||
|
|
||||||
: interactor-eval ( string gadget -- )
|
M: interactor graft* ( interactor -- )
|
||||||
interactor-continuation dup
|
f over set-interactor-busy? delegate graft* ;
|
||||||
[ [ continue-with ] in-thread ] when 2drop ;
|
|
||||||
|
: interactor-eval ( string interactor -- )
|
||||||
|
t over set-interactor-busy?
|
||||||
|
interactor-continuation schedule-thread-with ;
|
||||||
|
|
||||||
SYMBOL: structured-input
|
SYMBOL: structured-input
|
||||||
|
|
||||||
: interactor-call ( quot gadget -- )
|
: interactor-call ( quot gadget -- )
|
||||||
dup interactor-output [
|
dup interactor-busy? [
|
||||||
"Command: " write over short.
|
2drop
|
||||||
] with-stream*
|
] [
|
||||||
>r structured-input set-global
|
dup interactor-output [
|
||||||
"\"structured-input\" \"gadgets-text\" lookup get-global call"
|
"Command: " write over short.
|
||||||
r> interactor-eval ;
|
] with-stream*
|
||||||
|
>r structured-input set-global
|
||||||
|
"\"structured-input\" \"gadgets-text\" lookup get-global call"
|
||||||
|
r> interactor-eval
|
||||||
|
] if ;
|
||||||
|
|
||||||
: print-input ( string interactor -- )
|
: print-input ( string interactor -- )
|
||||||
interactor-output [
|
interactor-output [
|
||||||
|
@ -33,10 +40,14 @@ SYMBOL: structured-input
|
||||||
] with-style
|
] with-style
|
||||||
] with-stream* ;
|
] with-stream* ;
|
||||||
|
|
||||||
: interactor-commit ( gadget -- )
|
: interactor-commit ( interactor -- )
|
||||||
dup field-commit
|
dup interactor-busy? [
|
||||||
over control-model clear-doc
|
drop
|
||||||
swap 2dup print-input interactor-eval ;
|
] [
|
||||||
|
dup field-commit
|
||||||
|
over control-model clear-doc
|
||||||
|
swap 2dup print-input interactor-eval
|
||||||
|
] if ;
|
||||||
|
|
||||||
interactor H{
|
interactor H{
|
||||||
{ T{ key-down f f "RETURN" } [ interactor-commit ] }
|
{ T{ key-down f f "RETURN" } [ interactor-commit ] }
|
||||||
|
@ -44,5 +55,6 @@ interactor H{
|
||||||
{ T{ key-down f { C+ } "d" } [ f swap interactor-eval ] }
|
{ T{ key-down f { C+ } "d" } [ f swap interactor-eval ] }
|
||||||
} set-gestures
|
} set-gestures
|
||||||
|
|
||||||
M: interactor stream-readln ( pane -- line )
|
M: interactor stream-readln ( interactor -- line )
|
||||||
|
f over set-interactor-busy?
|
||||||
[ over set-interactor-continuation stop ] callcc1 nip ;
|
[ over set-interactor-continuation stop ] callcc1 nip ;
|
||||||
|
|
|
@ -62,8 +62,15 @@ M: listener-gadget gadget-title drop "Listener" <model> ;
|
||||||
listener-gadget-input over quotation?
|
listener-gadget-input over quotation?
|
||||||
[ interactor-call ] [ set-editor-text ] if ;
|
[ interactor-call ] [ set-editor-text ] if ;
|
||||||
|
|
||||||
|
: listener-available? ( gadget -- ? )
|
||||||
|
dup listener-gadget? [
|
||||||
|
listener-gadget-input interactor-busy? not
|
||||||
|
] [
|
||||||
|
drop f
|
||||||
|
] if ;
|
||||||
|
|
||||||
: listener-tool
|
: listener-tool
|
||||||
[ listener-gadget? ]
|
[ listener-available? ]
|
||||||
[ <listener-gadget> ]
|
[ <listener-gadget> ]
|
||||||
[ call-listener ] ;
|
[ call-listener ] ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue