Check-in [f815040834]
Not logged in
Overview
Comment: Modified Files: .csymrc .tclshrc src/csym/.csymrc src/tclreadline/README src/tclreadline/TODO src/tclreadline/configure.in src/tclreadline/sample.tclshrc src/tclreadline/tclreadline.n.in src/tclreadline/tclreadlineSetup.tcl.in Added Files: src/csym/version 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: f8150408345547263381774afc516ab635858223
User & Date: johannes@zellner.org on 1999-08-28 22:12:31
Other Links: manifest | tags
Context
1999-08-29
14:41
Modified Files: share/vim/ft/tcl_ft.vim src/tclreadline/README src/tclreadline/configure.in src/tclreadline/tclreadline.h.in src/tclreadline/tclreadline.n.in src/tclreadline/tclreadlineSetup.tcl.in Added Files: bin/script/tcltags src/csym/version src/tclreadline/Makefile.in src/tclreadline/tclreadline.c src/tclreadline/tclreadlineConfig.sh.in src/tclreadline/tclreadlineInit.tcl.in check-in: a912dd1a5a user: johannes@zellner.org tags: trunk
1999-08-28
22:12
Modified Files: .csymrc .tclshrc src/csym/.csymrc src/tclreadline/README src/tclreadline/TODO src/tclreadline/configure.in src/tclreadline/sample.tclshrc src/tclreadline/tclreadline.n.in src/tclreadline/tclreadlineSetup.tcl.in Added Files: src/csym/version src/tclreadline/Makefile.in src/tclreadline/tclreadline.c src/tclreadline/tclreadlineConfig.sh.in src/tclreadline/tclreadlineInit.tcl.in check-in: f815040834 user: johannes@zellner.org tags: trunk
1999-08-27
15:48
Modified Files: .login Modified Files: Exception.h StdMatrix.h StdVector.h Modified Files: tclreadline.c tclreadlineSetup.tcl.in check-in: be5c9f0d5b user: johannes@zellner.org tags: trunk
Changes

Modified README from [ae8d6ff895] to [37f97b7756].

1
2
3
4
5
6
7
8
9
10

    FILE: "/diska/home/joze/src/tclreadline/README"
    LAST MODIFICATION: "Mon Aug 23 19:42:31 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

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

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

72
73
74
75
76
77
78

























79
80
81
82
83
84
85
installed tclreadline properly, you are just ready to start:
start your favorite interpreter. The tclreadlineSetup.tcl script
does the rest.


4. History and Changes.
-----------------------


























tclreadline-0.9: (Aug 1999)

    changes:
        - tclreadline::readline customcompleter
        - tclreadline::readline builtincompleter
        - tclreadline::readline eofchar







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







72
73
74
75
76
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
installed tclreadline properly, you are just ready to start:
start your favorite interpreter. The tclreadlineSetup.tcl script
does the rest.


4. History and Changes.
-----------------------

tclreadline-0.9.2: (Aug 1999)

    changes:
        - history event `!' expansion on <Tab>
        - if tclreadline::historyLength >= 0,
          tclreadline::write will truncate the historyfile
          to this value.
          By default tclreadline::historyfile == -1, that
          is no truncation occurs.

    fixes:
        - after having at least one character typed, X events
          were not processed any more until pressing <return>.


tclreadline-0.9.1: (Aug 1999)

    changes:
        - new variable tclreadline_patchLevel
        - tclreadline::Loop takes an optional <historyfile>

    fixes:
        - tying to fix configure problems.


tclreadline-0.9: (Aug 1999)

    changes:
        - tclreadline::readline customcompleter
        - tclreadline::readline builtincompleter
        - tclreadline::readline eofchar
95
96
97
98
99
100
101

102
103
104
105

106
107
108
          namespace import tclreadline::ls (see sample.tclshrc).

    bug fixes:
        - lines added to tcl's history. (were only in readline's hist.)
        - macro mappings didn't work. (only when hitting
          mapped characters more than once.)
        - various changes and fixes in configure.in


tclreadline-0.8: (May 1999)
    - adapted for tcl8.1.
    - minor bug fixes.


tclreadline-0.7: (Feb 1999)
    first `public release'.







>




