diff options
author | cflip <cflip@cflip.net> | 2023-01-19 10:10:23 -0700 |
---|---|---|
committer | cflip <cflip@cflip.net> | 2023-01-19 13:08:18 -0700 |
commit | fe37b30e4a7321776621c91cacd3b58fb4247044 (patch) | |
tree | b90f04c91f08dd4250be914d25d0479c0ce05b8f /window.c | |
parent | b9ee44b8499d8e88d0566681a5218c8656ca6f58 (diff) |
Show filename and current working directory in window title
Diffstat (limited to 'window.c')
-rw-r--r-- | window.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -1,5 +1,6 @@ #include "window.h" +#include <unistd.h> #include <SDL2/SDL.h> #include "buffer.h" @@ -177,6 +178,20 @@ void window_redraw(struct editor_state *editor) SDL_UpdateWindowSurface(window); } +void window_set_filename(const char *filename) +{ +#define TITLE_BUFSIZE 128 +#define WORKDIR_BUFSIZE 128 + + char titlebuf[TITLE_BUFSIZE]; + char cwdbuf[WORKDIR_BUFSIZE]; + char *workdir; + workdir = getcwd(cwdbuf, WORKDIR_BUFSIZE); + + snprintf(titlebuf, TITLE_BUFSIZE, "%s - (%s)", filename, workdir); + SDL_SetWindowTitle(window, titlebuf); +} + void window_get_size(int *rows, int *cols) { *cols = window_width / font.width; |