2 Terminal management xterm and rxvt support
4 Copyright (C) 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
6 The Free Software Foundation, Inc.
9 Andrew Borodin <aborodin@vmail.ru>, 2009.
11 This file is part of the Midnight Commander.
13 The Midnight Commander is free software: you can redistribute it
14 and/or modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation, either version 3 of the License,
16 or (at your option) any later version.
18 The Midnight Commander is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program. If not, see <http://www.gnu.org/licenses/>.
28 * \brief Source: Terminal management xterm and rxvt support
36 #include <sys/types.h>
39 #include "lib/global.h"
40 #include "lib/util.h" /* is_printable() */
41 #include "tty-internal.h"
42 #include "tty.h" /* tty_gotoyx, tty_print_char */
45 /*** global variables ****************************************************************************/
50 /*** file scope macro definitions ****************************************************************/
52 /*** file scope type declarations ****************************************************************/
54 /*** file scope variables ************************************************************************/
56 static gboolean rxvt_extensions
= FALSE
;
58 /*** file scope functions ************************************************************************/
59 /* --------------------------------------------------------------------------------------------- */
61 /* my own wierd protocol base 16 - paul */
68 while (read (0, &c
, 1) != 1);
72 while (read (0, &c
, 1) != 1);
77 /* --------------------------------------------------------------------------------------------- */
89 return select (1, &fds
, 0, 0, &tv
);
92 /* --------------------------------------------------------------------------------------------- */
93 /*** public functions ****************************************************************************/
94 /* --------------------------------------------------------------------------------------------- */
97 do_enter_ca_mode (void)
99 if (mc_global
.tty
.xterm_flag
&& smcup
!= NULL
)
101 fprintf (stdout
, /* ESC_STR ")0" */ ESC_STR
"7" ESC_STR
"[?47h");
106 /* --------------------------------------------------------------------------------------------- */
109 do_exit_ca_mode (void)
111 if (mc_global
.tty
.xterm_flag
&& rmcup
!= NULL
)
113 fprintf (stdout
, ESC_STR
"[?47l" ESC_STR
"8" ESC_STR
"[m");
118 /* --------------------------------------------------------------------------------------------- */
121 show_rxvt_contents (int starty
, unsigned char y1
, unsigned char y2
)
124 int bytes
, i
, j
, cols
= 0;
126 y1
+= (mc_global
.keybar_visible
!= 0); /* i don't knwo why we need this - paul */
127 y2
+= (mc_global
.keybar_visible
!= 0);
128 while (anything_ready ())
129 tty_lowlevel_getch ();
131 /* my own wierd protocol base 26 - paul */
132 printf (ESC_STR
"CL%c%c%c%c\n", (y1
/ 26) + 'A', (y1
% 26) + 'A', (y2
/ 26) + 'A',
135 bytes
= (y2
- y1
) * (COLS
+ 1) + 1; /* *should* be the number of bytes read */
137 k
= g_malloc (bytes
);
146 for (cols
= 1;; cols
++)
155 for (i
= 0; i
< j
; i
++)
158 tty_gotoyx (starty
+ (i
/ cols
), 0);
159 tty_print_char (is_printable (k
[i
]) ? k
[i
] : ' ');
164 /* --------------------------------------------------------------------------------------------- */
167 look_for_rxvt_extensions (void)
169 static gboolean been_called
= FALSE
;
173 const char *e
= getenv ("RXVT_EXT");
174 rxvt_extensions
= ((e
!= NULL
) && (strcmp (e
, "1.0") == 0));
179 mc_global
.tty
.console_flag
= '\004';
181 return rxvt_extensions
;
184 /* --------------------------------------------------------------------------------------------- */