annotate lib-src/emacstool.c @ 13:13c6d0aaafe5

Added tag r19-15b7 for changeset bcdc7deadc19
author cvs
date Mon, 13 Aug 2007 08:48:18 +0200
parents 376386a54a3c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1986, 1988, 1990, 1991 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 This program is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 along with this program; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 Boston, MA 02111-1307, USA. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 * For Emacs in SunView/Sun-Windows: (supported by Sun Unix v3.2 or greater)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 * Insert a notifier filter-function to convert all useful input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 * to "key" sequences that emacs can understand. See: Emacstool(1).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 * Author: Jeff Peck, Sun Microsystems, Inc. <peck@eng.sun.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 * Original Idea: Ian Batten
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 * Updated 15-Mar-88, Jeff Peck: set IN_EMACSTOOL, TERM, TERMCAP
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 * Updated 10-Sep-88, Jeff Peck: add XVIEW and JLE support
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 * Updated 8-Oct-90, Jeff Peck: add Meta-bit for Xview
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 * Updated 6-Mar-91, Jeff Peck: Hack to detect -Wt invocation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 * [note, TTYSW limitation means you must Click-To-Type in Openwin]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 * [fixed in OW3 or use local/tty.o]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 * for better results, this should move to using TERMSW.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 * Updated 10-Mar-91, Jeff Peck, et al: support for TERMSW (TTERM)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 * allows point-to-type even in OW2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 * [note: xvetool should be started with the "-nw" flag for emacs!]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 #ifdef XVIEW
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 #include <xview/xview.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 #include <xview/panel.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 #include <xview/attr.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 #include <xview/tty.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 #include <xview/ttysw.h> /* private defines */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 #include <xview/termsw.h> /* -DTTERM */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 #include <xview/font.h> /* for testing */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 #include <suntool/sunview.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 #include <suntool/tty.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 #include <suntool/ttysw.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 #endif XVIEW
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 #ifdef JLE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 # include <locale.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 #endif JLE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 #include <stdio.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 #include <sys/file.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 #define BUFFER_SIZE 128 /* Size of all the buffers */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 /* define WANT_CAPS_LOCK to make f-key T1 (aka F1) behave as CapsLock */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 #define WANT_CAPS_LOCK
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 #ifdef WANT_CAPS_LOCK
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 int caps_lock; /* toggle indicator for f-key T1 caps lock */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 static char *Caps = "[CAPS] "; /* Caps Lock prefix string */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 #define CAPS_LEN 7 /* strlen (Caps) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 static char *mouse_prefix = "\030\000"; /* C-x C-@ */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 static int m_prefix_length = 2; /* mouse_prefix length */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 static char *key_prefix = "\030*"; /* C-x * */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 static int k_prefix_length = 2; /* key_prefix length */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 #ifdef JLE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 static char *emacs_name = "nemacs"; /* default run command */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 static char *title = "NEmacstool - "; /* initial title */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 static char *emacs_name = "emacs"; /* default run command */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 static char *title = "Emacstool - "; /* initial title */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 #endif JLE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 static char buffer[BUFFER_SIZE]; /* send to ttysw_input */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 static char *bold_name = 0; /* for -bold option */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 Frame frame; /* Base frame for system */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 #ifndef TTERM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 #define SWTYPE TTY
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 Tty tty_win; /* Where emacs is reading */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 #define SWTYPE TERMSW
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 Termsw tty_win; /* Termsw does follow-mouse */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 #endif TTERM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 #ifdef XVIEW
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 Xv_Window tty_view; /* Where the events are in Xview*/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 Tty tty_view; /* SunView place filler */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 #endif XVIEW
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 int font_width, font_height; /* For translating pixels to chars */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 int left_margin = 0; /* default window -- frame offset */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 int console_fd = 0; /* for debugging: setenv DEBUGEMACSTOOL */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 FILE *console; /* for debugging: setenv DEBUGEMACSTOOL */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 Icon frame_icon;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 /* make an icon_image for the default frame_icon */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 static short default_image[258] =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 #include <images/terminal.icon>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 mpr_static(icon_image, 64, 64, 1, default_image);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 * Assign a value to a set of keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 button_value (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 Event *event;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 int retval = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 * Code up the current situation:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 * 1 = MS_LEFT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 * 2 = MS_MIDDLE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 * 4 = MS_RIGHT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 * 8 = SHIFT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 * 16 = CONTROL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 * 32 = META;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 * 64 = DOUBLE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 * 128 = UP;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 if (MS_LEFT == (event_id (event))) retval = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 if (MS_MIDDLE == (event_id (event))) retval = 2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 if (MS_RIGHT == (event_id (event))) retval = 4;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 if (event_shift_is_down (event)) retval += 8;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 if (event_ctrl_is_down (event)) retval += 16;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 if (event_meta_is_down (event)) retval += 32;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 if (event_is_up (event)) retval += 128;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 return retval;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 * Variables to store the time of the previous mouse event that was
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 * sent to emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 * The theory is that to time double clicks while ignoreing UP buttons,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 * we must keep track of the accumulated time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 * If someone writes a SUN-SET-INPUT-MASK for emacstool,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 * That could be used to selectively disable UP events,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 * and then this cruft wouldn't be necessary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 static long prev_event_sec = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 static long prev_event_usec = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 * Give the time difference in milliseconds, where one second
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 * is considered infinite.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 time_delta (now_sec, now_usec, prev_sec, prev_usec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 long now_sec, now_usec, prev_sec, prev_usec;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 long sec_delta = now_sec - prev_sec;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 long usec_delta = now_usec - prev_usec;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 if (usec_delta < 0) { /* "borrow" a second */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 usec_delta += 1000000;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 --sec_delta;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 if (sec_delta >= 10)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 return (9999); /* Infinity */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 return ((sec_delta * 1000) + (usec_delta / 1000));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 * Filter function to translate selected input events for emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 * Mouse button events become ^X^@(button x-col y-line time-delta) .
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 * Function keys: ESC-*{c}{lrt} l,r,t for Left, Right, Top;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 * {c} encodes the keynumber as a character [a-o]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 static Notify_value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 input_event_filter_function (window, event, arg, type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 #ifdef XVIEW
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 Xv_Window window;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 Window window;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 #endif XVIEW
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 Event *event;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 Notify_arg arg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 Notify_event_type type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 struct timeval time_stamp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 if (console_fd) fprintf(console, "Event: %d\n", event_id(event));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 /* UP L1 is the STOP key */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 if (event_id(event) == WIN_STOP) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 ttysw_input(tty_win, "\007\007\007\007\007\007\007", 7);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 return NOTIFY_IGNORED;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 /* UP L5 & L7 is Expose & Open, let them pass to sunview */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 if (event_id(event) == KEY_LEFT(5) || event_id(event) == KEY_LEFT(7))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 if(event_is_up (event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 return notify_next_event_func (window, event, arg, type);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 else return NOTIFY_IGNORED;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 if (event_is_button (event)) { /* do Mouse Button events */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 /* Commented out so that we send mouse up events too.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 if (event_is_up (event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 return notify_next_event_func (window, event, arg, type);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 time_stamp = event_time (event);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 ttysw_input (tty_win, mouse_prefix, m_prefix_length);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 sprintf (buffer, "(%d %d %d %d)\015",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 button_value (event),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (event_x (event) - left_margin) / font_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 event_y (event) / font_height,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 time_delta (time_stamp.tv_sec, time_stamp.tv_usec,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 prev_event_sec, prev_event_usec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 ttysw_input (tty_win, buffer, strlen(buffer));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 prev_event_sec = time_stamp.tv_sec;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 prev_event_usec = time_stamp.tv_usec;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 return NOTIFY_IGNORED;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 { /* Do the function key events */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 int d;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 char c = (char) 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 if ((event_is_key_left (event)) ?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 ((d = event_id(event) - KEY_LEFT(1) + 'a'), c='l') :
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 ((event_is_key_right (event)) ?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 ((d = event_id(event) - KEY_RIGHT(1) + 'a'), c='r') :
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 ((event_is_key_top (event)) ?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 ((d = event_id(event) - KEY_TOP(1) + 'a'), c='t') : 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 if (event_is_up(event)) return NOTIFY_IGNORED;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 if (event_shift_is_down (event)) c = c - 32;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 /* this will give a non-{lrt} for unshifted keys */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 if (event_ctrl_is_down (event)) c = c - 64;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 if (event_meta_is_down (event)) c = c + 128;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 #ifdef WANT_CAPS_LOCK
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 /* set a toggle and relabel window so T1 can act like caps-lock */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 if (event_id(event) == KEY_TOP(1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 /* make a frame label with and without CAPS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 strcpy (buffer, Caps);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 title = &buffer[CAPS_LEN];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 strncpy (title, (char *)window_get (frame, FRAME_LABEL),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 BUFFER_SIZE - CAPS_LEN);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 buffer[BUFFER_SIZE] = (char) 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 if (strncmp (title, Caps, CAPS_LEN) == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 title += CAPS_LEN; /* already Caps */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 caps_lock = (caps_lock ? 0 : CAPS_LEN);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 window_set(frame, FRAME_LABEL, (title -= caps_lock), 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 return NOTIFY_IGNORED;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 ttysw_input (tty_win, key_prefix, k_prefix_length);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 sprintf (buffer, "%c%c", d, c);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 ttysw_input(tty_win, buffer, strlen(buffer));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 return NOTIFY_IGNORED;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 if ((event_is_ascii(event) || event_is_meta(event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 && event_is_up(event)) return NOTIFY_IGNORED;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 #ifdef WANT_CAPS_LOCK
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 /* shift alpha chars to upper case if toggle is set */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 if ((caps_lock) && event_is_ascii(event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 && (event_id(event) >= 'a') && (event_id(event) <= 'z'))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 event_set_id(event, (event_id(event) - 32));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 /* crufty, but it works for now. is there an UPCASE(event)? */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 #ifndef NO_META_BIT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 /* under Openwindows/X, the meta bit is not set in the key event,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 * emacs expects this so we add it in here:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 if (event_is_ascii(event) && event_meta_is_down(event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 event_set_id(event, 128 | event_id(event));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 return notify_next_event_func (window, event, arg, type);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 main (argc, argv)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 int argc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 char **argv;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 int error_code; /* Error codes */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 #ifdef JLE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 setlocale(LC_ALL, "");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 #endif JLE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 if(getenv("DEBUGEMACSTOOL"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 console = fdopen (console_fd = open("/dev/console",O_WRONLY), "w");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 putenv("IN_EMACSTOOL=t"); /* notify subprocess that it is in emacstool */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 if (putenv("TERM=sun") != 0) /* TTY_WIN will be a TERM=sun window */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 {fprintf (stderr, "%s: Could not set TERM=sun, using `%s'\n",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 argv[0], (char *)getenv("TERM")) ;};
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 * If TERMCAP starts with a slash, it is the pathname of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 * termcap file, not an entry extracted from it, so KEEP it!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 * Otherwise, it may not relate to the new TERM, so Nuke-It.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 * If there is no TERMCAP environment variable, don't make one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 char *termcap ; /* Current TERMCAP value */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 termcap = (char *)getenv("TERMCAP") ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 if (termcap && (*termcap != '/'))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 if (putenv("TERMCAP=") != 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 {fprintf (stderr, "%s: Could not clear TERMCAP\n", argv[0]) ;} ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 } ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 } ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 /* find command to run as subprocess in window */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 if (!(argv[0] = (char *)getenv("EMACSTOOL"))) /* Set emacs command name */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 argv[0] = emacs_name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 /* Emacstool recognizes two special args: -rc <file> and -bold <bold-name> */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 for (argc = 1; argv[argc]; argc++) /* Use last one on line */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 if(!(strcmp ("-rc", argv[argc]))) /* Override if -rc given */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 {int i = argc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 argv[argc--]=0; /* kill the -rc argument */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 if (argv[i+1]) { /* move to argv[0] and squeeze the rest */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 argv[0]=argv[i+1];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 for (; argv[i+2]; (argv[i]=argv[i+2],argv[++i]=0));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 if (!(strcmp ("-bold", argv[argc])))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 {int i = argc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 argv[argc--]=0; /* kill the -bold argument */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 if (argv[i+1]) { /* move to bold_name and squeeze the rest */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 bold_name = argv[i+1];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 for (; argv[i+2]; (argv[i]=argv[i+2],argv[++i]=0));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 strcpy (buffer, title);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 strncat (buffer, argv[0], /* append run command name */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (BUFFER_SIZE - (strlen (buffer)) - (strlen (argv[0]))) - 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 error_code = interpose_on_window(argc,argv);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 if (error_code != 0) { /* Barf */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 fprintf (stderr, "notify_interpose_event_func returns %d.\n", error_code);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 exit (1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 #ifdef XVIEW
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 xv_main_loop (frame); /* And away we go */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 window_main_loop (frame);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 #endif XVIEW
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 #ifdef XVIEW
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 int interpose_on_window(argc,argv)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 int argc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 char **argv;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 #ifndef TTERM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 int i, font_width_adjust = 1; /* hackery, and hueristics */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 /* if -Wt is not supplied, then font comes out as lucida-14 (width=8)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 * rather than the screen.r.12 (width=7) typically used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 * this hack attempts to workaround it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 * could use a env var EMACSTOOL_DEFAULT_FONT_WIDTH instead */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 for (i = 1; argv[i]; i++) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 if (!(strcmp ("-Wt", argv[i])))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 {font_width_adjust = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 if (console_fd) fprintf(console, "-Wt = %d\n", font_width_adjust);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 break;}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 #endif TTERM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 /* initialize Xview, and strip window args */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 xv_init(XV_INIT_ARGC_PTR_ARGV, &argc, argv, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 /* do this first, so arglist can override it */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 frame_icon = icon_create (ICON_LABEL, "Emacstool",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 ICON_IMAGE, &icon_image,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 /* Build a frame to run in */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 frame = xv_create ((Xv_Window)NULL, FRAME,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 FRAME_LABEL, buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 FRAME_ICON, frame_icon,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 /* Create a tty with emacs in it */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 tty_win = xv_create (frame, SWTYPE, WIN_IS_CLIENT_PANE,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 TTY_QUIT_ON_CHILD_DEATH, TRUE,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 TTY_BOLDSTYLE, TTYSW_BOLD_INVERT,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 TTY_ARGV, argv,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 if (bold_name) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (void)xv_set(tty_win, TTY_BOLDSTYLE_NAME, bold_name, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 Xv_font font; /* declare temp font variable */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 font = (Xv_font)xv_get (tty_win, XV_FONT);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 font_height = (int)xv_get (font, FONT_DEFAULT_CHAR_HEIGHT);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 font_width = (int)xv_get (font, FONT_DEFAULT_CHAR_WIDTH);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 if (console_fd) fprintf(console, "Width = %d\n", font_width);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 #ifndef TTERM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 font_width -= font_width_adjust; /* A guess! font bug in ttysw*/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 /* make the termsw act as a tty */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 xv_set(tty_win, TERMSW_MODE, TTYSW_MODE_TYPE, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 /* termsw has variable offset depending on scrollbar size/location */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 left_margin = (int)xv_get (tty_win, TEXTSW_LEFT_MARGIN);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 #endif TTERM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 tty_view = (Xv_Window) xv_get (tty_win, OPENWIN_NTH_VIEW, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 xv_set(tty_view,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 WIN_CONSUME_EVENTS,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 WIN_MOUSE_BUTTONS, WIN_UP_EVENTS,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 ACTION_ADJUST, ACTION_MENU,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 WIN_ASCII_EVENTS,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 WIN_LEFT_KEYS, WIN_TOP_KEYS, WIN_RIGHT_KEYS,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 0,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 /* Interpose my event function */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 return (int) notify_interpose_event_func
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (tty_view, input_event_filter_function, NOTIFY_SAFE);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 int interpose_on_window (argc, argv)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 int argc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 char **argv;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 /* do this first, so arglist can override it */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 frame_icon = icon_create (ICON_LABEL, "Emacstool",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 ICON_IMAGE, &icon_image,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 /* Build a frame to run in */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 frame = window_create ((Window)NULL, FRAME,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 FRAME_LABEL, buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 FRAME_ICON, frame_icon,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 FRAME_ARGC_PTR_ARGV, &argc, argv,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 /* Create a tty with emacs in it */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 tty_win = window_create (frame, TTY,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 TTY_QUIT_ON_CHILD_DEATH, TRUE,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 TTY_BOLDSTYLE, TTYSW_BOLD_INVERT,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 TTY_ARGV, argv,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 if (bold_name) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (void)window_set(tty_win, TTY_BOLDSTYLE_NAME, bold_name, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 /* ttysw uses pf_default, one must set WIN_FONT explicitly */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 window_set (tty_win, WIN_FONT, pf_default(), 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 font_height = (int)window_get (tty_win, WIN_ROW_HEIGHT);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 font_width = (int)window_get (tty_win, WIN_COLUMN_WIDTH);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 tty_view = tty_win;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 window_set(tty_view,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 WIN_CONSUME_PICK_EVENTS,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 WIN_STOP,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 WIN_MOUSE_BUTTONS, WIN_UP_EVENTS,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 /* LOC_WINENTER, LOC_WINEXIT, LOC_MOVE, */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 0,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 WIN_CONSUME_KBD_EVENTS,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 WIN_STOP,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 WIN_ASCII_EVENTS,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 WIN_LEFT_KEYS, WIN_TOP_KEYS, WIN_RIGHT_KEYS,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 /* WIN_UP_ASCII_EVENTS, */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 0,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 /* Interpose my event function */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 return (int) notify_interpose_event_func
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (tty_view, input_event_filter_function, NOTIFY_SAFE);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 #endif XVIEW