diff options
| author | Nikita Langer <nikitalanger@icloud.com> | 2026-05-31 09:57:10 +0200 |
|---|---|---|
| committer | Nikita Langer <nikitalanger@icloud.com> | 2026-05-31 09:57:10 +0200 |
| commit | 22c5f5f866d967d3d41f651c14f3a2fd11da0038 (patch) | |
| tree | f205fe53d20330a34fe3ea29d45c16a18d22a52b /x.c | |
| parent | c46a160aa0618182c92f8a135fd8a35e53cdb4bf (diff) | |
| download | st-22c5f5f866d967d3d41f651c14f3a2fd11da0038.tar.gz st-22c5f5f866d967d3d41f651c14f3a2fd11da0038.tar.bz2 st-22c5f5f866d967d3d41f651c14f3a2fd11da0038.tar.xz st-22c5f5f866d967d3d41f651c14f3a2fd11da0038.zip | |
Cliuck url
Diffstat (limited to 'x.c')
| -rw-r--r-- | x.c | 24 |
1 files changed, 23 insertions, 1 deletions
@@ -209,6 +209,7 @@ static void usage(void); static void (*handler[LASTEvent])(XEvent *) = { [KeyPress] = kpress, + [KeyRelease] = kpress, [ClientMessage] = cmessage, [ConfigureNotify] = resize, [VisibilityNotify] = visibility, @@ -473,6 +474,15 @@ mouseaction(XEvent *e, uint release) /* ignore Button<N>mask for Button<N> - it's set on release */ uint state = e->xbutton.state & ~buttonmask(e->xbutton.button); + if (release == 0 && + e->xbutton.button == Button1 && + (match(ControlMask, state) || + match(ControlMask, state & ~forcemousemod))) { + followurl(evrow(e), evcol(e)); + return 1; + } + + for (ms = mshortcuts; ms < mshortcuts + LEN(mshortcuts); ms++) { if (ms->release == release && ms->button == e->xbutton.button && @@ -1715,7 +1725,7 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i } /* Render underline and strikethrough. */ - if (base.mode & ATTR_UNDERLINE) { + if (base.mode & ATTR_UNDERLINE || base.mode & ATTR_URL) { XftDrawRect(xw.draw, fg, winx, winy + dc.font.ascent * chscale + 1, width, 1); } @@ -2123,6 +2133,18 @@ kpress(XEvent *ev) } else { len = XLookupString(e, buf, sizeof buf, &ksym, NULL); } + + /* 0. highlight URLs when control held */ + if (ksym == XK_Control_L) { + highlighturls(); + } else if (ev->type == KeyRelease && e->keycode == XKeysymToKeycode(e->display, XK_Control_L)) { + unhighlighturls(); + } + + /* KeyRelease not relevant to shortcuts */ + if (ev->type == KeyRelease) + return; + /* 1. shortcuts */ for (bp = shortcuts; bp < shortcuts + LEN(shortcuts); bp++) { if (ksym == bp->keysym && match(bp->mod, e->state)) { |
