macro cleanup in interpret.c, macro.c and parse.y
[nedit-bw.git] / fix-calltip-not-found-tip.patch
blob4043a49731a7b68ec95c3c9fdff212512335162f
1 ---
3 source/tags.c | 57 ++++++++++++++++++++++++++-------------------------------
4 1 file changed, 26 insertions(+), 31 deletions(-)
6 diff --quilt old/source/tags.c new/source/tags.c
7 --- old/source/tags.c
8 +++ new/source/tags.c
9 @@ -100,12 +100,10 @@ typedef struct _tag {
12 enum searchDirection {FORWARD, BACKWARD};
14 static int loadTagsFile(const char *tagSpec, int index, int recLevel);
15 -static void findDefCB(Widget widget, WindowInfo *window, Atom *sel,
16 - Atom *type, char *value, int *length, int *format);
17 static void setTag(tag *t, const char *name, const char *file,
18 int language, const char *searchString, int posInf,
19 const char * tag);
20 static int fakeRegExSearch(WindowInfo *window, char *buffer,
21 const char *searchString, int *startPos, int *endPos);
22 @@ -863,11 +861,10 @@ int LookupTag(const char *name, const ch
23 ** returns the calltip ID, or 0 on failure.
25 static int findDef(WindowInfo *window, const char *value, int search_type) {
26 static char tagText[MAX_TAG_LEN + 1];
27 const char *p;
28 - char message[MAX_TAG_LEN+40];
29 int l, ml, status = 0;
31 searchMode = search_type;
32 l = strlen(value);
33 if (l <= MAX_TAG_LEN) {
34 @@ -891,16 +888,11 @@ static int findDef(WindowInfo *window, c
37 if (status == -1) {
38 /* Didn't find any matches */
39 status++;
40 - if (searchMode == TIP_FROM_TAG || searchMode == TIP) {
41 - sprintf(message, "No match for \"%s\" in calltips or tags.",
42 - tagName);
43 - tagsShowCalltip( window, message );
44 - } else
45 - {
46 + if (searchMode != TIP_FROM_TAG && searchMode != TIP) {
47 DialogF(DF_WARN, window->textArea, 1, "Tags",
48 "\"%s\" not found in tags file%s", "OK", tagName,
49 (TagsFileList && TagsFileList->next) ? "s" : "");
52 @@ -920,59 +912,62 @@ static int findDef(WindowInfo *window, c
54 ** Lookup the definition for the current primary selection the currently
55 ** loaded tags file and bring up the file and line that the tags file
56 ** indicates.
58 -static void findDefinitionHelper(WindowInfo *window, Time time, const char *arg,
59 +static int findDefinitionHelper(WindowInfo *window, Time time, char **arg,
60 int search_type)
62 - if(arg)
63 + if(NULL == *arg)
65 - findDef(window, arg, search_type);
66 - }
67 - else
68 - {
69 - searchMode = search_type;
70 - XtGetSelectionValue(window->textArea, XA_PRIMARY, XA_STRING,
71 - (XtSelectionCallbackProc)findDefCB, window, time);
72 + *arg = GetAnySelection(window);
73 + if (NULL == *arg) {
74 + XBell(TheDisplay, 0);
75 + return 0;
76 + }
79 + return findDef(window, *arg, search_type);
83 ** See findDefHelper
85 void FindDefinition(WindowInfo *window, Time time, const char *arg)
87 - findDefinitionHelper(window, time, arg, TAG);
88 + char *usedArg = (char *)arg;
89 + findDefinitionHelper(window, time, &usedArg, TAG);
90 + if (usedArg != arg) {
91 + XtFree(usedArg);
92 + }
96 ** See findDefHelper
98 void FindDefCalltip(WindowInfo *window, Time time, const char *arg)
100 + int cID;
101 + char message[MAX_TAG_LEN + 40];
102 + char *usedArg = (char *)arg;
104 /* Reset calltip parameters to reasonable defaults */
105 globAnchored = False;
106 globPos = -1;
107 globHAlign = TIP_LEFT;
108 globVAlign = TIP_BELOW;
109 globAlignMode = TIP_SLOPPY;
111 - findDefinitionHelper(window, time, arg, TIP);
113 + cID = findDefinitionHelper(window, time, &usedArg, TIP);
114 + if (cID <= 0 && NULL != usedArg && '\0' != usedArg[0]) {
115 + sprintf(message, "No match for \"%s\" in calltips or tags.", usedArg);
116 + tagsShowCalltip(window, message);
119 -/* Callback function for FindDefinition */
120 -static void findDefCB(Widget widget, WindowInfo *window, Atom *sel,
121 - Atom *type, char *value, int *length, int *format)
123 - /* skip if we can't get the selection data, or it's obviously too long */
124 - if (*type == XT_CONVERT_FAIL || value == NULL) {
125 - XBell(TheDisplay, 0);
126 - } else {
127 - findDef(window, value, searchMode);
128 + if (usedArg != arg) {
129 + XtFree(usedArg);
131 - XtFree(value);
135 ** Try to display a calltip
136 ** anchored: If true, tip appears at position pos