a tad annoying, when external programmes such as GNU screen are running,

we don’t get SIGWINCH when the window size changes during the runtime of
that, so, the signal is only usable reliably during editing in the shell
and we re-check the window size before each interactive edit line again
This commit is contained in:
tg 2010-07-25 11:35:43 +00:00
parent befbed2859
commit c187f3089f
5 changed files with 24 additions and 23 deletions

View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.385 2010/07/24 17:08:28 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.386 2010/07/25 11:35:38 tg Exp $
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
@ -25,7 +25,7 @@
# http://www.research.att.com/~gsf/public/ifs.sh
expected-stdout:
@(#)MIRBSD KSH R39 2010/07/24
@(#)MIRBSD KSH R39 2010/07/25
description:
Check version of shell.
stdin:

23
edit.c
View File

@ -25,7 +25,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.195 2010/07/17 22:09:32 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.196 2010/07/25 11:35:40 tg Exp $");
/*
* in later versions we might use libtermcap for this, but since external
@ -59,6 +59,7 @@ static X_chars edchars;
#define XCF_COMMAND_FILE (XCF_COMMAND|XCF_FILE)
static char editmode;
static int xx_cols; /* for Emacs mode */
static int modified; /* buffer has been "modified" */
static char holdbuf[LINE]; /* place to hold last edit buffer */
@ -153,6 +154,16 @@ x_getc(void)
if (trap) {
x_mode(false);
runtraps(0);
#ifdef SIGWINCH
if (got_winch) {
change_winsz();
if (x_cols != xx_cols && editmode == 1) {
/* redraw line in Emacs mode */
xx_cols = x_cols;
x_e_rebuildline(MKSH_CLRTOEOL_STRING);
}
}
#endif
x_mode(true);
}
return ((n == 1) ? (int)(unsigned char)c : -1);
@ -823,7 +834,6 @@ static int x_adj_ok;
*/
static int x_adj_done;
static int xx_cols;
static int x_col;
static int x_displen;
static int x_arg; /* general purpose arg */
@ -3110,15 +3120,6 @@ x_mode(bool onoff)
static bool x_cur_mode;
bool prev;
if (onoff && got_winch) {
change_winsz();
if (x_cols != xx_cols && editmode == 1) {
/* redraw line in Emacs mode */
xx_cols = x_cols;
x_e_rebuildline(MKSH_CLRTOEOL_STRING);
}
}
if (x_cur_mode == onoff)
return (x_cur_mode);
prev = x_cur_mode;

10
lex.c
View File

@ -22,7 +22,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.117 2010/07/21 11:31:15 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.118 2010/07/25 11:35:41 tg Exp $");
/*
* states while lexing word
@ -1385,6 +1385,8 @@ getsc_line(Source *s)
ksh_tmout_state = TMOUT_READING;
alarm(ksh_tmout);
}
if (interactive)
change_winsz();
if (have_tty && (
#if !MKSH_S_NOVI
Flag(FVI) ||
@ -1398,11 +1400,9 @@ getsc_line(Source *s)
xp[nread] = '\0';
xp += nread;
} else {
if (interactive) {
if (got_winch)
change_winsz();
if (interactive)
pprompt(prompt, 0);
} else
else
s->line++;
while (1) {

6
sh.h
View File

@ -150,9 +150,9 @@
#endif
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.401 2010/07/24 17:08:30 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.402 2010/07/25 11:35:42 tg Exp $");
#endif
#define MKSH_VERSION "R39 2010/07/24"
#define MKSH_VERSION "R39 2010/07/25"
#ifndef MKSH_INCLUDES_ONLY
@ -675,7 +675,7 @@ EXTERN volatile sig_atomic_t intrsig; /* pending trap interrupts command */
EXTERN volatile sig_atomic_t fatal_trap;/* received a fatal signal */
extern Trap sigtraps[NSIG+1];
/* got_winch = 1 when needing to re-adjust the window size */
/* got_winch = 1 when we need to re-adjust the window size */
#ifdef SIGWINCH
EXTERN volatile sig_atomic_t got_winch I__(1);
#else

4
var.c
View File

@ -26,7 +26,7 @@
#include <sys/sysctl.h>
#endif
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.109 2010/07/18 17:29:50 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.110 2010/07/25 11:35:43 tg Exp $");
/*
* Variables
@ -1454,7 +1454,7 @@ change_winsz(void)
}
#ifdef TIOCGWINSZ
/* check if window size has changed since first time */
/* check if window size has changed */
if (tty_fd >= 0) {
struct winsize ws;