Commit graph

3808 commits

Author SHA1 Message Date
Daniel Eklöf
42cf196420
doc: ctlseqs: we use ‘CSI’ not so much in the tables as in text 2021-02-23 09:31:44 +01:00
Daniel Eklöf
325bbf5e85
doc: ctlseqs: left most -> leftmost 2021-02-23 09:31:44 +01:00
Daniel Eklöf
59bee8016f
doc: ctlseqs: fix weird sounding sentence 2021-02-23 09:31:44 +01:00
Daniel Eklöf
51900a5efb
doc: ctlseqs: be consistent; use dash between ‘8’ and ‘bit’ 2021-02-23 09:31:44 +01:00
Daniel Eklöf
634116e637
doc: ctlseqs: escape backslashes 2021-02-23 09:31:44 +01:00
Daniel Eklöf
6594c39823
doc: ctlseqs: document SGRs, add TODOs 2021-02-23 09:31:44 +01:00
Daniel Eklöf
38e2700f74
doc: ctlseqs: document CC0 control sequences 2021-02-23 09:31:44 +01:00
Daniel Eklöf
e1dd1fe6e8
Merge branch 'dracula-theme' 2021-02-23 09:30:32 +01:00
Elias
371a5fa672 themes: add Dracula 2021-02-22 23:11:39 +01:00
Daniel Eklöf
3d7207f9c5
Merge branch 'rename-_errno' 2021-02-22 09:28:53 +01:00
Daniel Eklöf
2c881b9f06
Merge branch 'osc8'
Closes #13
2021-02-21 20:48:18 +01:00
Daniel Eklöf
555f751f94
errno: don’t use ‘_errno’ as a variable name; _ are reserved for use as identifiers 2021-02-21 20:33:07 +01:00
Daniel Eklöf
3c6d4f152b
changelog: OSC-8 support 2021-02-21 20:16:25 +01:00
Daniel Eklöf
11464a65de
url-mode: use the same key combo for all occurrences of an URL 2021-02-21 20:15:33 +01:00
Daniel Eklöf
21a355f38a
config: typo: osc8-underline=always means ALWAYS 2021-02-21 20:15:32 +01:00
Daniel Eklöf
35779ec4e5
config: osc8-underline: default to ‘url-mode’ 2021-02-21 20:15:32 +01:00
Daniel Eklöf
2074f8b656
urls: OSC-8 URLs can now optionally be underlined outside of url-mode
This patch adds a new configuration option,
‘osc8-underline=url-mode|always’.

When set to ‘url-mode’, OSC-8 URLs are only
highlighted (i.e. underlined) in url-mode, just like auto-detected
URLs.

When set to ‘always’, they are always underlined, regardless of mode,
and regardless of their other attributes.

This is implemented by tagging collected URLs with a boolean,
instructing urls_render() and urls_reset() whether they should update
the cells’ ‘url’ attribute or not.

The OSC-8 collecter sets this based on the value of ‘osc8-underline’.

Finally, when closing an OSC-8 URL, the cells are immediately tagged
with the ‘url’ attribute if ‘osc8-underline’ is set to ‘always’.
2021-02-21 20:15:32 +01:00
Daniel Eklöf
a0b977fcee
grid: refactor: break out allocation of ‘extra’ member to separate function 2021-02-21 20:15:32 +01:00
Daniel Eklöf
7f13d0084e
terminal: osc8_close(): refactor: use grid_row_add_uri_range() 2021-02-21 20:15:32 +01:00
Daniel Eklöf
d42b129814
grid: refactor: use grid_row_add_uri_range() 2021-02-21 20:15:32 +01:00
Daniel Eklöf
5eea06cff9
grid: add new function grid_row_add_uri_range() 2021-02-21 20:15:32 +01:00
Daniel Eklöf
fd505f2274
grid: resize_without_reflow: allocate ‘extra’ on-demand on ‘new’ rows
Even if we have URI ranges on the old row, all those ranges may lay
outside the new grid’s range.
2021-02-21 20:15:32 +01:00
Daniel Eklöf
8da82c897b
grid: grid_resize_without_reflow: transfer URI ranges 2021-02-21 20:15:32 +01:00
Daniel Eklöf
3ca5a65c33
grid: reflow: translate URI ranges
URI ranges are per row. Translate by detecting URI range start/end
coordinates, and opening and closing a corresponding URI range on the
new grid.

