diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2020-02-17 16:02:53 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2020-02-17 16:02:53 -0800 |
| commit | f9fc99d28e23a5930ca916cbe7abe13c718c6f58 (patch) | |
| tree | 8a2211ecaeacf5ccfc17df807f9ed9e5cd54725d /bb.c | |
| parent | 2d9eac4237b23280fa9f10639bb74367f33729c6 (diff) | |
Added xwindow title setting, and $HOME -> ~ in the bb path area.
Diffstat (limited to 'bb.c')
| -rw-r--r-- | bb.c | 24 |
1 files changed, 23 insertions, 1 deletions
@@ -239,6 +239,7 @@ void handle_next_key_binding(bb_t *bb) restore_term(&default_termios); run_script(bb, binding->script); init_term(); + set_title(bb); check_cmdfile(bb); } if (mouse_x != -1 && mouse_y != -1) { @@ -430,6 +431,7 @@ int populate_files(bb_t *bb, const char *path) dirty = 1; strcpy(bb->path, pbuf); + set_title(bb); // Clear old files (if any) if (bb->files) { @@ -637,6 +639,7 @@ void run_bbcmd(bb_t *bb, const char *cmd) wait_for_process(&child); signal(SIGTTOU, SIG_DFL); init_term(); + set_title(bb); dirty = 1; } else if (matches_cmd(cmd, "goto:")) { // +goto: entry_t *e = load_entry(bb, value); @@ -752,7 +755,14 @@ void render(bb_t *bb) move_cursor(tty_out, 0, 0); const char *color = TITLE_COLOR; fputs(color, tty_out); - fputs_escaped(tty_out, bb->path, color); + + char *home = getenv("HOME"); + if (home && strncmp(bb->path, home, strlen(home)) == 0) { + fputs("~", tty_out); + fputs_escaped(tty_out, bb->path + strlen(home), color); + } else { + fputs_escaped(tty_out, bb->path, color); + } fputs(" \033[K\033[0m", tty_out); static const char *help = "Press '?' to see key bindings "; @@ -1099,6 +1109,18 @@ void set_sort(bb_t *bb, const char *sort) } /* + * Set the xwindow title property to: bb - current path + */ +void set_title(bb_t *bb) +{ + char *home = getenv("HOME"); + if (home && strncmp(bb->path, home, strlen(home)) == 0) + fprintf(tty_out, "\033]2;bb: ~%s\007", bb->path + strlen(home)); + else + fprintf(tty_out, "\033]2;bb: %s\007", bb->path); +} + +/* * If the given entry is not viewed or selected, remove it from the * hash, free it, and return 1. */ |
