Commit graph

3646 commits

Author SHA1 Message Date
Daniel Eklöf
e9ff8bac1c
url-mode: refresh rendered URLs after accepting a key 2021-02-07 16:33:34 +01:00
Daniel Eklöf
01c0535b5a
render: urls: add TODO: highlight already entered keys 2021-02-07 16:33:34 +01:00
Daniel Eklöf
5df2e990e3
render: urls: don’t display URLs whose key sequence doesn’t match 2021-02-07 16:33:34 +01:00
Daniel Eklöf
ab1224ba91
url-mode: urls_assign_key_combos(): remove URLs when all key combos have been used up 2021-02-07 16:33:34 +01:00
Daniel Eklöf
e6612927be
url-mode: add ftp://, ftps://, file://, gemini:// and gopher:// 2021-02-07 16:33:34 +01:00
Daniel Eklöf
a988138492
url-mode: urls_collect(): URL list pointer as an argument 2021-02-07 16:33:34 +01:00
Daniel Eklöf
2c10a147ea
url-mode: underline URLs using the color from colors.urls
This is implemented by allocating one of the (few!) remaining bits in
the cells’ attribute struct to indicate the cell should be “URL
highlighted”.

render_cell() looks at this bit and draws an underline using the color
from colors.urls (defaults to regular3 - i.e. yellow).

A new function, url_tag_cells(), iterates the currently detected URLs
and sets the new ‘url’ attribute flag on the affected cells.

Note: this is done in a separate function to keep urls_collect() free
from as many dependencies as possible.

urls_reset() is updated to *clear* the ‘url’ flag (and thus implicitly
also results in a grid refresh, _if_ there were any URLs).

We now exit URL mode on *any* client application input. This needs to
be so since we can’t know if the URLs we previously detected are still
valid.
2021-02-07 16:33:34 +01:00
Daniel Eklöf
6726494f4c
url-mode: store absolute row numbers in start/end coordinates
This allows us to update the jump label positions when the viewport
changes.

This in turn allows us to stay in URL mode while the user is using the
mouse to scroll in the scrollback history.

Scrolling with the keyboard is currently not possible, since input
handling in URL mode does not recognize “regular” key bindings. We
_could_ add scrollback up/down bindings to URL mode too, but lets not,
for the time being.

(Note: an alternative to this patch is to disallow mouse scrolling
too. Then we could have kept the URL start/end as viewport local
coordinates).
2021-02-07 16:33:34 +01:00
Daniel Eklöf
a578faf494
url-mode: make the end coordinate *inclusive* 2021-02-07 16:33:33 +01:00
Daniel Eklöf
d6ea2a4bdc
input: mouse events on jump label surfaces do nothing 2021-02-07 16:33:33 +01:00
Daniel Eklöf
69706546c8
term: surface-kind: add TERM_SURF_JUMP_LABEL 2021-02-07 16:33:33 +01:00
Daniel Eklöf
69847a19d6
readme: add URL mode to the feature list 2021-02-07 16:33:33 +01:00
Daniel Eklöf
d63bc1a880
readme: add ctrl+shift+u, with description, to the list of default key bindings 2021-02-07 16:33:33 +01:00
Daniel Eklöf
ee1d179b8f
config: use a bitfield for flags tracking whether to use custom colors for CSD or not 2021-02-07 16:33:33 +01:00
Daniel Eklöf
e9c3d03837
config: add colors.jump_labels and colors.urls
* colors.jump_labels configures the foreground and background colors
  used when rendering URL jump labels. Defaults to “regular0
  regular3” (i.e. black on yellow).

* colors.urls configures the color to use when highlighting URLs in
  URL mode. Note that we aren’t currently doing any
  highlighting... Defaults to regular3 (i.e. yellow).
2021-02-07 16:33:33 +01:00
Daniel Eklöf
fcbb5a0bf7
config: use a packed bitfield for “use custom color” flags 2021-02-07 16:33:33 +01:00
Daniel Eklöf
0d17fd6a5d
foot.ini: fix default values for csd.button-*-color 2021-02-07 16:33:33 +01:00
Daniel Eklöf
ef3ce530ba
url-mode: refactor: break out URL activation to a separate function 2021-02-07 16:33:33 +01:00
Daniel Eklöf
607ee63b77
url-mode: auto-detect: use wcsncasecmp() instead of towlower()
When matching the URI scheme, use wcsncasecmp() when comparing the
strings, instead of calling towlower() on each cell.
2021-02-07 16:33:33 +01:00
Daniel Eklöf
6b7003bcc3
url-mode: auto-detect: don’t store the lower-cased URL; use original casing 2021-02-07 16:33:33 +01:00
Daniel Eklöf
93181649b3
config: add show-urls-copy action
This works just like show-urls-launch, except that instead of opening
the URL (typically using xdg-open), it is placed in the clipboard when
activated.
2021-02-07 16:33:32 +01:00
Daniel Eklöf
b17a392b8c
config: show-urls-launch: change default key binding to ctrl+shift+u 2021-02-07 16:33:32 +01:00
Daniel Eklöf
0a1c5e44c4
config: rename ‘show-urls’ to ‘show-urls-launch’ 2021-02-07 16:33:32 +01:00
Daniel Eklöf
013b26d212
render: urls: tweak positioning
Don’t offset the labels too much vertically, _or_ horizontally.
2021-02-07 16:33:32 +01:00
Daniel Eklöf
d69497efe4
render: reduce URL jump label margins 2021-02-07 16:33:32 +01:00
Daniel Eklöf
82e2541760
config: add ctrl+d as (yet another) default binding url-bindings.cancel 2021-02-07 16:33:32 +01:00
Daniel Eklöf
65caa33084
url-mode: auto-detect: don’t line-wrap URL is row isn’t line-wrapped 2021-02-07 16:33:32 +01:00
Daniel Eklöf
eb0b244c89
render: url labels: don’t position outside window 2021-02-07 16:33:32 +01:00
Daniel Eklöf
f61f7c131f
url-mode: auto-detect: heuristics for parenthesis and brackets
While parenthesis and brackets _are_ valid URL characters, there are
many times when we do *not* want them to be part of the URL.

