Check-in [a8f8df8300]
Not logged in
Overview
Comment: Modified Files: .login Added Files: .tclcrystalrc Removed Files: .csymrc ---------------------------------------------------------------------- tcl_ft.vim tclreadline.c tclreadline.n.in tclreadlineCompleter.tcl tclreadlineSetup.tcl.in
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a8f8df8300aa49bffe98ecd20a1575963e526c33
User & Date: johannes@zellner.org on 1999-09-16 17:38:26
Other Links: manifest | tags
Context
1999-09-17
00:44
Modified Files: src/tclcrystal/.tclcrystalrc src/tclcrystal/Makefile.in src/tclcrystal/configure.in src/tclcrystal/crystal.cc src/tclreadline/README src/tclreadline/tclreadlineCompleter.tcl src/tclreadline/tclreadlineSetup.tcl.in check-in: 1f6689ebb8 user: johannes@zellner.org tags: trunk
1999-09-16
17:38
Modified Files: .login Added Files: .tclcrystalrc Removed Files: .csymrc ---------------------------------------------------------------------- tcl_ft.vim tclreadline.c tclreadline.n.in tclreadlineCompleter.tcl tclreadlineSetup.tcl.in check-in: a8f8df8300 user: johannes@zellner.org tags: trunk
09:30
tclreadlineCompleter.tcl check-in: c4f1436684 user: johannes@zellner.org tags: trunk
Changes

Modified tclreadline.c from [8639d7447d] to [42d7384f97].

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

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

    FILE: "/home/joze/src/tclreadline/tclreadline.c"
    LAST MODIFICATION: "Wed Sep 15 01:00:43 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: "/disk01/home/joze/src/tclreadline/tclreadline.c"
    LAST MODIFICATION: "Thu Sep 16 15:43:29 1999 (joze)"
    (C) 1998, 1999 by Johannes Zellner, <johannes@zellner.org>
    $Id$
    ---

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

187
188
189
190
191
192
193

194
195
196
197
198

199
200
201
202
203
204
205
{
    int i, obj_idx, status;
    Tcl_Obj** objv = (Tcl_Obj**) MALLOC((argc + 1) * sizeof(Tcl_Obj *));

    static char *subCmds[] = {
        "read", "initialize", "write", "add", "complete",
        "customcompleter", "builtincompleter", "eofchar",

        (char *) NULL
    };
    enum SubCmdIdx {
        TCLRL_READ, TCLRL_INITIALIZE, TCLRL_WRITE, TCLRL_ADD, TCLRL_COMPLETE,
        TCLRL_CUSTOMCOMPLETER, TCLRL_BUILTINCOMPLETER, TCLRL_EOFCHAR

    };


    Tcl_ResetResult(interp); /* clear the result space */

    for (i = 0;  i < argc;  i++) {
        Tcl_Obj* objPtr = Tcl_NewStringObj(argv[i], -1);







>




|
>







187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
{
    int i, obj_idx, status;
    Tcl_Obj** objv = (Tcl_Obj**) MALLOC((argc + 1) * sizeof(Tcl_Obj *));

    static char *subCmds[] = {
        "read", "initialize", "write", "add", "complete",
        "customcompleter", "builtincompleter", "eofchar",
		"reset-terminal",
        (char *) NULL
    };
    enum SubCmdIdx {
        TCLRL_READ, TCLRL_INITIALIZE, TCLRL_WRITE, TCLRL_ADD, TCLRL_COMPLETE,
        TCLRL_CUSTOMCOMPLETER, TCLRL_BUILTINCOMPLETER, TCLRL_EOFCHAR,
		TCLRL_RESET_TERMINAL
    };


    Tcl_ResetResult(interp); /* clear the result space */

    for (i = 0;  i < argc;  i++) {
        Tcl_Obj* objPtr = Tcl_NewStringObj(argv[i], -1);
365
366
367
368
369
370
371












372
373
374
375
376
377
378
                if (tclrl_eof_string)
                    FREE(tclrl_eof_string);
                if (!blank_line(argv[2]))
                    tclrl_eof_string = stripwhite(strdup(argv[2]));
            }
            Tcl_AppendResult(interp, tclrl_eof_string, (char*) NULL);
            break;













        default:
            goto BAD_COMMAND;
            /* NOTREACHED */
            break;
    }








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







367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
                if (tclrl_eof_string)
                    FREE(tclrl_eof_string);
                if (!blank_line(argv[2]))
                    tclrl_eof_string = stripwhite(strdup(argv[2]));
            }
            Tcl_AppendResult(interp, tclrl_eof_string, (char*) NULL);
            break;

        case TCLRL_RESET_TERMINAL:
			/* TODO: add this to the completer */
            if (argc > 3) {
                Tcl_WrongNumArgs(interp, 2, objv, "?terminal-name?");
                return TCL_ERROR;
            } else if (3 == argc) {
				rl_reset_terminal(Tcl_GetString(objv[2]));
            } else {
				rl_cleanup_after_signal();
			}
            break;

        default:
            goto BAD_COMMAND;
            /* NOTREACHED */
            break;
    }

