tty-ncurses.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773
  1. /*
  2. Interface to the terminal controlling library.
  3. Ncurses wrapper.
  4. Copyright (C) 2005-2024
  5. Free Software Foundation, Inc.
  6. Written by:
  7. Andrew Borodin <aborodin@vmail.ru>, 2009.
  8. Ilia Maslakov <il.smind@gmail.com>, 2009.
  9. This file is part of the Midnight Commander.
  10. The Midnight Commander is free software: you can redistribute it
  11. and/or modify it under the terms of the GNU General Public License as
  12. published by the Free Software Foundation, either version 3 of the License,
  13. or (at your option) any later version.
  14. The Midnight Commander is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. GNU General Public License for more details.
  18. You should have received a copy of the GNU General Public License
  19. along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. /** \file
  22. * \brief Source: NCurses-based tty layer of Midnight-commander
  23. */
  24. #include <config.h>
  25. #include <stdlib.h>
  26. #include <stdarg.h>
  27. #include <signal.h>
  28. #ifdef HAVE_SYS_IOCTL_H
  29. #include <sys/ioctl.h>
  30. #endif
  31. #include <termios.h>
  32. #include "lib/global.h"
  33. #include "lib/strutil.h" /* str_term_form */
  34. #include "lib/util.h"
  35. #ifndef WANT_TERM_H
  36. #define WANT_TERM_H
  37. #endif
  38. #include "tty-internal.h" /* mc_tty_normalize_from_utf8() */
  39. #include "tty.h"
  40. #include "color.h" /* tty_setcolor */
  41. #include "color-internal.h"
  42. #include "key.h"
  43. #include "mouse.h"
  44. #include "win.h"
  45. /* include at last !!! */
  46. #ifdef WANT_TERM_H
  47. #ifdef HAVE_NCURSES_TERM_H
  48. #include <ncurses/term.h>
  49. #else
  50. #include <term.h>
  51. #endif /* HAVE_NCURSES_TERM_H */
  52. #endif /* WANT_TERM_H */
  53. /*** global variables ****************************************************************************/
  54. /*** file scope macro definitions ****************************************************************/
  55. #if !defined(CTRL)
  56. #define CTRL(x) ((x) & 0x1f)
  57. #endif
  58. #define yx_in_screen(y, x) \
  59. (y >= 0 && y < LINES && x >= 0 && x < COLS)
  60. /*** global variables ****************************************************************************/
  61. /*** file scope type declarations ****************************************************************/
  62. /*** forward declarations (file scope functions) *************************************************/
  63. /*** file scope variables ************************************************************************/
  64. /* ncurses supports cursor positions only within window */
  65. /* We use our own cursor coordinates to support partially visible widgets */
  66. static int mc_curs_row, mc_curs_col;
  67. /* --------------------------------------------------------------------------------------------- */
  68. /*** file scope functions ************************************************************************/
  69. /* --------------------------------------------------------------------------------------------- */
  70. static void
  71. tty_setup_sigwinch (void (*handler) (int))
  72. {
  73. #if (NCURSES_VERSION_MAJOR >= 4) && defined (SIGWINCH)
  74. struct sigaction act, oact;
  75. memset (&act, 0, sizeof (act));
  76. act.sa_handler = handler;
  77. sigemptyset (&act.sa_mask);
  78. #ifdef SA_RESTART
  79. act.sa_flags = SA_RESTART;
  80. #endif /* SA_RESTART */
  81. my_sigaction (SIGWINCH, &act, &oact);
  82. #endif /* SIGWINCH */
  83. tty_create_winch_pipe ();
  84. }
  85. /* --------------------------------------------------------------------------------------------- */
  86. static void
  87. sigwinch_handler (int dummy)
  88. {
  89. ssize_t n = 0;
  90. (void) dummy;
  91. n = write (sigwinch_pipe[1], "", 1);
  92. (void) n;
  93. }
  94. /* --------------------------------------------------------------------------------------------- */
  95. /**
  96. * Get visible part of area.
  97. *
  98. * @returns TRUE if any part of area is in screen bounds, FALSE otherwise.
  99. */
  100. static gboolean
  101. tty_clip (int *y, int *x, int *rows, int *cols)
  102. {
  103. if (*y < 0)
  104. {
  105. *rows += *y;
  106. if (*rows <= 0)
  107. return FALSE;
  108. *y = 0;
  109. }
  110. if (*x < 0)
  111. {
  112. *cols += *x;
  113. if (*cols <= 0)
  114. return FALSE;
  115. *x = 0;
  116. }
  117. if (*y + *rows > LINES)
  118. *rows = LINES - *y;
  119. if (*rows <= 0)
  120. return FALSE;
  121. if (*x + *cols > COLS)
  122. *cols = COLS - *x;
  123. if (*cols <= 0)
  124. return FALSE;
  125. return TRUE;
  126. }
  127. /* --------------------------------------------------------------------------------------------- */
  128. /*** public functions ****************************************************************************/
  129. /* --------------------------------------------------------------------------------------------- */
  130. int
  131. mc_tty_normalize_lines_char (const char *ch)
  132. {
  133. char *str2;
  134. int res;
  135. struct mc_tty_lines_struct
  136. {
  137. const char *line;
  138. int line_code;
  139. } const lines_codes[] = {
  140. {"\342\224\230", ACS_LRCORNER}, /* ┌ */
  141. {"\342\224\224", ACS_LLCORNER}, /* └ */
  142. {"\342\224\220", ACS_URCORNER}, /* ┐ */
  143. {"\342\224\214", ACS_ULCORNER}, /* ┘ */
  144. {"\342\224\234", ACS_LTEE}, /* ├ */
  145. {"\342\224\244", ACS_RTEE}, /* ┤ */
  146. {"\342\224\254", ACS_TTEE}, /* ┬ */
  147. {"\342\224\264", ACS_BTEE}, /* ┴ */
  148. {"\342\224\200", ACS_HLINE}, /* ─ */
  149. {"\342\224\202", ACS_VLINE}, /* │ */
  150. {"\342\224\274", ACS_PLUS}, /* ┼ */
  151. {"\342\225\235", ACS_LRCORNER | A_BOLD}, /* ╔ */
  152. {"\342\225\232", ACS_LLCORNER | A_BOLD}, /* ╚ */
  153. {"\342\225\227", ACS_URCORNER | A_BOLD}, /* ╗ */
  154. {"\342\225\224", ACS_ULCORNER | A_BOLD}, /* ╝ */
  155. {"\342\225\237", ACS_LTEE | A_BOLD}, /* ╟ */
  156. {"\342\225\242", ACS_RTEE | A_BOLD}, /* ╢ */
  157. {"\342\225\244", ACS_TTEE | A_BOLD}, /* ╤ */
  158. {"\342\225\247", ACS_BTEE | A_BOLD}, /* ╧ */
  159. {"\342\225\220", ACS_HLINE | A_BOLD}, /* ═ */
  160. {"\342\225\221", ACS_VLINE | A_BOLD}, /* ║ */
  161. {NULL, 0}
  162. };
  163. if (ch == NULL)
  164. return (int) ' ';
  165. for (res = 0; lines_codes[res].line; res++)
  166. {
  167. if (strcmp (ch, lines_codes[res].line) == 0)
  168. return lines_codes[res].line_code;
  169. }
  170. str2 = mc_tty_normalize_from_utf8 (ch);
  171. res = g_utf8_get_char_validated (str2, -1);
  172. if (res < 0)
  173. res = (unsigned char) str2[0];
  174. g_free (str2);
  175. return res;
  176. }
  177. /* --------------------------------------------------------------------------------------------- */
  178. void
  179. tty_init (gboolean mouse_enable, gboolean is_xterm)
  180. {
  181. struct termios mode;
  182. initscr ();
  183. #ifdef HAVE_ESCDELAY
  184. /*
  185. * If ncurses exports the ESCDELAY variable, it should be set to
  186. * a low value, or you'll experience a delay in processing escape
  187. * sequences that are recognized by mc (e.g. Esc-Esc). On the other
  188. * hand, making ESCDELAY too small can result in some sequences
  189. * (e.g. cursor arrows) being reported as separate keys under heavy
  190. * processor load, and this can be a problem if mc hasn't learned
  191. * them in the "Learn Keys" dialog. The value is in milliseconds.
  192. */
  193. ESCDELAY = 200;
  194. #endif /* HAVE_ESCDELAY */
  195. tcgetattr (STDIN_FILENO, &mode);
  196. /* use Ctrl-g to generate SIGINT */
  197. mode.c_cc[VINTR] = CTRL ('g'); /* ^g */
  198. /* disable SIGQUIT to allow use Ctrl-\ key */
  199. mode.c_cc[VQUIT] = NULL_VALUE;
  200. tcsetattr (STDIN_FILENO, TCSANOW, &mode);
  201. /* curses remembers the "in-program" modes after this call */
  202. def_prog_mode ();
  203. tty_start_interrupt_key ();
  204. if (!mouse_enable)
  205. use_mouse_p = MOUSE_DISABLED;
  206. tty_init_xterm_support (is_xterm); /* do it before tty_enter_ca_mode() call */
  207. tty_enter_ca_mode ();
  208. tty_raw_mode ();
  209. noecho ();
  210. keypad (stdscr, TRUE);
  211. nodelay (stdscr, FALSE);
  212. tty_setup_sigwinch (sigwinch_handler);
  213. }
  214. /* --------------------------------------------------------------------------------------------- */
  215. void
  216. tty_shutdown (void)
  217. {
  218. tty_destroy_winch_pipe ();
  219. tty_reset_shell_mode ();
  220. tty_noraw_mode ();
  221. tty_keypad (FALSE);
  222. tty_reset_screen ();
  223. tty_exit_ca_mode ();
  224. }
  225. /* --------------------------------------------------------------------------------------------- */
  226. void
  227. tty_enter_ca_mode (void)
  228. {
  229. if (mc_global.tty.xterm_flag && smcup != NULL)
  230. {
  231. fprintf (stdout, /* ESC_STR ")0" */ ESC_STR "7" ESC_STR "[?47h");
  232. fflush (stdout);
  233. }
  234. }
  235. /* --------------------------------------------------------------------------------------------- */
  236. void
  237. tty_exit_ca_mode (void)
  238. {
  239. if (mc_global.tty.xterm_flag && rmcup != NULL)
  240. {
  241. fprintf (stdout, ESC_STR "[?47l" ESC_STR "8" ESC_STR "[m");
  242. fflush (stdout);
  243. }
  244. }
  245. /* --------------------------------------------------------------------------------------------- */
  246. void
  247. tty_change_screen_size (void)
  248. {
  249. #if defined(TIOCGWINSZ) && NCURSES_VERSION_MAJOR >= 4
  250. struct winsize winsz;
  251. winsz.ws_col = winsz.ws_row = 0;
  252. #ifndef NCURSES_VERSION
  253. tty_noraw_mode ();
  254. tty_reset_screen ();
  255. #endif
  256. /* Ioctl on the STDIN_FILENO */
  257. ioctl (fileno (stdout), TIOCGWINSZ, &winsz);
  258. if (winsz.ws_col != 0 && winsz.ws_row != 0)
  259. {
  260. #if defined(NCURSES_VERSION) && defined(HAVE_RESIZETERM)
  261. resizeterm (winsz.ws_row, winsz.ws_col);
  262. clearok (stdscr, TRUE); /* sigwinch's should use a semaphore! */
  263. #else
  264. COLS = winsz.ws_col;
  265. LINES = winsz.ws_row;
  266. #endif
  267. }
  268. #endif /* defined(TIOCGWINSZ) || NCURSES_VERSION_MAJOR >= 4 */
  269. #ifdef ENABLE_SUBSHELL
  270. if (mc_global.tty.use_subshell)
  271. tty_resize (mc_global.tty.subshell_pty);
  272. #endif
  273. }
  274. /* --------------------------------------------------------------------------------------------- */
  275. void
  276. tty_reset_prog_mode (void)
  277. {
  278. reset_prog_mode ();
  279. }
  280. /* --------------------------------------------------------------------------------------------- */
  281. void
  282. tty_reset_shell_mode (void)
  283. {
  284. reset_shell_mode ();
  285. }
  286. /* --------------------------------------------------------------------------------------------- */
  287. void
  288. tty_raw_mode (void)
  289. {
  290. raw (); /* FIXME: unneeded? */
  291. cbreak ();
  292. }
  293. /* --------------------------------------------------------------------------------------------- */
  294. void
  295. tty_noraw_mode (void)
  296. {
  297. nocbreak (); /* FIXME: unneeded? */
  298. noraw ();
  299. }
  300. /* --------------------------------------------------------------------------------------------- */
  301. void
  302. tty_noecho (void)
  303. {
  304. noecho ();
  305. }
  306. /* --------------------------------------------------------------------------------------------- */
  307. int
  308. tty_flush_input (void)
  309. {
  310. return flushinp ();
  311. }
  312. /* --------------------------------------------------------------------------------------------- */
  313. void
  314. tty_keypad (gboolean set)
  315. {
  316. keypad (stdscr, (bool) set);
  317. }
  318. /* --------------------------------------------------------------------------------------------- */
  319. void
  320. tty_nodelay (gboolean set)
  321. {
  322. nodelay (stdscr, (bool) set);
  323. }
  324. /* --------------------------------------------------------------------------------------------- */
  325. int
  326. tty_baudrate (void)
  327. {
  328. return baudrate ();
  329. }
  330. /* --------------------------------------------------------------------------------------------- */
  331. int
  332. tty_lowlevel_getch (void)
  333. {
  334. return getch ();
  335. }
  336. /* --------------------------------------------------------------------------------------------- */
  337. int
  338. tty_reset_screen (void)
  339. {
  340. return endwin ();
  341. }
  342. /* --------------------------------------------------------------------------------------------- */
  343. void
  344. tty_touch_screen (void)
  345. {
  346. touchwin (stdscr);
  347. }
  348. /* --------------------------------------------------------------------------------------------- */
  349. void
  350. tty_gotoyx (int y, int x)
  351. {
  352. mc_curs_row = y;
  353. mc_curs_col = x;
  354. if (y < 0)
  355. y = 0;
  356. if (y >= LINES)
  357. y = LINES - 1;
  358. if (x < 0)
  359. x = 0;
  360. if (x >= COLS)
  361. x = COLS - 1;
  362. move (y, x);
  363. }
  364. /* --------------------------------------------------------------------------------------------- */
  365. void
  366. tty_getyx (int *py, int *px)
  367. {
  368. *py = mc_curs_row;
  369. *px = mc_curs_col;
  370. }
  371. /* --------------------------------------------------------------------------------------------- */
  372. void
  373. tty_draw_hline (int y, int x, int ch, int len)
  374. {
  375. int x1;
  376. if (y < 0 || y >= LINES || x >= COLS)
  377. return;
  378. x1 = x;
  379. if (x < 0)
  380. {
  381. len += x;
  382. if (len <= 0)
  383. return;
  384. x = 0;
  385. }
  386. if ((chtype) ch == ACS_HLINE)
  387. ch = mc_tty_frm[MC_TTY_FRM_HORIZ];
  388. move (y, x);
  389. hline (ch, len);
  390. move (y, x1);
  391. mc_curs_row = y;
  392. mc_curs_col = x1;
  393. }
  394. /* --------------------------------------------------------------------------------------------- */
  395. void
  396. tty_draw_vline (int y, int x, int ch, int len)
  397. {
  398. int y1;
  399. if (x < 0 || x >= COLS || y >= LINES)
  400. return;
  401. y1 = y;
  402. if (y < 0)
  403. {
  404. len += y;
  405. if (len <= 0)
  406. return;
  407. y = 0;
  408. }
  409. if ((chtype) ch == ACS_VLINE)
  410. ch = mc_tty_frm[MC_TTY_FRM_VERT];
  411. move (y, x);
  412. vline (ch, len);
  413. move (y1, x);
  414. mc_curs_row = y1;
  415. mc_curs_col = x;
  416. }
  417. /* --------------------------------------------------------------------------------------------- */
  418. void
  419. tty_fill_region (int y, int x, int rows, int cols, unsigned char ch)
  420. {
  421. int i;
  422. if (!tty_clip (&y, &x, &rows, &cols))
  423. return;
  424. for (i = 0; i < rows; i++)
  425. {
  426. move (y + i, x);
  427. hline (ch, cols);
  428. }
  429. move (y, x);
  430. mc_curs_row = y;
  431. mc_curs_col = x;
  432. }
  433. /* --------------------------------------------------------------------------------------------- */
  434. void
  435. tty_colorize_area (int y, int x, int rows, int cols, int color)
  436. {
  437. #ifdef ENABLE_SHADOWS
  438. cchar_t *ctext;
  439. wchar_t wch[10]; /* TODO not sure if the length is correct */
  440. attr_t attrs;
  441. short color_pair;
  442. if (!use_colors || !tty_clip (&y, &x, &rows, &cols))
  443. return;
  444. tty_setcolor (color);
  445. ctext = g_malloc (sizeof (cchar_t) * (cols + 1));
  446. for (int row = 0; row < rows; row++)
  447. {
  448. mvin_wchnstr (y + row, x, ctext, cols);
  449. for (int col = 0; col < cols; col++)
  450. {
  451. getcchar (&ctext[col], wch, &attrs, &color_pair, NULL);
  452. setcchar (&ctext[col], wch, attrs, color, NULL);
  453. }
  454. mvadd_wchnstr (y + row, x, ctext, cols);
  455. }
  456. g_free (ctext);
  457. #else
  458. (void) y;
  459. (void) x;
  460. (void) rows;
  461. (void) cols;
  462. (void) color;
  463. #endif /* ENABLE_SHADOWS */
  464. }
  465. /* --------------------------------------------------------------------------------------------- */
  466. void
  467. tty_set_alt_charset (gboolean alt_charset)
  468. {
  469. (void) alt_charset;
  470. }
  471. /* --------------------------------------------------------------------------------------------- */
  472. void
  473. tty_display_8bit (gboolean what)
  474. {
  475. meta (stdscr, (int) what);
  476. }
  477. /* --------------------------------------------------------------------------------------------- */
  478. void
  479. tty_print_char (int c)
  480. {
  481. if (yx_in_screen (mc_curs_row, mc_curs_col))
  482. addch (c);
  483. mc_curs_col++;
  484. }
  485. /* --------------------------------------------------------------------------------------------- */
  486. void
  487. tty_print_anychar (int c)
  488. {
  489. if (mc_global.utf8_display || c > 255)
  490. {
  491. int res;
  492. unsigned char str[UTF8_CHAR_LEN + 1];
  493. res = g_unichar_to_utf8 (c, (char *) str);
  494. if (res == 0)
  495. {
  496. if (yx_in_screen (mc_curs_row, mc_curs_col))
  497. addch ('.');
  498. mc_curs_col++;
  499. }
  500. else
  501. {
  502. const char *s;
  503. str[res] = '\0';
  504. s = str_term_form ((char *) str);
  505. if (yx_in_screen (mc_curs_row, mc_curs_col))
  506. addstr (s);
  507. if (g_unichar_iswide (c))
  508. mc_curs_col += 2;
  509. else if (!g_unichar_iszerowidth (c))
  510. mc_curs_col++;
  511. }
  512. }
  513. else
  514. {
  515. if (yx_in_screen (mc_curs_row, mc_curs_col))
  516. addch (c);
  517. mc_curs_col++;
  518. }
  519. }
  520. /* --------------------------------------------------------------------------------------------- */
  521. void
  522. tty_print_alt_char (int c, gboolean single)
  523. {
  524. if (yx_in_screen (mc_curs_row, mc_curs_col))
  525. {
  526. if ((chtype) c == ACS_VLINE)
  527. c = mc_tty_frm[single ? MC_TTY_FRM_VERT : MC_TTY_FRM_DVERT];
  528. else if ((chtype) c == ACS_HLINE)
  529. c = mc_tty_frm[single ? MC_TTY_FRM_HORIZ : MC_TTY_FRM_DHORIZ];
  530. else if ((chtype) c == ACS_LTEE)
  531. c = mc_tty_frm[single ? MC_TTY_FRM_LEFTMIDDLE : MC_TTY_FRM_DLEFTMIDDLE];
  532. else if ((chtype) c == ACS_RTEE)
  533. c = mc_tty_frm[single ? MC_TTY_FRM_RIGHTMIDDLE : MC_TTY_FRM_DRIGHTMIDDLE];
  534. else if ((chtype) c == ACS_ULCORNER)
  535. c = mc_tty_frm[single ? MC_TTY_FRM_LEFTTOP : MC_TTY_FRM_DLEFTTOP];
  536. else if ((chtype) c == ACS_LLCORNER)
  537. c = mc_tty_frm[single ? MC_TTY_FRM_LEFTBOTTOM : MC_TTY_FRM_DLEFTBOTTOM];
  538. else if ((chtype) c == ACS_URCORNER)
  539. c = mc_tty_frm[single ? MC_TTY_FRM_RIGHTTOP : MC_TTY_FRM_DRIGHTTOP];
  540. else if ((chtype) c == ACS_LRCORNER)
  541. c = mc_tty_frm[single ? MC_TTY_FRM_RIGHTBOTTOM : MC_TTY_FRM_DRIGHTBOTTOM];
  542. else if ((chtype) c == ACS_PLUS)
  543. c = mc_tty_frm[MC_TTY_FRM_CROSS];
  544. addch (c);
  545. }
  546. mc_curs_col++;
  547. }
  548. /* --------------------------------------------------------------------------------------------- */
  549. void
  550. tty_print_string (const char *s)
  551. {
  552. int len;
  553. int start = 0;
  554. s = str_term_form (s);
  555. len = str_term_width1 (s);
  556. /* line is upper or below the screen or entire line is before or after screen */
  557. if (mc_curs_row < 0 || mc_curs_row >= LINES || mc_curs_col + len <= 0 || mc_curs_col >= COLS)
  558. {
  559. mc_curs_col += len;
  560. return;
  561. }
  562. /* skip invisible left part */
  563. if (mc_curs_col < 0)
  564. {
  565. start = -mc_curs_col;
  566. len += mc_curs_col;
  567. mc_curs_col = 0;
  568. }
  569. mc_curs_col += len;
  570. if (mc_curs_col >= COLS)
  571. len = COLS - (mc_curs_col - len);
  572. addstr (str_term_substring (s, start, len));
  573. }
  574. /* --------------------------------------------------------------------------------------------- */
  575. void
  576. tty_printf (const char *fmt, ...)
  577. {
  578. va_list args;
  579. char buf[BUF_1K]; /* FIXME: is it enough? */
  580. va_start (args, fmt);
  581. g_vsnprintf (buf, sizeof (buf), fmt, args);
  582. va_end (args);
  583. tty_print_string (buf);
  584. }
  585. /* --------------------------------------------------------------------------------------------- */
  586. char *
  587. tty_tgetstr (const char *cap)
  588. {
  589. char *unused = NULL;
  590. return tgetstr ((NCURSES_CONST char *) cap, &unused);
  591. }
  592. /* --------------------------------------------------------------------------------------------- */
  593. void
  594. tty_refresh (void)
  595. {
  596. refresh ();
  597. doupdate ();
  598. }
  599. /* --------------------------------------------------------------------------------------------- */
  600. void
  601. tty_beep (void)
  602. {
  603. beep ();
  604. }
  605. /* --------------------------------------------------------------------------------------------- */