Fix another race...

db4
Slava Pestov 2008-03-01 01:46:01 -06:00
parent 59872525fd
commit 5352ea14ff
5 changed files with 21 additions and 16 deletions

0
extra/ui/cocoa/tools/tools.factor Normal file → Executable file
View File

View File

@ -45,21 +45,20 @@ M: listener-gadget tool-scroller
listener-gadget-input interactor-flag wait-for-flag ; listener-gadget-input interactor-flag wait-for-flag ;
: workspace-busy? ( workspace -- ? ) : workspace-busy? ( workspace -- ? )
workspace-listener workspace-listener listener-gadget-input interactor-busy? ;
dup wait-for-listener
listener-gadget-input interactor-busy? ;
: get-listener ( -- listener )
[ workspace-busy? not ] get-workspace* workspace-listener ;
: listener-input ( string -- ) : listener-input ( string -- )
get-listener listener-gadget-input set-editor-string ; get-workspace
workspace-listener
listener-gadget-input set-editor-string ;
: (call-listener) ( quot listener -- ) : (call-listener) ( quot listener -- )
listener-gadget-input interactor-call ; listener-gadget-input interactor-call ;
: call-listener ( quot -- ) : call-listener ( quot -- )
get-listener (call-listener) ; [ workspace-busy? not ] get-workspace* workspace-listener
[ dup wait-for-listener (call-listener) ] 2curry
"Listener call" spawn drop ;
M: listener-command invoke-command ( target command -- ) M: listener-command invoke-command ( target command -- )
command-quot call-listener ; command-quot call-listener ;
@ -68,7 +67,8 @@ M: listener-operation invoke-command ( target command -- )
[ operation-hook call ] keep operation-quot call-listener ; [ operation-hook call ] keep operation-quot call-listener ;
: eval-listener ( string -- ) : eval-listener ( string -- )
get-listener get-workspace
workspace-listener
listener-gadget-input [ set-editor-string ] keep listener-gadget-input [ set-editor-string ] keep
evaluate-input ; evaluate-input ;
@ -96,7 +96,9 @@ M: listener-operation invoke-command ( target command -- )
[ drop ] [ [ "USE: " % % " " % % ] "" make ] if ; [ drop ] [ [ "USE: " % % " " % % ] "" make ] if ;
: insert-word ( word -- ) : insert-word ( word -- )
get-listener [ word-completion-string ] keep get-workspace
workspace-listener
[ word-completion-string ] keep
listener-gadget-input user-input ; listener-gadget-input user-input ;
: quot-action ( interactor -- lines ) : quot-action ( interactor -- lines )

View File

@ -111,7 +111,7 @@ ARTICLE: "ui-workspace-keys" "UI keyboard shortcuts"
{ $command-map workspace "scrolling" } { $command-map workspace "scrolling" }
{ $command-map workspace "workflow" } { $command-map workspace "workflow" }
{ $heading "Implementation" } { $heading "Implementation" }
"Workspaces are instances of " { $link workspace-window } "." ; "Workspaces are instances of " { $link workspace } "." ;
ARTICLE: "ui-tools" "UI development tools" ARTICLE: "ui-tools" "UI development tools"
"The Factor development environment can seem rather different from what you are used to, because it is very simple and powerful.." "The Factor development environment can seem rather different from what you are used to, because it is very simple and powerful.."

View File

@ -82,7 +82,7 @@ workspace "workflow" f {
} define-command-map } define-command-map
[ [
<workspace> "Factor workspace" open-status-window <workspace> dup "Factor workspace" open-status-window
] workspace-window-hook set-global ] workspace-window-hook set-global
: inspect-continuation ( traceback -- ) : inspect-continuation ( traceback -- )

View File

@ -14,9 +14,12 @@ TUPLE: workspace book listener popup ;
SYMBOL: workspace-window-hook SYMBOL: workspace-window-hook
: workspace-window ( -- workspace ) : workspace-window* ( -- workspace )
workspace-window-hook get call ; workspace-window-hook get call ;
: workspace-window ( -- )
workspace-window* drop ;
GENERIC: call-tool* ( arg tool -- ) GENERIC: call-tool* ( arg tool -- )
GENERIC: tool-scroller ( tool -- scroller ) GENERIC: tool-scroller ( tool -- scroller )
@ -33,9 +36,9 @@ M: gadget tool-scroller drop f ;
: select-tool ( workspace class -- ) swap show-tool drop ; : select-tool ( workspace class -- ) swap show-tool drop ;
: get-workspace* ( quot -- workspace ) : get-workspace* ( quot -- workspace )
[ dup workspace? [ over call ] [ drop f ] if ] find-window [ >r dup workspace? r> [ drop f ] if ] curry find-window
[ nip dup raise-window gadget-child ] [ dup raise-window gadget-child ]
[ workspace-window get-workspace* ] if* ; inline [ workspace-window* ] if* ; inline
: get-workspace ( -- workspace ) [ drop t ] get-workspace* ; : get-workspace ( -- workspace ) [ drop t ] get-workspace* ;