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,
34 #include "main.h" /* for slow_terminal */
41 /*** file scope macro definitions **************************************/
48 /*** global variables **************************************************/
50 /*** file scope type declarations **************************************/
52 /*** file scope variables **********************************************/
54 static volatile sig_atomic_t got_interrupt
= 0;
56 /*** file scope functions **********************************************/
59 sigintr_handler(int signo
)
65 /*** public functions **************************************************/
68 tty_enable_interrupt_key(void)
73 act
.sa_handler
= sigintr_handler
;
74 sigemptyset (&act
.sa_mask
);
76 sigaction (SIGINT
, &act
, NULL
);
80 tty_disable_interrupt_key(void)
84 act
.sa_handler
= SIG_IGN
;
85 sigemptyset (&act
.sa_mask
);
87 sigaction (SIGINT
, &act
, NULL
);
91 tty_got_interrupt(void)
95 rv
= (got_interrupt
!= 0);
101 tty_gotoyx(int y
, int x
)
111 tty_getyx(int *py
, int *px
)
114 *px
= SLsmg_get_column();
115 *py
= SLsmg_get_row();
117 getyx(stdscr
, *py
, *px
);
128 tty_print_char(int c
)
131 /* We cannot use SLsmg_write_char here because the Debian and Redhat
132 * people thought changing the API of an external project was fun,
133 * especially when it depends on the preprocessor symbol UTF8 being
134 * defined or not. Congratulations! At least, they left the API call
135 * for SLsmg_write_nchars as it has always been.
140 SLsmg_write_nchars(&ch
, 1);
147 tty_print_alt_char(int c
)
150 SLsmg_draw_object(SLsmg_get_row(), SLsmg_get_column(), c
);
159 tty_print_string(const char *s
)
162 SLsmg_write_string(str_unconst(s
));
169 tty_print_one_hline(void)
174 tty_print_alt_char(ACS_HLINE
);
178 tty_print_one_vline(void)
183 tty_print_alt_char(ACS_VLINE
);
187 tty_print_hline(int top
, int left
, int length
)
191 tty_gotoyx(top
, left
);
192 for (i
= 0; i
< length
; i
++)
193 tty_print_one_hline();
197 tty_print_vline(int top
, int left
, int length
)
201 tty_gotoyx(top
, left
);
202 for (i
= 0; i
< length
; i
++) {
203 tty_gotoyx(top
+ i
, left
);
204 tty_print_one_vline();
209 tty_printf(const char *fmt
, ...)
215 SLsmg_vprintf(str_unconst(fmt
), args
);
217 vw_printw(stdscr
, fmt
, args
);
223 tty_tgetstr (const char *cap
)
226 return SLtt_tgetstr (str_unconst (cap
));
230 return tgetstr (str_unconst (cap
), &unused
);