>



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
          namespace import tclreadline::ls (see sample.tclshrc).

    bug fixes:
        - lines added to tcl's history. (were only in readline's hist.)
        - macro mappings didn't work. (only when hitting
          mapped characters more than once.)
        - various changes and fixes in configure.in


tclreadline-0.8: (May 1999)
    - adapted for tcl8.1.
    - minor bug fixes.


tclreadline-0.7: (Feb 1999)
    first `public release'.

Modified TODO from [d280cb1986] to [ad5b37c53f].

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

 /* ==================================================================
   
    FILE: "/krispc6/home/joze/src/tclreadline/TOOD"
    LAST MODIFICATION: "Sat May  8 14:06:05 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: "/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

25
26
27
28
29
30
31
32
33
34


35
36


37

    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

    <johannes@zellner.org>, http://www.zellner.org/tclreadline/

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


    +  write README.
    +  write docs.
    +  use *forced* TCL_PREFIX or TCL_EXEC_PREFIX for installation.


       (unless specified via --prefix or --exec-prefix).
    +  write make release entry in Makefile.in


    +  update make ci.








|
|
|
>
>
|
|
>
>
|
>
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

    <johannes@zellner.org>, http://www.zellner.org/tclreadline/

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


    +  history_truncate_file(int n, char* historyfile)
       verwenden, um nur eine begrenze Zahl zu schreiben.

    +  wenn nur ein array Element von a vorliegt,
       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. !$).

Modified configure.in from [deb9dd7b2c] to [f2de18b30a].

1
2
3
4
5
6
7
8
9
10
# -*- autoconf -*-
# FILE: "/diska/home/joze/src/tclreadline/configure.in"
# LAST MODIFICATION: "Wed Aug 25 16:17:27 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
# -*- autoconf -*-
# FILE: "/home/joze/src/tclreadline/configure.in"
# LAST MODIFICATION: "Sat Aug 28 22:23:57 1999 (joze)"
# (C) 1998, 1999 by Johannes Zellner, <johannes@zellner.org>
# $Id$
# ---
#
# tclreadline -- gnu readline for tcl
# Copyright (C) 1999  Johannes Zellner
#
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

AC_REVISION($Revision$)

AC_INIT(tclreadline.c)

TCLREADLINE_MAJOR_VERSION=0
TCLREADLINE_MINOR_VERSION=9
TCLREADLINE_PATCHLEVEL=1
TCLREADLINE_VERSION=$TCLREADLINE_MAJOR_VERSION.$TCLREADLINE_MINOR_VERSION
VERSION=$TCLREADLINE_VERSION


AC_PREREQ(2.13)
AC_CONFIG_AUX_DIR(./aux)
AC_CANONICAL_HOST







|







33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

AC_REVISION($Revision$)

AC_INIT(tclreadline.c)

TCLREADLINE_MAJOR_VERSION=0
TCLREADLINE_MINOR_VERSION=9
TCLREADLINE_PATCHLEVEL=2
TCLREADLINE_VERSION=$TCLREADLINE_MAJOR_VERSION.$TCLREADLINE_MINOR_VERSION
VERSION=$TCLREADLINE_VERSION


AC_PREREQ(2.13)
AC_CONFIG_AUX_DIR(./aux)
AC_CANONICAL_HOST

Modified sample.tclshrc from [d234ad5a9b] to [26541f9376].

1
2
3
4
5
6
7
8
9
10
#!/bin/sh
# FILE: "/diska/home/joze/src/tclreadline/sample.tclshrc"
# LAST MODIFICATION: "Mon Aug 23 17:50:54 1999 (joze)"
# (C) 1999 by Johannes Zellner, <johannes@zellner.org>
# $Id$
# vim:set ft=tcl: \
exec tclsh "$0" "$@"


if {$tcl_interactive} {

|
|







1
2
3
4
5
6
7
8
9
10
#!/bin/sh
# FILE: "/home/joze/src/tclreadline/sample.tclshrc"
# LAST MODIFICATION: "Sat Aug 28 23:41:17 1999 (joze)"
# (C) 1999 by Johannes Zellner, <johannes@zellner.org>
# $Id$
# vim:set ft=tcl: \
exec tclsh "$0" "$@"


if {$tcl_interactive} {
40
41
42
43
44
45
46




47
48
49
50
51
52
    # tclreadline::Print no

    # uncomment the folling line, if you want
    # to change tclreadline's print behaviour
    # frequently with less typing.
    #
    # namespace import tclreadline::Print





    # go to tclrealdine's main loop.
    #
    tclreadline::Loop
}








>
>
>
>






40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
    # tclreadline::Print no

    # uncomment the folling line, if you want
    # to change tclreadline's print behaviour
    # frequently with less typing.
    #
    # namespace import tclreadline::Print

    # store maximal this much lines in the history file
    #
    set tclreadline::historyLength 200

    # go to tclrealdine's main loop.
    #
    tclreadline::Loop
}

Modified tclreadline.c from [e6dc3b897a] to [4b2effb6b7].

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

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

    FILE: "/diska/home/joze/src/tclreadline/tclreadline.c"
    LAST MODIFICATION: "Fri Aug 27 16:18:44 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: "/home/joze/src/tclreadline/tclreadline.c"
    LAST MODIFICATION: "Sat Aug 28 23:56:10 1999 (joze)"
    (C) 1998, 1999 by Johannes Zellner, <johannes@zellner.org>
    $Id$
    ---

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

66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
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* TclReadlineInitialize(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 { 







|







66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
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);
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 { 
88
89
90
91
92
93
94

95
96
97
98
99
100
101
 */
static int tclrl_line_complete = LINE_PENDING;
static int tclrl_state = TCL_OK;
static char* tclrl_eof_string = (char*) NULL;
static char* tclrl_line = (char*) NULL;
static char* tclrl_custom_completer = (char*) NULL;
static int tclrl_use_builtin_completer = 1;

Tcl_Interp* tclrl_interp = (Tcl_Interp*) NULL;


char*
stripleft(char* in)
{
    char* ptr = in;







>







88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
 */
static int tclrl_line_complete = LINE_PENDING;
static int tclrl_state = TCL_OK;
static char* tclrl_eof_string = (char*) NULL;
static char* tclrl_line = (char*) NULL;
static char* tclrl_custom_completer = (char*) NULL;
static int tclrl_use_builtin_completer = 1;
static int tclrl_history_length = -1;
Tcl_Interp* tclrl_interp = (Tcl_Interp*) NULL;


char*
stripleft(char* in)
{
    char* ptr = in;
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
209
210
211
212
213
214






215
216
217
218
219
220
221
        tclrl_state = TCL_OK;
        rl_callback_handler_install(argc == 3 ? argv[2] : "%",
                TclReadlineLineCompleteHandler);

        Tcl_CreateFileHandler(0, TCL_READABLE,
                TclReadlineDataAvailableHandler, (ClientData) NULL);

        while (LINE_PENDING == tclrl_line_complete && TCL_OK == tclrl_state) {

            Tcl_DoOneEvent(0);



        }

        Tcl_DeleteFileHandler(0);

	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)







            printf("%s\n", expansion);


        else if (status == -1)
            Tcl_AppendResult(interp, "error in history expansion\n",
                    (char*) NULL);





        
        if (expansion && *expansion)
            add_history(expansion);

        Tcl_AppendResult(interp, expansion, (char*) NULL);

        FREE(tclrl_line);
        FREE(expansion);
        return tclrl_state;
    } else if (c == 'i'  && strncmp(argv[1], "initialize", length) == 0) {
        if (3 != argc)
            goto BAD_COMMAND;
        else
            Tcl_AppendResult(interp, TclReadlineInitialize(argv[2]),
                    (char*) NULL);
    } else if (c == 'w'  && strncmp(argv[1], "write", length) == 0) {
        if (3 != argc)
            goto BAD_COMMAND;
        else if (write_history(argv[2]))
            Tcl_AppendResult(interp, "unable to write history to \"",
                    argv[2], "\"\n", (char*) NULL);






    } else if (c == 'a'  && strncmp(argv[1], "add", length) == 0) {
        if (3 != argc)
            goto BAD_COMMAND;
        else if (TclReadlineKnownCommands(argv[2], (int) 0, _CMD_SET))
            Tcl_AppendResult(interp, "unable to add command \"",
                    argv[2], "\"\n", (char*) NULL);
    } else if (c == 'c'  && strncmp(argv[1], "complete", length) == 0) {







|
>

>
>
>










|
>
>
>
>
>
>
>

>
>
|
|
|
>
>
>
>
>













|
<

|

|
|
|
>
>
>
>
>
>







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
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
        tclrl_state = TCL_OK;
        rl_callback_handler_install(argc == 3 ? argv[2] : "%",
                TclReadlineLineCompleteHandler);

        Tcl_CreateFileHandler(0, TCL_READABLE,
                TclReadlineDataAvailableHandler, (ClientData) NULL);

        while (LINE_PENDING == tclrl_line_complete
            && TCL_OK == tclrl_state && !rl_done) {
            Tcl_DoOneEvent(0);
            /*
            rl_inhibit_completion = 0;
            */
        }

        Tcl_DeleteFileHandler(0);

	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_Flush(channel);
            Tcl_Close(interp, channel);
#else
            printf("%s\n", expansion);
#endif
        }
        else if (status == -1) {
            Tcl_AppendResult
                (interp, "error in history expansion\n", (char*) NULL);
            return TCL_ERROR;
        }
        /**
         * TODO: status == 2 ...
         */
        
        if (expansion && *expansion)
            add_history(expansion);

        Tcl_AppendResult(interp, expansion, (char*) NULL);

        FREE(tclrl_line);
        FREE(expansion);
        return tclrl_state;
    } else if (c == 'i'  && strncmp(argv[1], "initialize", length) == 0) {
        if (3 != argc)
            goto BAD_COMMAND;
        else
            return TclReadlineInitialize(interp, argv[2]);

    } else if (c == 'w'  && strncmp(argv[1], "write", length) == 0) {
        if (3 != argc) {
            goto BAD_COMMAND;
        }  else if (write_history(argv[2])) {
            Tcl_AppendResult(interp, "unable to write history to `",
                    argv[2], "'\n", (char*) NULL);
            return TCL_ERROR;
        }
        if (tclrl_history_length >= 0) {
            history_truncate_file(argv[2], tclrl_history_length);
        }
        return TCL_OK;
    } else if (c == 'a'  && strncmp(argv[1], "add", length) == 0) {
        if (3 != argc)
            goto BAD_COMMAND;
        else if (TclReadlineKnownCommands(argv[2], (int) 0, _CMD_SET))
            Tcl_AppendResult(interp, "unable to add command \"",
                    argv[2], "\"\n", (char*) NULL);
    } else if (c == 'c'  && strncmp(argv[1], "complete", length) == 0) {
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
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 1







<
|







301
302
303
304
305
306
307

308
309
310
311
312
313
314
315
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
312
313
314
315
316
317
318

319
320
321





322
323
324
325

326
327
328
329
330
331
332
333
{
    return Tclreadline_Init(interp);
}

int
Tclreadline_Init(Tcl_Interp *interp)
{

    Tcl_CreateCommand(interp, "::tclreadline::readline", TclReadlineCmd,
	    (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
    tclrl_interp = interp;





    return Tcl_PkgProvide(interp, "tclreadline", TCLREADLINE_VERSION);
}

char*

TclReadlineInitialize(char* historyfile)
{
    rl_readline_name = "tclreadline";
    /* rl_special_prefixes = "${\""; */
    rl_special_prefixes = "${";
    /**
     * default is " \t\n\"\\'`@$><=;|&{("
     * removed "{("







>



>
>
>
>
>



<
>
|







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
{
    return Tclreadline_Init(interp);
}

int
Tclreadline_Init(Tcl_Interp *interp)
{
    int status;
    Tcl_CreateCommand(interp, "::tclreadline::readline", TclReadlineCmd,
	    (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
    tclrl_interp = interp;
    status = Tcl_LinkVar
        (interp, "::tclreadline::historyLength",
         (char*) &tclrl_history_length, TCL_LINK_INT);
    if (TCL_OK != status)
        return status;
    return Tcl_PkgProvide(interp, "tclreadline", TCLREADLINE_VERSION);
}


int
TclReadlineInitialize(Tcl_Interp* interp, char* historyfile)
{
    rl_readline_name = "tclreadline";
    /* rl_special_prefixes = "${\""; */
    rl_special_prefixes = "${";
    /**
     * default is " \t\n\"\\'`@$><=;|&{("
     * removed "{("
342
343
344
345
346
347
348
349
350


351
352

353
354
355
356
357
358
359
360

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

int
blank_line(char* str)
{
    char* ptr;
    for (ptr = str; ptr && *ptr; ptr++) {







|
|
>
>
|
<
>
|







371
372
373
374
375
376
377
378
379
380
381
382

383
384
385
386
387
388
389
390
391

    /*
     * 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)) {
        if (write_history(historyfile)) {
            Tcl_AppendResult (interp, "warning: `",
                historyfile, "' is not writable.", (char*) NULL);
        }

    }
    return TCL_OK;
}

int
blank_line(char* str)
{
    char* ptr;
    for (ptr = str; ptr && *ptr; ptr++) {
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
    char** matches = (char**) NULL;

#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 (tclrl_custom_completer) {
        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, "$[]{}\"");
        /*

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

        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);
        FREE(quoted_rl_line_buffer);
        if (TCL_OK != tclrl_state) {
            fprintf (stderr, "%s\n", Tcl_GetStringResult(tclrl_interp));
            /*

            Tcl_AppendResult (tclrl_interp, "`", tclrl_custom_completer,
                " {", text, "} ", start_s, " ", end_s,
                " {", rl_line_buffer, "}' failed.", (char*) NULL);
            */

            return matches;
        }
        obj = Tcl_GetObjResult(tclrl_interp);
        Tcl_ListObjGetElements(tclrl_interp, obj, &objc, &objv);
        /* fprintf (stderr, "(TclReadlineCompletion) objc = %d\n", objc); */
        if (objc) {
            int i, length /* not used */;







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









<
>







<
>









|
<
>



<
>







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
    char** matches = (char**) NULL;

#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);
        int 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;
        }
        FREE(expansion);
    }

    if (tclrl_custom_completer) {
        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);
        FREE(quoted_rl_line_buffer);
        if (TCL_OK != tclrl_state) {
            fprintf(stderr, "%s\n", Tcl_GetStringResult(tclrl_interp));

#if 0
            Tcl_AppendResult (tclrl_interp, "`", tclrl_custom_completer,
                " {", text, "} ", start_s, " ", end_s,
                " {", rl_line_buffer, "}' failed.", (char*) NULL);

#endif
            return matches;
        }
        obj = Tcl_GetObjResult(tclrl_interp);
        Tcl_ListObjGetElements(tclrl_interp, obj, &objc, &objv);
        /* fprintf (stderr, "(TclReadlineCompletion) objc = %d\n", objc); */
        if (objc) {
            int i, length /* not used */;
455
456
457
458
459
460
461

462
463
464
465
466
467
468
    char* tmp;
    char* args[256];
    int i, argc;
    char** name;

    char* local_line = (char*) NULL;
    int sub;

    
    switch (mode) {
        
        case _CMD_SET:

            new = (cmds_t *) MALLOC(sizeof(cmds_t));
            new->next = (cmds_t *) NULL;







>







524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
    char* tmp;
    char* args[256];
    int i, argc;
    char** name;

    char* local_line = (char*) NULL;
    int sub;

    
    switch (mode) {
        
        case _CMD_SET:

            new = (cmds_t *) MALLOC(sizeof(cmds_t));
            new->next = (cmds_t *) NULL;
492
493
494
495
496
497
498

499
500
501
502
503
504
505
506
507
508
509
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
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
575

        case _CMD_GET:

            local_line = strdup(rl_line_buffer);
            sub = TclReadlineParse(args, sizeof(args), local_line);
            /*
             * fprintf (stderr, "(TclReadlineKnownCommands) state=%d\n", state);

             */

            if (0 == sub || (1 == sub && '\0' != text[0])) {
                if (!state) {
                    new = cmds;
                    len = strlen(text);
                }
                while (new && (name = new->cmd)) {
                    new = new->next;
                    if (!strncmp(name[0], text, len))
                        return strdup(name[0]);
                }
                return (char*) NULL;
            } else {

                if (!state) {

#if 0
                    fprintf (stderr,
                        "(TclReadlineKnownCommands) _CMD_SUB_GET = |%s| %d %d\n",
                        text, state, mode);
#endif

                    /*
                    len = strlen(local_line);
                    stripright(local_line);
                    */

#if 0
                    if (len != strlen(local_line)) {
#endif
#if 0
                    } else {
                        sub = TclReadlineParse(args, sizeof(args), local_line) - 1;
                    }
#endif
#if 0
                    {
                        int i;
                        fprintf (stderr, "\n");
                        for (i = 0; i < sub; i++)
                            fprintf (stderr, "|%s|\n", args[i]);
                    }

                    fprintf (stderr,
                        "(TclReadlineKnownCommands) args[sub - 1] = |%s|\n",
                        args[sub - 1]);
#endif
#if 0
                    if (sub > 0 && args[sub - 1] && *(args[sub - 1]) == '$') {
                        char* var = strdup(args[sub - 1] + 1);
                        char* ptr = var;
                        int varlen;
                        if (var)
                            varlen = strlen(var);
                        else
                            return (char*) NULL;
                        if (!varlen) {
                            FREE(var);
                            return (char* ) NULL;
                        } else if ('{' == var[0]) {
                            ptr++;
                            varlen--;
                        }
                        fprintf (stderr, "(TclReadlineKnownCommands) $\n");
                        FREE(var);
                        return (char* ) NULL;
                    }
#endif

                    new = cmds;
                    len = strlen(text);

                    while (new && (name = new->cmd)) {
                        if (!strcmp(name[0], args[0]))
                            break;
                        new = new->next;







>

















<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586





















































587
588
589
590
591
592
593

        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)) {
                    new = new->next;
                    if (!strncmp(name[0], text, len))
                        return strdup(name[0]);
                }
                return (char*) NULL;
            } else {

                if (!state) {






















































                    new = cmds;
                    len = strlen(text);

                    while (new && (name = new->cmd)) {
                        if (!strcmp(name[0], args[0]))
                            break;
                        new = new->next;

Modified tclreadline.n.in from [7d9606e31a] to [ec21a73d43].

1
2
3
4
5
6
7
8
9
10
11
12
.TH tclreadline n "@TCLREADLINE_VERSION@.@TCLREADLINE_PATCHLEVEL@" "Johannes Zellner"

.\" (C) 1999 by Johannes Zellner
.\" FILE: "/diska/home/joze/src/tclreadline/tclreadline.n.in"
.\" LAST MODIFICATION: "Wed Aug 25 16:32:02 1999 (joze)"
.\" (C) 1998, 1999 by Johannes Zellner, <johannes@zellner.org>
.\" $Id$
.\" ---
.\"
.\" tclreadline -- gnu readline for the tcl scripting language
.\" Copyright (C) 1999  Johannes Zellner
.\"



|
|







1
2
3
4
5
6
7
8
9
10
11
12
.TH tclreadline n "@TCLREADLINE_VERSION@.@TCLREADLINE_PATCHLEVEL@" "Johannes Zellner"

.\" (C) 1999 by Johannes Zellner
.\" FILE: "/home/joze/src/tclreadline/tclreadline.n.in"
.\" LAST MODIFICATION: "Sat Aug 28 23:38:44 1999 (joze)"
.\" (C) 1998, 1999 by Johannes Zellner, <johannes@zellner.org>
.\" $Id$
.\" ---
.\"
.\" tclreadline -- gnu readline for the tcl scripting language
.\" Copyright (C) 1999  Johannes Zellner
.\"
77
78
79
80
81
82
83
84




85
86
87
88
89
90
91
.\" .SH SOURCE FILES


.SH "COMMANDS"

If you want to use \fBtclreadline\fP as a line interface
for developing tcl scripts, you probably don't have to read
this section.





.PP
The following list will give all commands, which are currently
implemented in the shared lib (e.g. libtclreadline@TCLREADLINE_VERSION@.so).
Additional commands were introduced in a startup script
\fBtclreadlineSetup.tcl\fP, which lives in the tclreadline
installation directory.







|
>
>
>
>







77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
.\" .SH SOURCE FILES


.SH "COMMANDS"

If you want to use \fBtclreadline\fP as a line interface
for developing tcl scripts, you probably don't have to read
this section. In this case the only thing you should do is
to modify your .tclshrc according to the section \fBFILES\fP.

For the functionality of the GNU readline you should refer to
the readline's documentation.

.PP
The following list will give all commands, which are currently
implemented in the shared lib (e.g. libtclreadline@TCLREADLINE_VERSION@.so).
Additional commands were introduced in a startup script
\fBtclreadlineSetup.tcl\fP, which lives in the tclreadline
installation directory.
166
167
168
169
170
171
172


173
174
175
176
177
178
179
loop. Both readline and X events are processed. Returns the
(eventually history-expanded) input string.

.TP 5
\fB::tclreadline::readline write\fP \fIhistoryfile\fP
writes the history to the \fIhistoryfile\fP. This command is called
automatically from the internal routine ::tclreadline::Exit.



.TP 5
\fB::tclreadline::Print\fP [\fIyes / no\fP]
turns on or off the default behavior of tclsh to print the result of
every command. This is turned on by default, so it will just behave
as the tclsh w/o tclreadline. Turning off might be useful, when reading
binary data for example. If \fB::tclreadline::Print\fP is called w/o







>
>







170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
loop. Both readline and X events are processed. Returns the
(eventually history-expanded) input string.

.TP 5
\fB::tclreadline::readline write\fP \fIhistoryfile\fP
writes the history to the \fIhistoryfile\fP. This command is called
automatically from the internal routine ::tclreadline::Exit.
If the variable \fBtclreadline::historyLength\fP is non-negative,
the historyfile will be truncated to hold only this number lines.

.TP 5
\fB::tclreadline::Print\fP [\fIyes / no\fP]
turns on or off the default behavior of tclsh to print the result of
every command. This is turned on by default, so it will just behave
as the tclsh w/o tclreadline. Turning off might be useful, when reading
binary data for example. If \fB::tclreadline::Print\fP is called w/o
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
.\" .SH "EXAMPLES"


.\" .SH "ENVIRONMENT VARIABLES"

.SH "VARIABLES"

\fItclreadline\fP defines the following variables in the global namespace:




.TP 5
\fBtclreadline_version\fP
holds the version string "@TCLREADLINE_VERSION@".

.TP 5
\fBtclreadline_patchLevel\fP
holds the patch level string "@TCLREADLINE_VERSION@.@TCLREADLINE_PATCHLEVEL@".

.TP 5
\fBtclreadline_library\fP
holds the library string "@TCLREADLINE_LIBRARY@".







.SH "FILES"

the \fB.tclshrc\fP file in the HOME directory, which
is read on tclsh startup. Alternatively, the name of this initialization
file might be \fB.wishrc\fP ... depending on what interpreter you use.
These files should typically contain something like
.CS







|
>
>
>


|



|



|


>
>
>
>
>
>







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
.\" .SH "EXAMPLES"


.\" .SH "ENVIRONMENT VARIABLES"

.SH "VARIABLES"

\fItclreadline\fP defines the following variables in the
namespace \fI::tclreadline\fP:
(for backwards compatiblity the global variables tclreadline_version,
 tclreadline_patchLevel and tclreadline_library are still present).

.TP 5
\fBtclreadline::version\fP
holds the version string "@TCLREADLINE_VERSION@".

.TP 5
\fBtclreadline::patchLevel\fP
holds the patch level string "@TCLREADLINE_VERSION@.@TCLREADLINE_PATCHLEVEL@".

.TP 5
\fBtclreadline::library\fP
holds the library string "@TCLREADLINE_LIBRARY@".

.TP 5
\fBtclreadline::historyLength\fP
Number of lines, which will be written to the historyfile.
This number is -1 by default, which means that the historyfile
will not be truncated.  See also \fBtclreadline::write\fP.

.SH "FILES"

the \fB.tclshrc\fP file in the HOME directory, which
is read on tclsh startup. Alternatively, the name of this initialization
file might be \fB.wishrc\fP ... depending on what interpreter you use.
These files should typically contain something like
.CS

Modified tclreadlineInit.tcl.in from [7b078b76d4] to [e2d2c550d3].

1
2
3
4
5
6
7
8
9
10
#!/usr/local/bin/tclsh
# FILE: "/diska/home/joze/src/tclreadline/tclreadlineInit.tcl.in"
# LAST MODIFICATION: "Wed Aug 25 16:27:19 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/local/bin/tclsh
# FILE: "/home/joze/src/tclreadline/tclreadlineInit.tcl.in"
# LAST MODIFICATION: "Sun Aug 29 00:03:22 1999 (joze)"
# (C) 1998, 1999 by Johannes Zellner, <johannes@zellner.org>
# $Id$
# ---
#
# tclreadline -- gnu readline for tcl
# Copyright (C) 1999  Johannes Zellner
#
34
35
36
37
38
39
40
41




42

43

44
45
46

47
48
49
50
51
52
53
54
55
56
57
}

proc ::tclreadline::Init {} {
    
    global tclreadline_version
    global tclreadline_library
    global tclreadline_patchLevel
    




    set tclreadline_version @TCLREADLINE_VERSION@

    set tclreadline_library @TCLREADLINE_LIBRARY@

    # NOTE, that tclreadline_patchLevel is the complete patchlevel string.
    #
    set tclreadline_patchLevel @TCLREADLINE_VERSION@.@TCLREADLINE_PATCHLEVEL@


    if [catch {load @TCLREADLINE_LIBRARY@/@TCLREADLINE_LIB_FILE@} msg] {
        puts stderr $msg
        exit 2
    }
}

tclreadline::Init

source [file join [file dirname [info script]] tclreadlineSetup.tcl]








|
>
>
>
>

>

>



>











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

proc ::tclreadline::Init {} {
    
    global tclreadline_version
    global tclreadline_library
    global tclreadline_patchLevel

    variable version
    variable library
    variable patchLevel
    
    set tclreadline_version @TCLREADLINE_VERSION@
    set version @TCLREADLINE_VERSION@
    set tclreadline_library @TCLREADLINE_LIBRARY@
    set library @TCLREADLINE_LIBRARY@
    # NOTE, that tclreadline_patchLevel is the complete patchlevel string.
    #
    set tclreadline_patchLevel @TCLREADLINE_VERSION@.@TCLREADLINE_PATCHLEVEL@
    set patchLevel @TCLREADLINE_VERSION@.@TCLREADLINE_PATCHLEVEL@

    if [catch {load @TCLREADLINE_LIBRARY@/@TCLREADLINE_LIB_FILE@} msg] {
        puts stderr $msg
        exit 2
    }
}

tclreadline::Init

source [file join [file dirname [info script]] tclreadlineSetup.tcl]

Modified tclreadlineSetup.tcl.in from [2ee5cd5fbe] to [235d3d230f].

1
2
3
4
5
6
7
8
9
10
#!/usr/local/bin/tclsh
# FILE: "/diska/home/joze/src/tclreadline/tclreadlineSetup.tcl.in"
# LAST MODIFICATION: "Fri Aug 27 16:08:15 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/local/bin/tclsh
# FILE: "/home/joze/src/tclreadline/tclreadlineSetup.tcl.in"
# LAST MODIFICATION: "Sat Aug 28 23:58:03 1999 (joze)"
# (C) 1998, 1999 by Johannes Zellner, <johannes@zellner.org>
# $Id$
# ---
#
# tclreadline -- gnu readline for tcl
# Copyright (C) 1999  Johannes Zellner
#
377
378
379
380
381
382
383
384
385
386


387
388
389
390
391
392
393
        if {[info procs exit] == ""} {

            catch {rename ::tclreadline::Exit ""}
            rename exit ::tclreadline::Exit

            proc exit {args} {

                catch {
                    ::tclreadline::readline write \
                    [::tclreadline::HistoryFileGet]


                }

                if [catch "eval ::tclreadline::Exit $args" message] {
                    puts stderr "error:"
                    puts stderr "$message"
                }
                # NOTREACHED







|


>
>







377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
        if {[info procs exit] == ""} {

            catch {rename ::tclreadline::Exit ""}
            rename exit ::tclreadline::Exit

            proc exit {args} {

                if {[catch {
                    ::tclreadline::readline write \
                    [::tclreadline::HistoryFileGet]
                } msg]} {
                    puts stderr $msg
                }

                if [catch "eval ::tclreadline::Exit $args" message] {
                    puts stderr "error:"
                    puts stderr "$message"
                }
                # NOTREACHED