Re: [dev] [surf]keybind to scroll left/right

From: pancake <pancake_AT_youterm.com>
Date: Thu, 24 May 2012 16:07:34 +0200

what about adding this to the default surf?

On 05/24/12 08:38, stanio_AT_cs.tu-berlin.de wrote:
> * Thuban<thuban_AT_singularity.fr> [2012-05-24 07:53]:
>> I was wondering if there is any way to have a keybind to scroll left or
>> right, just like you can scroll up and down with C-k and C-j?
> sure. Here an example:
> ----- config.h -----
> { MODKEY, GDK_j, scroll_v, { .i = +1 } },
> { MODKEY, GDK_k, scroll_v, { .i = -1 } },
> { MODKEY, GDK_g, scroll_v, { .i = -20000 } },
> { MODKEY|GDK_SHIFT_MASK,GDK_g, scroll_v, { .i = +20000 } },
> { MODKEY, GDK_b, scroll_v, { .i = -10000 } },
> { MODKEY, GDK_space, scroll_v, { .i = +10000 } },
> { MODKEY, GDK_l, scroll_h, { .i = +1 } },
> { MODKEY, GDK_h, scroll_h, { .i = -1 } },
> ----- -------- -----
>
>
> ------ surf.c ------
> void
> scroll_h(Client *c, const Arg *arg) {
> scroll(gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(c->scroll)), arg);
> }
>
> void
> scroll_v(Client *c, const Arg *arg) {
> scroll(gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(c->scroll)), arg);
> }
>
> void
> scroll(GtkAdjustment *a, const Arg *arg) {
> gdouble v;
>
> v = gtk_adjustment_get_value(a);
> switch (arg->i){
> case +10000:
> case -10000:
> v += gtk_adjustment_get_page_increment(a) * (arg->i / 10000); break;
> case +20000:
> case -20000:
> default:
> v += gtk_adjustment_get_step_increment(a) * arg->i;
> }
> v = MAX(v, 0.0);
> v = MIN(v, gtk_adjustment_get_upper(a) - gtk_adjustment_get_page_size(a));
> gtk_adjustment_set_value(a, v);
> }
> ----- -------- -----
>
> --s_
>
Received on Thu May 24 2012 - 16:07:34 CEST

This archive was generated by hypermail 2.3.0 : Thu May 24 2012 - 16:12:05 CEST