Add pane title controls and nested session detection
Add --hide-pane-titles and a Configuration menu toggle for pane title rows, rework layout/border rendering to support hidden titles, refresh help text, and prevent murx inception by setting MURX in panes and refusing to start or attach when already inside murx.
This commit is contained in:
parent
e0901131f2
commit
614646a5b6
4 changed files with 236 additions and 131 deletions
10
AGENTS.md
10
AGENTS.md
|
|
@ -29,10 +29,12 @@ outside the repo for geometry/logic checks; do not leave test files behind.
|
||||||
|
|
||||||
- Windows use a binary `Layout` tree: `L_COLS` (left/right split) or
|
- Windows use a binary `Layout` tree: `L_COLS` (left/right split) or
|
||||||
`L_ROWS` (top/bottom split), with `Layout` x/y/w/h plus a `Pane` leaf.
|
`L_ROWS` (top/bottom split), with `Layout` x/y/w/h plus a `Pane` leaf.
|
||||||
- `layout_apply()` assigns pane content rectangles. Each pane has a title row
|
- `layout_apply()` assigns pane content rectangles. With pane titles shown
|
||||||
above its content, so `pane->y = layout->y + 1`.
|
(default), each leaf reserves its top row for a title and sets
|
||||||
- Splits reserve one border column/row between children, so pane rectangles do
|
`pane->y = layout->y + 1`; with `--hide-pane-titles`, content fills the leaf.
|
||||||
not touch; vertical stacks have a two-row visual gap including the title row.
|
- Splits reserve one border column/row between children. With titles shown,
|
||||||
|
horizontal splits use the lower pane's title row as the separator; with titles
|
||||||
|
hidden, horizontal splits draw a border row like vertical splits.
|
||||||
- Pane movement must be based on rectangle edges, not centres. A pane is only
|
- Pane movement must be based on rectangle edges, not centres. A pane is only
|
||||||
to the right if `p->x >= a->x + a->w` (and similar for the other directions).
|
to the right if `p->x >= a->x + a->w` (and similar for the other directions).
|
||||||
Centre comparison wrongly classifies tall/wide panes that merely extend past
|
Centre comparison wrongly classifies tall/wide panes that merely extend past
|
||||||
|
|
|
||||||
29
README.md
29
README.md
|
|
@ -65,10 +65,11 @@ Use `--cwd` to show the current directory on the left of the status bar,
|
||||||
and `--clock` to show the clock on the right. Use `--murx` to show `[murx]`
|
and `--clock` to show the clock on the right. Use `--murx` to show `[murx]`
|
||||||
on the left when `--cwd` is not enabled; the directory takes precedence if
|
on the left when `--cwd` is not enabled; the directory takes precedence if
|
||||||
both are supplied. Use `--hostname` to show the `hostname:` prefix in window
|
both are supplied. Use `--hostname` to show the `hostname:` prefix in window
|
||||||
names and the outer terminal title. All four features are disabled by default.
|
names and the outer terminal title. These display options are disabled by
|
||||||
These options set the initial values for a new session; the
|
default. Use `--hide-pane-titles` to hide the title row above each pane;
|
||||||
`Configuration...` menu can change them in a running session (see
|
pane titles are shown by default. These options set the initial values for a
|
||||||
[Menu](#menu)). To restore the previous default display, use
|
new session; the `Configuration...` menu can change them in a running session
|
||||||
|
(see [Menu](#menu)). To restore the previous default display, use
|
||||||
`murx --cwd --clock --hostname session`.
|
`murx --cwd --clock --hostname session`.
|
||||||
|
|
||||||
## Upgrading from moerx
|
## Upgrading from moerx
|
||||||
|
|
@ -97,12 +98,13 @@ and `murx-root`.
|
||||||
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.
|
||||||
`Ctrl-A R` forces the session back to the current client's terminal size.
|
`Ctrl-A R` forces the session back to the current client's terminal size.
|
||||||
- Panes run `$SHELL` as a login shell with `TERM=screen-256color`.
|
- Panes run `$SHELL` as a login shell with `TERM=screen-256color` and
|
||||||
They inherit the launching process's umask, so builds keep their usual file
|
`MURX=<session>`. They inherit the launching process's umask, so builds keep
|
||||||
permissions. After upgrading from a version that forced `077`, restart the
|
their usual file permissions. After upgrading from a version that forced `077`,
|
||||||
session server to apply the fix. In an existing shell, `umask 022` restores
|
restart the session server to apply the fix. In an existing shell, `umask 022`
|
||||||
typical public file permissions for subsequent commands, including builds
|
restores typical public file permissions for subsequent commands, including
|
||||||
published with `rsync -a`.
|
builds published with `rsync -a`. murx refuses to start inside another murx
|
||||||
|
session; use `env -u MURX murx` to override intentionally.
|
||||||
- Window names show `program` for the foreground program in their active pane,
|
- Window names show `program` for the foreground program in their active pane,
|
||||||
refreshed every second, including in inactive windows. With `--hostname`,
|
refreshed every second, including in inactive windows. With `--hostname`,
|
||||||
they show `hostname:program` (for example `laptop:zsh` or `laptop:vim`). When a program exits, the name returns to the shell. For
|
they show `hostname:program` (for example `laptop:zsh` or `laptop:vim`). When a program exits, the name returns to the shell. For
|
||||||
|
|
@ -373,8 +375,11 @@ Hard-coded:
|
||||||
report root status; install them in each remote shell, including root's.
|
report root status; install them in each remote shell, including root's.
|
||||||
A root shell that does not run the hooks cannot report its privilege change.
|
A root shell that does not run the hooks cannot report its privilege change.
|
||||||
- Pane borders are thin box-drawing lines (`─`, `│`, `┬`, `┼`, ...) in
|
- Pane borders are thin box-drawing lines (`─`, `│`, `┬`, `┼`, ...) in
|
||||||
`colour8`, drawn on the terminal's default background. Only splits have
|
`colour8`, drawn on the terminal's default background. By default, the row
|
||||||
borders; panes have no title row, leaving more space for terminal content.
|
above each pane is a title bar showing `[N: title]`: on the active pane,
|
||||||
|
brackets/numbers use `colour7`, separator `colour11`, title `colour15`; on
|
||||||
|
inactive panes, `colour8`, `colour3`, `colour12`. Use `--hide-pane-titles`
|
||||||
|
or the Configuration menu to hide title rows and give panes more space.
|
||||||
- Messages use `fg=colour6,bg=colour8`.
|
- Messages use `fg=colour6,bg=colour8`.
|
||||||
- Menus use a black background with a `colour12` frame, `colour11` titles and
|
- Menus use a black background with a `colour12` frame, `colour11` titles and
|
||||||
selection, `colour14` accents and dim `colour8` hints and separators.
|
selection, `colour14` accents and dim `colour8` hints and separators.
|
||||||
|
|
|
||||||
23
murx.1
23
murx.1
|
|
@ -27,6 +27,9 @@ The default session name is
|
||||||
Each session has its own server and Unix socket.
|
Each session has its own server and Unix socket.
|
||||||
Detaching leaves programs running; run the same command to reattach.
|
Detaching leaves programs running; run the same command to reattach.
|
||||||
The session ends when its last pane exits or its server is killed.
|
The session ends when its last pane exits or its server is killed.
|
||||||
|
murx refuses to start or attach inside another murx session; use
|
||||||
|
.B env \-u MURX murx
|
||||||
|
to override intentionally.
|
||||||
.PP
|
.PP
|
||||||
Multiple clients may attach simultaneously and share windows and the active
|
Multiple clients may attach simultaneously and share windows and the active
|
||||||
pane. Each client has its own prefix, menus, lock and scrollback view.
|
pane. Each client has its own prefix, menus, lock and scrollback view.
|
||||||
|
|
@ -78,11 +81,15 @@ is not enabled. The directory takes precedence if both options are supplied.
|
||||||
.B \-\-hostname
|
.B \-\-hostname
|
||||||
Show the hostname: prefix in window names and the outer terminal title.
|
Show the hostname: prefix in window names and the outer terminal title.
|
||||||
.TP
|
.TP
|
||||||
|
.B \-\-hide-pane-titles
|
||||||
|
Hide the title row above each pane. Pane titles are shown by default.
|
||||||
|
.TP
|
||||||
.BR \-h ", " \-\-help
|
.BR \-h ", " \-\-help
|
||||||
Print usage and keyboard shortcuts, then exit.
|
Print usage and keyboard shortcuts, then exit.
|
||||||
.PP
|
.PP
|
||||||
These four display features are disabled by default and set a new session's
|
Display options set a new session's values; the Configuration menu can
|
||||||
values; the Configuration menu can change them in a running session.
|
change them in a running session. The cwd, clock, [murx] label and hostname
|
||||||
|
options are off by default; pane titles are shown by default.
|
||||||
To restore the previous default display, use
|
To restore the previous default display, use
|
||||||
.BR "murx \-\-cwd \-\-clock \-\-hostname session" .
|
.BR "murx \-\-cwd \-\-clock \-\-hostname session" .
|
||||||
.SH KEY BINDINGS
|
.SH KEY BINDINGS
|
||||||
|
|
@ -255,7 +262,11 @@ The outer terminal title follows [murx] program, or [murx] hostname:program
|
||||||
with --hostname. Its [murx] prefix is always present; --murx controls only
|
with --hostname. Its [murx] prefix is always present; --murx controls only
|
||||||
the status label.
|
the status label.
|
||||||
Hostnames are shortened at the first dot.
|
Hostnames are shortened at the first dot.
|
||||||
Panes have no title rows; only splits have separator lines.
|
By default each pane has a title row above its content showing
|
||||||
|
[R N: title R], where N is the pane number. Active pane titles use colour7
|
||||||
|
brackets/numbers, colour11 separator and colour15 title; inactive panes use
|
||||||
|
colour8, colour3 and colour12. Use --hide-pane-titles or the Configuration
|
||||||
|
menu to hide title rows. Splits use thin box-drawing lines in colour8.
|
||||||
The status uses colour12, accents colour14 and the current window colour11.
|
The status uses colour12, accents colour14 and the current window colour11.
|
||||||
The current window name turns bright red (colour9) when its active pane's
|
The current window name turns bright red (colour9) when its active pane's
|
||||||
foreground process is su or has effective UID 0, including programs launched
|
foreground process is su or has effective UID 0, including programs launched
|
||||||
|
|
@ -418,6 +429,12 @@ Command text is never evaluated by these hooks.
|
||||||
Both examples emit invisible terminal updates rather than visible command lines.
|
Both examples emit invisible terminal updates rather than visible command lines.
|
||||||
.SH ENVIRONMENT
|
.SH ENVIRONMENT
|
||||||
.TP
|
.TP
|
||||||
|
.B MURX
|
||||||
|
Set inside panes to the session name. murx refuses to start or attach when
|
||||||
|
this variable is set, preventing nested sessions. Use
|
||||||
|
.B env \-u MURX murx
|
||||||
|
to override intentionally.
|
||||||
|
.TP
|
||||||
.B SHELL
|
.B SHELL
|
||||||
Login shell started in new panes. If unset or empty, /usr/bin/zsh is used
|
Login shell started in new panes. If unset or empty, /usr/bin/zsh is used
|
||||||
when executable, otherwise /bin/sh.
|
when executable, otherwise /bin/sh.
|
||||||
|
|
|
||||||
305
murx.c
305
murx.c
|
|
@ -1278,6 +1278,7 @@ typedef struct {
|
||||||
int show_clock;
|
int show_clock;
|
||||||
int show_murx;
|
int show_murx;
|
||||||
int show_hostname;
|
int show_hostname;
|
||||||
|
int show_pane_titles;
|
||||||
} DisplayOptions;
|
} DisplayOptions;
|
||||||
|
|
||||||
struct Session {
|
struct Session {
|
||||||
|
|
@ -1492,7 +1493,8 @@ static void pane_free(Pane *p) {
|
||||||
free(p);
|
free(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Pane *pane_new(const char *cwd, int w, int h, const char *title) {
|
static Pane *pane_new(const char *cwd, int w, int h, const char *title,
|
||||||
|
const char *session_name) {
|
||||||
struct winsize iws;
|
struct winsize iws;
|
||||||
memset(&iws, 0, sizeof iws);
|
memset(&iws, 0, sizeof iws);
|
||||||
iws.ws_col = tty_dimension(w > 0 ? w : 80);
|
iws.ws_col = tty_dimension(w > 0 ? w : 80);
|
||||||
|
|
@ -1542,6 +1544,7 @@ static Pane *pane_new(const char *cwd, int w, int h, const char *title) {
|
||||||
signal(SIGINT, SIG_DFL);
|
signal(SIGINT, SIG_DFL);
|
||||||
signal(SIGTERM, SIG_DFL);
|
signal(SIGTERM, SIG_DFL);
|
||||||
setenv("TERM", "screen-256color", 1);
|
setenv("TERM", "screen-256color", 1);
|
||||||
|
if (session_name && *session_name) setenv("MURX", session_name, 1);
|
||||||
if (cwd && *cwd) chdir(cwd);
|
if (cwd && *cwd) chdir(cwd);
|
||||||
const char *base = strrchr(shell, '/');
|
const char *base = strrchr(shell, '/');
|
||||||
base = base ? base + 1 : shell;
|
base = base ? base + 1 : shell;
|
||||||
|
|
@ -1600,7 +1603,7 @@ static int layout_pane_count(Layout *l) {
|
||||||
return count_add(layout_pane_count(l->a), layout_pane_count(l->b));
|
return count_add(layout_pane_count(l->a), layout_pane_count(l->b));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void layout_apply(Layout *l, int x, int y, int w, int h) {
|
static void layout_apply(Layout *l, int x, int y, int w, int h, int show_titles) {
|
||||||
if (!l) return;
|
if (!l) return;
|
||||||
if (w < 1) w = 1;
|
if (w < 1) w = 1;
|
||||||
if (h < 1) h = 1;
|
if (h < 1) h = 1;
|
||||||
|
|
@ -1611,9 +1614,17 @@ static void layout_apply(Layout *l, int x, int y, int w, int h) {
|
||||||
|
|
||||||
if (l->type == L_LEAF) {
|
if (l->type == L_LEAF) {
|
||||||
Pane *p = l->pane;
|
Pane *p = l->pane;
|
||||||
p->x = x;
|
if (show_titles) {
|
||||||
p->y = y;
|
int ph = h - 1;
|
||||||
pane_resize(p, w, h);
|
if (ph < 1) ph = 1;
|
||||||
|
p->x = x;
|
||||||
|
p->y = y + 1;
|
||||||
|
pane_resize(p, w, ph);
|
||||||
|
} else {
|
||||||
|
p->x = x;
|
||||||
|
p->y = y;
|
||||||
|
pane_resize(p, w, h);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1626,18 +1637,28 @@ static void layout_apply(Layout *l, int x, int y, int w, int h) {
|
||||||
if (aw < 1) aw = 1;
|
if (aw < 1) aw = 1;
|
||||||
if (avail - aw < 1) aw = avail;
|
if (avail - aw < 1) aw = avail;
|
||||||
l->ratio = (double)aw / (double)avail;
|
l->ratio = (double)aw / (double)avail;
|
||||||
layout_apply(l->a, x, y, aw, h);
|
layout_apply(l->a, x, y, aw, h, show_titles);
|
||||||
layout_apply(l->b, x + aw + 1, y, avail - aw, h);
|
layout_apply(l->b, x + aw + 1, y, avail - aw, h, show_titles);
|
||||||
} else {
|
} else {
|
||||||
int avail = h - 1;
|
if (show_titles) {
|
||||||
if (avail < 1) avail = 1;
|
int ah = (int)(h * l->ratio + 0.5);
|
||||||
int ah = (int)(avail * l->ratio + 0.5);
|
if (ah < 2) ah = 2;
|
||||||
if (ah < 1) ah = 1;
|
if (ah > h - 2) ah = h - 2;
|
||||||
if (ah > avail - 1) ah = avail - 1;
|
if (ah < 1) ah = 1;
|
||||||
if (ah < 1) ah = 1;
|
l->ratio = (double)ah / (double)h;
|
||||||
l->ratio = (double)ah / (double)avail;
|
layout_apply(l->a, x, y, w, ah, show_titles);
|
||||||
layout_apply(l->a, x, y, w, ah);
|
layout_apply(l->b, x, y + ah, w, h - ah, show_titles);
|
||||||
layout_apply(l->b, x, y + ah + 1, w, avail - ah);
|
} else {
|
||||||
|
int avail = h - 1;
|
||||||
|
if (avail < 1) avail = 1;
|
||||||
|
int ah = (int)(avail * l->ratio + 0.5);
|
||||||
|
if (ah < 1) ah = 1;
|
||||||
|
if (ah > avail - 1) ah = avail - 1;
|
||||||
|
if (ah < 1) ah = 1;
|
||||||
|
l->ratio = (double)ah / (double)avail;
|
||||||
|
layout_apply(l->a, x, y, w, ah, show_titles);
|
||||||
|
layout_apply(l->b, x, y + ah + 1, w, avail - ah, show_titles);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1716,7 +1737,7 @@ static Window *window_new(Session *s, const char *name) {
|
||||||
int pw = s->w > 0 ? s->w : 80;
|
int pw = s->w > 0 ? s->w : 80;
|
||||||
int ph = s->h > 1 ? s->h - 1 : 23;
|
int ph = s->h > 1 ? s->h - 1 : 23;
|
||||||
if (ph < 1) ph = 1;
|
if (ph < 1) ph = 1;
|
||||||
Pane *p = pane_new(s->cwd, pw, ph, host);
|
Pane *p = pane_new(s->cwd, pw, ph, host, s->name);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
free(w);
|
free(w);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -1737,11 +1758,12 @@ static Window *window_new(Session *s, const char *name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void session_layout(Session *s) {
|
static void session_layout(Session *s) {
|
||||||
if (!s->cur || !s->cur->root) return;
|
|
||||||
int top = s->status_bottom ? 0 : 1;
|
int top = s->status_bottom ? 0 : 1;
|
||||||
int h = s->h - 1;
|
int h = s->h - 1;
|
||||||
if (h < 1) h = 1;
|
if (h < 1) h = 1;
|
||||||
layout_apply(s->cur->root, 0, top, s->w, h);
|
for (Window *w = s->windows; w; w = w->next) {
|
||||||
|
if (w->root) layout_apply(w->root, 0, top, s->w, h, s->display.show_pane_titles);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------ */
|
||||||
|
|
@ -1857,9 +1879,22 @@ static void border_mark(uint8_t *m, int w, int h, int x, int y, uint8_t bits) {
|
||||||
m[y * w + x] |= bits;
|
m[y * w + x] |= bits;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void border_collect(uint8_t *m, int w, int h, Layout *l) {
|
static void border_collect(uint8_t *m, int w, int h, Layout *l, int show_titles) {
|
||||||
if (!l || l->w < 1 || l->h < 1) return;
|
if (!l || l->w < 1 || l->h < 1) return;
|
||||||
if (l->type == L_LEAF) return;
|
if (l->type == L_LEAF) {
|
||||||
|
if (show_titles) {
|
||||||
|
int y = l->y;
|
||||||
|
int end = l->x + l->w;
|
||||||
|
if (y < 0 || y >= h) return;
|
||||||
|
for (int x = l->x; x < end; x++) {
|
||||||
|
uint8_t bits = 0;
|
||||||
|
if (x > l->x || l->w == 1) bits |= B_LEFT;
|
||||||
|
if (x < end - 1 || l->w == 1) bits |= B_RIGHT;
|
||||||
|
border_mark(m, w, h, x, y, bits);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (l->type == L_COLS) {
|
if (l->type == L_COLS) {
|
||||||
int ax = l->x + l->a->w;
|
int ax = l->x + l->a->w;
|
||||||
int end = l->y + l->h;
|
int end = l->y + l->h;
|
||||||
|
|
@ -1870,7 +1905,7 @@ static void border_collect(uint8_t *m, int w, int h, Layout *l) {
|
||||||
border_mark(m, w, h, ax, y, bits);
|
border_mark(m, w, h, ax, y, bits);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else if (!show_titles) {
|
||||||
int ay = l->y + l->a->h;
|
int ay = l->y + l->a->h;
|
||||||
int end = l->x + l->w;
|
int end = l->x + l->w;
|
||||||
for (int x = l->x; x < end; x++) {
|
for (int x = l->x; x < end; x++) {
|
||||||
|
|
@ -1880,8 +1915,8 @@ static void border_collect(uint8_t *m, int w, int h, Layout *l) {
|
||||||
border_mark(m, w, h, x, ay, bits);
|
border_mark(m, w, h, x, ay, bits);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
border_collect(m, w, h, l->a);
|
border_collect(m, w, h, l->a, show_titles);
|
||||||
border_collect(m, w, h, l->b);
|
border_collect(m, w, h, l->b, show_titles);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fill in the missing half of a T-junction: a line that ends next to a
|
/* Fill in the missing half of a T-junction: a line that ends next to a
|
||||||
|
|
@ -1943,6 +1978,46 @@ static void border_render(Grid *g, const uint8_t *m) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void draw_window_label(Grid *g, Window *win, Pane *p) {
|
||||||
|
int active = (p == win->active);
|
||||||
|
int fg1 = active ? C_WHITE : C_GREY;
|
||||||
|
int fg2 = active ? C_YELLOW : 3;
|
||||||
|
int fg3 = active ? C_BWHITE : C_BLUE;
|
||||||
|
int x = p->x;
|
||||||
|
int y = p->y - 1;
|
||||||
|
int end = p->x + p->w;
|
||||||
|
if (y < 0 || y >= g->h) return;
|
||||||
|
if (x < end) scr_put(g, x++, y, '[', fg1, DEFAULT_COLOR, 0);
|
||||||
|
char num[32];
|
||||||
|
snprintf(num, sizeof num, "%d", p->id);
|
||||||
|
x = draw_text(g, x, y, num, fg1, DEFAULT_COLOR, 0);
|
||||||
|
if (x < end) scr_put(g, x++, y, ':', fg2, DEFAULT_COLOR, 0);
|
||||||
|
if (x < end) scr_put(g, x++, y, ' ', fg2, DEFAULT_COLOR, 0);
|
||||||
|
const char *title = p->title[0] ? p->title : win->name;
|
||||||
|
const unsigned char *s = (const unsigned char *)title;
|
||||||
|
while (*s && x < end - 1) {
|
||||||
|
uint32_t cp;
|
||||||
|
int used = utf8_decode(s, (int)strlen((const char *)s), &cp);
|
||||||
|
int w = cp_width(cp);
|
||||||
|
if (w < 1) w = 1;
|
||||||
|
if (x + w > end - 1) break;
|
||||||
|
scr_put_wide(g, x, y, cp, fg3, DEFAULT_COLOR, 0);
|
||||||
|
x += w;
|
||||||
|
s += used;
|
||||||
|
}
|
||||||
|
if (x < end) scr_put(g, x, y, ']', fg1, DEFAULT_COLOR, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void draw_labels(Grid *g, Layout *l, Window *win) {
|
||||||
|
if (!l || l->w < 1 || l->h < 1) return;
|
||||||
|
if (l->type == L_LEAF) {
|
||||||
|
draw_window_label(g, win, l->pane);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
draw_labels(g, l->a, win);
|
||||||
|
draw_labels(g, l->b, win);
|
||||||
|
}
|
||||||
|
|
||||||
static void draw_layout(Grid *g, Layout *l) {
|
static void draw_layout(Grid *g, Layout *l) {
|
||||||
if (!l || l->w < 1 || l->h < 1) return;
|
if (!l || l->w < 1 || l->h < 1) return;
|
||||||
if (l->type == L_LEAF) {
|
if (l->type == L_LEAF) {
|
||||||
|
|
@ -2232,6 +2307,7 @@ enum {
|
||||||
SET_SHOW_CLOCK,
|
SET_SHOW_CLOCK,
|
||||||
SET_SHOW_MURX,
|
SET_SHOW_MURX,
|
||||||
SET_SHOW_HOSTNAME,
|
SET_SHOW_HOSTNAME,
|
||||||
|
SET_SHOW_PANE_TITLES,
|
||||||
SET_PREFIX
|
SET_PREFIX
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -2306,6 +2382,7 @@ static const MenuItem menu_config_items[] = {
|
||||||
{ "Show clock", MI_TOGGLE, SET_SHOW_CLOCK, 1, 0 },
|
{ "Show clock", MI_TOGGLE, SET_SHOW_CLOCK, 1, 0 },
|
||||||
{ "Show [murx] label", MI_TOGGLE, SET_SHOW_MURX, 1, 0 },
|
{ "Show [murx] label", MI_TOGGLE, SET_SHOW_MURX, 1, 0 },
|
||||||
{ "Show hostname", MI_TOGGLE, SET_SHOW_HOSTNAME, 1, 0 },
|
{ "Show hostname", MI_TOGGLE, SET_SHOW_HOSTNAME, 1, 0 },
|
||||||
|
{ "Show pane titles", MI_TOGGLE, SET_SHOW_PANE_TITLES, 1, 0 },
|
||||||
MENU_SEP,
|
MENU_SEP,
|
||||||
{ "Reset display/status defaults", MI_ACTION, ACT_RESET_DISPLAY, 0, 0 }
|
{ "Reset display/status defaults", MI_ACTION, ACT_RESET_DISPLAY, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
@ -2401,6 +2478,7 @@ static int menu_setting_on(Session *s, Client *c, const MenuItem *it) {
|
||||||
case SET_SHOW_CLOCK: return s->display.show_clock == it->arg;
|
case SET_SHOW_CLOCK: return s->display.show_clock == it->arg;
|
||||||
case SET_SHOW_MURX: return s->display.show_murx == it->arg;
|
case SET_SHOW_MURX: return s->display.show_murx == it->arg;
|
||||||
case SET_SHOW_HOSTNAME: return s->display.show_hostname == it->arg;
|
case SET_SHOW_HOSTNAME: return s->display.show_hostname == it->arg;
|
||||||
|
case SET_SHOW_PANE_TITLES: return s->display.show_pane_titles == it->arg;
|
||||||
case SET_PREFIX: return c->prefix == it->arg;
|
case SET_PREFIX: return c->prefix == it->arg;
|
||||||
default: return 0;
|
default: return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -2515,10 +2593,12 @@ static void compose(Session *s, Client *c, Grid *out) {
|
||||||
grid_clear(out, DEFAULT_COLOR);
|
grid_clear(out, DEFAULT_COLOR);
|
||||||
if (s->cur && s->cur->root) {
|
if (s->cur && s->cur->root) {
|
||||||
uint8_t *mask = xcalloc((size_t)out->w, (size_t)out->h);
|
uint8_t *mask = xcalloc((size_t)out->w, (size_t)out->h);
|
||||||
border_collect(mask, s->w, s->h, s->cur->root);
|
border_collect(mask, s->w, s->h, s->cur->root, s->display.show_pane_titles);
|
||||||
border_join(mask, s->w, s->h);
|
border_join(mask, s->w, s->h);
|
||||||
draw_layout(out, s->cur->root);
|
draw_layout(out, s->cur->root);
|
||||||
border_render(out, mask);
|
border_render(out, mask);
|
||||||
|
if (s->display.show_pane_titles)
|
||||||
|
draw_labels(out, s->cur->root, s->cur);
|
||||||
free(mask);
|
free(mask);
|
||||||
}
|
}
|
||||||
Scrollback *view = scrollback_current(c, s);
|
Scrollback *view = scrollback_current(c, s);
|
||||||
|
|
@ -2939,7 +3019,7 @@ static void switch_last_window(Session *s) {
|
||||||
static Pane *host_pane_new(Session *s, int w, int h) {
|
static Pane *host_pane_new(Session *s, int w, int h) {
|
||||||
char host[128];
|
char host[128];
|
||||||
short_hostname(host, sizeof host);
|
short_hostname(host, sizeof host);
|
||||||
return pane_new(s->cwd, w, h, host);
|
return pane_new(s->cwd, w, h, host, s->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void split_pane(Session *s, int type) {
|
static void split_pane(Session *s, int type) {
|
||||||
|
|
@ -3395,6 +3475,11 @@ static void menu_apply_setting(Client *c, Session *s, const MenuItem *it) {
|
||||||
case SET_SHOW_CLOCK: s->display.show_clock = it->arg ? 1 : 0; break;
|
case SET_SHOW_CLOCK: s->display.show_clock = it->arg ? 1 : 0; break;
|
||||||
case SET_SHOW_MURX: s->display.show_murx = it->arg ? 1 : 0; break;
|
case SET_SHOW_MURX: s->display.show_murx = it->arg ? 1 : 0; break;
|
||||||
case SET_SHOW_HOSTNAME: s->display.show_hostname = it->arg ? 1 : 0; break;
|
case SET_SHOW_HOSTNAME: s->display.show_hostname = it->arg ? 1 : 0; break;
|
||||||
|
case SET_SHOW_PANE_TITLES:
|
||||||
|
s->display.show_pane_titles = it->arg ? 1 : 0;
|
||||||
|
session_layout(s);
|
||||||
|
s->redraw = 1;
|
||||||
|
break;
|
||||||
case SET_PREFIX: c->prefix = (unsigned char)it->arg; break;
|
case SET_PREFIX: c->prefix = (unsigned char)it->arg; break;
|
||||||
default: return;
|
default: return;
|
||||||
}
|
}
|
||||||
|
|
@ -3435,6 +3520,7 @@ static void menu_action(Client *c, Session *s, int action) {
|
||||||
case ACT_KILL_SERVER: start_confirm(c, 2, "kill-server? (y/n) "); break;
|
case ACT_KILL_SERVER: start_confirm(c, 2, "kill-server? (y/n) "); break;
|
||||||
case ACT_RESET_DISPLAY:
|
case ACT_RESET_DISPLAY:
|
||||||
memset(&s->display, 0, sizeof s->display);
|
memset(&s->display, 0, sizeof s->display);
|
||||||
|
s->display.show_pane_titles = 1;
|
||||||
s->status_bottom = 0;
|
s->status_bottom = 0;
|
||||||
s->status_bg = 0;
|
s->status_bg = 0;
|
||||||
session_layout(s);
|
session_layout(s);
|
||||||
|
|
@ -4804,92 +4890,76 @@ static int run_client(int fd, const char *name, unsigned char prefix, int status
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Two-column help rows: the left field is padded so descriptions line up. */
|
||||||
|
static void help_row(FILE *out, const char *left, const char *right) {
|
||||||
|
fprintf(out, " %-24s %s\n", left, right);
|
||||||
|
}
|
||||||
|
|
||||||
static void print_help(FILE *out) {
|
static void print_help(FILE *out) {
|
||||||
fprintf(out,
|
fputs("usage: murx [OPTIONS] [session]\n"
|
||||||
"usage: murx [-p letter] [-s top|bottom] [-c RRGGBB] [--cwd] [--clock] [--murx] [--hostname] [--] [session]\n"
|
"\n"
|
||||||
" murx -l | --list-sessions\n"
|
"Attach to a running session, starting a server if needed. The session\n"
|
||||||
" murx -h | --help\n"
|
"name defaults to \"0\". Detach with the prefix followed by d.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Attach to a running session, or start it if it is not running.\n"
|
"Options:\n", out);
|
||||||
"The session name defaults to \"0\".\n"
|
|
||||||
"\n"
|
help_row(out, "-h, --help", "show this help and exit");
|
||||||
"Use -l or --list-sessions to list running sessions without attaching.\n"
|
help_row(out, "-l, --list-sessions", "list running sessions without attaching");
|
||||||
"\n"
|
help_row(out, "-p, --prefix LETTER", "client prefix Ctrl-LETTER (a-z, default: a)");
|
||||||
"Use -s top|bottom (or --status top|bottom) to position the status line.\n"
|
help_row(out, "-s, --status POSITION", "status line: top or bottom (new sessions: top)");
|
||||||
"New sessions default to top; an explicit choice updates all attached clients.\n"
|
help_row(out, "-c, --color RRGGBB", "status bar background, six hex digits (e.g. 000000)");
|
||||||
"Without -s, keep the session position.\n"
|
help_row(out, "--cwd", "show current directory in status bar");
|
||||||
"Use -c RRGGBB (or --color RRGGBB) to set the session's status bar background.\n"
|
help_row(out, "--clock", "show clock in status bar");
|
||||||
"Specify six hexadecimal digits, such as 000000 for black.\n"
|
help_row(out, "--murx", "show [murx] in status bar unless --cwd is set");
|
||||||
"New sessions use the terminal default. Without -c, keep the session color.\n"
|
help_row(out, "--hostname", "show hostname: prefix in window titles");
|
||||||
"Use --cwd to show the current directory in the status bar.\n"
|
help_row(out, "--hide-pane-titles", "hide the title row above each pane");
|
||||||
"Use --clock to show the clock in the status bar.\n"
|
|
||||||
"Use --murx to show [murx] in the status bar when --cwd is not enabled.\n"
|
fputs("\n"
|
||||||
"Use --hostname to show the hostname: prefix in window titles.\n"
|
"Without -s or -c, an existing session keeps its position and color.\n"
|
||||||
"These four features default to off and set a new session's values;\n"
|
"Display options set new session values and can be changed later from\n"
|
||||||
"the Configuration menu can change them in a running session.\n"
|
"the Configuration menu. Pane titles are shown by default.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Use -p x (or --prefix x) to choose Ctrl-X as this client's prefix.\n"
|
"Shortcuts (press the prefix, release it, then press the key shown;\n"
|
||||||
"Letters a through z are supported (case-insensitive); the default is a (Ctrl-A).\n"
|
"Ctrl-A is the default prefix):\n"
|
||||||
"The shortcuts below use the default Ctrl-A prefix. Replace it with\n"
|
"\n", out);
|
||||||
"your chosen prefix, including both keys in the last-window shortcut.\n"
|
|
||||||
"Prefix then a sends the chosen prefix literally to the pane.\n"
|
fputs("Menu\n", out);
|
||||||
"\n"
|
help_row(out, "m", "open the main menu");
|
||||||
"Menu\n"
|
|
||||||
" Ctrl-A m open the main menu\n"
|
fputs("\nWindows\n", out);
|
||||||
"\n"
|
help_row(out, "c, Ctrl-C", "new window");
|
||||||
"Windows\n"
|
help_row(out, "n, Space, Ctrl-N, Ctrl-@", "next window");
|
||||||
" Ctrl-A c new window\n"
|
help_row(out, "p, Ctrl-P, Backspace", "previous window");
|
||||||
" Ctrl-A Ctrl-C new window\n"
|
help_row(out, "Ctrl-A", "last window (press prefix twice)");
|
||||||
" Ctrl-A n next window\n"
|
help_row(out, "w, Ctrl-W, \"", "window menu");
|
||||||
" Ctrl-A Space next window\n"
|
help_row(out, "A", "rename window");
|
||||||
" Ctrl-A Ctrl-N next window\n"
|
help_row(out, "0 .. 9", "select window by number");
|
||||||
" Ctrl-A Ctrl-@ next window\n"
|
help_row(out, "&", "kill window (confirm)");
|
||||||
" Ctrl-A p previous window\n"
|
|
||||||
" Ctrl-A Backspace previous window\n"
|
fputs("\nPanes\n", out);
|
||||||
" Ctrl-A Ctrl-P previous window\n"
|
help_row(out, "|, %", "split left/right");
|
||||||
" Ctrl-A Ctrl-A last window\n"
|
help_row(out, "-", "split top/bottom");
|
||||||
" Ctrl-A w window menu\n"
|
help_row(out, "h, j, k, l", "select pane left/down/up/right");
|
||||||
" Ctrl-A Ctrl-W window menu\n"
|
help_row(out, "Up, Down, Left, Right", "select pane");
|
||||||
" Ctrl-A \" window menu\n"
|
help_row(out, "Tab, Shift-Tab, o", "next/previous pane");
|
||||||
" Ctrl-A A rename window\n"
|
help_row(out, "Ctrl-H, Ctrl-J", "resize pane left/down");
|
||||||
" Ctrl-A 0 .. Ctrl-A 9 select window by number\n"
|
help_row(out, "Ctrl-K, Ctrl-L", "resize pane up/right");
|
||||||
" Ctrl-A & kill window (confirm)\n"
|
help_row(out, "K", "kill pane (confirm)");
|
||||||
"\n"
|
help_row(out, "PageUp, [", "scrollback (PgUp/PgDn; q/Esc exits)");
|
||||||
"Panes\n"
|
|
||||||
" Ctrl-A | split left/right\n"
|
fputs("\nClient and session\n", out);
|
||||||
" Ctrl-A %% split left/right\n"
|
help_row(out, "a", "send prefix literally to the pane");
|
||||||
" Ctrl-A - split top/bottom\n"
|
help_row(out, "x, Ctrl-X", "lock the client");
|
||||||
" Ctrl-A h select pane left\n"
|
help_row(out, "*", "list attached clients");
|
||||||
" Ctrl-A j select pane down\n"
|
help_row(out, "r", "show \"Configuration Reloaded!\"");
|
||||||
" Ctrl-A k select pane up\n"
|
help_row(out, "R", "resize session to this terminal");
|
||||||
" Ctrl-A l select pane right\n"
|
help_row(out, "d, Ctrl-D", "detach");
|
||||||
" Ctrl-A arrow keys select pane\n"
|
help_row(out, "\\", "kill server (confirm)");
|
||||||
" Ctrl-A Tab next pane\n"
|
|
||||||
" Ctrl-A Shift-Tab previous pane\n"
|
fputs("\nMenus: Up/Down or j/k move, Left/Right or h/l enter/leave submenus,\n"
|
||||||
" Ctrl-A o next pane\n"
|
"Enter selects, q/Escape/Ctrl-C closes. Prompts: Enter accepts,\n"
|
||||||
" Ctrl-A Ctrl-H resize pane left\n"
|
"Escape/Ctrl-C cancels, Ctrl-U clears. Window shortcuts work in scrollback.\n"
|
||||||
" Ctrl-A Ctrl-J resize pane down\n"
|
"See murx(1) for the full manual.\n", out);
|
||||||
" Ctrl-A Ctrl-K resize pane up\n"
|
|
||||||
" Ctrl-A Ctrl-L resize pane right\n"
|
|
||||||
" Ctrl-A K kill pane (confirm)\n"
|
|
||||||
" Ctrl-A PageUp, [ scrollback (PgUp/PgDn; q/Escape exits)\n"
|
|
||||||
" window creation and switching shortcuts work in scrollback\n"
|
|
||||||
"\n"
|
|
||||||
"Client and server\n"
|
|
||||||
" Ctrl-A a send a literal Ctrl-A to the pane\n"
|
|
||||||
" Ctrl-A x lock the client\n"
|
|
||||||
" Ctrl-A Ctrl-X lock the client\n"
|
|
||||||
" Ctrl-A * list attached clients\n"
|
|
||||||
" Ctrl-A r show \"Configuration Reloaded!\"\n"
|
|
||||||
" Ctrl-A R resize session to this terminal (force)\n"
|
|
||||||
" Ctrl-A d detach\n"
|
|
||||||
" Ctrl-A Ctrl-D detach\n"
|
|
||||||
" Ctrl-A \\ kill server (confirm)\n"
|
|
||||||
"\n"
|
|
||||||
"Inside menus use Up/Down or j/k, Left/Right or h/l for submenus,\n"
|
|
||||||
"Enter to select and q or Escape to close. The Configuration menu holds\n"
|
|
||||||
"status line, prefix and display settings.\n"
|
|
||||||
"Inside prompts use Enter to accept, Escape to cancel, Ctrl-U to clear.\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int parse_prefix(const char *text, unsigned char *prefix) {
|
static int parse_prefix(const char *text, unsigned char *prefix) {
|
||||||
|
|
@ -4908,7 +4978,7 @@ int main(int argc, char **argv) {
|
||||||
unsigned char prefix = DEFAULT_PREFIX;
|
unsigned char prefix = DEFAULT_PREFIX;
|
||||||
int status = 0;
|
int status = 0;
|
||||||
uint32_t color = 0;
|
uint32_t color = 0;
|
||||||
DisplayOptions display = {0, 0, 0, 0};
|
DisplayOptions display = {0, 0, 0, 0, 1};
|
||||||
int list = 0;
|
int list = 0;
|
||||||
while (argi < argc && argv[argi][0] == '-' && argv[argi][1]) {
|
while (argi < argc && argv[argi][0] == '-' && argv[argi][1]) {
|
||||||
const char *option = argv[argi++];
|
const char *option = argv[argi++];
|
||||||
|
|
@ -4927,6 +4997,8 @@ int main(int argc, char **argv) {
|
||||||
display.show_murx = 1;
|
display.show_murx = 1;
|
||||||
} else if (strcmp(option, "--hostname") == 0) {
|
} else if (strcmp(option, "--hostname") == 0) {
|
||||||
display.show_hostname = 1;
|
display.show_hostname = 1;
|
||||||
|
} else if (strcmp(option, "--hide-pane-titles") == 0) {
|
||||||
|
display.show_pane_titles = 0;
|
||||||
} else if (strcmp(option, "-p") == 0 || strcmp(option, "--prefix") == 0) {
|
} else if (strcmp(option, "-p") == 0 || strcmp(option, "--prefix") == 0) {
|
||||||
if (argi >= argc || !parse_prefix(argv[argi], &prefix)) {
|
if (argi >= argc || !parse_prefix(argv[argi], &prefix)) {
|
||||||
fprintf(stderr, "murx: %s requires a letter from a through z\n", option);
|
fprintf(stderr, "murx: %s requires a letter from a through z\n", option);
|
||||||
|
|
@ -4973,6 +5045,15 @@ int main(int argc, char **argv) {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *in_murx = getenv("MURX");
|
||||||
|
if (in_murx && *in_murx) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"murx: already running inside murx session '%s'\n"
|
||||||
|
" Refusing to nest. Unset MURX to override: env -u MURX murx\n",
|
||||||
|
in_murx);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
make_socket_path(name, path, sizeof path);
|
make_socket_path(name, path, sizeof path);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue