Commit graph

3905 commits

Author SHA1 Message Date
Daniel Eklöf
6658740982
sixel: store current row position in pixels, not characters 2021-03-11 17:32:55 +01:00
Daniel Eklöf
928b819934
meson: SOURCE_DIR is not a valid macro in custom_target()
But appears to have been allowed in older versions of meson.

Fixes an issue where foot’s version was always reported as the last
stable release, even though it was a git build.
2021-03-11 17:30:00 +01:00
Daniel Eklöf
098bc2771b
Merge branch 'consume-modifiers-for-client-application'
Closes #376
2021-03-08 20:30:33 +01:00
Daniel Eklöf
e4f164d958
keymap: handle shift+tab combos correctly, after consuming modifiers
Shift+Tab is an odd bird in XKB; it produces a shifted variant of tab,
ISO_Left_Tab, with Shift being a consumed modifier.

From a terminal perspective, Tab and ISO_Left_Tab are the same key,
with Shift+Tab generating ‘CSI Z’, and all other combos generating a
‘CSI 27;mods;9~’ escape.

Before, when we didn’t filter out consumed modifiers, we could simply
re-use the keymap for Tab when translating ISO_Left_Tab.

This is no longer possible, since shift has been filtered out. As a
result, Shift+Tab no longer generated ‘CSI Z’, but ‘\t’. I.e as if
shift wasn’t being pressed.

This patch adds a separate keymap table for ISO_Left_Tab. It’s MOD_ANY
entry corresponds to Shift+Tab, and emits ‘CSI Z’. All its other
entries *exclude* shift (since it has been consumed), *but*, the
encoded modifier (in the escape sequences) *include* shift.
2021-03-08 20:30:25 +01:00
Daniel Eklöf
6cd72bdee6
input: do not include consumed modifiers in the set sent to the client
When sending a key escape sequence to the client application, do not
include consumed modifiers.

Fixes part of #376
2021-03-08 20:30:23 +01:00
Daniel Eklöf
a8696b567e
Merge branch 'xkbcommon-bump'
Closes #389
2021-03-08 20:29:01 +01:00
Craig Barnes
2e31a1ec7a meson: bump minimum xkbcommon version to 1.0.0
This requirement is due to the recently added maybe_repair_key_combo()
function, which is making use of xkb_keymap_key_get_mods_for_level().

See also: commit a5b554761a.
2021-03-07 19:28:17 +00:00
Daniel Eklöf
c95c663989
sixel: size provided by DECGRA does *not* limit the sixel size
Foot has, up until now, used a fixed image size when the application
used DECGRA (Raster Attributes) to “configure” the image size.

This was based on a misunderstanding, that this was how you emitted
sixels where the height was *not* a multiple of 6.

This isn’t the case. The VT340 documentation is actually pretty clear
about this:

  Ph and Pv do not limit the size of the image defined by the sixel
  data. However, Ph and Pv let you omit background sixel data from the
  image definition and still have a color background. They also
  provide a concise way for the application or terminal to encode the
  size of an image.

This is also how XTerm behaves. Test image:

  \EPq
  "1;1;1;1
  #0;2;0;0;0#1;2;100;100;0#2;2;0;100;0
  #1~~@@vv@@~~@@~~$
  #2??}}GG}}??}}??-
  #1!14@
  \E\

This uses DECGRA to set the image size to 1x1. The sixel however
is *not* clipped to 1x1, but is resized to 14x12
2021-03-06 15:03:47 +01:00
Daniel Eklöf
be980a6282
url-mode: fix auto-detection of URLs in the top corner of the viewport
The ‘proto_chars’ variable is kind of like a FIFO, where characters
from the grid is pushed to the back of it. I.e. the last <n> bytes are
at the *end* of the array.

This was what the protocol matching logic expected. However, it was
only true after reading ‘max_prot_len’ characters from the
grid. Before that, the last <n> bytes from the grid was in
the *beginning* of ‘proto_chars’.

This meant we did not detect URLs starting in the top left corner of
the viewport. Test case:

  foot sh -c "echo http://test.com && sleep 9999"
2021-03-06 13:06:54 +01:00
Daniel Eklöf
e8a8d122f0
Merge branch 'consume-modifiers-for-key-bindings'
Closes #376
2021-03-04 10:32:29 +01:00
Daniel Eklöf
b796965c3d
changelog: new key binding matching logic 2021-03-04 10:13:47 +01:00
Daniel Eklöf
93b02cf2b8
url-mode: ignore keys with modifiers 2021-03-04 09:43:44 +01:00
Daniel Eklöf
be00de4849
foot.ini: lower case Shift+X default bindings 2021-03-04 09:43:44 +01:00
Daniel Eklöf
a5b554761a
input: repair key combos containing both explicit modifier and shifted symbol
If a user-provided key combo contains both an explicit modifier, and
the shifted symbol it produces, replace the symbol with its un-shifted
version.

Example: Control+Shift+U contains both ‘Shift’, and ‘U’, where ‘Shift’
is the modifier that shifts ‘u’ to ‘U’.

Such modifiers are “consumed”, i.e. filtered out, when matching key
combos. As such, Control+Shift+U will never trigger since we’ll never
be able to match the consumed modifier ‘Shift’.

The above combo can be written in two ways:

- Control+U
- Control+Shift+u

To be able to detect that Control+Shift+U is an invalid combination,
we need to check all *shifted* symbols for all key *codes*.

Once we’ve detected a shifted symbol (and where it differs from the
un-shifted symbol), we loop all modifier sets that produce the shift
level where our shifted symbol is. For each such set, check if it
intersects with the user-provided key combo’s modifier set.

If there is an intersection, it means the user provided a key combo
containing a modifier and symbol, such that the modifier is consumed
when the symbol is produced.

In this case, we replace the symbol with its un-shifted version.
2021-03-04 09:43:44 +01:00
Daniel Eklöf
1b4d9eade0
config: parse_key_combos: lower case manually, instead of calling tolower()
tolower() is locale dependent, something we do not want in this case.
2021-03-04 09:43:43 +01:00
Daniel Eklöf
3a4f6c469b
doc: foot.ini: update default key bindings - use lower case keys 2021-03-04 09:43:43 +01:00
Daniel Eklöf
cfa82bc920
config: fix default key binding for extend-to-next-whitespace
Bindings now use lower-cased keys
2021-03-04 09:43:43 +01:00
Daniel Eklöf
47fe27ca5d
doc: foot.ini: key combos must *not* include shift and be in upper case 2021-03-04 09:43:43 +01:00
Daniel Eklöf
5e64e06a55
input: rewrite of how we match foot’s own key bindings
Bindings are matched in one out of three ways:

* By translated (by XKB) symbols
* By untranslated symbols
* By raw key codes

A translated symbol is affected by pressed modifiers, some of which
can be “consumed”. Consumed modifiers to not partake in the comparison
with the binding’s modifiers. In this mode, ctrl+shift+2 maps to
ctrl+@ on a US layout.

Untranslated symbols, or un-shifted symbols refer to the “base” symbol
of the pressed key, i.e. it’s unaffected by modifiers. In this mode,
consumed modifiers *do* partake in the comparison with the binding’s
modifiers, and ctrl+shift+2 maps to ctrl+shift+2 on a US layout.

More examples: ctrl+shift+u maps to ctrl+U in the translated lookup,
while ctrl+shift+u maps to ctrl+shift+u in the untranslated lookup.

Finally, we also match raw key codes. This allows our bindings to work
using the same physical keys when the user switches between latin and
non-latin layouts.

This means key bindings in foot.ini *must* not include both +shift+
and a *shifted* key. I.e. ctrl+shift+U is not a valid combo as it
cannot be triggered. Unfortunately, this was how you were supposed to
write bindings up until now... so, we try to detect such bindings, log
a deprecation warning and then “fix” the binding for the user.

When specifying bindings in foot.ini, both ctrl+U and ctrl+shift+u are
valid, and will work. The latter is preferred though, since we cannot
detect the raw key code for the former variant. Personally, I also
prefer the latter one because it is more explicit; it’s more obvious
which keys are involved.

