Mercurial > hg > xemacs-beta
annotate src/device-tty.c @ 5925:08cfc8f77fb6 cygwin
make space for long ptr, and store as such, for frame in WINDOW data,
add a bit more debugging to debug-mswindow,
Vin Shelton patch to fix M-x shell
| author | Henry Thompson <ht@markup.co.uk> |
|---|---|
| date | Fri, 27 Feb 2015 17:41:20 +0000 |
| parents | 56144c8593a8 |
| children |
| rev | line source |
|---|---|
| 428 | 1 /* TTY device functions. |
| 2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois. | |
| 3 Copyright (C) 1994, 1995 Free Software Foundation, Inc. | |
| 5043 | 4 Copyright (C) 1996, 2010 Ben Wing. |
| 428 | 5 |
| 6 This file is part of XEmacs. | |
| 7 | |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5169
diff
changeset
|
8 XEmacs is free software: you can redistribute it and/or modify it |
| 428 | 9 under the terms of the GNU General Public License as published by the |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5169
diff
changeset
|
10 Free Software Foundation, either version 3 of the License, or (at your |
|
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5169
diff
changeset
|
11 option) any later version. |
| 428 | 12 |
| 13 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
| 14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 16 for more details. | |
| 17 | |
| 18 You should have received a copy of the GNU General Public License | |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5169
diff
changeset
|
19 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */ |
| 428 | 20 |
| 21 /* Synched up with: Not in FSF. */ | |
| 22 | |
| 23 /* Authors: Ben Wing and Chuck Thompson. */ | |
| 24 | |
| 25 #include <config.h> | |
| 26 #include "lisp.h" | |
| 27 | |
| 872 | 28 #include "device-impl.h" |
| 428 | 29 #include "events.h" |
| 30 #include "faces.h" | |
| 31 #include "frame.h" | |
| 32 #include "lstream.h" | |
| 33 #include "redisplay.h" | |
| 34 #include "sysdep.h" | |
| 35 | |
| 872 | 36 #include "console-tty-impl.h" |
| 800 | 37 #include "console-stream.h" |
| 38 | |
| 558 | 39 #include "sysfile.h" |
| 428 | 40 #include "syssignal.h" /* for SIGWINCH */ |
| 41 | |
|
4477
e34711681f30
Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents:
3092
diff
changeset
|
42 Lisp_Object Qmake_device_early_tty_entry_point; |
| 428 | 43 |
| 44 | |
| 3092 | 45 #ifdef NEW_GC |
| 46 static const struct memory_description tty_device_data_description_1 [] = { | |
| 47 { XD_END } | |
| 48 }; | |
| 49 | |
|
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4477
diff
changeset
|
50 DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT ("tty-device", tty_device, |
|
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4477
diff
changeset
|
51 0, tty_device_data_description_1, |
|
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4477
diff
changeset
|
52 Lisp_Tty_Device); |
| 3092 | 53 #endif /* NEW_GC */ |
| 54 | |
| 428 | 55 static void |
| 56 allocate_tty_device_struct (struct device *d) | |
| 57 { | |
| 3092 | 58 #ifdef NEW_GC |
|
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
59 d->device_data = XTTY_DEVICE (ALLOC_NORMAL_LISP_OBJECT (tty_device)); |
| 3092 | 60 #else /* not NEW_GC */ |
| 428 | 61 d->device_data = xnew_and_zero (struct tty_device); |
| 3092 | 62 #endif /* not NEW_GC */ |
| 428 | 63 } |
| 64 | |
| 65 static void | |
| 2286 | 66 tty_init_device (struct device *d, Lisp_Object UNUSED (props)) |
| 428 | 67 { |
| 68 struct console *con = XCONSOLE (DEVICE_CONSOLE (d)); | |
| 69 Lisp_Object terminal_type = CONSOLE_TTY_DATA (con)->terminal_type; | |
| 70 | |
|
4477
e34711681f30
Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents:
3092
diff
changeset
|
71 /* Run part of the elisp side of the TTY device initialization. |
|
e34711681f30
Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents:
3092
diff
changeset
|
72 The post-init is run in the tty_finish_init_device() method. */ |
|
e34711681f30
Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents:
3092
diff
changeset
|
73 call0 (Qmake_device_early_tty_entry_point); |
|
e34711681f30
Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents:
3092
diff
changeset
|
74 |
| 428 | 75 DEVICE_INFD (d) = CONSOLE_TTY_DATA (con)->infd; |
| 76 DEVICE_OUTFD (d) = CONSOLE_TTY_DATA (con)->outfd; | |
| 77 | |
| 78 allocate_tty_device_struct (d); | |
| 79 init_baud_rate (d); | |
| 80 | |
| 81 switch (init_tty_for_redisplay (d, (char *) XSTRING_DATA (terminal_type))) | |
| 82 { | |
| 83 #if 0 | |
| 84 case TTY_UNABLE_OPEN_DATABASE: | |
| 85 suppress_early_error_handler_backtrace = 1; | |
| 563 | 86 signal_error (Qio_error, "Can't access terminal information database", Qunbound); |
| 428 | 87 break; |
| 88 #endif | |
| 89 case TTY_TYPE_UNDEFINED: | |
| 90 suppress_early_error_handler_backtrace = 1; | |
| 563 | 91 signal_error (Qio_error, "Terminal type undefined (or can't access database?)", |
| 92 terminal_type); | |
| 428 | 93 break; |
| 94 case TTY_TYPE_INSUFFICIENT: | |
| 95 suppress_early_error_handler_backtrace = 1; | |
| 563 | 96 signal_error (Qio_error, "Terminal type not powerful enough to run Emacs", |
| 97 terminal_type); | |
| 428 | 98 break; |
| 99 case TTY_SIZE_UNSPECIFIED: | |
| 100 suppress_early_error_handler_backtrace = 1; | |
| 563 | 101 signal_error (Qio_error, "Can't determine window size of terminal", Qunbound); |
| 428 | 102 break; |
| 103 case TTY_INIT_SUCCESS: | |
| 104 break; | |
| 105 default: | |
| 2500 | 106 ABORT (); |
| 428 | 107 } |
| 108 | |
| 109 init_one_device (d); | |
| 110 } | |
| 111 | |
| 3092 | 112 #ifndef NEW_GC |
| 428 | 113 static void |
| 114 free_tty_device_struct (struct device *d) | |
| 115 { | |
| 1726 | 116 if (d->device_data) |
|
5169
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5127
diff
changeset
|
117 { |
|
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5127
diff
changeset
|
118 xfree (d->device_data); |
|
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5127
diff
changeset
|
119 d->device_data = 0; |
|
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5127
diff
changeset
|
120 } |
| 428 | 121 } |
| 122 | |
| 123 static void | |
| 124 tty_delete_device (struct device *d) | |
| 125 { | |
| 126 free_tty_device_struct (d); | |
| 127 } | |
| 3092 | 128 #endif /* not NEW_GC */ |
| 428 | 129 |
| 130 #ifdef SIGWINCH | |
| 131 | |
| 132 static SIGTYPE | |
| 2286 | 133 tty_device_size_change_signal (int UNUSED (signo)) |
| 428 | 134 { |
| 135 int old_errno = errno; | |
| 136 asynch_device_change_pending++; | |
| 137 #ifdef HAVE_UNIXOID_EVENT_LOOP | |
| 138 signal_fake_event (); | |
| 139 #endif | |
| 140 EMACS_REESTABLISH_SIGNAL (SIGWINCH, tty_device_size_change_signal); | |
| 141 errno = old_errno; | |
| 142 SIGRETURN; | |
| 143 } | |
| 144 | |
| 145 /* frame_change_signal does nothing but set a flag that it was called. | |
| 146 When redisplay is called, it will notice that the flag is set and | |
| 147 call handle_pending_device_size_change to do the actual work. */ | |
| 148 static void | |
| 149 tty_asynch_device_change (void) | |
| 150 { | |
| 151 Lisp_Object devcons, concons; | |
| 152 | |
| 153 DEVICE_LOOP_NO_BREAK (devcons, concons) | |
| 154 { | |
| 155 int width, height; | |
| 156 Lisp_Object tail; | |
| 157 struct device *d = XDEVICE (XCAR (devcons)); | |
| 158 struct console *con = XCONSOLE (DEVICE_CONSOLE (d)); | |
| 159 | |
| 160 if (!DEVICE_TTY_P (d)) | |
| 161 continue; | |
| 162 | |
| 163 get_tty_device_size (d, &width, &height); | |
| 164 if (width > 0 && height > 0 | |
| 165 && (CONSOLE_TTY_DATA (con)->width != width | |
| 166 || CONSOLE_TTY_DATA (con)->height != height)) | |
| 167 { | |
| 168 CONSOLE_TTY_DATA (con)->width = width; | |
| 169 CONSOLE_TTY_DATA (con)->height = height; | |
| 170 | |
| 171 for (tail = DEVICE_FRAME_LIST (d); | |
| 172 !NILP (tail); | |
| 173 tail = XCDR (tail)) | |
| 174 { | |
| 175 struct frame *f = XFRAME (XCAR (tail)); | |
| 176 | |
| 177 /* We know the frame is tty because we made sure that the | |
| 178 device is tty. */ | |
| 5043 | 179 change_frame_size (f, width, height, 1); |
| 428 | 180 } |
| 181 } | |
| 182 } | |
| 183 } | |
| 184 | |
| 185 #endif /* SIGWINCH */ | |
| 186 | |
| 187 static Lisp_Object | |
| 188 tty_device_system_metrics (struct device *d, | |
| 189 enum device_metrics m) | |
| 190 { | |
| 191 struct console *con = XCONSOLE (DEVICE_CONSOLE (d)); | |
| 192 switch (m) | |
| 193 { | |
| 194 case DM_size_device: | |
|
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
195 return Fcons (make_fixnum (CONSOLE_TTY_DATA (con)->width), |
|
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
196 make_fixnum (CONSOLE_TTY_DATA (con)->height)); |
|
5398
5256fedd50e6
issue 757 - tty device metric for num-color-cells
Jeff Sparkes <jsparkes@gmail.com>
parents:
5169
diff
changeset
|
197 case DM_num_bit_planes: |
|
5401
4486ba63476b
Fix compile issues for C89 compilers. Use log() instead of log2().
Jeff Sparkes <jsparkes@gmail.com>
parents:
5398
diff
changeset
|
198 { |
|
4486ba63476b
Fix compile issues for C89 compilers. Use log() instead of log2().
Jeff Sparkes <jsparkes@gmail.com>
parents:
5398
diff
changeset
|
199 EMACS_INT l2 = (EMACS_INT) (log (CONSOLE_TTY_DATA (con)->colors) |
|
4486ba63476b
Fix compile issues for C89 compilers. Use log() instead of log2().
Jeff Sparkes <jsparkes@gmail.com>
parents:
5398
diff
changeset
|
200 / log (2)); |
|
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
201 return make_fixnum (l2); |
|
5401
4486ba63476b
Fix compile issues for C89 compilers. Use log() instead of log2().
Jeff Sparkes <jsparkes@gmail.com>
parents:
5398
diff
changeset
|
202 } |
|
5398
5256fedd50e6
issue 757 - tty device metric for num-color-cells
Jeff Sparkes <jsparkes@gmail.com>
parents:
5169
diff
changeset
|
203 case DM_num_color_cells: |
|
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5475
diff
changeset
|
204 return make_fixnum (CONSOLE_TTY_DATA (con)->colors); |
| 428 | 205 default: /* No such device metric property for TTY devices */ |
| 206 return Qunbound; | |
| 207 } | |
| 208 } | |
| 209 | |
| 210 /************************************************************************/ | |
| 211 /* initialization */ | |
| 212 /************************************************************************/ | |
| 213 | |
| 214 void | |
| 215 syms_of_device_tty (void) | |
| 216 { | |
| 3092 | 217 #ifdef NEW_GC |
|
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4477
diff
changeset
|
218 INIT_LISP_OBJECT (tty_device); |
| 3092 | 219 #endif /* NEW_GC */ |
| 220 | |
|
4477
e34711681f30
Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents:
3092
diff
changeset
|
221 DEFSYMBOL (Qmake_device_early_tty_entry_point); |
| 428 | 222 } |
| 223 | |
| 224 void | |
| 225 console_type_create_device_tty (void) | |
| 226 { | |
| 227 /* device methods */ | |
| 228 CONSOLE_HAS_METHOD (tty, init_device); | |
| 3092 | 229 #ifndef NEW_GC |
| 428 | 230 CONSOLE_HAS_METHOD (tty, delete_device); |
| 3092 | 231 #endif /* not NEW_GC */ |
| 428 | 232 #ifdef SIGWINCH |
| 233 CONSOLE_HAS_METHOD (tty, asynch_device_change); | |
| 234 #endif /* SIGWINCH */ | |
| 235 CONSOLE_HAS_METHOD (tty, device_system_metrics); | |
| 236 } | |
| 237 | |
| 238 void | |
| 239 init_device_tty (void) | |
| 240 { | |
| 241 #ifdef SIGWINCH | |
| 242 if (initialized && !noninteractive) | |
| 613 | 243 EMACS_SIGNAL (SIGWINCH, tty_device_size_change_signal); |
| 428 | 244 #endif /* SIGWINCH */ |
| 245 } |
