Overview
Comment: | .tclshrc .vimrc Modified Files: Makefile.in configure.in sample.tclshrc tclreadline.c tclreadline.h.in Added Files: config.h.in |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
0d1401e9c11d4c6028ad5501a5b8a0cc |
User & Date: | johannes@zellner.org on 1999-09-13 16:33:10 |
Other Links: | manifest | tags |
Context
1999-09-14
| ||
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 | |
00:21 | tclreadline.c tclreadlineCompleter.tcl check-in: ea4e9a080f user: johannes@zellner.org tags: trunk | |
Changes
Modified Makefile.in from [a0009b0ead] to [161ae43645].
1 2 3 4 5 6 7 8 9 10 ... 147 148 149 150 151 152 153 154 155 156 157 158 159 160 ... 163 164 165 166 167 168 169 170 171 172 173 174 175 176 ... 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 |
# -*- make -*- # FILE: "/home/joze/src/tclreadline/Makefile.in" # LAST MODIFICATION: "Wed Sep 8 21:06:25 1999 (joze)" # (C) 1998, 1999 by Johannes Zellner, <johannes@zellner.org> # $Id$ # --- # # tclreadline -- gnu readline for tcl # Copyright (C) 1999 Johannes Zellner # ................................................................................ # The information below should be usable as is. The configure # script won't modify it and you shouldn't need to modify it # either. #---------------------------------------------------------------- CC = @CC@ CC_SWITCHES = $(CFLAGS) $(SHLIB_CFLAGS) -I$(TOP_DIR) \ -I$(TCL_INCLUDE_DIR) -I$(READLINE_INCLUDE_DIR) OBJS = tclreadline.o CSRCS = $(TOP_DIR)/tclreadline.c TCLFILES = tclreadlineInit.tcl tclreadlineSetup.tcl tclreadlineCompleter.tcl ................................................................................ GPL \ Makefile.in \ README \ configure.in \ pkgIndex.tcl.in \ sample.tclshrc \ sources \ tclreadline.c \ tclreadline.h.in \ tclreadline.n.in \ tclreadlineConfig.sh.in \ tclreadlineInit.tcl.in \ tclreadlineSetup.tcl.in \ tclreadlineCompleter.tcl ................................................................................ clean: rm -f *.a *.o core errs *~ \#* tags* *.E a.out errors so_locations distclean: clean rm -f \ Makefile *.so *.sl pkgIndex.tcl tclreadlineInit.tcl \ tclreadlineSetup.tcl tclreadline.h tclreadline.n \ tclreadlineConfig.sh config.status config.log config.cache depend: makedepend -- $(CC_SWITCHES) -- $(CSRCS) configure: configure.in autoconf .c.o: $(CC) -c $(CC_SWITCHES) $< tclreadline.o: $(TOP_DIR)/tclreadline.c Makefile $(CC) -c $(CC_SWITCHES) $(TOP_DIR)/tclreadline.c ctags: ctags -R tcltags: ctags tclreadlineInit.tcl.in tclreadlineSetup.tcl.in \ tclreadlineCompleter.tcl tcltags -a tclreadlineInit.tcl.in tclreadlineSetup.tcl.in \ |
| | > > > | < < < | < |
1 2 3 4 5 6 7 8 9 10 ... 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 ... 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 ... 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 |
# -*- make -*- # FILE: "/diska/home/joze/src/tclreadline/Makefile.in" # LAST MODIFICATION: "Mon Sep 13 18:09:41 1999 (joze)" # (C) 1998, 1999 by Johannes Zellner, <johannes@zellner.org> # $Id$ # --- # # tclreadline -- gnu readline for tcl # Copyright (C) 1999 Johannes Zellner # ................................................................................ # The information below should be usable as is. The configure # script won't modify it and you shouldn't need to modify it # either. #---------------------------------------------------------------- CC = @CC@ DEFS = @DEFS@ CC_SWITCHES = $(CFLAGS) $(SHLIB_CFLAGS) -I$(TOP_DIR) \ -I$(TCL_INCLUDE_DIR) -I$(READLINE_INCLUDE_DIR) OBJS = tclreadline.o CSRCS = $(TOP_DIR)/tclreadline.c TCLFILES = tclreadlineInit.tcl tclreadlineSetup.tcl tclreadlineCompleter.tcl ................................................................................ GPL \ Makefile.in \ README \ configure.in \ pkgIndex.tcl.in \ sample.tclshrc \ sources \ config.h.in \ tclreadline.c \ tclreadline.h.in \ tclreadline.n.in \ tclreadlineConfig.sh.in \ tclreadlineInit.tcl.in \ tclreadlineSetup.tcl.in \ tclreadlineCompleter.tcl ................................................................................ clean: rm -f *.a *.o core errs *~ \#* tags* *.E a.out errors so_locations distclean: clean rm -f \ Makefile *.so *.sl pkgIndex.tcl tclreadlineInit.tcl \ tclreadlineSetup.tcl config.h tclreadline.h tclreadline.n \ tclreadlineConfig.sh config.status config.log config.cache depend: makedepend -- $(CC_SWITCHES) -- $(CSRCS) configure: configure.in autoconf tclreadline.o: $(TOP_DIR)/tclreadline.c Makefile $(CC) -c $(CC_SWITCHES) $(DEFS) $(TOP_DIR)/tclreadline.c ctags: ctags -R tcltags: ctags tclreadlineInit.tcl.in tclreadlineSetup.tcl.in \ tclreadlineCompleter.tcl tcltags -a tclreadlineInit.tcl.in tclreadlineSetup.tcl.in \ |
Added config.h.in version [79c57abe6e].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
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 |
/* ================================================================== FILE: "/diska/home/joze/src/tclreadline/config.h.in" LAST MODIFICATION: "Mon Sep 13 17:51:29 1999 (joze)" (C) 1998, 1999 by Johannes Zellner, <johannes@zellner.org> $Id$ vim:set ft=c: --- tclreadline -- gnu readline for tcl Copyright (C) 1999 Johannes Zellner This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. johannes@zellner.org http://www.zellner.org/tclreadline/ ================================================================== */ #undef EXECUTING_MACRO_HACK |
Modified configure.in from [0fd9b9796f] to [d9679836e4].
1 2 3 4 5 6 7 8 9 10 .. 30 31 32 33 34 35 36 37 38 39 40 41 42 43 ... 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 ... 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 |
# -*- autoconf -*- # FILE: "/diska/home/joze/src/tclreadline/configure.in" # LAST MODIFICATION: "Wed Sep 8 18:18:02 1999 (joze)" # (C) 1998, 1999 by Johannes Zellner, <johannes@zellner.org> # $Id$ # --- # # tclreadline -- gnu readline for tcl # Copyright (C) 1999 Johannes Zellner # ................................................................................ dnl This file is an input file used by the GNU "autoconf" program to dnl generate the file "configure", which is run during Tk installation dnl to configure the system for the local environment. AC_REVISION($Revision$) AC_INIT(tclreadline.c) TCLREADLINE_MAJOR_VERSION=0 TCLREADLINE_MINOR_VERSION=9 TCLREADLINE_PATCHLEVEL=3 TCLREADLINE_VERSION=$TCLREADLINE_MAJOR_VERSION.$TCLREADLINE_MINOR_VERSION TCLREADLINE_PATCHLEVEL_STR=${TCLREADLINE_VERSION}.${TCLREADLINE_PATCHLEVEL} VERSION=$TCLREADLINE_VERSION ................................................................................ # --- # check, if curses or termcap is already # linked with libreadline. (on newer Linux # systems it is.) # --- TERM_LIB="" AC_CHECK_LIB(readline, tputs, termcaps=yes, termcaps=no) if test "$termcaps" = "no"; then # --- # nope. tputs() is unresolved in libreadline, so # check if we want libcurses or libtermcap. # --- ................................................................................ AC_CHECK_FUNC( rl_callback_read_char, alternate=yes, alternate=no ) if test "$alternate" = "no"; then AC_MSG_ERROR(alternate interface not supported by this readline version.) fi AC_MSG_CHECKING([for the readline version number]) AC_TRY_RUN([ #include <stdio.h> int main () { FILE *fp = fopen ("conftestversion", "w"); extern char *rl_library_version; fprintf (fp, "%s", rl_library_version); close (fp); return (0); }], READLINE_VERSION=`cat conftestversion` AC_MSG_RESULT($READLINE_VERSION), AC_MSG_RESULT(failed), AC_MSG_RESULT(no cross compiling)) |
| > | | > > > > > > > > > > > > > > > | |
1 2 3 4 5 6 7 8 9 10 .. 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 ... 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 ... 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 |
# -*- autoconf -*- # FILE: "/diska/home/joze/src/tclreadline/configure.in" # LAST MODIFICATION: "Mon Sep 13 17:51:49 1999 (joze)" # (C) 1998, 1999 by Johannes Zellner, <johannes@zellner.org> # $Id$ # --- # # tclreadline -- gnu readline for tcl # Copyright (C) 1999 Johannes Zellner # ................................................................................ dnl This file is an input file used by the GNU "autoconf" program to dnl generate the file "configure", which is run during Tk installation dnl to configure the system for the local environment. AC_REVISION($Revision$) AC_INIT(tclreadline.c) AC_CONFIG_HEADER(config.h) TCLREADLINE_MAJOR_VERSION=0 TCLREADLINE_MINOR_VERSION=9 TCLREADLINE_PATCHLEVEL=3 TCLREADLINE_VERSION=$TCLREADLINE_MAJOR_VERSION.$TCLREADLINE_MINOR_VERSION TCLREADLINE_PATCHLEVEL_STR=${TCLREADLINE_VERSION}.${TCLREADLINE_PATCHLEVEL} VERSION=$TCLREADLINE_VERSION ................................................................................ # --- # check, if curses or termcap is already # linked with libreadline. (on newer Linux # systems it is.) # --- # TERM_LIB="" # AC_CHECK_LIB(readline, tputs, termcaps=yes, termcaps=no) termcaps=no if test "$termcaps" = "no"; then # --- # nope. tputs() is unresolved in libreadline, so # check if we want libcurses or libtermcap. # --- ................................................................................ AC_CHECK_FUNC( rl_callback_read_char, alternate=yes, alternate=no ) if test "$alternate" = "no"; then AC_MSG_ERROR(alternate interface not supported by this readline version.) fi # check for readline's (macro.c) private variable # _rl_executing_macro. AC_MSG_CHECKING([for _rl_executing_macro in -lreadline]) AC_TRY_LINK(,[ extern char* _rl_executing_macro; int main () { _rl_executing_macro = (char*) 0; return 0; }], AC_MSG_RESULT(yes); AC_DEFINE_UNQUOTED(EXECUTING_MACRO_HACK, 1), AC_MSG_RESULT(no)) AC_MSG_CHECKING([for the readline version number]) AC_TRY_RUN([ #include <stdio.h> int main () { FILE *fp = fopen("conftestversion", "w"); extern char *rl_library_version; fprintf(fp, "%s", rl_library_version); close(fp); return 0; }], READLINE_VERSION=`cat conftestversion` AC_MSG_RESULT($READLINE_VERSION), AC_MSG_RESULT(failed), AC_MSG_RESULT(no cross compiling)) |
Modified sample.tclshrc from [f07a36eb8e] to [f68b1de54f].
1
2
3
4
5
6
7
8
9
10
..
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#!/bin/sh # FILE: "/diska/home/joze/src/tclreadline/sample.tclshrc" # LAST MODIFICATION: "Wed Sep 8 18:10:30 1999 (joze)" # (C) 1999 by Johannes Zellner, <johannes@zellner.org> # $Id$ # vim:set ft=tcl: \ exec tclsh "$0" "$@" if {$tcl_interactive} { ................................................................................ # store maximal this much lines in the history file # set tclreadline::historyLength 200 # disable tclreadline's script completer # ::tclreadline::readline customcompleter "" # go to tclrealdine's main loop. # tclreadline::Loop } |
|
|
|
1
2
3
4
5
6
7
8
9
10
..
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#!/bin/sh # FILE: "/diska/home/joze/src/tclreadline/sample.tclshrc" # LAST MODIFICATION: "Mon Sep 13 18:21:52 1999 (joze)" # (C) 1999 by Johannes Zellner, <johannes@zellner.org> # $Id$ # vim:set ft=tcl: \ exec tclsh "$0" "$@" if {$tcl_interactive} { ................................................................................ # store maximal this much lines in the history file # set tclreadline::historyLength 200 # disable tclreadline's script completer # # ::tclreadline::readline customcompleter "" # go to tclrealdine's main loop. # tclreadline::Loop } |
Modified tclreadline.c from [3d6f99eaa5] to [9394d14783].
1 2 3 4 5 6 7 8 9 10 11 12 .. 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 .. 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 ... 172 173 174 175 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 ... 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 ... 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 ... 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 ... 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 ... 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 ... 604 605 606 607 608 609 610 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 ... 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 ... 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 |
/* ================================================================== FILE: "/home/joze/src/tclreadline/tclreadline.c" LAST MODIFICATION: "Mon Sep 13 02:21:35 1999 (joze)" (C) 1998, 1999 by Johannes Zellner, <johannes@zellner.org> $Id$ --- tclreadline -- gnu readline for tcl Copyright (C) 1999 Johannes Zellner ................................................................................ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. <johannes@zellner.org>, http://www.zellner.org/tclreadline/ ================================================================== */ #include <tcl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define READLINE_LIBRARY #include <readline.h> ................................................................................ #include <history.h> /** * this prototype is missing * in readline.h */ void rl_extend_line_buffer(int len); #include "tclreadline.h" #define MALLOC(size) Tcl_Alloc((int) size) #define FREE(ptr) if (ptr) { Tcl_Free((char*) ptr); ptr = 0; } enum { ................................................................................ */ char* stripleft(char* in); char* stripright(char* in); char* stripwhite(char* in); char* TclReadlineQuote(char* text, char* quotechars); int TclReadlineCmd(ClientData clientData, Tcl_Interp* interp, int argc, char** argv); int TclReadlineEventHook(void); void TclReadlineReadHandler(ClientData clientData, int mask); void TclReadlineWriteHandler(ClientData clientData, int mask); void TclReadlineLineCompleteHandler(char* ptr); int Tclreadline_SafeInit(Tcl_Interp* interp); int Tclreadline_Init(Tcl_Interp* interp); char *TclReadlineFilenameQuotingFunction( char *text, int match_type, char* quote_ptr); 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); ................................................................................ length = strlen(argv[1]); if (c == 'r' && strncmp(argv[1], "read", length) == 0) { char* expansion = (char*) NULL; int status; #if 1 tclrl_line_complete = LINE_PENDING; tclrl_state = TCL_OK; rl_callback_handler_install(argc == 3 ? argv[2] : "%", TclReadlineLineCompleteHandler); Tcl_CreateFileHandler(0, TCL_READABLE, TclReadlineReadHandler, (ClientData) NULL); /* Tcl_CreateFileHandler(1, TCL_WRITABLE, TclReadlineWriteHandler, (ClientData) NULL); */ /** * Main Loop. * XXX each modification of the global variables * which terminates the main loop must call * rl_callback_handler_remove() to leave * readline in a defined state. XXX */ while (LINE_PENDING == tclrl_line_complete && TCL_OK == tclrl_state && !rl_done) { Tcl_DoOneEvent(TCL_ALL_EVENTS); /* Tcl_DoOneEvent(0); fprintf (stderr, "(TclReadlineCmd) \n"); rl_inhibit_completion = 0; */ } Tcl_DeleteFileHandler(0); if (TCL_OK != tclrl_state) return tclrl_state; /* !! */ if ((LINE_EOF == tclrl_line_complete) && tclrl_eof_string) { Tcl_Eval(interp, tclrl_eof_string); return tclrl_state; } #else rl_event_hook = TclReadlineEventHook; tclrl_line = readline(argc == 3 ? argv[2] : "%"); #endif status = history_expand(tclrl_line, &expansion); if (status >= 1) { #if 0 Tcl_Channel channel = Tcl_MakeFileChannel(stdout, TCL_WRITABLE); /* Tcl_RegisterChannel(interp, channel); */ (void) Tcl_WriteChars(channel, expansion, -1); ................................................................................ Tcl_AppendResult(interp, "wrong # args: should be \"readline option ?arg ...?\"", (char*) NULL); return TCL_ERROR; } int TclReadlineEventHook(void) { Tcl_DoOneEvent(TCL_ALL_EVENTS | TCL_DONT_WAIT); /* TCL_DONT_WAIT TCL_WINDOW_EVENTS TCL_FILE_EVENTS TCL_TIMER_EVENTS TCL_IDLE_EVENTS TCL_ALL_EVENTS */ return TCL_OK; } void TclReadlineReadHandler(ClientData clientData, int mask) { #if 0 fprintf(stderr, "(TclReadlineReadHandler) mask = %d\n", mask); #endif if (mask & TCL_READABLE) { /* fprintf(stderr, "(TclReadlineReadHandler) mask = readable\n"); rl_event_hook = TclReadlineEventHook; while (!rl_done) { */ rl_callback_read_char(); /* } fflush(stdin); */ } } void TclReadlineWriteHandler(ClientData clientData, int mask) { if (mask & TCL_WRITABLE) { /* fprintf(stderr, "(TclReadlineReadHandler) mask = writable\n"); */ fflush(stdout); rl_redisplay(); } } void TclReadlineLineCompleteHandler(char* ptr) { #if 1 ................................................................................ return status; if (TCL_OK != (status = Tcl_LinkVar(interp, "tclreadline_patchLevel", (char*) &TCLRL_PATCHLEVEL, TCL_LINK_STRING | TCL_LINK_READ_ONLY))) return status; return Tcl_PkgProvide(interp, "tclreadline", TCLRL_VERSION); } #if 0 char * TclReadlineFilenameQuotingFunction (char *filename, int match_type, char* quote_ptr) { char *res = (char*) malloc(sizeof(char) * (strlen(filename) + 2)); int i = 0; fprintf (stderr, "(TclReadlineFilenameQuotingFunction) \n"); if (quote_ptr && *quote_ptr) { *res = *quote_ptr; /* leading quote */ i++; } strcpy (res + i, filename); /* name */ #if 0 fprintf (stderr, "(Tclreadline_Init) filename=|%s|\n", filename); fprintf (stderr, "(Tclreadline_Init) *quote_ptr=|%c|\n", *quote_ptr); #endif if (quote_ptr && '{' == *quote_ptr) { *quote_ptr = '}'; } return res; #if 0 switch (match_type) { case SINGLE_MATCH: break; default: } #endif } #endif int TclReadlineInitialize(Tcl_Interp* interp, char* historyfile) { rl_readline_name = "tclreadline"; // rl_special_prefixes = "${\"["; rl_special_prefixes = "$"; /** ................................................................................ * added "}" */ /* 11.Sep rl_basic_word_break_characters = " \t\n\"\\@$}=;|&[]"; */ /* besser (11. Sept) 2. (removed \") */ /* rl_basic_word_break_characters = " \t\n\\@$}=;|&[]"; */ /* besser (11. Sept) 3. (removed }) */ rl_basic_word_break_characters = " \t\n\\@$=;|&[]"; // rl_basic_quote_characters = "\"{"; // XXX ??? XXX // rl_completer_quote_characters = "\""; /* rl_filename_quote_characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; rl_filename_quoting_function = (CPFunction*) TclReadlineFilenameQuotingFunction; */ ................................................................................ } char** TclReadlineCompletion(char* text, int start, int end) { char** matches = (char**) NULL; int status; // rl_attempted_completion_over = 0; rl_completion_append_character = ' '; /* reset, just in case ... */ #if 0 fprintf(stderr, "DEBUG> TclReadlineCompletion: text=|%s|\n", text); fprintf(stderr, "DEBUG> TclReadlineCompletion: start=|%d|\n", start); fprintf(stderr, "DEBUG> TclReadlineCompletion: end=|%d|\n", end); #endif #if 0 char* history_event = (char*) NULL; if (text) { if ('!' == text[0]) history_event = strdup(text); else if (start && rl_line_buffer[start - 1] == '!' /* for '$' */) { int len = strlen(text); history_event = strncpy((char*) malloc(sizeof(char) * (len + 1)), rl_line_buffer[start - 1], len); history_event[len] = '\0'; /* terminate */ } } if (history_event) #endif if (text && ('!' == text[0] || (start && rl_line_buffer[start - 1] == '!' /* for '$' */))) { char* expansion = (char*) NULL; int oldlen = strlen(rl_line_buffer); status = history_expand(rl_line_buffer, &expansion); if (status >= 1) { rl_extend_line_buffer(strlen(expansion) + 1); strcpy(rl_line_buffer, expansion); rl_end = strlen(expansion); rl_point += strlen(expansion) - oldlen; FREE(expansion); /* rl_redisplay(); */ /* * TODO: * because we return 0 == matches, * the filename completer will still beep. rl_inhibit_completion = 1; */ return matches; ................................................................................ char start_s[BUFSIZ], end_s[BUFSIZ]; Tcl_Obj* obj; Tcl_Obj** objv; int objc; char* quoted_text = TclReadlineQuote(text, "$[]{}\""); char* quoted_rl_line_buffer = TclReadlineQuote(rl_line_buffer, "$[]{}\""); #if 0 fprintf (stderr, "(TclReadlineCompletion) rl_line_buffer = |%s|\n", rl_line_buffer); fprintf (stderr, "(TclReadlineCompletion) quoted_rl_line_buffer = |%s|\n", quoted_rl_line_buffer); fprintf (stderr, "(TclReadlineCompletion) text = |%s|\n", text); fprintf (stderr, "(TclReadlineCompletion) quoted_text = |%s|\n", quoted_text); #endif sprintf(start_s, "%d", start); sprintf(end_s, "%d", end); Tcl_ResetResult(tclrl_interp); /* clear result space */ tclrl_state = Tcl_VarEval(tclrl_interp, tclrl_custom_completer, " \"", quoted_text, "\" ", start_s, " ", end_s, " \"", quoted_rl_line_buffer, "\"", (char*) NULL); FREE(quoted_text); ................................................................................ if (TCL_OK != tclrl_state) { rl_callback_handler_remove(); Tcl_AppendResult (tclrl_interp, " `", tclrl_custom_completer, " \"", quoted_text, "\" ", start_s, " ", end_s, " \"", quoted_rl_line_buffer, "\"' failed.", (char*) NULL); return matches; } #if 0 fprintf(stderr, "\nscript returned |%s|\n", Tcl_GetStringResult(tclrl_interp)); #endif obj = Tcl_GetObjResult(tclrl_interp); status = Tcl_ListObjGetElements(tclrl_interp, obj, &objc, &objv); if (TCL_OK != status) return matches; /* fprintf (stderr, "(TclReadlineCompletion) objc = %d\n", objc); */ if (objc) { int i, length; matches = (char**) MALLOC(sizeof(char*) * (objc + 1)); for (i = 0; i < objc; i++) { matches[i] = strdup(Tcl_GetStringFromObj(objv[i], &length)); if (1 == objc && !strlen(matches[i])) { // rl_attempted_completion_over = 1; FREE(matches[i]); FREE(matches); return (char**) NULL; } /* fprintf (stderr, "(TclReadlineCompletion) len[%s]=%d\n", matches[i], strlen(matches[i])); */ } /** * this is a special one: * if the script returns exactly two arguments * and the second argument is the empty string, * the rl_completion_append_character is set ................................................................................ } Tcl_ResetResult(tclrl_interp); /* clear result space */ } if (!matches && tclrl_use_builtin_completer) { matches = completion_matches(text, TclReadline0generator); } #if 0 { char **ptr; for (ptr = matches; ptr && *ptr; ptr++) fprintf (stderr, "(TclReadlineCompletion) |%s|\n", *ptr); } #endif return matches; } char* TclReadline0generator(char* text, int state) { ................................................................................ break; case _CMD_GET: local_line = strdup(rl_line_buffer); sub = TclReadlineParse(args, sizeof(args), local_line); /* * fprintf (stderr, "(TclReadlineKnownCommands) state=%d\n", state); * fprintf (stderr, "(TclReadlineKnownCommands) text = |%s|\n", text); */ if (0 == sub || (1 == sub && '\0' != text[0])) { if (!state) { new = cmds; len = strlen(text); } while (new && (name = new->cmd)) { |
| | > > > > > > > > > > > > > < < < < < < < < < < < < < < > < < < < < < < < < < < < < < < < < < < < > > | > | < < | > < < < < < < < < < < < < < < < > < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < > | | > < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < |
1 2 3 4 5 6 7 8 9 10 11 12 .. 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 .. 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 ... 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 ... 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 ... 394 395 396 397 398 399 400 401 402 403 404 405 406 407 ... 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 ... 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 488 489 ... 495 496 497 498 499 500 501 502 503 504 505 506 507 508 ... 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 ... 548 549 550 551 552 553 554 555 556 557 558 559 560 561 ... 606 607 608 609 610 611 612 613 614 615 616 617 618 619 |
/* ================================================================== FILE: "/diska/home/joze/src/tclreadline/tclreadline.c" LAST MODIFICATION: "Mon Sep 13 18:04:01 1999 (joze)" (C) 1998, 1999 by Johannes Zellner, <johannes@zellner.org> $Id$ --- tclreadline -- gnu readline for tcl Copyright (C) 1999 Johannes Zellner ................................................................................ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. <johannes@zellner.org>, http://www.zellner.org/tclreadline/ ================================================================== */ #ifdef HAVE_CONFIG_H # include "config.h" #endif #include <tcl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define READLINE_LIBRARY #include <readline.h> ................................................................................ #include <history.h> /** * this prototype is missing * in readline.h */ void rl_extend_line_buffer(int len); #ifdef EXECUTING_MACRO_HACK /** * this prototype is private in readline's file `macro.c'. * We need it here to decide, if we should read more * characters from a macro. Dirty, but it should work. */ extern char* _rl_executing_macro; #endif #include "tclreadline.h" #define MALLOC(size) Tcl_Alloc((int) size) #define FREE(ptr) if (ptr) { Tcl_Free((char*) ptr); ptr = 0; } enum { ................................................................................ */ char* stripleft(char* in); char* stripright(char* in); char* stripwhite(char* in); 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); ................................................................................ length = strlen(argv[1]); if (c == 'r' && strncmp(argv[1], "read", length) == 0) { char* expansion = (char*) NULL; int status; tclrl_line_complete = LINE_PENDING; tclrl_state = TCL_OK; rl_callback_handler_install(argc == 3 ? argv[2] : "%", TclReadlineLineCompleteHandler); Tcl_CreateFileHandler(0, TCL_READABLE, TclReadlineReadHandler, (ClientData) NULL); /** * Main Loop. * XXX each modification of the global variables * which terminates the main loop must call * rl_callback_handler_remove() to leave * readline in a defined state. XXX */ while (LINE_PENDING == tclrl_line_complete && TCL_OK == tclrl_state && !rl_done) { Tcl_DoOneEvent(TCL_ALL_EVENTS); } Tcl_DeleteFileHandler(0); if (TCL_OK != tclrl_state) return tclrl_state; /* !! */ if ((LINE_EOF == tclrl_line_complete) && tclrl_eof_string) { Tcl_Eval(interp, tclrl_eof_string); return tclrl_state; } status = history_expand(tclrl_line, &expansion); if (status >= 1) { #if 0 Tcl_Channel channel = Tcl_MakeFileChannel(stdout, TCL_WRITABLE); /* Tcl_RegisterChannel(interp, channel); */ (void) Tcl_WriteChars(channel, expansion, -1); ................................................................................ Tcl_AppendResult(interp, "wrong # args: should be \"readline option ?arg ...?\"", (char*) NULL); return TCL_ERROR; } void TclReadlineReadHandler(ClientData clientData, int mask) { if (mask & TCL_READABLE) { rl_callback_read_char(); #ifdef EXECUTING_MACRO_HACK /** * check, if we're inside a macro and * if so, read all macro characters. */ while (_rl_executing_macro) { rl_callback_read_char(); } #endif } } void TclReadlineLineCompleteHandler(char* ptr) { #if 1 ................................................................................ return status; if (TCL_OK != (status = Tcl_LinkVar(interp, "tclreadline_patchLevel", (char*) &TCLRL_PATCHLEVEL, TCL_LINK_STRING | TCL_LINK_READ_ONLY))) return status; return Tcl_PkgProvide(interp, "tclreadline", TCLRL_VERSION); } int TclReadlineInitialize(Tcl_Interp* interp, char* historyfile) { rl_readline_name = "tclreadline"; // rl_special_prefixes = "${\"["; rl_special_prefixes = "$"; /** ................................................................................ * added "}" */ /* 11.Sep rl_basic_word_break_characters = " \t\n\"\\@$}=;|&[]"; */ /* besser (11. Sept) 2. (removed \") */ /* rl_basic_word_break_characters = " \t\n\\@$}=;|&[]"; */ /* besser (11. Sept) 3. (removed }) */ rl_basic_word_break_characters = " \t\n\\@$=;|&[]"; #if 0 rl_basic_quote_characters = "\"{"; // XXX ??? XXX rl_completer_quote_characters = "\""; #endif /* rl_filename_quote_characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; rl_filename_quoting_function = (CPFunction*) TclReadlineFilenameQuotingFunction; */ ................................................................................ } char** TclReadlineCompletion(char* text, int start, int end) { char** matches = (char**) NULL; int status; rl_completion_append_character = ' '; /* reset, just in case ... */ if (text && ('!' == text[0] || (start && rl_line_buffer[start - 1] == '!' /* for '$' */))) { char* expansion = (char*) NULL; int oldlen = strlen(rl_line_buffer); status = history_expand(rl_line_buffer, &expansion); if (status >= 1) { rl_extend_line_buffer(strlen(expansion) + 1); strcpy(rl_line_buffer, expansion); rl_end = strlen(expansion); rl_point += strlen(expansion) - oldlen; FREE(expansion); /* * TODO: * because we return 0 == matches, * the filename completer will still beep. rl_inhibit_completion = 1; */ return matches; ................................................................................ char start_s[BUFSIZ], end_s[BUFSIZ]; Tcl_Obj* obj; Tcl_Obj** objv; int objc; 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 */ tclrl_state = Tcl_VarEval(tclrl_interp, tclrl_custom_completer, " \"", quoted_text, "\" ", start_s, " ", end_s, " \"", quoted_rl_line_buffer, "\"", (char*) NULL); FREE(quoted_text); ................................................................................ if (TCL_OK != tclrl_state) { rl_callback_handler_remove(); Tcl_AppendResult (tclrl_interp, " `", tclrl_custom_completer, " \"", quoted_text, "\" ", start_s, " ", end_s, " \"", quoted_rl_line_buffer, "\"' failed.", (char*) NULL); return matches; } obj = Tcl_GetObjResult(tclrl_interp); status = Tcl_ListObjGetElements(tclrl_interp, obj, &objc, &objv); if (TCL_OK != status) return matches; if (objc) { int i, length; matches = (char**) MALLOC(sizeof(char*) * (objc + 1)); for (i = 0; i < objc; i++) { matches[i] = strdup(Tcl_GetStringFromObj(objv[i], &length)); if (1 == objc && !strlen(matches[i])) { FREE(matches[i]); FREE(matches); return (char**) NULL; } } /** * this is a special one: * if the script returns exactly two arguments * and the second argument is the empty string, * the rl_completion_append_character is set ................................................................................ } Tcl_ResetResult(tclrl_interp); /* clear result space */ } if (!matches && tclrl_use_builtin_completer) { matches = completion_matches(text, TclReadline0generator); } return matches; } char* TclReadline0generator(char* text, int state) { ................................................................................ break; case _CMD_GET: local_line = strdup(rl_line_buffer); sub = TclReadlineParse(args, sizeof(args), local_line); if (0 == sub || (1 == sub && '\0' != text[0])) { if (!state) { new = cmds; len = strlen(text); } while (new && (name = new->cmd)) { |
Modified tclreadline.h.in from [60998526c8] to [1247b0d625].
1 2 3 4 5 6 7 8 9 10 11 12 |
/* ==================================================================
FILE: "/home/joze/src/tclreadline/tclreadline.h.in"
LAST MODIFICATION: "Sun Aug 29 08:07:04 1999 (joze)"
(C) 1998, 1999 by Johannes Zellner, <johannes@zellner.org>
$Id$
vim:set ft=c:
---
tclreadline -- gnu readline for tcl
Copyright (C) 1999 Johannes Zellner
|
| | |
1 2 3 4 5 6 7 8 9 10 11 12 |
/* ================================================================== FILE: "/diska/home/joze/src/tclreadline/tclreadline.h.in" LAST MODIFICATION: "Mon Sep 13 17:52:25 1999 (joze)" (C) 1998, 1999 by Johannes Zellner, <johannes@zellner.org> $Id$ vim:set ft=c: --- tclreadline -- gnu readline for tcl Copyright (C) 1999 Johannes Zellner |