tty-slang.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747
  1. /*
  2. Interface to the terminal controlling library.
  3. Slang wrapper.
  4. Copyright (C) 2005, 2006, 2007, 2009, 2010, 2011
  5. The Free Software Foundation, Inc.
  6. Written by:
  7. Andrew Borodin <aborodin@vmail.ru>, 2009
  8. Egmont Koblinger <egmont@gmail.com>, 2010
  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: S-Lang-based tty layer of Midnight Commander
  23. */
  24. #include <config.h>
  25. #include <stdio.h>
  26. #include <stdlib.h>
  27. #include <string.h>
  28. #include <sys/types.h> /* size_t */
  29. #include <unistd.h>
  30. #ifdef HAVE_SYS_IOCTL_H
  31. #include <sys/ioctl.h>
  32. #endif
  33. #include <termios.h>
  34. #include "lib/global.h"
  35. #include "lib/strutil.h" /* str_term_form */
  36. #include "lib/util.h" /* is_printable() */
  37. #include "tty-internal.h" /* mc_tty_normalize_from_utf8() */
  38. #include "tty.h"
  39. #include "color.h"
  40. #include "color-slang.h"
  41. #include "color-internal.h"
  42. #include "mouse.h" /* Gpm_Event is required in key.h */
  43. #include "key.h" /* define_sequence */
  44. #include "win.h"
  45. /*** global variables ****************************************************************************/
  46. extern int reset_hp_softkeys;
  47. /*** file scope macro definitions ****************************************************************/
  48. #ifndef SA_RESTART
  49. #define SA_RESTART 0
  50. #endif
  51. #ifndef SLTT_MAX_SCREEN_COLS
  52. #define SLTT_MAX_SCREEN_COLS 512
  53. #endif
  54. #ifndef SLTT_MAX_SCREEN_ROWS
  55. #define SLTT_MAX_SCREEN_ROWS 512
  56. #endif
  57. /*** file scope type declarations ****************************************************************/
  58. /*** file scope variables ************************************************************************/
  59. /* Various saved termios settings that we control here */
  60. static struct termios boot_mode;
  61. static struct termios new_mode;
  62. /* Controls whether we should wait for input in tty_lowlevel_getch */
  63. static gboolean no_slang_delay;
  64. /* This table describes which capabilities we want and which values we
  65. * assign to them.
  66. */
  67. static const struct
  68. {
  69. int key_code;
  70. const char *key_name;
  71. } key_table[] =
  72. {
  73. /* *INDENT-OFF* */
  74. { KEY_F (0), "k0" },
  75. { KEY_F (1), "k1" },
  76. { KEY_F (2), "k2" },
  77. { KEY_F (3), "k3" },
  78. { KEY_F (4), "k4" },
  79. { KEY_F (5), "k5" },
  80. { KEY_F (6), "k6" },
  81. { KEY_F (7), "k7" },
  82. { KEY_F (8), "k8" },
  83. { KEY_F (9), "k9" },
  84. { KEY_F (10), "k;" },
  85. { KEY_F (11), "F1" },
  86. { KEY_F (12), "F2" },
  87. { KEY_F (13), "F3" },
  88. { KEY_F (14), "F4" },
  89. { KEY_F (15), "F5" },
  90. { KEY_F (16), "F6" },
  91. { KEY_F (17), "F7" },
  92. { KEY_F (18), "F8" },
  93. { KEY_F (19), "F9" },
  94. { KEY_F (20), "FA" },
  95. { KEY_IC, "kI" },
  96. { KEY_NPAGE, "kN" },
  97. { KEY_PPAGE, "kP" },
  98. { KEY_LEFT, "kl" },
  99. { KEY_RIGHT, "kr" },
  100. { KEY_UP, "ku" },
  101. { KEY_DOWN, "kd" },
  102. { KEY_DC, "kD" },
  103. { KEY_BACKSPACE, "kb" },
  104. { KEY_HOME, "kh" },
  105. { KEY_END, "@7" },
  106. { 0, NULL }
  107. /* *INDENT-ON* */
  108. };
  109. /* --------------------------------------------------------------------------------------------- */
  110. /*** file scope functions ************************************************************************/
  111. /* --------------------------------------------------------------------------------------------- */
  112. static void
  113. tty_setup_sigwinch (void (*handler) (int))
  114. {
  115. (void) SLsignal (SIGWINCH, handler);
  116. }
  117. /* --------------------------------------------------------------------------------------------- */
  118. static void
  119. sigwinch_handler (int dummy)
  120. {
  121. (void) dummy;
  122. mc_global.tty.winch_flag = 1;
  123. (void) SLsignal (SIGWINCH, sigwinch_handler);
  124. }
  125. /* --------------------------------------------------------------------------------------------- */
  126. /* HP Terminals have capabilities (pfkey, pfloc, pfx) to program function keys.
  127. elm 2.4pl15 invoked with the -K option utilizes these softkeys and the
  128. consequence is that function keys don't work in MC sometimes...
  129. Unfortunately I don't now the one and only escape sequence to turn off.
  130. softkeys (elm uses three different capabilities to turn on softkeys and two.
  131. capabilities to turn them off)..
  132. Among other things elm uses the pair we already use in slang_keypad. That's.
  133. the reason why I call slang_reset_softkeys from slang_keypad. In lack of
  134. something better the softkeys are programmed to their defaults from the
  135. termcap/terminfo database.
  136. The escape sequence to program the softkeys is taken from elm and it is.
  137. hardcoded because neither slang nor ncurses 4.1 know how to 'printf' this.
  138. sequence. -- Norbert
  139. */
  140. static void
  141. slang_reset_softkeys (void)
  142. {
  143. int key;
  144. char *send;
  145. static const char display[] = " ";
  146. char tmp[BUF_SMALL];
  147. for (key = 1; key < 9; key++)
  148. {
  149. g_snprintf (tmp, sizeof (tmp), "k%d", key);
  150. send = (char *) SLtt_tgetstr (tmp);
  151. if (send != NULL)
  152. {
  153. g_snprintf (tmp, sizeof (tmp), ESC_STR "&f%dk%dd%dL%s%s", key,
  154. (int) (sizeof (display) - 1), (int) strlen (send), display, send);
  155. SLtt_write_string (tmp);
  156. }
  157. }
  158. }
  159. /* --------------------------------------------------------------------------------------------- */
  160. static void
  161. do_define_key (int code, const char *strcap)
  162. {
  163. char *seq;
  164. seq = (char *) SLtt_tgetstr ((char *) strcap);
  165. if (seq != NULL)
  166. define_sequence (code, seq, MCKEY_NOACTION);
  167. }
  168. /* --------------------------------------------------------------------------------------------- */
  169. static void
  170. load_terminfo_keys (void)
  171. {
  172. int i;
  173. for (i = 0; key_table[i].key_code; i++)
  174. do_define_key (key_table[i].key_code, key_table[i].key_name);
  175. }
  176. /* --------------------------------------------------------------------------------------------- */
  177. /*** public functions ****************************************************************************/
  178. /* --------------------------------------------------------------------------------------------- */
  179. int
  180. mc_tty_normalize_lines_char (const char *str)
  181. {
  182. char *str2;
  183. int res;
  184. struct mc_tty_lines_struct
  185. {
  186. const char *line;
  187. int line_code;
  188. } const lines_codes[] = {
  189. {"\342\224\214", SLSMG_ULCORN_CHAR},
  190. {"\342\224\220", SLSMG_URCORN_CHAR},
  191. {"\342\224\224", SLSMG_LLCORN_CHAR},
  192. {"\342\224\230", SLSMG_LRCORN_CHAR},
  193. {"\342\224\234", SLSMG_LTEE_CHAR},
  194. {"\342\224\244", SLSMG_RTEE_CHAR},
  195. {"\342\224\254", SLSMG_UTEE_CHAR},
  196. {"\342\224\264", SLSMG_DTEE_CHAR},
  197. {"\342\224\200", SLSMG_HLINE_CHAR},
  198. {"\342\224\202", SLSMG_VLINE_CHAR},
  199. {"\342\224\274", SLSMG_PLUS_CHAR},
  200. {NULL, 0}
  201. };
  202. if (!str)
  203. return (int) ' ';
  204. for (res = 0; lines_codes[res].line; res++)
  205. {
  206. if (strcmp (str, lines_codes[res].line) == 0)
  207. return lines_codes[res].line_code;
  208. }
  209. str2 = mc_tty_normalize_from_utf8 (str);
  210. res = g_utf8_get_char_validated (str2, -1);
  211. if (res < 0)
  212. res = (unsigned char) str2[0];
  213. g_free (str2);
  214. return res;
  215. }
  216. /* --------------------------------------------------------------------------------------------- */
  217. void
  218. tty_init (gboolean mouse_enable, gboolean is_xterm)
  219. {
  220. SLtt_Ignore_Beep = 1;
  221. SLutf8_enable (-1); /* has to be called first before any of the other functions. */
  222. SLtt_get_terminfo ();
  223. /*
  224. * If the terminal in not in terminfo but begins with a well-known
  225. * string such as "linux" or "xterm" S-Lang will go on, but the
  226. * terminal size and several other variables won't be initialized
  227. * (as of S-Lang 1.4.4). Detect it and abort. Also detect extremely
  228. * small, large and negative screen dimensions.
  229. */
  230. if ((COLS < 10) || (LINES < 5)
  231. || (COLS > SLTT_MAX_SCREEN_COLS) || (LINES > SLTT_MAX_SCREEN_ROWS))
  232. {
  233. fprintf (stderr,
  234. _("Screen size %dx%d is not supported.\n"
  235. "Check the TERM environment variable.\n"), COLS, LINES);
  236. exit (EXIT_FAILURE);
  237. }
  238. tcgetattr (fileno (stdin), &boot_mode);
  239. /* 255 = ignore abort char; XCTRL('g') for abort char = ^g */
  240. SLang_init_tty (XCTRL ('g'), 1, 0);
  241. if (mc_global.tty.ugly_line_drawing)
  242. SLtt_Has_Alt_Charset = 0;
  243. /* If SLang uses fileno(stderr) for terminal input MC will hang
  244. if we call SLang_getkey between calls to open_error_pipe and
  245. close_error_pipe, e.g. when we do a growing view of an gzipped
  246. file. */
  247. if (SLang_TT_Read_FD == fileno (stderr))
  248. SLang_TT_Read_FD = fileno (stdin);
  249. if (tcgetattr (SLang_TT_Read_FD, &new_mode) == 0)
  250. {
  251. #ifdef VDSUSP
  252. new_mode.c_cc[VDSUSP] = NULL_VALUE; /* to ignore ^Y */
  253. #endif
  254. #ifdef VLNEXT
  255. new_mode.c_cc[VLNEXT] = NULL_VALUE; /* to ignore ^V */
  256. #endif
  257. tcsetattr (SLang_TT_Read_FD, TCSADRAIN, &new_mode);
  258. }
  259. tty_reset_prog_mode ();
  260. load_terminfo_keys ();
  261. SLtt_Blink_Mode = tty_use_256colors ()? 1 : 0;
  262. tty_start_interrupt_key ();
  263. /* It's the small part from the previous init_key() */
  264. init_key_input_fd ();
  265. /* For 8-bit locales, NCurses handles 154 (0x9A) symbol properly, while S-Lang
  266. * requires SLsmg_Display_Eight_Bit >= 154 (OR manual filtering if xterm display
  267. * detected - but checking TERM would fail under screen, OR running xterm
  268. * with allowC1Printable).
  269. */
  270. tty_display_8bit (FALSE);
  271. SLsmg_init_smg ();
  272. if (!mouse_enable)
  273. use_mouse_p = MOUSE_DISABLED;
  274. tty_init_xterm_support (is_xterm); /* do it before do_enter_ca_mode() call */
  275. init_mouse ();
  276. do_enter_ca_mode ();
  277. tty_keypad (TRUE);
  278. tty_nodelay (FALSE);
  279. tty_setup_sigwinch (sigwinch_handler);
  280. }
  281. /* --------------------------------------------------------------------------------------------- */
  282. void
  283. tty_shutdown (void)
  284. {
  285. char *op_cap;
  286. disable_mouse ();
  287. tty_reset_shell_mode ();
  288. tty_noraw_mode ();
  289. tty_keypad (FALSE);
  290. tty_reset_screen ();
  291. do_exit_ca_mode ();
  292. SLang_reset_tty ();
  293. /* Load the op capability to reset the colors to those that were
  294. * active when the program was started up
  295. */
  296. op_cap = SLtt_tgetstr ((char *) "op");
  297. if (op_cap != NULL)
  298. {
  299. fputs (op_cap, stdout);
  300. fflush (stdout);
  301. }
  302. }
  303. /* --------------------------------------------------------------------------------------------- */
  304. void
  305. tty_change_screen_size (void)
  306. {
  307. SLtt_get_screen_size ();
  308. SLsmg_reinit_smg ();
  309. #ifdef ENABLE_SUBSHELL
  310. if (mc_global.tty.use_subshell)
  311. tty_resize (mc_global.tty.subshell_pty);
  312. #endif
  313. }
  314. /* --------------------------------------------------------------------------------------------- */
  315. /* Done each time we come back from done mode */
  316. void
  317. tty_reset_prog_mode (void)
  318. {
  319. tcsetattr (SLang_TT_Read_FD, TCSANOW, &new_mode);
  320. SLsmg_init_smg ();
  321. SLsmg_touch_lines (0, LINES);
  322. }
  323. /* --------------------------------------------------------------------------------------------- */
  324. /* Called each time we want to shutdown slang screen manager */
  325. void
  326. tty_reset_shell_mode (void)
  327. {
  328. tcsetattr (SLang_TT_Read_FD, TCSANOW, &boot_mode);
  329. }
  330. /* --------------------------------------------------------------------------------------------- */
  331. void
  332. tty_raw_mode (void)
  333. {
  334. tcsetattr (SLang_TT_Read_FD, TCSANOW, &new_mode);
  335. }
  336. /* --------------------------------------------------------------------------------------------- */
  337. void
  338. tty_noraw_mode (void)
  339. {
  340. }
  341. /* --------------------------------------------------------------------------------------------- */
  342. void
  343. tty_noecho (void)
  344. {
  345. }
  346. /* --------------------------------------------------------------------------------------------- */
  347. int
  348. tty_flush_input (void)
  349. {
  350. return 0; /* OK */
  351. }
  352. /* --------------------------------------------------------------------------------------------- */
  353. void
  354. tty_keypad (gboolean set)
  355. {
  356. char *keypad_string;
  357. keypad_string = (char *) SLtt_tgetstr ((char *) (set ? "ks" : "ke"));
  358. if (keypad_string != NULL)
  359. SLtt_write_string (keypad_string);
  360. if (set && reset_hp_softkeys)
  361. slang_reset_softkeys ();
  362. }
  363. /* --------------------------------------------------------------------------------------------- */
  364. void
  365. tty_nodelay (gboolean set)
  366. {
  367. no_slang_delay = set;
  368. }
  369. /* --------------------------------------------------------------------------------------------- */
  370. int
  371. tty_baudrate (void)
  372. {
  373. return SLang_TT_Baud_Rate;
  374. }
  375. /* --------------------------------------------------------------------------------------------- */
  376. int
  377. tty_lowlevel_getch (void)
  378. {
  379. int c;
  380. if (no_slang_delay && (SLang_input_pending (0) == 0))
  381. return -1;
  382. c = SLang_getkey ();
  383. if (c == SLANG_GETKEY_ERROR)
  384. {
  385. fprintf (stderr,
  386. "SLang_getkey returned SLANG_GETKEY_ERROR\n"
  387. "Assuming EOF on stdin and exiting\n");
  388. exit (EXIT_FAILURE);
  389. }
  390. return c;
  391. }
  392. /* --------------------------------------------------------------------------------------------- */
  393. int
  394. tty_reset_screen (void)
  395. {
  396. SLsmg_reset_smg ();
  397. return 0; /* OK */
  398. }
  399. /* --------------------------------------------------------------------------------------------- */
  400. void
  401. tty_touch_screen (void)
  402. {
  403. SLsmg_touch_lines (0, LINES);
  404. }
  405. /* --------------------------------------------------------------------------------------------- */
  406. void
  407. tty_gotoyx (int y, int x)
  408. {
  409. SLsmg_gotorc (y, x);
  410. }
  411. /* --------------------------------------------------------------------------------------------- */
  412. void
  413. tty_getyx (int *py, int *px)
  414. {
  415. *py = SLsmg_get_row ();
  416. *px = SLsmg_get_column ();
  417. }
  418. /* --------------------------------------------------------------------------------------------- */
  419. void
  420. tty_draw_hline (int y, int x, int ch, int len)
  421. {
  422. int x1;
  423. if (y < 0 || y >= LINES || x >= COLS)
  424. return;
  425. x1 = x;
  426. if (x < 0)
  427. {
  428. len += x;
  429. if (len <= 0)
  430. return;
  431. x = 0;
  432. }
  433. if (ch == ACS_HLINE)
  434. ch = mc_tty_frm[MC_TTY_FRM_HORIZ];
  435. if (ch == 0)
  436. ch = ACS_HLINE;
  437. SLsmg_gotorc (y, x);
  438. if (ch == ACS_HLINE)
  439. SLsmg_draw_hline (len);
  440. else
  441. while (len-- != 0)
  442. tty_print_char (ch);
  443. SLsmg_gotorc (y, x1);
  444. }
  445. /* --------------------------------------------------------------------------------------------- */
  446. void
  447. tty_draw_vline (int y, int x, int ch, int len)
  448. {
  449. int y1;
  450. if (x < 0 || x >= COLS || y >= LINES)
  451. return;
  452. y1 = y;
  453. if (y < 0)
  454. {
  455. len += y;
  456. if (len <= 0)
  457. return;
  458. y = 0;
  459. }
  460. if (ch == ACS_VLINE)
  461. ch = mc_tty_frm[MC_TTY_FRM_VERT];
  462. if (ch == 0)
  463. ch = ACS_VLINE;
  464. SLsmg_gotorc (y, x);
  465. if (ch == ACS_VLINE)
  466. SLsmg_draw_vline (len);
  467. else
  468. {
  469. int pos = 0;
  470. while (len-- != 0)
  471. {
  472. SLsmg_gotorc (y + pos, x);
  473. tty_print_char (ch);
  474. pos++;
  475. }
  476. }
  477. SLsmg_gotorc (y1, x);
  478. }
  479. /* --------------------------------------------------------------------------------------------- */
  480. void
  481. tty_fill_region (int y, int x, int rows, int cols, unsigned char ch)
  482. {
  483. SLsmg_fill_region (y, x, rows, cols, ch);
  484. }
  485. /* --------------------------------------------------------------------------------------------- */
  486. void
  487. tty_set_alt_charset (gboolean alt_charset)
  488. {
  489. SLsmg_set_char_set ((int) alt_charset);
  490. }
  491. /* --------------------------------------------------------------------------------------------- */
  492. void
  493. tty_display_8bit (gboolean what)
  494. {
  495. SLsmg_Display_Eight_Bit = what ? 128 : 160;
  496. }
  497. /* --------------------------------------------------------------------------------------------- */
  498. void
  499. tty_print_char (int c)
  500. {
  501. SLsmg_write_char ((SLwchar_Type) ((unsigned int) c));
  502. }
  503. /* --------------------------------------------------------------------------------------------- */
  504. void
  505. tty_print_alt_char (int c, gboolean single)
  506. {
  507. #define DRAW(x, y) (x == y) \
  508. ? SLsmg_draw_object (SLsmg_get_row(), SLsmg_get_column(), x) \
  509. : SLsmg_write_char ((unsigned int) y)
  510. switch (c)
  511. {
  512. case ACS_VLINE:
  513. DRAW (c, mc_tty_frm[single ? MC_TTY_FRM_VERT : MC_TTY_FRM_DVERT]);
  514. break;
  515. case ACS_HLINE:
  516. DRAW (c, mc_tty_frm[single ? MC_TTY_FRM_HORIZ : MC_TTY_FRM_DHORIZ]);
  517. break;
  518. case ACS_LTEE:
  519. DRAW (c, mc_tty_frm[single ? MC_TTY_FRM_LEFTMIDDLE : MC_TTY_FRM_DLEFTMIDDLE]);
  520. break;
  521. case ACS_RTEE:
  522. DRAW (c, mc_tty_frm[single ? MC_TTY_FRM_RIGHTMIDDLE : MC_TTY_FRM_DRIGHTMIDDLE]);
  523. break;
  524. case ACS_ULCORNER:
  525. DRAW (c, mc_tty_frm[single ? MC_TTY_FRM_LEFTTOP : MC_TTY_FRM_DLEFTTOP]);
  526. break;
  527. case ACS_LLCORNER:
  528. DRAW (c, mc_tty_frm[single ? MC_TTY_FRM_LEFTBOTTOM : MC_TTY_FRM_DLEFTBOTTOM]);
  529. break;
  530. case ACS_URCORNER:
  531. DRAW (c, mc_tty_frm[single ? MC_TTY_FRM_RIGHTTOP : MC_TTY_FRM_DRIGHTTOP]);
  532. break;
  533. case ACS_LRCORNER:
  534. DRAW (c, mc_tty_frm[single ? MC_TTY_FRM_RIGHTBOTTOM : MC_TTY_FRM_DRIGHTBOTTOM]);
  535. break;
  536. case ACS_PLUS:
  537. DRAW (c, mc_tty_frm[MC_TTY_FRM_CROSS]);
  538. break;
  539. default:
  540. SLsmg_write_char ((unsigned int) c);
  541. }
  542. #undef DRAW
  543. }
  544. /* --------------------------------------------------------------------------------------------- */
  545. void
  546. tty_print_anychar (int c)
  547. {
  548. char str[6 + 1];
  549. if (c > 255)
  550. {
  551. int res = g_unichar_to_utf8 (c, str);
  552. if (res == 0)
  553. {
  554. str[0] = '.';
  555. str[1] = '\0';
  556. }
  557. else
  558. {
  559. str[res] = '\0';
  560. }
  561. SLsmg_write_string ((char *) str_term_form (str));
  562. }
  563. else
  564. {
  565. if (!is_printable (c))
  566. c = '.';
  567. SLsmg_write_char ((SLwchar_Type) ((unsigned int) c));
  568. }
  569. }
  570. /* --------------------------------------------------------------------------------------------- */
  571. void
  572. tty_print_string (const char *s)
  573. {
  574. SLsmg_write_string ((char *) str_term_form (s));
  575. }
  576. /* --------------------------------------------------------------------------------------------- */
  577. void
  578. tty_printf (const char *fmt, ...)
  579. {
  580. va_list args;
  581. va_start (args, fmt);
  582. SLsmg_vprintf ((char *) fmt, args);
  583. va_end (args);
  584. }
  585. /* --------------------------------------------------------------------------------------------- */
  586. char *
  587. tty_tgetstr (const char *cap)
  588. {
  589. return SLtt_tgetstr ((char *) cap);
  590. }
  591. /* --------------------------------------------------------------------------------------------- */
  592. void
  593. tty_refresh (void)
  594. {
  595. SLsmg_refresh ();
  596. }
  597. /* --------------------------------------------------------------------------------------------- */
  598. void
  599. tty_beep (void)
  600. {
  601. SLtt_beep ();
  602. }
  603. /* --------------------------------------------------------------------------------------------- */