okay, this didn't work out; changing window sizes when we're

actually within a (the emacs) editing mode does not work at
all, whether forced or not, only if we leave the editing mode
(at end of input); probably due to it saving stuff from e.g.
x_cols into xx_cols, etc.

-> remove SIGWINCH handling(!)
-> TIOCGWINSZ is now executed at end of every input line
-> use 'ESC #' if you direly need to change line size
This commit is contained in:
tg 2007-01-14 01:56:23 +00:00
parent 36e761840e
commit 29b62b186d
2 changed files with 10 additions and 28 deletions

35
edit.c
View File

@ -5,7 +5,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.77 2007/01/14 01:09:08 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/edit.c,v 1.78 2007/01/14 01:56:23 tg Exp $");
/* tty driver characters we are interested in */ /* tty driver characters we are interested in */
typedef struct { typedef struct {
@ -41,10 +41,8 @@ int x_emacs(char *, size_t);
void x_init_emacs(void); void x_init_emacs(void);
int x_vi(char *, size_t); int x_vi(char *, size_t);
#if defined(TIOCGWINSZ) && defined(SIGWINCH) #ifdef TIOCGWINSZ
static void x_sigwinch(int); static void chkwinsz(void);
static volatile sig_atomic_t got_sigwinch;
static void check_sigwinch(void);
#endif #endif
static int path_order_cmp(const void *aa, const void *bb); static int path_order_cmp(const void *aa, const void *bb);
@ -66,31 +64,18 @@ x_init(void)
edchars.eof = -2; edchars.eof = -2;
/* default value for deficient systems */ /* default value for deficient systems */
edchars.werase = 027; /* ^W */ edchars.werase = 027; /* ^W */
#ifdef TIOCGWINSZ
#if defined(TIOCGWINSZ) && defined(SIGWINCH) chkwinsz();
if (setsig(&sigtraps[SIGWINCH], x_sigwinch,
SS_RESTORE_ORIG | SS_SHTRAP))
sigtraps[SIGWINCH].flags |= TF_SHELL_USES;
check_sigwinch(); /* force initial check */
#endif #endif
x_init_emacs(); x_init_emacs();
} }
#if defined(TIOCGWINSZ) && defined(SIGWINCH) #ifdef TIOCGWINSZ
/* ARGSUSED */
static void static void
x_sigwinch(int sig __unused) chkwinsz(void)
{
got_sigwinch = 1;
}
static void
check_sigwinch(void)
{ {
struct winsize ws; struct winsize ws;
got_sigwinch = 0;
if (procpid == kshpid && ioctl(tty_fd, TIOCGWINSZ, &ws) >= 0) { if (procpid == kshpid && ioctl(tty_fd, TIOCGWINSZ, &ws) >= 0) {
struct tbl *vp; struct tbl *vp;
@ -128,9 +113,8 @@ x_read(char *buf, size_t len)
else else
i = -1; /* internal error */ i = -1; /* internal error */
x_mode(false); x_mode(false);
#if defined(TIOCGWINSZ) && defined(SIGWINCH) #ifdef TIOCGWINSZ
if (got_sigwinch) chkwinsz();
check_sigwinch();
#endif #endif
return i; return i;
} }
@ -2236,7 +2220,6 @@ x_mv_begin(int c __unused)
static int static int
x_draw_line(int c __unused) x_draw_line(int c __unused)
{ {
check_sigwinch();
x_redraw(-1); x_redraw(-1);
return KSTD; return KSTD;
} }

3
mksh.1
View File

@ -1,4 +1,4 @@
.\" $MirOS: src/bin/mksh/mksh.1,v 1.74 2007/01/14 01:09:09 tg Exp $ .\" $MirOS: src/bin/mksh/mksh.1,v 1.75 2007/01/14 01:56:23 tg Exp $
.\" $OpenBSD: ksh.1,v 1.118 2006/11/30 08:47:58 jmc Exp $ .\" $OpenBSD: ksh.1,v 1.118 2006/11/30 08:47:58 jmc Exp $
.\" .\"
.Dd January 14, 2007 .Dd January 14, 2007
@ -4553,7 +4553,6 @@ word of the previous command is inserted at the cursor.
The following character is taken literally rather than as an editing command. The following character is taken literally rather than as an editing command.
.It redraw: ^L .It redraw: ^L
Reprints the last line of the prompt string and the current input line. Reprints the last line of the prompt string and the current input line.
Also checks terminal size (columns and lines) as reported by stty for changes.
.It Xo search-character-backward: .It Xo search-character-backward:
.Op Ar n .Op Ar n
.No ^[^] .No ^[^]