2006-03-24 13:19:14 -05:00
|
|
|
! Copyright (C) 2005, 2006 Slava Pestov.
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2005-12-01 00:53:12 -05:00
|
|
|
IN: help
|
2006-06-06 15:54:07 -04:00
|
|
|
USING: arrays errors hashtables io kernel namespaces sequences
|
|
|
|
strings ;
|
2006-03-27 03:10:58 -05:00
|
|
|
|
|
|
|
! Markup
|
|
|
|
GENERIC: print-element
|
|
|
|
|
2006-06-16 23:12:40 -04:00
|
|
|
DEFER: $title
|
|
|
|
|
2006-03-27 03:10:58 -05:00
|
|
|
! Help articles
|
|
|
|
SYMBOL: articles
|
|
|
|
|
|
|
|
TUPLE: article title content ;
|
|
|
|
|
2006-06-06 15:54:07 -04:00
|
|
|
: article ( name -- article )
|
|
|
|
dup articles get hash
|
|
|
|
[ ] [ "No such article: " swap append throw ] ?if ;
|
2006-03-27 03:10:58 -05:00
|
|
|
|
|
|
|
: add-article ( name title element -- )
|
|
|
|
<article> swap articles get set-hash ;
|
|
|
|
|
|
|
|
M: string article-title article article-title ;
|
|
|
|
M: string article-content article article-content ;
|
|
|
|
|
|
|
|
! Special case: f help
|
|
|
|
M: f article-title drop \ f article-title ;
|
|
|
|
M: f article-content drop \ f article-content ;
|
|
|
|
|
2006-01-21 02:37:39 -05:00
|
|
|
SYMBOL: last-block
|
2005-12-01 00:53:12 -05:00
|
|
|
|
2006-06-16 23:12:40 -04:00
|
|
|
: print-title ( article -- )
|
|
|
|
article-title $title ;
|
|
|
|
|
|
|
|
: with-default-style ( quot -- )
|
|
|
|
default-char-style [
|
|
|
|
default-para-style [ last-block on call ] with-nesting
|
|
|
|
] with-style ; inline
|
|
|
|
|
|
|
|
: print-content ( element -- )
|
|
|
|
[ print-element ] with-default-style ;
|
|
|
|
|
|
|
|
: (help) ( topic -- ) article-content print-content terpri ;
|
2005-12-01 00:53:12 -05:00
|
|
|
|
2006-06-16 23:12:40 -04:00
|
|
|
: help ( topic -- ) dup print-title (help) ;
|
2005-12-28 20:25:17 -05:00
|
|
|
|
2006-01-19 03:28:10 -05:00
|
|
|
: handbook ( -- ) "handbook" help ;
|