1
0
mirror of https://github.com/janet-lang/janet synced 2024-12-27 17:00:27 +00:00

Add alt-d binding to repl.

This commit is contained in:
Calvin Rose 2020-01-19 11:39:10 -06:00
parent f18c3323ea
commit 693c6d63d4

View File

@ -370,14 +370,35 @@ static void kbackspace(int draw) {
}
}
static void kdelete(void) {
static void kdelete(int draw) {
if (gbl_pos != gbl_len) {
memmove(gbl_buf + gbl_pos, gbl_buf + gbl_pos + 1, gbl_len - gbl_pos);
gbl_buf[--gbl_len] = '\0';
refresh();
if (draw) refresh();
}
}
static void kbackspacew(void) {
while (gbl_pos && !isspace(gbl_buf[gbl_pos - 1])) {
kbackspace(0);
}
while (gbl_pos && isspace(gbl_buf[gbl_pos - 1])) {
kbackspace(0);
}
refresh();
}
static void kdeletew(void) {
while (gbl_pos < gbl_len && !isspace(gbl_buf[gbl_pos])) {
kdelete(0);
}
while (gbl_pos < gbl_len && isspace(gbl_buf[gbl_pos])) {
kdelete(0);
}
refresh();
}
/* See tools/symchargen.c */
static int is_symbol_char_gen(uint8_t c) {
if (c & 0x80) return 1;
@ -403,13 +424,6 @@ static int is_symbol_char_gen(uint8_t c) {
c == '_');
}
static void kbackspaceword(void) {
while (gbl_pos && is_symbol_char_gen(gbl_buf[gbl_pos - 1])) {
kbackspace(0);
}
refresh();
}
static JanetByteView get_symprefix(void) {
/* Calculate current partial symbol. Maybe we could actually hook up the Janet
* parser here...*/
@ -632,7 +646,7 @@ static int line() {
refresh();
break;
case 23: /* ctrl-w */
kbackspaceword();
kbackspacew();
break;
case 26: /* ctrl-z */
norawmode();
@ -653,7 +667,7 @@ static int line() {
if (seq[2] == '~') {
switch (seq[1]) {
case '3': /* delete */
kdelete();
kdelete(1);
break;
default:
break;
@ -691,6 +705,15 @@ static int line() {
switch (seq[0]) {
default:
break;
case 'h':
kleft();
break;
case 'l':
kright();
break;
case 'd':
kdeletew();
break;
case 'b':
kleftw();
break;