annotate src/integration.c @ 1907:9bc164a2c814 v7.2.204

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