*** empty log message ***
authorroot <root>
Wed, 21 Dec 2005 23:57:12 +0000 (23:57 +0000)
committerroot <root>
Wed, 21 Dec 2005 23:57:12 +0000 (23:57 +0000)
Changes
src/feature.h
src/rxvtlib.h.in
src/screen.C

diff --git a/Changes b/Changes
index 9cda352..352f859 100644 (file)
--- a/Changes
+++ b/Changes
@@ -3,8 +3,8 @@ TODO: after requesting the selection and getting a timeout, no further requests
 TODO: safer command: keymap processing.
 TODO: "slow" rendering mode for bidi and scripts
 TODO: read property sequence is broken with respect to utf-8 etc.
-WISH: xterm's -hold
 TODO: http://www120.pair.com/mccarthy/nextstep/intro.htmld/Workspace.html is the correct nextstep look.
+WISH: xterm's -hold
 WISH: keymap modification via esc-sequences.
 WISH: searchable backlog
 WISH: meta-tagging of data by regex/master process (my dream project)
@@ -23,7 +23,7 @@ WISH: just for fun, do shade and tint with XRender.
         - bump max savelines to 10000000.
         - major code cleanup (still not complete, though).
         - _major_ rewrite of internal buffer handling:
-#      - re-flow on resize, lines get wrapped instead of winged.
+       - re-flow on resize, lines get wrapped instead of winged.
        - circular line buffer (substantially speeds up scrolling).
         - slightly less code + data memory usage per terminal.
        - slight overall speed improvements.
index 9ac4bf0..c2e64f8 100644 (file)
 /*
  * Define maximum possible columns and rows
  */
-#define MAX_COLS       4000
-#define MAX_ROWS       1000
+#define MAX_COLS       10000
+#define MAX_ROWS       10000
+
+/*
+ * Define maximum possible savelines
+ */
+#define MAX_SAVELINES   10000000
 
 /*
  * Define default colours for certain items.  If you have a low colour
index 3b0ec99..5d1153d 100644 (file)
@@ -111,9 +111,9 @@ struct line_t {
  *
  *  width      : 1 <= width
  *  height     : 1 <= height
- *  ncol       : 1 <= ncol       <= MAX(int16_t)
- *  nrow       : 1 <= nrow       <= MAX(int16_t)
- *  saveLines  : 0 <= saveLines  <= MAX(int16_t)
+ *  ncol       : 1 <= ncol       <= MAX(tlen_t)
+ *  nrow       : 1 <= nrow       <= MAX(int)
+ *  saveLines  : 0 <= saveLines  <= MAX(int)
  *  total_rows : nrow + saveLines
  *  nsaved     : 0 <= nsaved     <= saveLines
  *  term_start : 0 <= term_start < saveLines
index b4ac645..db81d1c 100644 (file)
@@ -241,8 +241,6 @@ rxvt_term::scr_reset ()
        * add or delete rows as appropriate
        */
 
-     printf ("resize %d:%d => %d:%d\n", prev_nrow, prev_ncol, nrow, ncol);//D
-
       rxvt_salloc *old_ta = talloc; talloc = new rxvt_salloc (ncol * sizeof (text_t));
       rxvt_salloc *old_ra = ralloc; ralloc = new rxvt_salloc (ncol * sizeof (rend_t));
 
@@ -257,9 +255,9 @@ rxvt_term::scr_reset ()
         }
 #endif
 
