aboutsummaryrefslogtreecommitdiffstats
path: root/x.c
diff options
context:
space:
mode:
authorNikita Langer <nikitalanger@icloud.com>2026-05-27 21:52:45 +0200
committerNikita Langer <nikitalanger@icloud.com>2026-05-27 21:52:45 +0200
commit5187e696fdafee436aced2a54524445a58ff6ada (patch)
tree19af765e4052f682f705b5fe833406f2096982e9 /x.c
parent3ad44279c69b20201cee32b742cc78094bd87c6b (diff)
downloadst-5187e696fdafee436aced2a54524445a58ff6ada.tar.gz
st-5187e696fdafee436aced2a54524445a58ff6ada.tar.bz2
st-5187e696fdafee436aced2a54524445a58ff6ada.tar.xz
st-5187e696fdafee436aced2a54524445a58ff6ada.zip
links
Diffstat (limited to 'x.c')
-rw-r--r--x.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/x.c b/x.c
index 3541d20..181f8c9 100644
--- a/x.c
+++ b/x.c
@@ -211,6 +211,7 @@ static void usage(void);
static void (*handler[LASTEvent])(XEvent *) = {
[KeyPress] = kpress,
+ [KeyRelease] = kpress,
[ClientMessage] = cmessage,
[ConfigureNotify] = resize,
[VisibilityNotify] = visibility,
@@ -476,6 +477,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 &&
@@ -1771,7 +1781,7 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
XftDrawGlyphFontSpec(xw.draw, fg, specs, len);
/* 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);
}
@@ -2179,6 +2189,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)) {