experimentally use MKSH_CLRTOEOL_STRING instead of lots of spaces followed

by lots of backspaces for many clearing scenarios; requested by tmux user
slagtc on IRC
This commit is contained in:
tg 2016-07-12 23:07:10 +00:00
parent 353108cb25
commit 8370c0dd4d
3 changed files with 21 additions and 31 deletions

View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.739 2016/06/26 00:44:55 tg Exp $ # $MirOS: src/bin/mksh/check.t,v 1.740 2016/07/12 23:07:06 tg Exp $
# -*- mode: sh -*- # -*- mode: sh -*-
#- #-
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
@ -30,7 +30,7 @@
# (2013/12/02 20:39:44) http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date # (2013/12/02 20:39:44) http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date
expected-stdout: expected-stdout:
@(#)MIRBSD KSH R52 2016/06/25 @(#)MIRBSD KSH R52 2016/07/12
description: description:
Check version of shell. Check version of shell.
stdin: stdin:
@ -39,7 +39,7 @@ name: KSH_VERSION
category: shell:legacy-no category: shell:legacy-no
--- ---
expected-stdout: expected-stdout:
@(#)LEGACY KSH R52 2016/06/25 @(#)LEGACY KSH R52 2016/07/12
description: description:
Check version of legacy shell. Check version of legacy shell.
stdin: stdin:

27
edit.c
View File

@ -28,7 +28,7 @@
#ifndef MKSH_NO_CMDLINE_EDITING #ifndef MKSH_NO_CMDLINE_EDITING
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.296 2016/05/05 22:56:12 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/edit.c,v 1.297 2016/07/12 23:07:09 tg Exp $");
/* /*
* in later versions we might use libtermcap for this, but since external * in later versions we might use libtermcap for this, but since external
@ -149,7 +149,7 @@ x_getc(void)
/* redraw line in Emacs mode */ /* redraw line in Emacs mode */
xx_cols = x_cols; xx_cols = x_cols;
x_init_prompt(false); x_init_prompt(false);
x_e_rebuildline(MKSH_CLRTOEOL_STRING); x_e_rebuildline(null);
} }
} }
#endif #endif
@ -1183,6 +1183,12 @@ x_e_getmbc(char *sbuf)
return (pos); return (pos);
} }
/*
* minimum required space to work with on a line - if the prompt
* leaves less space than this on a line, the prompt is truncated
*/
#define MIN_EDIT_SPACE 7
static void static void
x_init_prompt(bool doprint) x_init_prompt(bool doprint)
{ {
@ -1826,7 +1832,6 @@ x_goto_hist(int c MKSH_A_UNUSED)
static void static void
x_load_hist(char **hp) x_load_hist(char **hp)
{ {
int oldsize;
char *sp = NULL; char *sp = NULL;
if (hp == histptr + 1) { if (hp == histptr + 1) {
@ -1839,17 +1844,12 @@ x_load_hist(char **hp)
if (sp == NULL) if (sp == NULL)
sp = *hp; sp = *hp;
x_histp = hp; x_histp = hp;
oldsize = x_size_str(xbuf);
if (modified) if (modified)
strlcpy(holdbufp, xbuf, LINE); strlcpy(holdbufp, xbuf, LINE);
strlcpy(xbuf, sp, xend - xbuf); strlcpy(xbuf, sp, xend - xbuf);
xbp = xbuf; xbp = xbuf;
xep = xcp = xbuf + strlen(xbuf); xep = xcp = xbuf + strlen(xbuf);
xlp_valid = false; x_adjust();
if (xep <= x_lastcp()) {
x_redraw(oldsize);
}
x_goto(xep);
modified = 0; modified = 0;
} }
@ -2103,9 +2103,9 @@ x_redraw(int limit)
x_displen = xx_cols - 2 - x_col; x_displen = xx_cols - 2 - x_col;
xlp_valid = false; xlp_valid = false;
x_zots(xbp); x_zots(xbp);
if (xbp != xbuf || xep > xlp) if (limit >= xx_cols || xbp != xbuf || xep > xlp)
limit = xx_cols; shf_puts(MKSH_CLRTOEOL_STRING, shl_out);
if (limit >= 0) { else if (limit >= 0) {
if (xep > xlp) if (xep > xlp)
/* we fill the line */ /* we fill the line */
i = 0; i = 0;
@ -3015,7 +3015,6 @@ x_set_arg(int c)
static int static int
x_comment(int c MKSH_A_UNUSED) x_comment(int c MKSH_A_UNUSED)
{ {
int oldsize = x_size_str(xbuf);
ssize_t len = xep - xbuf; ssize_t len = xep - xbuf;
int ret = x_do_comment(xbuf, xend - xbuf, &len); int ret = x_do_comment(xbuf, xend - xbuf, &len);
@ -3026,7 +3025,7 @@ x_comment(int c MKSH_A_UNUSED)
xep = xbuf + len; xep = xbuf + len;
*xep = '\0'; *xep = '\0';
xcp = xbp = xbuf; xcp = xbp = xbuf;
x_redraw(oldsize); x_redraw(xx_cols);
if (ret > 0) if (ret > 0)
return (x_newline('\n')); return (x_newline('\n'));
} }

19
sh.h
View File

@ -175,9 +175,9 @@
#endif #endif
#ifdef EXTERN #ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.774 2016/06/26 00:44:59 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/sh.h,v 1.775 2016/07/12 23:07:10 tg Exp $");
#endif #endif
#define MKSH_VERSION "R52 2016/06/25" #define MKSH_VERSION "R52 2016/07/12"
/* arithmetic types: C implementation */ /* arithmetic types: C implementation */
#if !HAVE_CAN_INTTYPES #if !HAVE_CAN_INTTYPES
@ -1087,18 +1087,9 @@ EXTERN char *current_wd;
#else #else
#define LINE (16384 - ALLOC_OVERHEAD) #define LINE (16384 - ALLOC_OVERHEAD)
#endif #endif
/* /* columns and lines of the tty */
* Minimum required space to work with on a line - if the prompt leaves EXTERN mksh_ari_t x_cols E_INIT(80);
* less space than this on a line, the prompt is truncated. EXTERN mksh_ari_t x_lins E_INIT(24);
*/
#define MIN_EDIT_SPACE 7
/*
* Minimum allowed value for x_cols: 2 for prompt, 3 for " < " at end of line
*/
#define MIN_COLS (2 + MIN_EDIT_SPACE + 3)
#define MIN_LINS 3
EXTERN mksh_ari_t x_cols E_INIT(80); /* tty columns */
EXTERN mksh_ari_t x_lins E_INIT(24); /* tty lines */
/* Determine the location of the system (common) profile */ /* Determine the location of the system (common) profile */