Display help in browser tool
parent
44c090d0a7
commit
2620a10107
|
@ -129,12 +129,17 @@ HELP: $title
|
||||||
{ $values { "topic" "a help article name or a word" } }
|
{ $values { "topic" "a help article name or a word" } }
|
||||||
{ $description "Prints a help article's title, or a word's " { $link summary } ", depending on the type of " { $snippet "topic" } "." } ;
|
{ $description "Prints a help article's title, or a word's " { $link summary } ", depending on the type of " { $snippet "topic" } "." } ;
|
||||||
|
|
||||||
|
HELP: print-topic
|
||||||
|
{ $values { "topic" "an article name or a word" } }
|
||||||
|
{ $description
|
||||||
|
"Displays a help topic on " { $link output-stream } "."
|
||||||
|
} ;
|
||||||
|
|
||||||
HELP: help
|
HELP: help
|
||||||
{ $values { "topic" "an article name or a word" } }
|
{ $values { "topic" "an article name or a word" } }
|
||||||
{ $description
|
{ $description
|
||||||
"Displays a help article or documentation associated to a word on " { $link output-stream } "."
|
"Displays a help topic."
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
HELP: about
|
HELP: about
|
||||||
{ $values { "vocab" "a vocabulary specifier" } }
|
{ $values { "vocab" "a vocabulary specifier" } }
|
||||||
{ $description
|
{ $description
|
||||||
|
|
|
@ -89,10 +89,17 @@ M: word set-article-parent swap "help-parent" set-word-prop ;
|
||||||
] with-nesting
|
] with-nesting
|
||||||
] with-style nl ;
|
] with-style nl ;
|
||||||
|
|
||||||
: help ( topic -- )
|
: print-topic ( topic -- )
|
||||||
last-element off dup $title
|
last-element off dup $title
|
||||||
article-content print-content nl ;
|
article-content print-content nl ;
|
||||||
|
|
||||||
|
SYMBOL: help-hook
|
||||||
|
|
||||||
|
help-hook global [ [ print-topic ] or ] change-at
|
||||||
|
|
||||||
|
: help ( topic -- )
|
||||||
|
help-hook get call ;
|
||||||
|
|
||||||
: about ( vocab -- )
|
: about ( vocab -- )
|
||||||
dup require
|
dup require
|
||||||
dup vocab [ ] [
|
dup vocab [ ] [
|
||||||
|
|
|
@ -4,17 +4,17 @@ USING: debugger ui.tools.workspace help help.topics kernel
|
||||||
models models.history ui.commands ui.gadgets ui.gadgets.panes
|
models models.history ui.commands ui.gadgets ui.gadgets.panes
|
||||||
ui.gadgets.scrollers ui.gadgets.tracks ui.gestures
|
ui.gadgets.scrollers ui.gadgets.tracks ui.gestures
|
||||||
ui.gadgets.buttons compiler.units assocs words vocabs
|
ui.gadgets.buttons compiler.units assocs words vocabs
|
||||||
accessors ;
|
accessors fry combinators.short-circuit ;
|
||||||
IN: ui.tools.browser
|
IN: ui.tools.browser
|
||||||
|
|
||||||
TUPLE: browser-gadget < track pane history ;
|
TUPLE: browser-gadget < track pane history ;
|
||||||
|
|
||||||
: show-help ( link help -- )
|
: show-help ( link help -- )
|
||||||
dup history>> add-history
|
history>> dup add-history
|
||||||
>r >link r> history>> set-model ;
|
[ >link ] dip set-model ;
|
||||||
|
|
||||||
: <help-pane> ( browser-gadget -- gadget )
|
: <help-pane> ( browser-gadget -- gadget )
|
||||||
history>> [ [ help ] curry try ] <pane-control> ;
|
history>> [ '[ _ print-topic ] try ] <pane-control> ;
|
||||||
|
|
||||||
: init-history ( browser-gadget -- )
|
: init-history ( browser-gadget -- )
|
||||||
"handbook" >link <history> >>history drop ;
|
"handbook" >link <history> >>history drop ;
|
||||||
|
@ -22,7 +22,7 @@ TUPLE: browser-gadget < track pane history ;
|
||||||
: <browser-gadget> ( -- gadget )
|
: <browser-gadget> ( -- gadget )
|
||||||
{ 0 1 } browser-gadget new-track
|
{ 0 1 } browser-gadget new-track
|
||||||
dup init-history
|
dup init-history
|
||||||
dup <toolbar> f track-add
|
add-toolbar
|
||||||
dup <help-pane> >>pane
|
dup <help-pane> >>pane
|
||||||
dup pane>> <scroller> 1 track-add ;
|
dup pane>> <scroller> 1 track-add ;
|
||||||
|
|
||||||
|
@ -38,10 +38,11 @@ M: browser-gadget ungraft*
|
||||||
[ call-next-method ] [ remove-definition-observer ] bi ;
|
[ call-next-method ] [ remove-definition-observer ] bi ;
|
||||||
|
|
||||||
: showing-definition? ( defspec assoc -- ? )
|
: showing-definition? ( defspec assoc -- ? )
|
||||||
[ key? ] 2keep
|
{
|
||||||
[ >r dup word-link? [ name>> ] when r> key? ] 2keep
|
[ key? ]
|
||||||
>r dup vocab-link? [ vocab ] when r> key?
|
[ [ dup word-link? [ name>> ] when ] dip key? ]
|
||||||
or or ;
|
[ [ dup vocab-link? [ vocab ] when ] dip key? ]
|
||||||
|
} 2|| ;
|
||||||
|
|
||||||
M: browser-gadget definitions-changed ( assoc browser -- )
|
M: browser-gadget definitions-changed ( assoc browser -- )
|
||||||
history>>
|
history>>
|
||||||
|
|
Loading…
Reference in New Issue