Check-in [0db7d87bfc]
Not logged in
Overview
Comment: .csymrc .tclshrc .vimrc tcltags StdOper.h StdVector.h vimrc Modified Files: .csymrc Containers.h HKLlink.h TclVector.h config.h.in configure.in csym.cc hkl.h misc.cc string.priv.h TODO tclreadline.c tclreadlineSetup.tcl.in
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 0db7d87bfc2a3fce98164fa6e3f40b82a44e7b53
User & Date: johannes@zellner.org on 1999-09-03 00:14:49
Other Links: manifest | tags
Context
1999-09-03
08:21
tclreadlineSetup.tcl.in check-in: d3a9894793 user: johannes@zellner.org tags: trunk
00:14
.csymrc .tclshrc .vimrc tcltags StdOper.h StdVector.h vimrc Modified Files: .csymrc Containers.h HKLlink.h TclVector.h config.h.in configure.in csym.cc hkl.h misc.cc string.priv.h TODO tclreadline.c tclreadlineSetup.tcl.in check-in: 0db7d87bfc user: johannes@zellner.org tags: trunk
1999-09-01
03:22
Modified Files: README tclreadlineSetup.tcl.in Added Files: Makefile.in tclreadline.c tclreadlineConfig.sh.in tclreadlineInit.tcl.in check-in: b7f4ea7980 user: johannes@zellner.org tags: trunk
Changes

Modified TODO from [ad5b37c53f] to [9c4e002210].

1
2
3
4
5
6
7
8
9
10
11
12

 /* ==================================================================
   
    FILE: "/home/joze/src/tclreadline/TODO"
    LAST MODIFICATION: "Sat Aug 28 23:20:25 1999 (joze)"
    (C) 1998, 1999 by Johannes Zellner, <johannes@zellner.org>
    $Id$
    ---

    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/TODO"
    LAST MODIFICATION: "Thu Sep  2 04:06:52 1999 (joze)"
    (C) 1998, 1999 by Johannes Zellner, <johannes@zellner.org>
    $Id$
    ---

    tclreadline -- gnu readline for tcl
    Copyright (C) 1999  Johannes Zellner

36
37
38
39
40
41
42






       wird trotzdem nur auf $a( completed. --> ändern.

    +  custom completers:
       prüfen, ob ein completer für eine Funktion da ist ...
       z.B.: `set' könnte für alle Variblennamen completen.

    +  history_expansion mit <Tab> (z.B. !$).













>
>
>
>
>
>
36
37
38
39
40
41
42
43
44
45
46
47
48
       wird trotzdem nur auf $a( completed. --> ändern.

    +  custom completers:
       prüfen, ob ein completer für eine Funktion da ist ...
       z.B.: `set' könnte für alle Variblennamen completen.

    +  history_expansion mit <Tab> (z.B. !$).

    +  ist $bla das erste Wort eines Befehls, so sollte vor 
       der completion die Variable ersetzt werden, um den
       completer herauszufinden.

    +  den script completern den level mitgeben ?

Modified tclreadline.c from [3dffb52a3c] to [26244269ef].

1
2
3
4
5
6
7
8
9
10
11
12

 /* ==================================================================

    FILE: "/home/joze/src/tclreadline/tclreadline.c"
    LAST MODIFICATION: "Tue Aug 31 03:22:55 1999 (joze)"
    (C) 1998, 1999 by Johannes Zellner, <johannes@zellner.org>
    $Id$
    ---

    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.c"
    LAST MODIFICATION: "Wed Sep  1 18:58:04 1999 (joze)"
    (C) 1998, 1999 by Johannes Zellner, <johannes@zellner.org>
    $Id$
    ---

    tclreadline -- gnu readline for tcl
    Copyright (C) 1999  Johannes Zellner

32
33
34
35
36
37
38






39
40
41
42
43
44
45
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define READLINE_LIBRARY
#include <readline.h>
#include <history.h>







#include "tclreadline.h"

#define MALLOC(size) Tcl_Alloc((int) size)
#define FREE(ptr) if (ptr) { Tcl_Free((char*) ptr); ptr = 0; }

enum {
    _CMD_SET     = (1 << 0),







>
>
>
>
>
>







32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#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 {
    _CMD_SET     = (1 << 0),
61
62
63
64
65
66
67

68

69
70
71
72
73
74
75
 */
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 TclReadlineDataAvailableHandler(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);







>
|
>







67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
 */
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);
164
165
166
167
168
169
170

171
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
    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,
                TclReadlineDataAvailableHandler, (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(0);
            /*


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





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







>






|
>
>
>
>










|

>
>












>
>
>
>







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
    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);
304
305
306
307
308
309
310












311
312
313
314
315
316
317





318
















319
320
321
322
323
324
325
    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) {





        rl_callback_read_char();
















    }
}

void
TclReadlineLineCompleteHandler(char* ptr)
{
#if 1







>
>
>
>
>
>
>
>
>
>
>
>

|


|


>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
    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
    */
}
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

Modified tclreadlineSetup.tcl.in from [3f15d44e6e] to [29408eb47d].

1
2
3
4
5
6
7
8
9
10
#!/usr/locanl/bin/tclsh
# FILE: "/home/joze/src/tclreadline/tclreadlineSetup.tcl.in"
# LAST MODIFICATION: "Tue Aug 31 03:32:02 1999 (joze)"
# (C) 1998, 1999 by Johannes Zellner, <johannes@zellner.org>
# $Id$
# ---
#
# tclreadline -- gnu readline for tcl
# Copyright (C) 1999  Johannes Zellner
#

|
|







1
2
3
4
5
6
7
8
9
10
#!/usr/locanl/bin/tclsh
# FILE: "/diska/home/joze/src/tclreadline/tclreadlineSetup.tcl.in"
# LAST MODIFICATION: "Wed Sep  1 19:24:22 1999 (joze)"
# (C) 1998, 1999 by Johannes Zellner, <johannes@zellner.org>
# $Id$
# ---
#
# tclreadline -- gnu readline for tcl
# Copyright (C) 1999  Johannes Zellner
#
1455
1456
1457
1458
1459
1460
1461

1462
1463
1464
1465
1466
1467
1468
            locals -
            vars {
                if {"exists" == $cmd} {
                    set do vars
                } else {
                    set do $cmd
                }

                return \
                [Format [uplevel 2 info ${do} "${mod}*"] $text]
            }
        }
    }
    return ""
}







>







1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
            locals -
            vars {
                if {"exists" == $cmd} {
                    set do vars
                } else {
                    set do $cmd
                }
                # puts stderr [list complete(info) level = [info level]]
                return \
                [Format [uplevel 2 info ${do} "${mod}*"] $text]
            }
        }
    }
    return ""
}