Commit graph

1454 commits

Author SHA1 Message Date
Daniel Eklöf
304f8d6982
wayland: output_mode: update PPI
Since we now use the width/height values from output_mode(), we also
need to update the PPI here.
2020-02-15 21:31:23 +01:00
Daniel Eklöf
f0887df5c5
main: bug: -t requires an argument 2020-02-15 21:05:53 +01:00
Daniel Eklöf
fc66c5f676
README: change wording of DPI header 2020-02-15 21:02:18 +01:00
Daniel Eklöf
593dad7d2b
README: talk about DPI, add font on-the-fly features to feature list 2020-02-15 20:59:34 +01:00
Daniel Eklöf
5b98510ea4
doc: foot.5: make 'pad' syntax/example clearer 2020-02-15 19:51:11 +01:00
Daniel Eklöf
34049af252
PKGBUILD: experimental: build with -fstrict-aliasing 2020-02-15 19:46:29 +01:00
Daniel Eklöf
db830643d2
shm: prefer posix_fallocate over ftruncate 2020-02-15 19:46:00 +01:00
Daniel Eklöf
291410bd71
wayland: debug: make sure state_str is properly NULL terminated 2020-02-15 19:30:59 +01:00
Daniel Eklöf
1a808d2552
Merge branch 'font-dpi-adjust-on-the-fly' 2020-02-15 19:16:22 +01:00
Daniel Eklöf
4d3ab6176d
term: implement term_font_dpi_changed()
This function reloads the font *if* the DPI has changed. To handle
user run-time adjusted font sizes, we record the number of adjustments
made.

Then, when re-loading the font, we first load the font as specified in
the configuration. Then, we re-apply the size adjustment using
font_size_adjust().

Note that this means we end up loading the fonts twice; first using
the default size (but with adjusted DPI), and then again with the
adjusted size. This can probably be improved upon.

The existing font code has been refactored to avoid code
duplication. For example, term_init() now calls
term_font_dpi_changed() to load the initial fonts, instead of directly
instantiating them.

Finally, the way we calculate the DPI to use has changed: instead of
using the highest DPI of all available outputs, we use the highest DPI
of the output's we're actually mapped on. If we're not mapped at all,
we use the globally highest DPI.

