annotate src/integration.c @ 1249:a3362a9b6494

updated for version 7.1
author vimboss
date Sat, 12 May 2007 13:48:35 +0000
parents e6e639f0cb97
children b9740fb41986
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 /* vi:set ts=8 sw=8:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 * Visual Workshop integration by Gordon Prieur
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 * Do ":help uganda" in Vim to read copying and usage conditions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 * Do ":help credits" in Vim to see a list of people who contributed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 * See README.txt for an overview of the Vim source code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 * Integration with Sun Workshop.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 * This file should not change much, it's also used by other editors that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 * connect to Workshop. Consider changing workshop.c instead.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 -> consider using MakeSelectionVisible instead of gotoLine hacks
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 to show the line properly
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 -> consider using glue instead of our own message wrapping functions
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 (but can only use glue if we don't have to distribute source)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 #include "vim.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 #include <stdio.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 #include <stdlib.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 #include <fcntl.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 #ifdef INET_SOCKETS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 #include <netdb.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 #include <netinet/in.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 #include <sys/un.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 #include <errno.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 #include <sys/types.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 #include <sys/socket.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 #include <sys/param.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 #ifdef HAVE_LIBGEN_H
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 # include <libgen.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 #include <unistd.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 #include <string.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 #include <X11/Intrinsic.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 #include <Xm/Xm.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 #include <Xm/AtomMgr.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 #include <Xm/PushB.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 #ifdef HAVE_X11_XPM_H
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 # include <X11/xpm.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 # ifdef HAVE_XM_XPMP_H
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 # include <Xm/XpmP.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 #ifdef HAVE_UTIL_DEBUG_H
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 # include <util/debug.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 #ifdef HAVE_UTIL_MSGI18N_H
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 # include <util/msgi18n.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 #include "integration.h" /* <EditPlugin/integration.h> */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 #ifdef HAVE_FRAME_H
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 # include <frame.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 #ifndef MAX
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 # define MAX(a, b) (a) > (b) ? (a) : (b)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 #ifndef NOCATGETS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 # define NOCATGETS(x) x
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 /* Functions private to this file */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 static void workshop_connection_closed(void);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 static void messageFromEserve(XtPointer clientData, int *NOTUSED1, XtInputId *NOTUSED2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 static void workshop_disconnect(void);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 static void workshop_sensitivity(int num, char *table);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 static void adjust_sign_name(char *filename);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 static void process_menuItem(char *);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 static void process_toolbarButton(char *);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 static void workshop_set_option_first(char *name, char *value);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 #define CMDBUFSIZ 2048
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 #ifdef DEBUG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 static FILE *dfd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 static void pldebug(char *, ...);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 static void unrecognised_message(char *);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 #define HANDLE_ERRORS(cmd) else unrecognised_message(cmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 #define HANDLE_ERRORS(cmd)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 * Version number of the protocol between an editor and eserve.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 * This number should be incremented when the protocol
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 * is changed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 #define PROTOCOL_VERSION "4.0.0"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 static int sd = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 static XtInputId inputHandler; /* Cookie for input */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 Boolean save_files = True; /* When true, save all files before build actions */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 workshop_connection_closed(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 * socket closed on other end
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 XtRemoveInput(inputHandler);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 inputHandler = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 sd = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 static char *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 getCommand(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 int len; /* length of this command */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 char lenbuf[7]; /* get the length string here */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 char *newcb; /* used to realloc cmdbuf */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 static char *cmdbuf;/* get the command string here */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 static int cbsize;/* size of cmdbuf */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 if ((len = read(sd, &lenbuf, 6)) == 6) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 lenbuf[6] = 0; /* Terminate buffer such that atoi() works right */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 len = atoi(lenbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 if (cbsize < (len + 1)) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 newcb = (char *) realloc(cmdbuf,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 MAX((len + 256), CMDBUFSIZ));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 if (newcb != NULL) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 cmdbuf = newcb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 cbsize = MAX((len + 256), CMDBUFSIZ);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 if (cbsize >= len && (len = read(sd, cmdbuf, len)) > 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 cmdbuf[len] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 return cmdbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 } else {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 } else {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 if (len == 0) { /* EOF */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 workshop_connection_closed();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 /*ARGSUSED*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 messageFromEserve(XtPointer clientData, int *NOTUSED1, XtInputId *NOTUSED2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 char *cmd; /* the 1st word of the command */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 cmd = getCommand();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 if (cmd == NULL) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169 /* We're being shut down by eserve and the "quit" message
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 * didn't arrive before the socket connection got closed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 #ifdef DEBUG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 pldebug("%s\n", cmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 switch (*cmd) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 case 'a':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 if (cmd[1] == 'c' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 strncmp(cmd, NOCATGETS("ack "), 4) == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 int ackNum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 char buf[20];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 ackNum = atoi(&cmd[4]);
272
ddada568db54 updated for version 7.0073
vimboss
parents: 7
diff changeset
184 vim_snprintf(buf, sizeof(buf),
ddada568db54 updated for version 7.0073
vimboss
parents: 7
diff changeset
185 NOCATGETS("ack %d\n"), ackNum);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 write(sd, buf, strlen(buf));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 } else if (strncmp(cmd,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 NOCATGETS("addMarkType "), 12) == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 int idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 char *color;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 char *sign;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 idx = atoi(strtok(&cmd[12], " "));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 color = strtok(NULL, NOCATGETS("\001"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 sign = strtok(NULL, NOCATGETS("\001"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 /* Skip space that separates names */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 if (color) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 color++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 if (sign) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 sign++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 /* Change sign name to accomodate a different size? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 adjust_sign_name(sign);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 workshop_add_mark_type(idx, color, sign);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 HANDLE_ERRORS(cmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 case 'b':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211 if (strncmp(cmd,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 NOCATGETS("balloon "), 8) == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 char *tip;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 tip = strtok(&cmd[8], NOCATGETS("\001"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 workshop_show_balloon_tip(tip);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218 HANDLE_ERRORS(cmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221 case 'c':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 if (strncmp(cmd,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 NOCATGETS("changeMarkType "), 15) == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 char *file;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 int markId;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226 int type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 file = strtok(&cmd[15], " ");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229 markId = atoi(strtok(NULL, " "));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 type = atoi(strtok(NULL, " "));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231 workshop_change_mark_type(file, markId, type);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233 HANDLE_ERRORS(cmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 case 'd':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 if (strncmp(cmd, NOCATGETS("deleteMark "), 11) == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238 char *file;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 int markId;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 file = strtok(&cmd[11], " ");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 markId = atoi(strtok(NULL, " "));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 workshop_delete_mark(file, markId);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245 HANDLE_ERRORS(cmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248 case 'f':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 if (cmd[1] == 'o' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250 strncmp(cmd, NOCATGETS("footerMsg "), 10) == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251 int severity;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 char *message;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254 severity =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 atoi(strtok(&cmd[10], " "));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 message = strtok(NULL, NOCATGETS("\001"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258 workshop_footer_message(message, severity);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259 } else if (strncmp(cmd,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260 NOCATGETS("frontFile "), 10) == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 char *file;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263 file = strtok(&cmd[10], " ");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264 workshop_front_file(file);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
266 HANDLE_ERRORS(cmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
267 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269 case 'g':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270 if (cmd[1] == 'e' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271 strncmp(cmd, NOCATGETS("getMarkLine "), 12) == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272 char *file;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273 int markid;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274 int line;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
275 char buf[100];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
276
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
277 file = strtok(&cmd[12], " ");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278 markid = atoi(strtok(NULL, " "));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279 line = workshop_get_mark_lineno(file, markid);
272
ddada568db54 updated for version 7.0073
vimboss
parents: 7
diff changeset
280 vim_snprintf(buf, sizeof(buf),
ddada568db54 updated for version 7.0073
vimboss
parents: 7
diff changeset
281 NOCATGETS("markLine %s %d %d\n"),
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282 file, markid, line);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283 write(sd, buf, strlen(buf));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284 } else if (cmd[1] == 'o' && cmd[4] == 'L' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285 strncmp(cmd, NOCATGETS("gotoLine "), 9) == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286 char *file;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287 int lineno;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289 file = strtok(&cmd[9], " ");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290 lineno = atoi(strtok(NULL, " "));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
291 workshop_goto_line(file, lineno);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292 } else if (strncmp(cmd,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293 NOCATGETS("gotoMark "), 9) == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294 char *file;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
295 int markId;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
296 char *message;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
297
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
298 file = strtok(&cmd[9], " ");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
299 markId = atoi(strtok(NULL, " "));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
300 message = strtok(NULL, NOCATGETS("\001"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
301 workshop_goto_mark(file, markId, message);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
302 #ifdef NOHANDS_SUPPORT_FUNCTIONS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
303 } else if (strcmp(cmd, NOCATGETS("getCurrentFile")) == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
304 char *f = workshop_test_getcurrentfile();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
305 char buffer[2*MAXPATHLEN];
272
ddada568db54 updated for version 7.0073
vimboss
parents: 7
diff changeset
306 vim_snprintf(buffer, sizeof(buffer),
ddada568db54 updated for version 7.0073
vimboss
parents: 7
diff changeset
307 NOCATGETS("currentFile %d %s"),
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
308 f ? strlen(f) : 0, f ? f : "");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
309 workshop_send_message(buffer);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
310 } else if (strcmp(cmd, NOCATGETS("getCursorRow")) == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
311 int row = workshop_test_getcursorrow();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
312 char buffer[2*MAXPATHLEN];
272
ddada568db54 updated for version 7.0073
vimboss
parents: 7
diff changeset
313 vim_snprintf(buffer, sizeof(buffer),
ddada568db54 updated for version 7.0073
vimboss
parents: 7
diff changeset
314 NOCATGETS("cursorRow %d"), row);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
315 workshop_send_message(buffer);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
316 } else if (strcmp(cmd, NOCATGETS("getCursorCol")) == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
317 int col = workshop_test_getcursorcol();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
318 char buffer[2*MAXPATHLEN];
272
ddada568db54 updated for version 7.0073
vimboss
parents: 7
diff changeset
319 vim_snprintf(buffer, sizeof(buffer),
ddada568db54 updated for version 7.0073
vimboss
parents: 7
diff changeset
320 NOCATGETS("cursorCol %d"), col);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
321 workshop_send_message(buffer);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
322 } else if (strcmp(cmd, NOCATGETS("getCursorRowText")) == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
323 char *t = workshop_test_getcursorrowtext();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
324 char buffer[2*MAXPATHLEN];
272
ddada568db54 updated for version 7.0073
vimboss
parents: 7
diff changeset
325 vim_snprintf(buffer, sizeof(buffer),
ddada568db54 updated for version 7.0073
vimboss
parents: 7
diff changeset
326 NOCATGETS("cursorRowText %d %s"),
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
327 t ? strlen(t) : 0, t ? t : "");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
328 workshop_send_message(buffer);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
329 } else if (strcmp(cmd, NOCATGETS("getSelectedText")) == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
330 char *t = workshop_test_getselectedtext();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
331 char buffer[2*MAXPATHLEN];
272
ddada568db54 updated for version 7.0073
vimboss
parents: 7
diff changeset
332 vim_snprintf(buffer, sizeof(buffer),
ddada568db54 updated for version 7.0073
vimboss
parents: 7
diff changeset
333 NOCATGETS("selectedText %d %s"),
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
334 t ? strlen(t) : 0, t ? t : "");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
335 workshop_send_message(buffer);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
336 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
337 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
338 HANDLE_ERRORS(cmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
339 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
340
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
341 case 'l':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
342 if (strncmp(cmd, NOCATGETS("loadFile "), 9) == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
343 char *file;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
344 int line;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
345 char *frameid;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
346
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347 file = strtok(&cmd[9], " ");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348 line = atoi(strtok(NULL, " "));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349 frameid = strtok(NULL, " ");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350 workshop_load_file(file, line, frameid);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 HANDLE_ERRORS(cmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355 case 'm': /* Menu, minimize, maximize */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356 if (cmd[1] == 'e' && cmd[4] == 'B' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
357 strncmp(cmd, NOCATGETS("menuBegin "), 10) == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358 workshop_menu_begin(&cmd[10]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359 } else if (cmd[1] == 'e' && cmd[4] == 'I' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360 strncmp(cmd, NOCATGETS("menuItem "), 9) == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361 process_menuItem(cmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362 } else if (cmd[1] == 'e' && cmd[4] == 'E' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
363 strcmp(cmd, NOCATGETS("menuEnd")) == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364 workshop_menu_end();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
365 } else if (cmd[1] == 'a' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366 strcmp(cmd, NOCATGETS("maximize")) == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
367 workshop_maximize();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
368 } else if (strcmp(cmd, NOCATGETS("minimize")) == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
369 workshop_minimize();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
370 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
371 HANDLE_ERRORS(cmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
372 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374 case 'o':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375 if (cmd[1] == 'p' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376 strcmp(cmd, NOCATGETS("option"))) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
377 char *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
378 char *value;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
379
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
380 name = strtok(&cmd[7], " ");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
381 value = strtok(NULL, " ");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
382 workshop_set_option_first(name, value);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
383 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
384 HANDLE_ERRORS(cmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
385 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
386
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
387 case 'p':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
388 if (strcmp(cmd, NOCATGETS("ping")) == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
389 #if 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390 int pingNum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
391
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
392 pingNum = atoi(&cmd[5]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393 workshop_send_ack(ackNum);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
394 WHAT DO I DO HERE?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397 HANDLE_ERRORS(cmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
398 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
400 case 'q':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401 if (strncmp(cmd, NOCATGETS("quit"), 4) == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
402
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403 /* Close the connection. It's important to do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404 * that now, since workshop_quit might be
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405 * looking at open files. For example, if you
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
406 * have modified one of the files without
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
407 * saving, NEdit will ask you what you want to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
408 * do, and spin loop by calling
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
409 * XtAppProcessEvent while waiting for your
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
410 * reply. In this case, if we still have an
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
411 * input handler and the socket has been
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
412 * closed on the other side when eserve
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
413 * expired, we will hang in IoWait.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
414 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
415 workshop_disconnect();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
416
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
417 workshop_quit();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
418 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
419 HANDLE_ERRORS(cmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
420 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
421
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
422 case 'r':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
423 if (cmd[1] == 'e' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
424 strncmp(cmd, NOCATGETS("reloadFile "), 11) == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
425 char *file;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
426 int line;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
427
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
428 file = strtok(&cmd[11], " ");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
429 line = atoi(strtok(NULL, " "));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
430 workshop_reload_file(file, line);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
431 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
432 HANDLE_ERRORS(cmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
433 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
434
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
435 case 's':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
436 if (cmd[1] == 'e' && cmd[2] == 't' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
437 strncmp(cmd, NOCATGETS("setMark "), 8) == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
438 char *file;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
439 int line;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
440 int markId;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
441 int type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
442
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
443 file = strtok(&cmd[8], " ");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
444 line = atoi(strtok(NULL, " "));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
445 markId = atoi(strtok(NULL, " "));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
446 type = atoi(strtok(NULL, " "));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
447 workshop_set_mark(file, line, markId, type);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
448 } else if (cmd[1] == 'h' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
449 strncmp(cmd, NOCATGETS("showFile "), 9) == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
450 workshop_show_file(&cmd[9]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
451 } else if (cmd[1] == 'u' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
452 strncmp(cmd, NOCATGETS("subMenu "), 8) == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
453 char *label;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
454
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
455 label = strtok(&cmd[8], NOCATGETS("\001"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
456 workshop_submenu_begin(label);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
457 } else if (cmd[1] == 'u' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
458 strcmp(cmd, NOCATGETS("subMenuEnd")) == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
459 workshop_submenu_end();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
460 } else if (cmd[1] == 'e' && cmd[2] == 'n' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
461 strncmp(cmd, NOCATGETS("sensitivity "), 12) == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
462 int num;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
463 char *bracket;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
464 char *table;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
465
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
466 num = atoi(strtok(&cmd[12], " "));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
467 bracket = strtok(NULL, " ");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
468 if (*bracket != '[') {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
469 fprintf(stderr, NOCATGETS("Parsing "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
470 "error for sensitivity\n"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
471 } else {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
472 table = strtok(NULL, NOCATGETS("]"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
473 workshop_sensitivity(num, table);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
474 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
475 } else if (cmd[1] == 'e' && cmd[2] == 'n' && cmd[3] == 'd' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
476 strncmp(cmd, NOCATGETS("sendVerb "), 9) == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
477 /* Send the given verb back (used for the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
478 * debug.lineno callback (such that other tools
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
479 * can obtain the position coordinates or the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
480 * selection) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
481 char *verb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
482
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
483 verb = strtok(&cmd[9], " ");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
484 workshop_perform_verb(verb, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
485 } else if (cmd[1] == 'a' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
486 strncmp(cmd, NOCATGETS("saveFile "), 9) == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
487 workshop_save_file(&cmd[9]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
488 #ifdef NOHANDS_SUPPORT_FUNCTIONS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
489 } else if (strncmp(cmd, NOCATGETS("saveSensitivity "), 16) == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
490 char *file;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
491
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
492 file = strtok(&cmd[16], " ");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
493 workshop_save_sensitivity(file);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
494 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
495 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
496 HANDLE_ERRORS(cmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
497 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
498
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
499 case 't': /* Toolbar */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
500 if (cmd[8] == 'e' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
501 strncmp(cmd, NOCATGETS("toolbarBegin"), 12) == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
502 workshop_toolbar_begin();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
503 } else if (cmd[8] == 'u' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
504 strncmp(cmd, NOCATGETS("toolbarButton"), 13) == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
505 process_toolbarButton(cmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
506 } else if (cmd[7] == 'E' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
507 strcmp(cmd, NOCATGETS("toolbarEnd")) == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
508 workshop_toolbar_end();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
509 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
510 HANDLE_ERRORS(cmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
511 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
512
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
513 #ifdef DEBUG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
514 default:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
515 unrecognised_message(cmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
516 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
517 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
518 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
519 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
520
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
521 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
522 process_menuItem(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
523 char *cmd)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
524 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
525 char *label = strtok(&cmd[9], NOCATGETS("\001"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
526 char *verb = strtok(NULL, NOCATGETS("\001"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
527 char *acc = strtok(NULL, NOCATGETS("\001"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
528 char *accText = strtok(NULL, NOCATGETS("\001"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
529 char *name = strtok(NULL, NOCATGETS("\001"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
530 char *sense = strtok(NULL, NOCATGETS("\n"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
531 char *filepos = strtok(NULL, NOCATGETS("\n"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
532 if (*acc == '-') {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
533 acc = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
534 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
535 if (*accText == '-') {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
536 accText = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
537 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
538 workshop_menu_item(label, verb, acc, accText, name, filepos, sense);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
539
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
540 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
541
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
542
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
543 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
544 process_toolbarButton(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
545 char *cmd) /* button definition */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
546 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
547 char *label = strtok(&cmd[14], NOCATGETS("\001"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
548 char *verb = strtok(NULL, NOCATGETS("\001"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
549 char *senseVerb = strtok(NULL, NOCATGETS("\001"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
550 char *filepos = strtok(NULL, NOCATGETS("\001"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
551 char *help = strtok(NULL, NOCATGETS("\001"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
552 char *sense = strtok(NULL, NOCATGETS("\001"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
553 char *file = strtok(NULL, NOCATGETS("\001"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
554 char *left = strtok(NULL, NOCATGETS("\n"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
555
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
556 if (!strcmp(label, NOCATGETS("-"))) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
557 label = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
558 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
559 if (!strcmp(help, NOCATGETS("-"))) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
560 help = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
561 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
562 if (!strcmp(file, NOCATGETS("-"))) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
563 file = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
564 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
565 if (!strcmp(senseVerb, NOCATGETS("-"))) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
566 senseVerb = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
567 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
568 workshop_toolbar_button(label, verb, senseVerb, filepos, help,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
569 sense, file, left);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
570 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
571
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
572
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
573 #ifdef DEBUG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
574 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
575 unrecognised_message(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
576 char *cmd)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
577 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
578 pldebug("Unrecognised eserve message:\n\t%s\n", cmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
579 /* abort(); */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
580 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
581 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
582
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
583
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
584 /* Change sign name to accomodate a different size:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585 * Create the filename based on the height. The filename format
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
586 * of multisize icons are:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
587 * x.xpm : largest icon
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
588 * x1.xpm : smaller icon
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589 * x2.xpm : smallest icon */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
590 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
591 adjust_sign_name(char *filename)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
592 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
593 char *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
594 static int fontSize = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
595
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
596 if (fontSize == -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
597 fontSize = workshop_get_font_height();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
598 if (fontSize == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
599 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
600 if (filename[0] == '-')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
601 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
602
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
603 /* This is ugly: later we should instead pass the fontheight over
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
604 * to eserve on startup and let eserve just send the right filenames
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
605 * to us in the first place
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
606
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
607 * I know that the filename will end with 1.xpm (see
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
608 * GuiEditor.cc`LispPrintSign if you wonder why) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609 s = filename+strlen(filename)-5;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
610 if (fontSize <= 11)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611 strcpy(s, "2.xpm");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
612 else if (fontSize <= 15)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
613 strcpy(s, "1.xpm");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
614 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
615 strcpy(s, ".xpm");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
616 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
617
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
618 /* Were we invoked by WorkShop? This function can be used early during startup
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
619 if you want to do things differently if the editor is started standalone
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
620 or in WorkShop mode. For example, in standalone mode you may not want to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
621 add a footer/message area or a sign gutter. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
622 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
623 workshop_invoked()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
624 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
625 static int result = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
626 if (result == -1) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
627 result = (getenv(NOCATGETS("SPRO_EDITOR_SOCKET")) != NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
628 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
629 return result;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
630 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
631
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
632 /* Connect back to eserve */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
633 void workshop_connect(XtAppContext context)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
634 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
635 #ifdef INET_SOCKETS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
636 struct sockaddr_in server;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
637 struct hostent * host;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
638 int port;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
639 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
640 struct sockaddr_un server;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
641 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
642 char buf[32];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
643 char * address;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
644 #ifdef DEBUG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
645 char *file;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
646 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
647
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
648 address = getenv(NOCATGETS("SPRO_EDITOR_SOCKET"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
649 if (address == NULL) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
650 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
651 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
652
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
653 #ifdef INET_SOCKETS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
654 port = atoi(address);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
655
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
656 if ((sd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
657 PERROR(NOCATGETS("workshop_connect"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
658 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
659 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
660
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
661 /* Get the server internet address and put into addr structure */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
662 /* fill in the socket address structure and connect to server */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
663 memset((char *)&server, '\0', sizeof(server));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
664 server.sin_family = AF_INET;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
665 server.sin_port = port;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
666 if ((host = gethostbyname(NOCATGETS("localhost"))) == NULL) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
667 PERROR(NOCATGETS("gethostbyname"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
668 sd = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
669 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
670 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
671 memcpy((char *)&server.sin_addr, host->h_addr, host->h_length);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
672 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
673 if ((sd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
674 PERROR(NOCATGETS("workshop_connect"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
675 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
676 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
677
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
678 server.sun_family = AF_UNIX;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
679 strcpy(server.sun_path, address);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
680 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
681 /* Connect to server */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
682 if (connect(sd, (struct sockaddr *)&server, sizeof(server))) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
683 if (errno == ECONNREFUSED) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
684 close(sd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
685 #ifdef INET_SOCKETS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
686 if ((sd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
687 PERROR(NOCATGETS("workshop_connect"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
688 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
689 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
690 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
691 if ((sd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
692 PERROR(NOCATGETS("workshop_connect"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
693 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
694 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
695 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
696 if (connect(sd, (struct sockaddr *)&server,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
697 sizeof(server))) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
698 PERROR(NOCATGETS("workshop_connect"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
699 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
700 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
701
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
702 } else {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
703 PERROR(NOCATGETS("workshop_connect"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
704 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
705 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
706 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
707
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
708 /* tell notifier we are interested in being called
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
709 * when there is input on the editor connection socket
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
710 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
711 inputHandler = XtAppAddInput(context, sd, (XtPointer) XtInputReadMask,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
712 messageFromEserve, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
713 #ifdef DEBUG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
714 if ((file = getenv(NOCATGETS("SPRO_PLUGIN_DEBUG"))) != NULL) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
715 char buf[BUFSIZ];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
716
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
717 unlink(file);
272
ddada568db54 updated for version 7.0073
vimboss
parents: 7
diff changeset
718 vim_snprintf(buf, sizeof(buf), "date > %s", file);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
719 system(buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
720 dfd = fopen(file, "a");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
721 } else {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
722 dfd = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
723 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
724 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
725
272
ddada568db54 updated for version 7.0073
vimboss
parents: 7
diff changeset
726 vim_snprintf(buf, sizeof(buf), NOCATGETS("connected %s %s %s\n"),
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
727 workshop_get_editor_name(),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
728 PROTOCOL_VERSION,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
729 workshop_get_editor_version());
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
730 write(sd, buf, strlen(buf));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
731
272
ddada568db54 updated for version 7.0073
vimboss
parents: 7
diff changeset
732 vim_snprintf(buf, sizeof(buf), NOCATGETS("ack 1\n"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
733 write(sd, buf, strlen(buf));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
734 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
735
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
736 void workshop_disconnect()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
737 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
738 /* Probably need to send some message here */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
739
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
740 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
741 * socket closed on other end
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
742 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
743 XtRemoveInput(inputHandler);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
744 close(sd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
745 inputHandler = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
746 sd = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
747
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
748 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
749
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
750 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
751 * Utility functions
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
752 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
753
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
754 /* Set icon for the window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
755 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
756 workshop_set_icon(Display *display, Widget shell, char **xpmdata,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
757 int width, int height)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
758 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
759 Pixel bgPixel;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
760 XpmAttributes xpmAttributes;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
761 XSetWindowAttributes attr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
762 Window iconWindow;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
763 int depth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
764 int screenNum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
765 Pixmap pixmap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
766
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
767 /* Create the pixmap/icon window which is shown when you
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
768 * iconify the sccs viewer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
769 * This code snipped was adapted from Sun WorkShop's source base,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
770 * setIcon.cc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
771 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
772 XtVaGetValues(shell, XmNbackground, &bgPixel, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
773 screenNum = XScreenNumberOfScreen(XtScreen(shell));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
774 depth = DisplayPlanes(display, screenNum);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
775 xpmAttributes.valuemask = XpmColorSymbols;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
776 xpmAttributes.numsymbols = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
777 xpmAttributes.colorsymbols =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
778 (XpmColorSymbol *)XtMalloc(sizeof (XpmColorSymbol) *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
779 xpmAttributes.numsymbols);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
780 xpmAttributes.colorsymbols[0].name = NOCATGETS("BgColor");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
781 xpmAttributes.colorsymbols[0].value = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
782 xpmAttributes.colorsymbols[0].pixel = bgPixel;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
783 if (XpmCreatePixmapFromData(display,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
784 RootWindow(display, screenNum), xpmdata, &pixmap,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
785 NULL, &xpmAttributes) >= 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
786 attr.background_pixmap = pixmap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
787 iconWindow = XCreateWindow(display, RootWindow(display,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
788 screenNum), 0, 0, width, height, 0, depth,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
789 (unsigned int)CopyFromParent,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
790 CopyFromParent, CWBackPixmap, &attr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
791
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
792 XtVaSetValues(shell,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
793 XtNiconWindow, iconWindow, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
794 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
795 XtFree((char *)xpmAttributes.colorsymbols);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
796 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
797
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
798 /* Minimize and maximize shells. From libutil's shell.cc. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
799
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
800 /* utility functions from libutil's shell.cc */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
801 static Boolean
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
802 isWindowMapped(Display *display, Window win)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
803 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
804 XWindowAttributes winAttrs;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
805 XGetWindowAttributes(display,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
806 win,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
807 &winAttrs);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
808 if (winAttrs.map_state == IsViewable) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
809 return(True);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
810 } else {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
811 return(False);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
812 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
813 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
814
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
815 static Boolean
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
816 isMapped(Widget widget)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
817 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
818 if (widget == NULL) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
819 return(False);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
820 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
821
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
822 if (XtIsRealized(widget) == False) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
823 return(False);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
824 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
825
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
826 return(isWindowMapped(XtDisplay(widget), XtWindow(widget)));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
827 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
828
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
829 static Boolean
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
830 widgetIsIconified(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
831 Widget w)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
832 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
833 Atom wm_state;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
834 Atom act_type; /* actual Atom type returned */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
835 int act_fmt; /* actual format returned */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
836 u_long nitems_ret; /* number of items returned */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
837 u_long bytes_after; /* number of bytes remaining */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
838 u_long *property; /* actual property returned */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
839
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
840 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
841 * If a window is iconified its WM_STATE is set to IconicState. See
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
842 * ICCCM Version 2.0, section 4.1.3.1 for more details.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
843 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
844
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
845 wm_state = XmInternAtom(XtDisplay(w), NOCATGETS("WM_STATE"), False);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
846 if (XtWindow(w) != 0) { /* only check if window exists! */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
847 XGetWindowProperty(XtDisplay(w), XtWindow(w), wm_state, 0L, 2L,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
848 False, AnyPropertyType, &act_type, &act_fmt, &nitems_ret,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
849 &bytes_after, (u_char **) &property);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
850 if (nitems_ret == 2 && property[0] == IconicState) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
851 return True;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
852 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
853 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
854
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
855 return False;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
856
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
857 } /* end widgetIsIconified */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
858
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
859 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
860 workshop_minimize_shell(Widget shell)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
861 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
862 if (shell != NULL &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
863 XtIsObject(shell) &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
864 XtIsRealized(shell) == True) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
865 if (isMapped(shell) == True) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
866 XIconifyWindow(XtDisplay(shell), XtWindow(shell),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
867 XScreenNumberOfScreen(XtScreen(shell)));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
868 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
869 XtVaSetValues(shell,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
870 XmNiconic, True,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
871 NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
872 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
873 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
874
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
875 void workshop_maximize_shell(Widget shell)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
876 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
877 if (shell != NULL &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
878 XtIsRealized(shell) == True &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
879 widgetIsIconified(shell) == True &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
880 isMapped(shell) == False) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
881 XtMapWidget(shell);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
882 /* This used to be
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
883 XtPopdown(shell);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
884 XtPopup(shell, XtGrabNone);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
885 However, I found that that would drop any transient
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
886 windows that had been iconified with the window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
887 According to the ICCCM, XtMapWidget should be used
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
888 to bring a window from Iconic to Normal state.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
889 However, Rich Mauri did a lot of work on this during
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
890 Bart, and found that XtPopDown,XtPopup was required
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
891 to fix several bugs involving multiple CDE workspaces.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
892 I've tested it now and things seem to work fine but
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
893 I'm leaving this note for history in case this needs
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
894 to be revisited.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
895 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
896 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
897 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
898
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
899
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
900 Boolean workshop_get_width_height(int *width, int *height)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
901 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
902 static int wid = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
903 static int hgt = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
904 static Boolean firstTime = True;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
905 static Boolean success = False;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
906
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
907 if (firstTime) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
908 char *settings;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
909
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
910 settings = getenv(NOCATGETS("SPRO_GUI_WIDTH_HEIGHT"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
911 if (settings != NULL) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
912 wid = atoi(settings);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
913 settings = strrchr(settings, ':');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
914 if (settings++ != NULL) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
915 hgt = atoi(settings);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
916 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
917 if (wid > 0 && hgt > 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
918 success = True;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
919 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
920 firstTime = False;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
921 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
922 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
923
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
924 if (success) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
925 *width = wid;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
926 *height = hgt;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
927 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
928 return success;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
929 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
930
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
931
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
932 Boolean workshop_get_rows_cols(int *rows, int *cols)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
933 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
934 static int r = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
935 static int c = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
936 static Boolean firstTime = True;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
937 static Boolean success = False;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
938
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
939 if (firstTime) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
940 char *settings;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
941
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
942 settings = getenv(NOCATGETS("SPRO_GUI_ROWS_COLS"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
943 if (settings != NULL) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
944 r = atoi(settings);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
945 settings = strrchr(settings, ':');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
946 if (settings++ != NULL) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
947 c = atoi(settings);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
948 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
949 if (r > 0 && c > 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
950 success = True;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
951 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
952 firstTime = False;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
953 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
954 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
955
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
956 if (success) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
957 *rows = r;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
958 *cols = c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
959 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
960 return success;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
961 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
962
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
963 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
964 * Toolbar code
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
965 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
966
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
967 void workshop_sensitivity(int num, char *table)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
968 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
969 /* build up a verb table */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
970 VerbSense *vs;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
971 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
972 char *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
973 if ((num < 1) || (num > 500)) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
974 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
975 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
976
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
977 vs = (VerbSense *)malloc((num+1)*sizeof(VerbSense));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
978
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
979 /* Point to the individual names (destroys the table string, but
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
980 * that's okay -- this is more efficient than duplicating strings) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
981 s = table;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
982 for (i = 0; i < num; i++) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
983 while (*s == ' ') {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
984 s++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
985 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
986 vs[i].verb = s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
987 while (*s && (*s != ' ') && (*s != '\001')) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
988 s++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
989 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
990 if (*s == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
991 vs[i].verb = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
992 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
993 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
994 if (*s == '\001') {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
995 *s = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
996 s++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
997 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
998 *s = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
999 s++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1000 while (*s == ' ') {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1001 s++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1002 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1003 if (*s == '1') {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1004 vs[i].sense = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1005 } else {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1006 vs[i].sense = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1007 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1008 s++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1009 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1010 vs[i].verb = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1011
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1012 workshop_frame_sensitivities(vs);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1013
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1014 free(vs);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1015 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1016
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1017 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1018 * Options code
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1019 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1020 /* Set an editor option.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1021 * IGNORE an option if you do not recognize it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1022 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1023 void workshop_set_option_first(char *name, char *value)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1024 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1025 /* Currently value can only be on/off. This may change later (for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1026 * example to set an option like "balloon evaluate delay", but
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1027 * for now just convert it into a boolean */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1028 Boolean on = !strcmp(value, "on");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1029
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1030 if (!strcmp(name, "workshopkeys")) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1031 workshop_hotkeys(on);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1032 } else if (!strcmp(name, "savefiles")) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1033 save_files = on;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1034 } else if (!strcmp(name, "balloon")) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1035 workshop_balloon_mode(on);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1036 } else if (!strcmp(name, "balloondelay")) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1037 int delay = atoi(value);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1038 /* Should I validate the number here?? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1039 workshop_balloon_delay(delay);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1040 } else {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1041 /* Let editor interpret it */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1042 workshop_set_option(name, value);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1043 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1044 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1045
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1046
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1047
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1048 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1049 * Send information to eserve on certain editor events
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1050 * You must make sure these are called when necessary
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1051 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1052
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1053 void workshop_file_closed(char *filename)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1054 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1055 char buffer[2*MAXPATHLEN];
272
ddada568db54 updated for version 7.0073
vimboss
parents: 7
diff changeset
1056 vim_snprintf(buffer, sizeof(buffer),
ddada568db54 updated for version 7.0073
vimboss
parents: 7
diff changeset
1057 NOCATGETS("deletedFile %s\n"), filename);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1058 write(sd, buffer, strlen(buffer));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1059 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1060
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1061 void workshop_file_closed_lineno(char *filename, int lineno)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1062 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1063 char buffer[2*MAXPATHLEN];
272
ddada568db54 updated for version 7.0073
vimboss
parents: 7
diff changeset
1064 vim_snprintf(buffer, sizeof(buffer),
ddada568db54 updated for version 7.0073
vimboss
parents: 7
diff changeset
1065 NOCATGETS("deletedFile %s %d\n"), filename, lineno);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1066 write(sd, buffer, strlen(buffer));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1067 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1068
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1069 void workshop_file_opened(char *filename, int readOnly)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1070 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1071 char buffer[2*MAXPATHLEN];
272
ddada568db54 updated for version 7.0073
vimboss
parents: 7
diff changeset
1072 vim_snprintf(buffer, sizeof(buffer),
ddada568db54 updated for version 7.0073
vimboss
parents: 7
diff changeset
1073 NOCATGETS("loadedFile %s %d\n"), filename, readOnly);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1074 write(sd, buffer, strlen(buffer));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1075 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1076
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1077
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1078 void workshop_file_saved(char *filename)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1079 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1080 char buffer[2*MAXPATHLEN];
272
ddada568db54 updated for version 7.0073
vimboss
parents: 7
diff changeset
1081 vim_snprintf(buffer, sizeof(buffer),
ddada568db54 updated for version 7.0073
vimboss
parents: 7
diff changeset
1082 NOCATGETS("savedFile %s\n"), filename);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1083 write(sd, buffer, strlen(buffer));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1084
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1085 /* Let editor report any moved marks that the eserve client
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1086 * should deal with (for example, moving location-based breakpoints) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1087 workshop_moved_marks(filename);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1088 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1089
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1090 void workshop_move_mark(char *filename, int markId, int newLineno)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1091 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1092 char buffer[2*MAXPATHLEN];
272
ddada568db54 updated for version 7.0073
vimboss
parents: 7
diff changeset
1093 vim_snprintf(buffer, sizeof(buffer),
ddada568db54 updated for version 7.0073
vimboss
parents: 7
diff changeset
1094 NOCATGETS("moveMark %s %d %d\n"), filename, markId, newLineno);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1095 write(sd, buffer, strlen(buffer));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1096 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1097
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1098 void workshop_file_modified(char *filename)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1099 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1100 char buffer[2*MAXPATHLEN];
272
ddada568db54 updated for version 7.0073
vimboss
parents: 7
diff changeset
1101 vim_snprintf(buffer, sizeof(buffer),
ddada568db54 updated for version 7.0073
vimboss
parents: 7
diff changeset
1102 NOCATGETS("modifiedFile %s\n"), filename);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1103 write(sd, buffer, strlen(buffer));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1104 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1105
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1106 void workshop_frame_moved(int new_x, int new_y, int new_w, int new_h)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1107 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1108 char buffer[200];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1109
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1110 if (sd >= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1111 {
272
ddada568db54 updated for version 7.0073
vimboss
parents: 7
diff changeset
1112 vim_snprintf(buffer, sizeof(buffer),
ddada568db54 updated for version 7.0073
vimboss
parents: 7
diff changeset
1113 NOCATGETS("frameAt %d %d %d %d\n"),
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1114 new_x, new_y, new_w, new_h);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1115 write(sd, buffer, strlen(buffer));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1116 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1117 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1118
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1119 /* A button in the toolbar has been pushed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1120 * Clientdata is a pointer used by the editor code to figure out the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1121 * positions for this toolbar (probably by storing a window pointer,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1122 * and then fetching the current buffer for that window and looking up
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1123 * cursor and selection positions etc.) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1124 void workshop_perform_verb(char *verb, void *clientData)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1125 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1126 char *filename;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1127 int curLine;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1128 int curCol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1129 int selStartLine;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1130 int selStartCol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1131 int selEndLine;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1132 int selEndCol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1133 int selLength;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1134 char *selection;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1135
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1136 char buf[2*MAXPATHLEN];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1137 /* Later: needsFilePos indicates whether or not we need to fetch all this
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1138 * info for this verb... for now, however, it looks as if
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1139 * eserve parsing routines depend on it always being present */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1140
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1141 if (workshop_get_positions(clientData,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1142 &filename,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1143 &curLine,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1144 &curCol,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1145 &selStartLine,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1146 &selStartCol,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1147 &selEndLine,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1148 &selEndCol,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1149 &selLength,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1150 &selection)) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1151 if (selection == NULL) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1152 selection = NOCATGETS("");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1153 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1154
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1155 /* Should I save the files??? This is currently done by checking
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1156 if the verb is one of a few recognized ones. Later we can pass
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1157 this list from eserve to the editor (it's currently hardcoded in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1158 vi and emacs as well). */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1159 if (save_files) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1160 if (!strcmp(verb, "build.build") || !strcmp(verb, "build.build-file") ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1161 !strcmp(verb, "debug.fix") || !strcmp(verb, "debug.fix-all")) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1162 workshop_save_files();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1163 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1164 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1165
272
ddada568db54 updated for version 7.0073
vimboss
parents: 7
diff changeset
1166 vim_snprintf(buf, sizeof(buf),
ddada568db54 updated for version 7.0073
vimboss
parents: 7
diff changeset
1167 NOCATGETS("toolVerb %s %s %d,%d %d,%d %d,%d %d %s\n"),
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1168 verb,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1169 filename,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1170 curLine, curCol,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1171 selStartLine, selStartCol,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1172 selEndLine, selEndCol,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1173 selLength,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1174 selection);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1175 write(sd, buf, strlen(buf));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1176 if (*selection) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1177 free(selection);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1178 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1179 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1180 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1181
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1182 /* Send a message to eserve */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1183 void workshop_send_message(char *buf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1184 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1185 write(sd, buf, strlen(buf));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1186 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1187
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1188 /* Some methods, like currentFile, cursorPos, etc. are missing here.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1189 * But it looks like these are used for NoHands testing only so we
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1190 * won't bother requiring editors to implement these
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1191 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1192
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1193
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1194 #ifdef DEBUG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1195
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1196 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1197 pldebug(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1198 char *fmt, /* a printf style format line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1199 ...)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1200 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1201 va_list ap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1202
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1203 if (dfd != NULL) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1204 va_start(ap, fmt);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1205 vfprintf(dfd, fmt, ap);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1206 va_end(ap);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1207 fflush(dfd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1208 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1209
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1210 } /* end pldebug */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1211
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1212 #endif