summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorasomers <asomers@FreeBSD.org>2016-06-23 23:13:14 +0000
committerasomers <asomers@FreeBSD.org>2016-06-23 23:13:14 +0000
commit226be952e76a861478ac965b82e666d82560ace8 (patch)
tree04bf923003d8c9f278f4520b41c979e0fbaee3bd
parentf3a7d6a3f15e3b2146dca4f01ba9806d1c94ff53 (diff)
downloadFreeBSD-src-226be952e76a861478ac965b82e666d82560ace8.zip
FreeBSD-src-226be952e76a861478ac965b82e666d82560ace8.tar.gz
Fix gstat's interactive f and q commands
curses and libedit don't play well together. After last year's libedit upgrade in head, they play even less well together. This change resets some curses settings after they get screwed up by libedit calls. Without it, gstat's interactive commands require an extra "enter", screw up the terminal on exit, and screw up the display if the user enters an invalid filter string. PR: 204852 Submitted by: Keith White Reviewed by: pfg Approved by: re (gjb) MFC after: 4 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D6934
-rw-r--r--usr.sbin/gstat/gstat.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/usr.sbin/gstat/gstat.c b/usr.sbin/gstat/gstat.c
index 8be3775..a360f8f 100644
--- a/usr.sbin/gstat/gstat.c
+++ b/usr.sbin/gstat/gstat.c
@@ -167,20 +167,6 @@ main(int argc, char **argv)
if (sq == NULL)
err(1, "geom_stats_snapshot()");
if (!flag_b) {
- /* Setup curses */
- initscr();
- start_color();
- use_default_colors();
- pair_content(0, &cf, &cb);
- init_pair(1, COLOR_GREEN, cb);
- init_pair(2, COLOR_MAGENTA, cb);
- init_pair(3, COLOR_RED, cb);
- cbreak();
- noecho();
- nonl();
- nodelay(stdscr, 1);
- intrflush(stdscr, FALSE);
- keypad(stdscr, TRUE);
/* Setup libedit */
hist = history_init();
if (hist == NULL)
@@ -195,6 +181,20 @@ main(int argc, char **argv)
el_set(el, EL_PROMPT, el_prompt);
if (f_s[0] != '\0')
history(hist, &hist_ev, H_ENTER, f_s);
+ /* Setup curses */
+ initscr();
+ start_color();
+ use_default_colors();
+ pair_content(0, &cf, &cb);
+ init_pair(1, COLOR_GREEN, cb);
+ init_pair(2, COLOR_MAGENTA, cb);
+ init_pair(3, COLOR_RED, cb);
+ cbreak();
+ noecho();
+ nonl();
+ nodelay(stdscr, 1);
+ intrflush(stdscr, FALSE);
+ keypad(stdscr, TRUE);
}
geom_stats_snapshot_timestamp(sq, &tq);
for (quit = 0; !quit;) {
@@ -410,12 +410,15 @@ main(int argc, char **argv)
if ((p = strchr(tmp_f_s, '\n')) != NULL)
*p = '\0';
/*
- * We have to clear since we messed up
+ * Fix the terminal. We messed up
* curses idea of the screen by using
* libedit.
*/
clear();
refresh();
+ cbreak();
+ noecho();
+ nonl();
if (regcomp(&tmp_f_re, tmp_f_s, REG_EXTENDED)
!= 0) {
move(0, 0);
@@ -440,8 +443,8 @@ main(int argc, char **argv)
}
if (!flag_b) {
- endwin();
el_end(el);
+ endwin();
}
exit(EX_OK);
}
OpenPOWER on IntegriCloud