+ * Retrieve a line of the screen or of the scrollback, according to
+ * whether the y coordinate is non-negative or negative
+ * (respectively).
+ */
+unsigned long *lineptr(int y, int lineno) {
+ unsigned long *line, lineattrs;
+ tree234 *whichtree;
+ int i, treeindex, oldlen;
+
+ if (y >= 0) {
+ whichtree = screen;
+ treeindex = y;
+ } else {
+ whichtree = scrollback;
+ treeindex = y + count234(scrollback);
+ }
+ line = index234(whichtree, treeindex);
+
+ /* We assume that we don't screw up and retrieve something out of range. */
+if (line == NULL) {
+debug(("line=%d y=%d treeindex=%d\n", lineno, y, treeindex));
+debug(("screen:%d scrollback:%d\n", count234(screen), count234(scrollback)));
+ assert(line != NULL);
+}
+
+ if (line[0] != cols) {
+ /*
+ * This line is the wrong length, which probably means it
+ * hasn't been accessed since a resize. Resize it now.
+ */
+ oldlen = line[0];
+ lineattrs = line[oldlen+1];
+ delpos234(whichtree, treeindex);
+ line = srealloc(line, TSIZE * (2+cols));
+ line[0] = cols;
+ for (i = oldlen; i < cols; i++)
+ line[i+1] = ERASE_CHAR;
+ line[cols+1] = lineattrs & LATTR_MODE;
+ addpos234(whichtree, line, treeindex);
+ }
+
+ return line+1;
+}
+#define lineptr(x) lineptr(x,__LINE__)
+/*