Eric, thanks for the ideas!

I tried a bunch of things to distinguish the callbacks, but it got too
complicated.  Checking for a different line number is a clever idea, but
PgUp and PgDown also move the cursor which changes the line number.
 Similar problems for tracking the char offset in the line (for simply
typing at the end of the last visible line, not creating a new line/para).

So, it would be nice if there was a simple signal for this case, where the
window scrolls because of keyboard input in the last visible line.

The reason I want this is, is so my app can scroll the window
automatically, so that the cursor insert point becomes centered
vertically.  In other words, when I'm typing a long paragraph, and it's the
last visible line, I want it to scroll up, so I'm now typing in the middle
of the window (vs. continuing to type on the last visible line).

I suppose this is a bit esoteric.

I did create a kbd shortcut to do that scroll manually:

gtk_text_view_scroll_to_iter(..., 0.0, TRUE, 1.0, 0.5)

so I have that to use.


On Tue, Sep 25, 2018 at 2:34 PM <cecas...@aol.com> wrote:

>
> Not sure how to go about this myself. I see the extra callbacks and it
> would be a good thing to limit them. For filtering maybe check if the
> cursor has changed lines along with the adjustment value change. Suspect
> there is a better solution for this.
>
> static void value_changed(GtkAdjustment *v_adjust, gpointer textview)
>   {
>     static gint s_line=0;
>     GtkTextIter iter;
>     GtkTextBuffer
> *buffer=gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
>     GtkTextMark *mark=gtk_text_buffer_get_mark(buffer, "insert");
>     gtk_text_buffer_get_iter_at_mark(buffer, &iter, mark);
>     gint line=gtk_text_iter_get_line(&iter);
>     if(s_line!=line)
>       {
>         g_print("Scroll Line\n");
>         s_line=line;
>       }
>   }
>
> Eric
>
>
> -----Original Message-----
> From: Doug McCasland <do...@bravoecho.net>
> To: cecashon <cecas...@aol.com>
> Sent: Tue, Sep 25, 2018 2:10 pm
> Subject: Re: is there a signal for typing at bottom of window?
>
> Actually I get 11 signals with a different setting of:
> gtk_text_view_set_pixels_inside_wrap()
>
> So it's one signal per vertical pixel perhaps?   I can code for that.
>
> But I also I get those signals during any scrolling (scrollbar or
> mousewheel).  How can I distinguish between automatic scrolling at bottom
> and user-commanded scrolling?
>
> thanks
>
>
>
>
>
> On Tue, Sep 25, 2018 at 1:47 PM Doug McCasland <do...@bravoecho.net>
> wrote:
>
> Woo-hoo, that works!
>
> BUT, I get 12 signals for each line that is auto-scrolled.  I can code for
> this, but why 12?  Will it always be 12?
>
>
> On Tue, Sep 25, 2018 at 11:46 AM <cecas...@aol.com> wrote:
>
>
> Hi Doug,
>
> Try getting the vertical adjustment of the scrolled window and connect to
> "value-changed". See if that will work. Something like
>
> ...
> static void value_changed(GtkAdjustment *v_adjust, gpointer user_data)
>   {
>   }
> ...
> GtkWidget *scroll=gtk_scrolled_window_new(NULL, NULL);
> GtkAdjustment
> *v_adjust=gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(scroll));
> g_signal_connect(v_adjust, "value-changed", G_CALLBACK(value_changed),
> NULL);
> ...
>
> Eric
>
>
>
>
>
> --
> Doug McCasland   <do...@bravoecho.net>
>
>
>
> --
> Doug McCasland   <do...@bravoecho.net>
>


-- 
Doug McCasland   <do...@bravoecho.net>
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to