Overview
Comment: | Modified Files: share/vim/VIM/vimrc share/vim/functions/selectBuffer.vim Added Files: src/tclreadline/Makefile.in src/tclreadline/tclreadline.c src/tclreadline/tclreadlineConfig.sh.in src/tclreadline/tclreadlineInit.tcl.in |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
1d9d3e3f9c68be554c31a3cf98d38c50 |
User & Date: | johannes@zellner.org on 1999-08-21 16:16:54 |
Other Links: | manifest | tags |
Context
1999-08-22
| ||
18:52 | Modified Files: .tclshrc src/tclreadline/README src/tclreadline/configure.in Added Files: src/tclreadline/Makefile.in src/tclreadline/tclreadline.c src/tclreadline/tclreadlineConfig.sh.in src/tclreadline/tclreadlineInit.tcl.in check-in: ca84c60bc0 user: johannes@zellner.org tags: trunk | |
1999-08-21
| ||
16:16 | Modified Files: share/vim/VIM/vimrc share/vim/functions/selectBuffer.vim Added Files: src/tclreadline/Makefile.in src/tclreadline/tclreadline.c src/tclreadline/tclreadlineConfig.sh.in src/tclreadline/tclreadlineInit.tcl.in check-in: 1d9d3e3f9c user: johannes@zellner.org tags: trunk | |
1999-08-20
| ||
22:43 | share/vim/ft/c_ft.vim share/vim/ft/cpp_ft.vim src/tclreadline/configure.in src/tclreadline/tclreadline.n.in src/tclreadline/tclreadlineSetup.tcl.in Added Files: src/tclreadline/Makefile.in src/tclreadline/tclreadline.c src/tclreadline/tclreadlineConfig.sh.in src/tclreadline/tclreadlineInit.tcl.in check-in: d6ac1c38a3 user: johannes@zellner.org tags: trunk | |
Changes
Modified tclreadline.c from [1a4acfc94a] to [abc453aae1].
1 2 3 4 | /* ================================================================== FILE: "/home/joze/src/tclreadline/tclreadline.c" | | | 1 2 3 4 5 6 7 8 9 10 11 12 | /* ================================================================== FILE: "/home/joze/src/tclreadline/tclreadline.c" LAST MODIFICATION: "Sat Aug 21 17:44:13 1999 (joze)" (C) 1998, 1999 by Johannes Zellner, <johannes@zellner.org> $Id$ --- tclreadline -- gnu readline for tcl Copyright (C) 1999 Johannes Zellner |
︙ | ︙ | |||
89 90 91 92 93 94 95 | int Tclreadline_SafeInit (Tcl_Interp *interp); int Tclreadline_Init (Tcl_Interp *interp); char* TclReadlineInitialize (char *historyfile); char** TclReadlineCompletion (char *text, int start, int end); char* TclReadline0generator (char *text, int state); char* TclReadline1generator (char *text, int state); char* TclReadlineKnownCommands (char *text, int state, int mode); | < < < < < | < < | | | | | > < < > > | 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 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | int Tclreadline_SafeInit (Tcl_Interp *interp); int Tclreadline_Init (Tcl_Interp *interp); char* TclReadlineInitialize (char *historyfile); char** TclReadlineCompletion (char *text, int start, int end); char* TclReadline0generator (char *text, int state); char* TclReadline1generator (char *text, int state); char* TclReadlineKnownCommands (char *text, int state, int mode); int TclReadlineParse (char **args, int maxargs, char *buf); enum { LINE_PENDING, LINE_CONTROL_D, LINE_COMPLETE }; static int line_complete = LINE_PENDING; static char *line = (char *) NULL; int TclReadlineCmd( ClientData clientData, /* Main window associated with interpreter */ Tcl_Interp* interp, /* Current interpreter */ int argc, /* Number of arguments */ char** argv /* Argument strings */ ) { int c, length; if (argc < 2) { interp->result = "wrong # args"; for (c = 0; c < argc; c++) fprintf (stderr, "argv[%d] = %s\n", c, argv[c]); return TCL_ERROR; } c = argv[1][0]; length = strlen(argv[1]); if (c == 'r' && strncmp (argv[1], "read", length) == 0) { char *expansion = (char *) NULL; int status; line_complete = LINE_PENDING; rl_callback_handler_install (argc == 3 ? argv[2] : "%", TclReadlineLineCompleteHandler); Tcl_CreateFileHandler (0, TCL_READABLE, TclReadlineDataAvailableHandler, (ClientData) NULL); while (LINE_PENDING == line_complete) { Tcl_DoOneEvent (0); } Tcl_DeleteFileHandler (0); /* if (LINE_CONTROL_D == line_complete) { Tcl_Eval (interp, "puts {}; exit"); } */ status = history_expand (line, &expansion); if (status == 1) printf ("%s\n", expansion); else if (status == -1) Tcl_AppendResult (interp, "error in history expansion\n", (char *) NULL); |
︙ | ︙ | |||
210 211 212 213 214 215 216 | Tcl_AppendResult (interp, "wrong # args: should be \"readline option ?arg ...?\"", (char *) NULL); return TCL_ERROR; } | > | > < > | < > > > > > | > | > | > | > | | 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 | Tcl_AppendResult (interp, "wrong # args: should be \"readline option ?arg ...?\"", (char *) NULL); return TCL_ERROR; } void TclReadlineDataAvailableHandler(ClientData clientData, int mask) { #if 0 fprintf (stderr, "(TclReadlineDataAvailableHandler) mask = %d\n", mask); #endif if (mask & TCL_READABLE) { while (0 == rl_done) rl_callback_read_char (); } } void TclReadlineLineCompleteHandler(char *ptr) { #if 0 fprintf (stderr, "(TclReadlineLineCompleteHandler) ptr = %p\n", ptr); if (ptr) fprintf (stderr, "(TclReadlineLineCompleteHandler) *ptr = %p\n", *ptr); if (!ptr) { /* <c-d> */ line_complete = LINE_CONTROL_D; rl_callback_handler_remove (); } else if (*ptr) { line_complete = LINE_COMPLETE; rl_callback_handler_remove (); line = ptr; } #endif if (ptr && *ptr) { line_complete = 1; rl_callback_handler_remove (); line = ptr; } } int Tclreadline_SafeInit(Tcl_Interp *interp) { return Tclreadline_Init (interp); } int Tclreadline_Init(Tcl_Interp *interp) { Tcl_CreateCommand (interp, "::tclreadline::readline", TclReadlineCmd, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); return Tcl_PkgProvide (interp, "tclreadline", TCLREADLINE_VERSION); } char* TclReadlineInitialize(char* historyfile) { rl_readline_name = "tclreadline"; using_history (); /* * try to read historyfile in home * directory. If this failes, this * is *not* an error. */ rl_attempted_completion_function = (CPPFunction *) TclReadlineCompletion; if (read_history (historyfile)) return "unable to read history file"; else return ""; } char** TclReadlineCompletion(char* text, int start, int end) { char **matches = (char **) NULL; static char local_line[BUFSIZ]; strcpy (local_line, rl_line_buffer); STRIPWHITE (local_line); |
︙ | ︙ | |||
293 294 295 296 297 298 299 | matches = completion_matches (text, TclReadline0generator); else matches = completion_matches (text, TclReadline1generator); return matches; } | > | > | > | > | | 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 | matches = completion_matches (text, TclReadline0generator); else matches = completion_matches (text, TclReadline1generator); return matches; } char* TclReadline0generator(char* text, int state) { return TclReadlineKnownCommands (text, state, _CMD_GET); } char* TclReadline1generator(char* text, int state) { return TclReadlineKnownCommands (text, state, _CMD_SUB_GET); } char* TclReadlineKnownCommands(char* text, int state, int mode) { static int len; static cmds_t *cmds = (cmds_t *) NULL, *new; char* tmp; char* args[256]; int i, argc; char **name; switch (mode) { case _CMD_SET: |
︙ | ︙ | |||
372 373 374 375 376 377 378 | len = strlen (local_line); STRIPRIGHT (local_line); if (len != strlen (local_line)) sub = TclReadlineParse (args, sizeof (args), local_line); else | | < | 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | len = strlen (local_line); STRIPRIGHT (local_line); if (len != strlen (local_line)) sub = TclReadlineParse (args, sizeof (args), local_line); else sub = TclReadlineParse(args, sizeof(args), local_line) - 1; new = cmds; len = strlen (text); while (new && (name = new->cmd)) { if (!strcmp (name[0], args[0])) break; |
︙ | ︙ | |||
407 408 409 410 411 412 413 | default: return (char *) NULL; break; } | < | | | < < < < < < | | 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 | default: return (char *) NULL; break; } /* NOTREACHED */ } int TclReadlineParse(char** args, int maxargs, char* buf) { int nr = 0; while (*buf != '\0' && nr < maxargs) { /* * Strip whitespace. Use nulls, so * that the previous argument is terminated |
︙ | ︙ | |||
443 444 445 446 447 448 449 | while ((*buf!='\0') && (*buf!=' ') && (*buf!='\t') && (*buf!='\n')) buf++; } *args = '\0'; return nr; | | < | 443 444 445 446 447 448 449 450 | while ((*buf!='\0') && (*buf!=' ') && (*buf!='\t') && (*buf!='\n')) buf++; } *args = '\0'; return nr; } |