Splitview with GtkTextView

Right now the cursor and the selection are managed by the Buffer with the insert and selection-bound marks. This is problematic if you want 2 Views with the same buffer and managin the cursor and the selections differently. This page is about to provide ideas to implement this in a different way, so the cursor and the selection is managed per View instead of per Buffer.

Why do we need this?

As it is GtkTextView/Buffer in gedit we have to create 2 buffers and keep them sync, also we have to sync all properties of the buffer. This produces problems when we manage the undo stack from SourceView and of course as we keep a copy of the buffer we are using the double of the memory.

Idea1

Add in the view:

Property: independent-cursor : If True manage the cursor and the selection per view instead of per buffer. Also we would refactor all gtk_text_buffer_get_insert and gtk_text_buffer_get_selection_bound functions to gtk_text_view... equivalents.

GtkTextMark * gtk_text_view_get_insert (GtkTextView *text_view) {

  • if (independent-cursor)
    • set_mark (insert, priv->insert) return priv->insert

    else
    • return buffer_get_insert

}

In this way we could have backward compatibility.


See also :

Projects/GTK+/GtkTextView/Splitview (last edited 2014-04-07 19:58:19 by SébastienWilmet)