tsm: screen: introduce scrollback-buffer line IDs
authorDavid Herrmann <dh.herrmann@googlemail.com>
Fri, 5 Oct 2012 11:24:58 +0000 (13:24 +0200)
committerDavid Herrmann <dh.herrmann@googlemail.com>
Fri, 5 Oct 2012 11:24:58 +0000 (13:24 +0200)
If we have pointers somewhere into the scrollback-buffer, there is not
easy way to see which of two lines comes first. Therefore, we introduce
scrollback buffer IDs. These are unique and every line gets one assigned
when it is linked into the sb-buffer. These IDs guarantee that front lines
have lower IDs than bottom lines.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
src/tsm_screen.c

index cce6e57..fa91932 100644 (file)
@@ -54,6 +54,7 @@ struct line {
 
        unsigned int size;
        struct cell *cells;
+       uint64_t sb_id;
 };
 
 struct tsm_screen {
@@ -80,6 +81,7 @@ struct tsm_screen {
        struct line *sb_last;           /* last line; was moved last*/
        unsigned int sb_max;            /* max-limit of lines in sb */
        struct line *sb_pos;            /* current position in sb or NULL */
+       uint64_t sb_last_id;            /* last id given to sb-line */
 
        /* cursor */
        unsigned int cursor_x;
@@ -197,6 +199,7 @@ static void link_to_scrollback(struct tsm_screen *con, struct line *line)
                line_free(tmp);
        }
 
+       line->sb_id = ++con->sb_last_id;
        line->next = NULL;
        line->prev = con->sb_last;
        if (con->sb_last)