-      drawn_buf = (line_t *) rxvt_realloc (drawn_buf, nrow * sizeof (line_t));
-      temp_buf  = (line_t *) rxvt_realloc (temp_buf , nrow * sizeof (line_t));
-      swap_buf  = (line_t *) rxvt_realloc (swap_buf , nrow * sizeof (line_t));
+      drawn_buf = (line_t *)rxvt_realloc (drawn_buf, nrow * sizeof (line_t));
+      temp_buf  = (line_t *)rxvt_realloc (temp_buf , nrow * sizeof (line_t));
+      swap_buf  = (line_t *)rxvt_realloc (swap_buf , nrow * sizeof (line_t));
 
       for (int row = min (nrow, prev_nrow); row--; )
         {
@@ -278,16 +276,16 @@ rxvt_term::scr_reset ()
       // re-wrap lines, this is rather ugly, possibly because I am too dumb
       // to come up with a lean and mean algorithm.
 
-      int p    = MOD (term_start + nrow  , prev_total_rows);  // previous row
-      int pend = MOD (term_start - nsaved, prev_total_rows);
+      int p    = MOD (term_start + prev_nrow, prev_total_rows);  // previous row
+      int pend = MOD (term_start - nsaved   , prev_total_rows);
       int q    = total_rows; // rewrapped row
 
       while (p != pend && q > 0)
         {
           p = MOD (p - 1, prev_total_rows);
-
+#ifdef DEBUG_STRICT
           assert (old_buf [MOD (p, prev_total_rows)].t);
-          assert (!old_buf [MOD (p, prev_total_rows)].is_longer ());
+#endif
 
           int llen = old_buf [MOD (p, prev_total_rows)].l;
 
@@ -298,58 +296,61 @@ rxvt_term::scr_reset ()
               llen += prev_ncol;
             }
 
-          int qlines = llen / ncol + 1;
-          int lofs = 0;
+          int qlines = max (0, (llen - 1) / ncol) + 1;
+
+          // drop partial lines completely
+          if (q < qlines)
+            break;
 
           q -= qlines;
 
-          int qrow = q;
+          int lofs = 0;
+          line_t *qline;
 
-          for (; qlines--; qrow++)
+          // re-assemble the full line by destination lines
+          for (int qrow = q; qlines--; qrow++)
             {
-              if (qrow >= 0)
-                {
-                  line_t &qline = row_buf [qrow];
+              qline = row_buf + qrow;
+              lalloc (*qline);
+              qline->set_is_longer ();
 
-                  lalloc (qline);
-                  qline.set_is_longer ();
+              int qcol = 0;
 
-                  int qcol = 0;
+              // fill a single destination line
+              while (lofs < llen && qcol < ncol)
+                {
+                  int prow = lofs / prev_ncol;
+                  int pcol = lofs % prev_ncol;
 
-                  for (;;)
-                    {
-                      int prow = lofs / prev_ncol + p;
-                      int pcol = lofs % prev_ncol;
+                  line_t &pline = old_buf [MOD (p + prow, prev_total_rows)];
 
-                      line_t &pline = old_buf [p];
+                  int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs);
 
-                      int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs);
+                  assert (len);
+                  assert (pline.t);
 
-                      printf ("q %d lofs %d>%d len %d pq %d:%d p %d:%d q :%d\n", q, llen, lofs, len, prev_ncol, ncol, prow, pcol, qcol);
+                  memcpy (qline->t + qcol, pline.t + pcol, len * sizeof (text_t));
+                  memcpy (qline->r + qcol, pline.r + pcol, len * sizeof (rend_t));
 
-                      if (len <= 0)
-                        {
-                          qline.l = qcol;
-                          scr_blank_line (qline, qcol, ncol - qcol, DEFAULT_RSTYLE);
-                          break;
-                        }
+                  lofs += len;
+                  qcol += len;
+                }
+            }
 
-                      assert (lofs < 1000);
+          qline->l = llen < ncol ? llen : MOD (llen - 1, ncol) + 1;
+          scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE);
+        }
 
-                      memcpy (qline.t + qcol, pline.t + pcol, len * sizeof (text_t));
-                      memcpy (qline.r + qcol, pline.r + pcol, len * sizeof (rend_t));
+      term_start = total_rows - nrow;
+      view_start = 0;
+      nsaved = term_start - q;
 
-                      lofs += len;
-                      qcol += len;
+      // make sure all terminal lines exist
+      while (nsaved < 0)
+        scr_blank_screen_mem (ROW (-++nsaved), DEFAULT_RSTYLE);
 
-                      if (qcol == ncol)
-                        break;
-                    }
-                }
-              else
-                lofs += ncol;
-            }
-        }
+      for (int i = -nsaved; i < nrow; i++)
+        assert (ROW (i).t);//D
 
       free (old_buf);
       delete old_ta;
@@ -388,6 +389,8 @@ rxvt_term::scr_release ()
   free (drawn_buf);
   free (temp_buf);
   free (tabs);
+
+  row_buf = 0; // signal that we freed all the arrays
 }
 
 /* ------------------------------------------------------------------------- */
@@ -453,9 +456,6 @@ rxvt_term::scr_cursor (int mode)
 #ifdef DEBUG_STRICT
   assert (s->cur.row >= 0);
   assert (s->cur.col >= 0);
-#else                           /* drive with your eyes closed */
-  max_it (s->cur.row, 0);
-  max_it (s->cur.col, 0);
 #endif
 }
 
@@ -679,9 +679,6 @@ rxvt_term::scr_add_lines (const unicode_t *str, int nlines, int len)
   assert (screen.cur.col < last_col);
   assert (screen.cur.row < nrow
           && screen.cur.row >= -nsaved);
-#else                           /* drive with your eyes closed */
-  min_it (screen.cur.col, last_col - 1);
-  clamp_it (screen.cur.row, -nsaved, nrow - 1);
 #endif
   row = screen.cur.row;
 
@@ -902,8 +899,6 @@ rxvt_term::scr_add_lines (const unicode_t *str, int nlines, int len)
 
 #ifdef DEBUG_STRICT
   assert (screen.cur.row >= 0);
-#else                           /* drive with your eyes closed */
-  max_it (screen.cur.row, 0);
 #endif
 }
 
@@ -1693,14 +1688,6 @@ rxvt_term::scr_expose (int x, int y, int ewidth, int eheight, bool refresh)
     }
 #endif
 
-#ifdef DEBUG_STRICT
-#if 0
-  // that's not debugging //TODO //FIXME
-  clamp_it (x, 0, width);
-  clamp_it (y, 0, height);
-#endif
-#endif
-
   /* round down */
   rc[PART_BEG].col = Pixel2Col (x);
   rc[PART_BEG].row = Pixel2Row (y);