ui: the with-ui-running combinator can be removed

It was only used within the (with-ui) words which in turn were only
called by with-ui.
factor-shell
Björn Lindqvist 2018-01-29 07:18:39 +01:00
parent f0347b71cf
commit dd36f6ad57
6 changed files with 35 additions and 41 deletions

View File

@ -215,7 +215,6 @@ cocoa-startup-hook [
M: cocoa-ui-backend (with-ui)
"UI" assert.app [
[
init-clipboard
cocoa-startup-hook get call( -- )
start-ui
@ -223,7 +222,6 @@ M: cocoa-ui-backend (with-ui)
init-thread-timer
reset-thread-timer
NSApp -> run
] with-ui-running
] with-cocoa ;
cocoa-ui-backend ui-backend set-global

View File

@ -503,7 +503,6 @@ M:: gtk-ui-backend system-alert ( caption text -- )
] with-destructors ;
M: gtk-ui-backend (with-ui)
[
f f gtk_init
f f gtk_gl_init
load-icon
@ -511,8 +510,7 @@ M: gtk-ui-backend (with-ui)
start-ui
[
[ [ gtk_main ] with-timer ] with-event-loop
] with-destructors
] with-ui-running ;
] with-destructors ;
M: gtk-ui-backend stop-event-loop
gtk_main_quit ;

View File

@ -705,14 +705,12 @@ M: windows-ui-backend set-title ( string world -- )
[ [ hWnd>> WM_SETTEXT 0 ] dip alien-address SendMessage drop ] bi ;
M: windows-ui-backend (with-ui)
[
[
init-clipboard
init-win32-ui
start-ui
event-loop
] [ cleanup-win32-ui ] [ ] cleanup
] with-ui-running ;
] [ cleanup-win32-ui ] [ ] cleanup ;
M: windows-ui-backend beep ( -- )
0 MessageBeep drop ;

View File

@ -319,15 +319,13 @@ M: x11-handle flush-gl-context ( handle -- )
dpy get swap window>> glXSwapBuffers ;
M: x11-ui-backend (with-ui) ( quot -- )
[
f [
[
init-clipboard
start-ui
event-loop
] with-xim
] with-x
] with-ui-running ;
] with-x ;
M: x11-ui-backend beep ( -- )
dpy get 100 XBell drop ;

View File

@ -3,7 +3,6 @@ math.rectangles namespaces quotations sequences strings ui.backend
ui.gadgets ui.gadgets.books ui.gadgets.grids ui.gadgets.packs
ui.gadgets.private ui.gadgets.tracks ui.gadgets.worlds ui.private ui.text
vocabs.loader ;
IN: ui
HELP: close-window
@ -91,7 +90,10 @@ HELP: raise-window
HELP: with-ui
{ $values { "quot" { $quotation ( -- ) } } }
{ $description "Calls the quotation, starting the UI if necessary. If starting the UI is necessary, this word does not return and the UI will start after the quotation returns." }
{ $description
"Calls the quotation, starting the UI if necessary. If starting the UI is necessary, this word does not return and the UI will start after the quotation returns." $nl
"While the combinator is running, " { $link ui-running? } " can be used by user code to determine whether it is running in a UI context or not."
}
{ $notes "This word should be used in the " { $link POSTPONE: MAIN: } " word of an application that uses the UI in order for the vocabulary to work when run from either the UI listener (" { $snippet "\"my-app\" run" } ") and the command line (" { $snippet "./factor -run=my-app" } ")." }
{ $examples "The " { $vocab-link "hello-ui" } " vocabulary implements a simple UI application which uses this word." } ;

View File

@ -134,10 +134,6 @@ M: world ungraft*
SYMBOL: ui-running
: with-ui-running ( quot -- )
t ui-running set-global
[ f ui-running set-global ] [ ] cleanup ; inline
PRIVATE>
: find-windows ( quot: ( world -- ? ) -- seq )
@ -225,7 +221,11 @@ M: object resize-window 2drop ;
[ find-world [ dup pref-dim resize-window ] when* ] bi ;
: with-ui ( quot: ( -- ) -- )
ui-running? [ call( -- ) ] [ '[ init-ui @ ] (with-ui) ] if ;
ui-running? [ call( -- ) ] [
t ui-running set-global '[
[ init-ui @ ] (with-ui)
] [ f ui-running set-global ] [ ] cleanup
] if ;
HOOK: beep ui-backend ( -- )