For example, in markdown we write “[text](url)”, or even
“[![alt-text](url-1)](url-2)”.

Here, the URLs are clearly *not* “url)” or “url-1)](url2)”.
2021-02-07 16:33:32 +01:00
Daniel Eklöf
9d8ec857ce
url-mode: use ‘url-launch’ from config to open URLs 2021-02-07 16:33:32 +01:00
Daniel Eklöf
06aba59430
notify: break out command template expansion to spawn_expand_template() 2021-02-07 16:33:32 +01:00
Daniel Eklöf
4233c806c3
config: add ‘url-launch’ option, defaulting to “xdg-open ${url}” 2021-02-07 16:33:31 +01:00
Daniel Eklöf
0cbdf657a7
term: destroy: set term->window = NULL after destroying it
This fixes a crash in urls_reset() on destroy, where we tried to
access an already free:d window pointer in order to destroy the jump
label surfaces.
2021-02-07 16:33:31 +01:00
Daniel Eklöf
44b7758416
render: urls: positioning: place a bit further away from the starting position 2021-02-07 16:33:31 +01:00
Daniel Eklöf
2315aba458
url-mode: urls_reset() do an early return if we don’t have any URLs 2021-02-07 16:33:31 +01:00
Daniel Eklöf
d75688b0bd
url-mode: fix ‘n’ parameter to wcstombs() 2021-02-07 16:33:31 +01:00
Daniel Eklöf
2cc84db979
urls: initial support for detecting URLs and rendering jump-labels
The jump labels work, but is currently hardcoded to use xdg-open
2021-02-07 16:33:31 +01:00
Daniel Eklöf
b255aea3ed
config: free URL bindings 2021-02-07 16:33:31 +01:00
Daniel Eklöf
ee39966ded
config: add infrastructure to handle URL mode specific key bindings
* Add “show-urls” action to regular key bindings
* Add url-bindings section to foot.ini
* Add “cancel” action to URL mode key bindings
2021-02-07 16:33:31 +01:00
Daniel Eklöf
8f4a8cd8ce
Merge branch 'xassert-performance-regression-2' 2021-02-07 16:32:03 +01:00
Daniel Eklöf
cb60ddd090
vt: remove xassert(), that cannot be optimized out, from action_print()
action_print() is in the hot path, and having if-statement here *does*
have an impact on performance.

Much more so when that if-statement involves a functional call to
wcwidth().

Closes #330
2021-02-07 11:14:07 +01:00
Daniel Eklöf
7cb49681e7
ime: enter(): remove assertion on surface kind being TERM_SURF_GRID
The main surface is the *only* IME capable surface we have. If the
compositor is sending an ime::enter event for another surface, it is a
compositor bug, not a foot bug.
2021-02-07 11:11:58 +01:00
Daniel Eklöf
0d012db3a8
main: include uname.sysname when logging host architecture 2021-02-07 10:24:48 +01:00
Daniel Eklöf
1d9cd8cc04
Merge branch 'mouse-events-never-sent-to-client' 2021-02-04 19:28:40 +01:00
Daniel Eklöf
5a2e44e24e
changelog: some mouse events never being sent to the client application 2021-02-02 09:53:24 +01:00
Daniel Eklöf
eff8481cdc
selection: remove selection_enabled()
Its name did not reflect its semantics. Since it was only used in a
single place, “inline” it there, and get rid of it.
2021-02-02 09:52:22 +01:00
Daniel Eklöf
d6b1dbf8d9
input: don’t execute mouse bindings when the application is grabbing the mouse
When the application is grabbing the mouse, we require ‘shift’ to be
pressed to be able to use foot’s mouse bindings. Otherwise the mouse
event is sent to the application.

This wasn’t being enforced consistently; each and every mouse **only**
action was checking the mouse grab state, but e.g. *primary
paste* (which can be used as both a key binding and a mouse binding)
was not.

The fix is actually quite simple: don’t even try to execute *any*
mouse bindings when the application is grabbing the mouse (unless
shift is pressed).

This fixes an issue where e.g. middle mouse button events (using the
default mouse bindings) were never seen by any mouse grabbing client
applications.
2021-02-02 09:52:05 +01:00
Daniel Eklöf
f8da14eed5
term: term_mouse_grabbed: return true if mouse tracking is disabled 2021-02-02 09:51:22 +01:00
Daniel Eklöf
e1eed7bafc
Merge branch 'reset-term-ime-on-text-input-leave' 2021-01-31 12:12:16 +01:00
Daniel Eklöf
48270187ca
notify: repair debug log: the parameter has been renamed: msg -> body 2021-01-31 10:26:36 +01:00