1 /* Midnight Commander Tk initialization.
2 Copyright (C) 1995 Miguel de Icaza
3 Copyright (C) 1995 Jakub Jelinek
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
21 #include "tty.h" /* If you wonder why, read the comment below */
24 /* The tty.h file is included since we try to use as much object code
25 * from the curses distribution as possible so we need to send back
26 * the same constants that the code expects on the non-X version
27 * of the code. The constants may be the ones from curses/ncurses
28 * or our macro definitions for slang
31 /* Describes the key code and the keysym name returned by X
32 * In case we found many keyboard problems with the Fnn keys
33 * we can allways remove them and put them on the mc.tcl file
36 static key_code_name_t x_keys
[] = {
38 { KEY_RIGHT
, "Right" },
46 { KEY_PPAGE
, "Prior" },
47 { KEY_NPAGE
, "Next" },
54 { KEY_BACKSPACE
, "Delete" },
57 { KEY_BACKSPACE
, "BackSpace" },
68 { 0, 0} /* terminator */
71 int lookup_keysym (char *s
)
75 for (i
= 0; x_keys
[i
].name
; i
++){
76 if (!strcmp (s
, x_keys
[i
].name
))
77 return (x_keys
[i
].code
);
83 #if TCL_MAJOR_VERSION > 7
84 /* Tcl 8.xx support */
86 void add_select_channel (int fd
, select_fn callback
, void *info
)
88 Tcl_CreateFileHandler (fd
, TCL_READABLE
, (Tcl_FileProc
*) callback
, 0);
91 void delete_select_channel (int fd
)
93 Tcl_DeleteFileHandler (fd
);
97 /* Tcl 7.xx support */
99 void add_select_channel (int fd
, select_fn callback
, void *info
)
103 handle
= Tcl_GetFile ((ClientData
) fd
, TCL_UNIX_FD
);
104 Tcl_CreateFileHandler (handle
, TCL_READABLE
, (Tcl_FileProc
*) callback
, 0);
107 void delete_select_channel (int fd
)
111 handle
= Tcl_GetFile ((ClientData
) fd
, TCL_UNIX_FD
);
112 Tcl_DeleteFileHandler (handle
);
113 Tcl_FreeFile (handle
);