Modified tclreadline.n.in from [9b636f5135] to [72c7fb52c1].

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: "Mon Aug 30 14:12:14 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: "/disk01/home/joze/src/tclreadline/tclreadline.n.in"
.\" LAST MODIFICATION: "Thu Sep 16 18:10:41 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
.\"
175
176
177
178
179
180
181






182
183
184
185
186
187
188
.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
arguments, it returns the current setting.







>
>
>
>
>
>







175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
.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::readline reset-terminal\fP [\fIterminalName\fP]
w/o argument: reset the state of the terminal to what it was
before tclreadline was used. With argument: reinitialize readline's
idea of the terminal settings using terminalName as the terminal type.

.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
arguments, it returns the current setting.

Modified tclreadlineCompleter.tcl from [f9084f3db9] to [66fd51af9c].

1
2
3
4
5
6
7
8
9
10
# -*- tclsh -*-
# FILE: "/disk01/home/joze/src/tclreadline/tclreadlineCompleter.tcl"
# LAST MODIFICATION: "Thu Sep 16 02:53:18 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
# -*- tclsh -*-
# FILE: "/disk01/home/joze/src/tclreadline/tclreadlineCompleter.tcl"
# LAST MODIFICATION: "Thu Sep 16 16:24:46 1999 (joze)"
# (C) 1998, 1999 by Johannes Zellner, <johannes@zellner.org>
# $Id$
# ---
#
# tclreadline -- gnu readline for tcl
# Copyright (C) 1999  Johannes Zellner
#
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
	} else {

		# try to use $pos further ...
		# puts stderr |$line|
		#
		if {"." == [string index [string trim ${line}] 0]} {
			set alias WIDGET
			set namespc ""
		} else {

			# the double `lindex' strips {} or quotes.
			# the subst enables variables containing
			# command names.
			#
			set alias [uplevel [info level] \







|







980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
	} else {

		# try to use $pos further ...
		# puts stderr |$line|
		#
		if {"." == [string index [string trim ${line}] 0]} {
			set alias WIDGET
			set namespc ""; # widgets are always in the global
		} else {

			# the double `lindex' strips {} or quotes.
			# the subst enables variables containing
			# command names.
			#
			set alias [uplevel [info level] \
1035
1036
1037
1038
1039
1040
1041



1042

1043
1044
1045
1046
1047
1048
1049
					[namespace eval ::tclreadline::${namespc} \
					[list complete(${cmd}) $part $start $end $line $pos $mod]]]\
					::tclreadline::errorMsg]
				} {
					error [list error during evaluation of `complete(${cmd})']
				}
				# puts stderr \nscript_result=|${script_result}|



				return ${script_result}

			}
			# set namespc ""; # no qualifiers for tclreadline_complete_unknown
		}

		# as we've reached here no valid specific completer
		# was found. Check, if it's a proc and return the
		# arguments.







>
>
>
|
>







1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
					[namespace eval ::tclreadline::${namespc} \
					[list complete(${cmd}) $part $start $end $line $pos $mod]]]\
					::tclreadline::errorMsg]
				} {
					error [list error during evaluation of `complete(${cmd})']
				}
				# puts stderr \nscript_result=|${script_result}|
				if {[string length ${script_result}] || \
					"tclreadline_complete_unknown" == ${cmd}
				} {
					return ${script_result}
				}
			}
			# set namespc ""; # no qualifiers for tclreadline_complete_unknown
		}

		# as we've reached here no valid specific completer
		# was found. Check, if it's a proc and return the
		# arguments.
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
	}
	return ""
}

proc complete(lappend) {text start end line pos mod} {
	switch -- $pos {
		1 { return [VarCompletion ${text}] }
		default { return [DisplayHints ?value?] }
	}
	return ""
}

# the following routines are described in the
# `library' man page.
# --- LIBRARY ---







|







2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
	}
	return ""
}

