factor/library/ui/tools/help.factor

39 lines
1.2 KiB
Factor
Raw Normal View History

! Copyright (C) 2006 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
IN: gadgets-help
2006-07-06 18:08:14 -04:00
USING: gadgets gadgets-borders gadgets-buttons gadgets-frames
2006-08-27 19:02:16 -04:00
gadgets-panes gadgets-search gadgets-scrolling help kernel
models namespaces sequences gadgets-tracks ;
2006-08-31 22:36:31 -04:00
TUPLE: help-gadget history search ;
: show-help ( link help -- )
2006-07-01 16:07:10 -04:00
dup help-gadget-history add-history
2006-07-05 17:12:30 -04:00
help-gadget-history set-model ;
2006-06-29 03:54:30 -04:00
: go-home ( help -- ) "handbook" swap show-help ;
2006-08-24 18:23:48 -04:00
help-gadget {
2006-09-01 03:58:47 -04:00
{
"Help"
{ "Back" T{ key-down f { C+ } "b" } [ help-gadget-history go-back ] }
{ "Forward" T{ key-down f { C+ } "f" } [ help-gadget-history go-forward ] }
{ "Home" T{ key-down f { C+ } "h" } [ go-home ] }
}
2006-08-24 18:23:48 -04:00
} define-commands
2006-06-29 03:54:30 -04:00
: <help-pane> ( history -- gadget )
2006-07-01 16:07:10 -04:00
gadget get help-gadget-history [ help ] <pane-control> ;
2006-06-29 03:54:30 -04:00
: init-history ( help-gadget -- )
2006-08-26 14:30:58 -04:00
T{ link f "handbook" } <history>
swap set-help-gadget-history ;
C: help-gadget ( -- gadget )
dup init-history {
2006-08-31 22:36:31 -04:00
{ [ <help-pane> ] f [ <scroller> ] 4/5 }
{ [ [ search-help. ] <search-gadget> ] set-help-gadget-search f 1/5 }
2006-08-31 22:36:31 -04:00
} { 0 1 } make-track* ;
M: help-gadget focusable-child* help-gadget-search ;