Remove the ui word, and ui-hook kludge; with-ui is now the only way to start the UI. ui.tools vocabulary is now runnable

db4
Slava Pestov 2009-01-07 20:56:09 -06:00
parent 3c624f670b
commit 268b995116
11 changed files with 80 additions and 78 deletions

View File

@ -1,4 +1,4 @@
! Copyright (C) 2006, 2008 Slava Pestov.
! Copyright (C) 2006, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors math arrays assocs cocoa cocoa.application
command-line kernel memory namespaces cocoa.messages
@ -145,7 +145,7 @@ cocoa-init-hook global [
[ "MiniFactor.nib" load-nib install-app-delegate ] or
] change-at
M: cocoa-ui-backend ui
M: cocoa-ui-backend (with-ui)
"UI" assert.app [
[
init-clipboard
@ -160,4 +160,4 @@ M: cocoa-ui-backend ui
cocoa-ui-backend ui-backend set-global
[ running.app? "ui" "listener" ? ] main-vocab-hook set-global
[ running.app? "ui.tools" "listener" ? ] main-vocab-hook set-global

View File

@ -2,7 +2,9 @@ USING: help.markup help.syntax ui.commands ;
IN: ui.tools.browser
ARTICLE: "ui-browser" "UI browser"
"The browser is used to display Factor code, documentation, and vocabularies."
"The browser is used to display Factor code, documentation, and vocabularies. The browser is opened when a word or articlelink presentation is clicked. It can also be opened using words:"
{ $subsection com-follow }
{ $subsection browser-window }
{ $command-map browser-gadget "toolbar" }
{ $command-map browser-gadget "scrolling" }
{ $command-map browser-gadget "multi-touch" }

View File

@ -2,14 +2,7 @@ USING: help.markup help.syntax ui.commands ui.gadgets.slots
ui.gadgets.editors ;
IN: ui.tools.inspector
ARTICLE: "ui-inspector" "UI inspector"
"The graphical inspector provides functionality similar to the terminal inspector (see " { $link "inspector" } "), adding in-place editing of slot values."
$nl
"To display an object in the UI inspector, right-click a presentation and choose " { $strong "Inspector" } " from the menu that appears."
$nl
"The inspector embeds a table gadget, which supports keyboard navigation; see " { $link "ui.gadgets.tables" } ". It also provides a few other commands:"
{ $command-map inspector-gadget "toolbar" }
{ $command-map inspector-gadget "multi-touch" }
ARTICLE: "ui-inspector-edit" "Editing slot values in the inspector"
"Slot values can be edited in the inspector. Clicking the ellipsis to the left of the slot's textual representation displays a slot editor gadget. A text representation of the object can be edited in the slot editor. The parser is used to turn the text representation back into an object. Keep in mind that some structure is lost in the conversion; see " { $link "prettyprint-limitations" } "."
$nl
"The slot editor's text editing commands are standard; see " { $link "gadgets-editors" } "."
@ -19,4 +12,15 @@ $nl
"The following commands are also available."
{ $command-map source-editor "word" } ;
ARTICLE: "ui-inspector" "UI inspector"
"The graphical inspector provides functionality similar to the terminal inspector (see " { $link "inspector" } "), adding in-place editing of slot values."
$nl
"To display an object in the UI inspector, right-click a presentation and choose " { $strong "Inspector" } " from the menu that appears. The inspector can also be opened from the listener using a word:"
{ $subsection inspector }
"The inspector embeds a table gadget, which supports keyboard navigation; see " { $link "ui.gadgets.tables" } ". It also provides a few other commands:"
{ $command-map inspector-gadget "toolbar" }
{ $command-map inspector-gadget "multi-touch" }
"The UI inspector is an instance of " { $link inspector-gadget } "."
{ $subsection "ui-inspector-edit" } ;
ABOUT: "ui-inspector"

View File

@ -9,15 +9,21 @@ $nl
$nl
"Interactors implement the " { $link stream-readln } ", " { $link stream-read } " and " { $link read-quot } " generic words." } ;
ARTICLE: "ui-listener-completion" "Word and vocabulary completion"
"The listener is great"
;
ARTICLE: "ui-listener" "UI listener"
"The graphical listener is based around the terminal listener (" { $link "listener" } ") and adds the following features:"
{ $list
"Input history"
{ "Completion (see " { $link "ui-completion" } ")" }
{ "Completion (see " { $link "ui-listener-completion" } ")" }
{ "Clickable presentations (see " { $link "ui-presentations" } ")" }
}
{ $command-map listener-gadget "toolbar" }
{ $command-map listener-gadget "scrolling" }
{ $command-map listener-gadget "workflow" }
{ $command-map listener-gadget "multi-touch" }
{ $command-map interactor "interactor" }
{ $command-map source-editor "word" }
{ $command-map interactor "quotation" }

View File

@ -192,7 +192,7 @@ M: listener-gadget focusable-child*
dup "Listener" open-status-window ;
: listener-window ( -- )
listener-window* drop ;
[ listener-window* drop ] with-ui ;
: (get-listener) ( quot -- listener )
find-window

View File

@ -7,6 +7,16 @@ ui.tools.listener ui.tools.operations ui.tools.profiler
ui.tools.walker vocabs ;
IN: ui.tools
ARTICLE: "starting-ui-tools" "Starting the UI tools"
"The UI tools start automatically where possible:"
{ $list
{ "On Windows, the tools start when the Factor executable is run." }
{ "On X11, the tools start if the " { $snippet "DISPLAY" } " environment variable is set." }
{ "On Mac OS X, the tools start if the " { $snippet "Factor.app" } " application bundle is run." }
}
"In all cases, passing the " { $snippet "-run=listener" } " command line switch starts the terminal listener instead. The UI can be started from the terminal by issuing the following command:"
{ $code "USE: threads" "[ \"ui.tools\" run ] in-thread" } ;
ARTICLE: "ui-presentations" "Presentations in the UI"
"A " { $emphasis "presentation" } " is a graphical view of an object which is directly linked to the object in some way. The help article links you see in the documentation browser are presentations; and if you " { $link see } " a word in the UI listener, all words in the definition will themselves be presentations."
$nl
@ -26,7 +36,8 @@ $nl
"Clicking on a vocabulary in the vocabulary list narrows down the word list to only include words from that vocabulary. The sorting options control the order of elements in the vocabulary and word lists. The search fields narrow down the list to only include words or vocabularies whose names contain a substring."
$nl
"Consult " { $link "profiling" } " for details about the profiler itself."
{ $command-map profiler-gadget "toolbar" } ;
{ $command-map profiler-gadget "toolbar" }
"The profiler is an instance of " { $link profiler-gadget } "." ;
ARTICLE: "ui-cocoa" "Functionality specific to Mac OS X"
"On Mac OS X, the Factor UI offers additional features which integrate with this operating system."
@ -40,9 +51,9 @@ $nl
;
ARTICLE: "ui-tools" "UI developer tools"
"The Factor development environment can seem rather different from what you are used to, because it is very simple and powerful.."
"The " { $vocab-link "ui.tools" } " vocabulary hierarchy implements a collection of simple developer tools."
$nl
"To take full advantage of the UI, you should be using a supported text editor. See " { $link "editor" } "."
"To take full advantage of the UI tools, you should be using a supported text editor. See " { $link "editor" } "."
{ $subsection "ui-presentations" }
{ $subsection "ui-listener" }
{ $subsection "ui-browser" }

View File

@ -1,6 +1,9 @@
! Copyright (C) 2006, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: ui.tools.operations ui.tools.listener ui namespaces ;
USING: ui.tools.operations ui.tools.listener ui kernel ;
IN: ui.tools
[ listener-window ] ui-hook set-global
: main ( -- )
restore-windows? [ restore-windows ] [ listener-window ] if ;
MAIN: main

View File

@ -36,8 +36,10 @@ HELP: unregister-window
{ $description "Removes a window from the global " { $link windows } " variable." }
{ $notes "This word should only be called only by the UI backend, and not user code." } ;
HELP: ui
{ $description "Starts the Factor UI." } ;
HELP: (with-ui)
{ $values { "quot" quotation } }
{ $contract "Starts the Factor UI." }
{ $notes "This is a low-level word; user code should call " { $link with-ui } " instead." } ;
HELP: start-ui
{ $description "Called by the UI backend to initialize the platform-independent parts of UI. This word should be called after the backend is ready to start displaying new windows, and before the event loop starts." } ;
@ -132,7 +134,7 @@ ARTICLE: "ui-backend" "Developing UI backends"
"UI backends may implement the " { $link "clipboard-protocol" } "." ;
ARTICLE: "ui-backend-init" "UI initialization and the event loop"
"An UI backend is required to define a method on the " { $link ui } " word. This word should contain backend initialization, together with some boilerplate:"
"An UI backend is required to define a method on the " { $link (with-ui) } " word. This word should contain backend initialization, together with some boilerplate:"
{ $code
"IN: shells"
""
@ -144,7 +146,7 @@ ARTICLE: "ui-backend-init" "UI initialization and the event loop"
}
"The above word must call the following:"
{ $subsection start-ui }
"The " { $link ui } " word must not return until the event loop has stopped and the UI has been shut down." ;
"The " { $link (with-ui) } " word must not return until the event loop has stopped and the UI has been shut down." ;
ARTICLE: "ui-backend-windows" "UI backend window management"
"The high-level " { $link open-window } " word eventually calls a low-level word which you must implement:"
@ -236,16 +238,6 @@ $nl
{ $see-also "ui-layout-impl" } ;
ARTICLE: "starting-ui" "Starting the UI"
"The UI starts automatically where possible:"
{ $list
{ "On Windows, the UI starts when the Factor executable is run." }
{ "On X11, the UI starts if the " { $snippet "DISPLAY" } " environment variable is set." }
{ "On Mac OS X, the UI starts if the " { $snippet "Factor.app" } " application bundle is run." }
}
"In all cases, passing the " { $snippet "-run=listener" } " command line switch starts the terminal listener instead. The UI can be started from the terminal listener using a word:"
{ $subsection ui }
"To run the terminal listener and the UI simultaneously, start the UI in a new thread:"
{ $code "USING: threads ui ;" "[ ui ] in-thread" }
"The main word of a vocabulary implementing a UI application should use a combinator to ensure that the application works when run from the command line as well as in the UI listener:"
{ $subsection with-ui } ;

View File

@ -1,10 +1,10 @@
! Copyright (C) 2006, 2008 Slava Pestov.
! Copyright (C) 2006, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: arrays assocs io kernel math models namespaces make
dlists deques sequences threads sequences words ui.gadgets
ui.gadgets.worlds ui.gadgets.tracks ui.gestures ui.backend
ui.render continuations init combinators hashtables
concurrency.flags sets accessors calendar ;
dlists deques sequences threads sequences words continuations
init combinators hashtables concurrency.flags sets accessors
calendar fry ui.gadgets ui.gadgets.worlds ui.gadgets.tracks
ui.gestures ui.backend ui.render ;
IN: ui
! Assoc mapping aliens to gadgets
@ -73,8 +73,6 @@ M: world ungraft*
windows get values
[ gadget-child swap call ] with find-last nip ; inline
SYMBOL: ui-hook
: init-ui ( -- )
<dlist> \ graft-queue set-global
<dlist> \ layout-queue set-global
@ -96,14 +94,6 @@ SYMBOL: ui-hook
: restore-world ( world -- )
dup reset-world restore-gadget ;
: restore-windows ( -- )
windows get [ values ] keep delete-all
[ restore-world ] each
forget-rollover ;
: restore-windows? ( -- ? )
windows get empty? not ;
: update-hand ( world -- )
dup hand-world get-global eq?
[ hand-loc get-global swap move-hand ] [ drop ] if ;
@ -181,30 +171,25 @@ HOOK: close-window ui-backend ( gadget -- )
M: object close-window
find-world [ ungraft ] when* ;
: start-ui ( -- )
restore-windows? [
restore-windows
] [
init-ui ui-hook get call
] if
notify-ui-thread start-ui-thread ;
: start-ui ( quot -- )
call notify-ui-thread start-ui-thread ;
[
f \ ui-running set-global
<flag> ui-notify-flag set-global
] "ui" add-init-hook
HOOK: ui ui-backend ( -- )
HOOK: (with-ui) ui-backend ( quot -- )
MAIN: ui
: restore-windows ( -- )
[
windows get [ values ] [ delete-all ] bi
[ restore-world ] each
forget-rollover
] (with-ui) ;
: restore-windows? ( -- ? )
windows get empty? not ;
: with-ui ( quot -- )
ui-running? [
call
] [
f windows set-global
[
ui-hook set
ui
] with-scope
] if ;
ui-running? [ call ] [ '[ init-ui @ ] (with-ui) ] if ;

View File

@ -1,5 +1,5 @@
! Copyright (C) 2005, 2006 Doug Coleman.
! Portions copyright (C) 2007, 2008 Slava Pestov.
! Portions copyright (C) 2007, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.c-types alien.strings arrays assocs ui
ui.gadgets ui.backend ui.clipboards ui.gadgets.worlds
@ -540,6 +540,7 @@ M: win-base flush-gl-context ( handle -- )
M: windows-ui-backend (open-offscreen-buffer) ( world -- )
dup dim>> setup-offscreen-gl <win-offscreen>
>>handle drop ;
M: windows-ui-backend (close-offscreen-buffer) ( handle -- )
[ hDC>> DeleteDC drop ]
[ hBitmap>> DeleteObject drop ] bi ;
@ -560,18 +561,16 @@ M: windows-ui-backend offscreen-pixels ( world -- alien w h )
[ (opaque-pixels) ] [ dim>> first2 ] bi ;
M: windows-ui-backend raise-window* ( world -- )
handle>> [
hWnd>> SetFocus drop
] when* ;
handle>> [ hWnd>> SetFocus drop ] when* ;
M: windows-ui-backend set-title ( string world -- )
handle>>
dup title>> [ free ] when*
[ utf16n malloc-string ] dip
2dup (>>title)
hWnd>> WM_SETTEXT 0 roll alien-address SendMessage drop ;
swap utf16n malloc-string
[ >>title ]
[ [ hWnd>> WM_SETTEXT 0 ] dip alien-address SendMessage drop ] bi ;
M: windows-ui-backend ui
M: windows-ui-backend (with-ui)
[
[
init-clipboard
@ -586,4 +585,4 @@ M: windows-ui-backend beep ( -- )
windows-ui-backend ui-backend set-global
[ "ui" ] main-vocab-hook set-global
[ "ui.tools" ] main-vocab-hook set-global

View File

@ -1,4 +1,4 @@
! Copyright (C) 2005, 2008 Eduardo Cavazos and Slava Pestov
! Copyright (C) 2005, 2009 Eduardo Cavazos and Slava Pestov
! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien alien.c-types arrays ui ui.gadgets
ui.gestures ui.backend ui.clipboards ui.gadgets.worlds ui.render
@ -277,7 +277,7 @@ M: x11-ui-backend (close-offscreen-buffer) ( handle -- )
M: x11-ui-backend offscreen-pixels ( world -- alien w h )
[ [ dim>> ] [ handle>> pixmap>> ] bi pixmap-bits ] [ dim>> first2 ] bi ;
M: x11-ui-backend ui ( -- )
M: x11-ui-backend (with-ui) ( quot -- )
[
f [
[
@ -293,5 +293,5 @@ M: x11-ui-backend beep ( -- )
x11-ui-backend ui-backend set-global
[ "DISPLAY" os-env "ui" "listener" ? ]
[ "DISPLAY" os-env "ui.tools" "listener" ? ]
main-vocab-hook set-global