GNOME Bugzilla – Bug 344874
Keep cursor visible when size changes
Last modified: 2006-06-27 07:30:54 UTC
Attached small patch from maemo-gtk keeps the cursor visible upon size_allocate(). It IMHO feels very natural: with the patch, try tests/testtext and see yourself.
Created attachment 67341 [details] [review] Patch implementing the above
Looks reasonable to me
Fixed in CVS: 2006-06-22 Michael Natterer <mitch@imendio.com> * gtk/gtktextview.c (gtk_text_view_size_allocate): keep the cursor visible when the size changes. Fixes bug #344874.
Please revert it, it's a break, not a fix. Just insert two screens of text, put cursor in the beginning, scroll to bottom, and resize the window to see what I mean. It's probably good to scroll to cursor in case when cursor is initially visible and *user* resizes the window so that cursor becomes invisible, but it's not as simple as "just scroll". Note that scrolling, and then resizing is a very common use case: you get some text, you scroll to find something, you fail to find it immediately and you maximize it (well, maybe *very* is not a really good word here, but it's really very common if you compare it to cases when you resize and cursor disappears and you need to scroll back). Also, if you have cursor in the most right position, and make window narrower, and get ugly jumping. Also, if you called gtk_text_view_scroll_to_mark before that (e.g. when widget is not realized yet), your scroll goes to trash.
One more case: you certainly don't want to scroll to cursor if it's not visible.
Very well :) comitting seemed to be the only way to get opinions. I guess you are right and we should revert it. Opinions?
since muntyan asked my opinion on irc, for what is worth I agree that it should be reverted.
Mitch, seems best to revert it then; maybe we need to make this optional (and change the code to only keep the cursor visible when it was before), or maybe it is just not worth it....
Reverted. I don't think we need to make this configurable since it's easy enough to connect_after() to size_allocate and do it manually if it's absolutely needed. 2006-06-26 Michael Natterer <mitch@imendio.com> * gtk/gtktextview.c (gtk_text_view_size_allocate): revert "keep cursor visible when size changes" since it breaks things (#344874).
Maybe we can find a place in the docs for this as a useful trick. Don't know if it qualifies as a "frequently answered question"...