popup and diagnose ui

This commit is contained in:
2026-06-02 13:00:13 +02:00
parent a8b2960eb4
commit 2738bc8042
25 changed files with 587 additions and 461 deletions
+40 -9
View File
@@ -108,9 +108,41 @@ char *keyToString(int key) {
int editorReadKey() {
char c;
/* read first byte — may be start of UTF-8 or escape */
while (read(STDIN_FILENO, &c, 1) != 1)
;
int nread;
while (1) {
fd_set fds;
FD_ZERO(&fds);
FD_SET(STDIN_FILENO, &fds);
// Also watch the LSP wake pipe if available
int max_fd = STDIN_FILENO;
if (E.lsp_client && E.lsp_client->wake_pipe[0] > 0) {
FD_SET(E.lsp_client->wake_pipe[0], &fds);
if (E.lsp_client->wake_pipe[0] > max_fd)
max_fd = E.lsp_client->wake_pipe[0];
}
int ready = select(max_fd + 1, &fds, NULL, NULL, NULL);
if (ready <= 0)
continue;
// LSP event arrived — drain pipe and trigger a redraw
// by returning a special no-op key
if (E.lsp_client && FD_ISSET(E.lsp_client->wake_pipe[0], &fds)) {
char tmp[16];
read(E.lsp_client->wake_pipe[0], tmp, sizeof(tmp));
return LSP_WAKE_KEY; // ← special value, see below
}
// Normal keypress
if (FD_ISSET(STDIN_FILENO, &fds)) {
nread = read(STDIN_FILENO, &c, 1);
if (nread == 1)
break;
}
}
appDebug("f : %hhu %ld\r\n", c, 0x200);
if (c == '\x1b') {
@@ -219,19 +251,18 @@ int getWindowSize(int *rows, int *cols) {
return -1;
}
return getCursorPosition(rows, cols);
} else {
*cols = ws.ws_col;
*rows = ws.ws_row;
return 0;
}
*cols = ws.ws_col;
*rows = ws.ws_row;
return 0;
}
void appDebug(const char *fmt, ...) {
#ifdef APP_DEBUG
va_list ap;
char message[256];
char message[1024];
va_start(ap, fmt);
vsnprintf(message, 256, fmt, ap);
vsnprintf(message, 1024, fmt, ap);
va_end(ap);
fprintf(stderr, "%s\n", message);
#endif