summaryrefslogtreecommitdiff
path: root/window.c
diff options
context:
space:
mode:
Diffstat (limited to 'window.c')
-rw-r--r--window.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/window.c b/window.c
index 031caef..bbd7d2f 100644
--- a/window.c
+++ b/window.c
@@ -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;