tty.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. extern void tty_beep (void);
  54. /*** declarations of public functions ************************************************************/
  55. /* {{{ Input }}} */
  56. extern int reset_hp_softkeys;
  57. extern gboolean tty_check_term (gboolean force_xterm);
  58. extern void tty_init (gboolean slow, gboolean ugly_lines, gboolean mouse_enable,
  59. gboolean is_xterm);
  60. extern void tty_shutdown (void);
  61. extern gboolean tty_is_slow (void);
  62. extern void tty_start_interrupt_key (void);
  63. extern void tty_enable_interrupt_key (void);
  64. extern void tty_disable_interrupt_key (void);
  65. extern gboolean tty_got_interrupt (void);
  66. extern void tty_reset_prog_mode (void);
  67. extern void tty_reset_shell_mode (void);
  68. extern void tty_raw_mode (void);
  69. extern void tty_noraw_mode (void);
  70. extern void tty_noecho (void);
  71. extern int tty_flush_input (void);
  72. extern void tty_keypad (gboolean set);
  73. extern void tty_nodelay (gboolean set);
  74. extern int tty_baudrate (void);
  75. extern int tty_lowlevel_getch (void);
  76. /* {{{ Output }}} */
  77. /*
  78. The output functions do not check themselves for screen overflows,
  79. so make sure that you never write more than what fits on the screen.
  80. While SLang provides such a feature, ncurses does not.
  81. */
  82. extern int tty_reset_screen (void);
  83. extern void tty_touch_screen (void);
  84. extern void tty_gotoyx (int y, int x);
  85. extern void tty_getyx (int *py, int *px);
  86. extern void tty_set_alt_charset (gboolean alt_charset);
  87. extern void tty_display_8bit (gboolean what);
  88. extern void tty_print_char (int c);
  89. extern void tty_print_alt_char (int c, gboolean single);
  90. extern void tty_print_anychar (int c);
  91. extern void tty_print_string (const char *s);
  92. extern void tty_printf (const char *s, ...);
  93. extern void tty_print_one_vline (gboolean single);
  94. extern void tty_print_one_hline (gboolean single);
  95. extern void tty_draw_hline (int y, int x, int ch, int len);
  96. extern void tty_draw_vline (int y, int x, int ch, int len);
  97. extern void tty_draw_box (int y, int x, int rows, int cols, gboolean single);
  98. extern void tty_fill_region (int y, int x, int rows, int cols, unsigned char ch);
  99. extern void tty_refresh (void);
  100. extern void tty_setup_sigwinch (void (*handler) (int));
  101. extern int mc_tty_normalize_lines_char (const char *);
  102. /*** inline functions ****************************************************************************/
  103. #endif /* MC_TTY_H */