billiob pushed a commit to branch master.

http://git.enlightenment.org/apps/terminology.git/commit/?id=df2b87308b1187a9840b9bd8d56d4c54b35dc63a

commit df2b87308b1187a9840b9bd8d56d4c54b35dc63a
Author: Boris Faure <bill...@gmail.com>
Date:   Mon Nov 18 21:41:30 2013 +0100

    add termpty_screen_swap() to simplify code
---
 src/bin/termpty.c    | 34 ++++++++++++++++++++++++++--------
 src/bin/termpty.h    |  2 +-
 src/bin/termptyesc.c | 14 ++------------
 3 files changed, 29 insertions(+), 21 deletions(-)

diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index a8586f3..03a6413 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -1484,18 +1484,36 @@ termpty_cell_copy(Termpty *ty, Termcell *src, Termcell 
*dst, int n)
      }
 }
 
+static void
+_swap_line(Termpty *ty, Termcell *cells, Termcell *cells2)
+{
+   int x;
+   Termcell c;
+
+   for (x = 0; x < ty->w; x++)
+     {
+        c = cells[x];
+        cells[x] = cells2[x];
+        cells2[x] = c;
+     }
+}
+
 void
-termpty_cell_swap(Termpty *ty EINA_UNUSED, Termcell *src, Termcell *dst, int n)
+termpty_screen_swap(Termpty *ty)
 {
-   int i;
-   Termcell t;
-   
-   for (i = 0; i < n; i++)
+   int y;
+
+   for (y = 0; y < ty->h; y++)
      {
-        t = dst[i];
-        dst[i] = src[i];
-        src[i] = t;
+        _swap_line(ty,
+                   &(TERMPTY_SCREEN(ty, 0, y)),
+                   &ty->screen2[y * ty->w]);
      }
+   ty->circular_offset = 0;
+   ty->altbuf = !ty->altbuf;
+
+   if (ty->cb.cancel_sel.func)
+     ty->cb.cancel_sel.func(ty->cb.cancel_sel.data);
 }
 
 void
diff --git a/src/bin/termpty.h b/src/bin/termpty.h
index 6f3b1d2..208c8fb 100644
--- a/src/bin/termpty.h
+++ b/src/bin/termpty.h
@@ -225,9 +225,9 @@ void       termpty_block_chid_update(Termpty *ty, Termblock 
*blk);
 Termblock *termpty_block_chid_get(Termpty *ty, const char *chid);
 
 void       termpty_cell_copy(Termpty *ty, Termcell *src, Termcell *dst, int n);
-void       termpty_cell_swap(Termpty *ty, Termcell *src, Termcell *dst, int n);
 void       termpty_cell_fill(Termpty *ty, Termcell *src, Termcell *dst, int n);
 void       termpty_cell_codepoint_att_fill(Termpty *ty, int codepoint, Termatt 
att, Termcell *dst, int n);
+void       termpty_screen_swap(Termpty *ty);
 
 ssize_t termpty_line_length(const Termcell *cells, ssize_t nb_cells);
 
diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index bd7daee..ff66d2c 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -626,8 +626,6 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, 
Eina_Unicode *ce)
                        arg = _csi_arg_get(&b);
                        if (b)
                          {
-                            int size;
-
                             // complete-ish list here:
                             // 
http://ttssh2.sourceforge.jp/manual/en/about/ctrlseq.html
                             switch (arg)
@@ -830,7 +828,7 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, 
Eina_Unicode *ce)
                                    {
                                       // if we are looking at alt buf now,
                                       // clear main buf before we swap it back
-                                      // into the sreen2 save (so save is
+                                      // into the screen2 save (so save is
                                       // clear)
                                       _termpty_clear_all(ty);
 //                                      _termpty_cursor_copy(&(ty->swap), 
&(ty->state));
@@ -841,16 +839,8 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, 
Eina_Unicode *ce)
 //                                      _termpty_cursor_copy(&(ty->state), 
&(ty->swap));
                                       ty->swap = ty->state;
                                    }
-                                 size = ty->w * ty->h;
                                  // swap screen content now
-                                 for (i = 0; i < size; i++)
-                                   termpty_cell_swap(ty, 
-                                                     &(ty->screen[(i + 
ty->circular_offset * ty->w) % size]),
-                                                     &(ty->screen2[i]),
-                                                     1);
-                                 ty->altbuf = !ty->altbuf;
-                                 if (ty->cb.cancel_sel.func)
-                                   
ty->cb.cancel_sel.func(ty->cb.cancel_sel.data);
+                                 termpty_screen_swap(ty);
                                  break;
                                case 1048:
                                  if (mode)

-- 


Reply via email to