GTK source view: How to add/delete a child anchor without affecting the undo stack
- From: flix <pupobrasil tiscali it>
- To: gnome-devtools gnome org
- Subject: GTK source view: How to add/delete a child anchor without affecting the undo stack
- Date: Mon, 11 Aug 2014 13:37:10 +0200
I'm trying to implement a basic form of text folding (I'm using
GtkSourceViewmm).
My code is becoming long and complicated, but basically I'm following
these steps:
When I detect that a code block must be collapsed:
-> I tag it so that it's invisible (brackets included).
-> I add a ChildAnchor at the beginning with a label widget with
text: "{...}"
-> I surround the childAnchor insertion point with a read-only tag,
so that I can only erase it through code.
When I detect that the block must be expanded:
-> I remove the invisibility tag
-> I remove the read-only tag around the childAnchor
-> I erase the childAnchor. (*)
The problem arises at point (*): in order to delete the child anchor,
the only way I've found is to write (GtkSourceViewmm code):
buffer->erase(childAnchorIter,childAnchorIterPlusOneCursorPosition);
Well: it works! But: If I press CTRL+Z after that I see an odd character
that appears on the screen (a small box with "OBJ" written inside it).
Here's my question:
Is there an alternative way to erase a child anchor without affecting
the undo stack ?
I've tried using the
buffer->begin_not_undoable_action()/buffer->end_not_undoable_action(),
but these calls seem to just reset the undo stack completely (I can't
undo past the call).
Alternatively is there some undo option that excludes "object
characters" from the undo stack (like buffer->get_text() do, opposite to
buffer->get_slice()) ?
P.S. Maybe adding the child anchor affects the undo stack as well as
removing it... I don't know, I have to check: it's done with a dedicated
method...
P.S.2. To overcome this problem, I'm thinking of using a custom
Gsv::UndoManager for the buffer... but for some odd reason I'm not able
to create a Glib::RefPtr from it to feed buffer->set_undo_manager(...):
when I derive from Gsv::UndoManager, and I add a static method to return
a Glib::RefPtr<MyUndoManager> from it, I get an error at runtime
[g_object_ref: assertion 'G_IS_OBJECT (object)' failed].
That's probably because Gsv::UndoManager derives from: Glib::ObjectBase
-> Glib::ObjectBase -> sigc::trackable -> trackable, but not from
Glib::Object.
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]