tcl-hacks

Check-in [0e516a3f34]
Login

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

Overview
Comment:completion for longest-prefix
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:0e516a3f349e939954a99cb3e4c4316e7fac4173
User & Date: aspect 2018-05-21 13:32:46
Context
2018-05-24
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
2018-05-20
15:23
be honest check-in: b16ed0e2dd user: aspect tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to getline/main.tcl.

25
26
27
28
29
30
31
32
33

34
35
36
37
38
39
40
..
62
63
64
65
66
67
68





69

70
71
72
73
74
75
76
#  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
#  ? modes support
#  - output attrs

#  - 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
................................................................................
    set l [string length $w]
    set cs [info commands ${w}*]            ;# here's the dictionary!
    if {[llength $cs] == 1} {
        lassign $cs comp
        set comp [string range $comp [string length $w] end]
        return [list insert "$comp "]
    } else {





        return [list flash-message $cs]     ;# FIXME: abbreviate

    }
}


proc main {args} {
    exec stty raw -echo <@ stdin
    trace add variable args unset {apply {args {exec stty -raw echo <@ stdin}}}







<

>







 







>
>
>
>
>
|
>







25
26
27
28
29
30
31

32
33
34
35
36
37
38
39
40
..
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#  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
................................................................................
    set l [string length $w]
    set cs [info commands ${w}*]            ;# here's the dictionary!
    if {[llength $cs] == 1} {
        lassign $cs comp
        set comp [string range $comp [string length $w] end]
        return [list insert "$comp "]
    } else {
        set comp [common-prefix $cs]
        set comp [string range $comp [string length $w] end]
        if {$comp ne ""} {
            return [list insert $comp]
        } else {
            return [list flash-message $cs]     ;# FIXME: abbreviate
        }
    }
}


proc main {args} {
    exec stty raw -echo <@ stdin
    trace add variable args unset {apply {args {exec stty -raw echo <@ stdin}}}

Changes to getline/util.tcl.

52
53
54
55
56
57
58









59
60
61
62
63
64
65
    }
}

proc prepend {_str prefix} {
    upvar 1 $_str str
    set str $prefix$str
}










proc watchexec {name} {
    uplevel 1 [list trace add execution $name {enterstep leavestep} [coroutine [info cmdcount] watchexec_cb]]
}

proc watchexec_cb {} {
    set args [lassign [yieldto string cat [info coroutine]] cmd]







>
>
>
>
>
>
>
>
>







52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
    }
}

proc prepend {_str prefix} {
    upvar 1 $_str str
    set str $prefix$str
}

proc common-prefix {ss} {
    set ss [lassign $ss s]
    set i [expr {[string length $s] -1}]
    foreach s1 $ss {
        while {[string range $s 0 $i] ne [string range $s1 0 $i]} {incr i -1}
    }
    string range $s 0 $i
}

proc watchexec {name} {
    uplevel 1 [list trace add execution $name {enterstep leavestep} [coroutine [info cmdcount] watchexec_cb]]
}

proc watchexec_cb {} {
    set args [lassign [yieldto string cat [info coroutine]] cmd]