However, in some cases it makes more sense to use the other
variant. Typically for non-letter combos.
2021-03-04 09:43:43 +01:00
Daniel Eklöf
decc655d48
input: ask XKB for consumed modifiers, but don’t actually use them just yet 2021-03-04 09:42:36 +01:00
Daniel Eklöf
b87b8f1170
Revert "url-mode: ignore keys with modifiers"
This reverts commit e5cd09bf3f.

This needs to be applied on the consume-modifiers-for-key-bindings
branch.
2021-03-04 09:34:37 +01:00
Daniel Eklöf
544cd823d7
Merge branch 'ime-dont-commit-unless-we-have-ime-focus'
Closes #384
2021-03-04 09:29:36 +01:00
Daniel Eklöf
e9d8ade5cc
input: mutter has been seen sending NULL surfaces in pointer enter 2021-03-04 08:57:31 +01:00
Daniel Eklöf
81b5d476a9
input: exit URLs mode on mouse button events
This makes URLs mode behave like scrollback search mode.
2021-03-04 08:57:03 +01:00
Daniel Eklöf
31a3b7dadf
render: jump-labels: case insensitive comparison when looking for matching keys 2021-03-04 08:55:55 +01:00
Daniel Eklöf
e5cd09bf3f
url-mode: ignore keys with modifiers 2021-03-04 08:54:38 +01:00
Daniel Eklöf
6654aab620
changelog: oops, vertical-letter-offset is new in 1.7.x
No need to a changelog entry for fixing something that hasn’t yet been
released.
2021-03-02 09:25:06 +01:00
Daniel Eklöf
55e3c74903
Merge branch 'fix-vertical-letter-offset-config' 2021-03-02 09:22:59 +01:00
Daniel Eklöf
3f19ee4d92
ime: don’t commit IME changes when we don’t have IME focus
Fixes log spamming in Sway:

  00:54:07.780 [DEBUG] [wlr] [types/wlr_text_input_v3.c:181] Text input commit received without focus
  00:54:07.780 [INFO] [sway/input/text_input.c:127] Inactive text input tried to commit an update

Closes #384
2021-03-02 09:01:40 +01:00
L3MON4D3
6edba44651 Mention fix in Changelog. 2021-03-01 20:26:56 +01:00
Daniel Eklöf
c3880af593
Merge branch 'add-name-section-to-foot-ctlseq' 2021-03-01 19:59:10 +01:00
L3MON4D3
093df837ca Fix typo. 2021-03-01 13:44:46 +01:00
Felix Lechner
e54abd1c33 Add NAME section to foot-ctlseqs.7; fixes whatis entry for manual page.
In a recent Debian build from master, Lintian complained about a bad
whatis entry for this manual page. The tag description [1] says a NAME
section is required. It is added here.

[1] https://lintian.debian.org/tags/bad-whatis-entry.html
2021-02-28 09:52:53 -08:00
Daniel Eklöf
3f57cc9c01
Merge branch 'sixel-private-mode-80-scrolling'
Closes #361
2021-02-27 11:49:47 +01:00
Daniel Eklöf
dd73964cd5
changelog: default value of -t,--term in --help when built without terminfo 2021-02-26 15:16:42 +01:00
Chloe Kudryavtsev
80b95eeb7e
config: reuse HAVE_TERMINFO via DEFAULT_TERM
add detection in --help output
also make it more easily accessible for other locations to change
2021-02-26 15:15:05 +01:00
Daniel Eklöf
1563fecc20
sixel: don’t go past the bottom scroll margin when sixel scrolling is disabled
When sixel scrolling is disabled (private mode 80 is off), and scroll
margins have been set, XTerm seems to ignore the top margin (sixel
still begins at (0,0)), but does not go past the bottom margin.

This patch implements the same behavior in foot.
2021-02-26 14:20:00 +01:00
Daniel Eklöf
849427bf10
sixel: implement private mode 80 - sixel scrolling
When enabled (the default), sixels behave much like normal output; the
start where the cursor is, and the cursor moves with the
sixel. I.e. after emitting a sixel the cursor is left after the image;
either to the right, if private mode 8452 is enabled, or otherwise on
the next line. Terminal content is scrolled up if the sixel is larger
than the screen.

When disabled, sixels *always* start at (0,0), the cursor never moves,
and the terminal content never scrolls.

In other words, the ‘disabled’ mode is a much simpler mode.

