mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-01-19 11:31:26 +01:00
32157: fix extra line feed after prompt, and erased character in completion listing, when ZLE_RPROMPT_INDENT=0
This commit is contained in:
parent
5f36aece2a
commit
9cacf4411f
5 changed files with 49 additions and 25 deletions
|
@ -1,5 +1,12 @@
|
|||
2013-12-18 Barton E. Schaefer <schaefer@zsh.org>
|
||||
|
||||
* 32157: Doc/Zsh/params.yo, Src/Zle/zle_refresh.c, Src/init.c,
|
||||
Src/params.c: make ZLE_RPROMPT_INDENT a special variable tied to
|
||||
an internal C global, to avoid having the shell variable value
|
||||
fetched on every keystroke and to make it available when testing
|
||||
how to reposition the cursor after the right-prompt is output.
|
||||
Fixes erasure in completion listing when ZLE_RPROMPT_INDENT=0.
|
||||
|
||||
* 32150: Completion/compaudit: Reference loop variable rather
|
||||
than absolute path in executable ownership test
|
||||
|
||||
|
|
|
@ -1548,7 +1548,7 @@ ifzman(zmanref(zshcompsys))\
|
|||
ifnzman(noderef(Completion System)).
|
||||
)
|
||||
vindex(ZLE_RPROMPT_INDENT)
|
||||
item(tt(ZLE_RPROMPT_INDENT))(
|
||||
item(tt(ZLE_RPROMPT_INDENT <S>))(
|
||||
If set, used to give the indentation between the right hand side of
|
||||
the right prompt in the line editor as given by tt(RPS1) or tt(RPROMPT)
|
||||
and the right hand side of the screen. If not set, the value 1 is used.
|
||||
|
|
|
@ -977,7 +977,7 @@ zrefresh(void)
|
|||
int tmpalloced; /* flag to free tmpline when finished */
|
||||
int remetafy; /* flag that zle line is metafied */
|
||||
int txtchange; /* attributes set after prompts */
|
||||
int rprompt_off = 1; /* Offset of rprompt from right of screen */
|
||||
int rprompt_off; /* Offset of rprompt from right of screen */
|
||||
struct rparams rpms;
|
||||
#ifdef MULTIBYTE_SUPPORT
|
||||
int width; /* width of wide character */
|
||||
|
@ -1579,16 +1579,12 @@ zrefresh(void)
|
|||
!strchr(rpromptbuf, '\t');
|
||||
if (put_rpmpt)
|
||||
{
|
||||
struct value vbuf;
|
||||
char *name = "ZLE_RPROMPT_INDENT";
|
||||
if (getvalue(&vbuf, &name, 1)) {
|
||||
rprompt_off = (int)getintvalue(&vbuf);
|
||||
/* sanity to avoid horrible things happening */
|
||||
if (rprompt_off < 0)
|
||||
rprompt_off = 0;
|
||||
}
|
||||
put_rpmpt =
|
||||
(int)ZR_strlen(nbuf[0]) + rpromptw < winw - rprompt_off;
|
||||
rprompt_off = rprompt_indent;
|
||||
/* sanity to avoid horrible things happening */
|
||||
if (rprompt_off < 0)
|
||||
rprompt_off = 0;
|
||||
put_rpmpt =
|
||||
(int)ZR_strlen(nbuf[0]) + rpromptw < winw - rprompt_off;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -2127,19 +2123,24 @@ moveto(int ln, int cl)
|
|||
const REFRESH_ELEMENT *rep;
|
||||
|
||||
if (vcs == winw) {
|
||||
vln++, vcs = 0;
|
||||
if (!hasam) {
|
||||
zputc(&zr_cr);
|
||||
zputc(&zr_nl);
|
||||
if (rprompt_indent == 0 && tccan(TCLEFT)) {
|
||||
tc_leftcurs(1);
|
||||
vcs--;
|
||||
} else {
|
||||
if ((vln < nlnct) && nbuf[vln] && nbuf[vln]->chr)
|
||||
rep = nbuf[vln];
|
||||
else
|
||||
rep = &zr_sp;
|
||||
zputc(rep);
|
||||
zputc(&zr_cr);
|
||||
if ((vln < olnct) && obuf[vln] && obuf[vln]->chr)
|
||||
*obuf[vln] = *rep;
|
||||
vln++, vcs = 0;
|
||||
if (!hasam) {
|
||||
zputc(&zr_cr);
|
||||
zputc(&zr_nl);
|
||||
} else {
|
||||
if ((vln < nlnct) && nbuf[vln] && nbuf[vln]->chr)
|
||||
rep = nbuf[vln];
|
||||
else
|
||||
rep = &zr_sp;
|
||||
zputc(rep);
|
||||
zputc(&zr_cr);
|
||||
if ((vln < olnct) && obuf[vln] && obuf[vln]->chr)
|
||||
*obuf[vln] = *rep;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
15
Src/init.c
15
Src/init.c
|
@ -77,7 +77,7 @@ mod_export int tclen[TC_COUNT];
|
|||
/**/
|
||||
int tclines, tccolumns;
|
||||
/**/
|
||||
mod_export int hasam, hasxn;
|
||||
mod_export int hasam, hasxn, hasye;
|
||||
|
||||
/* Value of the Co (max_colors) entry: may not be set */
|
||||
|
||||
|
@ -699,6 +699,7 @@ init_term(void)
|
|||
/* check whether terminal has automargin (wraparound) capability */
|
||||
hasam = tgetflag("am");
|
||||
hasxn = tgetflag("xn"); /* also check for newline wraparound glitch */
|
||||
hasye = tgetflag("YE"); /* print in last column does carriage return */
|
||||
|
||||
tclines = tgetnum("li");
|
||||
tccolumns = tgetnum("co");
|
||||
|
@ -748,6 +749,9 @@ init_term(void)
|
|||
tcstr[TCCLEARSCREEN] = ztrdup("\14");
|
||||
tclen[TCCLEARSCREEN] = 1;
|
||||
}
|
||||
#if 0 /* This might work, but there may be more to it */
|
||||
rprompt_indent = (hasye || !tccan(TCLEFT)) ? 1 : 0;
|
||||
#endif
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -999,6 +1003,15 @@ setupvals(void)
|
|||
setiparam("COLUMNS", zterm_columns);
|
||||
setiparam("LINES", zterm_lines);
|
||||
#endif
|
||||
{
|
||||
/* Import from environment, overrides init_term() */
|
||||
struct value vbuf;
|
||||
char *name = "ZLE_RPROMPT_INDENT";
|
||||
if (getvalue(&vbuf, &name, 1) && !(vbuf.flags & PM_UNSET))
|
||||
rprompt_indent = getintvalue(&vbuf);
|
||||
else
|
||||
rprompt_indent = 1;
|
||||
}
|
||||
|
||||
#ifdef HAVE_GETRLIMIT
|
||||
for (i = 0; i != RLIM_NLIMITS; i++) {
|
||||
|
|
|
@ -97,6 +97,7 @@ zlong lastval, /* $? */
|
|||
lastpid, /* $! */
|
||||
zterm_columns, /* $COLUMNS */
|
||||
zterm_lines, /* $LINES */
|
||||
rprompt_indent, /* $ZLE_RPROMPT_INDENT */
|
||||
ppid, /* $PPID */
|
||||
zsh_subshell; /* $ZSH_SUBSHELL */
|
||||
/**/
|
||||
|
@ -316,8 +317,10 @@ IPDEF4("PPID", &ppid),
|
|||
IPDEF4("ZSH_SUBSHELL", &zsh_subshell),
|
||||
|
||||
#define IPDEF5(A,B,F) {{NULL,A,PM_INTEGER|PM_SPECIAL},BR((void *)B),GSU(F),10,0,NULL,NULL,NULL,0}
|
||||
#define IPDEF5U(A,B,F) {{NULL,A,PM_INTEGER|PM_SPECIAL|PM_UNSET},BR((void *)B),GSU(F),10,0,NULL,NULL,NULL,0}
|
||||
IPDEF5("COLUMNS", &zterm_columns, zlevar_gsu),
|
||||
IPDEF5("LINES", &zterm_lines, zlevar_gsu),
|
||||
IPDEF5U("ZLE_RPROMPT_INDENT", &rprompt_indent, zlevar_gsu),
|
||||
IPDEF5("OPTIND", &zoptind, varinteger_gsu),
|
||||
IPDEF5("SHLVL", &shlvl, varinteger_gsu),
|
||||
IPDEF5("TRY_BLOCK_ERROR", &try_errflag, varinteger_gsu),
|
||||
|
|
Loading…
Reference in a new issue