From owner-svn-src-all@freebsd.org Thu Jun 23 23:13:15 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A8F83B73D26; Thu, 23 Jun 2016 23:13:15 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5D66228EE; Thu, 23 Jun 2016 23:13:15 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5NNDEA5093675; Thu, 23 Jun 2016 23:13:14 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5NNDEu3093674; Thu, 23 Jun 2016 23:13:14 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201606232313.u5NNDEu3093674@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Thu, 23 Jun 2016 23:13:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302162 - head/usr.sbin/gstat X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Jun 2016 23:13:15 -0000 Author: asomers Date: Thu Jun 23 23:13:14 2016 New Revision: 302162 URL: https://svnweb.freebsd.org/changeset/base/302162 Log: 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 Modified: head/usr.sbin/gstat/gstat.c Modified: head/usr.sbin/gstat/gstat.c ============================================================================== --- head/usr.sbin/gstat/gstat.c Thu Jun 23 22:42:03 2016 (r302161) +++ head/usr.sbin/gstat/gstat.c Thu Jun 23 23:13:14 2016 (r302162) @@ -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); }