dlmiles
04/30/2024, 10:06 AMStefan Schippers
04/30/2024, 10:48 AMStefan Schippers
04/30/2024, 11:03 AMdlmiles
04/30/2024, 11:08 AMdlmiles
04/30/2024, 11:21 AMWARNING: tclreadline active, see tclreadline/issue/12345 recommend disabling with -r
Stefan Schippers
04/30/2024, 1:03 PM!
character since it is used for history (like in a shell) however !
is used in tcl expressions.
This command:
if {!$a} { puts "Zero"}
just does not work with tclreadline.
this is more than enough to drop tclreadline altogether.Stefan Schippers
04/30/2024, 1:11 PMrlwrap xschem -r
will do the job without tclreadline.
I like the Unix / Kiss approach of doing one thing and (does it?) doing it well , and rlwrap (maybe) does exactly that.dlmiles
04/30/2024, 2:43 PMhistory_expansion_char = '\0'
needs main executable to linked -lreadline -ldl
but both libraries can become a configure dependency making both optional. Maybe if cleaned up can #ifdef HAS_DLFCN_H
around relevant parts
instead of letting tclreadline load it at runtime.
diff --git a/src/xinit.c b/src/xinit.c
index aace3665..4eeeb8ef 100644
--- a/src/xinit.c
+++ b/src/xinit.c
@@ -24,6 +24,7 @@
#ifdef __unix__
#include <pwd.h> /* getpwuid */
#endif
+#include <dlfcn.h>
static int init_done=0; /* 20150409 to avoid double call by Xwindows close and TclExitHandler */
static XSetWindowAttributes winattr;
@@ -2267,6 +2268,22 @@ void resetwin(int create_pixmap, int clear_pixmap, int force, int w, int h)
}
}
+static int fixup_readline(void)
+{
+ /* This dirty hack is doing the equivalent: */
+ /* <readline/history.h> */
+ /*extern char history_expansion_char;*/
+ /*history_expansion_char = '\0'*/
+ {
+ char *sym = (char *) dlsym((void*)0, "history_expansion_char");
+ if(sym) {
+ dbg(1, "readline history_expansion_char=0 patched\n");
+ *sym = '\0'; /* prevents '!' history expansion in tcl expressions */
+ }
+ }
+ return TCL_OK;
+}
+
static void tclmainloop(void)
{
while(1) Tcl_DoOneEvent(TCL_ALL_EVENTS);
@@ -2567,6 +2584,8 @@ int Tcl_AppInit(Tcl_Interp *inter)
/* */
Tcl_CreateCommand(interp, "xschem", (myproc *) xschem, NULL, NULL);
+ Tcl_CreateCommand(interp, "fixup_readline", (myproc *) fixup_readline, NULL, NULL);
+
dbg(1, "Tcl_AppInit(): done step a1 of xinit()\n");
@@ -3014,6 +3033,7 @@ int Tcl_AppInit(Tcl_Interp *inter)
tcleval( "if {![catch {package require tclreadline}] && $tcl_interactive} "
"{::tclreadline::readline builtincompleter 0;"
"::tclreadline::readline customcompleter completer;"
+ "fixup_readline;"
"::tclreadline::Loop }"
);
}
Stefan Schippers
05/01/2024, 5:47 AMxschem [~]
readline: readline_callback_read_char() called with no handler!
Aborted
Never been able to fix this.
If I don't get a work around on this I think it is fair to remove tclreadline altogether, I am really pissed off for all the issues it brings in. On the other side rlwrap seems to work fine.dlmiles
05/01/2024, 8:18 AM!
is GNU readline not tclreadline (which is a wrapper with TCL hooks/API/bindings and some more useful defaults in configuration), underneath it still defers the implementation to GNU readline via the tclreadline wrapper and it is this that does the history !
expansion, so even using rlwrap
maybe have this unwanted features. But it seems a configurable thing (exported from history.h
), even if not totally documented.
There is also inputrc
file configuration possibility to modify the bindings for xschem as wanted, especially if it allows for use of custom path $HOME/.xschem/inputrc
. If not then it is another additional step for installation to have the user append conf to $HOME/.inputrc
which may not be desirable.dlmiles
05/01/2024, 8:21 AMtclreadline
does not do much (as in provide much net positive), is not maintained (or at least the standard version found in a linux distribution is not maintained). So direct use of readline
could use a less hackey patch.Stefan Schippers
05/01/2024, 8:22 AMschippes@asus:~$ rlwrap xschem -r
% set a 1
1
% if {!$a} {puts zero}
% set a 0
0
% if {!$a} {puts zero}
zero
Stefan Schippers
05/01/2024, 8:27 AMdlmiles
05/01/2024, 8:27 AMrlwrap
before, so do not know its specifics, just demonstraing the !
is configurable.
Ideally I think I am still thinking that using readline
as a dependency but directly then converting it to run inside GUI shell popup window is the most ideal situation, as I don't think you need to re-write the readline features, just bind the X.11 keypress events to the readline and provide a redraw mechanismdlmiles
05/01/2024, 8:28 AMStefan Schippers
05/01/2024, 8:31 AM