Author: mesyeti <mesyeti@mesyeti.uk>
fix kilo and bash in yterm
source/interpreter/vt100.c | 18 +++++++++++++++++- source/sysTerm.h | 1 + source/sysTerm/unix.c | 9 +++++++++
diff --git a/source/interpreter/vt100.c b/source/interpreter/vt100.c index aa46f49a03e9b551a6598c99f79392ce372fa23f..d1cc1b6a2b46cd8a4ec53465ccca1d54fddce41d 100644 --- a/source/interpreter/vt100.c +++ b/source/interpreter/vt100.c @@ -405,7 +405,7 @@ switch (op) { case 0: { // TODO: compare with other impls - for (int i = terminal->cursor.x + 1; i < terminal->buffer.width; ++ i) { + for (int i = terminal->cursor.x; i < terminal->buffer.width; ++ i) { Buffer_Set(&terminal->buffer, i, terminal->cursor.y, cell); } break; @@ -461,6 +461,22 @@ ColourSeq(part, terminal); } + break; + } + case 'n': { + if (num == 0) break; // no default + + switch (atoi(parts[0])) { + case 6: { // report cursor position + char seq[64]; + snprintf(seq, 64, "\x1b[%d;%dR", terminal->cursor.y, terminal->cursor.x); + + SysTerm_WriteString(&terminal->term, seq); + break; + } + } + + printf("Unsupported: CSI %d n\n", atoi(parts[0])); break; } case 'h': { diff --git a/source/sysTerm/unix.c b/source/sysTerm/unix.c index 7b306224d6f284b4164be3c9d692bb2765f540c2..89699f796d6bef9245b87df234ab7fe37adc7dcc 100644 --- a/source/sysTerm/unix.c +++ b/source/sysTerm/unix.c @@ -186,4 +186,13 @@ return true; } +bool SysTerm_WriteString(SysTerm* term, const char* str) { + if (write(term->master, str, strlen(str)) <= 0) { + Log("write failed: %s", strerror(errno)); + return false; + } + + return true; +} + #endif diff --git a/source/sysTerm.h b/source/sysTerm.h index c90e9456469de6b4b2e3bdc5cd16bd0608a17bd5..c48b54e3b3bd73314234b63b290e55c26edf33ab 100644 --- a/source/sysTerm.h +++ b/source/sysTerm.h @@ -16,5 +16,6 @@ void SysTerm_UpdateSize(SysTerm* term, int w, int h); bool SysTerm_DataAvailable(SysTerm* term); bool SysTerm_ReadByte(SysTerm* term, char* result); bool SysTerm_WriteByte(SysTerm* term, char val); +bool SysTerm_WriteString(SysTerm* term, const char* str); #endif