diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2019-07-21 15:35:53 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2019-07-21 15:35:53 +0000 |
| commit | 97350f6488c9e431d4b93a173734c9a3735769d5 (patch) | |
| tree | 51dc5ee04d4e0b94d645078a10a975f8fab84799 | |
| parent | csi: remove TODO; we have our own terminfo (diff) | |
term: track current window title in terminal struct
| -rw-r--r-- | main.c | 3 | ||||
| -rw-r--r-- | osc.c | 6 | ||||
| -rw-r--r-- | terminal.c | 9 | ||||
| -rw-r--r-- | terminal.h | 3 |
4 files changed, 17 insertions, 4 deletions
@@ -589,7 +589,7 @@ main(int argc, char *const *argv) xdg_toplevel_add_listener(term.wl.xdg_toplevel, &xdg_toplevel_listener, &term); xdg_toplevel_set_app_id(term.wl.xdg_toplevel, "foot"); - render_set_title(&term, "foot"); + term_set_window_title(&term, "foot"); wl_surface_commit(term.wl.surface); wl_display_roundtrip(term.wl.display); @@ -848,6 +848,7 @@ out: for (int row = 0; row < term.alt.num_rows; row++) grid_row_free(term.alt.rows[row]); free(term.alt.rows); + free(term.window_title); for (size_t i = 0; i < sizeof(term.fonts) / sizeof(term.fonts[0]); i++) { struct font *f = &term.fonts[i]; @@ -234,9 +234,9 @@ osc_dispatch(struct terminal *term) } switch (param) { - case 0: render_set_title(term, string); break; /* icon + title */ - case 1: break; /* icon */ - case 2: render_set_title(term, string); break; /* title */ + case 0: term_set_window_title(term, string); break; /* icon + title */ + case 1: break; /* icon */ + case 2: term_set_window_title(term, string); break; /* title */ case 52: osc_selection(term, string); break; case 104: /* Reset Color Number 'c' */ @@ -10,6 +10,7 @@ #define LOG_ENABLE_DBG 0 #include "log.h" #include "grid.h" +#include "render.h" #include "vt.h" #define min(x, y) ((x) < (y) ? (x) : (y)) @@ -460,3 +461,11 @@ term_mouse_motion(struct terminal *term, int button, int row, int col, break; } } + +void +term_set_window_title(struct terminal *term, const char *title) +{ + free(term->window_title); + term->window_title = strdup(title); + render_set_title(term, term->window_title); +} @@ -245,6 +245,7 @@ struct terminal { int selected_charset; enum charset charset[4]; /* G0-G3 */ + char *window_title; struct vt vt; struct kbd kbd; @@ -341,3 +342,5 @@ void term_mouse_up(struct terminal *term, int button, int row, int col, bool shift, bool alt, bool ctrl); void term_mouse_motion(struct terminal *term, int button, int row, int col, bool shift, bool alt, bool ctrl); + +void term_set_window_title(struct terminal *term, const char *title); |
