annotate src/msdos.c @ 13063:30ee606ce331

Fix display of Chinese date.
author Edward M. Reingold <reingold@emr.cs.iit.edu>
date Fri, 22 Sep 1995 19:36:26 +0000
parents 169d50e2ee4c
children b0de215331ba
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7666
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
1 /* MS-DOS specific C utilities.
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
2 Copyright (C) 1993, 1994 Free Software Foundation, Inc.
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4 This file is part of GNU Emacs.
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
10504
8a1bd0598b49 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 10501
diff changeset
8 the Free Software Foundation; either version 2, or (at your option)
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 any later version.
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 GNU General Public License for more details.
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19
7666
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
20 /* Contributed by Morten Welinder */
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
21
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 /* Note: some of the stuff here was taken from end of sysdep.c in demacs. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23
5980
a203b7c30300 Use <...> for config.h.
Richard M. Stallman <rms@gnu.org>
parents: 5503
diff changeset
24 #include <config.h>
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 #ifdef MSDOS
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 #include "lisp.h"
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 #include <stdio.h>
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 #include <stdlib.h>
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 #include <sys/param.h>
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 #include <sys/time.h>
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 #include <dos.h>
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 #include "dosfns.h"
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 #include "msdos.h"
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 #include "systime.h"
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 #include "termhooks.h"
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
37 #include "dispextern.h"
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
38 #include "termopts.h"
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 #include "frame.h"
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
40 #include "window.h"
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 #include <go32.h>
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 #include <pc.h>
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 #include <ctype.h>
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 /* #include <process.h> */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 /* Damn that local process.h! Instead we can define P_WAIT ourselves. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 #define P_WAIT 1
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 static int break_stat; /* BREAK check mode status. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 static int stdin_stat; /* stdin IOCTL status. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 static int extended_kbd; /* 101 (102) keyboard present. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 int have_mouse; /* Mouse present? */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 static int mouse_last_x;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 static int mouse_last_y;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
56 #define DO_TERMSCRIPT /* define if you want open-termscript to work on msdos */
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
57
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
58 /* Standard putchar may call _flsbuf which doesn't go through
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
59 fflush's overlayed internal_flush routine. */
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
60 #undef putchar
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
61 #define putchar(x) \
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
62 (--(stdout)->_cnt>=0? \
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
63 ((int)((unsigned char)((*(stdout)->_ptr++=(unsigned)(x))))): \
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
64 (internal_flush (stdout), --(stdout)->_cnt, *(stdout)->_ptr++=(unsigned)(x)))
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
65
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
66 static void
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
67 mouse_get_xy (int *x, int *y);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
68
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 /* Turn off Dos' Ctrl-C checking and inhibit interpretation of control chars
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 by Dos. Determine the keyboard type. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 int
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 dos_ttraw ()
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 union REGS inregs, outregs;
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
75 static int only_once = 1;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
76
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
77 if (only_once) {
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
78 inregs.h.ah = 0xc0;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
79 int86 (0x15, &inregs, &outregs);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
80 extended_kbd = (!outregs.x.cflag) && (outregs.h.ah == 0);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
81 }
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
82
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 break_stat = getcbrk ();
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 setcbrk (0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 install_ctrl_break_check ();
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
87 if (only_once)
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
88 have_mouse = mouse_init1 ();
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
89
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
90 inregs.x.ax = 0x4400; /* Get IOCTL status. */
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
91 inregs.x.bx = 0x00; /* 0 = stdin. */
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 intdos (&inregs, &outregs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 stdin_stat = outregs.h.dl;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
95 only_once = 0;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
96
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
97 inregs.x.dx = stdin_stat | 0x0020; /* raw mode */
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
98 inregs.x.ax = 0x4401; /* Set IOCTL status */
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 intdos (&inregs, &outregs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 return !outregs.x.cflag;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 /* Restore status of standard input and Ctrl-C checking. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 int
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 dos_ttcooked ()
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 union REGS inregs, outregs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 setcbrk (break_stat);
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
110 mouse_off ();
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 inregs.x.ax = 0x4401; /* Set IOCTL status. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 inregs.x.bx = 0x00; /* 0 = stdin. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 inregs.x.dx = stdin_stat;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 intdos (&inregs, &outregs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 return !outregs.x.cflag;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
119 /* generate a reliable event timestamp, KFS 1995-07-06 */
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
120
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
121 static unsigned long
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
122 event_timestamp ()
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
123 {
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
124 struct time t;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
125 unsigned long s;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
126
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
127 gettime (&t);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
128 s = t.ti_min;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
129 s *= 60;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
130 s += t.ti_sec;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
131 s *= 1000;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
132 s += t.ti_hund * 10;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
133
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
134 return s;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
135 }
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
136
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 static unsigned short
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 ibmpc_translate_map[] =
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 /* --------------- 00 to 0f --------------- */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 0, /* Ctrl Break */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 0xff1b, /* Escape */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 0xffb1, /* Keypad 1 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 0xffb2, /* Keypad 2 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 0xffb3, /* Keypad 3 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 0xffb4, /* Keypad 4 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 0xffb5, /* Keypad 5 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 0xffb6, /* Keypad 6 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 0xffb7, /* Keypad 7 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 0xffb8, /* Keypad 8 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 0xffb9, /* Keypad 9 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 0xffb0, /* Keypad 0 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 '-', '=',
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 0xff08, /* Backspace */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 0xff74, /* (Shift) Tab [Tab doesn't use this table] */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 /* --------------- 10 to 1f --------------- */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']',
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 0xff8d, /* Keypad Enter */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 0, /* Ctrl */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 'a', 's',
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 /* --------------- 20 to 2f --------------- */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`',
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 0, /* Left shift */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 '\\', 'z', 'x', 'c', 'v',
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 /* --------------- 30 to 3f --------------- */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 'b', 'n', 'm', ',', '.',
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 0xffaf, /* Grey / */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 0, /* Right shift */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 0xffaa, /* Grey * */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 0, /* Alt */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 ' ',
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 0, /* Caps Lock */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 0xffbe, /* F1 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 0xffbf, /* F2 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 0xffc0, /* F3 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 0xffc1, /* F4 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 0xffc2, /* F5 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 /* --------------- 40 to 4f --------------- */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 0xffc3, /* F6 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 0xffc4, /* F7 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 0xffc5, /* F8 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 0xffc6, /* F9 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 0xffc7, /* F10 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 0, /* Num Lock */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 0, /* Scroll Lock */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 0xff50, /* Home */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 0xff52, /* Up */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 0xff55, /* Page Up */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 0xffad, /* Grey - */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 0xff51, /* Left */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 0xffb5, /* Keypad 5 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 0xff53, /* Right */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 0xffab, /* Grey + */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 0xff57, /* End */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 /* --------------- 50 to 5f --------------- */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 0xff54, /* Down */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 0xff56, /* Page Down */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 0xff63, /* Insert */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 0xffff, /* Delete */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 0xffbe, /* (Shift) F1 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 0xffbf, /* (Shift) F2 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 0xffc0, /* (Shift) F3 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 0xffc1, /* (Shift) F4 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 0xffc2, /* (Shift) F5 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 0xffc3, /* (Shift) F6 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 0xffc4, /* (Shift) F7 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 0xffc5, /* (Shift) F8 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 0xffc6, /* (Shift) F9 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 0xffc7, /* (Shift) F10 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 0xffbe, /* (Ctrl) F1 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 0xffbf, /* (Ctrl) F2 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 /* --------------- 60 to 6f --------------- */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 0xffc0, /* (Ctrl) F3 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 0xffc1, /* (Ctrl) F4 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 0xffc2, /* (Ctrl) F5 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 0xffc3, /* (Ctrl) F6 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 0xffc4, /* (Ctrl) F7 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 0xffc5, /* (Ctrl) F8 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 0xffc6, /* (Ctrl) F9 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 0xffc7, /* (Ctrl) F10 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 0xffbe, /* (Alt) F1 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 0xffbf, /* (Alt) F2 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 0xffc0, /* (Alt) F3 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 0xffc1, /* (Alt) F4 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 0xffc2, /* (Alt) F5 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 0xffc3, /* (Alt) F6 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 0xffc4, /* (Alt) F7 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 0xffc5, /* (Alt) F8 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 /* --------------- 70 to 7f --------------- */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 0xffc6, /* (Alt) F9 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 0xffc7, /* (Alt) F10 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 0xff6d, /* (Ctrl) Sys Rq */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 0xff51, /* (Ctrl) Left */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 0xff53, /* (Ctrl) Right */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 0xff57, /* (Ctrl) End */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 0xff56, /* (Ctrl) Page Down */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 0xff50, /* (Ctrl) Home */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 '1', '2', '3', '4', '5', '6', '7', '8', /* (Alt) */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247 /* --------------- 80 to 8f --------------- */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248 '9', '0', '-', '=', /* (Alt) */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 0xff55, /* (Ctrl) Page Up */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 0xffc8, /* F11 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 0xffc9, /* F12 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 0xffc8, /* (Shift) F11 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 0xffc9, /* (Shift) F12 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 0xffc8, /* (Ctrl) F11 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 0xffc9, /* (Ctrl) F12 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 0xffc8, /* (Alt) F11 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 0xffc9, /* (Alt) F12 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 0xff52, /* (Ctrl) Up */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 0xffae, /* (Ctrl) Grey - */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 0xffb5, /* (Ctrl) Keypad 5 */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 /* --------------- 90 to 9f --------------- */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 0xffab, /* (Ctrl) Grey + */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 0xff54, /* (Ctrl) Down */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 0xff63, /* (Ctrl) Insert */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 0xffff, /* (Ctrl) Delete */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 0xff09, /* (Ctrl) Tab */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268 0xffaf, /* (Ctrl) Grey / */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 0xffaa, /* (Ctrl) Grey * */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 0xff50, /* (Alt) Home */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 0xff52, /* (Alt) Up */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 0xff55, /* (Alt) Page Up */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 0, /* NO KEY */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 0xff51, /* (Alt) Left */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 0, /* NO KEY */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 0xff53, /* (Alt) Right */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277 0, /* NO KEY */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 0xff57, /* (Alt) End */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 /* --------------- a0 to af --------------- */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281 0xff54, /* (Alt) Down */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 0xff56, /* (Alt) Page Down */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 0xff63, /* (Alt) Insert */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 0xffff, /* (Alt) Delete */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 0xffaf, /* (Alt) Grey / */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 0xff09, /* (Alt) Tab */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 0xff0d /* (Alt) Enter */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288 };
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290 /* Get a char from keyboard. Function keys are put into the event queue. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 static int
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 dos_rawgetc ()
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 struct input_event event;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 union REGS regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 int ctrl_p, alt_p, shift_p;
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
297
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 /* Calculate modifier bits */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 regs.h.ah = extended_kbd ? 0x12 : 0x02;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 int86 (0x16, &regs, &regs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 ctrl_p = ((regs.h.al & 4) != 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 shift_p = ((regs.h.al & 3) != 0);
7666
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
303 /* Please be very careful here not to break international keyboard support.
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
304 When Keyb.Com is loaded, the key marked `Alt Gr' is used for accessing
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
305 characters like { and } if their positions are overlaid. */
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306 alt_p = ((extended_kbd ? (regs.h.ah & 2) : (regs.h.al & 8)) != 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307
8194
b11f71df59d9 (dos_rawgetc): Use bios, not kbhit ().
Richard M. Stallman <rms@gnu.org>
parents: 8183
diff changeset
308 /* The following condition is equivalent to `kbhit ()', except that
b11f71df59d9 (dos_rawgetc): Use bios, not kbhit ().
Richard M. Stallman <rms@gnu.org>
parents: 8183
diff changeset
309 it uses the bios to do its job. This pleases DESQview/X. */
b11f71df59d9 (dos_rawgetc): Use bios, not kbhit ().
Richard M. Stallman <rms@gnu.org>
parents: 8183
diff changeset
310 while ((regs.h.ah = extended_kbd ? 0x11 : 0x01),
b11f71df59d9 (dos_rawgetc): Use bios, not kbhit ().
Richard M. Stallman <rms@gnu.org>
parents: 8183
diff changeset
311 int86 (0x16, &regs, &regs),
b11f71df59d9 (dos_rawgetc): Use bios, not kbhit ().
Richard M. Stallman <rms@gnu.org>
parents: 8183
diff changeset
312 (regs.x.flags & 0x40) == 0)
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314 union REGS regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315 register unsigned char c;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316 int sc, code;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 regs.h.ah = extended_kbd ? 0x10 : 0x00;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 int86 (0x16, &regs, &regs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320 c = regs.h.al;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321 sc = regs.h.ah;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323 /* Determine from the scan code if a keypad key was pressed. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 if (c >= '0' && c <= '9' && sc > 0xb)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 sc = (c == '0') ? 0xb : (c - '0' + 1), c = 0;
7666
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
326 else if (sc == 0x53 && c != 0xe0)
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
327 {
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
328 code = 0xffae; /* Keypad decimal point/comma. */
7666
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
329 goto nonascii;
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
330 }
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 else if (sc == 0xe0)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 switch (c)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 {
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
335 case 10: /* Ctrl Enter */
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 case 13:
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 sc = 0x1c;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 case '/':
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 sc = 0x35;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342 default:
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343 sc = 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344 };
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
345 c = 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
346 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
347
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
348 if (c == 0
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349 || c == ' '
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350 || alt_p
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351 || (ctrl_p && shift_p)
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
352 || (c == 0xe0 && sc != 0) /* Pseudo-key */
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
353 || sc == 0x37 /* Grey * */
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
354 || sc == 0x4a /* Grey - */
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
355 || sc == 0x4e /* Grey + */
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
356 || sc == 0x0e) /* Back space *key*, not Ctrl-h */
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
357 {
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
358 if (sc >= (sizeof (ibmpc_translate_map) / sizeof (short)))
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
359 code = 0;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
360 else
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
361 code = ibmpc_translate_map[sc];
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
362 if (code != 0)
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
363 {
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
364 if (code >= 0x100)
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
365 {
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
366 nonascii:
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
367 event.kind = non_ascii_keystroke;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
368 event.code = (code & 0xff) + 0xff00;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
369 }
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
370 else
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
371 {
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
372 /* Don't return S- if we don't have to. `shifted' is
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
373 supposed to be the shifted versions of the characters
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
374 in `unshifted'. Unfortunately, this is only true for
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
375 US keyboard layout. If anyone knows how to do this
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
376 right, please tell us. */
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
377 static char *unshifted
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
378 = "abcdefghijklmnopqrstuvwxyz,./=;[\\]'-`0123456789";
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
379 static char *shifted
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
380 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ<>?+:{|}\"_~)!@#$%^&*(";
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
381 char *pos;
7666
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
382
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
383 if (shift_p && (pos = strchr (unshifted, code)))
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
384 {
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
385 c = shifted[pos - unshifted];
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
386 shift_p = 0;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
387 }
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
388 else
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
389 if (c == 0) c = code;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
390 event.kind = ascii_keystroke;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
391 event.code = c;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
392 }
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
393 event.modifiers
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
394 = (shift_p ? shift_modifier : 0)
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
395 + (ctrl_p ? ctrl_modifier : 0)
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
396 + (alt_p ? meta_modifier : 0);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
397 /* EMACS == Enter Meta Alt Control Shift */
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
398 XSETFRAME (event.frame_or_window, selected_frame);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
399 event.timestamp = event_timestamp ();
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
400 kbd_buffer_store_event (&event);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
401 }
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
402 } else
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
403 return c;
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
406 if (have_mouse > 0)
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
407 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
408 int but, press, x, y, ok;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
409
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410 /* Check for mouse movement *before* buttons. */
7273
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
411 mouse_check_moved ();
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413 for (but = 0; but < NUM_MOUSE_BUTTONS; but++)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414 for (press = 0; press < 2; press++)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416 if (press)
7273
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
417 ok = mouse_pressed (but, &x, &y);
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 else
7273
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
419 ok = mouse_released (but, &x, &y);
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 if (ok)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 event.kind = mouse_click;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 event.code = but;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 event.modifiers
7666
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
425 = (shift_p ? shift_modifier : 0)
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
426 + (ctrl_p ? ctrl_modifier : 0)
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
427 + (alt_p ? meta_modifier : 0)
13a977e6777a (dos_rawgetc): Doc fix. Make C-, S-, and M- modifiers
Richard M. Stallman <rms@gnu.org>
parents: 7523
diff changeset
428 + (press ? down_modifier : up_modifier);
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429 event.x = x;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430 event.y = y;
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
431 XSETFRAME (event.frame_or_window, selected_frame);
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
432 event.timestamp = event_timestamp ();
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433 kbd_buffer_store_event (&event);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 return -1;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
439 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
440
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441 static int prev_get_char = -1;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
442
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 /* Return 1 if a key is ready to be read without suspending execution. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 dos_keysns ()
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
445 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
446 if (prev_get_char != -1)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
447 return 1;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
448 else
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
449 return ((prev_get_char = dos_rawgetc ()) != -1);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
450 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
451
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
452 /* Read a key. Return -1 if no key is ready. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
453 dos_keyread ()
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
454 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
455 if (prev_get_char != -1)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
456 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
457 int c = prev_get_char;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
458 prev_get_char = -1;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
459 return c;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
460 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
461 else
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
462 return dos_rawgetc ();
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
463 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
464
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
465 /* Hostnames for a pc are not really funny, but they are used in change log
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
466 so we emulate the best we can. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
467 gethostname (p, size)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
468 char *p;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
469 int size;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
470 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
471 char *q = egetenv ("HOSTNAME");
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
472
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
473 if (!q) q = "pc";
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
474 strcpy (p, q);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
475 return 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
476 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
477
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478 /* Destructively turn backslashes into slashes. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480 dostounix_filename (p)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481 register char *p;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
482 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
483 while (*p)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
484 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
485 if (*p == '\\')
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
486 *p = '/';
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
487 p++;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
488 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
489 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
490
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
491 /* Destructively turn slashes into backslashes. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
492 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
493 unixtodos_filename (p)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
494 register char *p;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
495 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
496 while (*p)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
497 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
498 if (*p == '/')
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
499 *p = '\\';
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
500 p++;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
501 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
502 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
504 /* Get the default directory for a given drive. 0=def, 1=A, 2=B, ... */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
505 int
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
506 getdefdir (drive, dst)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
507 int drive;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
508 char *dst;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
509 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
510 union REGS regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512 *dst++ = '/';
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513 regs.h.dl = drive;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
514 regs.x.si = (int) dst;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515 regs.h.ah = 0x47;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
516 intdos (&regs, &regs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
517 return !regs.x.cflag;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
518 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
519
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
520 /* Remove all CR's that are followed by a LF. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
521 int
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
522 crlf_to_lf (n, buf)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
523 register int n;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
524 register unsigned char *buf;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
525 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
526 unsigned char *np = buf;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
527 unsigned char *startp = buf;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
528 unsigned char *endp = buf + n;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
529 unsigned char c;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
530
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
531 if (n == 0)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
532 return n;
7507
b393834bab2a (crlf_to_lf): Fix off-by-one condition.
Richard M. Stallman <rms@gnu.org>
parents: 7273
diff changeset
533 while (buf < endp - 1)
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
534 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535 if (*buf == 0x0d)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
536 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
537 if (*(++buf) != 0x0a)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
538 *np++ = 0x0d;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
539 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
540 else
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
541 *np++ = *buf++;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
542 }
7507
b393834bab2a (crlf_to_lf): Fix off-by-one condition.
Richard M. Stallman <rms@gnu.org>
parents: 7273
diff changeset
543 if (buf < endp)
b393834bab2a (crlf_to_lf): Fix off-by-one condition.
Richard M. Stallman <rms@gnu.org>
parents: 7273
diff changeset
544 *np++ = *buf++;
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
545 return np - startp;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
546 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
547
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
548
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
549 /* Run command as specified by ARGV in directory DIR.
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
550 The command is run with input from TEMPIN and output to file TEMPOUT. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
551 int
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
552 run_msdos_command (argv, dir, tempin, tempout)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
553 unsigned char **argv;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
554 Lisp_Object dir;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
555 int tempin, tempout;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
556 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
557 char *saveargv1, *saveargv2, **envv;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
558 char oldwd[MAXPATHLEN + 1]; /* Fixed size is safe on MSDOS. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
559 int msshell, result = -1;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
560 int in, out, inbak, outbak, errbak;
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
561 int x, y;
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
562 Lisp_Object cmd;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
563
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
564 /* Get current directory as MSDOS cwd is not per-process. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
565 getwd (oldwd);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
566
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
567 cmd = Ffile_name_nondirectory (build_string (argv[0]));
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
568 msshell = !NILP (Fmember (cmd, Fsymbol_value (intern ("msdos-shells"))))
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
569 && !strcmp ("-c", argv[1]);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
570 if (msshell)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
571 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
572 saveargv1 = argv[1];
7774
f9cde3320987 (run_msdos_command): Make local copy of argv[2] on stack, not on heap.
Karl Heuer <kwzh@gnu.org>
parents: 7744
diff changeset
573 saveargv2 = argv[2];
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
574 argv[1] = "/c";
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
575 if (argv[2])
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
576 {
7774
f9cde3320987 (run_msdos_command): Make local copy of argv[2] on stack, not on heap.
Karl Heuer <kwzh@gnu.org>
parents: 7744
diff changeset
577 char *p = alloca (strlen (argv[2]) + 1);
f9cde3320987 (run_msdos_command): Make local copy of argv[2] on stack, not on heap.
Karl Heuer <kwzh@gnu.org>
parents: 7744
diff changeset
578
f9cde3320987 (run_msdos_command): Make local copy of argv[2] on stack, not on heap.
Karl Heuer <kwzh@gnu.org>
parents: 7744
diff changeset
579 strcpy (argv[2] = p, saveargv2);
f9cde3320987 (run_msdos_command): Make local copy of argv[2] on stack, not on heap.
Karl Heuer <kwzh@gnu.org>
parents: 7744
diff changeset
580 while (*p && isspace (*p))
f9cde3320987 (run_msdos_command): Make local copy of argv[2] on stack, not on heap.
Karl Heuer <kwzh@gnu.org>
parents: 7744
diff changeset
581 p++;
f9cde3320987 (run_msdos_command): Make local copy of argv[2] on stack, not on heap.
Karl Heuer <kwzh@gnu.org>
parents: 7744
diff changeset
582 while (*p && !isspace (*p))
f9cde3320987 (run_msdos_command): Make local copy of argv[2] on stack, not on heap.
Karl Heuer <kwzh@gnu.org>
parents: 7744
diff changeset
583 if (*p == '/')
f9cde3320987 (run_msdos_command): Make local copy of argv[2] on stack, not on heap.
Karl Heuer <kwzh@gnu.org>
parents: 7744
diff changeset
584 *p++ = '\\';
f9cde3320987 (run_msdos_command): Make local copy of argv[2] on stack, not on heap.
Karl Heuer <kwzh@gnu.org>
parents: 7744
diff changeset
585 else
f9cde3320987 (run_msdos_command): Make local copy of argv[2] on stack, not on heap.
Karl Heuer <kwzh@gnu.org>
parents: 7744
diff changeset
586 p++;
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
587 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
588 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
589
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
590 /* Build the environment array. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
591 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
592 extern Lisp_Object Vprocess_environment;
6505
ce4fbb055f87 (run_msdos_command): Use assignment instead of initialization.
Karl Heuer <kwzh@gnu.org>
parents: 6056
diff changeset
593 Lisp_Object tmp, lst;
ce4fbb055f87 (run_msdos_command): Use assignment instead of initialization.
Karl Heuer <kwzh@gnu.org>
parents: 6056
diff changeset
594 int i, len;
ce4fbb055f87 (run_msdos_command): Use assignment instead of initialization.
Karl Heuer <kwzh@gnu.org>
parents: 6056
diff changeset
595
ce4fbb055f87 (run_msdos_command): Use assignment instead of initialization.
Karl Heuer <kwzh@gnu.org>
parents: 6056
diff changeset
596 lst = Vprocess_environment;
ce4fbb055f87 (run_msdos_command): Use assignment instead of initialization.
Karl Heuer <kwzh@gnu.org>
parents: 6056
diff changeset
597 len = XFASTINT (Flength (lst));
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
598
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
599 envv = alloca ((len + 1) * sizeof (char *));
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
600 for (i = 0; i < len; i++)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
601 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
602 tmp = Fcar (lst);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
603 lst = Fcdr (lst);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
604 CHECK_STRING (tmp, 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
605 envv[i] = alloca (XSTRING (tmp)->size + 1);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
606 strcpy (envv[i], XSTRING (tmp)->data);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
607 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
608 envv[len] = (char *) 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
609 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
610
9118
3c4437496ebc (run_msdos_command): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 8246
diff changeset
611 if (STRINGP (dir))
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
612 chdir (XSTRING (dir)->data);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
613 inbak = dup (0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
614 outbak = dup (1);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
615 errbak = dup (2);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
616 if (inbak < 0 || outbak < 0 || errbak < 0)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
617 goto done; /* Allocation might fail due to lack of descriptors. */
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
618
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
619 if (have_mouse > 0)
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
620 {
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
621 mouse_get_xy (&x, &y);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
622 mouse_off ();
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
623 }
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
624 dos_ttcooked(); /* do it here while 0 = stdin */
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
625
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
626 dup2 (tempin, 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
627 dup2 (tempout, 1);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
628 dup2 (tempout, 2);
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
629
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
630 result = spawnve (P_WAIT, argv[0], argv, envv);
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
631
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
632 dup2 (inbak, 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
633 dup2 (outbak, 1);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
634 dup2 (errbak, 2);
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
635 close (inbak);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
636 close (outbak);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
637 close (errbak);
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
638
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
639 dos_ttraw();
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
640 if (have_mouse > 0) {
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
641 mouse_init ();
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
642 mouse_moveto (x, y);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
643 }
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
644
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
645 done:
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
646 chdir (oldwd);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
647 if (msshell)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
648 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
649 argv[1] = saveargv1;
7774
f9cde3320987 (run_msdos_command): Make local copy of argv[2] on stack, not on heap.
Karl Heuer <kwzh@gnu.org>
parents: 7744
diff changeset
650 argv[2] = saveargv2;
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
651 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
652 return result;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
653 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
654
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
655
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
656 croak (badfunc)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
657 char *badfunc;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
658 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
659 fprintf (stderr, "%s not yet implemented\r\n", badfunc);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
660 reset_sys_modes ();
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
661 exit (1);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
662 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
663
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
664 /* A list of unimplemented functions that we silently ignore. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
665 unsigned alarm (s) unsigned s; {}
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
666 fork () { return 0; }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
667 int kill (x, y) int x, y; { return -1; }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
668 nice (p) int p; {}
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
669 void volatile pause () {}
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
670 request_sigio () {}
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
671 setpgrp () {return 0; }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
672 setpriority (x,y,z) int x,y,z; { return 0; }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
673 sigsetmask (x) int x; { return 0; }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
674 unrequest_sigio () {}
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
675
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
676 #ifdef chdir
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
677 #undef chdir
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
678 #endif
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
679
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
680 int
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
681 sys_chdir (path)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
682 const char* path;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
683 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
684 int len = strlen (path);
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
685 char *tmp = (char *)path;
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
686 /* Gotta do this extern here due to the corresponding #define: */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
687 extern int chdir ();
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
688
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
689 if (*tmp && tmp[1] == ':')
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
690 {
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
691 if (getdisk () != tolower (tmp[0]) - 'a')
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
692 setdisk (tolower (tmp[0]) - 'a');
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
693 tmp += 2; /* strip drive: KFS 1995-07-06 */
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
694 len -= 2;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
695 }
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
696
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
697 if (len > 1 && (tmp[len - 1] == '/'))
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
698 {
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
699 char *tmp1 = (char *) alloca (len + 1);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
700 strcpy (tmp1, tmp);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
701 tmp1[len - 1] = 0;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
702 tmp = tmp1;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
703 }
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
704 return chdir (tmp);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
705 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
706
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
707 #ifndef HAVE_SELECT
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
708 #include "sysselect.h"
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
709
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
710 /* Only event queue is checked. */
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
711 int
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
712 sys_select (nfds, rfds, wfds, efds, timeout)
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
713 int nfds;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
714 SELECT_TYPE *rfds, *wfds, *efds;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
715 EMACS_TIME *timeout;
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
716 {
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
717 SELECT_TYPE orfds;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
718 long timeoutval, clnow, cllast;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
719 struct time t;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
720
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
721 FD_ZERO (&orfds);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
722 if (rfds)
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
723 {
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
724 orfds = *rfds;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
725 FD_ZERO (rfds);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
726 }
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
727 if (wfds)
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
728 FD_ZERO (wfds);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
729 if (efds)
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
730 FD_ZERO (efds);
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
731
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
732 if (nfds != 1 || !FD_ISSET (0, &orfds))
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
733 abort ();
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
734
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
735 /* If we are looking only for the terminal, with no timeout,
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
736 just read it and wait -- that's more efficient. */
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
737 if (!timeout)
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
738 {
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
739 while (! detect_input_pending ());
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
740 }
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
741 else
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
742 {
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
743 timeoutval = EMACS_SECS (*timeout) * 100 + EMACS_USECS (*timeout) / 10000;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
744 gettime (&t);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
745 cllast = t.ti_sec * 100 + t.ti_hund;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
746
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
747 while (!detect_input_pending ())
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
748 {
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
749 gettime (&t);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
750 clnow = t.ti_sec * 100 + t.ti_hund;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
751 if (clnow < cllast) /* time wrap */
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
752 timeoutval -= clnow + 6000 - cllast;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
753 else
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
754 timeoutval -= clnow - cllast;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
755 if (timeoutval <= 0) /* Stop on timer being cleared */
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
756 return 0;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
757 cllast = clnow;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
758 }
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
759 }
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
760
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
761 FD_SET (0, rfds);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
762 return 1;
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
763 }
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
764 #endif
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
765
7821
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
766 /* The Emacs root directory as determined by init_environment. */
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
767 static char emacsroot[MAXPATHLEN];
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
768
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
769 char *
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
770 rootrelativepath (rel)
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
771 char *rel;
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
772 {
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
773 static char result[MAXPATHLEN + 10];
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
774
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
775 strcpy (result, emacsroot);
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
776 strcat (result, "/");
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
777 strcat (result, rel);
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
778 return result;
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
779 }
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
780
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
781 /* Define a lot of environment variables if not already defined. Don't
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
782 remove anything unless you know what you're doing -- lots of code will
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
783 break if one or more of these are missing. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
784 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
785 init_environment (argc, argv, skip_args)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
786 int argc;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
787 char **argv;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
788 int skip_args;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
789 {
7821
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
790 char *s, *t, *root;
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
791 int len;
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
792
7821
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
793 /* Find our root from argv[0]. Assuming argv[0] is, say,
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
794 "c:/emacs/bin/emacs.exe" our root will be "c:/emacs". */
12614
1415c961bea6 (init_environment): Move alloca call out of function arg.
Richard M. Stallman <rms@gnu.org>
parents: 12573
diff changeset
795 root = alloca (MAXPATHLEN + 20);
1415c961bea6 (init_environment): Move alloca call out of function arg.
Richard M. Stallman <rms@gnu.org>
parents: 12573
diff changeset
796 _fixpath (argv[0], root);
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
797 strlwr (root);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
798 len = strlen (root);
7821
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
799 while (len > 0 && root[len] != '/' && root[len] != ':')
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
800 len--;
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
801 root[len] = '\0';
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
802 if (len > 4 && strcmp (root + len - 4, "/bin") == 0)
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
803 root[len - 4] = '\0';
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
804 else
7821
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
805 strcpy (root, "c:/emacs"); /* Only under debuggers, I think. */
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
806 len = strlen (root);
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
807 strcpy (emacsroot, root);
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
808
7821
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
809 /* We default HOME to our root. */
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
810 setenv ("HOME", root, 0);
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
811
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
812 /* We default EMACSPATH to root + "/bin". */
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
813 strcpy (root + len, "/bin");
f96225d8c3eb (init_environment): Clean up code and make the default
Richard M. Stallman <rms@gnu.org>
parents: 7774
diff changeset
814 setenv ("EMACSPATH", root, 0);
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
815
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
816 /* I don't expect anybody to ever use other terminals so the internal
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
817 terminal is the default. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
818 setenv ("TERM", "internal", 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
819
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
820 #ifdef HAVE_X_WINDOWS
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
821 /* Emacs expects DISPLAY to be set. */
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
822 setenv ("DISPLAY", "unix:0.0", 0);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
823 #endif
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
824
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
825 /* SHELL is a bit tricky -- COMSPEC is the closest we come, but we must
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
826 downcase it and mirror the backslashes. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
827 s = getenv ("COMSPEC");
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
828 if (!s) s = "c:/command.com";
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
829 t = alloca (strlen (s) + 1);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
830 strcpy (t, s);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
831 strlwr (t);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
832 dostounix_filename (t);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
833 setenv ("SHELL", t, 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
834
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
835 /* PATH is also downcased and backslashes mirrored. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
836 s = getenv ("PATH");
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
837 if (!s) s = "";
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
838 t = alloca (strlen (s) + 3);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
839 /* Current directory is always considered part of MsDos's path but it is
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
840 not normally mentioned. Now it is. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
841 strcat (strcpy (t, ".;"), s);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
842 strlwr (t);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
843 dostounix_filename (t); /* Not a single file name, but this should work. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
844 setenv ("PATH", t, 1);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
845
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
846 /* In some sense all dos users have root privileges, so... */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
847 setenv ("USER", "root", 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
848 setenv ("NAME", getenv ("USER"), 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
849
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
850 /* Time zone determined from country code. To make this possible, the
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
851 country code may not span more than one time zone. In other words,
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
852 in the USA, you lose. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
853 switch (dos_country_code)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
854 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
855 case 31: /* Belgium */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
856 case 32: /* The Netherlands */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
857 case 33: /* France */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
858 case 34: /* Spain */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
859 case 36: /* Hungary */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
860 case 38: /* Yugoslavia (or what's left of it?) */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
861 case 39: /* Italy */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
862 case 41: /* Switzerland */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
863 case 42: /* Tjekia */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
864 case 45: /* Denmark */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
865 case 46: /* Sweden */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
866 case 47: /* Norway */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
867 case 48: /* Poland */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
868 case 49: /* Germany */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
869 /* Daylight saving from last Sunday in March to last Sunday in
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
870 September, both at 2AM. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
871 setenv ("TZ", "MET-01METDST-02,M3.5.0/02:00,M9.5.0/02:00", 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
872 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
873 case 44: /* United Kingdom */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
874 case 351: /* Portugal */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
875 case 354: /* Iceland */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
876 setenv ("TZ", "GMT+00", 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
877 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
878 case 81: /* Japan */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
879 case 82: /* Korea */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
880 setenv ("TZ", "???-09", 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
881 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
882 case 90: /* Turkey */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
883 case 358: /* Finland */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
884 case 972: /* Israel */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
885 setenv ("TZ", "EET-02", 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
886 break;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
887 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
888 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
889
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
890 /* Flash the screen as a substitute for BEEPs. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
891
7273
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
892 static void
7667
bae9c0fa1c2f (do_visible_bell): Renamed from visible_bell to avoid
Richard M. Stallman <rms@gnu.org>
parents: 7666
diff changeset
893 do_visible_bell (xorattr)
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
894 unsigned char xorattr;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
895 {
7273
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
896 asm volatile
8183
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
897 (" movb $1,%%dl
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
898 visible_bell_0:
8183
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
899 movl _ScreenPrimary,%%eax
7273
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
900 call dosmemsetup
8183
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
901 movl %%eax,%%ebx
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
902 movl %1,%%ecx
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
903 movb %0,%%al
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
904 incl %%ebx
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
905 visible_bell_1:
8183
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
906 xorb %%al,%%gs:(%%ebx)
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
907 addl $2,%%ebx
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
908 decl %%ecx
7273
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
909 jne visible_bell_1
8183
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
910 decb %%dl
7273
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
911 jne visible_bell_3
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
912 visible_bell_2:
8183
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
913 movzwl %%ax,%%eax
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
914 movzwl %%ax,%%eax
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
915 movzwl %%ax,%%eax
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
916 movzwl %%ax,%%eax
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
917 decw %%cx
7273
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
918 jne visible_bell_2
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
919 jmp visible_bell_0
8183
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
920 visible_bell_3:"
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
921 : /* no output */
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
922 : "m" (xorattr), "g" (ScreenCols () * ScreenRows ())
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
923 : "%eax", "%ebx", /* "%gs",*/ "%ecx", "%edx");
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
924 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
925
7744
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
926 /* At screen position (X,Y), output C characters from string S with
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
927 attribute A. Do it fast! */
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
928
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
929 static void
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
930 output_string (x, y, s, c, a)
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
931 int x, y, c;
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
932 unsigned char *s;
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
933 unsigned char a;
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
934 {
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
935 char *t = (char *)ScreenPrimary + 2 * (x + ScreenCols () * y);
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
936 #ifdef DO_TERMSCRIPT
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
937 if (termscript)
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
938 {
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
939 fprintf (termscript, "<%d@%dx%d>", c, x, y);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
940 fwrite (s, sizeof (unsigned char), c, termscript);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
941 }
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
942 #endif
7744
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
943 asm volatile
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
944 (" movl %1,%%eax
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
945 call dosmemsetup
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
946 movl %%eax,%%edi
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
947 movb %0,%%ah
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
948 movl %2,%%ecx
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
949 movl %3,%%esi
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
950 output_string1:
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
951 movb (%%esi),%%al
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
952 movw %%ax,%%gs:(%%edi)
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
953 addl $2,%%edi
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
954 incl %%esi
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
955 decl %%ecx
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
956 jne output_string1"
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
957 : /* no output */
7744
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
958 : "m" (a), "g" (t), "g" (c), "g" (s)
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
959 : "%eax", "%ecx", /* "%gs",*/ "%esi", "%edi");
7744
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
960 }
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
961
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
962 static int internal_terminal = 0;
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
963 static int highlight;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
964
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
965 #undef fflush
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
966
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
967 static int /* number of characters used by escape; -1 if incomplete */
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
968 flush_escape (resume, cp, count, xp, yp)
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
969 int resume;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
970 unsigned char *cp;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
971 int count;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
972 int *xp;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
973 int *yp;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
974 {
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
975 static char spaces[] = " ";
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
976 static unsigned char esc_cmd[8];
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
977 static int esc_count = 0;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
978 int esc_needed;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
979 int i, j, used = 0;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
980
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
981 if (!resume)
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
982 {
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
983 esc_cmd[0] = '\e';
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
984 esc_count = 1;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
985 used++;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
986 }
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
987
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
988 while (esc_count < 2)
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
989 {
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
990 if (used == count)
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
991 return -1;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
992 esc_cmd[esc_count++] = *cp++;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
993 used++;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
994 }
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
996 switch (esc_cmd[1])
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
997 {
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
998 case '@':
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
999 esc_needed = 4;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1000 break;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1001 case 'A':
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1002 case 'B':
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1003 case 'X':
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1004 esc_needed = 3;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1005 break;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1006 default:
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1007 esc_needed = 2;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1008 break;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1009 }
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1010
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1011 while (esc_count < esc_needed)
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1012 {
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1013 if (used == count)
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1014 return -1;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1015 esc_cmd[esc_count++] = *cp++;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1016 used++;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1017 }
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1018
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1019 switch (esc_cmd[1])
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1020 {
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1021 case '@':
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1022 *yp = esc_cmd[2];
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1023 *xp = esc_cmd[3];
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1024 break;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1025 case 'A':
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1026 ScreenAttrib = esc_cmd[2];
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1027 break;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1028 case 'B':
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1029 do_visible_bell (esc_cmd[2]);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1030 break;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1031 case 'C':
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1032 ScreenClear ();
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1033 *xp = *yp = 0;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1034 break;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1035 case 'E':
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1036 i = ScreenCols () - *xp;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1037 j = *xp;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1038 while (i >= sizeof spaces)
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1039 {
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1040 output_string (j, *yp, spaces, sizeof spaces, ScreenAttrib);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1041 j += sizeof spaces;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1042 i -= sizeof spaces;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1043 }
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1044 if (i > 0)
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1045 output_string (j, *yp, spaces, i, ScreenAttrib);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1046 break;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1047 case 'R':
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1048 ++*xp;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1049 break;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1050 case 'U':
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1051 --*yp;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1052 break;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1053 case 'X':
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1054 ScreenAttrib ^= esc_cmd[2];
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1055 break;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1056 case '\e':
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1057 output_string (*xp, *yp, &esc_cmd[1], 1, ScreenAttrib);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1058 ++*xp;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1059 break;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1060 }
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1061
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1062 esc_count = 0;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1063 return used;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1064 }
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1065
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1066 int
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1067 internal_flush (f)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1068 FILE *f;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1069 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1070 static int x;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1071 static int y;
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1072 static int resume_esc = 0;
7744
da18793f532d (output_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7667
diff changeset
1073 unsigned char *cp, *cp0;
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1074 int count, i;
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1075
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1076 if (!internal_terminal || f != stdout)
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1077 {
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1078 /* This is a call to the original fflush. */
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1079 fflush (f);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1080 return;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1081 }
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1082
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1083 mouse_off ();
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1084 cp = stdout->_base;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1085 count = stdout->_ptr - stdout->_base;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1086
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1087 #ifdef DO_TERMSCRIPT
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1088 if (termscript)
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1089 fprintf (termscript, "\n<FLUSH%s %d>\n", resume_esc ? " RESUME" : "", count);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1090 #endif
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1091
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1092 if (resume_esc)
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1093 {
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1094 i = flush_escape (1, cp, count, &x, &y);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1095 if (i < 0)
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1096 count = 0;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1097 else
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1098 {
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1099 resume_esc = 0;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1100 count -= i;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1101 cp += i;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1102 }
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1103 }
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1104
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1105 while (count > 0)
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1106 {
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1107 switch (*cp++)
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1108 {
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1109 case 27:
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1110 i = flush_escape (0, cp, count, &x, &y);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1111 if (i < 0)
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1112 {
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1113 resume_esc = 1;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1114 count = 0;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1115 }
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1116 else
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1117 {
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1118 count -= i;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1119 cp += i - 1;
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1120 }
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1121 break;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1122 case 7:
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1123 write (1, "\007", 1);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1124 count--;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1125 break;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1126 case 8:
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1127 x--;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1128 count--;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1129 break;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1130 case 13:
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1131 x = 0;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1132 count--;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1133 break;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1134 case 10:
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1135 y++;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1136 count--;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1137 break;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1138 default:
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1139 cp0 = cp - 1;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1140 count--;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1141 while (count > 0 && *cp >= ' ')
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1142 cp++, count--;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1143 output_string (x, y, cp0, cp - cp0, ScreenAttrib);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1144 x += (cp - cp0);
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1145 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1146 }
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1147 fpurge (stdout);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1148 ScreenSetCursor (y, x);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1149 mouse_on ();
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1150 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1151
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1152 #ifndef HAVE_X_WINDOWS
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1153 static void
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1154 rien_du_tout ()
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1155 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1156 /* Rien du tout, cela va sans dire! */
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1157 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1158
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1159 static
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1160 IT_ring_bell ()
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1161 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1162 if (visible_bell)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1163 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1164 /* This creates an xor-mask that will swap the default fore- and
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1165 background colors. */
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1166 mouse_off ();
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1167 do_visible_bell (((the_only_x_display.foreground_pixel
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1168 ^ the_only_x_display.background_pixel)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1169 * 0x11) & 0x7f);
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1170 mouse_on ();
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1171 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1172 else
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1173 /* Write it directly to ms-dos -- don't let it go through our terminal
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1174 emulator. This way the mouse cursor won't blink. */
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1175 write (1, "\007", 1);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1176 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1177
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1178 static void
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1179 IT_set_face (int face)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1180 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1181 struct face *fp;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1182 extern struct face *intern_face (/* FRAME_PTR, struct face * */);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1183
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1184 if (face == 1 || (face == 0 && highlight))
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1185 fp = FRAME_MODE_LINE_FACE (foo);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1186 else if (face <= 0 || face >= FRAME_N_COMPUTED_FACES (foo))
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1187 fp = FRAME_DEFAULT_FACE (foo);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1188 else
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1189 fp = intern_face (selected_frame, FRAME_COMPUTED_FACES (foo)[face]);
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1190 #ifdef DO_TERMSCRIPT
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1191 if (termscript)
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1192 fprintf (termscript, "<FACE:%d:%d>", FACE_FOREGROUND (fp), FACE_BACKGROUND (fp));
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1193 #endif
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1194 putchar ('\e');
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1195 putchar ('A');
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1196 putchar ((FACE_BACKGROUND (fp) << 4) | FACE_FOREGROUND (fp));
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1197 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1198
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1199 static
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1200 IT_write_glyphs (GLYPH *str, int len)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1201 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1202 int face = -1;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1203 int newface;
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1204 int ch;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1205
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1206 while (len > 0)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1207 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1208 newface = FAST_GLYPH_FACE (*str);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1209 if (newface != face)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1210 IT_set_face ((face = newface));
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1211 ch = FAST_GLYPH_CHAR (*str);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1212 #ifdef DO_TERMSCRIPT
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1213 if (termscript)
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1214 fputc (ch, termscript);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1215 #endif
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1216 if (ch == '\e') putchar (ch); /* allow esc to be printed */
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1217 putchar (ch);
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1218 str++, len--;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1219 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1220 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1221
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1222 static
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1223 IT_clear_end_of_line (first_unused)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1224 {
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1225 IT_set_face (0);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1226 #ifdef DO_TERMSCRIPT
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1227 if (termscript)
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1228 fprintf (termscript, "<CLR:EOL>");
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1229 #endif
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1230 putchar ('\e');
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1231 putchar ('E');
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1232 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1233
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1234 static
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1235 IT_cursor_to (int y, int x)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1236 {
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1237 #ifdef DO_TERMSCRIPT
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1238 if (termscript)
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1239 fprintf (termscript, "\n<XY=%dx%d>", x, y);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1240 #endif
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1241 putchar ('\e');
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1242 putchar ('@');
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1243 putchar (y);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1244 putchar (x);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1245 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1246
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1247 IT_reassert_line_highlight (new, vpos)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1248 int new, vpos;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1249 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1250 highlight = new;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1251 IT_set_face (0); /* To possibly clear the highlighting. */
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1252 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1253
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1254 static
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1255 IT_change_line_highlight (new_highlight, vpos, first_unused_hpos)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1256 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1257 highlight = new_highlight;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1258 IT_set_face (0); /* To possibly clear the highlighting. */
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1259 IT_cursor_to (vpos, 0);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1260 IT_clear_end_of_line (first_unused_hpos);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1261 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1262
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1263 static
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1264 IT_update_begin ()
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1265 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1266 highlight = 0;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1267 IT_set_face (0); /* To possibly clear the highlighting. */
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1268 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1269
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1270 /* This was more or less copied from xterm.c */
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1271 static void
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1272 IT_set_menu_bar_lines (window, n)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1273 Lisp_Object window;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1274 int n;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1275 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1276 struct window *w = XWINDOW (window);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1277
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1278 XSETFASTINT (w->top, XFASTINT (w->top) + n);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1279 XSETFASTINT (w->height, XFASTINT (w->height) - n);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1280
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1281 /* Handle just the top child in a vertical split. */
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1282 if (!NILP (w->vchild))
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1283 IT_set_menu_bar_lines (w->vchild, n);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1284
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1285 /* Adjust all children in a horizontal split. */
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1286 for (window = w->hchild; !NILP (window); window = w->next)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1287 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1288 w = XWINDOW (window);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1289 IT_set_menu_bar_lines (window, n);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1290 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1291 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1292
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1293 void
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1294 IT_set_frame_parameters (frame, alist)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1295 FRAME_PTR frame;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1296 Lisp_Object alist;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1297 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1298 Lisp_Object tail;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1299 int redraw;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1300 extern unsigned long load_color ();
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1301 FRAME_PTR f = (FRAME_PTR) &the_only_frame;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1302
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1303 redraw = 0;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1304 for (tail = alist; CONSP (tail); tail = Fcdr (tail))
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1305 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1306 Lisp_Object elt, prop, val;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1307
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1308 elt = Fcar (tail);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1309 prop = Fcar (elt);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1310 val = Fcdr (elt);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1311 CHECK_SYMBOL (prop, 1);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1312
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1313 if (EQ (prop, intern ("foreground-color")))
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1314 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1315 unsigned long new_color = load_color (f, val);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1316 if (new_color != ~0)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1317 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1318 FRAME_FOREGROUND_PIXEL (f) = new_color;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1319 redraw = 1;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1320 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1321 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1322 else if (EQ (prop, intern ("background-color")))
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1323 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1324 unsigned long new_color = load_color (f, val);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1325 if (new_color != ~0)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1326 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1327 FRAME_BACKGROUND_PIXEL (f) = new_color & ~8;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1328 redraw = 1;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1329 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1330 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1331 else if (EQ (prop, intern ("menu-bar-lines")))
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1332 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1333 int new;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1334 int old = FRAME_MENU_BAR_LINES (the_only_frame);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1335
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1336 if (INTEGERP (val))
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1337 new = XINT (val);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1338 else
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1339 new = 0;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1340 FRAME_MENU_BAR_LINES (f) = new;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1341 IT_set_menu_bar_lines (the_only_frame.root_window, new - old);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1342 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1343 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1344
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1345 if (redraw)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1346 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1347 recompute_basic_faces (f);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1348 Fredraw_frame (Fselected_frame ());
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1349 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1350 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1351
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1352 /* Similar to the_only_frame. */
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1353 struct x_display the_only_x_display;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1354
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1355 /* This is never dereferenced. */
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1356 Display *x_current_display;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1357
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1358 #endif /* !HAVE_X_WINDOWS */
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1359
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1360 /* Do we need the internal terminal? */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1361 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1362 internal_terminal_init ()
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1363 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1364 char *term = getenv ("TERM");
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1365 char *colors;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1366
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1367 #ifdef HAVE_X_WINDOWS
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1368 if (!inhibit_window_system)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1369 return;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1370 #endif
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1371
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1372 internal_terminal
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1373 = (!noninteractive) && term && !strcmp (term, "internal");
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1374
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1375 #ifndef HAVE_X_WINDOWS
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1376 if (internal_terminal && !inhibit_window_system)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1377 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1378 Vwindow_system = intern ("pc");
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1379 Vwindow_system_version = make_number (1);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1380
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1381 bzero (&the_only_x_display, sizeof the_only_x_display);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1382 the_only_x_display.background_pixel = 7; /* White */
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1383 the_only_x_display.foreground_pixel = 0; /* Black */
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1384 colors = getenv ("EMACSCOLORS");
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1385 if (colors && strlen (colors) >=2)
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1386 {
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1387 the_only_x_display.foreground_pixel = colors[0] & 0x07;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1388 the_only_x_display.background_pixel = colors[1] & 0x07;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1389 }
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1390 the_only_x_display.line_height = 1;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1391 the_only_frame.display.x = &the_only_x_display;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1392 the_only_frame.output_method = output_msdos_raw;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1393
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1394 init_frame_faces ((FRAME_PTR) &the_only_frame);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1395
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1396 ring_bell_hook = IT_ring_bell;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1397 write_glyphs_hook = IT_write_glyphs;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1398 cursor_to_hook = raw_cursor_to_hook = IT_cursor_to;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1399 clear_end_of_line_hook = IT_clear_end_of_line;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1400 change_line_highlight_hook = IT_change_line_highlight;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1401 update_begin_hook = IT_update_begin;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1402 reassert_line_highlight_hook = IT_reassert_line_highlight;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1403
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1404 /* These hooks are called by term.c without being checked. */
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1405 set_terminal_modes_hook
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1406 = reset_terminal_modes_hook
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1407 = update_end_hook
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1408 = set_terminal_window_hook
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1409 = (void *)rien_du_tout;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1410 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1411 else
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1412 the_only_frame.output_method = output_termcap;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1413 #endif
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1414 }
7523
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
1415
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
1416 /* When time zones are set from Ms-Dos too may C-libraries are playing
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
1417 tricks with time values. We solve this by defining our own version
13040
169d50e2ee4c (gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents: 13020
diff changeset
1418 of `gettimeofday' bypassing GO32. Our version needs to be initialized
169d50e2ee4c (gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents: 13020
diff changeset
1419 once and after each call to `tzset' with TZ changed. */
169d50e2ee4c (gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents: 13020
diff changeset
1420
169d50e2ee4c (gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents: 13020
diff changeset
1421 static int daylight, gmtoffset;
7523
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
1422
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
1423 int
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
1424 gettimeofday (struct timeval *tp, struct timezone *tzp)
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
1425 {
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
1426 if (tp)
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
1427 {
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
1428 struct time t;
13040
169d50e2ee4c (gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents: 13020
diff changeset
1429 struct date d;
169d50e2ee4c (gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents: 13020
diff changeset
1430 struct tm tmrec;
7523
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
1431
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
1432 gettime (&t);
13040
169d50e2ee4c (gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents: 13020
diff changeset
1433 /* If midnight occurs here, the results can be incorrect. */
169d50e2ee4c (gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents: 13020
diff changeset
1434 getdate (&d);
169d50e2ee4c (gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents: 13020
diff changeset
1435 tmrec.tm_year = d.da_year - 1900;
169d50e2ee4c (gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents: 13020
diff changeset
1436 tmrec.tm_mon = d.da_mon - 1;
169d50e2ee4c (gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents: 13020
diff changeset
1437 tmrec.tm_mday = d.da_day;
169d50e2ee4c (gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents: 13020
diff changeset
1438 tmrec.tm_hour = t.ti_hour;
169d50e2ee4c (gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents: 13020
diff changeset
1439 tmrec.tm_min = t.ti_min;
169d50e2ee4c (gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents: 13020
diff changeset
1440 tmrec.tm_sec = t.ti_sec;
169d50e2ee4c (gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents: 13020
diff changeset
1441 tmrec.tm_gmtoff = gmtoffset;
169d50e2ee4c (gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents: 13020
diff changeset
1442 tmrec.tm_isdst = daylight;
169d50e2ee4c (gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents: 13020
diff changeset
1443 tp->tv_sec = mktime (&tmrec);
169d50e2ee4c (gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents: 13020
diff changeset
1444 tp->tv_usec = t.ti_hund * (1000000 / 100);
7523
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
1445 }
13020
a656ccd43989 (gettimeofday): Don't bother setting time zone,
Richard M. Stallman <rms@gnu.org>
parents: 12995
diff changeset
1446 /* Ignore tzp; it's obsolescent. */
7523
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
1447 return 0;
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
1448 }
13040
169d50e2ee4c (gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents: 13020
diff changeset
1449
169d50e2ee4c (gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents: 13020
diff changeset
1450 void
169d50e2ee4c (gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents: 13020
diff changeset
1451 init_gettimeofday ()
169d50e2ee4c (gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents: 13020
diff changeset
1452 {
169d50e2ee4c (gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents: 13020
diff changeset
1453 time_t ltm, gtm;
169d50e2ee4c (gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents: 13020
diff changeset
1454 struct tm *lstm;
169d50e2ee4c (gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents: 13020
diff changeset
1455 #undef tzset
169d50e2ee4c (gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents: 13020
diff changeset
1456 extern void tzset (void);
169d50e2ee4c (gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents: 13020
diff changeset
1457
169d50e2ee4c (gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents: 13020
diff changeset
1458 tzset ();
169d50e2ee4c (gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents: 13020
diff changeset
1459 daylight = 0;
169d50e2ee4c (gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents: 13020
diff changeset
1460 gmtoffset = 0;
169d50e2ee4c (gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents: 13020
diff changeset
1461 ltm = gtm = time (NULL);
169d50e2ee4c (gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents: 13020
diff changeset
1462 ltm = mktime (lstm = localtime (&ltm));
169d50e2ee4c (gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents: 13020
diff changeset
1463 gtm = mktime (gmtime (&gtm));
169d50e2ee4c (gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents: 13020
diff changeset
1464 daylight = lstm->tm_isdst;
169d50e2ee4c (gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents: 13020
diff changeset
1465 gmtoffset = (int)(gtm - ltm) / 60;
169d50e2ee4c (gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
Paul Eggert <eggert@twinsun.com>
parents: 13020
diff changeset
1466 }
7523
8994727ff976 (gettimeofday): New function substituting the library
Richard M. Stallman <rms@gnu.org>
parents: 7507
diff changeset
1467
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1468 /* These must be global. */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1469 static _go32_dpmi_seginfo ctrl_break_vector;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1470 static _go32_dpmi_registers ctrl_break_regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1471 static int ctrlbreakinstalled = 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1472
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1473 /* Interrupt level detection of Ctrl-Break. Don't do anything fancy here! */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1474 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1475 ctrl_break_func (regs)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1476 _go32_dpmi_registers *regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1477 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1478 Vquit_flag = Qt;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1479 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1480
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1481 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1482 install_ctrl_break_check ()
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1483 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1484 if (!ctrlbreakinstalled)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1485 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1486 /* Don't press Ctrl-Break if you don't have either DPMI or Emacs
8183
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
1487 was compiler with Djgpp 1.11 maintenance level 5 or later! */
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1488 ctrlbreakinstalled = 1;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1489 ctrl_break_vector.pm_offset = (int) ctrl_break_func;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1490 _go32_dpmi_allocate_real_mode_callback_iret (&ctrl_break_vector,
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1491 &ctrl_break_regs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1492 _go32_dpmi_set_real_mode_interrupt_vector (0x1b, &ctrl_break_vector);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1493 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1494 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1495
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1496 /* Mouse routines follow. Coordinates are in screen positions and zero
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1497 based. Mouse buttons are numbered from left to right and also zero
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1498 based. */
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1499
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1500 static int mouse_button_translate[NUM_MOUSE_BUTTONS];
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1501 static int mouse_button_count;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1502
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1503 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1504 mouse_init ()
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1505 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1506 union REGS regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1507
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1508 regs.x.ax = 0x0007;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1509 regs.x.cx = 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1510 regs.x.dx = 8 * (ScreenCols () - 1);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1511 int86 (0x33, &regs, &regs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1512
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1513 regs.x.ax = 0x0008;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1514 regs.x.cx = 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1515 regs.x.dx = 8 * (ScreenRows () - 1);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1516 int86 (0x33, &regs, &regs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1517
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1518 mouse_moveto (ScreenCols () - 1, ScreenRows () - 1);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1519 mouse_on ();
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1520 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1521
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1522 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1523 mouse_on ()
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1524 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1525 union REGS regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1526
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1527 if (have_mouse > 0)
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1528 {
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1529 regs.x.ax = 0x0001;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1530 int86 (0x33, &regs, &regs);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1531 }
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1532 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1533
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1534 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1535 mouse_off ()
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1536 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1537 union REGS regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1538
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1539 if (have_mouse > 0)
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1540 {
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1541 regs.x.ax = 0x0002;
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1542 int86 (0x33, &regs, &regs);
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1543 }
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1544 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1545
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1546 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1547 mouse_moveto (x, y)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1548 int x, y;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1549 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1550 union REGS regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1551
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1552 regs.x.ax = 0x0004;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1553 mouse_last_x = regs.x.cx = x * 8;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1554 mouse_last_y = regs.x.dx = y * 8;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1555 int86 (0x33, &regs, &regs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1556 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1557
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1558 int
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1559 mouse_pressed (b, xp, yp)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1560 int b, *xp, *yp;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1561 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1562 union REGS regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1563
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1564 if (b >= mouse_button_count)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1565 return 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1566 regs.x.ax = 0x0005;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1567 regs.x.bx = mouse_button_translate[b];
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1568 int86 (0x33, &regs, &regs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1569 if (regs.x.bx)
8183
d35fd7fd0ef8 (install_ctrl_break_check): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7821
diff changeset
1570 *xp = regs.x.cx / 8, *yp = regs.x.dx / 8;
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1571 return (regs.x.bx != 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1572 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1573
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1574 int
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1575 mouse_released (b, xp, yp)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1576 int b, *xp, *yp;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1577 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1578 union REGS regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1579
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1580 if (b >= mouse_button_count)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1581 return 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1582 regs.x.ax = 0x0006;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1583 regs.x.bx = mouse_button_translate[b];
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1584 int86 (0x33, &regs, &regs);
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1585 #if 0
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1586 if (regs.x.ax & (1 << mouse_button_translate[b]))
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1587 regs.x.bx = 0; /* if mouse is still pressed, ignore release */
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1588 #endif
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1589 if (regs.x.bx)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1590 *xp = regs.x.cx / 8, *yp = regs.x.dx / 8;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1591 return (regs.x.bx != 0);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1592 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1593
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1594 static void
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1595 mouse_get_xy (int *x, int *y)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1596 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1597 union REGS regs;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1598
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1599 regs.x.ax = 0x0003;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1600 int86 (0x33, &regs, &regs);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1601 *x = regs.x.cx / 8;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1602 *y = regs.x.dx / 8;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1603 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1604
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1605 void
11124
020042ee37cd (mouse_get_pos): New arg `insist'.
Richard M. Stallman <rms@gnu.org>
parents: 10504
diff changeset
1606 mouse_get_pos (f, insist, bar_window, part, x, y, time)
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1607 FRAME_PTR *f;
11124
020042ee37cd (mouse_get_pos): New arg `insist'.
Richard M. Stallman <rms@gnu.org>
parents: 10504
diff changeset
1608 int insist;
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1609 Lisp_Object *bar_window, *x, *y;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1610 enum scroll_bar_part *part;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1611 unsigned long *time;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1612 {
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1613 int ix, iy;
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1614 union REGS regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1615
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1616 regs.x.ax = 0x0003;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1617 int86 (0x33, &regs, &regs);
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1618 *f = selected_frame;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1619 *bar_window = Qnil;
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1620 mouse_get_xy (&ix, &iy);
12573
f8193b0f95ed (mouse_get_pos, mouse_check_moved, XMenuActivate):
Karl Heuer <kwzh@gnu.org>
parents: 11124
diff changeset
1621 selected_frame->mouse_moved = 0;
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1622 *x = make_number (ix);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1623 *y = make_number (iy);
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1624 *time = event_timestamp ();
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1625 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1626
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1627 void
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1628 mouse_check_moved ()
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1629 {
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1630 int x, y;
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1631
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1632 mouse_get_xy (&x, &y);
12573
f8193b0f95ed (mouse_get_pos, mouse_check_moved, XMenuActivate):
Karl Heuer <kwzh@gnu.org>
parents: 11124
diff changeset
1633 selected_frame->mouse_moved |= (x != mouse_last_x || y != mouse_last_y);
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1634 mouse_last_x = x;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1635 mouse_last_y = y;
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1636 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1637
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1638 int
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1639 mouse_init1 ()
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1640 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1641 union REGS regs;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1642 int present;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1643
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1644 #ifdef HAVE_X_WINDOWS
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1645 if (!inhibit_window_system)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1646 return 0;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1647 #endif
8246
d48c2b01fba5 (mouse_init1): Use alternate mouse detection for old mouse drivers.
Richard M. Stallman <rms@gnu.org>
parents: 8194
diff changeset
1648 if (!internal_terminal)
d48c2b01fba5 (mouse_init1): Use alternate mouse detection for old mouse drivers.
Richard M. Stallman <rms@gnu.org>
parents: 8194
diff changeset
1649 return 0;
d48c2b01fba5 (mouse_init1): Use alternate mouse detection for old mouse drivers.
Richard M. Stallman <rms@gnu.org>
parents: 8194
diff changeset
1650
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1651 regs.x.ax = 0x0021;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1652 int86 (0x33, &regs, &regs);
8246
d48c2b01fba5 (mouse_init1): Use alternate mouse detection for old mouse drivers.
Richard M. Stallman <rms@gnu.org>
parents: 8194
diff changeset
1653 present = (regs.x.ax & 0xffff) == 0xffff;
d48c2b01fba5 (mouse_init1): Use alternate mouse detection for old mouse drivers.
Richard M. Stallman <rms@gnu.org>
parents: 8194
diff changeset
1654 if (!present)
d48c2b01fba5 (mouse_init1): Use alternate mouse detection for old mouse drivers.
Richard M. Stallman <rms@gnu.org>
parents: 8194
diff changeset
1655 {
d48c2b01fba5 (mouse_init1): Use alternate mouse detection for old mouse drivers.
Richard M. Stallman <rms@gnu.org>
parents: 8194
diff changeset
1656 /* Reportedly, the above doesn't work for some mouse drivers. There
d48c2b01fba5 (mouse_init1): Use alternate mouse detection for old mouse drivers.
Richard M. Stallman <rms@gnu.org>
parents: 8194
diff changeset
1657 is an additional detection method that should work, but might be
d48c2b01fba5 (mouse_init1): Use alternate mouse detection for old mouse drivers.
Richard M. Stallman <rms@gnu.org>
parents: 8194
diff changeset
1658 a little slower. Use that as an alternative. */
d48c2b01fba5 (mouse_init1): Use alternate mouse detection for old mouse drivers.
Richard M. Stallman <rms@gnu.org>
parents: 8194
diff changeset
1659 regs.x.ax = 0x0000;
d48c2b01fba5 (mouse_init1): Use alternate mouse detection for old mouse drivers.
Richard M. Stallman <rms@gnu.org>
parents: 8194
diff changeset
1660 int86 (0x33, &regs, &regs);
d48c2b01fba5 (mouse_init1): Use alternate mouse detection for old mouse drivers.
Richard M. Stallman <rms@gnu.org>
parents: 8194
diff changeset
1661 present = (regs.x.ax & 0xffff) == 0xffff;
d48c2b01fba5 (mouse_init1): Use alternate mouse detection for old mouse drivers.
Richard M. Stallman <rms@gnu.org>
parents: 8194
diff changeset
1662 }
d48c2b01fba5 (mouse_init1): Use alternate mouse detection for old mouse drivers.
Richard M. Stallman <rms@gnu.org>
parents: 8194
diff changeset
1663
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1664 if (present)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1665 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1666 if (regs.x.bx == 3)
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1667 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1668 mouse_button_count = 3;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1669 mouse_button_translate[0] = 0; /* Left */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1670 mouse_button_translate[1] = 2; /* Middle */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1671 mouse_button_translate[2] = 1; /* Right */
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1672 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1673 else
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1674 {
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1675 mouse_button_count = 2;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1676 mouse_button_translate[0] = 0;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1677 mouse_button_translate[1] = 1;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1678 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1679 mouse_position_hook = &mouse_get_pos;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1680 mouse_init ();
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1681 }
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1682 return present;
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1683 }
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1684
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1685 #ifndef HAVE_X_WINDOWS
7273
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1686 /* See xterm.c for more info. */
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1687 void
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1688 pixel_to_glyph_coords (f, pix_x, pix_y, x, y, bounds, noclip)
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1689 FRAME_PTR f;
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1690 register int pix_x, pix_y;
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1691 register int *x, *y;
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1692 void /* XRectangle */ *bounds;
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1693 int noclip;
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1694 {
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1695 if (bounds) abort ();
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1696
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1697 /* Ignore clipping. */
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1698
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1699 *x = pix_x;
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1700 *y = pix_y;
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1701 }
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1702
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1703 void
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1704 glyph_to_pixel_coords (f, x, y, pix_x, pix_y)
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1705 FRAME_PTR f;
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1706 register int x, y;
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1707 register int *pix_x, *pix_y;
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1708 {
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1709 *pix_x = x;
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1710 *pix_y = y;
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
1711 }
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1712
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1713 /* Simulation of X's menus. Nothing too fancy here -- just make it work
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1714 for now.
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1715
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1716 Actually, I don't know the meaning of all the parameters of the functions
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1717 here -- I only know how they are called by xmenu.c. I could of course
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1718 grab the nearest Xlib manual (down the hall, second-to-last door on the
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1719 left), but I don't think it's worth the effort. */
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1720
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1721 static XMenu *
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1722 IT_menu_create ()
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1723 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1724 XMenu *menu;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1725
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1726 menu = (XMenu *) xmalloc (sizeof (XMenu));
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1727 menu->allocated = menu->count = menu->panecount = menu->width = 0;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1728 return menu;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1729 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1730
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1731 /* Allocate some (more) memory for MENU ensuring that there is room for one
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1732 for item. */
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1733
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1734 static void
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1735 IT_menu_make_room (XMenu *menu)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1736 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1737 if (menu->allocated == 0)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1738 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1739 int count = menu->allocated = 10;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1740 menu->text = (char **) xmalloc (count * sizeof (char *));
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1741 menu->submenu = (XMenu **) xmalloc (count * sizeof (XMenu *));
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1742 menu->panenumber = (int *) xmalloc (count * sizeof (int));
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1743 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1744 else if (menu->allocated == menu->count)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1745 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1746 int count = menu->allocated = menu->allocated + 10;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1747 menu->text
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1748 = (char **) xrealloc (menu->text, count * sizeof (char *));
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1749 menu->submenu
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1750 = (XMenu **) xrealloc (menu->submenu, count * sizeof (XMenu *));
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1751 menu->panenumber
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1752 = (int *) xrealloc (menu->panenumber, count * sizeof (int));
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1753 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1754 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1755
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1756 /* Search the given menu structure for a given pane number. */
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1757
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1758 static XMenu *
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1759 IT_menu_search_pane (XMenu *menu, int pane)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1760 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1761 int i;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1762 XMenu *try;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1763
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1764 for (i = 0; i < menu->count; i++)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1765 if (menu->submenu[i])
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1766 {
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1767 if (pane == menu->panenumber[i])
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1768 return menu->submenu[i];
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1769 else if ((try = IT_menu_search_pane (menu->submenu[i], pane)))
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1770 return try;
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1771 }
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1772 return (XMenu *) 0;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1773 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1774
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1775 /* Determine how much screen space a given menu needs. */
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1776
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1777 static void
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1778 IT_menu_calc_size (XMenu *menu, int *width, int *height)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1779 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1780 int i, h2, w2, maxsubwidth, maxheight;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1781
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1782 maxsubwidth = 0;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1783 maxheight = menu->count;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1784 for (i = 0; i < menu->count; i++)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1785 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1786 if (menu->submenu[i])
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1787 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1788 IT_menu_calc_size (menu->submenu[i], &w2, &h2);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1789 if (w2 > maxsubwidth) maxsubwidth = w2;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1790 if (i + h2 > maxheight) maxheight = i + h2;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1791 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1792 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1793 *width = menu->width + maxsubwidth;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1794 *height = maxheight;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1795 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1796
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1797 /* Display MENU at (X,Y) using FACES. */
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1798
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1799 static void
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1800 IT_menu_display (XMenu *menu, int y, int x, int *faces)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1801 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1802 int i, j, face, width;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1803 GLYPH *text, *p;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1804 char *q;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1805 int mx, my;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1806 int enabled, mousehere;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1807 int row, col;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1808
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1809 width = menu->width;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1810 text = (GLYPH *) xmalloc ((width + 2) * sizeof (GLYPH));
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1811 ScreenGetCursor (&row, &col);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1812 mouse_get_xy (&mx, &my);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1813 mouse_off ();
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1814 (*update_begin_hook) ();
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1815 for (i = 0; i < menu->count; i++)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1816 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1817 (*cursor_to_hook) (y + i, x);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1818 enabled
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1819 = (!menu->submenu[i] && menu->panenumber[i]) || (menu->submenu[i]);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1820 mousehere = (y + i == my && x <= mx && mx < x + width + 2);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1821 face = faces[enabled + mousehere * 2];
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1822 p = text;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1823 *p++ = FAST_MAKE_GLYPH (' ', face);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1824 for (j = 0, q = menu->text[i]; *q; j++)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1825 *p++ = FAST_MAKE_GLYPH (*q++, face);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1826 for (; j < width; j++)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1827 *p++ = FAST_MAKE_GLYPH (' ', face);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1828 *p++ = FAST_MAKE_GLYPH (menu->submenu[i] ? 16 : ' ', face);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1829 (*write_glyphs_hook) (text, width + 2);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1830 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1831 internal_flush (stdout);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1832 (*update_end_hook) ();
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1833 mouse_on ();
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1834 ScreenSetCursor (row, col);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1835 xfree (text);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1836 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1837
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1838 /* Create a brand new menu structure. */
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1839
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1840 XMenu *
10501
19c4a9ef23e5 (XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents: 9572
diff changeset
1841 XMenuCreate (Display *foo1, Window foo2, char *foo3)
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1842 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1843 return IT_menu_create ();
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1844 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1845
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1846 /* Create a new pane and place it on the outer-most level. It is not
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1847 clear that it should be placed out there, but I don't know what else
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1848 to do. */
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1849
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1850 int
10501
19c4a9ef23e5 (XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents: 9572
diff changeset
1851 XMenuAddPane (Display *foo, XMenu *menu, char *txt, int enable)
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1852 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1853 int len;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1854
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1855 if (!enable)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1856 abort ();
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1857
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1858 IT_menu_make_room (menu);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1859 menu->submenu[menu->count] = IT_menu_create ();
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1860 menu->text[menu->count] = txt;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1861 menu->panenumber[menu->count] = ++menu->panecount;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1862 menu->count++;
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1863 if ((len = strlen (txt)) > menu->width)
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1864 menu->width = len;
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1865 return menu->panecount;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1866 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1867
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1868 /* Create a new item in a menu pane. */
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1869
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1870 int
10501
19c4a9ef23e5 (XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents: 9572
diff changeset
1871 XMenuAddSelection (Display *bar, XMenu *menu, int pane,
19c4a9ef23e5 (XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents: 9572
diff changeset
1872 int foo, char *txt, int enable)
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1873 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1874 int len;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1875
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1876 if (pane)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1877 if (!(menu = IT_menu_search_pane (menu, pane)))
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1878 return XM_FAILURE;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1879 IT_menu_make_room (menu);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1880 menu->submenu[menu->count] = (XMenu *) 0;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1881 menu->text[menu->count] = txt;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1882 menu->panenumber[menu->count] = enable;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1883 menu->count++;
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1884 if ((len = strlen (txt)) > menu->width)
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1885 menu->width = len;
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1886 return XM_SUCCESS;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1887 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1888
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1889 /* Decide where the menu would be placed if requested at (X,Y). */
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1890
10501
19c4a9ef23e5 (XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents: 9572
diff changeset
1891 void
19c4a9ef23e5 (XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents: 9572
diff changeset
1892 XMenuLocate (Display *foo0, XMenu *menu, int foo1, int foo2, int x, int y,
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1893 int *ulx, int *uly, int *width, int *height)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1894 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1895 if (menu->count == 1 && menu->submenu[0])
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1896 /* Special case: the menu consists of only one pane. */
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1897 IT_menu_calc_size (menu->submenu[0], width, height);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1898 else
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1899 IT_menu_calc_size (menu, width, height);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1900 *ulx = x + 1;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1901 *uly = y;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1902 *width += 2;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1903 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1904
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1905 struct IT_menu_state
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1906 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1907 void *screen_behind;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1908 XMenu *menu;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1909 int pane;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1910 int x, y;
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1911 };
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1912
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1913
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1914 /* Display menu, wait for user's response, and return that response. */
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1915
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1916 int
10501
19c4a9ef23e5 (XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents: 9572
diff changeset
1917 XMenuActivate (Display *foo, XMenu *menu, int *pane, int *selidx,
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1918 int x0, int y0, unsigned ButtonMask, char **txt)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1919 {
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1920 struct IT_menu_state *state;
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1921 int statecount;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1922 int x, y, i, b;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1923 int screensize;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1924 int faces[4], selectface;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1925 int leave, result, onepane;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1926
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1927 /* Just in case we got here without a mouse present... */
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1928 if (have_mouse <= 0)
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1929 return XM_IA_SELECT;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1930
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
1931 state = alloca (menu->panecount * sizeof (struct IT_menu_state));
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1932 screensize = ScreenRows () * ScreenCols () * 2;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1933 faces[0]
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1934 = compute_glyph_face (&the_only_frame,
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1935 face_name_id_number
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1936 (&the_only_frame,
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1937 intern ("msdos-menu-passive-face")),
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1938 0);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1939 faces[1]
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1940 = compute_glyph_face (&the_only_frame,
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1941 face_name_id_number
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1942 (&the_only_frame,
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1943 intern ("msdos-menu-active-face")),
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1944 0);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1945 selectface
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1946 = face_name_id_number (&the_only_frame, intern ("msdos-menu-select-face"));
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1947 faces[2] = compute_glyph_face (&the_only_frame, selectface, faces[0]);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1948 faces[3] = compute_glyph_face (&the_only_frame, selectface, faces[1]);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1949
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1950 statecount = 1;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1951 state[0].menu = menu;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1952 mouse_off ();
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1953 ScreenRetrieve (state[0].screen_behind = xmalloc (screensize));
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1954 mouse_on ();
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1955 if ((onepane = menu->count == 1 && menu->submenu[0]))
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1956 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1957 menu->width = menu->submenu[0]->width;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1958 state[0].menu = menu->submenu[0];
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1959 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1960 else
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1961 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1962 state[0].menu = menu;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1963 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1964 state[0].x = x0 - 1;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1965 state[0].y = y0;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1966 state[0].pane = onepane;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1967
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1968 mouse_last_x = -1; /* A hack that forces display. */
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1969 leave = 0;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1970 while (!leave)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1971 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1972 mouse_check_moved ();
12573
f8193b0f95ed (mouse_get_pos, mouse_check_moved, XMenuActivate):
Karl Heuer <kwzh@gnu.org>
parents: 11124
diff changeset
1973 if (selected_frame->mouse_moved)
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1974 {
12573
f8193b0f95ed (mouse_get_pos, mouse_check_moved, XMenuActivate):
Karl Heuer <kwzh@gnu.org>
parents: 11124
diff changeset
1975 selected_frame->mouse_moved = 0;
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1976 result = XM_IA_SELECT;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1977 mouse_get_xy (&x, &y);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1978 for (i = 0; i < statecount; i++)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1979 if (state[i].x <= x && x < state[i].x + state[i].menu->width + 2)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1980 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1981 int dy = y - state[i].y;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1982 if (0 <= dy && dy < state[i].menu->count)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1983 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1984 if (!state[i].menu->submenu[dy])
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1985 if (state[i].menu->panenumber[dy])
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1986 result = XM_SUCCESS;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1987 else
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1988 result = XM_IA_SELECT;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1989 *pane = state[i].pane - 1;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1990 *selidx = dy;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1991 /* We hit some part of a menu, so drop extra menues that
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1992 have been opened. That does not include an open and
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1993 active submenu. */
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1994 if (i != statecount - 2
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1995 || state[i].menu->submenu[dy] != state[i+1].menu)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1996 while (i != statecount - 1)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1997 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1998 statecount--;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
1999 mouse_off ();
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2000 ScreenUpdate (state[statecount].screen_behind);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2001 mouse_on ();
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2002 xfree (state[statecount].screen_behind);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2003 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2004 if (i == statecount - 1 && state[i].menu->submenu[dy])
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2005 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2006 IT_menu_display (state[i].menu,
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2007 state[i].y,
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2008 state[i].x,
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2009 faces);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2010 state[statecount].menu = state[i].menu->submenu[dy];
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2011 state[statecount].pane = state[i].menu->panenumber[dy];
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2012 mouse_off ();
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2013 ScreenRetrieve (state[statecount].screen_behind
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2014 = xmalloc (screensize));
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2015 mouse_on ();
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2016 state[statecount].x
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2017 = state[i].x + state[i].menu->width + 2;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2018 state[statecount].y = y;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2019 statecount++;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2020 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2021 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2022 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2023 IT_menu_display (state[statecount - 1].menu,
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2024 state[statecount - 1].y,
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2025 state[statecount - 1].x,
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2026 faces);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2027 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2028 for (b = 0; b < mouse_button_count; b++)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2029 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2030 (void) mouse_pressed (b, &x, &y);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2031 if (mouse_released (b, &x, &y))
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2032 leave = 1;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2033 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2034 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2035
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2036 mouse_off ();
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2037 ScreenUpdate (state[0].screen_behind);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2038 mouse_on ();
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2039 while (statecount--)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2040 xfree (state[statecount].screen_behind);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2041 return result;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2042 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2043
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2044 /* Dispose of a menu. */
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
2045
10501
19c4a9ef23e5 (XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents: 9572
diff changeset
2046 void
19c4a9ef23e5 (XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents: 9572
diff changeset
2047 XMenuDestroy (Display *foo, XMenu *menu)
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2048 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2049 int i;
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2050 if (menu->allocated)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2051 {
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2052 for (i = 0; i < menu->count; i++)
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2053 if (menu->submenu[i])
10501
19c4a9ef23e5 (XMenuCreate, XMenuAddPane, XMenuAddSelection, XMenuLocate,
Richard M. Stallman <rms@gnu.org>
parents: 9572
diff changeset
2054 XMenuDestroy (foo, menu->submenu[i]);
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2055 xfree (menu->text);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2056 xfree (menu->submenu);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2057 xfree (menu->panenumber);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2058 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2059 xfree (menu);
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2060 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2061
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
2062 int
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
2063 x_pixel_width (struct frame *f)
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2064 {
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
2065 return FRAME_WIDTH (f);
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2066 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2067
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
2068 int
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
2069 x_pixel_height (struct frame *f)
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2070 {
12995
a3620c5ffad7 (putchar): Call internal_flush instead of _flsbuf.
Richard M. Stallman <rms@gnu.org>
parents: 12614
diff changeset
2071 return FRAME_HEIGHT (f);
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2072 }
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9118
diff changeset
2073 #endif /* !HAVE_X_WINDOWS */
7273
24426d7e14eb Finish downcasing mouse_init1, mouse_off,
Richard M. Stallman <rms@gnu.org>
parents: 6505
diff changeset
2074
5503
003e84b91d21 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2075 #endif /* MSDOS */