Manual pages: mcmcdiffmceditmcview

root/lib/tty/tty.h

/* [previous][next][first][last][top][bottom][index][help]  */

INCLUDED FROM


   1 
   2 /** \file tty.h
   3  *  \brief Header: %interface to the terminal controlling library
   4  *
   5  *  This file is the %interface to the terminal controlling library:
   6  *  slang or ncurses. It provides an additional layer of abstraction
   7  *  above the "real" libraries to keep the number of ifdefs in the other
   8  *  files small.
   9  */
  10 
  11 #ifndef MC__TTY_H
  12 #define MC__TTY_H
  13 
  14 #include "lib/global.h"  // include <glib.h>
  15 
  16 #ifdef HAVE_SLANG
  17 #include "tty-slang.h"
  18 #else
  19 #include "tty-ncurses.h"
  20 #endif
  21 
  22 /*** typedefs(not structures) and defined constants **********************************************/
  23 
  24 #define KEY_KP_ADD      4001
  25 #define KEY_KP_SUBTRACT 4002
  26 #define KEY_KP_MULTIPLY 4003
  27 
  28 // In UTF-8 locales it's always the gunichar.
  29 // In 8-bit locales it's either one of the MC_ACS_* special values for single frame characters,
  30 // or the 8-bit character code.
  31 typedef unsigned int mc_tty_char_t;
  32 
  33 /*** enums ***************************************************************************************/
  34 
  35 // These values always represent the given line drawing characters, in a common way regardless of
  36 // the underlying screen library. Only used in 8-bit mode, in UTF-8 the actual codepoint is used.
  37 // These values really have the type 'mc_tty_char_t', but enum cannot denote it.
  38 enum
  39 {
  40     // Even though these are only used in 8-bit mode, let's start the numbers above the highest
  41     // Unicode value to avoid any chance of confusion.
  42     MC_ACS_HLINE = 0x110000,  // ─
  43     MC_ACS_VLINE,             // │
  44     MC_ACS_ULCORNER,          // ┌
  45     MC_ACS_URCORNER,          // ┐
  46     MC_ACS_LLCORNER,          // └
  47     MC_ACS_LRCORNER,          // ┘
  48     MC_ACS_TTEE,              // ┬
  49     MC_ACS_BTEE,              // ┴
  50     MC_ACS_LTEE,              // ├
  51     MC_ACS_RTEE,              // ┤
  52     MC_ACS_PLUS,              // ┼
  53 };
  54 
  55 // These refer to the roles, the given positions of more prominent and less prominent boxes.
  56 // The actual characters, taken from the skin, may or may not match the role name.
  57 typedef enum
  58 {
  59     // single lines
  60     MC_TTY_FRM_HORIZ,
  61     MC_TTY_FRM_VERT,
  62     MC_TTY_FRM_LEFTTOP,
  63     MC_TTY_FRM_RIGHTTOP,
  64     MC_TTY_FRM_LEFTBOTTOM,
  65     MC_TTY_FRM_RIGHTBOTTOM,
  66     MC_TTY_FRM_TOPMIDDLE,
  67     MC_TTY_FRM_BOTTOMMIDDLE,
  68     MC_TTY_FRM_LEFTMIDDLE,
  69     MC_TTY_FRM_RIGHTMIDDLE,
  70     MC_TTY_FRM_CROSS,
  71 
  72     // double lines
  73     MC_TTY_FRM_DHORIZ,
  74     MC_TTY_FRM_DVERT,
  75     MC_TTY_FRM_DLEFTTOP,
  76     MC_TTY_FRM_DRIGHTTOP,
  77     MC_TTY_FRM_DLEFTBOTTOM,
  78     MC_TTY_FRM_DRIGHTBOTTOM,
  79     MC_TTY_FRM_DTOPMIDDLE,
  80     MC_TTY_FRM_DBOTTOMMIDDLE,
  81     MC_TTY_FRM_DLEFTMIDDLE,
  82     MC_TTY_FRM_DRIGHTMIDDLE,
  83 
  84     MC_TTY_FRM_MAX
  85 } mc_tty_frm_t;
  86 
  87 /*** structures declarations (and typedefs of structures)*****************************************/
  88 
  89 /*** global variables defined in .c file *********************************************************/
  90 
  91 // The actual characters used for frame drawing, as taken from the skin. Indexed by MC_TTY_FRM_*,
  92 // the values are either one of MCS_ACS_* or a character in the current locale.
  93 extern mc_tty_char_t mc_tty_frm[];
  94 
  95 extern int tty_tigetflag (const char *terminfo_cap, const char *termcap_cap);
  96 extern int tty_tigetnum (const char *terminfo_cap, const char *termcap_cap);
  97 extern char *tty_tigetstr (const char *terminfo_cap, const char *termcap_cap);
  98 
  99 /*** declarations of public functions ************************************************************/
 100 
 101 extern void tty_beep (void);
 102 
 103 /* {{{ Input }}} */
 104 
 105 extern gboolean tty_check_xterm_compat (gboolean force_xterm);
 106 extern void tty_init (gboolean mouse_enable, gboolean is_xterm);
 107 extern void tty_shutdown (void);
 108 
 109 extern void tty_start_interrupt_key (void);
 110 extern void tty_enable_interrupt_key (void);
 111 extern void tty_disable_interrupt_key (void);
 112 extern gboolean tty_got_interrupt (void);
 113 
 114 extern gboolean tty_got_winch (void);
 115 extern gboolean tty_flush_winch (void);
 116 
 117 extern void tty_reset_prog_mode (void);
 118 extern void tty_reset_shell_mode (void);
 119 
 120 extern void tty_raw_mode (void);
 121 extern void tty_noraw_mode (void);
 122 
 123 extern void tty_noecho (void);
 124 extern int tty_flush_input (void);
 125 
 126 extern void tty_keypad (gboolean set);
 127 extern void tty_nodelay (gboolean set);
 128 extern int tty_baudrate (void);
 129 
 130 /* {{{ Output }}} */
 131 
 132 /*
 133    The output functions do not check themselves for screen overflows,
 134    so make sure that you never write more than what fits on the screen.
 135    While SLang provides such a feature, ncurses does not.
 136  */
 137 
 138 extern int tty_reset_screen (void);
 139 extern void tty_touch_screen (void);
 140 
 141 extern void tty_gotoyx (int y, int x);
 142 extern void tty_getyx (int *py, int *px);
 143 
 144 extern void tty_display_8bit (gboolean what);
 145 extern void tty_print_char (mc_tty_char_t c);
 146 extern void tty_print_anychar (mc_tty_char_t c);
 147 extern void tty_print_string (const char *s);
 148 extern void tty_printf (const char *s, ...) G_GNUC_PRINTF (1, 2);
 149 
 150 extern void tty_print_one_vline (gboolean single);
 151 extern void tty_print_one_hline (gboolean single);
 152 extern void tty_draw_hline (int y, int x, mc_tty_char_t ch, int len);
 153 extern void tty_draw_vline (int y, int x, mc_tty_char_t ch, int len);
 154 extern void tty_draw_box (int y, int x, int rows, int cols, gboolean single);
 155 extern void tty_draw_box_shadow (int y, int x, int rows, int cols, int shadow_color);
 156 extern void tty_fill_region (int y, int x, int rows, int cols, unsigned char ch);
 157 
 158 extern int tty_resize (int fd);
 159 extern void tty_refresh (void);
 160 extern void tty_change_screen_size (void);
 161 
 162 /* Clear screen */
 163 extern void tty_clear_screen (void);
 164 
 165 extern void tty_enter_ca_mode (void);
 166 extern void tty_exit_ca_mode (void);
 167 
 168 /*** inline functions ****************************************************************************/
 169 
 170 #endif

/* [previous][next][first][last][top][bottom][index][help]  */