From 2620a101071c345c329e868da316ad362a45170e Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 20 Nov 2008 20:34:49 -0600 Subject: [PATCH] Display help in browser tool --- basis/help/help-docs.factor | 9 +++++++-- basis/help/help.factor | 9 ++++++++- basis/ui/tools/browser/browser.factor | 19 ++++++++++--------- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/basis/help/help-docs.factor b/basis/help/help-docs.factor index 277d965e39..4a06235c69 100644 --- a/basis/help/help-docs.factor +++ b/basis/help/help-docs.factor @@ -129,12 +129,17 @@ HELP: $title { $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" } "." } ; +HELP: print-topic +{ $values { "topic" "an article name or a word" } } +{ $description + "Displays a help topic on " { $link output-stream } "." +} ; + HELP: help { $values { "topic" "an article name or a word" } } { $description - "Displays a help article or documentation associated to a word on " { $link output-stream } "." + "Displays a help topic." } ; - HELP: about { $values { "vocab" "a vocabulary specifier" } } { $description diff --git a/basis/help/help.factor b/basis/help/help.factor index 686578f1b6..f9775e2668 100644 --- a/basis/help/help.factor +++ b/basis/help/help.factor @@ -89,10 +89,17 @@ M: word set-article-parent swap "help-parent" set-word-prop ; ] with-nesting ] with-style nl ; -: help ( topic -- ) +: print-topic ( topic -- ) last-element off dup $title article-content print-content nl ; +SYMBOL: help-hook + +help-hook global [ [ print-topic ] or ] change-at + +: help ( topic -- ) + help-hook get call ; + : about ( vocab -- ) dup require dup vocab [ ] [ diff --git a/basis/ui/tools/browser/browser.factor b/basis/ui/tools/browser/browser.factor index 83a3b7ff68..b717bbb2f9 100644 --- a/basis/ui/tools/browser/browser.factor +++ b/basis/ui/tools/browser/browser.factor @@ -4,17 +4,17 @@ USING: debugger ui.tools.workspace help help.topics kernel models models.history ui.commands ui.gadgets ui.gadgets.panes ui.gadgets.scrollers ui.gadgets.tracks ui.gestures ui.gadgets.buttons compiler.units assocs words vocabs -accessors ; +accessors fry combinators.short-circuit ; IN: ui.tools.browser TUPLE: browser-gadget < track pane history ; : show-help ( link help -- ) - dup history>> add-history - >r >link r> history>> set-model ; + history>> dup add-history + [ >link ] dip set-model ; : ( browser-gadget -- gadget ) - history>> [ [ help ] curry try ] ; + history>> [ '[ _ print-topic ] try ] ; : init-history ( browser-gadget -- ) "handbook" >link >>history drop ; @@ -22,7 +22,7 @@ TUPLE: browser-gadget < track pane history ; : ( -- gadget ) { 0 1 } browser-gadget new-track dup init-history - dup f track-add + add-toolbar dup >>pane dup pane>> 1 track-add ; @@ -38,10 +38,11 @@ M: browser-gadget ungraft* [ call-next-method ] [ remove-definition-observer ] bi ; : showing-definition? ( defspec assoc -- ? ) - [ key? ] 2keep - [ >r dup word-link? [ name>> ] when r> key? ] 2keep - >r dup vocab-link? [ vocab ] when r> key? - or or ; + { + [ key? ] + [ [ dup word-link? [ name>> ] when ] dip key? ] + [ [ dup vocab-link? [ vocab ] when ] dip key? ] + } 2|| ; M: browser-gadget definitions-changed ( assoc browser -- ) history>>