1
0
Fork 0
forked from murx/murx

Arrow navigation fix.

This commit is contained in:
Johannes Findeisen 2026-11-15 01:32:30 +01:00
commit e39712bb36
2 changed files with 16 additions and 3 deletions

View file

@ -24,6 +24,9 @@ sent straight to the pane.
- Real ptys per pane, a built-in VT100/xterm-ish screen emulator (colors, - Real ptys per pane, a built-in VT100/xterm-ish screen emulator (colors,
256-color and truecolor SGR, alternate screen, scrolling, UTF-8, wide 256-color and truecolor SGR, alternate screen, scrolling, UTF-8, wide
characters). characters).
- Application cursor-key mode follows the active pane, so arrow navigation
works in programs such as Midnight Commander. Menus and prompts use normal
cursor-key mode; detaching restores normal cursor keys in the outer terminal.
- Multiple clients can attach to the same session. The most recently attached - Multiple clients can attach to the same session. The most recently attached
or resized client sets the session size; a larger client shows the session or resized client sets the session size; a larger client shows the session
centred in its terminal, while a smaller client shows the top-left part. centred in its terminal, while a smaller client shows the top-left part.

16
moerx.c
View file

@ -295,6 +295,7 @@ struct Pane {
int wrap_pending; int wrap_pending;
int scroll_top, scroll_bot; int scroll_top, scroll_bot;
int cursor_visible; int cursor_visible;
int app_cursor; /* DEC private mode 1: application cursor keys */
int insert_mode; int insert_mode;
Pen pen; Pen pen;
@ -483,6 +484,7 @@ static void em_reset(Pane *p) {
p->pen.attr = 0; p->pen.attr = 0;
p->cursor_visible = 1; p->cursor_visible = 1;
p->insert_mode = 0; p->insert_mode = 0;
p->app_cursor = 0;
p->pstate = PS_GROUND; p->pstate = PS_GROUND;
} }
@ -769,7 +771,8 @@ static void em_csi(Pane *p, const char *raw, int len, unsigned char final) {
for (int i = 0; i < pn; i++) { for (int i = 0; i < pn; i++) {
int v = ps[i]; int v = ps[i];
if (priv) { if (priv) {
if (v == 25) p->cursor_visible = on; if (v == 1) p->app_cursor = on;
else if (v == 25) p->cursor_visible = on;
else if (v == 47 || v == 1047 || v == 1049) em_set_alt(p, on); else if (v == 47 || v == 1047 || v == 1049) em_set_alt(p, on);
else if (v == 1048) { else if (v == 1048) {
if (on) { if (on) {
@ -2061,6 +2064,13 @@ static void draw_frame(Session *s, Client *c, Grid *scr) {
int cx, cy, vis; int cx, cy, vis;
cursor_for(s, c, &cx, &cy, &vis); cursor_for(s, c, &cx, &cy, &vis);
/* Match the pane's DECCKM request on every attached terminal. Otherwise
screen-256color applications such as mc expect ESC O A/B/C/D while
the outer terminal continues sending ESC [ A/B/C/D. Overlays use
normal cursor keys; switching panes restores that pane's mode. */
int app_cursor = !c->locked && c->mode == 0 && !c->prefix_pending &&
s->cur && s->cur->active && s->cur->active->app_cursor;
buf_puts(&b, app_cursor ? "\x1b[?1h" : "\x1b[?1l");
buf_puts(&b, "\x1b[0m"); buf_puts(&b, "\x1b[0m");
if (vis && (cy == 0 || cx >= vw || cy >= vh)) vis = 0; if (vis && (cy == 0 || cx >= vw || cy >= vh)) vis = 0;
if (vis) { if (vis) {
@ -3469,7 +3479,7 @@ static int tty_raw(struct termios *saved) {
} }
static void tty_restore(struct termios *saved) { static void tty_restore(struct termios *saved) {
const char *seq = "\x1b[0m\x1b[?25h\x1b[?1049l"; const char *seq = "\x1b[?1l\x1b[0m\x1b[?25h\x1b[?1049l";
write_all(STDOUT_FILENO, seq, strlen(seq)); write_all(STDOUT_FILENO, seq, strlen(seq));
tcsetattr(STDIN_FILENO, TCSAFLUSH, saved); tcsetattr(STDIN_FILENO, TCSAFLUSH, saved);
} }
@ -3541,7 +3551,7 @@ static int run_client(int fd, const char *name) {
signal(SIGPIPE, SIG_IGN); signal(SIGPIPE, SIG_IGN);
{ {
const char *seq = "\x1b[?1049h\x1b[?25l\x1b[2J\x1b[H"; const char *seq = "\x1b[?1049h\x1b[?1l\x1b[?25l\x1b[2J\x1b[H";
write_all(STDOUT_FILENO, seq, strlen(seq)); write_all(STDOUT_FILENO, seq, strlen(seq));
} }