Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Feb 1996 01:12:21 -0700 (MST)
From:      Dave Andersen <angio@aros.net>
To:        hackers@freebsd.org
Subject:   kbdcontrol change
Message-ID:  <199602140812.BAA04009@terra.aros.net>

next in thread | raw e-mail | index | archive | help
   I got annoyed with kbdcontrol's inability to put returns or tabs in 
macros (makes it difficult to do multi-line commands. :), so I patched it 
to handle \ notation..

  kbdcontrol -f 1 "cd /\nls\ncd\n"
works admirably to create a sequence of:
cd /
ls
cd

   Minor tweak, but it was bugging me that it wouldn't work. The 
disadvantage is that if anyone uses \s in their current keyboard macros, 
they'll have to escape them with \\.  I can't see anywhere that the 
changes to kbdcontrol would cause any problems except that.  I also left 
out the other standard escape characters, because I figured that those 
three are all you really need in a keyboard macro.  Easy to insert them 
later.

   -Dave Andersen

This is a diff off of FreeBSD-stable (as of today), which is identical to 
-current's kbdcontrol.

*** kbdcontrol.c	Tue Jan 30 19:53:42 1996
--- kbdnew.c	Wed Feb 14 01:00:26 1996
***************
*** 403,408 ****
--- 403,409 ----
  void
  set_functionkey(char *keynumstr, char *string)
  {
+ 	int i, j;
  	fkeyarg_t fkey;
  	int keynum;
  
***************
*** 417,422 ****
--- 418,441 ----
  			NUM_FKEYS);
  		return;
  	}
+ 
+ 	/* Do substitution on backslashed characters */
+ 
+ 	for (i = j = 0; string[i] != 0; i++) {
+ 		if (string[i] == '\\') {
+ 			if (!string[i+1]) string[j++] = '\\';
+ 			else
+ 				switch (string[i+1]) {
+ 				case 'n' : string[j++] = '\n'; break;
+ 				case 't' : string[j++] = '\t'; break;
+ 				case 'r' : string[j++] = '\r'; break;
+ 				default  : string[j++] = string[i+1];
+ 				}
+ 			i++;
+ 		} else string[j++] = string[i];
+ 	}
+ 	string[j] = 0;  /* Make sure it's terminated */
+ 
  	if ((fkey.flen = strlen(string)) > MAXFK) {
  		fprintf(stderr, "function key string too long (%d > %d)\n",
  			fkey.flen, MAXFK);




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199602140812.BAA04009>