1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-24 09:17:17 +00:00

Add support for delete key in repl

This commit is contained in:
Jon Staab 2019-11-16 16:01:52 -08:00
parent bcd2089f71
commit 40e6616df0
2 changed files with 14 additions and 0 deletions

3
.gitignore vendored
View File

@ -13,6 +13,9 @@ janet
janet-*.tar.gz
dist
# Kakoune (fzf via fd)
.fdignore
# VSCode
.vscode

View File

@ -314,6 +314,14 @@ static void kbackspace() {
}
}
static void kdelete() {
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();
}
}
static int line() {
gbl_cols = getcols();
gbl_plen = 0;
@ -386,6 +394,9 @@ static int line() {
if (read(STDIN_FILENO, seq + 2, 1) == -1) break;
if (seq[2] == '~') {
switch (seq[1]) {
case '3': /* delete */
kdelete();
break;
default:
break;
}