fix deleting AND moving left

This commit is contained in:
tg 2006-11-05 17:34:39 +00:00
parent 15fd277841
commit 72f958edea
1 changed files with 17 additions and 17 deletions

34
edit.c
View File

@ -5,7 +5,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.47 2006/11/05 17:24:00 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/edit.c,v 1.48 2006/11/05 17:34:39 tg Exp $");
/* tty driver characters we are interested in */ /* tty driver characters we are interested in */
typedef struct { typedef struct {
@ -1690,18 +1690,18 @@ x_emacs_putbuf(const char *s, size_t len)
static int static int
x_del_back(int c __attribute__((unused))) x_del_back(int c __attribute__((unused)))
{ {
int i = x_arg; int i = 0;
char *cp = xcp;
while (i--) { if (xcp == xbuf) {
if (xcp == xbuf) { x_e_putc2(7);
x_goto(cp); return (KSTD);
x_e_putc2(7);
return (KSTD);
}
x_goto(xcp - 1);
} }
x_delete(x_arg, false); while (i++ < x_arg) {
x_goto(xcp - 1);
if (xcp == xbuf)
break;
}
x_delete(i, false);
return KSTD; return KSTD;
} }
@ -1975,15 +1975,15 @@ x_zotc3(char **cp)
static int static int
x_mv_back(int c __attribute__((unused))) x_mv_back(int c __attribute__((unused)))
{ {
int col = xcp - xbuf; if (xcp == xbuf) {
if (col == 0) {
x_e_putc2(7); x_e_putc2(7);
return KSTD; return KSTD;
} }
if (x_arg > col) while (x_arg--) {
x_arg = col; x_goto(xcp - 1);
x_goto(xcp - x_arg); if (xcp == xbuf)
break;
}
return KSTD; return KSTD;
} }