Author: mesyeti <mesyeti@mesyeti.uk>
allow disabling the top bar
docs/config.md | 5 +++ example_config.ini | 1 source/app.c | 64 +++++++++++++++++++++++++++-------------------- source/app.h | 1 source/config.c | 3 ++ source/pane.c | 6 +++-
diff --git a/docs/config.md b/docs/config.md index 3ee1cf76b453d4b3643722aea44cc9e0ef4db08b..39f2f2f3c7f583958717eb6b5c6c37170d46ed4b 100644 --- a/docs/config.md +++ b/docs/config.md @@ -25,3 +25,8 @@ Whether the active pane title is displayed. Does not affect whether the active pane title is used in the terminal's window title. Default = `true` + +### `bar` +Whether the status bar is displayed + +Default = `true` diff --git a/example_config.ini b/example_config.ini index 29f0139242bba2dc5d122eda3e387c2bbc4d58ef..127bec8cce29b730fd6acfcb3b10d262e7d7e6f6 100644 --- a/example_config.ini +++ b/example_config.ini @@ -5,3 +5,4 @@ [display] clock = true title = true +bar = true diff --git a/source/app.c b/source/app.c index 4a56f93053ff92321d6ce27681aaf46bf50b8e5f..0b63ac27cacceb70e7eff56790a633e03e7e249a 100644 --- a/source/app.c +++ b/source/app.c @@ -15,6 +15,7 @@ // default config app.renderTitle = true; app.renderClock = true; + app.renderBar = true; Event_Init(); Window_Init(); @@ -152,44 +153,53 @@ Window_SetTitle(&video.windows[0], winTitle); // render Buffer_Clear(&screen.buffer, BufAttr_Default()); - BufCell bar; - bar.ch = ' '; - bar.attr.fgMode = BUF_16COL; - bar.attr.bgMode = BUF_16COL; - bar.attr.fg.idx = 0x7; // white - bar.attr.bg.idx = 0x8; // grey + if (app.renderBar) { + BufCell bar; + bar.ch = ' '; + bar.attr.fgMode = BUF_16COL; + bar.attr.bgMode = BUF_16COL; + bar.attr.fg.idx = 0x7; // white + bar.attr.bg.idx = 0x8; // grey - Buffer_HLine(&screen.buffer, 0, 0, screen.buffer.width, bar); + Buffer_HLine(&screen.buffer, 0, 0, screen.buffer.width, bar); - char info[32]; - snprintf(info, sizeof(info), "yterm - [%d/%d]", (int) app.tabSel + 1, (int) app.tabNum); - Buffer_Print(&screen.buffer, 0, 0, bar.attr, info); + char info[32]; + snprintf(info, sizeof(info), "yterm - [%d/%d]", (int) app.tabSel + 1, (int) app.tabNum); + Buffer_Print(&screen.buffer, 0, 0, bar.attr, info); - // clock - if (app.renderClock) { - time_t now = time(NULL); + // clock + if (app.renderClock) { + time_t now = time(NULL); + + if (now != -1) { + struct tm* timeInfo = localtime(&now); + + char time[32]; + snprintf( + time, sizeof(time), "%.2d:%.2d:%.2d", timeInfo->tm_hour, timeInfo->tm_min, + timeInfo->tm_sec + ); - if (now != -1) { - struct tm* timeInfo = localtime(&now); + Buffer_Print(&screen.buffer, screen.buffer.width - strlen(time), 0, bar.attr, time); + } + } - char time[32]; - snprintf( - time, sizeof(time), "%.2d:%.2d:%.2d", timeInfo->tm_hour, timeInfo->tm_min, - timeInfo->tm_sec - ); + if (app.renderTitle) { + char* title = app.paneSel->v.terminal.title; + int titleX = (screen.buffer.width / 2) - (strlen(title) / 2); - Buffer_Print(&screen.buffer, screen.buffer.width - strlen(time), 0, bar.attr, time); + Buffer_Print(&screen.buffer, titleX, 0, bar.attr, title); } } - if (app.renderTitle) { - char* title = app.paneSel->v.terminal.title; - int titleX = (screen.buffer.width / 2) - (strlen(title) / 2); - - Buffer_Print(&screen.buffer, titleX, 0, bar.attr, title); + Rect within; + if (app.renderBar) { + within = (Rect) {0, 1, screen.buffer.width, screen.buffer.height - 1}; + } + else { + within = (Rect) {0, 0, screen.buffer.width, screen.buffer.height}; } - Rect within = {0, 1, screen.buffer.width, screen.buffer.height - 1}; Pane_Render(&app.tabs[app.tabSel], within); Screen_Render(); diff --git a/source/app.h b/source/app.h index b416f7cf7f86bddacbda1de9450f24cc1613ebc0..15522938e1c25a5d117863bec71c034f1514e01e 100644 --- a/source/app.h +++ b/source/app.h @@ -27,6 +27,7 @@ // config bool renderTitle; bool renderClock; + bool renderBar; } App; extern App app; diff --git a/source/config.c b/source/config.c index 695409e1c75545b0a5da0d92d11ea51458a5e769..8ebc79cf6f9138b8eabecfc7247ad1c5e3067faf 100644 --- a/source/config.c +++ b/source/config.c @@ -88,6 +88,9 @@ } else if (strcmp(key, "title") == 0) { return ParseBool(val, &app.renderTitle); } + else if (strcmp(key, "bar") == 0) { + return ParseBool(val, &app.renderBar); + } else { return "Invalid key"; } diff --git a/source/pane.c b/source/pane.c index 5d2e766ff5959140bca2211d1488197346c16e10..d8716eaeb43f419e8f1c9f7da4b40521db749903 100644 --- a/source/pane.c +++ b/source/pane.c @@ -6,7 +6,9 @@ Pane Pane_NewRootPane(bool* success) { Pane ret; ret.type = PANE_TERMINAL; - ret.v.terminal = Terminal_New(screen.buffer.width, screen.buffer.height - 1, success); + ret.v.terminal = Terminal_New( + screen.buffer.width, screen.buffer.height - (app.renderBar? 1 : 0), success + ); return ret; } @@ -44,7 +46,7 @@ int ch; Font_CharSize(&screen.font, &cw, &ch); int newW = video.windows[0].width / cw; - int newH = (video.windows[0].height / ch) - 1; + int newH = (video.windows[0].height / ch) - (app.renderBar? 1 : 0); Terminal_Resize(&pane->v.terminal, newW, newH); return;