proc complete(lappend) {text start end line pos mod} {
	switch -- $pos {
		1 { return [VarCompletion ${text}] }
		default { return [TryFromList ${text} ?value?] }
	}
	return ""
}

# the following routines are described in the
# `library' man page.
# --- LIBRARY ---
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990







2991
2992
2993
2994
2995
2996
2997
}

proc tclreadline::complete(readline) {text start end line pos mod} {
	set cmd [Lindex $line 1]
	switch -- $pos {
		1 { return [CompleteFromList ${text} {
			read initialize write add complete
			customcompleter builtincompleter eofchar}]
		}
		2 {
			switch -- $cmd {
				read {}
				initialize {}
				write {}
				add { return [DisplayHints <completerLine>] }
				completer { return [DisplayHints <line>] }
				customcompleter { return [DisplayHints ?scriptCompleter?] }
				builtincompleter { return [DisplayHints ?boolean?] }
				eofchar { return [DisplayHints ?script?] }







			}
		}
	}
	return ""
}

# --- END OF TCLREADLINE PACKAGE ---







|











>
>
>
>
>
>
>







2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
}

proc tclreadline::complete(readline) {text start end line pos mod} {
	set cmd [Lindex $line 1]
	switch -- $pos {
		1 { return [CompleteFromList ${text} {
			read initialize write add complete
			customcompleter builtincompleter eofchar reset-terminal}]
		}
		2 {
			switch -- $cmd {
				read {}
				initialize {}
				write {}
				add { return [DisplayHints <completerLine>] }
				completer { return [DisplayHints <line>] }
				customcompleter { return [DisplayHints ?scriptCompleter?] }
				builtincompleter { return [DisplayHints ?boolean?] }
				eofchar { return [DisplayHints ?script?] }
				reset-terminal {
					if {[info exists ::env(TERM)]} {
						return [CompleteFromList ${text} $::env(TERM)]
					} else {
						return [DisplayHints ?terminalName?]
					}
				}
			}
		}
	}
	return ""
}

# --- END OF TCLREADLINE PACKAGE ---

Modified tclreadlineSetup.tcl.in from [4dfd34c126] to [4d1fefee5e].

1
2
3
4
5
6
7
8
9
10
#!/usr/locanl/bin/tclsh
# FILE: "/disk01/home/joze/src/tclreadline/tclreadlineSetup.tcl.in"
# LAST MODIFICATION: "Wed Sep 15 15:23:30 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: "/disk01/home/joze/src/tclreadline/tclreadlineSetup.tcl.in"
# LAST MODIFICATION: "Thu Sep 16 18:06:23 1999 (joze)"
# (C) 1998, 1999 by Johannes Zellner, <johannes@zellner.org>
# $Id$
# ---
#
# tclreadline -- gnu readline for tcl
# Copyright (C) 1999  Johannes Zellner
#
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
		}
	}
	return -code error "invalid command name \"$name\""
}

namespace eval tclreadline {

namespace export Setup Glob Loop InitTclCmds InitTkCmds Print ls

proc ls {args} {
	if {[exec uname -s] == "Linux"} {
		eval exec ls --color -FC [Glob $args]
	} else {
		eval exec ls -FC [Glob $args]
	}







|







134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
		}
	}
	return -code error "invalid command name \"$name\""
}

namespace eval tclreadline {

namespace export Setup Loop InitTclCmds InitTkCmds Print ls

proc ls {args} {
	if {[exec uname -s] == "Linux"} {
		eval exec ls --color -FC [Glob $args]
	} else {
		eval exec ls -FC [Glob $args]
	}
201
202
203
204
205
206
207


208
209
210
211
212
213
214

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



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







>
>







201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216

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

				::tclreadline::readline reset-terminal

				if [catch "eval ::tclreadline::Exit $args" message] {
					puts stderr "error:"
					puts stderr "$message"
				}
				# NOTREACHED
			}
245
246
247
248
249
250
251


252
253
254
255
256
257
258
}

proc HistoryFileGet {} {
	variable historyfile
	return $historyfile
}



proc Glob {string} {

	set commandstring ""
	foreach name $string {
		set replace [glob -nocomplain -- $name]
		if {$replace == ""} {
			lappend commandstring $name







>
>







247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
}

proc HistoryFileGet {} {
	variable historyfile
	return $historyfile
}

# obsolete
#
proc Glob {string} {

	set commandstring ""
	foreach name $string {
		set replace [glob -nocomplain -- $name]
		if {$replace == ""} {
			lappend commandstring $name