All we need to do to support both modes is re-write the sixel-emitting
loop to:

* break early if we’re “out of rows”, i.e. we’ve reached the bottom of
  the screen.
* not linefeed, or move the cursor when scrolling is disabled

This patch also fixes a bug in the (new) implementation of private
mode 8452.

When emitting a sixel, we may break it up into smaller pieces, to
ensure a single sixel (as tracked internally) does not cross the
scrollback wrap-around.

The code that checked if we should do a linefeed or not, would skip
the linefeed on the last row of *each* such sixel piece. The correct
thing to do is to skip it only on the last row of the *last* piece.

I chose not to fix this bug in a separate patch since doing so would
have meant re-writing it again when implementing private mode 80.
2021-02-26 09:28:03 +01:00
Daniel Eklöf
792202bf29
grid: snapshot: don’t mark all cells as dirty - copy state from source grid 2021-02-26 09:25:27 +01:00
Daniel Eklöf
ed47a65afc
csi: remove extra ‘;’ 2021-02-26 09:25:17 +01:00
Daniel Eklöf
c0be074348
doc: use ‘fuzzel’ instead of ‘bemenu’ in examples 2021-02-26 09:24:40 +01:00
Daniel Eklöf
44d9b7c74f
Merge branch 'url-mode-snapshot-screen-state' 2021-02-26 09:16:09 +01:00
Daniel Eklöf
ae0f20a536
url-mode: damage current view before entering URL mode
Clear scroll damage and damage the entire viewport before entering URL
mode. This will cause us to do a full screen redraw both when entering
URL mode, and later when exiting it.

Clearing the scroll damage is necessary to ensure we don’t apply it
twice (once for the snapshot:ed grid, and later again for the real
grid), as that would result in an incorrect pixmap.

But, since we’ve cleared the scroll damage, we need to damage the
entire view to ensure we redraw the contents correctly.
2021-02-26 09:15:46 +01:00
Daniel Eklöf
3c123425fb
command: scrollback: don’t allow scrolling in URL mode 2021-02-26 09:15:46 +01:00
Daniel Eklöf
bc71e06d5f
url-mode: dirty the “last cursor” cell before taking the snapshot
This ensures the “last cursor” cell is re-drawn (without a cursor, if
the cursor has moved), both in the snapshot:ed grid, and later, when
we switch back to the real grid.

We must also be careful and reset term->render.last_cursor.row
both when *entering* and *leaving* URL mode, to ensure it doesn’t
point to an invalid row.
2021-02-26 09:15:45 +01:00
Daniel Eklöf
aa10cd54ea
url-mode: no need to damage the entire view when exiting URL mode
The renderer will simply apply *all* accumulated damage at once, when
we render the real grid.
2021-02-26 09:15:45 +01:00
Daniel Eklöf
a0f021b7db
grid: snapshot: copy scroll damage 2021-02-26 09:15:45 +01:00
Daniel Eklöf
2cb624ee43
grid: grid_free(): free scroll damage list 2021-02-26 09:15:45 +01:00
Daniel Eklöf
54b5ae95c1
url-mode: snapshot screen state when entering URL mode
Previously, we automatically exited URL mode whenever we received data
on the PTY. This was done since we don’t know _what_ has changed on
the screen, and we don’t want to display misleading jump labels.

However, this becomes a problem in curses-like applications that
periodically updates part of the screen. For example, a statusbar with
a clock.

This patch changes this behavior; instead of cancelling URL mode when
receiving PTY data, we snapshot the grid when entering URL mode.

When *rendering*, we use the snapshot:ed grid, while PTY updates
modify the “real” grid.

Snapshot:ing the grid means taking a full/deep copy of the current
grid, including sixel images etc.

Finally, it isn’t necessary to “damage” the entire view
when *entering* URL mode, since we’re at that point the renderer is in
sync with the grid. But we *do* need to damage the entire view when
exiting URL mode, since the grid changes on the “real” grid hasn’t
been tracked by the renderer.
2021-02-26 09:15:45 +01:00
Daniel Eklöf
ae3ec52507
grid: add grid_snapshot()
This function deep copies a grid into a newly *allocated* grid struct.
2021-02-26 09:15:45 +01:00