mirror of
https://github.com/janet-lang/janet
synced 2025-01-14 01:20:27 +00:00
Add alt-d binding to repl.
This commit is contained in:
parent
f18c3323ea
commit
693c6d63d4
@ -370,14 +370,35 @@ static void kbackspace(int draw) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void kdelete(void) {
|
static void kdelete(int draw) {
|
||||||
if (gbl_pos != gbl_len) {
|
if (gbl_pos != gbl_len) {
|
||||||
memmove(gbl_buf + gbl_pos, gbl_buf + gbl_pos + 1, gbl_len - gbl_pos);
|
memmove(gbl_buf + gbl_pos, gbl_buf + gbl_pos + 1, gbl_len - gbl_pos);
|
||||||
gbl_buf[--gbl_len] = '\0';
|
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 */
|
/* See tools/symchargen.c */
|
||||||
static int is_symbol_char_gen(uint8_t c) {
|
static int is_symbol_char_gen(uint8_t c) {
|
||||||
if (c & 0x80) return 1;
|
if (c & 0x80) return 1;
|
||||||
@ -403,13 +424,6 @@ static int is_symbol_char_gen(uint8_t c) {
|
|||||||
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) {
|
static JanetByteView get_symprefix(void) {
|
||||||
/* Calculate current partial symbol. Maybe we could actually hook up the Janet
|
/* Calculate current partial symbol. Maybe we could actually hook up the Janet
|
||||||
* parser here...*/
|
* parser here...*/
|
||||||
@ -632,7 +646,7 @@ static int line() {
|
|||||||
refresh();
|
refresh();
|
||||||
break;
|
break;
|
||||||
case 23: /* ctrl-w */
|
case 23: /* ctrl-w */
|
||||||
kbackspaceword();
|
kbackspacew();
|
||||||
break;
|
break;
|
||||||
case 26: /* ctrl-z */
|
case 26: /* ctrl-z */
|
||||||
norawmode();
|
norawmode();
|
||||||
@ -653,7 +667,7 @@ static int line() {
|
|||||||
if (seq[2] == '~') {
|
if (seq[2] == '~') {
|
||||||
switch (seq[1]) {
|
switch (seq[1]) {
|
||||||
case '3': /* delete */
|
case '3': /* delete */
|
||||||
kdelete();
|
kdelete(1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -691,6 +705,15 @@ static int line() {
|
|||||||
switch (seq[0]) {
|
switch (seq[0]) {
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
case 'h':
|
||||||
|
kleft();
|
||||||
|
break;
|
||||||
|
case 'l':
|
||||||
|
kright();
|
||||||
|
break;
|
||||||
|
case 'd':
|
||||||
|
kdeletew();
|
||||||
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
kleftw();
|
kleftw();
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user