Commit graph

352 commits

Author SHA1 Message Date
Daniel Eklöf
97e07c1ea1
term: cursor-left: don’t do reverse-wrapping unless auto-margins are enabled
This matches XTerm’s behavior.
2020-10-03 10:50:28 +02:00
Daniel Eklöf
03cacaba86
term: cursor-left: reverse-wrap when cursor is at the left margin
Assuming the private mode ‘reverse-wrap’ has been enabled.
2020-10-02 21:30:32 +02:00
Daniel Eklöf
5594746e49
Revert "term: cursor-left: reduce move count by one when lcf=true"
This reverts commit 02e3e4ac9b.

This broke at least Emacs. Cursor movement at the margins *is*
undefined, and the behavior we’re now reverting to matches XTerm.
2020-10-02 20:02:36 +02:00
Daniel Eklöf
02e3e4ac9b
term: cursor-left: reduce move count by one when lcf=true
When lcf is true, cursor is actually beyond the right margin, but the
stored coordinate is at the margin.

This means we need to reduce the number of cells to move the cursor by
one.

This fixes an issue where e.g. backspacing when the cursor is at the
right margin erased the next-to-last character instead of the last
character.
2020-10-01 20:08:29 +02:00
Daniel Eklöf
5116e40581
term: add term_damage_cursor() and term_damage_margins()
term_damage_cursor() damages the cell where the cursor is currently
at. This can be used to ensure the cursor is re-drawn, if there aren’t
any other pending updates.

term_damage_margins() requests the margins be redrawn the next time we
render the grid.
2020-09-29 10:04:18 +02:00
Daniel Eklöf
f2497320c6
config: add mouse.alternate-scroll-mode option
This option controls the initial state of the Alternate Scroll Mode,
and defaults to ‘enabled’.
2020-09-15 19:12:29 +02:00
Daniel Eklöf
91a839bf8e
term: enqueue data: cleanup 2020-08-25 18:56:15 +02:00
Daniel Eklöf
e570146c07
selection: block non-paste data from being sent to client while pasting
While pasting data from the clipboard, block *all* other data from
being sent to the client. This includes keyboard and mouse events, but
also replies for VT queries.

This is particularly important when bracketed paste has been enabled,
since then the client will interpret *everything* between the
bracketed paste start and end as paste data.
2020-08-25 18:56:15 +02:00
Daniel Eklöf
dabdffafa5
don't use empty struct initializers 2020-08-23 10:07:00 +02:00
Daniel Eklöf
44557dc7cf
input: don't crash on mouse motion events on the render timer surface 2020-08-14 07:35:01 +02:00
Craig Barnes
7a77958ba2 Convert most dynamic allocations to use functions from xmalloc.h 2020-08-08 20:37:57 +01:00
Craig Barnes
7eb70a453b Replace GCC "unused" and "format" attributes with portable macros 2020-08-07 20:42:34 +01:00
Daniel Eklöf
4919ccbc70
term: remove unusued 'damage' list 2020-08-04 18:07:22 +02:00
Daniel Eklöf
d4ee9be4d7
config: add 'hide-when-typing'
When enabled, the mouse cursor is hidden when the user types in the
terminal. It is un-hidden when the user moves the mouse, or when the
window loses keyboard focus.
2020-07-31 17:09:06 +02:00
Daniel Eklöf
f6533a71e4
user-notification: 'productify' the user-warning system
* Rename user_warning to user_notification
* Add warning and error types (in addition to the existing deprecated)
* Simplify logic when emitting a user notification after forking; we
  don't need to copy the notification data since we're in a new
  process and have total control over that memory.
2020-07-30 18:58:54 +02:00
Daniel Eklöf
b3d0215c38
term: add capability to print warnings *inside* the terminal
This is intended to be used to print e.g. deprecation warnings inside
the terminal, *before* the shell is started.
2020-07-29 19:42:12 +02:00
Daniel Eklöf
295083059c
Merge branch 'master' into diagonal-dpi 2020-07-28 20:01:56 +02:00
Daniel Eklöf
76350c568e
term: term_surface_kind(): recognize the scrollback indicator sub-surface 2020-07-26 12:37:12 +02:00
Daniel Eklöf
6e909d5cd3
term: use the monitors diagonal DPI value, instead of it's vertical PPI value 2020-07-26 07:45:55 +02:00
Daniel Eklöf
b08db1ef97
term: store current font DPI as a float instead of an integer
FontConfig's DPI is a double, and using a float instead of an integer
results in higher resolution.
2020-07-26 07:45:03 +02:00
Daniel Eklöf
c4679e474e
config: rename scrollback-indicator to scrollback-indicator-style
And turn it from a boolean to an enum. It can be set to:

* `none` - disables the indicator
* `static` - always rendered near the top of the window
* `moving` - position reflects the scrollback position
2020-07-25 14:31:45 +02:00
Daniel Eklöf
de75a2035e
Merge branch 'master' into pipe-grid-to-external-tool 2020-07-16 08:53:20 +02:00
Daniel Eklöf
7f6ed98a83
term: line-wrap: don't move cursor outside the grid
Remove assertion that row be less than the scrolling region end. The
cursor may in fact be *inside* the margin.