We need to take care when line-wrapping the new grid; here we need to
manually close the still-open URI ranges (on the new grid), and
re-opening them on the next row.
2021-02-21 20:15:32 +01:00
Daniel Eklöf
17f90eeec4
grid: grid_row_free(): use grid_row_reset_extra() 2021-02-21 20:15:32 +01:00
Daniel Eklöf
3e06362d74
terminal: scroll: use grid_row_reset_extra() 2021-02-21 20:15:32 +01:00
Daniel Eklöf
00977fcc15
grid: add new function, grid_row_reset_extra()
This function resets (free:s) all ‘extra’ data associated with a row.
2021-02-21 20:15:31 +01:00
Daniel Eklöf
0e6b1f7508
term: osc-8: close: ignore zero-length URLs
If the client application emitted e.g:

  \E]8;;http://foo\E\\\E]8;;\E\\

i.e. an anchor without content, then we ended up with an ‘end’
coordinate that lied *before* the ‘start’ coordinate, since we
subtract one (column) from the end point to make it inclusive.
2021-02-21 20:15:31 +01:00
Daniel Eklöf
20ff492d33
term: osc-8: open: typo: close previous URL if ‘begin’ coords are *non-negative* 2021-02-21 20:15:31 +01:00
Daniel Eklöf
4ff5154cb8
config: change default key binding for toggle-url-visible to ‘t’ 2021-02-21 20:15:31 +01:00
Daniel Eklöf
06a9ffa763
urls: add key binding that toggles whether URLs are displayed on jump-label
By default, the URL isn’t shown on the jump-label. For auto-detect
URLs, doing so is virtually always useless, as the URL is already
visible in the grid.

For OSC-8 URLs however, the URL is often _not_ visible in the
grid. Many times, seeing the URL is still not needed (if you’re doing
‘ls --hyperlink’, you already know what the URIs are).

But it is still useful to have a way to show the URLs.

This patch adds a new key binding action that can be used in url-mode
to toggle the URL on and off in the jump label.

It is bound to ctrl+t by default.
2021-02-21 20:15:31 +01:00
Daniel Eklöf
cc43c1b704
urls: remove free-form ‘text’ member from URL struct 2021-02-21 20:15:31 +01:00
Daniel Eklöf
cf651d361f
url-mode: remove duplicate URLs
Remove URLs with the same start and end coordinates. Such duplicate
URLs can be created by emitting an OSC-8 URL with matching grid
content:

  \E]8;;http://foo\E\\http://foo\E]8;;\E\\
2021-02-21 20:15:31 +01:00
Daniel Eklöf
d44cda11bf
osc-8: fix thinko: can’t use the ID parameters *address* as actual ID
Doing so means the next OSC-8 URL emitted by the client application,
with the same ID, will get a *new* id internally.

Instead, hash the string and use that as ID.
2021-02-21 20:15:31 +01:00
Daniel Eklöf
34b814349b
util: add a sdbm hash implementation 2021-02-21 20:15:31 +01:00
Daniel Eklöf
663c43c139
term_osc8_close(): the URL *end* column is inclusive 2021-02-21 20:15:31 +01:00
Daniel Eklöf
a99f9c9341
url-mode: activate_url(): ensure ‘scheme’, ‘host’ and ‘path’ are free:d
uri_parse() may succeed. But if the scheme isn’t “file”, or if the
hostname isn’t localhost, then we failed to free ‘scheme’, ‘host’ and
‘path’.
2021-02-21 20:15:31 +01:00
Daniel Eklöf
fb9e9513a5
url-mode: multiple URL (parts) with the same ID is assigned a single key sequence
In case an URL is split up into multiple parts, those parts are now
treated as a single URL when it comes to key assignment.

Only the *first* URL part is actually assigned a key combo. The other
parts are ignored.

