Within the function I create a start_mark and end_mark to revalidate the
text iterator throughout the function and before control is returned to the
caller. The start_mark is created with LEFT-gravity so when the comment syntax
is inserted at the beginning of the selection, the mark remains to the left of
the inserted text expanding the selection bounds to contain the newly inserted
opening comment string, e.g.
/* preserve marks for start/end to revalidate iterators before return
* using left gravity on start to mark stays left of inserted text.
start_mark = gtk_text_buffer_create_mark (buffer, NULL, start, TRUE);
end_mark = gtk_text_buffer_create_mark (buffer, NULL, end, FALSE);
Prior to the end of the function, the start/end iterators are revalidated
and the selection is remade between the start/end iterators to insure when the
function returns the selection encompasses the block comment syntax as well as
the commented text so if the user chooses, has a change of mind, whatever,
they can 'uncomment' without having to touch the keyboard or mouse to adjust
the selection, e.g.
/* extend selection to cover new comment syntax (for uncomment) */
gtk_text_buffer_select_range (buffer, end, start);
This works perfectly when compiled and run under Linux, but fails to include
the opening syntax for the block comment when compiled/run under windoze.
Instead the `start` iter behaves as if it has RIGHT-gravity and is outside of
the selection when the function ends.
I have even manually set the iter to the beginning of the line with:
gtk_text_iter_set_line_offset (start, 0);
But still the selection is not adjusted in windows as all.
Is this a problem with gtk select_range under windows, or just the result of
windows selection being something gtk cannot interface with given the
different windows API?
Re: Does 'left-gravity' for text_mark work in windows to preserve selection bounds? (gtk2)
On 07/17/2018 11:12 PM, David C. Rankin wrote:
> Is this a problem with gtk select_range under windows, or just the result of
> windows selection being something gtk cannot interface with given the
> different windows API?
Disregard. It does work and will affect the selection bounds in windoze.
After another complete rebuild, the selection is extended to include the
opening comment tag. My only guess on the earlier failure is an earlier
version of the editor was running and after the prior rebuild invoking the
editor name at the command line apparently started a second instance of the
running/cached version instead of re-reading the new executable.