factor/library/ui/tools/help.factor

57 lines
1.5 KiB
Factor
Raw Normal View History

! Copyright (C) 2006 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
IN: gadgets-help
USING: gadgets gadgets-panes gadgets-presentations
gadgets-scrolling gadgets-tabs gadgets-tiles gadgets-tracks help
2006-05-25 23:45:19 -04:00
io kernel sequences words ;
2006-05-26 02:44:31 -04:00
TUPLE: help-gadget showing history tabs ;
TUPLE: history pane seq ;
C: history ( -- gadget )
V{ } clone over set-history-seq
<pane> dup pick set-history-pane
<scroller> "History" f <tile> over set-gadget-delegate ;
: update-history ( history -- )
dup history-seq swap history-pane [
2006-05-26 02:44:31 -04:00
<reversed> [
[ article-title ] keep simple-object terpri
] each
] with-pane ;
2006-05-26 02:44:31 -04:00
: add-history ( help -- )
dup help-gadget-history swap help-gadget-showing dup
[ over history-seq push-new update-history ] [ 2drop ] if ;
C: help-gadget ( -- gadget )
{
{ [ <history> ] set-help-gadget-history 1/4 }
{ [ <tabs> ] set-help-gadget-tabs 3/4 }
} { 1 0 0 } make-track* ;
2006-05-26 02:44:31 -04:00
M: help-gadget gadget-title
"Help - " swap help-gadget-showing article-title append ;
2006-05-26 02:29:44 -04:00
: fancy-help ( article -- )
dup word? [
dup article-content { $definition } rot add add
] [
article-content
] if (help) ;
: show-help ( link help -- )
2006-05-26 02:44:31 -04:00
dup add-history [ set-help-gadget-showing ] 2keep
dup update-title {
{ "Article" [ fancy-help ] }
{ "Links in" [ links-in. ] }
} swap help-gadget-tabs set-pages ;
: help-tool
[ help-gadget? ]
[ <help-gadget> ]
[ show-help ] ;
2006-05-25 23:49:36 -04:00
M: link show-object ( link button -- ) help-tool call-tool ;