Overview
Comment: | Modified Files: src/tclreadline/tclreadline.c src/tclreadline/tclreadlineCompleter.tcl src/tclreadline/tclreadlineSetup.tcl.in Added Files: src/csym/version |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
3257fb6735879419a823e3c56da1b380 |
User & Date: | johannes@zellner.org on 1999-09-14 00:00:35 |
Other Links: | manifest | tags |
Context
1999-09-14
| ||
14:56 | .complete .login .tclshrc .vimrc .wishrc tcltags vimrc tcl_ft.vim Align.vim SpecificSettings.vim comment.vim configure.in sources tclreadline.c tclreadlineCompleter.tcl check-in: db706bec68 user: johannes@zellner.org tags: trunk | |
00:00 | Modified Files: src/tclreadline/tclreadline.c src/tclreadline/tclreadlineCompleter.tcl src/tclreadline/tclreadlineSetup.tcl.in Added Files: src/csym/version check-in: 3257fb6735 user: johannes@zellner.org tags: trunk | |
1999-09-13
| ||
16:33 | .tclshrc .vimrc Modified Files: Makefile.in configure.in sample.tclshrc tclreadline.c tclreadline.h.in Added Files: config.h.in check-in: 0d1401e9c1 user: johannes@zellner.org tags: trunk | |
Changes
Modified tclreadline.c from [9394d14783] to [1096dacb0c].
1 2 3 | 1 2 3 4 5 6 7 8 9 10 11 12 | - - + + | /* ================================================================== |
︙ | |||
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | + + - - - + + + - - + | /* * forward declarations. */ char* stripleft(char* in); char* stripright(char* in); char* stripwhite(char* in); int TclReadlineLineComplete(void); void TclReadlineTerminate(int state); char* TclReadlineQuote(char* text, char* quotechars); int TclReadlineCmd(ClientData clientData, Tcl_Interp* interp, int argc, char** argv); void TclReadlineReadHandler(ClientData clientData, int mask); void TclReadlineLineCompleteHandler(char* ptr); int Tclreadline_SafeInit(Tcl_Interp* interp); int Tclreadline_Init(Tcl_Interp* interp); int TclReadlineInitialize(Tcl_Interp* interp, char* historyfile); int blank_line(char* str); char** TclReadlineCompletion(char* text, int start, int end); char* TclReadline0generator(char* text, int state); char* TclReadlineKnownCommands(char* text, int state, int mode); int TclReadlineParse(char** args, int maxargs, char* buf); enum { |
︙ | |||
137 138 139 140 141 142 143 144 145 146 147 148 149 150 | 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | + + + + + + + + + + + + + | char* stripwhite(char* in) { stripleft(in); stripright(in); return in; } int TclReadlineLineComplete(void) { return !(tclrl_state == LINE_PENDING); } void TclReadlineTerminate(int state) { tclrl_state = state; rl_callback_handler_remove(); } char* TclReadlineQuote(char* text, char* quotechars) { char* ptr; char* result_c; int i, len = strlen(quotechars); |
︙ | |||
162 163 164 165 166 167 168 | 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 | - - - - + + + + + + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + + + + + - + - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - - - + + + + + + + - - - + - - - - - - + + - - + + + - - - - - - + + + + + + - - - - + - - - - + - - - - - + - - - - - + + + + + + + + + - - - + + + + - - - - - - - - + + + + + + + + + + - - - + + + + + + - - + + + - - - - - - - + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + + + + + + + + + - + - - - - - + + + + + + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | } result_c = strdup(Tcl_DStringValue(&result)); return result_c; } int TclReadlineCmd( |
︙ | |||
398 399 400 401 402 403 404 | 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 | - + - + | return Tcl_PkgProvide(interp, "tclreadline", TCLRL_VERSION); } int TclReadlineInitialize(Tcl_Interp* interp, char* historyfile) { rl_readline_name = "tclreadline"; |
︙ | |||
492 493 494 495 496 497 498 499 500 501 502 503 504 | 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 | + - + - + - + | } if (tclrl_custom_completer) { char start_s[BUFSIZ], end_s[BUFSIZ]; Tcl_Obj* obj; Tcl_Obj** objv; int objc; int state; char* quoted_text = TclReadlineQuote(text, "$[]{}\""); char* quoted_rl_line_buffer = TclReadlineQuote(rl_line_buffer, "$[]{}\""); sprintf(start_s, "%d", start); sprintf(end_s, "%d", end); Tcl_ResetResult(tclrl_interp); /* clear result space */ |
︙ |
Modified tclreadlineCompleter.tcl from [6becbaf62d] to [db38bf929f].
1 2 | 1 2 3 4 5 6 7 8 9 10 | - + | #!/usr/locanl/bin/tclsh # FILE: "/home/joze/src/tclreadline/tclreadlineCompleter.tcl" |
︙ | |||
143 144 145 146 147 148 149 150 151 152 153 154 155 156 | 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | + + + + - + | } } #** # build a list hosts from the /etc/hosts file. # this is only done once. This is sort of a # dirty hack, /etc/hosts is hardcoded ... # But on the other side, if the user supplies # a valid host table in tclreadline::hosts # before entering the event loop, this proc # will return this list. # proc HostList {} { # read the host table only once. # variable hosts if {![info exists hosts]} { catch { |
︙ | |||
203 204 205 206 207 208 209 210 211 212 213 214 215 216 | 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | foreach word $lst { if {[string match ${text}* ${word}]} { lappend result ${word} } } return [string trim $result] } #** # invoke cmd with a (hopefully) invalid string and # parse the error message to get an option list. # # @param cmd # @return list of options for cmd # @date Sep-14-1999 # proc TrySubCmds {cmd} { set trystring ____ set result "" if [catch {set result [${cmd} ${trystring}]} msg] { if {[regexp {bad *option.*____.*: *must *be( .*$)} ${msg} all raw]} { regsub -all -- , ${raw} { } raw set len [llength ${raw}] set len_2 [expr ${len} - 2] for {set i 0} {${i} < ${len}} {incr i} { set word [lindex ${raw} ${i}] if {"or" != ${word} && ${i} != ${len_2}} { lappend result ${word} } } } else { # check, if it's a blt error msg ... # set msglst [split ${msg} \n] foreach line ${msglst} { if {[regexp "${cmd}\[ \t\]\+\(\[^ \t\]*\)\[^:\]*$" \ ${line} all sub]} { lappend result [list ${sub}] } } } } return ${result} } proc FirstNonOption {line} { set expr_pos 1 foreach word [lrange ${line} 1 end] {; # 0 is the command itself if {"-" != [string index ${word} 0]} { break } else { |
︙ | |||
655 656 657 658 659 660 661 | 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 | - + + + + + + + - - - - - - - + | return [CommandCompletion ${cmd} procs] } proc CommandsOnlyCompletion {cmd} { return [CommandCompletion ${cmd} commands] } |
︙ | |||
695 696 697 698 699 700 701 | 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 | - - - + + + - + | set commands "" } if {"commands" != ${action}} { set all_procs [namespace eval $spc [list info procs ${cmd}]] # puts stderr procs=|$procs| set procs "" foreach proc $all_procs { |
︙ | |||
828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 | 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 | + + + + | # [SplitLine] --> {1 " put $b"} == sub # new_start = [lindex $sub 0] == 1 # new_end = [expr $end - ($start - $new_start)] == 4 # new_part == $part == put # new_line = [lindex $sub 1] == " put $b" # } elseif {"" != [set sub [SplitLine $start $line]]} { set new_start [lindex $sub 0] set new_end [expr $end - ($start - $new_start)] set new_line [lindex $sub 1] # puts stderr "(SplitLine) $new_start $new_end $new_line" return [ScriptCompleter $part $new_start $new_end $new_line] } elseif {0 == [set pos [PartPosition part start end line]]} { # puts stderr "(PartPosition) $part $start $end $line" set all [CommandCompletion ${part}] # puts stderr "(ScriptCompleter) all=$all" #puts \nmatches=$matches\n # return [Format $all $part] return [TryFromList $part $all] } else { # try to use $pos further ... # puts stderr |$line| # if {"." == [string index [string trim ${line}] 0]} { set alias WIDGET |
︙ | |||
905 906 907 908 909 910 911 912 913 914 915 916 917 918 | 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | error [list error during evaluation of `complete(${cmd})'] } # puts stderr \nscript_result=|${script_result}| return ${script_result} } # set namespc ""; # no qualifiers for tclreadline_complete_unknown } # as we've reached here no valid specific completer # was found. Check, if it's a proc and return the # arguments. # if {[string length [uplevel [info level] info proc $alias]]} { set args [uplevel [info level] info args $alias] set arg [lindex $args [expr $pos - 1]] if {"" != $arg} { if {[uplevel [info level] info default $alias $arg junk]} { return [DisplayHints ?$arg?] } else { return [DisplayHints <$arg>] } } } # Ok, also no proc. Try to do the same as for widgets now: # try to get at least the first option from an error output. # switch -- $pos { 1 { set cmds [TrySubCmds ${alias}] if {[llength ${cmds}]} { return [TryFromList ${part} ${cmds}] } } } # no specific command completer found. return "" } error "{NOTREACHED (this is probably an error)}" } |
︙ | |||
1049 1050 1051 1052 1053 1054 1055 | 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 | - - + + + | switch -- $pos { 1 { return [DisplayHints <script>] } 2 { return [DisplayHints ?varName?] } } return "" } |
︙ | |||
2229 2230 2231 2232 2233 2234 2235 2236 2237 | 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 | + + + + + + - - + + + + + + + + + + + + + - + + | names {} unknown { return [DisplayHints ?command?] } vcompare - vsatisfies { return [DisplayHints <version1>] } } } 3 { set versions "" catch [list set versions [package versions [Lindex $line 2]]] switch -- $cmd { forget {} ifneeded { if {"" != $versions} { return [CompleteFromList ${text} $versions] } else { |
︙ | |||
2769 2770 2771 2772 2773 2774 2775 2776 2777 | 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + | } } } } return "" } # --- TCLREADLINE PACKAGE --- # create a tclreadline namespace inside # tclreadline and import some commands. # namespace eval tclreadline { catch { namespace import \ ::tclreadline::DisplayHints \ ::tclreadline::CompleteFromList \ ::tclreadline::Lindex } } proc tclreadline::complete(readline) {text start end line pos mod} { set cmd [Lindex $line 1] switch -- $pos { 1 { return [CompleteFromList ${text} { read initialize write add complete customcompleter builtincompleter eofchar}] } 2 { switch -- $cmd { read {} initialize {} write {} add { return [DisplayHints <completerLine>] } completer { return [DisplayHints <line>] } customcompleter { return [DisplayHints ?scriptCompleter?] } builtincompleter { return [DisplayHints ?boolean?] } eofchar { return [DisplayHints ?script?] } } } } return "" } # --- END OF TCLREADLINE PACKAGE --- proc complete(tell) {text start end line pos mod} { switch -- $pos { |
︙ | |||
2926 2927 2928 2929 2930 2931 2932 | 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 | - + - + - - - - - - + + - - - - - - - - + + - - - - - - - - - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + + + | return "" } # ------------------------------------- # TK # ------------------------------------- |
Modified tclreadlineSetup.tcl.in from [602286f12e] to [026fd75a9a].
1 | 1 2 3 4 5 6 7 8 9 10 | - - + + | #!/usr/locanl/bin/tclsh |
︙ | |||
24 25 26 27 28 29 30 | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | - + + | # # johannes@zellner.org # http://www.zellner.org/tclreadline/ # # ================================================================== |
︙ | |||
294 295 296 297 298 299 300 | 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | + + + + + + + + - + + | } ::tclreadline::errorMsg]} { puts stderr [list tclreadline::Loop: error. \ $::tclreadline::errorMsg] continue } # Magnus Eriksson <magnus.eriksson@netinsight.se> proposed # to add the line also to tclsh's history. # # I decided to add only lines which are different from # the previous one to the history. This is different # from tcsh's behaviour, but I found it quite convenient # while using mshell on os9. # if {[string length $LINE] && [history event 0] != $LINE} { |
︙ |