tcl-hacks

Check-in [ea6039b24d]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:move TODO out of main
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:ea6039b24d160932c58093d456eea0aa04d6617c
User & Date: aspect 2018-05-24 09:35:20
Context
2018-05-24
10:20
make getline a module: add tclish check-in: 015a60358b user: aspect tags: trunk
09:35
move TODO out of main check-in: ea6039b24d user: aspect tags: trunk
2018-05-21
13:32
completion for longest-prefix check-in: 0e516a3f34 user: aspect tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added getline/TODO.

































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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

# TODO:
#  - output attrs
#  ? modes support
#  - history-incremental-search
#  - cumulative yank
#  ? completion UI choices
#  ? prefix keymaps (eg: ^L=redraw-line; ^L^L=redraw-all-lines)
#  ? numeric arguments
#  ? yank-last-arg?  Not yank ring, stuff that.
#  ? mark
#  ? transpositions
#  ? undo
#  ? ^search^replace and !! and !prefix and !-n

# WIBNI: continuation prompts, colours, completion
#  - M-: to issue commands directly to getline
#  - M-digit digit .. counts so \e5^X^E opens an editor with LAST FIVE LINES OMG
#  - factor command definitions for symmetry, but don't go overboard
#  - attrs
#  - use exceptions for beep, result
#  - inter-line nav without excessive redraw
#  - a manual, with that call graph

# DONE:
#  x char-wise nav
#  x line-wise nav
#  x wrap handling
#  x word-wise nav
#  x history (basic)
#  x history-search
#  x basic yank
#  x C-x C-e EDITOR (get smarter)
#  x flash message
#  x tcloo'ify
#  x multi-line input (debug further)
#   x fix line joinage: too much redraw by far
#   x continuation prompts
#   x multi-line redraw (just a keymap / action naming thing?)
#  x fix up history
#  x objectify keymap
#  x -options to Getline, move history etc into components
#  x chan independence
#  x up/down navigation in lines
#  x actions can have arguments (but not user-controlled eg counts)
#  x use throw for accept and beep
#  x basic completion interface
# OPTIMISATION:

Changes to getline/getline.tcl.

366
367
368
369
370
371
372









