diff options
author | Jason White <jason@jasonjgw.net> | 2013-01-02 12:34:53 +1100 |
---|---|---|
committer | Mike Gorse <mgorse@suse.com> | 2015-01-21 10:06:51 -0600 |
commit | 3e3e3fdec8302a04c400bc7fbfa1118dbf9cbccd (patch) | |
tree | c2d509003aaf9b82d98656d5235d51a9319ead3c | |
parent | c91ad56404898a4f2e7ef668edd52497f19cf5de (diff) | |
download | vte-3e3e3fdec8302a04c400bc7fbfa1118dbf9cbccd.tar.gz |
Set the caret properly when the cursor is at the top left of the terminal.
https://bugzilla.gnome.org/show_bug.cgi?id=166637
-rw-r--r-- | src/vteaccess.c | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/src/vteaccess.c b/src/vteaccess.c index 9cb1ed48..61d98adf 100644 --- a/src/vteaccess.c +++ b/src/vteaccess.c @@ -340,29 +340,43 @@ vte_terminal_accessible_update_private_data_if_needed(VteTerminalAccessible *acc _vte_debug_print(VTE_DEBUG_ALLY, "Cursor at (%ld, " "%ld).\n", ccol, crow); - /* Get the offsets to the beginnings of each line. */ caret = -1; - for (i = 0; i < priv->snapshot_characters->len; i++) { - /* Get the attributes for the current cell. */ - offset = g_array_index(priv->snapshot_characters, - int, i); - attrs = g_array_index(priv->snapshot_attributes, - struct _VteCharAttributes, - offset); - /* If this cell is "before" the cursor, move the - * caret to be "here". */ - if ((attrs.row < crow) || - ((attrs.row == crow) && (attrs.column < ccol))) { - caret = i + 1; - } + if (priv->snapshot_characters->len) { + /* If the cursor is at the top left of the screen, move the + * caret there. */ + /* Get the attributes of the first character in the buffer. */ + attrs = g_array_index(priv->snapshot_attributes, + struct _VteCharAttributes, + 0); + if ((crow == attrs.row) && + (ccol == 0)) { + caret = 0; + } } - /* If no cells are before the caret, then the caret must be - * at the end of the buffer. */ if (caret == -1) { - caret = priv->snapshot_characters->len; + /* Get the offsets to the beginnings of each line. */ + for (i = 0; i < priv->snapshot_characters->len; i++) { + /* Get the attributes for the current cell. */ + offset = g_array_index(priv->snapshot_characters, + int, i); + attrs = g_array_index(priv->snapshot_attributes, + struct _VteCharAttributes, + offset); + /* If this cell is "before" the cursor, move the + * caret to be "here". */ + if ((attrs.row < crow) || + ((attrs.row == crow) && (attrs.column < ccol))) { + caret = i + 1; + } + } + + /* If no cells are before the caret, then the caret must be + * at the end of the buffer. */ + if (caret == -1) { + caret = priv->snapshot_characters->len; + } } - /* Notify observers if the caret moved. */ if (caret != priv->snapshot_caret) { priv->snapshot_caret = caret; |