disable OM2.3.1 by default, enable with make bertw OM231=1
[nedit-bw.git] / fix-calltip-not-found-tip.patch
blob2680ec21b589d80f6406e73a5e1f29deb047350f
1 Subject: remove 'calltip not found'-tip in error case
3 This can be easily recreated by the user.
5 ---
7 source/tags.c | 57 ++++++++++++++++++++++++++-------------------------------
8 1 file changed, 26 insertions(+), 31 deletions(-)
10 diff --quilt old/source/tags.c new/source/tags.c
11 --- old/source/tags.c
12 +++ new/source/tags.c
13 @@ -100,12 +100,10 @@ typedef struct _tag {
16 enum searchDirection {FORWARD, BACKWARD};
18 static int loadTagsFile(const char *tagSpec, int index, int recLevel);
19 -static void findDefCB(Widget widget, WindowInfo *window, Atom *sel,
20 - Atom *type, char *value, int *length, int *format);
21 static void setTag(tag *t, const char *name, const char *file,
22 int language, const char *searchString, int posInf,
23 const char * tag);
24 static int fakeRegExSearch(WindowInfo *window, char *buffer,
25 const char *searchString, int *startPos, int *endPos);
26 @@ -863,11 +861,10 @@ int LookupTag(const char *name, const ch
27 ** returns the calltip ID, or 0 on failure.
29 static int findDef(WindowInfo *window, const char *value, int search_type) {
30 static char tagText[MAX_TAG_LEN + 1];
31 const char *p;
32 - char message[MAX_TAG_LEN+40];
33 int l, ml, status = 0;
35 searchMode = search_type;
36 l = strlen(value);
37 if (l <= MAX_TAG_LEN) {
38 @@ -891,16 +888,11 @@ static int findDef(WindowInfo *window, c
41 if (status == -1) {
42 /* Didn't find any matches */
43 status++;
44 - if (searchMode == TIP_FROM_TAG || searchMode == TIP) {
45 - sprintf(message, "No match for \"%s\" in calltips or tags.",
46 - tagName);
47 - tagsShowCalltip( window, message );
48 - } else
49 - {
50 + if (searchMode != TIP_FROM_TAG && searchMode != TIP) {
51 DialogF(DF_WARN, window->textArea, 1, "Tags",
52 "\"%s\" not found in tags file%s", "OK", tagName,
53 (TagsFileList && TagsFileList->next) ? "s" : "");
56 @@ -920,59 +912,62 @@ static int findDef(WindowInfo *window, c
58 ** Lookup the definition for the current primary selection the currently
59 ** loaded tags file and bring up the file and line that the tags file
60 ** indicates.
62 -static void findDefinitionHelper(WindowInfo *window, Time time, const char *arg,
63 +static int findDefinitionHelper(WindowInfo *window, Time time, char **arg,
64 int search_type)
66 - if(arg)
67 + if(NULL == *arg)
69 - findDef(window, arg, search_type);
70 - }
71 - else
72 - {
73 - searchMode = search_type;
74 - XtGetSelectionValue(window->textArea, XA_PRIMARY, XA_STRING,
75 - (XtSelectionCallbackProc)findDefCB, window, time);
76 + *arg = GetAnySelection(window);
77 + if (NULL == *arg) {
78 + XBell(TheDisplay, 0);
79 + return 0;
80 + }
83 + return findDef(window, *arg, search_type);
87 ** See findDefHelper
89 void FindDefinition(WindowInfo *window, Time time, const char *arg)
91 - findDefinitionHelper(window, time, arg, TAG);
92 + char *usedArg = (char *)arg;
93 + findDefinitionHelper(window, time, &usedArg, TAG);
94 + if (usedArg != arg) {
95 + XtFree(usedArg);
96 + }
100 ** See findDefHelper
102 void FindDefCalltip(WindowInfo *window, Time time, const char *arg)
104 + int cID;
105 + char message[MAX_TAG_LEN + 40];
106 + char *usedArg = (char *)arg;
108 /* Reset calltip parameters to reasonable defaults */
109 globAnchored = False;
110 globPos = -1;
111 globHAlign = TIP_LEFT;
112 globVAlign = TIP_BELOW;
113 globAlignMode = TIP_SLOPPY;
115 - findDefinitionHelper(window, time, arg, TIP);
117 + cID = findDefinitionHelper(window, time, &usedArg, TIP);
118 + if (cID <= 0 && NULL != usedArg && '\0' != usedArg[0]) {
119 + sprintf(message, "No match for \"%s\" in calltips or tags.", usedArg);
120 + tagsShowCalltip(window, message);
123 -/* Callback function for FindDefinition */
124 -static void findDefCB(Widget widget, WindowInfo *window, Atom *sel,
125 - Atom *type, char *value, int *length, int *format)
127 - /* skip if we can't get the selection data, or it's obviously too long */
128 - if (*type == XT_CONVERT_FAIL || value == NULL) {
129 - XBell(TheDisplay, 0);
130 - } else {
131 - findDef(window, value, searchMode);
132 + if (usedArg != arg) {
133 + XtFree(usedArg);
135 - XtFree(value);
139 ** Try to display a calltip
140 ** anchored: If true, tip appears at position pos