commit dc2c33447cc70129447c35401081e46c06e66d38 from: Mark Jamsek date: Mon Jan 23 04:22:44 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 - 3f6c66148db9beccfaaa0138fcff4b84cb99ec5a commit + dc2c33447cc70129447c35401081e46c06e66d38 blob - 20e53ee697ba1c8890789243f34f8726f9ef496b blob + c1730a93d0f5558332b281e3b842aea06d9748f0 --- tog/tog.c +++ tog/tog.c @@ -1778,6 +1778,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; @@ -1841,7 +1865,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; @@ -9482,7 +9506,6 @@ main(int argc, char *argv[]) } endwin(); - putchar('\n'); if (cmd_argv) { int i; for (i = 0; i < argc; i++)