tty.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /** \file tty.h
  2. * \brief Header: %interface to the terminal controlling library
  3. *
  4. * This file is the %interface to the terminal controlling library:
  5. * slang or ncurses. It provides an additional layer of abstraction
  6. * above the "real" libraries to keep the number of ifdefs in the other
  7. * files small.
  8. */
  9. #ifndef MC__TTY_H
  10. #define MC__TTY_H
  11. #include "lib/global.h" /* include <glib.h> */
  12. #ifdef HAVE_SLANG
  13. #include "tty-slang.h"
  14. #else
  15. #include "tty-ncurses.h"
  16. #endif
  17. /*** typedefs(not structures) and defined constants **********************************************/
  18. #define KEY_KP_ADD 4001
  19. #define KEY_KP_SUBTRACT 4002
  20. #define KEY_KP_MULTIPLY 4003
  21. /*** enums ***************************************************************************************/
  22. typedef enum
  23. {
  24. /* single lines */
  25. MC_TTY_FRM_VERT,
  26. MC_TTY_FRM_HORIZ,
  27. MC_TTY_FRM_LEFTTOP,
  28. MC_TTY_FRM_RIGHTTOP,
  29. MC_TTY_FRM_LEFTBOTTOM,
  30. MC_TTY_FRM_RIGHTBOTTOM,
  31. MC_TTY_FRM_TOPMIDDLE,
  32. MC_TTY_FRM_BOTTOMMIDDLE,
  33. MC_TTY_FRM_LEFTMIDDLE,
  34. MC_TTY_FRM_RIGHTMIDDLE,
  35. MC_TTY_FRM_CROSS,
  36. /* double lines */
  37. MC_TTY_FRM_DVERT,
  38. MC_TTY_FRM_DHORIZ,
  39. MC_TTY_FRM_DLEFTTOP,
  40. MC_TTY_FRM_DRIGHTTOP,
  41. MC_TTY_FRM_DLEFTBOTTOM,
  42. MC_TTY_FRM_DRIGHTBOTTOM,
  43. MC_TTY_FRM_DTOPMIDDLE,
  44. MC_TTY_FRM_DBOTTOMMIDDLE,
  45. MC_TTY_FRM_DLEFTMIDDLE,
  46. MC_TTY_FRM_DRIGHTMIDDLE,
  47. MC_TTY_FRM_MAX
  48. } mc_tty_frm_t;
  49. /*** structures declarations (and typedefs of structures)*****************************************/
  50. /*** global variables defined in .c file *********************************************************/
  51. extern int mc_tty_frm[];
  52. extern char *tty_tgetstr (const char *name);
  53. /*** declarations of public functions ************************************************************/
  54. extern void tty_beep (void);
  55. /* {{{ Input }}} */
  56. extern gboolean tty_check_term (gboolean force_xterm);
  57. extern void tty_init (gboolean mouse_enable, gboolean is_xterm);
  58. extern void tty_shutdown (void);
  59. extern void tty_start_interrupt_key (void);
  60. extern void tty_enable_interrupt_key (void);
  61. extern void tty_disable_interrupt_key (void);
  62. extern gboolean tty_got_interrupt (void);
  63. extern void tty_reset_prog_mode (void);
  64. extern void tty_reset_shell_mode (void);
  65. extern void tty_raw_mode (void);
  66. extern void tty_noraw_mode (void);
  67. extern void tty_noecho (void);
  68. extern int tty_flush_input (void);
  69. extern void tty_keypad (gboolean set);
  70. extern void tty_nodelay (gboolean set);
  71. extern int tty_baudrate (void);
  72. /* {{{ Output }}} */
  73. /*
  74. The output functions do not check themselves for screen overflows,
  75. so make sure that you never write more than what fits on the screen.
  76. While SLang provides such a feature, ncurses does not.
  77. */
  78. extern int tty_reset_screen (void);
  79. extern void tty_touch_screen (void);
  80. extern void tty_gotoyx (int y, int x);
  81. extern void tty_getyx (int *py, int *px);
  82. extern void tty_set_alt_charset (gboolean alt_charset);
  83. extern void tty_display_8bit (gboolean what);
  84. extern void tty_print_char (int c);
  85. extern void tty_print_alt_char (int c, gboolean single);
  86. extern void tty_print_anychar (int c);
  87. extern void tty_print_string (const char *s);
  88. /* *INDENT-OFF* */
  89. extern void tty_printf (const char *s, ...) G_GNUC_PRINTF (1, 2);
  90. /* *INDENT-ON* */
  91. extern void tty_print_one_vline (gboolean single);
  92. extern void tty_print_one_hline (gboolean single);
  93. extern void tty_draw_hline (int y, int x, int ch, int len);
  94. extern void tty_draw_vline (int y, int x, int ch, int len);
  95. extern void tty_draw_box (int y, int x, int rows, int cols, gboolean single);
  96. extern void tty_fill_region (int y, int x, int rows, int cols, unsigned char ch);
  97. extern int tty_resize (int fd);
  98. extern void tty_refresh (void);
  99. extern void tty_change_screen_size (void);
  100. extern int mc_tty_normalize_lines_char (const char *);
  101. extern void tty_enter_ca_mode (void);
  102. extern void tty_exit_ca_mode (void);
  103. /*** inline functions ****************************************************************************/
  104. #endif /* MC_TTY_H */