commit 6ec3d39ca03fd5b2f4bf0d896a3b9171644390cd from: Mark Jamsek via: Thomas Adam date: Mon Jan 23 18:21:06 2023 UTC don't print empty line when exiting tog Reported and tested by dv: rather than print a new line to avoid clobbering the shell prompt when exiting tog with the alternate screen buffer disabled^, adopt naddy's vi(1) solution by looping through visible views to delete the topmost line, which inserts an empty line at the bottom so we don't need to print an empty line to ensure a clean prompt. ^: xterm -xrm 'XTerm*titeInhibit: 1' or run tog in the console ok naddy@ commit - f2d06bef0f9de303eb6de9523de85da21645850f commit + 6ec3d39ca03fd5b2f4bf0d896a3b9171644390cd blob - 1bc0752f6f3684856059199715c5278f8db65cf5 blob + ca4b32aa5e3ae11946ad03de15bb435c4f3aceca --- tog/tog.c +++ tog/tog.c @@ -1783,6 +1783,30 @@ view_loop(struct tog_view *view) err = view_input(&new_view, &done, view, &views); if (err) break; + + if (view->dying && view == TAILQ_FIRST(&views) && + TAILQ_NEXT(view, entry) == NULL) + done = 1; + if (done) { + struct tog_view *v; + + /* + * When we quit, scroll the screen up a single line + * so we don't lose any information. + */ + TAILQ_FOREACH(v, &views, entry) { + wmove(v->window, 0, 0); + wdeleteln(v->window); + wnoutrefresh(v->window); + if (v->child && !view_is_fullscreen(v)) { + wmove(v->child->window, 0, 0); + wdeleteln(v->child->window); + wnoutrefresh(v->child->window); + } + } + doupdate(); + } + if (view->dying) { struct tog_view *v, *prev = NULL; @@ -1846,7 +1870,7 @@ view_loop(struct tog_view *view) TAILQ_INSERT_TAIL(&views, new_view, entry); view = new_view; } - if (view) { + if (view && !done) { if (view_is_parent_view(view)) { if (view->child && view->child->focussed) view = view->child; @@ -9487,7 +9511,6 @@ main(int argc, char *argv[]) } endwin(); - putchar('\n'); if (cmd_argv) { int i; for (i = 0; i < argc; i++)