surf

surf
git clone git@git.zachrice.app:repos/surf.git
Log | Files | Refs | README | LICENSE

surf-scrolltobounds.patch (1622B)


      1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
      2 From: Zach Rice <bynxmusic@gmail.com>
      3 Date: Sun, 18 May 2026 00:00:00 +0000
      4 Subject: [PATCH] Add scroll-to-top and scroll-to-bottom (gg/G)
      5 
      6 Adds scrolltop() and scrollbottom() functions using evalscript()
      7 to run window.scrollTo() directly. Bound to MODKEY+comma and
      8 MODKEY+period by default.
      9 
     10 diff --git a/config.def.h b/config.def.h
     11 --- a/config.def.h
     12 +++ b/config.def.h
     13 @@ -183,6 +183,9 @@ static Key keys[] = {
     14  	{ MODKEY,                GDK_KEY_i,      scrollh,    { .i = +10 } },
     15  	{ MODKEY,                GDK_KEY_u,      scrollh,    { .i = -10 } },
     16 
     17 +	/* scroll to top/bottom of page (vim gg / G) */
     18 +	{ MODKEY,                GDK_KEY_comma,   scrolltop,    { 0 } },
     19 +	{ MODKEY,                GDK_KEY_period,  scrollbottom, { 0 } },
     20 
     21  	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_j,      zoom,       { .i = -1 } },
     22 diff --git a/surf.c b/surf.c
     23 --- a/surf.c
     24 +++ b/surf.c
     25 @@ -236,6 +236,8 @@ static void zoom(Client *c, const Arg *a);
     26  static void scrollv(Client *c, const Arg *a);
     27  static void scrollh(Client *c, const Arg *a);
     28 +static void scrolltop(Client *c, const Arg *a);
     29 +static void scrollbottom(Client *c, const Arg *a);
     30  static void navigate(Client *c, const Arg *a);
     31  static void stop(Client *c, const Arg *a);
     32 @@ -1953,6 +1955,16 @@ scrollh(Client *c, const Arg *a)
     33  	msgext(c, 'h', a);
     34  }
     35 
     36 +void
     37 +scrolltop(Client *c, const Arg *a)
     38 +{
     39 +	evalscript(c, "window.scrollTo(0,0);");
     40 +}
     41 +
     42 +void
     43 +scrollbottom(Client *c, const Arg *a)
     44 +{
     45 +	evalscript(c, "window.scrollTo(0,document.body.scrollHeight);");
     46 +}
     47 +
     48  void
     49  navigate(Client *c, const Arg *a)