Commit graph

3673 commits

Author SHA1 Message Date
Craig Barnes
7656744877 debug: make use of log_msg() in fatal_error() and bug() functions
Instead of writing directly to stderr and/or syslog(3).
2021-02-09 12:32:33 +00:00
Craig Barnes
e19db15104 render: use portable HAS_INCLUDE() wrapper instead of __has_include() 2021-02-09 03:14:08 +00:00
Daniel Eklöf
79e054faff
Merge branch 'refactor-key-bindings' 2021-02-08 18:57:17 +01:00
Daniel Eklöf
fb5f74062c
Merge branch 'url-parser-recognize-percent'
Closes #338
2021-02-08 18:56:38 +01:00
Daniel Eklöf
1710c1452a
url-mode: ‘%’ is a valid URI character (but don’t allow it at the end)
Closes #338
2021-02-08 16:02:07 +01:00
Daniel Eklöf
5c3d52e4c7
Merge branch 'kitty-theme' 2021-02-08 13:19:23 +01:00
Stefan Tatschner
a3270d226a Add kitty theme 2021-02-08 13:17:16 +01:00
Daniel Eklöf
274e5ce5af
Merge branch 'prefer-tll_remove-over-tll_free' 2021-02-08 12:24:09 +01:00
Daniel Eklöf
4bad85b593
misc: when free:ing tll lists, prefer tll_remove() over tll_free()
In many places we have the following pattern:

  tll_foreach(list, it)
     free(it->item.thing);
  tll_free(list);

Since all tll functions are macros, and thus inlined, and since
tll_free in itself expands to a tll_foreach(), the above pattern
expands to more native code than necessary.

This is somewhat smaller:

  tll_foreach(list, it) {
      free(it->item.thing);
      tll_remove(list, it);
  }
2021-02-08 10:09:59 +01:00
Daniel Eklöf
03bac9dada
key-bindings: refactor: use a single type for all key bindings
Up until now, the various key binding modes (“normal”, “search” and
“url”) have used their own struct definitions for their key bindings.

The only reason for this was to have a properly typed “action” (using
the appropriate “action” enum).

This caused lots of duplicated code. This patch refactors this to use
a single struct definition for the “unparsed” key bindings handled by
the configuration, and another single definition for “parsed” bindings
used while handling input.

This allows us to implement configuration parsing, keymap translation
and so on using one set of functions, regardless of key binding mode.
2021-02-08 10:09:14 +01:00
Daniel Eklöf
63a50afc8e
Merge branch 'url-detection' 2021-02-08 10:06:13 +01:00
Daniel Eklöf
24263412dc
url-mode: urls_render(): early exit when URL list is empty 2021-02-07 16:33:35 +01:00
Daniel Eklöf
9ee392dc8c
url-mode: generate-key-combos: minor efficiency tweaks
* Use a do..while loop; this lets us drop the second half of the loop
  condition.

* Call wcslen(prefix) once, *before* iterating the alphabet
  characters.

* Step through the alphabet characters using a  pointer, as this
  avoids an indexed load (with possibly an imul instruction in
  e.g. -Os builds).
2021-02-07 16:33:35 +01:00
Daniel Eklöf
c84e379767
url-mode: be consistent; use xmalloc() + xrealloc() 2021-02-07 16:33:35 +01:00
Daniel Eklöf
9066ba87df
url-mode: early exit when assigning key combos to empty list 2021-02-07 16:33:35 +01:00
Daniel Eklöf
fec19f1503
changelog: URL mode 2021-02-07 16:33:35 +01:00
Daniel Eklöf
0c847cfe7b
doc: foot.1: document the new URL mode 2021-02-07 16:33:35 +01:00
Daniel Eklöf
4b67394a5f
readme: document the new URL mode 2021-02-07 16:33:35 +01:00
Daniel Eklöf
5af481cd89
render: urls: blank out keys already pressed 2021-02-07 16:33:35 +01:00
Daniel Eklöf
85f7503aec
render: urls: fix string formatter in swprintf() 2021-02-07 16:33:35 +01:00
Daniel Eklöf
b3043e92f6
render: urls: don’t use/allocate maximum allowed characters unless needed 2021-02-07 16:33:35 +01:00
Daniel Eklöf
0f57e6c422
render: render_osd(): remove ‘alpha’ parameter - it’s always 0xffff 2021-02-07 16:33:35 +01:00
Daniel Eklöf
1aec534b37
url-mode: input: backspace reverts the last key 2021-02-07 16:33:35 +01:00
Daniel Eklöf
ddd6f1d944
url-mode: fix key sequence generation
* We were using the ‘back’ element of the list as prefix for the next
  iteration of sequences, instead of the element at index ‘offset’

* ALEN() on a wchar_t[] includes the NULL terminator. We don’t want
  that.
2021-02-07 16:33:34 +01:00
Daniel Eklöf
672c414b91
render: urls: reduce vertical margin 2021-02-07 16:33:34 +01:00
Daniel Eklöf
19e23254fb
render: urls: uppercase the activation key sequence 2021-02-07 16:33:34 +01:00
Daniel Eklöf
29c86612df
url-mode: generate key combinations using vimium’s algorithm 2021-02-07 16:33:34 +01:00
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