[gdb/tui] Factor out require_tui_terminal

I noticed this bit of code in tui_enable:
...
      /* Check required terminal capabilities.  The MinGW port of
	 ncurses does have them, but doesn't expose them through "cup".  */
      cap = tigetstr ((char *) "cup");
      if (cap == NULL || cap == (char *) -1 || *cap == '\0')
	{
	  endwin ();
	  delscreen (s);
	  error (_("Cannot enable the TUI: "
		   "terminal doesn't support cursor addressing [TERM=%s]"),
		 gdb_getenv_term ());
	}
...

At this point in tui_enable, we need endwin and delscreen to clean up after
newterm, but the check can be done before newterm.

Fix this by factoring out a new function require_tui_terminal, and moving the
code there.

Approved-By: Tom Tromey <tom@tromey.com>
1 file changed