aboutsummaryrefslogtreecommitdiff
path: root/forth/forth/help.fs
blob: 8128b6abbd81cbec46e84f4cd62ca96106f2f5c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
\ *******************************************************************
\                                                                   *
\    Filename:      help.txt                                        *
\    Date:          03.03.2014                                      *
\    FF Version:    5.0                                             *
\    Copyright:     Mikael Nordman                                  *
\    Author:        Mikael Nordman                                  *
\ *******************************************************************
\ FlashForth is licensed according to the GNU General Public License*
\ *******************************************************************
-help
marker -help
ram hex

$1b constant esc
$09 constant tab
$0d constant ret
$0a constant nl

flash hi $32ff - constant ahelp \ Start of help text area
ram

: h= ( caddr caddr1 u -- flag )
  swap !p>r
  for
    c@+ pc@ p+ -
    if drop false rdrop r>p exit then
  next
  r>p drop true
;


: .help ( addr -- )
  cr
  begin
    c@+ dup emit ret =
  until
  cr drop
;
: help ( "name" -- )
  bl word         \ addr
  dup c@ 0= if words abort then
  ahelp !p>r
  begin
    busy pause idle
    @p over c@+ h= if @p .help r>p drop exit then
    begin 
      pc@ ret = pc@ nl = or 
      p+
      pc@ ret <> pc@ nl <> and 
      and
    until
    pc@ [char] | =
  until
  r>p drop
;

: loadhelp ( --     store help info )
  ahelp !p>r        \ Help info stored here
  begin
    key
    dup emit
    dup pc! p+ 
    [char] | =
  until
  r>p
;