Added background color support to status line.
This commit is contained in:
parent
c7e43d85f1
commit
69241a09d2
5 changed files with 48 additions and 13 deletions
6
APKBUILD
6
APKBUILD
|
|
@ -26,10 +26,10 @@ package() {
|
||||||
}
|
}
|
||||||
|
|
||||||
sha512sums="
|
sha512sums="
|
||||||
8eefff81f546d9893d2878b6208fceaf36d6c66ec6a9b1627545f81802f82cfbf9edef7fb3310aa516a682eb775c68afaabd294f3d5ca8463a7b0329801ac87c murx.c
|
cca1f9816de1cdaa97c2543d74ec52fec4813c9068d756f8f940c82b58c7b3afd631a20991c981b3bc75a968d1d3d9ed36182150e32a6a7718863045643c4264 murx.c
|
||||||
ca73b902d64fc9dc52d8d14b6c8ca6b494f4bea3f3602c29fd2909252668e110edff075c881e014e689d7c7d990dee2a4a96208276bae50243ca382adc5ead80 Makefile
|
ca73b902d64fc9dc52d8d14b6c8ca6b494f4bea3f3602c29fd2909252668e110edff075c881e014e689d7c7d990dee2a4a96208276bae50243ca382adc5ead80 Makefile
|
||||||
ea99904e2e3b02c1a2f3bd8e1f2faef9aeb3cd8bc97c2ab14ce2d66de7d16a804bbf9610ade09385fd2a660493372cf335faae2cc30ccec8b62d019ad95ae457 murx.1
|
7e2535df251ac8d4a64dc8ad379337798f10afb4d0ab1642e5d010128344b626d03f08363c280cdfdb512d666a62a96fad8f4f6a2be53ae2b9bd5c13bdf0491c murx.1
|
||||||
b30835225a564919f4a6043f0348e4d16886179bb523715c4b7cd5b75fb2490cc649aeffa4cac19d3db90409dd5ca222b31f704f1c5f116bf86b21b3a95f54d6 README.md
|
9a3bb80832e106746bd55bb1f0ffa2ee4ce7e7b141b734971756742fa28d34e310cd41867a661aef01b6b1e43903749422f135aeb97e70bc3e884d7dfe2fb0e9 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=('e88e3f143f861cc09bb3dec1fa9658d07ec1f88d74821d332452449aa747e36c'
|
sha256sums=('6e6b2ce665984239d753cd5683ae9469009763420ced4a0048f18788df350dd6'
|
||||||
'c683ed74c664ebb2a72603297367ed102afdf27e4d6cee47920db8632a8efa91'
|
'c683ed74c664ebb2a72603297367ed102afdf27e4d6cee47920db8632a8efa91'
|
||||||
'd7d36ecc3e8ab59cebfdcca317231e5eaae136d3097e7fe2ef8c2540886bf21a'
|
'0a2be096fb83ff1a17d0194547a40a84337c0c5c43da5f0940d1aecd76f742bf'
|
||||||
'968fd3fa3bbd1af2867d535f6c817cb043f499c145954777a4b15fddc854643f'
|
'476af085c9d2d54d047757b45e2e1bcf39798df500a4c98eac3d9cea727fb50f'
|
||||||
'31c5556be4cdd9bf52bb55f18ead0c68a4f0e793c2c2dab0a2a2c6d92407d0d4'
|
'31c5556be4cdd9bf52bb55f18ead0c68a4f0e793c2c2dab0a2a2c6d92407d0d4'
|
||||||
'dbc8a4fc569d4cd7bcd45516ccc98c1396fce0682c262103069c8f5150538cdb')
|
'dbc8a4fc569d4cd7bcd45516ccc98c1396fce0682c262103069c8f5150538cdb')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ make
|
||||||
./murx --status bottom work # same as -s bottom
|
./murx --status bottom work # same as -s bottom
|
||||||
./murx --cwd work # show the current directory in the status bar
|
./murx --cwd work # show the current directory in the status bar
|
||||||
./murx --murx work # show [murx] on the left of the status bar
|
./murx --murx work # show [murx] on the left of the status bar
|
||||||
|
./murx -c 191a1c work # use a grey status bar background
|
||||||
./murx --clock work # show the status bar clock
|
./murx --clock work # show the status bar clock
|
||||||
./murx --hostname work # show the hostname: prefix in window titles
|
./murx --hostname work # show the hostname: prefix in window titles
|
||||||
./murx -l, --list-sessions # list running sessions without attaching
|
./murx -l, --list-sessions # list running sessions without attaching
|
||||||
|
|
@ -312,7 +313,7 @@ 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, 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
|
||||||
|
|
@ -336,6 +337,10 @@ Hard-coded:
|
||||||
borders; panes have no title row, leaving more space for terminal content.
|
borders; panes have no title row, leaving more space for terminal content.
|
||||||
- Messages use `fg=colour6,bg=colour8`.
|
- Messages use `fg=colour6,bg=colour8`.
|
||||||
|
|
||||||
|
Use `-c RRGGBB` or `--color RRGGBB` to set this client's status bar
|
||||||
|
background. Supply six hexadecimal digits, such as `000000` for black. Repeat
|
||||||
|
the option when reattaching. Omitting it uses the terminal's default background.
|
||||||
|
|
||||||
Colours are written to the outer terminal in 256-colour form (`38;5;n` /
|
Colours are written to the outer terminal in 256-colour form (`38;5;n` /
|
||||||
`48;5;n`). Truecolor from a pane is mapped to the nearest xterm-256 entry,
|
`48;5;n`). Truecolor from a pane is mapped to the nearest xterm-256 entry,
|
||||||
unless the outer terminal advertises `COLORTERM=truecolor` and is not
|
unless the outer terminal advertises `COLORTERM=truecolor` and is not
|
||||||
|
|
|
||||||
7
murx.1
7
murx.1
|
|
@ -5,6 +5,7 @@ murx \- small persistent terminal multiplexer
|
||||||
.B murx
|
.B murx
|
||||||
.RB [ \-p " letter"]
|
.RB [ \-p " letter"]
|
||||||
.RB [ \-s " top|bottom"]
|
.RB [ \-s " top|bottom"]
|
||||||
|
.RB [ \-c " RRGGBB"]
|
||||||
.RB [ \-\-cwd ]
|
.RB [ \-\-cwd ]
|
||||||
.RB [ \-\-clock ]
|
.RB [ \-\-clock ]
|
||||||
.RB [ \-\-murx ]
|
.RB [ \-\-murx ]
|
||||||
|
|
@ -57,6 +58,12 @@ New sessions default to top. An explicit choice changes an existing session
|
||||||
for all clients. Omitting this option preserves the session's position.
|
for all clients. Omitting this option preserves the session's position.
|
||||||
Prompts and messages follow the status line.
|
Prompts and messages follow the status line.
|
||||||
.TP
|
.TP
|
||||||
|
.BR \-c " RRGGBB, " \-\-color " RRGGBB"
|
||||||
|
Set this client's status bar background.
|
||||||
|
Supply six hexadecimal digits, such as 000000 for black.
|
||||||
|
Repeat this option when reattaching. Omitting it uses the terminal's default
|
||||||
|
background.
|
||||||
|
.TP
|
||||||
.B \-\-cwd
|
.B \-\-cwd
|
||||||
Show the current directory at the left of the status line.
|
Show the current directory at the left of the status line.
|
||||||
.TP
|
.TP
|
||||||
|
|
|
||||||
35
murx.c
35
murx.c
|
|
@ -30,7 +30,7 @@
|
||||||
/*
|
/*
|
||||||
* murx - a very small terminal multiplexer
|
* murx - a very small terminal multiplexer
|
||||||
*
|
*
|
||||||
* One binary, no config file. Shortcuts and colours are hard-coded.
|
* One binary, no config file. Shortcuts and the interface palette have built-in defaults.
|
||||||
*
|
*
|
||||||
* murx [session] attach to session (default "0"), or start it
|
* murx [session] attach to session (default "0"), or start it
|
||||||
* murx -h|--help show usage and all Ctrl-A shortcut chains
|
* murx -h|--help show usage and all Ctrl-A shortcut chains
|
||||||
|
|
@ -1213,6 +1213,7 @@ struct Client {
|
||||||
int attached;
|
int attached;
|
||||||
uint64_t order; /* attach/resize sequence, newest client wins */
|
uint64_t order; /* attach/resize sequence, newest client wins */
|
||||||
int truecolor;
|
int truecolor;
|
||||||
|
int32_t status_bg;
|
||||||
unsigned char in[16384];
|
unsigned char in[16384];
|
||||||
size_t inlen;
|
size_t inlen;
|
||||||
long long escape_since;
|
long long escape_since;
|
||||||
|
|
@ -2112,6 +2113,13 @@ static void status_draw(Grid *g, Session *s, Client *c) {
|
||||||
/* keep the clock visible even if a message or window list is long */
|
/* keep the clock visible even if a message or window list is long */
|
||||||
status_right_draw(g, rx, y, clockbuf);
|
status_right_draw(g, rx, y, clockbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (c->status_bg != DEFAULT_COLOR) {
|
||||||
|
for (int x = 0; x < s->w; x++) {
|
||||||
|
Cell *cell = grid_at(g, x, y);
|
||||||
|
if (cell->bg == DEFAULT_COLOR) cell->bg = c->status_bg;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void menu_draw(Grid *g, Session *s, Client *c) {
|
static void menu_draw(Grid *g, Session *s, Client *c) {
|
||||||
|
|
@ -3453,6 +3461,10 @@ static void handle_message(Client *c, Session *s, uint32_t type, const unsigned
|
||||||
uint32_t status = 0;
|
uint32_t status = 0;
|
||||||
if (len >= 20) memcpy(&status, data + 16, 4);
|
if (len >= 20) memcpy(&status, data + 16, 4);
|
||||||
if (status > 2) { c->dead = 1; return; }
|
if (status > 2) { c->dead = 1; return; }
|
||||||
|
uint32_t color = 0;
|
||||||
|
if (len >= 24) memcpy(&color, data + 20, 4);
|
||||||
|
if (color && (color >> 24) != 1) { c->dead = 1; return; }
|
||||||
|
c->status_bg = color ? (int32_t)color : DEFAULT_COLOR;
|
||||||
if (status) {
|
if (status) {
|
||||||
s->status_bottom = status == 2;
|
s->status_bottom = status == 2;
|
||||||
session_layout(s);
|
session_layout(s);
|
||||||
|
|
@ -4106,7 +4118,7 @@ static int terminal_truecolor(void) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int run_client(int fd, const char *name, unsigned char prefix, int status) {
|
static int run_client(int fd, const char *name, unsigned char prefix, int status, uint32_t color) {
|
||||||
struct termios saved;
|
struct termios saved;
|
||||||
if (tty_raw(&saved) < 0) {
|
if (tty_raw(&saved) < 0) {
|
||||||
fprintf(stderr, "murx: not a terminal\n");
|
fprintf(stderr, "murx: not a terminal\n");
|
||||||
|
|
@ -4141,8 +4153,8 @@ static int run_client(int fd, const char *name, unsigned char prefix, int status
|
||||||
|
|
||||||
int cols, rows;
|
int cols, rows;
|
||||||
tty_size(&cols, &rows);
|
tty_size(&cols, &rows);
|
||||||
uint32_t attach[5] = { (uint32_t)cols, (uint32_t)rows,
|
uint32_t attach[6] = { (uint32_t)cols, (uint32_t)rows,
|
||||||
(uint32_t)terminal_truecolor(), prefix, (uint32_t)status };
|
(uint32_t)terminal_truecolor(), prefix, (uint32_t)status, color };
|
||||||
if (send_msg(fd, C_ATTACH, attach, sizeof attach) < 0) {
|
if (send_msg(fd, C_ATTACH, attach, sizeof attach) < 0) {
|
||||||
/* errno is the only clue: the server accepted the connection but the
|
/* errno is the only clue: the server accepted the connection but the
|
||||||
attach write failed, usually because it closed the socket while
|
attach write failed, usually because it closed the socket while
|
||||||
|
|
@ -4272,7 +4284,7 @@ static int run_client(int fd, const char *name, unsigned char prefix, int status
|
||||||
|
|
||||||
static void print_help(FILE *out) {
|
static void print_help(FILE *out) {
|
||||||
fprintf(out,
|
fprintf(out,
|
||||||
"usage: murx [-p letter] [-s top|bottom] [--cwd] [--clock] [--murx] [--hostname] [session]\n"
|
"usage: murx [-p letter] [-s top|bottom] [-c RRGGBB] [--cwd] [--clock] [--murx] [--hostname] [session]\n"
|
||||||
" murx -l | --list-sessions\n"
|
" murx -l | --list-sessions\n"
|
||||||
" murx -h | --help\n"
|
" murx -h | --help\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
|
@ -4284,6 +4296,9 @@ static void print_help(FILE *out) {
|
||||||
"Use -s top|bottom (or --status top|bottom) to position the status line.\n"
|
"Use -s top|bottom (or --status top|bottom) to position the status line.\n"
|
||||||
"New sessions default to top; an explicit choice updates all attached clients.\n"
|
"New sessions default to top; an explicit choice updates all attached clients.\n"
|
||||||
"Without -s, keep the session position.\n"
|
"Without -s, keep the session position.\n"
|
||||||
|
"Use -c RRGGBB (or --color RRGGBB) to set this client's status bar background.\n"
|
||||||
|
"Specify six hexadecimal digits, such as 000000 for black.\n"
|
||||||
|
"Without -c, use the terminal's default background.\n"
|
||||||
"Use --cwd to show the current directory in the status bar.\n"
|
"Use --cwd to show the current directory in the status bar.\n"
|
||||||
"Use --clock to show the clock in the status bar.\n"
|
"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"
|
"Use --murx to show [murx] in the status bar when --cwd is not enabled.\n"
|
||||||
|
|
@ -4363,6 +4378,7 @@ int main(int argc, char **argv) {
|
||||||
int argi = 1;
|
int argi = 1;
|
||||||
unsigned char prefix = DEFAULT_PREFIX;
|
unsigned char prefix = DEFAULT_PREFIX;
|
||||||
int status = 0;
|
int status = 0;
|
||||||
|
uint32_t color = 0;
|
||||||
DisplayOptions display = {0, 0, 0, 0};
|
DisplayOptions display = {0, 0, 0, 0};
|
||||||
int list = 0;
|
int list = 0;
|
||||||
while (argi < argc && argv[argi][0] == '-' && argv[argi][1]) {
|
while (argi < argc && argv[argi][0] == '-' && argv[argi][1]) {
|
||||||
|
|
@ -4388,6 +4404,13 @@ int main(int argc, char **argv) {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
argi++;
|
argi++;
|
||||||
|
} else if (strcmp(option, "-c") == 0 || strcmp(option, "--color") == 0) {
|
||||||
|
if (argi >= argc || strlen(argv[argi]) != 6 ||
|
||||||
|
strspn(argv[argi], "0123456789abcdefABCDEF") != 6) {
|
||||||
|
fprintf(stderr, "murx: %s requires six hexadecimal digits (RRGGBB)\n", option);
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
color = RGB_FLAG | (uint32_t)strtoul(argv[argi++], NULL, 16);
|
||||||
} else if (strcmp(option, "-s") == 0 || strcmp(option, "--status") == 0) {
|
} else if (strcmp(option, "-s") == 0 || strcmp(option, "--status") == 0) {
|
||||||
if (argi >= argc || (strcmp(argv[argi], "top") != 0 &&
|
if (argi >= argc || (strcmp(argv[argi], "top") != 0 &&
|
||||||
strcmp(argv[argi], "bottom") != 0)) {
|
strcmp(argv[argi], "bottom") != 0)) {
|
||||||
|
|
@ -4433,5 +4456,5 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return run_client(fd, name, prefix, status);
|
return run_client(fd, name, prefix, status, color);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue