It is possible to switch and create windows even when in scroll mode.
This commit is contained in:
parent
e3dff5136c
commit
1f1e48cebc
5 changed files with 123 additions and 66 deletions
6
APKBUILD
6
APKBUILD
|
|
@ -26,10 +26,10 @@ package() {
|
||||||
}
|
}
|
||||||
|
|
||||||
sha512sums="
|
sha512sums="
|
||||||
a2ce74a762c5d4a29ed2a0c1db930c4d6c5a02ff1b75c87c1a713ed3db01f26356d4a9bc73b43da7a94e05e90421353c7db3e5765a219b05adfda5690917c683 murx.c
|
95b73a9ce945da4071f60007a5c57f288b68e0677b05f8a4ffc8c0a10940e5ed57e9df1840e6ce2741d471e15375cfb5a4a09edade51c6b4866160a3c507cd73 murx.c
|
||||||
ca73b902d64fc9dc52d8d14b6c8ca6b494f4bea3f3602c29fd2909252668e110edff075c881e014e689d7c7d990dee2a4a96208276bae50243ca382adc5ead80 Makefile
|
ca73b902d64fc9dc52d8d14b6c8ca6b494f4bea3f3602c29fd2909252668e110edff075c881e014e689d7c7d990dee2a4a96208276bae50243ca382adc5ead80 Makefile
|
||||||
e084b9d2eaf2d93080898439a98e9a0a9acf2e076a53849f89ea0fff9a24d277cb348736cd3607bf18c9b94bd72af1c60d37617af9347d0452a04aff7160bedb murx.1
|
db9fe919bac2b4976efa6d760b1f917ec6fee88a4f2811ea4ac69334f6f24d522569c2cd3c3d087eb43cace659bf4c00f3c4097cc901d769b4e4000342d65c45 murx.1
|
||||||
af70fd707b1bcaaac68fffe8090783e06c9d494cc2ad11c0bfcc8e963bd51a658a02b17e296ed4017b87ffd04a412389c04d65a3192f78908deb7d70645162c1 README.md
|
153e4c4d23e64b74119714790c3701cc3cb2883494237fb44974efb9fc95a9adbc9a3425b1ed93d6e14014d8b3861e08ce2ef658093cd3ea151d9cf9fdada07f README.md
|
||||||
2fe33ba22c5f68e124904be594208f050be20f33d115f9a56f60cac93304102da32e6a7e78154e831d3704da7ca8bfefd7025e7b8901e65babcd83e7342f6382 LICENSE
|
2fe33ba22c5f68e124904be594208f050be20f33d115f9a56f60cac93304102da32e6a7e78154e831d3704da7ca8bfefd7025e7b8901e65babcd83e7342f6382 LICENSE
|
||||||
4d32dba475e5f9818fcd008068b011cbae9fc4b8e29897c933775d6660f44a7992d08a1550320d83233af729a42b241ef1d182bf5983ef2f64deab76cab2260d AUTHORS
|
4d32dba475e5f9818fcd008068b011cbae9fc4b8e29897c933775d6660f44a7992d08a1550320d83233af729a42b241ef1d182bf5983ef2f64deab76cab2260d AUTHORS
|
||||||
"
|
"
|
||||||
|
|
|
||||||
6
PKGBUILD
6
PKGBUILD
|
|
@ -8,10 +8,10 @@ url='https://codeberg.org/armin/murx'
|
||||||
license=('Apache-2.0')
|
license=('Apache-2.0')
|
||||||
depends=('glibc')
|
depends=('glibc')
|
||||||
source=('murx.c' 'Makefile' 'murx.1' 'README.md' 'LICENSE' 'AUTHORS')
|
source=('murx.c' 'Makefile' 'murx.1' 'README.md' 'LICENSE' 'AUTHORS')
|
||||||
sha256sums=('0e30a88aac206f531087115521b3233acd35c011d625c44ff0c7e6809600d92f'
|
sha256sums=('ef7a6d215ec78876a7eb850eae5bb554011c4e12b4f0607f57d9195d9e2ba821'
|
||||||
'c683ed74c664ebb2a72603297367ed102afdf27e4d6cee47920db8632a8efa91'
|
'c683ed74c664ebb2a72603297367ed102afdf27e4d6cee47920db8632a8efa91'
|
||||||
'22bcaf7178867f0978616634951c6b89f9812698f9d21541cd742049dd6069e5'
|
'd2219b9be02a6d588c593eb001c2c7f1ada845c4c72fa5837937d08192572678'
|
||||||
'1155ea87e045f7cb90608c278abadf085c51ebf304d075eebf4f83d44fe30dc4'
|
'7b47bf380ba9c9c5defede500514fba6527c8202e64d8f9f622c09de7c5610e8'
|
||||||
'31c5556be4cdd9bf52bb55f18ead0c68a4f0e793c2c2dab0a2a2c6d92407d0d4'
|
'31c5556be4cdd9bf52bb55f18ead0c68a4f0e793c2c2dab0a2a2c6d92407d0d4'
|
||||||
'dbc8a4fc569d4cd7bcd45516ccc98c1396fce0682c262103069c8f5150538cdb')
|
'dbc8a4fc569d4cd7bcd45516ccc98c1396fce0682c262103069c8f5150538cdb')
|
||||||
|
|
||||||
|
|
|
||||||
13
README.md
13
README.md
|
|
@ -299,12 +299,16 @@ Two bindings worth noting: `Ctrl-A Ctrl-H`/`Ctrl-A Ctrl-L` resize the pane
|
||||||
Press `Ctrl-A`, then `Page Up` to scroll back in the active pane. Use
|
Press `Ctrl-A`, then `Page Up` to scroll back in the active pane. Use
|
||||||
`Page Up` and `Page Down` without the prefix to move through history.
|
`Page Up` and `Page Down` without the prefix to move through history.
|
||||||
`Ctrl-A [` opens scrollback at the current screen. Press `q`, Escape,
|
`Ctrl-A [` opens scrollback at the current screen. Press `q`, Escape,
|
||||||
Enter or Ctrl-C to return to live output.
|
Enter or Ctrl-C to return to live output. While browsing, use the usual
|
||||||
|
window shortcuts to switch directly, including `Ctrl-A n`, `Ctrl-A p`,
|
||||||
|
`Ctrl-A 0` through `Ctrl-A 9`, a double prefix, or `Ctrl-A w` for the window
|
||||||
|
chooser. Use `Ctrl-A c` to create a window while browsing. Returning to a
|
||||||
|
window restores its scrollback view and position.
|
||||||
|
|
||||||
Each pane keeps up to 2,000 lines of normal screen history. The view is frozen
|
Each pane keeps up to 2,000 lines of normal screen history. The view is frozen
|
||||||
while browsing; programs keep running and new output continues to be saved.
|
while browsing; programs keep running and new output continues to be saved.
|
||||||
Scrollback is private to each client. Changing the active pane or window closes
|
Scrollback views are private to each client and saved per pane while attached.
|
||||||
it. Alternate-screen programs such as editors do not add history; opening
|
Alternate-screen programs such as editors do not add history; opening
|
||||||
scrollback there shows only their current screen. History is kept in memory,
|
scrollback there shows only their current screen. History is kept in memory,
|
||||||
retains colors, and is clipped or padded to the pane width without reflow.
|
retains colors, and is clipped or padded to the pane width without reflow.
|
||||||
Restart an existing session server after upgrading to enable this feature.
|
Restart an existing session server after upgrading to enable this feature.
|
||||||
|
|
@ -313,7 +317,8 @@ Restart an existing session server after upgrading to enable this feature.
|
||||||
|
|
||||||
Hard-coded:
|
Hard-coded:
|
||||||
|
|
||||||
- Status on top by default (`-s bottom` moves it), default background (overridable with `-c`), foreground `colour12`. The palette mirrors
|
- Status on top by default (`-s bottom` moves it), default background (overridable with `-c`),
|
||||||
|
foreground `colour12`. The palette mirrors
|
||||||
`~/.tmux.conf`.
|
`~/.tmux.conf`.
|
||||||
- With `--cwd`, `[/path/to/directory]` on the left (directory in `colour14`, brackets
|
- With `--cwd`, `[/path/to/directory]` on the left (directory in `colour14`, brackets
|
||||||
`colour12`), refreshed every second and when switching panes. On Linux this
|
`colour12`), refreshed every second and when switching panes. On Linux this
|
||||||
|
|
|
||||||
8
murx.1
8
murx.1
|
|
@ -204,11 +204,15 @@ Ctrl-A Page Up freezes the active pane's history and moves up one page.
|
||||||
Ctrl-A [ opens the view at the current screen.
|
Ctrl-A [ opens the view at the current screen.
|
||||||
Use Page Up and Page Down without a prefix to browse;
|
Use Page Up and Page Down without a prefix to browse;
|
||||||
q, Escape, Enter or Ctrl-C returns to live output.
|
q, Escape, Enter or Ctrl-C returns to live output.
|
||||||
|
The usual window shortcuts work in scrollback, including Ctrl-A n, Ctrl-A p,
|
||||||
|
Ctrl-A 0 through Ctrl-A 9, a double prefix, and Ctrl-A w for the window chooser.
|
||||||
|
Use Ctrl-A c to create a window while browsing.
|
||||||
|
Returning to a window restores its scrollback view and position.
|
||||||
.PP
|
.PP
|
||||||
Each pane retains up to 2,000 normal-screen history lines in memory.
|
Each pane retains up to 2,000 normal-screen history lines in memory.
|
||||||
Programs keep running while the view is frozen.
|
Programs keep running while the view is frozen.
|
||||||
Scrollback is private to each client and closes when its active pane or
|
Scrollback views are private to each client and saved per pane while attached.
|
||||||
window changes. Alternate-screen programs such as editors do not add history;
|
Alternate-screen programs such as editors do not add history;
|
||||||
opening scrollback there shows only their current screen.
|
opening scrollback there shows only their current screen.
|
||||||
Colors are retained; lines are clipped or padded to the pane width without reflow.
|
Colors are retained; lines are clipped or padded to the pane width without reflow.
|
||||||
Text selection and copying are not provided.
|
Text selection and copying are not provided.
|
||||||
|
|
|
||||||
156
murx.c
156
murx.c
|
|
@ -1207,6 +1207,13 @@ typedef struct Window {
|
||||||
typedef struct Client Client;
|
typedef struct Client Client;
|
||||||
typedef struct Session Session;
|
typedef struct Session Session;
|
||||||
|
|
||||||
|
typedef struct Scrollback {
|
||||||
|
Pane *pane;
|
||||||
|
Grid grid;
|
||||||
|
int offset;
|
||||||
|
struct Scrollback *next;
|
||||||
|
} Scrollback;
|
||||||
|
|
||||||
struct Client {
|
struct Client {
|
||||||
int fd;
|
int fd;
|
||||||
int cols, rows;
|
int cols, rows;
|
||||||
|
|
@ -1226,15 +1233,13 @@ struct Client {
|
||||||
int prefix_pending;
|
int prefix_pending;
|
||||||
unsigned char prefix;
|
unsigned char prefix;
|
||||||
|
|
||||||
int mode; /* 0 none, 1 prompt, 2 menu, 3 confirm, 4 scrollback */
|
int mode; /* 0 none, 1 prompt, 2 menu, 3 confirm */
|
||||||
int prompt_kind; /* 1 rename window, 2 choose window */
|
int prompt_kind; /* 1 rename window, 2 choose window */
|
||||||
char prompt[160];
|
char prompt[160];
|
||||||
int prompt_len;
|
int prompt_len;
|
||||||
int prompt_label_len;
|
int prompt_label_len;
|
||||||
|
|
||||||
Grid backscroll; /* private frozen history and screen snapshot */
|
Scrollback *scrollbacks;
|
||||||
Pane *backscroll_pane;
|
|
||||||
int backscroll_offset;
|
|
||||||
|
|
||||||
int menu_sel;
|
int menu_sel;
|
||||||
int confirm_action; /* 1 kill pane, 2 kill server */
|
int confirm_action; /* 1 kill pane, 2 kill server */
|
||||||
|
|
@ -2014,6 +2019,25 @@ static int status_y(Session *s) {
|
||||||
return s->status_bottom ? s->h - 1 : 0;
|
return s->status_bottom ? s->h - 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Scrollback **scrollback_slot(Client *c, Pane *pane) {
|
||||||
|
Scrollback **slot = &c->scrollbacks;
|
||||||
|
while (*slot && (*slot)->pane != pane) slot = &(*slot)->next;
|
||||||
|
return slot;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Scrollback *scrollback_current(Client *c, Session *s) {
|
||||||
|
if (c->mode || !s->cur || !s->cur->active) return NULL;
|
||||||
|
return *scrollback_slot(c, s->cur->active);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void scrollback_remove(Scrollback **slot) {
|
||||||
|
Scrollback *view = *slot;
|
||||||
|
if (!view) return;
|
||||||
|
*slot = view->next;
|
||||||
|
grid_free(&view->grid);
|
||||||
|
free(view);
|
||||||
|
}
|
||||||
|
|
||||||
static void status_draw(Grid *g, Session *s, Client *c) {
|
static void status_draw(Grid *g, Session *s, Client *c) {
|
||||||
if (s->h < 1) return;
|
if (s->h < 1) return;
|
||||||
int y = status_y(s);
|
int y = status_y(s);
|
||||||
|
|
@ -2083,9 +2107,10 @@ static void status_draw(Grid *g, Session *s, Client *c) {
|
||||||
|
|
||||||
char scroll_msg[128];
|
char scroll_msg[128];
|
||||||
const char *overlay = NULL;
|
const char *overlay = NULL;
|
||||||
if (c->mode == 4) {
|
Scrollback *view = scrollback_current(c, s);
|
||||||
|
if (view) {
|
||||||
snprintf(scroll_msg, sizeof scroll_msg, "Scrollback [%d] PgUp/PgDn, q/Esc exits",
|
snprintf(scroll_msg, sizeof scroll_msg, "Scrollback [%d] PgUp/PgDn, q/Esc exits",
|
||||||
c->backscroll_offset);
|
view->offset);
|
||||||
overlay = scroll_msg;
|
overlay = scroll_msg;
|
||||||
}
|
}
|
||||||
if (c->mode == 1 || c->mode == 3) overlay = c->prompt;
|
if (c->mode == 1 || c->mode == 3) overlay = c->prompt;
|
||||||
|
|
@ -2162,10 +2187,6 @@ static void menu_draw(Grid *g, Session *s, Client *c) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void compose(Session *s, Client *c, Grid *out) {
|
static void compose(Session *s, Client *c, Grid *out) {
|
||||||
if (c->mode == 4 && (!s->cur || s->cur->active != c->backscroll_pane)) {
|
|
||||||
c->mode = 0;
|
|
||||||
grid_free(&c->backscroll);
|
|
||||||
}
|
|
||||||
grid_init(out, s->w, s->h);
|
grid_init(out, s->w, s->h);
|
||||||
grid_clear(out, DEFAULT_COLOR);
|
grid_clear(out, DEFAULT_COLOR);
|
||||||
if (s->cur && s->cur->root) {
|
if (s->cur && s->cur->root) {
|
||||||
|
|
@ -2176,12 +2197,13 @@ static void compose(Session *s, Client *c, Grid *out) {
|
||||||
border_render(out, mask);
|
border_render(out, mask);
|
||||||
free(mask);
|
free(mask);
|
||||||
}
|
}
|
||||||
if (c->mode == 4 && s->cur && s->cur->active) {
|
Scrollback *view = scrollback_current(c, s);
|
||||||
|
if (view) {
|
||||||
Pane *p = s->cur->active;
|
Pane *p = s->cur->active;
|
||||||
int top = c->backscroll.h - p->h - c->backscroll_offset;
|
int top = view->grid.h - p->h - view->offset;
|
||||||
for (int y = 0; y < p->h; y++) {
|
for (int y = 0; y < p->h; y++) {
|
||||||
for (int x = 0; x < p->w; x++) {
|
for (int x = 0; x < p->w; x++) {
|
||||||
Cell *src = grid_at(&c->backscroll, x, top + y);
|
Cell *src = grid_at(&view->grid, x, top + y);
|
||||||
Cell *dst = grid_at(out, p->x + x, p->y + y);
|
Cell *dst = grid_at(out, p->x + x, p->y + y);
|
||||||
if (dst) {
|
if (dst) {
|
||||||
*dst = src ? *src : blank_cell();
|
*dst = src ? *src : blank_cell();
|
||||||
|
|
@ -2207,7 +2229,7 @@ static void cursor_for(Session *s, Client *c, int *x, int *y, int *visible) {
|
||||||
*visible = 1;
|
*visible = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (c->mode != 0) return;
|
if (c->mode != 0 || scrollback_current(c, s)) return;
|
||||||
if (!s->cur || !s->cur->active) return;
|
if (!s->cur || !s->cur->active) return;
|
||||||
Pane *p = s->cur->active;
|
Pane *p = s->cur->active;
|
||||||
if (!p->cursor_visible) return;
|
if (!p->cursor_visible) return;
|
||||||
|
|
@ -2429,7 +2451,7 @@ static void draw_frame(Session *s, Client *c, Grid *scr) {
|
||||||
the outer terminal continues sending ESC [ A/B/C/D. Overlays use
|
the outer terminal continues sending ESC [ A/B/C/D. Overlays use
|
||||||
normal cursor keys; switching panes restores that pane's mode. */
|
normal cursor keys; switching panes restores that pane's mode. */
|
||||||
int app_cursor = !c->locked && c->mode == 0 && !c->prefix_pending &&
|
int app_cursor = !c->locked && c->mode == 0 && !c->prefix_pending &&
|
||||||
s->cur && s->cur->active && s->cur->active->app_cursor;
|
!scrollback_current(c, s) && s->cur && s->cur->active && s->cur->active->app_cursor;
|
||||||
buf_puts(&b, app_cursor ? "\x1b[?1h" : "\x1b[?1l");
|
buf_puts(&b, app_cursor ? "\x1b[?1h" : "\x1b[?1l");
|
||||||
buf_puts(&b, "\x1b[0m");
|
buf_puts(&b, "\x1b[0m");
|
||||||
if (vis && (cx >= vw || cy >= vh)) vis = 0;
|
if (vis && (cx >= vw || cy >= vh)) vis = 0;
|
||||||
|
|
@ -2520,13 +2542,19 @@ static void session_recalc_size(Session *s) {
|
||||||
invalidate_clients(s);
|
invalidate_clients(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void window_free(Window *w) {
|
static void session_pane_free(Session *s, Pane *p) {
|
||||||
|
for (Client *c = s->clients; c; c = c->next)
|
||||||
|
scrollback_remove(scrollback_slot(c, p));
|
||||||
|
pane_free(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void window_free(Session *s, Window *w) {
|
||||||
if (!w) return;
|
if (!w) return;
|
||||||
if (w->root) {
|
if (w->root) {
|
||||||
Pane *list[128];
|
Pane *list[128];
|
||||||
int n = 0;
|
int n = 0;
|
||||||
layout_collect(w->root, list, &n);
|
layout_collect(w->root, list, &n);
|
||||||
for (int i = 0; i < n; i++) pane_free(list[i]);
|
for (int i = 0; i < n; i++) session_pane_free(s, list[i]);
|
||||||
layout_free(w->root);
|
layout_free(w->root);
|
||||||
}
|
}
|
||||||
free(w);
|
free(w);
|
||||||
|
|
@ -2646,7 +2674,7 @@ static void kill_active_pane(Session *s) {
|
||||||
s->nwin--;
|
s->nwin--;
|
||||||
if (s->cur == w) s->cur = next ? next : prev;
|
if (s->cur == w) s->cur = next ? next : prev;
|
||||||
if (s->last == w) s->last = NULL;
|
if (s->last == w) s->last = NULL;
|
||||||
window_free(w);
|
window_free(s, w);
|
||||||
if (!s->windows) s->running = 0;
|
if (!s->windows) s->running = 0;
|
||||||
} else {
|
} else {
|
||||||
Layout *par = leaf->parent;
|
Layout *par = leaf->parent;
|
||||||
|
|
@ -2660,7 +2688,7 @@ static void kill_active_pane(Session *s) {
|
||||||
sib->parent = par->parent;
|
sib->parent = par->parent;
|
||||||
free(leaf);
|
free(leaf);
|
||||||
free(par);
|
free(par);
|
||||||
pane_free(p);
|
session_pane_free(s, p);
|
||||||
w->active = layout_first_pane(w->root);
|
w->active = layout_first_pane(w->root);
|
||||||
}
|
}
|
||||||
window_renumber(s->windows);
|
window_renumber(s->windows);
|
||||||
|
|
@ -2684,7 +2712,7 @@ static void kill_active_window(Session *s) {
|
||||||
s->nwin--;
|
s->nwin--;
|
||||||
if (s->cur == w) s->cur = next ? next : prev;
|
if (s->cur == w) s->cur = next ? next : prev;
|
||||||
if (s->last == w) s->last = NULL;
|
if (s->last == w) s->last = NULL;
|
||||||
window_free(w);
|
window_free(s, w);
|
||||||
if (!s->windows) s->running = 0;
|
if (!s->windows) s->running = 0;
|
||||||
window_renumber(s->windows);
|
window_renumber(s->windows);
|
||||||
if (s->cur) {
|
if (s->cur) {
|
||||||
|
|
@ -2954,35 +2982,33 @@ static void backscroll_start(Client *c, Session *s, int page_up) {
|
||||||
Pane *p = s->cur ? s->cur->active : NULL;
|
Pane *p = s->cur ? s->cur->active : NULL;
|
||||||
if (!p) return;
|
if (!p) return;
|
||||||
int count = p->on_alt ? 0 : p->history_count;
|
int count = p->on_alt ? 0 : p->history_count;
|
||||||
grid_free(&c->backscroll);
|
Scrollback **slot = scrollback_slot(c, p);
|
||||||
grid_init(&c->backscroll, p->grid->w, count + p->grid->h);
|
if (!*slot) {
|
||||||
|
*slot = xcalloc(1, sizeof **slot);
|
||||||
|
(*slot)->pane = p;
|
||||||
|
}
|
||||||
|
Scrollback *view = *slot;
|
||||||
|
grid_free(&view->grid);
|
||||||
|
grid_init(&view->grid, p->grid->w, count + p->grid->h);
|
||||||
for (int y = 0; y < count + p->grid->h; y++) {
|
for (int y = 0; y < count + p->grid->h; y++) {
|
||||||
Grid *row = y < count ? &p->history[(p->history_start + y) % HISTORY_LINES] : p->grid;
|
Grid *row = y < count ? &p->history[(p->history_start + y) % HISTORY_LINES] : p->grid;
|
||||||
int sy = y < count ? 0 : y - count;
|
int sy = y < count ? 0 : y - count;
|
||||||
int width = row->w < c->backscroll.w ? row->w : c->backscroll.w;
|
int width = row->w < view->grid.w ? row->w : view->grid.w;
|
||||||
memcpy(&c->backscroll.c[y * c->backscroll.w], &row->c[sy * row->w],
|
memcpy(&view->grid.c[y * view->grid.w], &row->c[sy * row->w],
|
||||||
(size_t)width * sizeof(Cell));
|
(size_t)width * sizeof(Cell));
|
||||||
Cell *last = grid_at(&c->backscroll, c->backscroll.w - 1, y);
|
Cell *last = grid_at(&view->grid, view->grid.w - 1, y);
|
||||||
if (cp_width(last->ch) == 2) *last = blank_cell();
|
if (cp_width(last->ch) == 2) *last = blank_cell();
|
||||||
}
|
}
|
||||||
c->backscroll_pane = p;
|
view->offset = page_up ? p->h : 0;
|
||||||
c->backscroll_offset = page_up ? p->h : 0;
|
if (view->offset > count) view->offset = count;
|
||||||
if (c->backscroll_offset > count) c->backscroll_offset = count;
|
|
||||||
c->mode = 4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return zero for an incomplete page-key sequence. */
|
/* Return zero for an incomplete page-key sequence. */
|
||||||
static size_t backscroll_key(Client *c, Session *s, const unsigned char *buf, size_t n) {
|
static size_t backscroll_key(Client *c, Scrollback *view, const unsigned char *buf, size_t n) {
|
||||||
if (!s->cur || s->cur->active != c->backscroll_pane) {
|
|
||||||
c->mode = 0;
|
|
||||||
grid_free(&c->backscroll);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (buf[0] == 27 && n == 1) return 0;
|
if (buf[0] == 27 && n == 1) return 0;
|
||||||
if (buf[0] == 'q' || buf[0] == 3 || buf[0] == '\r' || buf[0] == '\n' ||
|
if (buf[0] == 'q' || buf[0] == 3 || buf[0] == '\r' || buf[0] == '\n' ||
|
||||||
(buf[0] == 27 && (n == 1 || buf[1] != '['))) {
|
(buf[0] == 27 && (n == 1 || buf[1] != '['))) {
|
||||||
c->mode = 0;
|
scrollback_remove(scrollback_slot(c, view->pane));
|
||||||
grid_free(&c->backscroll);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (buf[0] == 27 && n >= 2 && buf[1] == '[') {
|
if (buf[0] == 27 && n >= 2 && buf[1] == '[') {
|
||||||
|
|
@ -2991,12 +3017,12 @@ static size_t backscroll_key(Client *c, Session *s, const unsigned char *buf, si
|
||||||
if (used == n) return 0;
|
if (used == n) return 0;
|
||||||
used++;
|
used++;
|
||||||
if (used == 4 && buf[3] == '~' && (buf[2] == '5' || buf[2] == '6')) {
|
if (used == 4 && buf[3] == '~' && (buf[2] == '5' || buf[2] == '6')) {
|
||||||
int height = s->cur->active->h;
|
int height = view->pane->h;
|
||||||
int max = c->backscroll.h - height;
|
int max = view->grid.h - height;
|
||||||
if (max < 0) max = 0;
|
if (max < 0) max = 0;
|
||||||
c->backscroll_offset += buf[2] == '5' ? height : -height;
|
view->offset += buf[2] == '5' ? height : -height;
|
||||||
if (c->backscroll_offset < 0) c->backscroll_offset = 0;
|
if (view->offset < 0) view->offset = 0;
|
||||||
if (c->backscroll_offset > max) c->backscroll_offset = max;
|
if (view->offset > max) view->offset = max;
|
||||||
}
|
}
|
||||||
return used;
|
return used;
|
||||||
}
|
}
|
||||||
|
|
@ -3004,6 +3030,17 @@ static size_t backscroll_key(Client *c, Session *s, const unsigned char *buf, si
|
||||||
}
|
}
|
||||||
|
|
||||||
static void prefix_command(Client *c, Session *s, int key) {
|
static void prefix_command(Client *c, Session *s, int key) {
|
||||||
|
if (scrollback_current(c, s) && !(key >= '0' && key <= '9')) {
|
||||||
|
switch (key) {
|
||||||
|
case 0x03: case 'c':
|
||||||
|
case 0x0e: case ' ': case 'n':
|
||||||
|
case 0x10: case 'p': case 0x7f:
|
||||||
|
case 0x17: case 'w': case '"':
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case '[':
|
case '[':
|
||||||
case K_PGUP:
|
case K_PGUP:
|
||||||
|
|
@ -3278,10 +3315,8 @@ static void client_feed(Client *c, Session *s, const unsigned char *buf, size_t
|
||||||
if (n > sizeof c->in - c->inlen) n = sizeof c->in - c->inlen;
|
if (n > sizeof c->in - c->inlen) n = sizeof c->in - c->inlen;
|
||||||
if (n == 0 && c->inlen == 1 && c->in[0] == 27 && c->escape_since &&
|
if (n == 0 && c->inlen == 1 && c->in[0] == 27 && c->escape_since &&
|
||||||
now_ms() - c->escape_since >= 100) {
|
now_ms() - c->escape_since >= 100) {
|
||||||
if (c->mode == 4) {
|
Scrollback *view = scrollback_current(c, s);
|
||||||
c->mode = 0;
|
if (view) scrollback_remove(scrollback_slot(c, view->pane));
|
||||||
grid_free(&c->backscroll);
|
|
||||||
}
|
|
||||||
c->prefix_pending = 0;
|
c->prefix_pending = 0;
|
||||||
c->inlen = 0;
|
c->inlen = 0;
|
||||||
c->escape_since = 0;
|
c->escape_since = 0;
|
||||||
|
|
@ -3301,8 +3336,20 @@ static void client_feed(Client *c, Session *s, const unsigned char *buf, size_t
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (c->dead) break;
|
if (c->dead) break;
|
||||||
if (c->mode == 4) {
|
Scrollback *view = scrollback_current(c, s);
|
||||||
size_t used = backscroll_key(c, s, p, left);
|
if (view) {
|
||||||
|
if (c->prefix_pending) {
|
||||||
|
int used = handle_prefix_key(c, s, p, left);
|
||||||
|
if (used == 0) break;
|
||||||
|
i += (size_t)used;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (p[0] == c->prefix) {
|
||||||
|
c->prefix_pending = 1;
|
||||||
|
i++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
size_t used = backscroll_key(c, view, p, left);
|
||||||
if (used == 0) break;
|
if (used == 0) break;
|
||||||
i += used;
|
i += used;
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -3346,7 +3393,7 @@ static void client_feed(Client *c, Session *s, const unsigned char *buf, size_t
|
||||||
memmove(c->in, c->in + i, c->inlen - i);
|
memmove(c->in, c->in + i, c->inlen - i);
|
||||||
c->inlen -= i;
|
c->inlen -= i;
|
||||||
}
|
}
|
||||||
if (c->inlen == 1 && c->in[0] == 27 && (c->mode == 4 || c->prefix_pending)) {
|
if (c->inlen == 1 && c->in[0] == 27 && (scrollback_current(c, s) || c->prefix_pending)) {
|
||||||
if (!c->escape_since) c->escape_since = now_ms();
|
if (!c->escape_since) c->escape_since = now_ms();
|
||||||
} else c->escape_since = 0;
|
} else c->escape_since = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -3390,7 +3437,7 @@ static void unlink_window(Session *s, Window *w) {
|
||||||
s->nwin--;
|
s->nwin--;
|
||||||
if (s->cur == w) s->cur = next ? next : prev;
|
if (s->cur == w) s->cur = next ? next : prev;
|
||||||
if (s->last == w) s->last = NULL;
|
if (s->last == w) s->last = NULL;
|
||||||
window_free(w);
|
window_free(s, w);
|
||||||
window_renumber(s->windows);
|
window_renumber(s->windows);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3412,7 +3459,7 @@ static void remove_pane_ptr(Session *s, Pane *p) {
|
||||||
sib->parent = par->parent;
|
sib->parent = par->parent;
|
||||||
free(leaf);
|
free(leaf);
|
||||||
free(par);
|
free(par);
|
||||||
pane_free(p);
|
session_pane_free(s, p);
|
||||||
w->active = layout_first_pane(w->root);
|
w->active = layout_first_pane(w->root);
|
||||||
window_renumber(s->windows);
|
window_renumber(s->windows);
|
||||||
}
|
}
|
||||||
|
|
@ -3433,7 +3480,7 @@ static void client_remove(Session *s, Client *c) {
|
||||||
else s->clients = c->next;
|
else s->clients = c->next;
|
||||||
if (c->fd >= 0) close(c->fd);
|
if (c->fd >= 0) close(c->fd);
|
||||||
if (c->prev_valid) grid_free(&c->prev);
|
if (c->prev_valid) grid_free(&c->prev);
|
||||||
grid_free(&c->backscroll);
|
while (c->scrollbacks) scrollback_remove(&c->scrollbacks);
|
||||||
free(c);
|
free(c);
|
||||||
session_recalc_size(s);
|
session_recalc_size(s);
|
||||||
invalidate_clients(s);
|
invalidate_clients(s);
|
||||||
|
|
@ -3720,7 +3767,7 @@ static void server_cleanup(Session *s) {
|
||||||
Client *next = c->next;
|
Client *next = c->next;
|
||||||
if (c->fd >= 0) close(c->fd);
|
if (c->fd >= 0) close(c->fd);
|
||||||
if (c->prev_valid) grid_free(&c->prev);
|
if (c->prev_valid) grid_free(&c->prev);
|
||||||
grid_free(&c->backscroll);
|
while (c->scrollbacks) scrollback_remove(&c->scrollbacks);
|
||||||
free(c);
|
free(c);
|
||||||
c = next;
|
c = next;
|
||||||
}
|
}
|
||||||
|
|
@ -3728,7 +3775,7 @@ static void server_cleanup(Session *s) {
|
||||||
Window *w = s->windows;
|
Window *w = s->windows;
|
||||||
while (w) {
|
while (w) {
|
||||||
Window *next = w->next;
|
Window *next = w->next;
|
||||||
window_free(w);
|
window_free(s, w);
|
||||||
w = next;
|
w = next;
|
||||||
}
|
}
|
||||||
s->windows = NULL;
|
s->windows = NULL;
|
||||||
|
|
@ -4347,6 +4394,7 @@ static void print_help(FILE *out) {
|
||||||
" Ctrl-A Ctrl-L resize pane right\n"
|
" Ctrl-A Ctrl-L resize pane right\n"
|
||||||
" Ctrl-A K kill pane (confirm)\n"
|
" Ctrl-A K kill pane (confirm)\n"
|
||||||
" Ctrl-A PageUp, [ scrollback (PgUp/PgDn; q/Escape exits)\n"
|
" Ctrl-A PageUp, [ scrollback (PgUp/PgDn; q/Escape exits)\n"
|
||||||
|
" window creation and switching shortcuts work in scrollback\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Client and server\n"
|
"Client and server\n"
|
||||||
" Ctrl-A a send a literal Ctrl-A to the pane\n"
|
" Ctrl-A a send a literal Ctrl-A to the pane\n"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue