Commit graph

203 commits

Author SHA1 Message Date
Daniel Eklöf
ad5b2030f0
term: free sixel images on reset 2020-02-22 10:47:16 +01:00
Daniel Eklöf
bb82b9fabc
sixel: add sixel_destroy() 2020-02-22 00:23:19 +01:00
Daniel Eklöf
63140a68f5
sixel: calculate image height in (cell) rows 2020-02-22 00:05:25 +01:00
Daniel Eklöf
f0fc82f098
sixel: wip: maintain a list of finished, and "active" sixel images
In unhook, add the generated image to a list of finished sixel images,
along with positioning and size information.

When rendering, loop this list of images, and render the images (or
parts of) that are visible.

When scrolling, check if any part of the images cover the re-cycled
lines, and if so, remove the *entire* image from the list.

This means we have the following limitations:

* The renderer always renders the whole (visible area of) the
  image(s). There are times when this isn't necessary - for example,
  when the image is scrolled inside the visible area.
* It would be nice if we could crop the image when parts of it is
  scrolled out.
2020-02-21 23:40:35 +01:00
Daniel Eklöf
01f8719c77
term: spawn_new: check return value of chdir() and write() 2020-02-20 18:46:16 +01:00
Daniel Eklöf
b5efe984bb
slave: prefix argv[0] with a '-' when spawning a login-shell 2020-02-20 18:36:09 +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
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
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
335bf2e5b4
Merge branch 'text-reflow' 2020-02-11 19:39:23 +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
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
d6ef3c02fb
term: log error when failing to initialize the primary fonts 2020-02-09 16:56:59 +01:00
Daniel Eklöf
1dfd121c44
term: factor out common font changing code 2020-02-08 18:23:08 +01:00
Daniel Eklöf
6c0d00fcee
term: add term_font_size_reset() 2020-02-08 17:57:50 +01:00
Daniel Eklöf
89cca2a5d1
term: add term_font_size_{increase,decrease}() 2020-02-08 14:09:06 +01:00
Daniel Eklöf
2560e83c54
term: reduce max number of iterations when trying to drain client 2020-02-05 20:24:46 +01:00
Daniel Eklöf
92376eae01
term: language 2020-02-05 20:23:20 +01:00
Daniel Eklöf
9d52c422e1
term: always read *all* we can from the client before updating state
But place an upper limit on the number of iterations we read, to
prevent starvation caused by a bad behaving client to constantly
writes data.
2020-02-05 19:50:49 +01:00
Daniel Eklöf
8f4ec9aa47
Implement --hold
When specified, we don't exit when the slave/client process exits.
2020-02-03 19:58:32 +01:00
Daniel Eklöf
31baf334b3
fcft: update to 1.1.0 2020-02-01 20:20:22 +01:00
Daniel Eklöf
08eb0532ad
terminal: regression: char printed to wrong column
When term_print() was implemented, it introduced a regression where
printing a character when the last cursor was in the last column on a
line would print the character in the wrong column.

This is because term_print() retrieved a pointer to the current
cell *before* line wrapping (and possibly inserting empty cells).
2020-01-22 18:22:15 +01:00
Daniel Eklöf
a3d919a90d
input: implement metaSendsEscape and eightBitMeta 2020-01-20 18:45:14 +01:00
Daniel Eklöf
0c11459eef
term: fix reset state of VT state 2020-01-20 18:35:13 +01:00
Daniel Eklöf
300f83e66b
term: factor out character printing to new function term_print() 2020-01-20 18:34:32 +01:00
Daniel Eklöf
767a0ec232
fcft: update to 1.0.0
Allow/disallow subpixel antialiasing in font_glyph_for_wc(), not using
font_enable_subpixel_antialias().
2020-01-19 12:44:21 +01:00
Daniel Eklöf
7a00c7ddf4
term: enable subpixel antialiasing if background is opaque 2020-01-18 19:58:14 +01:00
Daniel Eklöf
1623fc0c0a
term: shorten application_synchronized_updates -> app_sync_updates 2020-01-12 12:55:19 +01:00
Daniel Eklöf
02c310d241
term: enable_application_synchronized_updates: not a noop if already enabled
If synchronized updates are already enabled when we receive a request
to enable them, extend the timeout.
2020-01-12 12:51:21 +01:00
Daniel Eklöf
95d2ee0cc1
term: app sync updates: disable delayed rendering timers once only
Disable the delayed rendering timers when enabling application
synchronized updates, not every time we've received ptmx data.
2020-01-12 12:45:34 +01:00
Daniel Eklöf
bdf127fc7e
term/render: move {enable,disable}_application_synchronized_updates()
From render -> terminal
2020-01-12 12:43:28 +01:00
Daniel Eklöf
afa1dbb7cc
render: add a timeout for application synchronized updates
This ensures we can recover from a crashing (or bad behaving)
application that sends a BSU but then never sends an ESU.
2020-01-12 12:40:42 +01:00
Daniel Eklöf
cb8a0260f3
term: rename refresh_prohibited -> application_synchronized_updates 2020-01-12 12:25:58 +01:00
Daniel Eklöf
84f836c0c8
term: ptmx: cancel, and don't re-arm, delay timers when refresh has been disabled 2020-01-12 12:23:29 +01:00
Daniel Eklöf
5956faac01
term/wayland: use MONOTONIC timers 2020-01-10 21:33:40 +01:00
Daniel Eklöf
5bfc560451
Revert "terminal: use edge-triggered FDM handler for the PTY"
This reverts commit f5e27b49eb.
2020-01-10 19:51:16 +01:00
Daniel Eklöf
3762f1f205
terminal: make the event FD used to delay shutdown non-blocking 2020-01-10 19:25:56 +01:00
Daniel Eklöf
f5e27b49eb
terminal: use edge-triggered FDM handler for the PTY
This means that the read handler now has to keep reading until we get
EAGAIN.

But it also means we don't have to flip the EPOLLOUT flag in the FDM
handler back and forth when writing to the PTY.
2020-01-10 19:24:45 +01:00
Daniel Eklöf
5ec447697c
render: throttle xcursor updates
With a bad behaving client (e.g. 'less' with mouse support enabled),
we can end up with a *lot* of xcursor updates (so much, that we
flooded the wayland socket before we implemented a blocking
wayl_flush()).

Since there's little point in updating the cursor more than once per
frame interval, use frame callbacks to throttle the updates.

This works more or lesslike normal terminal refreshes:

render_xcursor_set() stores the last terminal (window) that had (and
updated) the cursor.

The renderer's FDM hook checks if we have such a pending terminal set,
and if so, tries to refresh the cursor.

This is done by first checking if we're already waiting for a callback
from a previous cursor update, and if so we do nothing; the callback
will update the cursor for the next frame. If we're *not* already
waiting for a callback, we update the cursor immediately.
2020-01-04 22:58:32 +01:00
Daniel Eklöf
b7c970010d
term: mouse_grabbed: ctrl may be pressed too (for block selection) 2020-01-04 12:09:26 +01:00
Daniel Eklöf
0ea0323d0f
wayland: don't use wl_display_dispatch()
wl_display_dispatch() calls poll(), which is unnecessary since we
already know the FD is readable.

Use the more lower level wl_display_read_events() +
wl_display_dispatch_pending().

These require wl_display_prepare_read() to have been called.

The idea is to call wl_display_prepare_read() **before** calling
poll().

Thus, we do this more or less last in wayl_init(), and at the **end**
of the FDM handler.

However, having taking this lock also means we no longer can call
wl_display_roundtrip() directly (it will hang).

So, add a wrapper, wayl_roundtrip(), that cancels the read intent,
does the roundtrip, and then re-acquires the read intent.
2020-01-03 21:02:12 +01:00
Daniel Eklöf
ef3c7d7e0a
term: init: don't resize if compositor has already resized us 2020-01-03 19:31:09 +01:00
Daniel Eklöf
782da0f8e9
term: no need to call render_refresh() when starting/stopping blink timer 2020-01-03 19:27:57 +01:00
Daniel Eklöf
d07fd7de39
render: remove 'refresh' from render_resize() 2020-01-03 13:56:10 +01:00
Daniel Eklöf
9a0238bb52
wayland: window now keeps pointer to owning terminal, not wayland 2020-01-03 13:37:03 +01:00
Daniel Eklöf
bd13c2c86a
term: render_resize() now takes a 'refresh' argument 2020-01-03 12:45:30 +01:00
Daniel Eklöf
80dfd5b645
term: visual_focus_{in,out}: do nothing if already focused/defocused 2020-01-03 11:19:56 +01:00
Daniel Eklöf
913c684844
term: term_init() calls wl_display_roundtrip()
Instead of having `wayl_win_init()` call
`wl_display_roundtrip()` (which it itself doesn't need), call it from
`term_init()`.

This allows us to add ourselves (the new terminal instance) to the
terminal list in the wayland backend, before triggering the wayland
events caused by `wayl_win_init()`.

This is turn allows the wayland backend to find/lookup the new
terminal when those events occur..
2020-01-03 11:16:06 +01:00
Daniel Eklöf
4451f4ad62
term: spell 'initialize' correctly 2020-01-03 11:15:35 +01:00