    Allow tag-based calltips to pick up text before and after the target

    Previously only a few lines of text at and following the tag target would be
    retrieved; now a number of lines preceding the target are retrieved too.
    This is for people who expect commentary in front of an item.

diff -r nedit_official nedit_mod
diff -ur nedit_official/source/tags.c nedit_mod/source/tags.c
--- nedit_official/source/tags.c	2004-10-18 15:27:24.000000000 -0400
+++ nedit_mod/source/tags.c	2004-12-07 19:01:35.122484000 -0500
@@ -1292,6 +1292,29 @@
 }    
 
 /*
+ * Given a \0 terminated string and a position, move the position back
+ * by n lines, where line separators (for now) are \n.  If the start of
+ * string is reached before n lines, return the number of lines moved back,
+ * else normally return -1.
+ */
+static int moveBackNLines( char *str, int *pos, int n ) {
+    int i = n++;
+    int p = *pos;
+    while (p > 0 && n > 0) {
+        --p;
+        if (str[p] == '\n')
+            --n;
+    }
+    if (p < *pos) {
+        *pos = p + 1;
+    }
+    if (n==0)
+        return -1;
+    else
+        return i-n;
+}    
+
+/*
 ** Show the calltip specified by tagFiles[i], tagSearch[i], tagPosInf[i]
 ** This reads from either a source code file (if searchMode == TIP_FROM_TAG)
 ** or a calltips file (if searchMode == TIP).
@@ -1388,6 +1411,7 @@
     } else {  /* Mode = TIP_FROM_TAG */
         /* 4. Copy TIP_DEFAULT_LINES lines of text to the calltip string */
         endPos = startPos;
+        moveBackNLines( fileString, &startPos, TIP_DEFAULT_LINES );
         moveAheadNLines( fileString, &endPos, TIP_DEFAULT_LINES );
         /* Make sure not to overrun the fileString with ". . ." */
         if (((size_t) endPos) <= (strlen(fileString)-5)) {
