2 Interface to the terminal controlling library.
4 Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
7 Roland Illig <roland.illig@gmx.de>, 2005.
9 This file is part of the Midnight Commander.
11 The Midnight Commander is free software; you can redistribute it
12 and/or modify it under the terms of the GNU General Public License as
13 published by the Free Software Foundation; either version 2 of the
14 License, or (at your option) any later version.
16 The Midnight Commander is distributed in the hope that it will be
17 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
18 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
28 * \brief Source: %interface to the terminal controlling library
38 #include "main.h" /* for slow_terminal */
41 #if defined(USE_NCURSES) || defined(USE_NCURSESW)
46 /*** file scope macro definitions **************************************/
53 /*** global variables **************************************************/
55 /*** file scope type declarations **************************************/
57 /*** file scope variables **********************************************/
59 static volatile sig_atomic_t got_interrupt
= 0;
61 /*** file scope functions **********************************************/
64 sigintr_handler(int signo
)
70 /*** public functions **************************************************/
73 tty_start_interrupt_key(void)
77 act
.sa_handler
= sigintr_handler
;
78 sigemptyset (&act
.sa_mask
);
79 act
.sa_flags
= SA_RESTART
;
80 sigaction (SIGINT
, &act
, NULL
);
84 tty_enable_interrupt_key(void)
88 act
.sa_handler
= sigintr_handler
;
89 sigemptyset (&act
.sa_mask
);
91 sigaction (SIGINT
, &act
, NULL
);
96 tty_disable_interrupt_key(void)
100 act
.sa_handler
= SIG_IGN
;
101 sigemptyset (&act
.sa_mask
);
103 sigaction (SIGINT
, &act
, NULL
);
107 tty_got_interrupt(void)
111 rv
= (got_interrupt
!= 0);
117 tty_gotoyx(int y
, int x
)
127 tty_getyx(int *py
, int *px
)
130 *px
= SLsmg_get_column();
131 *py
= SLsmg_get_row();
133 getyx(stdscr
, *py
, *px
);
144 tty_print_char(int c
)
147 /* We cannot use SLsmg_write_char here because the Debian and Redhat
148 * people thought changing the API of an external project was fun,
149 * especially when it depends on the preprocessor symbol UTF8 being
150 * defined or not. Congratulations! At least, they left the API call
151 * for SLsmg_write_nchars as it has always been.
156 SLsmg_write_nchars(&ch
, 1);
163 tty_print_alt_char(int c
)
166 SLsmg_draw_object(SLsmg_get_row(), SLsmg_get_column(), c
);
175 tty_print_string(const char *s
)
178 SLsmg_write_string (str_unconst (str_term_form (s
)));
180 addstr (str_term_form (s
));
185 tty_print_one_hline(void)
190 tty_print_alt_char(ACS_HLINE
);
194 tty_print_one_vline(void)
199 tty_print_alt_char(ACS_VLINE
);
203 tty_print_hline(int top
, int left
, int length
)
207 tty_gotoyx(top
, left
);
208 for (i
= 0; i
< length
; i
++)
209 tty_print_one_hline();
213 tty_print_vline(int top
, int left
, int length
)
217 tty_gotoyx(top
, left
);
218 for (i
= 0; i
< length
; i
++) {
219 tty_gotoyx(top
+ i
, left
);
220 tty_print_one_vline();
225 tty_printf(const char *fmt
, ...)
231 SLsmg_vprintf(str_unconst(fmt
), args
);
233 vw_printw(stdscr
, fmt
, args
);
239 tty_tgetstr (const char *cap
)
242 return SLtt_tgetstr (str_unconst (cap
));
246 return tgetstr (str_unconst (cap
), &unused
);