- matched = (Boolean)rematch(buf);
- if (matched)
- break;
- } while (line != cursrcline);
- if (!matched)
- error("No match");
-#define WINDOW 10 /* should be used globally */
- l1 = line - WINDOW / 2;
- if (l1 < 1)
- l1 = 1;
- l2 = line + WINDOW / 2;
- if (l2 > lastlinenum)
- l2 = lastlinenum;
- printlines(l1, l2);
- cursrcline = line; /* override printlines */
+ matched = (boolean) re_exec(buf);
+ } while (not matched and line != cursrcline);
+ if (not matched) {
+ beginerrmsg();
+ fprintf(stderr, "no match\n");
+ } else {
+ printlines(line, line);
+ cursrcline = line;
+ }
+ }
+ }
+}
+
+public integer srcwindowlen ()
+{
+ Node s;
+
+ s = findvar(identname("$listwindow", true));
+ if (s == nil)
+ return 10;
+ eval(s);
+ return pop(integer);
+}
+
+/*
+ * Compute a small window around the given line.
+ */
+
+public getsrcwindow (line, l1, l2)
+Lineno line, *l1, *l2;
+{
+ integer size;
+
+ size = srcwindowlen();
+ *l1 = line - (size div 2);
+ if (*l1 < 1) {
+ *l1 = 1;
+ }
+ *l2 = *l1 + size;
+ if (lastlinenum != LASTLINE and *l2 > lastlinenum) {
+ *l2 = lastlinenum;
+ }