Commit graph

3780 commits

Author SHA1 Message Date
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
Daniel Eklöf
34f89fbe72
Merge branch 'refactor-subsurface-creation' 2021-02-17 21:51:31 +01:00
Daniel Eklöf
7b5a43bcbd
wayland: csd_instantiate(): remove TODO
The sub-surfaces are working just fine without the initial commit.
2021-02-17 21:48:39 +01:00
Daniel Eklöf
5c8579043d
wayland: drop ‘_surface’ suffix from subsurface struct instances 2021-02-17 21:48:08 +01:00
Daniel Eklöf
438853a2d8
render-timer: use wayl_win_subsurface_new/destroy() 2021-02-17 21:48:08 +01:00
Daniel Eklöf
c8324943de
scrollback-indicator: use wayl_win_subsurface_new/destroy() 2021-02-17 21:48:08 +01:00
Daniel Eklöf
e049124f6d
search: use wayl_win_subsurface_new/destroy() 2021-02-17 21:48:07 +01:00
Daniel Eklöf
587f04f2e1
csd: use wayl_win_subsurface_new/destroy() 2021-02-17 21:48:07 +01:00
Daniel Eklöf
9d362158e3
url-mode: convert struct wl_url to use wayl_win_subsurface_new() 2021-02-17 21:48:07 +01:00
Daniel Eklöf
bb4d9a5fd3
wayland: add wayl_win_subsurface_new() and wayl_win_subsurface_destroy()
These are utility functions to create a Wayland subsurface associated
with the window.
2021-02-17 21:47:57 +01:00
Daniel Eklöf
8658ab4bed
csi: ‘CSI 13 ; 2 t’ reply is now (0,0)
Foot previously responded with window local coordinates.

But, XTerm responds with screen *absolute* coordinates. This isn’t
possible under Wayland, thus we now report (0,0) instead. Same as we
do for ‘CSI 13 ; 0 t’.
2021-02-16 14:31:46 +01:00
Daniel Eklöf
4ff07a0d18
install: add libnotify and xdg-utils as optional dependencies 2021-02-14 12:10:38 +01:00
Daniel Eklöf
f689584734
Merge branch 'notifications-are-inhibited-while-window-has-keyboard-focus'
Closes #328
2021-02-14 11:57:23 +01:00
Daniel Eklöf
d92d0a60d0
doc: foot.ini: notifications are inhibited while we’re focused
Closes #328
2021-02-14 11:22:07 +01:00
Daniel Eklöf
689a4cc741
Merge branch 'working-dir-command-line-option'
Closes #347
2021-02-14 11:17:08 +01:00
Daniel Eklöf
4c1846f11b
Merge branch 'url-hint-letters'
Closes #355
2021-02-13 19:13:46 +01:00
Daniel Eklöf
0b1af321d9
readme: mention that the key sequence alphabet can be configured 2021-02-13 11:45:54 +01:00
Daniel Eklöf
4118d23267
doc: foot.1: mention that the key sequence alphabet can be configured 2021-02-13 11:45:38 +01:00
Daniel Eklöf
c7006661f5
url-mode: use ‘jump-label-letters’ as the alphabet for key sequences
Instead of hard coding the alphabet to “sadfjklewcmpgh”, use the
letters from ‘jump-label-letters’.

Closes #355
2021-02-13 11:43:28 +01:00
Daniel Eklöf
d29ec4fd18
doc: foot.ini.5: document jump-label-letters 2021-02-13 11:43:02 +01:00
Daniel Eklöf
fe8e6f6cdb
foot.ini: add default value of jump-label-letters 2021-02-13 11:42:51 +01:00
Daniel Eklöf
7bcab01068
config: add jump-label-letters option 2021-02-13 11:42:40 +01:00
Daniel Eklöf
94266b99d7
config: refactor: add str_to_wchars(), use it when parsing word-delimiters 2021-02-13 11:42:21 +01:00
Daniel Eklöf
b09606e343
url-mode: do case insensitive comparison when matching key sequence 2021-02-13 11:41:04 +01:00
Daniel Eklöf
5b0ebee290
client: -D,--working-directory: check path exists and is a directory 2021-02-13 10:48:58 +01:00
Daniel Eklöf
f896f12967
main: -D,--working-directory: check path exists and is a directory 2021-02-13 10:48:31 +01:00
Daniel Eklöf
37c4917e8e
changelog: -D,--working-directory=DIR 2021-02-12 21:42:53 +01:00
Daniel Eklöf
fc070dbdf1
completions: fish: add -D,--working-directory 2021-02-12 21:42:53 +01:00
Daniel Eklöf
60e67b9c21
completions: zsh: add -D,--working-directory 2021-02-12 21:42:53 +01:00