We still highlight them, but for all other purposes they are ignored.
2021-02-21 20:15:29 +01:00
Daniel Eklöf
ffbee5ff37
term: add an ‘id’ member to the the ‘row_uri_range’ struct
term_osc8_close() sets it from the OSC-8 ID tracked in the VT
sub-struct.
2021-02-21 20:14:52 +01:00
Daniel Eklöf
b934969b85
term: add ‘id’ parameter to term_osc8_open()
The current OSC-8 URL’s ID is now tracked along with the URI itself,
and its starting point.
2021-02-21 20:14:52 +01:00
Daniel Eklöf
ecbfc2bbe9
osc: 8: parse params, and the ‘id’ parameter specifically
Applications can assign an ID to the URL. This is used to associate
the parts of a split up URL with each other:

  ╔═ file1 ════╗
  ║          ╔═ file2 ═══╗
  ║http://exa║Lorem ipsum║
  ║le.com    ║ dolor sit ║
  ║          ║amet, conse║
  ╚══════════║ctetur adip║
             ╚═══════════╝

In the example above, ‘http://exa’ and ‘le.com’ are part of the same
URL, but by necessity split up into two OSC-8 URLs.

If the application sets the same ID for those two OSC-8 URLs, the
terminal can ensure they are handled as one.
2021-02-21 20:14:52 +01:00
Daniel Eklöf
c600e131e2
main: initialize pseudo-random generator 2021-02-21 20:14:51 +01:00
Daniel Eklöf
39c5057d49
url-mode: initial support for OSC-8 URLs
Things left to do: since OSC-8 URLs are stored as ranges in the
per-row ‘extra’ data member, we currently do not handle line-wrapping
URLs very well; they will be considered two separate URLs, and
assigned two different key sequences.
2021-02-21 20:14:51 +01:00
Daniel Eklöf
b55f6925d3
osc: parse OSC-8, by calling term_osc8_{open,close} as appropriate 2021-02-21 20:14:51 +01:00
Daniel Eklöf
682494d45a
terminal: add term_osc8_{open,close} functions
These functions update the OSC-8 URI state in the terminal.

term_osc8_open() tracks the beginning of an URL, by storing the start
coordinate (i.e. the current cursor location), along with the URL
itself.

Note that term_osc8_open() may not be called with an empty URL. This
is important to notice, since the way OSC-8 works, applications close
an URL by “opening” a new, empty one:

  \E]8;;https://foo.bar\e\\this is an OSC-8 URL\E]8;;\e\\

It is up to the caller to check for this, and call term_osc8_close()
instead of term_osc8_open() when the URL is empty.

However, it is *also* valid to switch directly from one URL to
another:

  \E]8;;http://123\e\\First URL\E]8;;http//456\e\\Second URL\E]8;;\e\\

This use-case *is* handled by term_osc8_open().

term_osc8_close() uses the information from term_osc8_open() to add
per-row URL data (using the new ‘extra’ row data).
2021-02-21 20:14:51 +01:00
Daniel Eklöf
841e5f0e50
terminal: add OSC-8 state tracking to the VT sub-struct 2021-02-21 20:14:51 +01:00
Daniel Eklöf
fd87bca102
grid: enable rows to have ‘extra’ data associated with them
This patch adds an ‘extra’ member to the row struct. It is a pointer
to a struct containing extra data to be associated with this row.

Initially, this struct contains a list of URL ranges. These
define (OSC-8) URLs on this row.

The ‘extra’ data is allocated on-demand. I.e. the pointer is NULL by
default; it is *not* allocated by grid_row_alloc().
2021-02-21 20:14:51 +01:00
Daniel Eklöf
3339915d20
url-mode: store URL in UTF-8, not UTF-32
The only time the URL is actually in UTF-32 is when we’re collecting
it (auto-detecting it) from the grid, since cells store their
character(s) in UTF-32.

Everything *after* that prefers the URL in UTF-8. So, do the
conversion while collecting the URL.

This patch also changes the URL activation code to strip the
‘file://user@host/’ prefix from file URIs that refer to files
on the *local* computer.
2021-02-21 20:14:51 +01:00
Daniel Eklöf
0bda60aacc
Merge branch 'restore-signals-when-spawning-subprocess'
Closes #366
2021-02-21 20:00:31 +01:00
Daniel Eklöf
dd5c31657e
spawn/slave: restore signal mask after fork
slave: no need to restore signal handlers; they are automatically
restored as long as they are not SIG_IGN (which they never are in
foot).

spawn(): restore signal mask after fork. This fixes an issue where a
terminal spawned with ctrl+shift+n did not terminate when its shell
exited.

Closes #366
2021-02-21 19:59:50 +01:00