go back to 3 lines of context
[nedit-bw.git] / fix-calltip-not-found-tip.patch
blob829e1273778dae8d9f15c8b7bba75f0374ef7d44
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 @@ -102,8 +102,6 @@ typedef struct _tag {
14 enum searchDirection {FORWARD, BACKWARD};
16 static int loadTagsFile(const char *tagSpec, int index, int recLevel);
17 -static void findDefCB(Widget widget, WindowInfo *window, Atom *sel,
18 - Atom *type, char *value, int *length, int *format);
19 static void setTag(tag *t, const char *name, const char *file,
20 int language, const char *searchString, int posInf,
21 const char * tag);
22 @@ -865,7 +863,6 @@ int LookupTag(const char *name, const ch
23 static int findDef(WindowInfo *window, const char *value, int search_type) {
24 static char tagText[MAX_TAG_LEN + 1];
25 const char *p;
26 - char message[MAX_TAG_LEN+40];
27 int l, ml, status = 0;
29 searchMode = search_type;
30 @@ -893,12 +890,7 @@ static int findDef(WindowInfo *window, c
31 if (status == -1) {
32 /* Didn't find any matches */
33 status++;
34 - if (searchMode == TIP_FROM_TAG || searchMode == TIP) {
35 - sprintf(message, "No match for \"%s\" in calltips or tags.",
36 - tagName);
37 - tagsShowCalltip( window, message );
38 - } else
39 - {
40 + if (searchMode != TIP_FROM_TAG && searchMode != TIP) {
41 DialogF(DF_WARN, window->textArea, 1, "Tags",
42 "\"%s\" not found in tags file%s", "OK", tagName,
43 (TagsFileList && TagsFileList->next) ? "s" : "");
44 @@ -922,19 +914,19 @@ static int findDef(WindowInfo *window, c
45 ** loaded tags file and bring up the file and line that the tags file
46 ** indicates.
48 -static void findDefinitionHelper(WindowInfo *window, Time time, const char *arg,
49 +static int findDefinitionHelper(WindowInfo *window, Time time, char **arg,
50 int search_type)
52 - if(arg)
53 + if(NULL == *arg)
55 - findDef(window, arg, search_type);
56 - }
57 - else
58 - {
59 - searchMode = search_type;
60 - XtGetSelectionValue(window->textArea, XA_PRIMARY, XA_STRING,
61 - (XtSelectionCallbackProc)findDefCB, window, time);
62 + *arg = GetAnySelection(window);
63 + if (NULL == *arg) {
64 + XBell(TheDisplay, 0);
65 + return 0;
66 + }
69 + return findDef(window, *arg, search_type);
73 @@ -942,7 +934,11 @@ static void findDefinitionHelper(WindowI
75 void FindDefinition(WindowInfo *window, Time time, const char *arg)
77 - findDefinitionHelper(window, time, arg, TAG);
78 + char *usedArg = (char *)arg;
79 + findDefinitionHelper(window, time, &usedArg, TAG);
80 + if (usedArg != arg) {
81 + XtFree(usedArg);
82 + }
86 @@ -950,6 +946,10 @@ void FindDefinition(WindowInfo *window,
88 void FindDefCalltip(WindowInfo *window, Time time, const char *arg)
90 + int cID;
91 + char message[MAX_TAG_LEN + 40];
92 + char *usedArg = (char *)arg;
94 /* Reset calltip parameters to reasonable defaults */
95 globAnchored = False;
96 globPos = -1;
97 @@ -957,20 +957,15 @@ void FindDefCalltip(WindowInfo *window,
98 globVAlign = TIP_BELOW;
99 globAlignMode = TIP_SLOPPY;
101 - findDefinitionHelper(window, time, arg, TIP);
103 + cID = findDefinitionHelper(window, time, &usedArg, TIP);
104 + if (cID <= 0 && NULL != usedArg && '\0' != usedArg[0]) {
105 + sprintf(message, "No match for \"%s\" in calltips or tags.", usedArg);
106 + tagsShowCalltip(window, message);
109 -/* Callback function for FindDefinition */
110 -static void findDefCB(Widget widget, WindowInfo *window, Atom *sel,
111 - Atom *type, char *value, int *length, int *format)
113 - /* skip if we can't get the selection data, or it's obviously too long */
114 - if (*type == XT_CONVERT_FAIL || value == NULL) {
115 - XBell(TheDisplay, 0);
116 - } else {
117 - findDef(window, value, searchMode);
118 + if (usedArg != arg) {
119 + XtFree(usedArg);
121 - XtFree(value);