373
374
375
376
377
378
379
        method is-last-line {}      { expr {$Lineidx == [llength $Lines]-1} }

        method prior-line {} {
            if {[my is-first-line]} { throw {GETLINE BEEP} "No prior line" }
            my goto-column 0
            lset Lines $Lineidx [input get]
            incr Lineidx -1









            my set-state [lindex $Lines $Lineidx]
            set  nrows [output wrap 0 [output len]]  ;# hmmm
            incr nrows 1
            output emit [tty::up $nrows]
            my redraw-line
        }
        method next-line {} {







>
>
>
>
>
>
>
>
>







366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
        method is-last-line {}      { expr {$Lineidx == [llength $Lines]-1} }

        method prior-line {} {
            if {[my is-first-line]} { throw {GETLINE BEEP} "No prior line" }
            my goto-column 0
            lset Lines $Lineidx [input get]
            incr Lineidx -1
            ### the following could be (to eliminate set-state)
            # set line [lindex $Lines $Lineidx]
            # input set-state $line [string length $line]
            # set rep [srep $line]
            # set wraps [output wrap 0 [string length [my Prompt]$rep]]    ;# output repwrap {*}[my Prompt] + {*}$rep
            # output emit [tty::up [expr {1+$wraps}]]
            # output reset [my Prompt]
            # output insert $rep
            ## my goto-column $col
            my set-state [lindex $Lines $Lineidx]
            set  nrows [output wrap 0 [output len]]  ;# hmmm
            incr nrows 1
            output emit [tty::up $nrows]
            my redraw-line
        }
        method next-line {} {

Changes to getline/main.tcl.

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
# WIBNI: continuation prompts, colours, completion
#  - M-: to issue commands directly to getline
#  - M-digit digit .. counts so \e5^X^E opens an editor with LAST FIVE LINES OMG
#  - factor command definitions for symmetry, but don't go overboard
#  - attrs
#  - use exceptions for beep, result
#  - inter-line nav without excessive redraw
#  - a manual, with that call graph
# TODO:
#  x char-wise nav
#  x line-wise nav
#  x wrap handling
#  x word-wise nav
#  x history (basic)
#  x history-search
#  x basic yank
#  x C-x C-e EDITOR (get smarter)
#  x flash message
#  x tcloo'ify
#  x multi-line input (debug further)
#   x fix line joinage: too much redraw by far
#   x continuation prompts
#   x multi-line redraw (just a keymap / action naming thing?)
#  x fix up history
#  x objectify keymap
#  x -options to Getline, move history etc into components
#  x chan independence
#  x up/down navigation in lines
#  x actions can have arguments (but not user-controlled eg counts)
#  x use throw for accept and beep
#  x basic completion interface
#  - output attrs
#  ? modes support
#  - history-incremental-search
#  - cumulative yank
#  ? completion UI choices
#  ? prefix keymaps (eg: ^L=redraw-line; ^L^L=redraw-all-lines)
#  ? numeric arguments
#  ? yank-last-arg?  Not yank ring, stuff that.
#  ? mark
#  ? transpositions
#  ? undo
#  ? ^search^replace and !! and !prefix and !-n
# OPTIMISATION:
#  - don't redraw so greedily when forthing
#  - incrementally fix up lines

source getline.tcl

namespace path ::getline

proc complete-tcl-command {s t} {
    set j [string length $s]
    while {[info complete [string range $s $j end]\n} {incr j -1}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






















































1
2
3
4
5
6
7















































source getline.tcl

namespace path ::getline

proc complete-tcl-command {s t} {
    set j [string length $s]
    while {[info complete [string range $s $j end]\n} {incr j -1}

Changes to getline/output.tcl.

1
2
3
4
5




6
7
8
9
10
11
12
..
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
source util.tcl     ;# sinsert
source tty.tcl

oo::class create Output {





    variable chan
    variable output
    variable pos
    variable cols
    variable rows
    variable flashid

................................................................................
    }

    method wrap {i j} {
        set j [expr {($i + $j) / $cols}]
        set i [expr {$i / $cols}]
        return [expr {abs($i-$j)}]
    }
    method eol? {p} {expr {$p % $cols == 0}}

    method get {} {return $output}
    method len {} {string length $output}
    method pos {}  {return $pos}
    method rpos {} {expr {[string length $output]-$pos}}

    method reset {prompt} {
        set r [my get]
        set output ""
        set pos 0
        my emit [tty::goto-col 0]
        my emit [tty::erase-to-end]
        my insert $prompt
        #my redraw
        return $r
    }
    method set-state {s p} {
        set output $s
        set pos $p
    }






>
>
>
>







 







|

|
|
|
|








<







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
..
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
source util.tcl     ;# sinsert
source tty.tcl

oo::class create Output {

    # insert has to take {str ?attr? ?...?}
    # repwrap takes the same
    # output becomes an {attr str ...} list
    # .. all the operations using $output need to be re-jiggerd
    variable chan
    variable output
    variable pos
    variable cols
    variable rows
    variable flashid

................................................................................
    }

    method wrap {i j} {
        set j [expr {($i + $j) / $cols}]
        set i [expr {$i / $cols}]
        return [expr {abs($i-$j)}]
    }
    method eol? {p}             {expr {$p % $cols == 0}}

    method get {{i 0} {j end}}  {string range $output $i $j}
    method len {}               {string length $output}
    method pos {}               {return $pos}
    method rpos {}              {expr {[string length $output]-$pos}}

    method reset {prompt} {
        set r [my get]
        set output ""
        set pos 0
        my emit [tty::goto-col 0]
        my emit [tty::erase-to-end]
        my insert $prompt

        return $r
    }
    method set-state {s p} {
        set output $s
        set pos $p
    }