mirror of
git://git.code.sf.net/p/zsh/code
synced 2024-09-25 13:30:42 +02:00
Joakim Rosqvist: 27591 as modified in 27594:
KEYBOARD_HACK variable
This commit is contained in:
parent
a7ea114f96
commit
036cb0ce95
@ -1,3 +1,10 @@
|
|||||||
|
2010-01-13 Peter Stephenson <pws@csr.com>
|
||||||
|
|
||||||
|
* Joakim Rosqvist: 27591 as modified in 27594:
|
||||||
|
FEATURES, Doc/Zsh/options.yo, Doc/Zsh/params.yo, Src/input.c,
|
||||||
|
Src/options.c, Src/params.c: extend SUN_KEYBOARD_HACK option
|
||||||
|
to KEYBOARD_HACK variable.
|
||||||
|
|
||||||
2010-01-04 Peter Stephenson <p.w.stephenson@ntlworld.com>
|
2010-01-04 Peter Stephenson <p.w.stephenson@ntlworld.com>
|
||||||
|
|
||||||
* 27553: Jesse Weinstein: Doc/Zsh/compsys.yo: improve phrasing.
|
* 27553: Jesse Weinstein: Doc/Zsh/compsys.yo: improve phrasing.
|
||||||
@ -12568,5 +12575,5 @@
|
|||||||
|
|
||||||
*****************************************************
|
*****************************************************
|
||||||
* This is used by the shell to define $ZSH_PATCHLEVEL
|
* This is used by the shell to define $ZSH_PATCHLEVEL
|
||||||
* $Revision: 1.4859 $
|
* $Revision: 1.4860 $
|
||||||
*****************************************************
|
*****************************************************
|
||||||
|
@ -1209,6 +1209,8 @@ If a line ends with a backquote, and there are an odd number
|
|||||||
of backquotes on the line, ignore the trailing backquote.
|
of backquotes on the line, ignore the trailing backquote.
|
||||||
This is useful on some keyboards where the return key is
|
This is useful on some keyboards where the return key is
|
||||||
too small, and the backquote key lies annoyingly close to it.
|
too small, and the backquote key lies annoyingly close to it.
|
||||||
|
As an alternative the variable tt(KEYBOARD_HACK) lets you choose the
|
||||||
|
character to be removed.
|
||||||
)
|
)
|
||||||
enditem()
|
enditem()
|
||||||
|
|
||||||
|
@ -897,6 +897,16 @@ space character.
|
|||||||
If the parameter is unset, the default is used. Note this has
|
If the parameter is unset, the default is used. Note this has
|
||||||
a different effect from setting the parameter to an empty string.
|
a different effect from setting the parameter to an empty string.
|
||||||
)
|
)
|
||||||
|
vindex(KEYBOARD_HACK)
|
||||||
|
item(tt(KEYBOARD_HACK))(
|
||||||
|
This variable defines a character to be removed from the end of the
|
||||||
|
command line before interpreting it (interactive shells only). It is
|
||||||
|
intended to fix the problem with keys placed annoyingly close to return
|
||||||
|
and replaces the tt(SUNKEYBOARDHACK) option which did this for
|
||||||
|
backquotes only. Should the chosen character be one of singlequote,
|
||||||
|
doublequote or backquote, there must also be an odd number of them
|
||||||
|
on the command line for the last one to be removed.
|
||||||
|
)
|
||||||
vindex(KEYTIMEOUT)
|
vindex(KEYTIMEOUT)
|
||||||
item(tt(KEYTIMEOUT))(
|
item(tt(KEYTIMEOUT))(
|
||||||
The time the shell waits, in hundredths of seconds, for another key to
|
The time the shell waits, in hundredths of seconds, for another key to
|
||||||
|
1
FEATURES
1
FEATURES
@ -66,6 +66,7 @@ with histverify option, performing csh-style history expansions causes the
|
|||||||
input line to be brought up for editing instead of being executed
|
input line to be brought up for editing instead of being executed
|
||||||
with sunkeyboardhack option, accidentally typed trailing ` characters
|
with sunkeyboardhack option, accidentally typed trailing ` characters
|
||||||
are removed from the input line (for those of you with Sun keyboards :-) )
|
are removed from the input line (for those of you with Sun keyboards :-) )
|
||||||
|
with KEYBOARD_HACK, any accidentally typed trailing ascii character can be junked
|
||||||
"cd old new" replaces "old" with "new" in directory string
|
"cd old new" replaces "old" with "new" in directory string
|
||||||
generalized argument completion, new system based on shell functions:
|
generalized argument completion, new system based on shell functions:
|
||||||
- highly context sensitive
|
- highly context sensitive
|
||||||
|
38
Src/input.c
38
Src/input.c
@ -291,20 +291,32 @@ inputline(void)
|
|||||||
zputs(ingetcline, stderr);
|
zputs(ingetcline, stderr);
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
}
|
}
|
||||||
if (*ingetcline && ingetcline[strlen(ingetcline) - 1] == '\n' &&
|
if (keyboardhackchar && *ingetcline &&
|
||||||
interact && isset(SUNKEYBOARDHACK) && isset(SHINSTDIN) &&
|
ingetcline[strlen(ingetcline) - 1] == '\n' &&
|
||||||
SHTTY != -1 && *ingetcline && ingetcline[1] &&
|
interact && isset(SHINSTDIN) &&
|
||||||
ingetcline[strlen(ingetcline) - 2] == '`') {
|
SHTTY != -1 && ingetcline[1])
|
||||||
/* Junk an unmatched "`" at the end of the line. */
|
{
|
||||||
int ct;
|
char *stripptr = ingetcline + strlen(ingetcline) - 2;
|
||||||
char *ptr;
|
if (*stripptr == keyboardhackchar) {
|
||||||
|
/* Junk an unwanted character at the end of the line.
|
||||||
|
(key too close to return key) */
|
||||||
|
int ct = 1; /* force odd */
|
||||||
|
char *ptr;
|
||||||
|
|
||||||
for (ct = 0, ptr = ingetcline; *ptr; ptr++)
|
if (keyboardhackchar == '\'' || keyboardhackchar == '"' ||
|
||||||
if (*ptr == '`')
|
keyboardhackchar == '`') {
|
||||||
ct++;
|
/*
|
||||||
if (ct & 1) {
|
* for the chars above, also require an odd count before
|
||||||
ptr[-2] = '\n';
|
* junking
|
||||||
ptr[-1] = '\0';
|
*/
|
||||||
|
for (ct = 0, ptr = ingetcline; *ptr; ptr++)
|
||||||
|
if (*ptr == keyboardhackchar)
|
||||||
|
ct++;
|
||||||
|
}
|
||||||
|
if (ct & 1) {
|
||||||
|
stripptr[0] = '\n';
|
||||||
|
stripptr[1] = '\0';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isfirstch = 1;
|
isfirstch = 1;
|
||||||
|
@ -748,6 +748,9 @@ dosetopt(int optno, int value, int force)
|
|||||||
} else if ((optno == EMACSMODE || optno == VIMODE) && value) {
|
} else if ((optno == EMACSMODE || optno == VIMODE) && value) {
|
||||||
zleentry(ZLE_CMD_SET_KEYMAP, optno);
|
zleentry(ZLE_CMD_SET_KEYMAP, optno);
|
||||||
opts[(optno == EMACSMODE) ? VIMODE : EMACSMODE] = 0;
|
opts[(optno == EMACSMODE) ? VIMODE : EMACSMODE] = 0;
|
||||||
|
} else if (optno == SUNKEYBOARDHACK) {
|
||||||
|
/* for backward compatibility */
|
||||||
|
keyboardhackchar = (value ? '`' : '\0');
|
||||||
}
|
}
|
||||||
opts[optno] = value;
|
opts[optno] = value;
|
||||||
if (optno == BANGHIST || optno == SHINSTDIN)
|
if (optno == BANGHIST || optno == SHINSTDIN)
|
||||||
|
46
Src/params.c
46
Src/params.c
@ -108,6 +108,9 @@ zlong lineno, /* $LINENO */
|
|||||||
mod_export unsigned char bangchar;
|
mod_export unsigned char bangchar;
|
||||||
/**/
|
/**/
|
||||||
unsigned char hatchar, hashchar;
|
unsigned char hatchar, hashchar;
|
||||||
|
|
||||||
|
/**/
|
||||||
|
unsigned char keyboardhackchar = '\0';
|
||||||
|
|
||||||
/* $SECONDS = now.tv_sec - shtimer.tv_sec
|
/* $SECONDS = now.tv_sec - shtimer.tv_sec
|
||||||
* + (now.tv_usec - shtimer.tv_usec) / 1000000.0
|
* + (now.tv_usec - shtimer.tv_usec) / 1000000.0
|
||||||
@ -204,6 +207,8 @@ static const struct gsu_scalar ifs_gsu =
|
|||||||
{ ifsgetfn, ifssetfn, stdunsetfn };
|
{ ifsgetfn, ifssetfn, stdunsetfn };
|
||||||
static const struct gsu_scalar underscore_gsu =
|
static const struct gsu_scalar underscore_gsu =
|
||||||
{ underscoregetfn, nullstrsetfn, stdunsetfn };
|
{ underscoregetfn, nullstrsetfn, stdunsetfn };
|
||||||
|
static const struct gsu_scalar keyboard_hack_gsu =
|
||||||
|
{ keyboardhackgetfn, keyboardhacksetfn, stdunsetfn };
|
||||||
#ifdef USE_LOCALE
|
#ifdef USE_LOCALE
|
||||||
static const struct gsu_scalar lc_blah_gsu =
|
static const struct gsu_scalar lc_blah_gsu =
|
||||||
{ strgetfn, lcsetfn, stdunsetfn };
|
{ strgetfn, lcsetfn, stdunsetfn };
|
||||||
@ -273,6 +278,7 @@ IPDEF2("TERM", term_gsu, 0),
|
|||||||
IPDEF2("WORDCHARS", wordchars_gsu, 0),
|
IPDEF2("WORDCHARS", wordchars_gsu, 0),
|
||||||
IPDEF2("IFS", ifs_gsu, PM_DONTIMPORT),
|
IPDEF2("IFS", ifs_gsu, PM_DONTIMPORT),
|
||||||
IPDEF2("_", underscore_gsu, PM_READONLY),
|
IPDEF2("_", underscore_gsu, PM_READONLY),
|
||||||
|
IPDEF2("KEYBOARD_HACK", keyboard_hack_gsu, PM_DONTIMPORT),
|
||||||
|
|
||||||
#ifdef USE_LOCALE
|
#ifdef USE_LOCALE
|
||||||
# define LCIPDEF(name) IPDEF2(name, lc_blah_gsu, PM_UNSET)
|
# define LCIPDEF(name) IPDEF2(name, lc_blah_gsu, PM_UNSET)
|
||||||
@ -3834,6 +3840,46 @@ errnogetfn(UNUSED(Param pm))
|
|||||||
return errno;
|
return errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Function to get value for special parameter `KEYBOARD_HACK' */
|
||||||
|
|
||||||
|
/**/
|
||||||
|
char *
|
||||||
|
keyboardhackgetfn(UNUSED(Param pm))
|
||||||
|
{
|
||||||
|
static char buf[2];
|
||||||
|
|
||||||
|
buf[0] = keyboardhackchar;
|
||||||
|
buf[1] = '\0';
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Function to set value of special parameter `KEYBOARD_HACK' */
|
||||||
|
|
||||||
|
/**/
|
||||||
|
void
|
||||||
|
keyboardhacksetfn(UNUSED(Param pm), char *x)
|
||||||
|
{
|
||||||
|
if (x) {
|
||||||
|
int len, i;
|
||||||
|
|
||||||
|
unmetafy(x, &len);
|
||||||
|
if (len > 1) {
|
||||||
|
len = 1;
|
||||||
|
zwarn("Only one KEYBOARD_HACK character can be defined"); /* could be changed if needed */
|
||||||
|
}
|
||||||
|
for (i = 0; i < len; i++) {
|
||||||
|
if (!isascii(STOUC(x[i]))) {
|
||||||
|
zwarn("KEYBOARD_HACK can only contain ASCII characters");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
keyboardhackchar = len ? STOUC(x[0]) : '\0';
|
||||||
|
free(x);
|
||||||
|
} else
|
||||||
|
keyboardhackchar = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
/* Function to get value for special parameter `histchar' */
|
/* Function to get value for special parameter `histchar' */
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
Reference in New Issue
Block a user