[ksh93-integration-discuss] TABTAB+CTRL-V patch #007...

Roland Mainz roland.mainz at nrubsig.org
Sun May 21 20:31:28 PDT 2006


Hi!

----

Attached is the TABTAB+CTRL-V patch #007
("ksh93_tab_tab_ctrl_v_007_patch.diff.txt").
Changes since last version:
- Removed the Solaris-specfic default editor stuff (see
http://mail.opensolaris.org/pipermail/ksh93-integration-discuss/2006-May/000353.html)

Happy testing! :-)

----

Bye,
Roland

-- 
  __ .  . __
 (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/lib/libshell/common/edit/emacs.c
===================================================================
--- src/lib/libshell/common/edit/emacs.c	(revision 243)
+++ 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') :


More information about the ksh93-integration-discuss mailing list