Hi!
----
Here comes the next iteration of the TAB-TAB patch.
Changes since version 005:
- Added CTRL-V quoting mode in "gmacs" mode (like bash/readline do).
Typing CTRL-V will make the following character appear as-is, e.g.
without special interpretation by the shell, allowing the input of any
special character. This allows the input of TAB again which is normally
used to control the filename completion (TAB and TAB-TAB, regardless of
position of the cursor).
----
Bye,
Roland
P.S.: I am out of the office for the next one or two days.
--
__ . . __
(o.\ \/ /.o) roland.mainz at nrubsig.org
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 7950090
(;O/ \/ \O;)
-------------- next part --------------
Index: src/cmd/ksh/Makefile.com
===================================================================
--- src/cmd/ksh/Makefile.com (revision 225)
+++ src/cmd/ksh/Makefile.com (working copy)
@@ -56,6 +56,7 @@
-DSHOPT_RAWONLY \
-DSHOPT_SUID_EXEC \
-DSHOPT_VSH \
+ -DSHOPT_DEFAULTEDITMODE=SH_GMACS \
-D_BLD_shell \
-D_PACKAGE_ast \
'-DUSAGE_LICENSE="[-author?David Korn <dgk at
research.att.com>][-copyright?Copyright (c) 1982-2006 AT&T Knowledge
Ventures][-license?http://www.opensource.org/licenses/cpl1.0.txt][--catalog?libshell]"'
Index: src/lib/libshell/common/edit/emacs.c
===================================================================
--- src/lib/libshell/common/edit/emacs.c (revision 222)
+++ src/lib/libshell/common/edit/emacs.c (working copy)
@@ -179,6 +179,8 @@
int ed_emacsread(void *context, int fd,char *buff,int scend, int reedit)
{
+ static unsigned int tab_count = 0;
+ static unsigned int quote_next_char = 0; /* boolean */
Edit_t *ed = (Edit_t*)context;
register int c;
register int i;
@@ -306,10 +308,36 @@
count = 1;
adjust = -1;
i = cur;
+
+ /* Count tabs for TAB completion (single TAB or TAB-TAB) */
+ if(c == '\t')
+ tab_count++;
+ else
+ tab_count = 0;
+
+ /* CTRL-V is used to quote special characters in "gmacs"
+ * (which otherwise would have a special meaning/function) */
+ if(quote_next_char)
+ {
+ quote_next_char = 0;
+ goto default_processing;
+ }
+
+
switch(c)
{
case cntl('V'):
- show_info(ep,fmtident(e_version));
+ if(sh_isoption(SH_GMACS))
+ {
+ /* Hint: Use "echo ${.sh.version}" if
+ * you want to get the shell version */
+ quote_next_char = 1;
+ }
+ else
+ {
+ /* Print shell version */
+ show_info(ep,fmtident(e_version));
+ }
continue;
case '\0':
ep->mark = i;
@@ -327,12 +355,16 @@
continue;
#endif /* u370 */
case '\t':
- if(cur>0 && cur>=eol && out[cur-1]!='\t' &&
out[cur-1]!=' ' && ep->ed->sh->nextprompt)
+ if((cur>0 && cur>=eol && out[cur-1]!='\t' &&
out[cur-1]!=' ' && ep->ed->sh->nextprompt) ||
+ sh_isoption(SH_GMACS))
{
- ed_ungetchar(ep->ed,ESC);
- ed_ungetchar(ep->ed,ESC);
- continue;
+ if (tab_count == 1)
+ ed_ungetchar(ep->ed,cntl('[')); /* like
ESC-ESC */
+ else if (tab_count >= 2)
+ ed_ungetchar(ep->ed,'='); /* like
ESC-'=' */
+ goto esc_;
}
+default_processing:
default:
if ((eol+1) >= (scend)) /* will not fit on line */
{
@@ -574,10 +606,23 @@
}
continue;
case cntl('L'):
- ed_crlf(ep->ed);
+ if (sh_isoption(SH_GMACS))
+ {
+ /* FixMe: a better way is needed here than
+ * calling |system()| - unfortunately I do
+ * not know a "portable" way (except
+ * linking to curses/ncurses) */
+ /* clear the screen (like bash/readline does) */
+ system("clear");
+ }
+ else
+ {
+ ed_crlf(ep->ed);
+ }
draw(ep,REFRESH);
continue;
case cntl('[') :
+esc_:
adjust = escape(ep,out,oadjust);
continue;
case cntl('R') :
Index: src/lib/libshell/common/sh/init.c
===================================================================
--- src/lib/libshell/common/sh/init.c (revision 222)
+++ src/lib/libshell/common/sh/init.c (working copy)
@@ -937,6 +937,17 @@
#if SHOPT_TIMEOUT
sh.st.tmout = SHOPT_TIMEOUT;
#endif /* SHOPT_TIMEOUT */
+#ifdef SHOPT_DEFAULTEDITMODE
+ /* set platform-specific default modes (if EDITOR/VISUAL env vars
+ * are not defined and no edit mode was set yet) */
+ if((sh_isoption(SH_VI) || sh_isoption(SH_VIRAW) ||
+ sh_isoption(SH_EMACS) || sh_isoption(SH_GMACS) ||
+ nv_getval(nv_scoped(VISINOD)) ||
+ nv_getval(nv_scoped(EDITNOD)) ) == 0)
+ {
+ sh_onoption(SHOPT_DEFAULTEDITMODE);
+ }
+#endif /* SHOPT_DEFAULTEDITMODE */
/* initialize jobs table */
job_clear();
if(argc>0)
Index: src/lib/libshell/Makefile.com
===================================================================
--- src/lib/libshell/Makefile.com (revision 222)
+++ src/lib/libshell/Makefile.com (working copy)
@@ -127,6 +127,7 @@
-DSHOPT_RAWONLY \
-DSHOPT_SUID_EXEC \
-DSHOPT_VSH \
+ -DSHOPT_DEFAULTEDITMODE=SH_GMACS \
-D_BLD_shell \
-D_PACKAGE_ast \
'-DUSAGE_LICENSE="[-author?David Korn <dgk at
research.att.com>][-copyright?Copyright (c) 1982-2006 AT&T Knowledge
Ventures][-license?http://www.opensource.org/licenses/cpl1.0.txt][--catalog?libshell]"'