Inside the margin, content never scrolls, but we must make sure we
don't move the cursor outside the grid.
2020-07-16 08:47:37 +02:00
Daniel Eklöf
6f2cffd8c0
vt: never call term_print() with a width <= 0 2020-07-16 08:04:12 +02:00
Daniel Eklöf
69d9ff3f25
spawn: add optional stdin/stdout/stderr redirection FDs
If not -1, spawn() will redirect the child's stdin/stdout/stderr to
these FDs.
2020-07-15 13:33:56 +02:00
Daniel Eklöf
9cdccdd2ac
term: break out fork+exec functionality to a separate file 2020-07-15 12:39:10 +02:00
Daniel Eklöf
4d17423ed1
term: add term_scrollback_to_text() and term_view_to_text()
These functions extract the current view, or the entire scrollback as
an UTF-8 encoded byte buffer.
2020-07-15 11:33:37 +02:00
Max Hollmann
54e2b0b005 limit font size to non-negative values 2020-07-15 09:53:13 +02:00
Daniel Eklöf
2fa2c9fad4
term: print: don't pad with spacers if auto-margin is disabled 2020-07-15 08:04:51 +02:00
Daniel Eklöf
f962fb236e
term: copy current VT attributes to multi-column spacer cells
And refactor: break out spacer-writing code to a function, since we do
exactly the same thing in two places.
2020-07-14 20:24:52 +02:00
Daniel Eklöf
6d7aba3ea0
term: print: linewrap + insert *before* inserting SPACERS
Otherwise we end up overwriting the character in the last column
2020-07-14 17:03:20 +02:00
Daniel Eklöf
df2927e088
term: print: write special value CELL_MULT_COL_SPACER to extra cells
When printing a multi-column character, write CELL_MULT_COL_SPACER
instead of '0' to both padding cells (when character doesn't fit at
the end of the line), and to the cells following the actual character.
2020-07-14 16:49:11 +02:00
Daniel Eklöf
4cf7195695
selection: recognize empty padding cells in a forced linewrap
When printing a multi-column character at the end of the line, and it
doesn't fit, we currently insert a forced line-wrap. This means the
last character(s) on the previous line will be empty, followed by a
multi-column character in the first cell on the next line.

Without special code to handle this, the selection text extraction
code will insert a hard newline, since this is normally the correct
thing to do.

Add a TODO, to consider writing a special place holder value to these
padding cells.
2020-07-14 13:17:50 +02:00
Daniel Eklöf
7480c1c06b
term: remove assert, as we're already checking for this in the loop condition 2020-07-14 12:07:12 +02:00
Daniel Eklöf
b035469a7f
term: print: manually increment cursor column
We know we're within bounds, and thus we don't need the extra overhead
of term_cursor_right().
2020-07-14 12:05:24 +02:00
Daniel Eklöf
98ebb99be3
term: line-wrap: need to update grid->cur_row when we did *not* scroll 2020-07-14 12:01:00 +02:00
Daniel Eklöf
6ea9d1246f
term: print: also require width > 1 when checking if we need to force-wrap or not
While this might seem like it would slow down things, it should in
fact help the compiler optimize: the "normal" code path, that prints
regular ASCII characters, always call term_print() with width == 1.
2020-07-14 11:26:14 +02:00
Daniel Eklöf
b8c7dfba5c
term: line-wrap: manually set cursor row+col
line-wrap is in the hot path, and term_cursor_down/left adds
additional checks that we don't need.
2020-07-14 11:25:06 +02:00
Daniel Eklöf
9dc1d18241
term: print: force line-wrap if a multi-column character does not fit on current line 2020-07-14 10:58:57 +02:00
Daniel Eklöf
6faa9955ba
term: print: manually increment cursor column for multi-column chars
There's nothing wrong with using term_cursor_right(), but it is
unnecessary since we already check for the end-of-line.
2020-07-14 10:51:22 +02:00
Daniel Eklöf
ca7ec13f3b
term: insert: move assert() after checking whether insert mode is enabled or not 2020-07-14 10:50:38 +02:00
Daniel Eklöf
01c3a2635d
term: linefeed: explicitly clear LCF
LF should always clear LCF. Previously, it was done implicitly in
term_cursor_down(). I.e it was cleared as long as the cursor wasn't at
the bottom of the scrolling region
2020-07-14 10:49:44 +02:00
Daniel Eklöf
bbce760ab0
term: line-wrap: use term_cursor_{down,left} 2020-07-14 10:08:57 +02:00
Daniel Eklöf
b9719673a1
term: rename term_formfeed() -> term_carriage_return() 2020-07-14 09:29:10 +02:00
Daniel Eklöf
3958d84069
term: set_fonts: describe why we force resize 2020-07-13 15:01:09 +02:00
Daniel Eklöf
09bdf20aa0
render: keep lock while pushing dirty rows to worker queue
Instead of locking the queue for each dirty row we append, and
signaling a condition variable, just keep the lock while going through
the visible rows.

Release the lock once done.

Since we take the lock *before* posting the 'start' semaphore, all
workers will be waiting for the lock to be released.

Then, one at a time they'll get the lock and pick a row to
render. The queue will never get empty - when all rows have been
rendered, each worker will pick a 'frame done' "job" from the queue,
and break the rendering loop.
2020-07-13 13:27:23 +02:00
Daniel Eklöf
ab875c824a
term: update cursor on kbd focus changes, not visual focus changes 2020-07-11 11:14:32 +02:00
Daniel Eklöf
7d8974f930
term: remove term_has_kbd_focus(), use term->kbd_focus instead 2020-07-11 09:06:20 +02:00
Daniel Eklöf
8c72e9434e
term: cache kbd-focused state, just like we cache visual focus state
There's one difference however, when we receive a kbd unfocus call,
*all* seats must have us unfocused before we actually change the
state.
2020-07-11 09:04:46 +02:00
Daniel Eklöf
4e48d550ef
multi-seat: improve handling of multiple (mouse) pointers
* xcursor always set for all pointers
* xcursor sometimes not updated when it should be
* mouse grabbed state wasn't per seat, but global (i.e. "does at least
  one seat enable mouse grabbing")
* selection enabled state wasn't per seat
2020-07-09 09:52:11 +02:00