aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/repl.tes
blob: 9cfa8c01fb97578a9674efdb4e5ab9d3176dbad5 (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
!*
 * This is a stand-alone script that mimics
 * classic TECO command lines.
 * Requires an ANSI-compatible terminal.
 *
 * Currently, you must set the terminal characteristics on the outside:
 * stty raw opost icrnl && sciteco -m repl.tes
 *
 * You can launch into interactive mode by typing -u#ex
 *
 * TODO:
 * - Catch errors
 * - Support *q
 *!
0U#ex
<
  *
  <
    U Q:;
    !* erase current command line *!
    [.c[.l
      0U.i 0U.l :Q<%.i-1Q-10"=%.l'>
      Q.l"> [\.lF | 13 '
      
    ].l].c
    !* Handle rub out *!
    Q-8"= 127U '
    Q-127"=
      :Q">
        !*
         * Remove last character from reg 
         * Doesn't require EQ which cannot be reliably undone.
         *!
        [.i 0U.i :Q-1<%.i-1Q:> ].i
      '
    |
      Q:
    '
    !* Redraw command line *!
    [.i[.c
      0U.i :Q< %.i-1QU.c
        Q.c-10"= 10 F> '
        Q.c-"= $ F> '
        Q.c-32"< ^,(Q.c#64) | Q.c '
      >
    ].c].i
    !* FIXME: Catch errors *!
    Q-"=
      Q#">0U# 10 :M  1;' 1|0
    'U#
  >
  ED&2"N1;' !* EX called *!
  Q#ex:;
>