fix 'nedit file' segfaults
[nedit-bw.git] / calltip_ignore_arg.patch
blob20e71b699dbb2c6ee2f90a77244e35ef753a5dda
1 ---
3 doc/help.etx | 5 +++--
4 source/macro.c | 9 ++++++++-
5 source/tags.c | 16 +++++++++-------
6 source/tags.h | 2 +-
7 4 files changed, 21 insertions(+), 11 deletions(-)
9 diff --quilt old/source/macro.c new/source/macro.c
10 --- old/source/macro.c
11 +++ new/source/macro.c
12 @@ -3227,10 +3227,11 @@ static void stringDialogEscCB(Widget w,
13 ** "right": Put the right edge of the calltip at the position
14 ** "center" and "right" cannot both be specified.
15 ** "above": Place the calltip above the position
16 ** "strict": Don't move the calltip to keep it on-screen and away
17 ** from the cursor's line.
18 +** "ignore": Don't show calltip, if nothing is found
19 **
20 ** Returns the new calltip's ID on success, 0 on failure.
22 ** Does this need to go on IgnoredActions? I don't think so, since
23 ** showing a calltip may be part of the action you want to learn.
24 @@ -3241,10 +3242,11 @@ static int calltipMS(WindowInfo *window,
25 char stringStorage[TYPE_INT_STR_SIZE(int)], *tipText, *txtArg;
26 Boolean anchored = False, lookup = True;
27 int mode = -1, i;
28 int anchorPos, hAlign = TIP_LEFT, vAlign = TIP_BELOW,
29 alignMode = TIP_SLOPPY;
30 + Boolean ignore = False;
32 /* Read and check the string */
33 if (nArgs < 1) {
34 *errMsg = "%s subroutine called with too few arguments";
35 return False;
36 @@ -3301,20 +3303,25 @@ static int calltipMS(WindowInfo *window,
37 else if (!strcmp(txtArg, "tagKey"))
38 mode = TIP_FROM_TAG;
39 else
40 goto bad_arg;
41 break;
42 + case 'i':
43 + if (strcmp(txtArg, "ignore"))
44 + goto bad_arg;
45 + ignore = True;
46 + break;
47 default:
48 goto bad_arg;
52 result->tag = INT_TAG;
53 if (mode < 0) lookup = False;
54 /* Look up (maybe) a calltip and display it */
55 result->val.n = ShowTipString( window, tipText, anchored, anchorPos, lookup,
56 - mode, hAlign, vAlign, alignMode );
57 + mode, hAlign, vAlign, alignMode, ignore );
59 return True;
61 bad_arg:
62 /* This is how the (more informative) global var. version would work,
63 diff --quilt old/source/tags.c new/source/tags.c
64 --- old/source/tags.c
65 +++ new/source/tags.c
66 @@ -115,11 +115,12 @@ static int addTag(const char *name, cons
67 const char *search, int posInf, const char *path,
68 int index);
69 static int delTag(const char *name, const char *file, int lang,
70 const char *search, int posInf, int index);
71 static tag *getTag(const char *name, int search_type);
72 -static int findDef(WindowInfo *window, const char *value, int search_type);
73 +static int findDef(WindowInfo *window, const char *value, int search_type,
74 + Boolean ignore);
75 static int findAllMatches(WindowInfo *window, const char *string);
76 static void findAllCB(Widget parent, XtPointer client_data, XtPointer call_data);
77 static Widget createSelectMenu(Widget parent, char *label, int nArgs,
78 char *args[]);
79 static void editTaggedLocation( Widget parent, int i );
80 @@ -855,11 +856,12 @@ int LookupTag(const char *name, const ch
82 /*
83 ** This code path is followed if the request came from either
84 ** FindDefinition or FindDefCalltip. This should probably be refactored.
86 -static int findDef(WindowInfo *window, const char *value, int search_type) {
87 +static int findDef(WindowInfo *window, const char *value, int search_type,
88 + Boolean ignore) {
89 static char tagText[MAX_TAG_LEN + 1];
90 const char *p;
91 char message[MAX_TAG_LEN+40];
92 int l, ml, status = 0;
94 @@ -880,11 +882,11 @@ static int findDef(WindowInfo *window, c
95 if (status == 0 && search_type == TIP && TagsFileList != NULL) {
96 searchMode = TIP_FROM_TAG;
97 status = findAllMatches(window, tagText);
100 - if (status == 0) {
101 + if (status == 0 && !ignore) {
102 /* Didn't find any matches */
103 if (searchMode == TIP_FROM_TAG || searchMode == TIP) {
104 sprintf(message, "No match for \"%s\" in calltips or tags.",
105 tagName);
106 tagsShowCalltip( window, message );
107 @@ -916,11 +918,11 @@ static int findDef(WindowInfo *window, c
108 static void findDefinitionHelper(WindowInfo *window, Time time, const char *arg,
109 int search_type)
111 if(arg)
113 - findDef(window, arg, search_type);
114 + findDef(window, arg, search_type, False);
116 else
118 searchMode = search_type;
119 XtGetSelectionValue(window->textArea, XA_PRIMARY, XA_STRING,
120 @@ -957,11 +959,11 @@ static void findDefCB(Widget widget, Win
122 /* skip if we can't get the selection data, or it's obviously too long */
123 if (*type == XT_CONVERT_FAIL || value == NULL) {
124 XBell(TheDisplay, 0);
125 } else {
126 - findDef(window, value, searchMode);
127 + findDef(window, value, searchMode, False);
129 XtFree(value);
133 @@ -971,11 +973,11 @@ static void findDefCB(Widget widget, Win
134 ** tip and/or tag database depending on search_type
135 ** search_type: Either TIP or TIP_FROM_TAG
137 int ShowTipString(WindowInfo *window, char *text, Boolean anchored,
138 int pos, Boolean lookup, int search_type, int hAlign, int vAlign,
139 - int alignMode) {
140 + int alignMode, Boolean ignore) {
142 if (search_type == TAG) return 0;
144 /* So we don't have to carry all of the calltip alignment info around */
145 globAnchored = anchored;
146 @@ -986,11 +988,11 @@ int ShowTipString(WindowInfo *window, ch
148 /* If this isn't a lookup request, just display it. */
149 if (!lookup)
150 return tagsShowCalltip(window, text);
151 else
152 - return findDef(window, text, search_type);
153 + return findDef(window, text, search_type, ignore);
156 /* store all of the info into a pre-allocated tags struct */
157 static void setTag(tag *t, const char *name, const char *file,
158 int language, const char *searchString, int posInf,
159 diff --quilt old/source/tags.h new/source/tags.h
160 --- old/source/tags.h
161 +++ new/source/tags.h
162 @@ -65,8 +65,8 @@ void FindDefCalltip(WindowInfo *window,
164 /* Display (possibly finding first) a calltip. Search type can only be
165 TIP or TIP_FROM_TAG here. */
166 int ShowTipString(WindowInfo *window, char *text, Boolean anchored,
167 int pos, Boolean lookup, int search_type, int hAlign, int vAlign,
168 - int alignMode);
169 + int alignMode, Boolean ignore);
171 #endif /* NEDIT_TAGS_H_INCLUDED */
172 diff --quilt old/doc/help.etx new/doc/help.etx
173 --- old/doc/help.etx
174 +++ new/doc/help.etx
175 @@ -2537,12 +2537,13 @@ Macro Subroutines
176 the right edge of the calltip with the position. ("center" and "right" may
177 not both be used.) "above" places the calltip above the position. "strict"
178 does not allow the calltip to move from its position in order to avoid going
179 off-screen or obscuring the cursor.
181 - Returns the ID of the calltip if it was found and/or displayed correctly,
182 - 0 otherwise.
183 + Returns the ID of the calltip if it was found and/or displayed correctly, 0
184 + otherwise, in this case a calltp will be shown with an error messages, which
185 + can be supressed with the "ignore" argument.
187 **clipboard_to_string()**
188 Returns the contents of the clipboard as a macro string. Returns empty
189 string on error.