On Sat, Jan 11, 2014 at 11:15 PM, Marc André Tanner <m...@brain-dump.org> wrote: > Thanks applied with NOMOD instead of ERR here.
Thanks, I meant to do that. :) > If I recall correctly you mentioned that you have a patch which makes > the window title configurable: top / bottom / disable. Would you mind > posting it? Someone just asked whether something like this is possible. Sure, but it's horribly ugly without fixing all the layouts to draw the line drawing intersection characters (e.g. ACS_LTEE) at the correct places. I had an idea to move the responsibility for drawing these from the layouts to dvtm.c, but it would involve quite a bit more work. I've included it below, merged with the recent show_border() patch -- very nice, by the way! -Mark
From ab69a39e38e70f1109c71eee8b4907a23e775908 Mon Sep 17 00:00:00 2001 From: Mark Edgar <medgar...@gmail.com> Date: Wed, 5 Feb 2014 22:57:29 +0100 Subject: [PATCH] TITLE_POS is one of TITLE_TOP TITLE_BOTTOM TITLE_OFF --- config.def.h | 2 ++ dvtm.c | 23 +++++++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/config.def.h b/config.def.h index 8584b5e..b3ac31b 100644 --- a/config.def.h +++ b/config.def.h @@ -27,6 +27,8 @@ * is replaced by the title, second %s is replaced by * the SEPARATOR, %d stands for the window number */ #define TITLE "[%s%s#%d]" +/* where to draw the title */ +#define TITLE_POS TITLE_TOP /* TITLE_BOTTOM, TITLE_OFF */ /* master width factor [0.1 .. 0.9] */ #define MFACT 0.5 /* scroll back buffer size in lines */ diff --git a/dvtm.c b/dvtm.c index 359a152..0639853 100644 --- a/dvtm.c +++ b/dvtm.c @@ -116,6 +116,7 @@ typedef struct { enum { BAR_TOP, BAR_BOTTOM, BAR_OFF }; enum { ALIGN_LEFT, ALIGN_RIGHT }; +enum { TITLE_OFF, TITLE_TOP, TITLE_BOTTOM }; typedef struct { int fd; @@ -193,6 +194,7 @@ static Client *msel = NULL; static bool mouse_events_enabled = ENABLE_MOUSE; static Layout *layout = layouts; static StatusBar bar = { -1, BAR_POS, 1 }; +static int title_pos = TITLE_POS; static CmdFifo cmdfifo = { -1 }; static const char *shell; static char *copybuf; @@ -260,7 +262,10 @@ drawbar() { static int show_border() { - return (bar.fd != -1 && bar.pos != BAR_OFF) || (clients && clients->next); + if (title_pos == TITLE_OFF) + return 0; + else + return (bar.fd != -1 && bar.pos != BAR_OFF) || (clients && clients->next); } static void @@ -269,10 +274,13 @@ draw_border(Client *c) { return; char t = '\0'; int x, y, maxlen; + int title_y = title_pos == TITLE_TOP ? 0 : c->h - 1; + if (title_pos == TITLE_OFF) + return; wattrset(c->window, (sel == c || (runinall && !c->minimized)) ? SELECTED_ATTR : NORMAL_ATTR); getyx(c->window, y, x); - mvwhline(c->window, 0, 0, ACS_HLINE, c->w); + mvwhline(c->window, title_y, 0, ACS_HLINE, c->w); maxlen = c->w - (2 + sstrlen(TITLE) - sstrlen("%s%sd") + sstrlen(SEPARATOR) + 2); if (maxlen < 0) maxlen = 0; @@ -281,7 +289,7 @@ draw_border(Client *c) { c->title[maxlen] = '\0'; } - mvwprintw(c->window, 0, 2, TITLE, + mvwprintw(c->window, title_y, 2, TITLE, *c->title ? c->title : "", *c->title ? SEPARATOR : "", c->order); @@ -292,7 +300,8 @@ draw_border(Client *c) { static void draw_content(Client *c) { - vt_draw(c->term, c->window, show_border(), 0); + int vt_y = 0 + (title_pos == TITLE_TOP && show_border()); + vt_draw(c->term, c->window, vt_y, 0); } static void @@ -472,7 +481,8 @@ resize_client(Client *c, int w, int h) { c->w = w; c->h = h; } - vt_resize(c->term, h - show_border(), w); + int vt_h = h - show_border(); + vt_resize(c->term, vt_h, w); } static void @@ -737,7 +747,8 @@ create(const char *args[]) { return; } - if (!(c->term = vt_create(screen.h - show_border(), screen.w, screen.history))) { + int vt_h = screen.h - show_border(); + if (!(c->term = vt_create(vt_h, screen.w, screen.history))) { delwin(c->window); free(c); return; -- 1.8.5.2