annotate src/workshop.c @ 8993:2085167ab1b0 v7.4.1782

commit https://github.com/vim/vim/commit/fca66003053f8c0da5161d1fe4b75b3a389934b5 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Apr 23 15:30:09 2016 +0200 patch 7.4.1782 Problem: strcharpart() does not work properly with some multi-byte characters. Solution: Use mb_cptr2len() instead of mb_char2len(). (Hirohito Higashi)
author Christian Brabandt <cb@256bit.org>
date Sat, 23 Apr 2016 15:45:04 +0200
parents 33ba2adb6065
children fd9727ae3c49
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 sts=4 sw=4:
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 #ifdef HAVE_CONFIG_H
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 # include "auto/config.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 #include <stdio.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 #include <stdlib.h>
44
af1bcb9a13c0 updated for version 7.0027
vimboss
parents: 7
diff changeset
16 #include <sys/types.h>
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 #include <netdb.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 #include <netinet/in.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 #include <sys/socket.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 #ifdef HAVE_LIBGEN_H
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 # include <libgen.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 #include <unistd.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 #include <string.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 #include <stdlib.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 #include <ctype.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 #include <X11/Intrinsic.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 #include <Xm/Xm.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 #include <Xm/PushB.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 #include "integration.h" /* <EditPlugin/integration.h> */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 #include "vim.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 #include "version.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 #include "gui_beval.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 #include "workshop.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 void workshop_hotkeys(Boolean);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 static Boolean isShowing(int);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 static win_T *get_window(buf_T *);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 static void updatePriority(Boolean);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 static char *addUniqueMnemonic(char *, char *);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 static char *fixup(char *);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 static char *get_selection(buf_T *);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 static char *append_selection(int, char *, int *, int *);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 static void load_buffer_by_name(char *, int);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 static void load_window(char *, int lnum);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 static void warp_to_pc(int);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 #ifdef FEAT_BEVAL
2031
07de57cbcb25 updated for version 7.2.327
Bram Moolenaar <bram@zimbu.org>
parents: 1887
diff changeset
52 void workshop_beval_cb(BalloonEval *, int);
07de57cbcb25 updated for version 7.2.327
Bram Moolenaar <bram@zimbu.org>
parents: 1887
diff changeset
53 static int computeIndex(int, char_u *, int);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 static char *fixAccelText(char *);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 static void addMenu(char *, char *, char *);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 static char *lookupVerb(char *, int);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 static void coloncmd(char *, Boolean);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 extern Widget vimShell;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 extern Widget textArea;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 extern XtAppContext app_context;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 static int tbpri; /* ToolBar priority */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 int usingSunWorkShop = 0; /* set if -ws flag is used */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 char curMenuName[BUFSIZ];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 char curMenuPriority[BUFSIZ];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 static Boolean workshopInitDone = False;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 static Boolean workshopHotKeysEnabled = False;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 * The following enum is from <gp_dbx/gp_dbx_common.h>. We can't include it
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 * here because its C++.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 enum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 GPLineEval_EVALUATE, /* evaluate expression */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 GPLineEval_INDIRECT, /* evaluate *<expression> */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 GPLineEval_TYPE /* type of expression */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 * Store each verb in the MenuMap. This lets us map from a verb to a menu.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 * There may be multiple matches for a single verb in this table.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 #define MENU_INC 50 /* menuMap incremental size increases */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 typedef struct
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 char *name; /* name of the menu */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 char *accel; /* optional accelerator key */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 char *verb; /* menu verb */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 } MenuMap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 static MenuMap *menuMap; /* list of verb/menu mappings */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 static int menuMapSize; /* current size of menuMap */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 static int menuMapMax; /* allocated size of menuMap */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 static char *initialFileCmd; /* save command but defer doing it */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 void
7837
33ba2adb6065 commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents: 2668
diff changeset
101 workshop_init(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 char_u buf[64];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 int is_dirty = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 int width, height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 XtInputMask mask;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 * Turn on MenuBar, ToolBar, and Footer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 STRCPY(buf, p_go);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 if (vim_strchr(p_go, GO_MENUS) == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 STRCAT(buf, "m");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 is_dirty = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 if (vim_strchr(p_go, GO_TOOLBAR) == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 STRCAT(buf, "T");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 is_dirty = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 if (vim_strchr(p_go, GO_FOOTER) == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 STRCAT(buf, "F");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 is_dirty = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 if (is_dirty)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 set_option_value((char_u *)"go", 0L, buf, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 * Set size from workshop_get_width_height().
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 width = height = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 if (workshop_get_width_height(&width, &height))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 XtVaSetValues(vimShell,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 XmNwidth, width,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 XmNheight, height,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 * Now read in the initial messages from eserve.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 while ((mask = XtAppPending(app_context))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 && (mask & XtIMAlternateInput) && !workshopInitDone)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 XtAppProcessEvent(app_context, (XtInputMask)XtIMAlternateInput);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 void
7837
33ba2adb6065 commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents: 2668
diff changeset
151 workshop_postinit(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 do_cmdline_cmd((char_u *)initialFileCmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 ALT_INPUT_LOCK_OFF;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 free(initialFileCmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 initialFileCmd = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 ex_wsverb(exarg_T *eap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 msg_clr_cmdline();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 workshop_perform_verb((char *) eap->arg, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 * Editor name
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 * This string is recognized by eserve and should be all lower case.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169 * This is how the editor detects that it is talking to gvim instead
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 * of NEdit, for example, when the connection is initiated from the editor.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 char *
7837
33ba2adb6065 commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents: 2668
diff changeset
173 workshop_get_editor_name(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 return "gvim";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 * Version number of the editor.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 * This number is communicated along with the protocol
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 * version to the application.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 char *
7837
33ba2adb6065 commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents: 2668
diff changeset
184 workshop_get_editor_version(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 return Version;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 * Answer functions: called by eserve
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 * Name:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 * workshop_load_file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 * Function:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 * Load a given file into the WorkShop buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 workshop_load_file(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 char *filename, /* the file to load */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 int line, /* an optional line number (or 0) */
1887
fc89a4f98a8b updated for version 7.2-184
vimboss
parents: 1756
diff changeset
204 char *frameid UNUSED) /* used for multi-frame support */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 #ifdef WSDEBUG_TRACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 wstrace("workshop_load_file(%s, %d)\n", filename, line);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211 #ifdef FEAT_BEVAL
189
504c627f7474 updated for version 7.0057
vimboss
parents: 44
diff changeset
212 bevalServers |= BEVAL_WORKSHOP;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 load_window(filename, line);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 * Reload the WorkShop buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 workshop_reload_file(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 char *filename,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 int line)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226 #ifdef WSDEBUG_TRACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 wstrace("workshop_reload_file(%s, %d)\n", filename, line);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 load_window(filename, line);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 workshop_show_file(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235 char *filename)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 #ifdef WSDEBUG_TRACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 wstrace("workshop_show_file(%s)\n", filename);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 load_window(filename, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 workshop_goto_line(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 char *filename,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248 int lineno)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250 #ifdef WSDEBUG_TRACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 wstrace("workshop_goto_line(%s, %d)\n", filename, lineno);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 load_window(filename, lineno);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259 workshop_front_file(
1887
fc89a4f98a8b updated for version 7.2-184
vimboss
parents: 1756
diff changeset
260 char *filename UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 #ifdef WSDEBUG_TRACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264 wstrace("workshop_front_file()\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
266 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
267 * Assumption: This function will always be called after a call to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268 * workshop_show_file(), so the file is always showing.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270 if (vimShell != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271 XRaiseWindow(gui.dpy, XtWindow(vimShell));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
275 workshop_save_file(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
276 char *filename)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
277 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278 char cbuf[BUFSIZ]; /* build vim command here */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280 #ifdef WSDEBUG_TRACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282 wstrace("workshop_save_file(%s)\n", filename);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285 /* Save the given file */
273
2463194c8cdd updated for version 7.0073
vimboss
parents: 189
diff changeset
286 vim_snprintf(cbuf, sizeof(cbuf), "w %s", filename);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287 coloncmd(cbuf, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290 void
7837
33ba2adb6065 commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents: 2668
diff changeset
291 workshop_save_files(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293 /* Save the given file */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294 #ifdef WSDEBUG_TRACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
295 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
296 wstrace("workshop_save_files()\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
297 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
298
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
299 add_to_input_buf((char_u *) ":wall\n", 6);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
300 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
301
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
302 void
7837
33ba2adb6065 commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents: 2668
diff changeset
303 workshop_quit(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
304 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
305 #ifdef WSDEBUG_TRACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
306 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
307 wstrace("workshop_quit()\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
308 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
309
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
310 add_to_input_buf((char_u *) ":qall\n", 6);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
311 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
312
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
313 void
7837
33ba2adb6065 commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents: 2668
diff changeset
314 workshop_minimize(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
315 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
316 #ifdef WSDEBUG_TRACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
317 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
318 wstrace("workshop_minimize()\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
319 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
320 workshop_minimize_shell(vimShell);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
321 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
322 void
7837
33ba2adb6065 commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents: 2668
diff changeset
323 workshop_maximize(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
324 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
325 #ifdef WSDEBUG_TRACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
326 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
327 wstrace("workshop_maximize()\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
328 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
329
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
330 workshop_maximize_shell(vimShell);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
331 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
332
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
333 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
334 workshop_add_mark_type(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
335 int idx,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
336 char *colorspec,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
337 char *sign)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
338 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
339 char gbuf[BUFSIZ]; /* buffer for sign name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
340 char cibuf[BUFSIZ]; /* color information */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
341 char cbuf[BUFSIZ]; /* command buffer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
342 char *bp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
343
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
344 #ifdef WSDEBUG_TRACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
345 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
346 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347 char *cp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349 cp = strrchr(sign, '/');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350 if (cp == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351 cp = sign;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353 cp++; /* skip '/' character */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354 wstrace("workshop_add_mark_type(%d, \"%s\", \"%s\")\n", idx,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355 colorspec && *colorspec ? colorspec : "<None>", cp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
357 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360 * Isolate the basename of sign in gbuf. We will use this for the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361 * GroupName in the highlight command sent to vim.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
363 STRCPY(gbuf, gettail((char_u *)sign));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364 bp = strrchr(gbuf, '.');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
365 if (bp != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366 *bp = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
367
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
368 if (gbuf[0] != '-' && gbuf[1] != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
369 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
370 if (colorspec != NULL && *colorspec)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
371 {
273
2463194c8cdd updated for version 7.0073
vimboss
parents: 189
diff changeset
372 vim_snprintf(cbuf, sizeof(cbuf),
2463194c8cdd updated for version 7.0073
vimboss
parents: 189
diff changeset
373 "highlight WS%s guibg=%s", gbuf, colorspec);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374 coloncmd(cbuf, FALSE);
273
2463194c8cdd updated for version 7.0073
vimboss
parents: 189
diff changeset
375 vim_snprintf(cibuf, sizeof(cibuf), "linehl=WS%s", gbuf);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
377 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
378 cibuf[0] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
379
273
2463194c8cdd updated for version 7.0073
vimboss
parents: 189
diff changeset
380 vim_snprintf(cbuf, sizeof(cbuf),
2463194c8cdd updated for version 7.0073
vimboss
parents: 189
diff changeset
381 "sign define %d %s icon=%s", idx, cibuf, sign);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
382 coloncmd(cbuf, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
383 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
384 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
385
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
386 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
387 workshop_set_mark(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
388 char *filename, /* filename which gets the mark */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
389 int lineno, /* line number which gets the mark */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390 int markId, /* unique mark identifier */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
391 int idx) /* which mark to use */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
392 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393 char cbuf[BUFSIZ]; /* command buffer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
394
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395 /* Set mark in a given file */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396 #ifdef WSDEBUG_TRACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
398 wstrace("workshop_set_mark(%s, %d (ln), %d (id), %d (idx))\n",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399 filename, lineno, markId, idx);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
400 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401
273
2463194c8cdd updated for version 7.0073
vimboss
parents: 189
diff changeset
402 vim_snprintf(cbuf, sizeof(cbuf), "sign place %d line=%d name=%d file=%s",
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403 markId, lineno, idx, filename);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404 coloncmd(cbuf, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
406
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
407 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
408 workshop_change_mark_type(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
409 char *filename, /* filename which gets the mark */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
410 int markId, /* unique mark identifier */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
411 int idx) /* which mark to use */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
412 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
413 char cbuf[BUFSIZ]; /* command buffer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
414
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
415 /* Change mark type */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
416 #ifdef WSDEBUG_TRACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
417 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
418 wstrace("workshop_change_mark_type(%s, %d, %d)\n",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
419 filename, markId, idx);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
420 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
421
273
2463194c8cdd updated for version 7.0073
vimboss
parents: 189
diff changeset
422 vim_snprintf(cbuf, sizeof(cbuf),
2463194c8cdd updated for version 7.0073
vimboss
parents: 189
diff changeset
423 "sign place %d name=%d file=%s", markId, idx, filename);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
424 coloncmd(cbuf, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
425 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
426
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
427 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
428 * Goto the given mark in a file (e.g. show it).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
429 * If message is not null, display it in the footer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
430 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
431 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
432 workshop_goto_mark(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
433 char *filename,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
434 int markId,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
435 char *message)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
436 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
437 char cbuf[BUFSIZ]; /* command buffer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
438
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
439 /* Goto mark */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
440 #ifdef WSDEBUG_TRACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
441 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
442 wstrace("workshop_goto_mark(%s, %d (id), %s)\n",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
443 filename, markId, message && *message &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
444 !(*message == ' ' && message[1] == NULL) ?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
445 message : "<None>");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
446 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
447
273
2463194c8cdd updated for version 7.0073
vimboss
parents: 189
diff changeset
448 vim_snprintf(cbuf, sizeof(cbuf), "sign jump %d file=%s", markId, filename);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
449 coloncmd(cbuf, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
450 if (message != NULL && *message != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
451 gui_mch_set_footer((char_u *)message);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
452 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
453
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
454 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
455 workshop_delete_mark(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
456 char *filename,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
457 int markId)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
458 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
459 char cbuf[BUFSIZ]; /* command buffer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
460
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
461 /* Delete mark */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
462 #ifdef WSDEBUG_TRACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
463 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
464 wstrace("workshop_delete_mark(%s, %d (id))\n",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
465 filename, markId);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
466 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
467
273
2463194c8cdd updated for version 7.0073
vimboss
parents: 189
diff changeset
468 vim_snprintf(cbuf, sizeof(cbuf),
2463194c8cdd updated for version 7.0073
vimboss
parents: 189
diff changeset
469 "sign unplace %d file=%s", markId, filename);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
470 coloncmd(cbuf, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
471 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
472
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
473 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
474 workshop_get_mark_lineno(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
475 char *filename,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
476 int markId)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
477 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
478 buf_T *buf; /* buffer containing filename */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
479 int lineno; /* line number of filename in buf */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
480
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
481 /* Get mark line number */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
482 #ifdef WSDEBUG_TRACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
483 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
484 wstrace("workshop_get_mark_lineno(%s, %d)\n",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
485 filename, markId);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
486 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
487
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
488 lineno = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
489 buf = buflist_findname((char_u *)filename);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
490 if (buf != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
491 lineno = buf_findsign(buf, markId);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
492
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
493 return lineno;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
494 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
495
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
496
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
497 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
498 * Are there any moved marks? If so, call workshop_move_mark on
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
499 * each of them now. This is how eserve can find out if for example
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
500 * breakpoints have moved when a program has been recompiled and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
501 * reloaded into dbx.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
502 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
503 void
1887
fc89a4f98a8b updated for version 7.2-184
vimboss
parents: 1756
diff changeset
504 workshop_moved_marks(char *filename UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
505 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
506 #ifdef WSDEBUG_TRACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
507 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
508 wstrace("XXXworkshop_moved_marks(%s)\n", filename);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
509 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
510 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
511
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
512 int
7837
33ba2adb6065 commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents: 2668
diff changeset
513 workshop_get_font_height(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
514 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
515 XmFontList fontList; /* fontList made from gui.norm_font */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
516 XmString str;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
517 Dimension w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
518 Dimension h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
519
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
520 #ifdef WSDEBUG_TRACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
521 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
522 wstrace("workshop_get_font_height()\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
523 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
524
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
525 /* Pick the proper signs for this font size */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
526 fontList = gui_motif_create_fontlist((XFontStruct *)gui.norm_font);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
527 h = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
528 if (fontList != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
529 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
530 str = XmStringCreateLocalized("A");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
531 XmStringExtent(fontList, str, &w, &h);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
532 XmStringFree(str);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
533 XmFontListFree(fontList);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
534 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
535
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
536 return (int)h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
537 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
538
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
539 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
540 workshop_footer_message(
1887
fc89a4f98a8b updated for version 7.2-184
vimboss
parents: 1756
diff changeset
541 char *message,
fc89a4f98a8b updated for version 7.2-184
vimboss
parents: 1756
diff changeset
542 int severity UNUSED) /* severity is currently unused */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
543 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
544 #ifdef WSDEBUG_TRACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
545 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
546 wstrace("workshop_footer_message(%s, %d)\n", message, severity);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
547 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
548
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
549 gui_mch_set_footer((char_u *) message);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
550 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
551
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
552 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
553 * workshop_menu_begin() is passed the menu name. We determine its mnemonic
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
554 * here and store its name and priority.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
555 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
556 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
557 workshop_menu_begin(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
558 char *label)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
559 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
560 vimmenu_T *menu; /* pointer to last menu */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
561 int menuPriority = 0; /* priority of new menu */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
562 char mnembuf[64]; /* store menubar mnemonics here */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
563 char *name; /* label with a mnemonic */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
564 char *p; /* used to find mnemonics */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
565 int idx; /* index into mnembuf */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
566
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
567 #ifdef WSDEBUG_TRACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
568 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
569 wstrace("workshop_menu_begin()\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
570 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
571
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
572 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
573 * Look through all existing (non-PopUp and non-Toolbar) menus
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
574 * and gather their mnemonics. Use this list to decide what
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
575 * mnemonic should be used for label.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
576 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
577
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
578 idx = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
579 mnembuf[idx++] = 'H'; /* H is mnemonic for Help */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
580 for (menu = root_menu; menu != NULL; menu = menu->next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
581 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
582 if (menu_is_menubar(menu->name))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
583 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
584 p = strchr((char *)menu->name, '&');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585 if (p != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
586 mnembuf[idx++] = *++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
587 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
588 if (menu->next != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589 && strcmp((char *) menu->next->dname, "Help") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
590 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
591 menuPriority = menu->priority + 10;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
592 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
593 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
594 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
595 mnembuf[idx++] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
596 name = addUniqueMnemonic(mnembuf, label);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
597
273
2463194c8cdd updated for version 7.0073
vimboss
parents: 189
diff changeset
598 vim_snprintf(curMenuName, sizeof(curMenuName), "%s", name);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
599 sprintf(curMenuPriority, "%d.0", menuPriority);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
600 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
601
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
602 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
603 * Append the name and priority to strings to be used in vim menu commands.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
604 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
605 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
606 workshop_submenu_begin(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
607 char *label)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
608 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609 #ifdef WSDEBUG_TRACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
610 if (ws_debug && ws_dlevel & WS_TRACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611 && strncmp(curMenuName, "ToolBar", 7) != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
612 wstrace("workshop_submenu_begin(%s)\n", label);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
613 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
614
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
615 strcat(curMenuName, ".");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
616 strcat(curMenuName, fixup(label));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
617
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
618 updatePriority(True);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
619 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
620
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
621 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
622 * Remove the submenu name and priority from curMenu*.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
623 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
624
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
625 void
7837
33ba2adb6065 commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents: 2668
diff changeset
626 workshop_submenu_end(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
627 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
628 char *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
629
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
630 #ifdef WSDEBUG_TRACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
631 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
632 && strncmp(curMenuName, "ToolBar", 7) != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
633 wstrace("workshop_submenu_end()\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
634 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
635
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
636 p = strrchr(curMenuPriority, '.');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
637 ASSERT(p != NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
638 *p = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
639
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
640 p = strrchr(curMenuName, '.');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
641 ASSERT(p != NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
642 *p = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
643 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
644
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
645 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
646 * This is where menus are really made. Each item will generate an amenu vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
647 * command. The globals curMenuName and curMenuPriority contain the name and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
648 * priority of the parent menu tree.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
649 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
650 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
651 workshop_menu_item(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
652 char *label,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
653 char *verb,
1887
fc89a4f98a8b updated for version 7.2-184
vimboss
parents: 1756
diff changeset
654 char *accelerator UNUSED,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
655 char *acceleratorText,
1887
fc89a4f98a8b updated for version 7.2-184
vimboss
parents: 1756
diff changeset
656 char *name UNUSED,
fc89a4f98a8b updated for version 7.2-184
vimboss
parents: 1756
diff changeset
657 char *filepos UNUSED,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
658 char *sensitive)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
659 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
660 char cbuf[BUFSIZ];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
661 char namebuf[BUFSIZ];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
662 char accText[BUFSIZ];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
663
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
664 #ifdef WSDEBUG_TRACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
665 if (WSDLEVEL(WS_TRACE_VERBOSE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
666 && strncmp(curMenuName, "ToolBar", 7) != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
667 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
668 if (ws_dlevel & WS_TRACE_VERBOSE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
669 wsdebug("workshop_menu_item(\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
670 "\tlabel = \"%s\",\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
671 "\tverb = %s,\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
672 "\taccelerator = %s,\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
673 "\tacceleratorText = \"%s\",\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
674 "\tname = %s,\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
675 "\tfilepos = %s,\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
676 "\tsensitive = %s)\n",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
677 label && *label ? label : "<None>",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
678 verb && *verb ? verb : "<None>",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
679 accelerator && *accelerator ?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
680 accelerator : "<None>",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
681 acceleratorText && *acceleratorText ?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
682 acceleratorText : "<None>",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
683 name && *name ? name : "<None>",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
684 filepos && *filepos ? filepos : "<None>",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
685 sensitive);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
686 else if (ws_dlevel & WS_TRACE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
687 wstrace("workshop_menu_item(\"%s\", %s)\n",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
688 label && *label ? label : "<None>",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
689 verb && *verb ? verb : "<None>", sensitive);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
690 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
691 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
692 #ifdef WSDEBUG_SENSE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
693 if (ws_debug)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
694 wstrace("menu: %-21.20s%-21.20s(%s)\n", label, verb,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
695 *sensitive == '1' ? "Sensitive" : "Insensitive");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
696 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
697
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
698 if (acceleratorText != NULL)
273
2463194c8cdd updated for version 7.0073
vimboss
parents: 189
diff changeset
699 vim_snprintf(accText, sizeof(accText), "<Tab>%s", acceleratorText);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
700 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
701 accText[0] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
702 updatePriority(False);
273
2463194c8cdd updated for version 7.0073
vimboss
parents: 189
diff changeset
703 vim_snprintf(namebuf, sizeof(namebuf), "%s.%s", curMenuName, fixup(label));
2463194c8cdd updated for version 7.0073
vimboss
parents: 189
diff changeset
704 vim_snprintf(cbuf, sizeof(cbuf), "amenu %s %s%s\t:wsverb %s<CR>",
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
705 curMenuPriority, namebuf, accText, verb);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
706
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
707 coloncmd(cbuf, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
708 addMenu(namebuf, fixAccelText(acceleratorText), verb);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
709
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
710 if (*sensitive == '0')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
711 {
273
2463194c8cdd updated for version 7.0073
vimboss
parents: 189
diff changeset
712 vim_snprintf(cbuf, sizeof(cbuf), "amenu disable %s", namebuf);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
713 coloncmd(cbuf, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
714 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
715 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
716
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
717 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
718 * This function is called when a complete WorkShop menu description has been
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
719 * sent over from eserve. We do some menu cleanup.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
720 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
721
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
722 void
7837
33ba2adb6065 commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents: 2668
diff changeset
723 workshop_menu_end(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
724 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
725 Boolean using_tearoff; /* set per current option setting */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
726
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
727 #ifdef WSDEBUG_TRACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
728 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
729 wstrace("workshop_menu_end()\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
730 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
731
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
732 using_tearoff = vim_strchr(p_go, GO_TEAROFF) != NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
733 gui_mch_toggle_tearoffs(using_tearoff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
734 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
735
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
736 void
7837
33ba2adb6065 commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents: 2668
diff changeset
737 workshop_toolbar_begin(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
738 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
739 #ifdef WSDEBUG_TRACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
740 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
741 wstrace("workshop_toolbar_begin()\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
742 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
743
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
744 coloncmd("aunmenu ToolBar", True);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
745 tbpri = 10;
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 void
7837
33ba2adb6065 commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents: 2668
diff changeset
749 workshop_toolbar_end(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
750 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
751 char_u buf[64];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
752
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
753 #ifdef WSDEBUG_TRACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
754 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
755 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
756 wstrace("workshop_toolbar_end()\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
757 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
758 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
759
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
760 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
761 * Turn on ToolBar.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
762 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
763 STRCPY(buf, p_go);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
764 if (vim_strchr(p_go, 'T') == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
765 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
766 STRCAT(buf, "T");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
767 set_option_value((char_u *)"go", 0L, buf, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
768 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
769 workshopInitDone = True;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
770 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
771
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
772 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
773 workshop_toolbar_button(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
774 char *label,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
775 char *verb,
1887
fc89a4f98a8b updated for version 7.2-184
vimboss
parents: 1756
diff changeset
776 char *senseVerb UNUSED,
fc89a4f98a8b updated for version 7.2-184
vimboss
parents: 1756
diff changeset
777 char *filepos UNUSED,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
778 char *help,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
779 char *sense,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
780 char *file,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
781 char *left)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
782 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
783 char cbuf[BUFSIZ + MAXPATHLEN];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
784 char namebuf[BUFSIZ];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
785 static int tbid = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
786 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
787
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
788 #ifdef WSDEBUG_TRACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
789 if (WSDLEVEL(WS_TRACE_VERBOSE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
790 wsdebug("workshop_toolbar_button(\"%s\", %s, %s,\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
791 "\t%s, \"%s\", %s,\n\t\"%s\",\n\t<%s>)\n",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
792 label && *label ? label : "<None>",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
793 verb && *verb ? verb : "<None>",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
794 senseVerb && *senseVerb ? senseVerb : "<None>",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
795 filepos && *filepos ? filepos : "<None>",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
796 help && *help ? help : "<None>",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
797 sense && *sense ? sense : "<None>",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
798 file && *file ? file : "<None>",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
799 left && *left ? left : "<None>");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
800 else if (WSDLEVEL(WS_TRACE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
801 wstrace("workshop_toolbar_button(\"%s\", %s)\n",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
802 label && *label ? label : "<None>",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
803 verb && *verb ? verb : "<None>");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
804 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
805 #ifdef WSDEBUG_SENSE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
806 if (ws_debug)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
807 wsdebug("button: %-21.20s%-21.20s(%s)\n", label, verb,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
808 *sense == '1' ? "Sensitive" : "Insensitive");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
809 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
810
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
811 if (left && *left && atoi(left) > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
812 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
813 /* Add a separator (but pass the width passed after the ':') */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
814 sprintf(cbuf, "amenu 1.%d ToolBar.-sep%d:%s- <nul>",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
815 tbpri - 5, tbid++, left);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
816
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
817 coloncmd(cbuf, True);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
818 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
819
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
820 p = vim_strsave_escaped((char_u *)label, (char_u *)"\\. ");
273
2463194c8cdd updated for version 7.0073
vimboss
parents: 189
diff changeset
821 vim_snprintf(namebuf, sizeof(namebuf), "ToolBar.%s", p);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
822 vim_free(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
823 STRCPY(cbuf, "amenu <silent> ");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
824 if (file != NULL && *file != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
825 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
826 p = vim_strsave_escaped((char_u *)file, (char_u *)" ");
2280
941ff1cd317a Add file save counter to undo information. Add undotree() function.
Bram Moolenaar <bram@vim.org>
parents: 2267
diff changeset
827 vim_snprintf_add(cbuf, sizeof(cbuf), "icon=%s ", p);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
828 vim_free(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
829 }
2280
941ff1cd317a Add file save counter to undo information. Add undotree() function.
Bram Moolenaar <bram@vim.org>
parents: 2267
diff changeset
830 vim_snprintf_add(cbuf, sizeof(cbuf),"1.%d %s :wsverb %s<CR>",
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
831 tbpri, namebuf, verb);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
832
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
833 /* Define the menu item */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
834 coloncmd(cbuf, True);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
835
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
836 if (*sense == '0')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
837 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
838 /* If menu isn't sensitive at startup... */
273
2463194c8cdd updated for version 7.0073
vimboss
parents: 189
diff changeset
839 vim_snprintf(cbuf, sizeof(cbuf), "amenu disable %s", namebuf);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
840 coloncmd(cbuf, True);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
841 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
842
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
843 if (help && *help)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
844 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
845 /* Do the tooltip */
273
2463194c8cdd updated for version 7.0073
vimboss
parents: 189
diff changeset
846 vim_snprintf(cbuf, sizeof(cbuf), "tmenu %s %s", namebuf, help);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
847 coloncmd(cbuf, True);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
848 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
849
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
850 addMenu(namebuf, NULL, verb);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
851 tbpri += 10;
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 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
855 workshop_frame_sensitivities(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
856 VerbSense *vs) /* list of verbs to (de)sensitize */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
857 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
858 VerbSense *vp; /* iterate through vs */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
859 char *menu_name; /* used in menu lookup */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
860 int cnt; /* count of verbs to skip */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
861 int len; /* length of nonvariant part of command */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
862 char cbuf[4096];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
863
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
864 #ifdef WSDEBUG_TRACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
865 if (WSDLEVEL(WS_TRACE_VERBOSE) || WSDLEVEL(4))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
866 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
867 wsdebug("workshop_frame_sensitivities(\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
868 for (vp = vs; vp->verb != NULL; vp++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
869 wsdebug("\t%-25s%d\n", vp->verb, vp->sense);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
870 wsdebug(")\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
871 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
872 else if (WSDLEVEL(WS_TRACE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
873 wstrace("workshop_frame_sensitivities()\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
874 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
875 #ifdef WSDEBUG_SENSE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
876 if (ws_debug)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
877 for (vp = vs; vp->verb != NULL; vp++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
878 wsdebug("change: %-21.20s%-21.20s(%s)\n",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
879 "", vp->verb, vp->sense == 1 ?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
880 "Sensitive" : "Insensitive");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
881 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
882
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
883 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
884 * Look for all matching menu entries for the verb. There may be more
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
885 * than one if the verb has both a menu and toolbar entry.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
886 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
887 for (vp = vs; vp->verb != NULL; vp++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
888 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
889 cnt = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
890 strcpy(cbuf, "amenu");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
891 strcat(cbuf, " ");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
892 strcat(cbuf, vp->sense ? "enable" : "disable");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
893 strcat(cbuf, " ");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
894 len = strlen(cbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
895 while ((menu_name = lookupVerb(vp->verb, cnt++)) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
896 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
897 strcpy(&cbuf[len], menu_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
898 coloncmd(cbuf, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
899 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
900 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
901 gui_update_menus(0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
902 gui_mch_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
903 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
904
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
905 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
906 workshop_set_option(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
907 char *option, /* name of a supported option */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
908 char *value) /* value to set option to */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
909 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
910 char cbuf[BUFSIZ]; /* command buffer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
911
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
912 #ifdef WSDEBUG_TRACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
913 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
914 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
915 wstrace("workshop_set_option(%s, %s)\n", option, value);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
916 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
917 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
918
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
919 cbuf[0] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
920 switch (*option) /* switch on 1st letter */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
921 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
922 case 's':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
923 if (strcmp(option, "syntax") == 0)
273
2463194c8cdd updated for version 7.0073
vimboss
parents: 189
diff changeset
924 vim_snprintf(cbuf, sizeof(cbuf), "syntax %s", value);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
925 else if (strcmp(option, "savefiles") == 0)
1887
fc89a4f98a8b updated for version 7.2-184
vimboss
parents: 1756
diff changeset
926 {
fc89a4f98a8b updated for version 7.2-184
vimboss
parents: 1756
diff changeset
927 /* XXX - Not yet implemented */
fc89a4f98a8b updated for version 7.2-184
vimboss
parents: 1756
diff changeset
928 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
929 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
930
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
931 case 'l':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
932 if (strcmp(option, "lineno") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
933 sprintf(cbuf, "set %snu",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
934 (strcmp(value, "on") == 0) ? "" : "no");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
935 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
936
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
937 case 'p':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
938 if (strcmp(option, "parentheses") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
939 sprintf(cbuf, "set %ssm",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
940 (strcmp(value, "on") == 0) ? "" : "no");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
941 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
942
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
943 case 'w':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
944 /* this option is set by a direct call */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
945 #ifdef WSDEBUG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
946 wsdebug("workshop_set_option: "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
947 "Got unexpected workshopkeys option");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
948 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
949 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
950
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
951 case 'b': /* these options are set from direct calls */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
952 if (option[7] == NUL && strcmp(option, "balloon") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
953 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
954 #ifdef WSDEBUG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
955 /* set by direct call to workshop_balloon_mode */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
956 wsdebug("workshop_set_option: "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
957 "Got unexpected ballooneval option");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
958 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
959 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
960 else if (strcmp(option, "balloondelay") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
961 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
962 #ifdef WSDEBUG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
963 /* set by direct call to workshop_balloon_delay */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
964 wsdebug("workshop_set_option: "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
965 "Got unexpected balloondelay option");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
966 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
967 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
968 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
969 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
970 if (cbuf[0] != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
971 coloncmd(cbuf, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
972 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
973
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
974
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
975 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
976 workshop_balloon_mode(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
977 Boolean on)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
978 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
979 char cbuf[BUFSIZ]; /* command buffer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
980
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
981 #ifdef WSDEBUG_TRACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
982 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
983 wstrace("workshop_balloon_mode(%s)\n", on ? "True" : "False");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
984 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
985
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
986 sprintf(cbuf, "set %sbeval", on ? "" : "no");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
987 coloncmd(cbuf, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
988 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
989
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
990
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
991 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
992 workshop_balloon_delay(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
993 int delay)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
994 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
995 char cbuf[BUFSIZ]; /* command buffer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
996
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
997 #ifdef WSDEBUG_TRACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
998 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
999 wstrace("workshop_balloon_delay(%d)\n", delay);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1000 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1001
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1002 sprintf(cbuf, "set bdlay=%d", delay);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1003 coloncmd(cbuf, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1004 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1005
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1006
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1007 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1008 workshop_show_balloon_tip(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1009 char *tip)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1010 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1011 #ifdef WSDEBUG_TRACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1012 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1013 wstrace("workshop_show_balloon_tip(%s)\n", tip);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1014 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1015
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1016 if (balloonEval != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1017 gui_mch_post_balloon(balloonEval, (char_u *)tip);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1018 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1019
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1020
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1021 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1022 workshop_hotkeys(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1023 Boolean on)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1024 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1025 char cbuf[BUFSIZ]; /* command buffer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1026 MenuMap *mp; /* iterate over menuMap entries */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1027
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1028 #ifdef WSDEBUG_TRACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1029 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1030 wstrace("workshop_hotkeys(%s)\n", on ? "True" : "False");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1031 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1032
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1033 workshopHotKeysEnabled = on;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1034 if (workshopHotKeysEnabled)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1035 for (mp = menuMap; mp < &menuMap[menuMapSize]; mp++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1036 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1037 if (mp->accel != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1038 {
273
2463194c8cdd updated for version 7.0073
vimboss
parents: 189
diff changeset
1039 vim_snprintf(cbuf, sizeof(cbuf),
2463194c8cdd updated for version 7.0073
vimboss
parents: 189
diff changeset
1040 "map %s :wsverb %s<CR>", mp->accel, mp->verb);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1041 coloncmd(cbuf, TRUE);
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 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1045 for (mp = menuMap; mp < &menuMap[menuMapSize]; mp++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1046 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1047 if (mp->accel != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1048 {
273
2463194c8cdd updated for version 7.0073
vimboss
parents: 189
diff changeset
1049 vim_snprintf(cbuf, sizeof(cbuf), "unmap %s", mp->accel);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1050 coloncmd(cbuf, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1051 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1052 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1053 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1054
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1055 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1056 * A button in the toolbar has been pushed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1057 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1058 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1059 workshop_get_positions(
1887
fc89a4f98a8b updated for version 7.2-184
vimboss
parents: 1756
diff changeset
1060 void *clientData UNUSED,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1061 char **filename, /* output data */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1062 int *curLine, /* output data */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1063 int *curCol, /* output data */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1064 int *selStartLine, /* output data */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1065 int *selStartCol, /* output data */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1066 int *selEndLine, /* output data */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1067 int *selEndCol, /* output data */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1068 int *selLength, /* output data */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1069 char **selection) /* output data */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1070 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1071 static char ffname[MAXPATHLEN];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1072
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1073 #ifdef WSDEBUG_TRACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1074 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1075 wstrace("workshop_get_positions(%#x, \"%s\", ...)\n",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1076 clientData, (curbuf && curbuf->b_sfname != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1077 ? (char *)curbuf->b_sfname : "<None>");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1078 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1079
1756
5fafc42c22d2 updated for version 7.2-053
vimboss
parents: 1621
diff changeset
1080 if (curbuf->b_ffname == NULL)
5fafc42c22d2 updated for version 7.2-053
vimboss
parents: 1621
diff changeset
1081 ffname[0] = NUL;
5fafc42c22d2 updated for version 7.2-053
vimboss
parents: 1621
diff changeset
1082 else
5fafc42c22d2 updated for version 7.2-053
vimboss
parents: 1621
diff changeset
1083 /* copy so nobody can change b_ffname */
5fafc42c22d2 updated for version 7.2-053
vimboss
parents: 1621
diff changeset
1084 strcpy(ffname, (char *) curbuf->b_ffname);
5fafc42c22d2 updated for version 7.2-053
vimboss
parents: 1621
diff changeset
1085 *filename = ffname;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1086 *curLine = curwin->w_cursor.lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1087 *curCol = curwin->w_cursor.col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1088
692
a28f83d37113 updated for version 7.0208
vimboss
parents: 456
diff changeset
1089 if (curbuf->b_visual.vi_mode == 'v' &&
a28f83d37113 updated for version 7.0208
vimboss
parents: 456
diff changeset
1090 equalpos(curwin->w_cursor, curbuf->b_visual.vi_end))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1091 {
692
a28f83d37113 updated for version 7.0208
vimboss
parents: 456
diff changeset
1092 *selStartLine = curbuf->b_visual.vi_start.lnum;
a28f83d37113 updated for version 7.0208
vimboss
parents: 456
diff changeset
1093 *selStartCol = curbuf->b_visual.vi_start.col;
a28f83d37113 updated for version 7.0208
vimboss
parents: 456
diff changeset
1094 *selEndLine = curbuf->b_visual.vi_end.lnum;
a28f83d37113 updated for version 7.0208
vimboss
parents: 456
diff changeset
1095 *selEndCol = curbuf->b_visual.vi_end.col;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1096 *selection = get_selection(curbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1097 if (*selection)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1098 *selLength = strlen(*selection);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1099 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1100 *selLength = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1101 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1102 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1103 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1104 *selStartLine = *selEndLine = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1105 *selStartCol = *selEndCol = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1106 *selLength = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1107 *selection = "";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1108 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1109
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1110 return True;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1111 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1112
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1113
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1114
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1115 /************************************************************************
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1116 * Utility functions
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1117 ************************************************************************/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1118
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1119 static char *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1120 get_selection(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1121 buf_T *buf) /* buffer whose selection we want */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1122 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1123 pos_T *start; /* start of the selection */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1124 pos_T *end; /* end of the selection */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1125 char *lp; /* pointer to actual line data */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1126 int llen; /* length of actual line data */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1127 char *sp; /* pointer to selection buffer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1128 int slen; /* string length in selection buffer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1129 int size; /* size of selection buffer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1130 char *new_sp; /* temp pointer to new sp */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1131 int lnum; /* line number we are appending */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1132
692
a28f83d37113 updated for version 7.0208
vimboss
parents: 456
diff changeset
1133 if (buf->b_visual.vi_mode == 'v')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1134 {
692
a28f83d37113 updated for version 7.0208
vimboss
parents: 456
diff changeset
1135 start = &buf->b_visual.vi_start;
a28f83d37113 updated for version 7.0208
vimboss
parents: 456
diff changeset
1136 end = &buf->b_visual.vi_end;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1137 if (start->lnum == end->lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1138 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1139 /* selection is all on one line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1140 lp = (char *) ml_get_pos(start);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1141 llen = end->col - start->col + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1142 sp = (char *) malloc(llen + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1143 if (sp != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1144 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1145 strncpy(sp, lp, llen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1146 sp[llen] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1147 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1148 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1149 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1150 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1151 /* multi-line selection */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1152 lp = (char *) ml_get_pos(start);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1153 llen = strlen(lp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1154 sp = (char *) malloc(BUFSIZ + llen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1155 if (sp != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1156 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1157 size = BUFSIZ + llen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1158 strcpy(sp, lp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1159 sp[llen] = '\n';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1160 slen = llen + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1161
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1162 lnum = start->lnum + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1163 while (lnum < end->lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1164 sp = append_selection(lnum++, sp, &size, &slen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1165
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1166 lp = (char *) ml_get(end->lnum);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1167 llen = end->col + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1168 if ((slen + llen) >= size)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1169 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1170 new_sp = (char *)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1171 realloc(sp, slen + llen + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1172 if (new_sp != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1173 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1174 size += llen + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1175 sp = new_sp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1176 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1177 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1178 if ((slen + llen) < size)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1179 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1180 strncpy(&sp[slen], lp, llen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1181 sp[slen + llen] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1182 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1183
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1184 }
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 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1188 sp = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1189
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1190 return sp;
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 static char *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1194 append_selection(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1195 int lnum, /* line number to append */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1196 char *sp, /* pointer to selection buffer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1197 int *size, /* ptr to size of sp */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1198 int *slen) /* ptr to length of selection string */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1199 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1200 char *lp; /* line of data from buffer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1201 int llen; /* strlen of lp */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1202 char *new_sp; /* temp pointer to new sp */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1203
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1204 lp = (char *)ml_get((linenr_T)lnum);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1205 llen = strlen(lp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1206
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1207 if ((*slen + llen) <= *size)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1208 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1209 new_sp = (char *) realloc((void *) sp, BUFSIZ + *slen + llen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1210 if (*new_sp != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1211 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1212 *size = BUFSIZ + *slen + llen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1213 sp = new_sp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1214 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1215 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1216 if ((*slen + llen) > *size)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1217 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1218 strcat(&sp[*slen], lp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1219 *slen += llen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1220 sp[*slen++] = '\n';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1221 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1222
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1223 return sp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1224 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1225
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1226
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1227
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1228 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1229 load_buffer_by_name(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1230 char *filename, /* the file to load */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1231 int lnum) /* an optional line number (or 0) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1232 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1233 char lnumbuf[16]; /* make line number option for :e */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1234 char cbuf[BUFSIZ]; /* command buffer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1235
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1236 if (lnum > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1237 sprintf(lnumbuf, "+%d", lnum);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1238 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1239 lnumbuf[0] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1240
273
2463194c8cdd updated for version 7.0073
vimboss
parents: 189
diff changeset
1241 vim_snprintf(cbuf, sizeof(cbuf), "e %s %s", lnumbuf, filename);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1242 coloncmd(cbuf, False);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1243 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1244
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1245
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1246 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1247 load_window(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1248 char *filename, /* filename to load */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1249 int lnum) /* linenumber to go to */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1250 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1251 buf_T *buf; /* buffer filename is stored in */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1252 win_T *win; /* window filenme is displayed in */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1253
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1254 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1255 * Make sure filename is displayed and is the current window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1256 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1257
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1258 buf = buflist_findname((char_u *)filename);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1259 if (buf == NULL || (win = get_window(buf)) == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1260 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1261 /* No buffer or buffer is not in current window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1262 /* wsdebug("load_window: load_buffer_by_name(\"%s\", %d)\n",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1263 filename, lnum); */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1264 load_buffer_by_name(filename, lnum);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1265 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1266 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1267 {
2267
c08f91142c41 Crypt the swapfile.
Bram Moolenaar <bram@vim.org>
parents: 2250
diff changeset
1268 #ifdef FEAT_WINDOWS
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1269 /* buf is in a window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1270 if (win != curwin)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1271 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1272 win_enter(win, False);
2267
c08f91142c41 Crypt the swapfile.
Bram Moolenaar <bram@vim.org>
parents: 2250
diff changeset
1273 /* wsdebug("load_window: window enter %s\n",
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1274 win->w_buffer->b_sfname); */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1275 }
2267
c08f91142c41 Crypt the swapfile.
Bram Moolenaar <bram@vim.org>
parents: 2250
diff changeset
1276 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1277 if (lnum > 0 && win->w_cursor.lnum != lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1278 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1279 warp_to_pc(lnum);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1280 /* wsdebug("load_window: warp to %s[%d]\n",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1281 win->w_buffer->b_sfname, lnum); */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1282 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1283 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1284 out_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1285 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1286
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1287
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1288
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1289 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1290 warp_to_pc(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1291 int lnum) /* line number to warp to */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1292 {
1212
e085b0f7b036 updated for version 7.1b
vimboss
parents: 692
diff changeset
1293 char lbuf[256]; /* build line command here */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1294
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1295 if (lnum > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1296 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1297 if (State & INSERT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1298 add_to_input_buf((char_u *) "\033", 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1299 if (isShowing(lnum))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1300 sprintf(lbuf, "%dG", lnum);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1301 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1302 sprintf(lbuf, "%dz.", lnum);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1303 add_to_input_buf((char_u *) lbuf, strlen(lbuf));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1304 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1305 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1306
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1307 static Boolean
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1308 isShowing(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1309 int lnum) /* tell if line number is showing */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1310 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1311 return lnum >= curwin->w_topline && lnum < curwin->w_botline;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1312 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1313
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1314
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1315
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1316 static win_T *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1317 get_window(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1318 buf_T *buf) /* buffer to find window for */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1319 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1320 win_T *wp = NULL; /* window filename is in */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1321
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1322 for (wp = firstwin; wp != NULL; wp = W_NEXT(wp))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1323 if (buf == wp->w_buffer)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1324 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1325 return wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1326 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1327
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1328
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1329 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1330 updatePriority(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1331 Boolean subMenu) /* if True then start new submenu pri */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1332 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1333 int pri; /* priority of this menu/item */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1334 char *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1335
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1336 p = strrchr(curMenuPriority, '.');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1337 ASSERT(p != NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1338 *p++ = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1339
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1340 pri = atoi(p) + 10; /* our new priority */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1341
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1342 if (subMenu)
273
2463194c8cdd updated for version 7.0073
vimboss
parents: 189
diff changeset
1343 vim_snprintf(curMenuPriority, sizeof(curMenuPriority),
2463194c8cdd updated for version 7.0073
vimboss
parents: 189
diff changeset
1344 "%s.%d.0", curMenuPriority, pri);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1345 else
273
2463194c8cdd updated for version 7.0073
vimboss
parents: 189
diff changeset
1346 vim_snprintf(curMenuPriority, sizeof(curMenuPriority),
2463194c8cdd updated for version 7.0073
vimboss
parents: 189
diff changeset
1347 "%s.%d", curMenuPriority, pri);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1348 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1349
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1350 static char *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1351 addUniqueMnemonic(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1352 char *mnemonics, /* currently used mnemonics */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1353 char *label) /* label of menu needing mnemonic */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1354 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1355 static char name[BUFSIZ]; /* buffer for the updated name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1356 char *p; /* pointer into label */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1357 char *found; /* pointer to possible mnemonic */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1358
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1359 found = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1360 for (p = label; *p != NUL; p++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1361 if (strchr(mnemonics, *p) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1362 if (found == NULL || (isupper((int)*p) && islower((int)*found)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1363 found = p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1364
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1365 if (found != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1366 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1367 strncpy(name, label, (found - label));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1368 strcat(name, "&");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1369 strcat(name, found);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1370 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1371 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1372 strcpy(name, label);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1373
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1374 return name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1375 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1376
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1377 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1378 * Some characters in a menu name must be escaped in vim. Since this is vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1379 * specific, it must be done on this side.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1380 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1381 static char *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1382 fixup(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1383 char *label)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1384 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1385 static char buf[BUFSIZ];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1386 char *bp; /* pointer into buf */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1387 char *lp; /* pointer into label */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1388
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1389 lp = label;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1390 bp = buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1391 while (*lp != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1392 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1393 if (*lp == ' ' || *lp == '.')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1394 *bp++ = '\\';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1395 *bp++ = *lp++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1396 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1397 *bp = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1398
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1399 return buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1400 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1401
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1402
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1403 #ifdef NOHANDS_SUPPORT_FUNCTIONS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1404
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1405 /* For the NoHands test suite */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1406
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1407 char *
7837
33ba2adb6065 commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents: 2668
diff changeset
1408 workshop_test_getcurrentfile(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1409 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1410 char *filename, *selection;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1411 int curLine, curCol, selStartLine, selStartCol, selEndLine;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1412 int selEndCol, selLength;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1413
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1414 if (workshop_get_positions(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1415 NULL, &filename, &curLine, &curCol, &selStartLine,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1416 &selStartCol, &selEndLine, &selEndCol, &selLength,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1417 &selection))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1418 return filename;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1419 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1420 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1421 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1422
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1423 int
7837
33ba2adb6065 commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents: 2668
diff changeset
1424 workshop_test_getcursorrow(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1425 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1426 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1427 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1428
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1429 int
7837
33ba2adb6065 commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents: 2668
diff changeset
1430 workshop_test_getcursorcol(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1431 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1432 char *filename, *selection;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1433 int curLine, curCol, selStartLine, selStartCol, selEndLine;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1434 int selEndCol, selLength;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1435
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1436 if (workshop_get_positions(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1437 NULL, &filename, &curLine, &curCol, &selStartLine,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1438 &selStartCol, &selEndLine, &selEndCol, &selLength,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1439 &selection))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1440 return curCol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1441 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1442 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1443 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1444
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1445 char *
7837
33ba2adb6065 commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents: 2668
diff changeset
1446 workshop_test_getcursorrowtext(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1447 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1448 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1449 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1450
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1451 char *
7837
33ba2adb6065 commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents: 2668
diff changeset
1452 workshop_test_getselectedtext(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1453 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1454 char *filename, *selection;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1455 int curLine, curCol, selStartLine, selStartCol, selEndLine;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1456 int selEndCol, selLength;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1457
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1458 if (workshop_get_positions(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1459 NULL, &filename, &curLine, &curCol, &selStartLine,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1460 &selStartCol, &selEndLine, &selEndCol, &selLength,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1461 &selection))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1462 return selection;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1463 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1464 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1465 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1466
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1467 void
1887
fc89a4f98a8b updated for version 7.2-184
vimboss
parents: 1756
diff changeset
1468 workshop_save_sensitivity(char *filename UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1469 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1470 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1471
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1472 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1473
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1474 static char *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1475 fixAccelText(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1476 char *ap) /* original acceleratorText */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1477 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1478 char buf[256]; /* build in temp buffer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1479 char *shift; /* shift string of "" */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1480
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1481 if (ap == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1482 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1483
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1484 /* If the accelerator is shifted use the vim form */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1485 if (strncmp("Shift+", ap, 6) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1486 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1487 shift = "S-";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1488 ap += 6;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1489 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1490 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1491 shift = "";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1492
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1493 if (*ap == 'F' && atoi(&ap[1]) > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1494 {
273
2463194c8cdd updated for version 7.0073
vimboss
parents: 189
diff changeset
1495 vim_snprintf(buf, sizeof(buf), "<%s%s>", shift, ap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1496 return strdup(buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1497 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1498 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1499 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1500 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1501
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1502 #ifdef FEAT_BEVAL
189
504c627f7474 updated for version 7.0057
vimboss
parents: 44
diff changeset
1503 void
504c627f7474 updated for version 7.0057
vimboss
parents: 44
diff changeset
1504 workshop_beval_cb(
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1505 BalloonEval *beval,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1506 int state)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1507 {
189
504c627f7474 updated for version 7.0057
vimboss
parents: 44
diff changeset
1508 win_T *wp;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1509 char_u *text;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1510 int type;
189
504c627f7474 updated for version 7.0057
vimboss
parents: 44
diff changeset
1511 linenr_T lnum;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1512 int col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1513 int idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1514 char buf[MAXPATHLEN * 2];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1515 static int serialNo = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1516
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1517 if (!p_beval)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1518 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1519
189
504c627f7474 updated for version 7.0057
vimboss
parents: 44
diff changeset
1520 if (get_beval_info(beval, FALSE, &wp, &lnum, &text, &col) == OK)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1521 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1522 if (text && text[0])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1523 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1524 /* Send debugger request */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1525 if (strlen((char *) text) > (MAXPATHLEN/2))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1526 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1527 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1528 * The user has probably selected the entire
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1529 * buffer or something like that - don't attempt
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1530 * to evaluate it
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1531 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1532 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1533 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1534
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1535 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1536 * WorkShop expects the col to be a character index, not
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1537 * a column number. Compute the index from col. Also set
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1538 * line to 0 because thats what dbx expects.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1539 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1540 idx = computeIndex(col, text, beval->ts);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1541 if (idx > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1542 {
189
504c627f7474 updated for version 7.0057
vimboss
parents: 44
diff changeset
1543 lnum = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1544
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1545 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1546 * If successful, it will respond with a balloon cmd.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1547 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1548 if (state & ControlMask)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1549 /* Evaluate *(expression) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1550 type = (int)GPLineEval_INDIRECT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1551 else if (state & ShiftMask)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1552 /* Evaluate type(expression) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1553 type = (int)GPLineEval_TYPE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1554 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1555 /* Evaluate value(expression) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1556 type = (int)GPLineEval_EVALUATE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1557
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1558 /* Send request to dbx */
273
2463194c8cdd updated for version 7.0073
vimboss
parents: 189
diff changeset
1559 vim_snprintf(buf, sizeof(buf), "toolVerb debug.balloonEval "
189
504c627f7474 updated for version 7.0057
vimboss
parents: 44
diff changeset
1560 "%s %ld,0 %d,0 %d,%d %ld %s\n",
504c627f7474 updated for version 7.0057
vimboss
parents: 44
diff changeset
1561 (char *)wp->w_buffer->b_ffname,
504c627f7474 updated for version 7.0057
vimboss
parents: 44
diff changeset
1562 (long)lnum, idx, type, serialNo++,
504c627f7474 updated for version 7.0057
vimboss
parents: 44
diff changeset
1563 (long)strlen((char *)text), (char *)text);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1564 balloonEval = beval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1565 workshop_send_message(buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1566 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1567 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1568 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1569 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1570
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1571 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1572 computeIndex(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1573 int wantedCol,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1574 char_u *line,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1575 int ts)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1576 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1577 int col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1578 int idx = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1579
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1580 while (line[idx])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1581 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1582 if (line[idx] == '\t')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1583 col += ts - (col % ts);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1584 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1585 col++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1586 idx++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1587 if (col >= wantedCol)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1588 return idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1589 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1590
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1591 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1592 }
2031
07de57cbcb25 updated for version 7.2.327
Bram Moolenaar <bram@zimbu.org>
parents: 1887
diff changeset
1593 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1594
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1595 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1596 addMenu(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1597 char *menu, /* menu name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1598 char *accel, /* accelerator text (optional) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1599 char *verb) /* WorkShop action-verb */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1600 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1601 MenuMap *newMap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1602 char cbuf[BUFSIZ];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1603
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1604 if (menuMapSize >= menuMapMax)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1605 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1606 newMap = realloc(menuMap,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1607 sizeof(MenuMap) * (menuMapMax + MENU_INC));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1608 if (newMap != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1609 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1610 menuMap = newMap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1611 menuMapMax += MENU_INC;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1612 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1613 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1614 if (menuMapSize < menuMapMax)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1615 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1616 menuMap[menuMapSize].name = strdup(menu);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1617 menuMap[menuMapSize].accel = accel && *accel ? strdup(accel) : NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1618 menuMap[menuMapSize++].verb = strdup(verb);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1619 if (accel && workshopHotKeysEnabled)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1620 {
273
2463194c8cdd updated for version 7.0073
vimboss
parents: 189
diff changeset
1621 vim_snprintf(cbuf, sizeof(cbuf),
2463194c8cdd updated for version 7.0073
vimboss
parents: 189
diff changeset
1622 "map %s :wsverb %s<CR>", accel, verb);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1623 coloncmd(cbuf, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1624 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1625 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1626 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1627
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1628 static char *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1629 nameStrip(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1630 char *raw) /* menu name, possibly with & chars */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1631 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1632 static char buf[BUFSIZ]; /* build stripped name here */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1633 char *bp = buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1634
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1635 while (*raw)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1636 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1637 if (*raw != '&')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1638 *bp++ = *raw;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1639 raw++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1640 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1641 *bp = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1642 return buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1643 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1644
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1645
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1646 static char *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1647 lookupVerb(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1648 char *verb,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1649 int skip) /* number of matches to skip */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1650 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1651 int i; /* loop iterator */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1652
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1653 for (i = 0; i < menuMapSize; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1654 if (strcmp(menuMap[i].verb, verb) == 0 && skip-- == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1655 return nameStrip(menuMap[i].name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1656
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1657 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1658 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1659
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1660
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1661 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1662 coloncmd(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1663 char *cmd, /* the command to print */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1664 Boolean force) /* force cursor update */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1665 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1666 char_u *cpo_save = p_cpo;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1667
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1668 #ifdef WSDEBUG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1669 if (WSDLEVEL(WS_TRACE_COLONCMD))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1670 wsdebug("Cmd: %s\n", cmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1671 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1672
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1673 p_cpo = empty_option;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1674
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1675 ALT_INPUT_LOCK_ON;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1676 do_cmdline_cmd((char_u *)cmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1677 ALT_INPUT_LOCK_OFF;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1678
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1679 p_cpo = cpo_save;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1680
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1681 if (force)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1682 gui_update_screen();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1683 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1684
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1685 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1686 * setDollarVim - Given the run directory, search for the vim install
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1687 * directory and set $VIM.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1688 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1689 * We can be running out of SUNWspro/bin or out of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1690 * SUNWspro/contrib/contrib6/vim5.6/bin so we check
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1691 * relative to both of these directories.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1692 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1693 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1694 setDollarVim(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1695 char *rundir)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1696 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1697 char buf[MAXPATHLEN];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1698 char *cp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1699
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1700 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1701 * First case: Running from <install-dir>/SUNWspro/bin
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1702 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1703 strcpy(buf, rundir);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1704 strcat(buf, "/../contrib/contrib6/vim" VIM_VERSION_SHORT "/share/vim/"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1705 VIM_VERSION_NODOT "/syntax/syntax.vim");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1706 if (access(buf, R_OK) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1707 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1708 strcpy(buf, "SPRO_WSDIR=");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1709 strcat(buf, rundir);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1710 cp = strrchr(buf, '/');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1711 if (cp != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1712 strcpy(cp, "/WS6U2");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1713 putenv(strdup(buf));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1714
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1715 strcpy(buf, "VIM=");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1716 strcat(buf, rundir);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1717 strcat(buf, "/../contrib/contrib6/vim" VIM_VERSION_SHORT "/share/vim/"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1718 VIM_VERSION_NODOT);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1719 putenv(strdup(buf));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1720 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1721 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1722
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1723 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1724 * Second case: Probably running from
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1725 * <install-dir>/SUNWspro/contrib/contrib6/vim5.6/bin
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1726 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1727 strcpy(buf, rundir);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1728 strcat(buf, "/../../../contrib/contrib6/vim" VIM_VERSION_SHORT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1729 "/share/vim/" VIM_VERSION_NODOT "/syntax/syntax.vim");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1730 if (access(buf, R_OK) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1731 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1732 strcpy(buf, "SPRO_WSDIR=");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1733 strcat(buf, rundir);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1734 cp = strrchr(buf, '/');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1735 if (cp != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1736 strcpy(cp, "../../../../WS6U2");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1737 putenv(strdup(buf));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1738
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1739 strcpy(buf, "VIM=");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1740 strcat(buf, rundir);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1741 strcat(buf, "/../../../contrib/contrib6/vim" VIM_VERSION_SHORT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1742 "/share/vim/" VIM_VERSION_NODOT);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1743 putenv(strdup(buf));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1744 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1745 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1746 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1747
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1748 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1749 * findYourself - Find the directory we are running from. This is used to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1750 * set $VIM. We need to set this because users can install
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1751 * the package in a different directory than the compiled
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1752 * directory. This is a Sun Visual WorkShop requirement!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1753 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1754 * Note: We override a user's $VIM because it won't have the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1755 * WorkShop specific files. S/he may not like this but its
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1756 * better than getting the wrong files (especially as the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1757 * user is likely to have $VIM set to 5.4 or later).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1758 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1759 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1760 findYourself(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1761 char *argv0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1762 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1763 char *runpath = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1764 char *path;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1765 char *pathbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1766
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1767 if (*argv0 == '/')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1768 runpath = strdup(argv0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1769 else if (*argv0 == '.' || strchr(argv0, '/'))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1770 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1771 runpath = (char *) malloc(MAXPATHLEN);
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2245
diff changeset
1772 if (getcwd(runpath, MAXPATHLEN) == NULL)
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2245
diff changeset
1773 runpath[0] = NUL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1774 strcat(runpath, "/");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1775 strcat(runpath, argv0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1776 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1777 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1778 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1779 path = getenv("PATH");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1780 if (path != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1781 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1782 runpath = (char *) malloc(MAXPATHLEN);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1783 pathbuf = strdup(path);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1784 path = strtok(pathbuf, ":");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1785 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1786 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1787 strcpy(runpath, path);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1788 strcat(runpath, "/");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1789 strcat(runpath, argv0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1790 if (access(runpath, X_OK) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1791 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1792 } while ((path = strtok(NULL, ":")) != NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1793 free(pathbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1794 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1795 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1796
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1797 if (runpath != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1798 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1799 char runbuf[MAXPATHLEN];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1800
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1801 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1802 * We found the run directory. Now find the install dir.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1803 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1804 (void)vim_FullName((char_u *)runpath, (char_u *)runbuf, MAXPATHLEN, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1805 path = strrchr(runbuf, '/');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1806 if (path != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1807 *path = NUL; /* remove the vim/gvim name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1808 path = strrchr(runbuf, '/');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1809 if (path != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1810 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1811 if (strncmp(path, "/bin", 4) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1812 setDollarVim(runbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1813 else if (strncmp(path, "/src", 4) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1814 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1815 *path = NUL; /* development tree */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1816 setDollarVim(runbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1817 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1818 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1819 free(runpath);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1820 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1821 }