Doing it this way means we usually only have to load the fonts
once. Otherwise, we'd end up using the default DPI of 96 when the
terminal is first instantiated (since it's not mapped at that time).

On a single monitor system, we'll use the globally highest DPI at
first, before being mapped. Then when we get mapped, we re-load the
fonts using the highest mapped DPI. But since they'll be the same,
we can skip actually reloading the fonts.
2020-02-15 19:08:14 +01:00
Daniel Eklöf
027696e9c6
wayland: calculate DPI from physical size, not logical size
xdg_output_handle_logical_size() reports _logical_ output size. That
is, it is scaled by the output's scale factor.

We want the _actual_ DPI. The _real_ output size is reported by
output_mode(), so use that instead.
2020-02-15 19:06:28 +01:00
Daniel Eklöf
ffcb09dd75
wayland: break out scale/resize updating to a new function
And call this function once from output_done(), rather than from each
output_*() callback.
2020-02-15 19:05:33 +01:00
Daniel Eklöf
e5253ca737
input: fix xcursor getting stuck
Apparently, a frame callback for the cursor surface is *never*
triggered if we get a pointer-leave event *before* the callback is
triggered. At least on Sway 1.4.

This caused the cursor being stuck, and never updating once this state
was reached.

Fix by destroying the cursor frame callback on pointer-leave.
2020-02-15 19:02:43 +01:00
Daniel Eklöf
26a8d4b8a1
Merge branch 'configurable-padding' 2020-02-15 19:02:21 +01:00
Daniel Eklöf
faf3bdaec3
doc: foot.5: document new 'pad' configuration option 2020-02-15 19:02:05 +01:00
Daniel Eklöf
7f211d8f03
footrc: add 'pad' option 2020-02-15 19:01:54 +01:00
Daniel Eklöf
b036a66c42
render: resize: take padding from configuration into account 2020-02-15 19:01:26 +01:00
Daniel Eklöf
9ab9247b88
config: add 'pad' option, default to 2 2020-02-15 19:00:56 +01:00
Daniel Eklöf
a089d6264d
Merge branch 'text-reflow-fixes' 2020-02-15 19:00:18 +01:00
Daniel Eklöf
f07a124c11
render: reflow: set 'linebreak' flag before inserting new line 2020-02-15 18:59:21 +01:00
Daniel Eklöf
3019d59369
render: reflow: remove 'linebreak' flag from recycled rows 2020-02-15 18:58:57 +01:00
Daniel Eklöf
56c2dd4199
render: reflow: no need to mark new rows as dirty 2020-02-15 18:58:36 +01:00
Daniel Eklöf
ab43a6fd37
render: resize: cancel selection before reflowing text
The old selection will no longer be valid once we resize the grids.
2020-02-15 18:57:52 +01:00
Daniel Eklöf
9e6404be11
render: reflow: bug: fix off-by-one
The 'last-row' variable points to the last row the cursor is *on*,
thus it's not a counter, and we need to add one when calculating the
new grid offsets, or we get an off-by-one error.

With this, there's no longer any need to scroll the reflowed text.
2020-02-15 18:56:16 +01:00
Daniel Eklöf
d11a71e0b2
term: reset: use grid_row_alloc() with initialize=true
This will both zero out the cells, *and* re-initialize the row
properties correctly.
2020-02-14 22:43:23 +01:00
Daniel Eklöf
ce8005545d
term: convert cell 'linefeed' attribute to a row 'linebreak' property
To do text reflow, we only need to know if a line has been explicitly
linebreaked or not. If not, that means it wrapped, and that we
should *not* insert a linebreak when reflowing text.

When reflowing text, when reaching the end of a row in the old grid,
only insert a linebreak in the new grid if the old row had been
explicitly linebreaked.

Furthermore, when reflowing text and wrapping a row in the new grid,
mark the previous row as linebreaked if either the last cell was
(the last column in the last row) empty, or the current cell (the
first column in the new row) is empty. If both are non-empty, then we
assume a linewrap.
2020-02-14 22:39:26 +01:00
Daniel Eklöf
60056fdd61
render: resize: don't reflow text if grid layout hasn't changed
A window resize doesn't necessarily mean the grid layout changes. When
it doesn't, don't reflow text.

This fixes a slowness issue on Sway, when swapping positions of two
~equally sized windows.
2020-02-14 19:03:33 +01:00
Daniel Eklöf
ec63a24c80
render: reflow: erase row when wrapping around the scrollback 2020-02-14 19:03:13 +01:00
Daniel Eklöf
cb015d5eec
render: reflow: mark all "new" rows as dirty 2020-02-14 19:02:36 +01:00
Daniel Eklöf
4b328ead5e
render: resize: do linefeed *after* updating cursor position 2020-02-12 20:39:43 +01:00
Daniel Eklöf
a96a6c2c58
render: resize; heuristics to prevent prompt from being printed on a newline 2020-02-12 20:26:14 +01:00
Daniel Eklöf
ea52d3e570
render: resize: temporarily disable row adjustment
This was intended to prevent a new prompt from being printed on a
newline. However, it breaks normal output under certain conditions,
that have yet to be determined exactly what they are.
2020-02-12 20:16:42 +01:00
Daniel Eklöf
c28c0ab9c2
render: resize: only stay on current row if col is within grid width 2020-02-12 19:49:39 +01:00
Daniel Eklöf
69a633221f
term: formfeed: set linefeed correctly when we're at last column with lcf=1
When cursor.lcf is set, that means the cursor column was *not*
incremented when we printed the last character. Thus, we should *not*
decrement the column before setting the linefeed bit.
2020-02-12 18:06:27 +01:00
Daniel Eklöf
bcd28bcd14
render: spelling 2020-02-12 18:06:15 +01:00
Daniel Eklöf
3f282a2f2e
footrc, doc/foot.5: improve documentation of 'shell', and mention --login 2020-02-11 19:57:15 +01:00
Daniel Eklöf
335bf2e5b4
Merge branch 'text-reflow' 2020-02-11 19:39:23 +01:00
Daniel Eklöf
b28a742a00
selection: handle line break at last column correctly
Insert a newline into the selection even if the last column contained
a printable character, *if* that column also has linefeed=1.
2020-02-11 19:36:31 +01:00
Daniel Eklöf
e56523f326
render: resize: calculated cursor row *should* never be beyond the screen bottom 2020-02-10 22:40:16 +01:00
Daniel Eklöf
88e2ab21b3
render: reflow: clear new line if already allocated 2020-02-10 22:38:30 +01:00
Daniel Eklöf
3ad2ee7681
render: resize: fix cursor positioning at grid wrap around
When current view is at a grid wrap around (last emitted row index is
< grid offset), the cursor row ended up being negative which we then
mapped to the top line.

This is wrong. When we're at a wrap around, re-adjust cursor by adding
the grid's row count.
2020-02-10 22:36:39 +01:00
Daniel Eklöf
8d262e71c1
render: reflow: initial line is always unallocated 2020-02-10 22:36:17 +01:00
Daniel Eklöf
b0f98a9d0c
term: font_size_{increase,descrease}: adjust size by 0.5pt 2020-02-10 22:22:42 +01:00
Daniel Eklöf
8716430450
input: ctrl+= increases font size, not resets it 2020-02-10 21:57:55 +01:00
Daniel Eklöf
4a169f5643
vt: tag cells that were form-feed:ed, to allow correct text reflow
To handle text reflow correctly when a line has a printable character
in the last column, but was still line breaked, we need to track the
fact that the slave inserted a line break here.

Otherwise, when the window width is increased, we'll end up pulling up
the next line, when we really should have inserted a line break.
2020-02-10 21:54:37 +01:00
Daniel Eklöf
3004c650ef
README: reflow has been implemented 2020-02-10 20:46:58 +01:00
Daniel Eklöf
80e8f91270
render: reflow: no need to clear cells
We set initialize=true when allocating a new row. This initializes the
cell to 0, with clean=1.
2020-02-10 20:46:02 +01:00
Daniel Eklöf
61b43620fc
render: initial support for text reflow
The algorithm is as follows:

Start at the beginning of the scrollback. That is, at the oldest
emitted lines. This is done by taking the current offset, and adding
the number of (old) screen rows, and then iterating until we find the
first allocated line.

Next, we iterate the entire old grid. At the beginning, we allocate a
line for the new grid, and setup a global pointer for that line, and
the current cell index.

For each line in the old grid, iterate its cells. Copy the the cells
over to the new line. Whenever the new line reaches its maximum number
of columns, we line break it by increasing the current row index and
allocating a new row (if necessary - we may be overwriting old
scrollback if the new grid is smaller than the old grid).

Whenever we reach the end of a line of the old grid, we insert a line
break in the new grid's line too **if** the last cell in the old line
was empty. If it was **not** empty, we **don't** line break the new
line.

Furthermore, empty cells in general need special consideration. A line
ending with a string of empty cells doesn't have to be copied the new
line. And more importantly, should **not** increase the new line's
cell index (which may cause line breaks, which is incorrect).

However, if a string of empty cells is followed by non empty cells, we
need to copy all the preceding empty cells to the line too.

When the entire scrollback history has been reflowed, we need to
figure out the new grid's offset.

This is done by trying to put the **last** emitted line at the bottom
of the screen. I.e. the new offset is typically "last_line_idx -
term->rows". However, we need to handle empty lines. So, after
subtracting the number of screen rows, we _increase_ the offset until
we see a non-empty line. This ensures we handle grid's that doesn't
fill an entire screen.

Finally, we need to re-position the cursor. This is done by trying to
place the cursor **at** (_not_ after) the last emitted line. We keep
the current cursor column as is (but possibly truncated, if the grid's
width decreased).
2020-02-10 20:35:24 +01:00
Daniel Eklöf
d6ef3c02fb
term: log error when failing to initialize the primary fonts 2020-02-09 16:56:59 +01:00
Daniel Eklöf
f751a213d5
Merge branch 'document-text-resize' 2020-02-09 11:37:12 +01:00