aboutsummaryrefslogtreecommitdiff
path: root/terminal.c (follow)
Commit message (Collapse)AuthorAgeLines
* term: update sixel rows/cols *after* cell dimension change, *before* resizeDaniel Eklöf2020-10-11-39/+27
| | | | | This fixes an issue where we resized+reflowed with bad rows/cols values in the sixels.
* term: re-calculate sixel images’ rows/cols values when cell size changesDaniel Eklöf2020-10-11-0/+14
|
* term: add term_damage_cursor() and term_damage_margins()Daniel Eklöf2020-10-11-0/+13
| | | | | | | | | 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.
* config: add mouse.alternate-scroll-mode optionDaniel Eklöf2020-09-15-0/+1
| | | | | This option controls the initial state of the Alternate Scroll Mode, and defaults to ‘enabled’.
* term: enqueue data: cleanupDaniel Eklöf2020-08-25-14/+8
|
* selection: block non-paste data from being sent to client while pastingDaniel Eklöf2020-08-25-47/+112
| | | | | | | | | | 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.
* don't use empty struct initializersDaniel Eklöf2020-08-23-9/+9
|
* input: don't crash on mouse motion events on the render timer surfaceDaniel Eklöf2020-08-14-1/+3
|
* Convert most dynamic allocations to use functions from xmalloc.hCraig Barnes2020-08-08-8/+13
|
* Replace GCC "unused" and "format" attributes with portable macrosCraig Barnes2020-08-07-1/+1
|
* term: remove unusued 'damage' listDaniel Eklöf2020-08-04-4/+2
|
* config: add 'hide-when-typing'Daniel Eklöf2020-07-31-9/+14
| | | | | | 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.
* user-notification: 'productify' the user-warning systemDaniel Eklöf2020-07-30-1/+1
| | | | | | | | * 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.
* term: add capability to print warnings *inside* the terminalDaniel Eklöf2020-07-29-1/+2
| | | | | This is intended to be used to print e.g. deprecation warnings inside the terminal, *before* the shell is started.
* Merge branch 'master' into diagonal-dpiDaniel Eklöf2020-07-28-1/+3
|\
| * term: term_surface_kind(): recognize the scrollback indicator sub-surfaceDaniel Eklöf2020-07-26-0/+2
| |
| * config: rename scrollback-indicator to scrollback-indicator-styleDaniel Eklöf2020-07-25-1/+1
| | | | | | | | | | | | | | | | 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
* | term: use the monitors diagonal DPI value, instead of it's vertical PPI valueDaniel Eklöf2020-07-26-3/+3
| |
* | term: store current font DPI as a float instead of an integerDaniel Eklöf2020-07-26-11/+11
|/ | | | | FontConfig's DPI is a double, and using a float instead of an integer results in higher resolution.
* Merge branch 'master' into pipe-grid-to-external-toolDaniel Eklöf2020-07-16-7/+9
|\
| * term: line-wrap: don't move cursor outside the gridDaniel Eklöf2020-07-16-4/+7
| | | | | | | | | | | | | | | | 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.
| * vt: never call term_print() with a width <= 0Daniel Eklöf2020-07-16-2/+1
| |
| * limit font size to non-negative valuesMax Hollmann2020-07-15-1/+1
| |
* | spawn: add optional stdin/stdout/stderr redirection FDsDaniel Eklöf2020-07-15-1/+2
| | | | | | | | | | If not -1, spawn() will redirect the child's stdin/stdout/stderr to these FDs.
* | term: break out fork+exec functionality to a separate fileDaniel Eklöf2020-07-15-53/+3
| |
* | term: add term_scrollback_to_text() and term_view_to_text()Daniel Eklöf2020-07-15-0/+58
|/ | | | | These functions extract the current view, or the entire scrollback as an UTF-8 encoded byte buffer.
* term: print: don't pad with spacers if auto-margin is disabledDaniel Eklöf2020-07-15-1/+1
|
* term: copy current VT attributes to multi-column spacer cellsDaniel Eklöf2020-07-14-9/+14
| | | | | And refactor: break out spacer-writing code to a function, since we do exactly the same thing in two places.
* term: print: linewrap + insert *before* inserting SPACERSDaniel Eklöf2020-07-14-3/+4
| | | | Otherwise we end up overwriting the character in the last column
* term: print: write special value CELL_MULT_COL_SPACER to extra cellsDaniel Eklöf2020-07-14-12/+9
| | | | | | 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.
* selection: recognize empty padding cells in a forced linewrapDaniel Eklöf2020-07-14-0/+10
| | | | | | | | | | | | | | 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.
* term: remove assert, as we're already checking for this in the loop conditionDaniel Eklöf2020-07-14-1/+0
|
* term: print: manually increment cursor columnDaniel Eklöf2020-07-14-3/+4
| | | | | We know we're within bounds, and thus we don't need the extra overhead of term_cursor_right().
* term: line-wrap: need to update grid->cur_row when we did *not* scrollDaniel Eklöf2020-07-14-0/+1
|
* term: print: also require width > 1 when checking if we need to force-wrap or notDaniel Eklöf2020-07-14-1/+3
| | | | | | 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.
* term: line-wrap: manually set cursor row+colDaniel Eklöf2020-07-14-3/+7
| | | | | line-wrap is in the hot path, and term_cursor_down/left adds additional checks that we don't need.
* term: print: force line-wrap if a multi-column character does not fit on current lineDaniel Eklöf2020-07-14-0/+6
|
* term: print: manually increment cursor column for multi-column charsDaniel Eklöf2020-07-14-2/+2
| | | | | There's nothing wrong with using term_cursor_right(), but it is unnecessary since we already check for the end-of-line.
* term: insert: move assert() after checking whether insert mode is enabled or notDaniel Eklöf2020-07-14-2/+2
|
* term: linefeed: explicitly clear LCFDaniel Eklöf2020-07-14-0/+2
| | | | | | 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
* term: line-wrap: use term_cursor_{down,left}Daniel Eklöf2020-07-14-4/+4
|
* term: rename term_formfeed() -> term_carriage_return()Daniel Eklöf2020-07-14-1/+1
|
* term: set_fonts: describe why we force resizeDaniel Eklöf2020-07-13-0/+1
|
* render: keep lock while pushing dirty rows to worker queueDaniel Eklöf2020-07-13-9/+0
| | | | | | | | | | | | | | | | 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.
* term: update cursor on kbd focus changes, not visual focus changesDaniel Eklöf2020-07-11-2/+2
|
* term: remove term_has_kbd_focus(), use term->kbd_focus insteadDaniel Eklöf2020-07-11-17/+5
|
* term: cache kbd-focused state, just like we cache visual focus stateDaniel Eklöf2020-07-11-2/+11
| | | | | | There's one difference however, when we receive a kbd unfocus call, *all* seats must have us unfocused before we actually change the state.
* multi-seat: improve handling of multiple (mouse) pointersDaniel Eklöf2020-07-09-31/+24
| | | | | | | | * 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
* focus in/out: terminal checks whether it is a state change or notDaniel Eklöf2020-07-09-2/+4
|
* input: only call term_kbd_focus_{in,out}() on actual state changeDaniel Eklöf2020-07-09-0/+4
| | | | | | That is, only call term_kbd_focus_in() if we're the *first* seat focusing that terminal, and only call term_kbd_focus_out() if we're the *last* seat that focused it.
* multi-seat: re-enable mouse button+motion reporting supportDaniel Eklöf2020-07-08-29/+22
|
* multi-seat: enable xcursor theme support againDaniel Eklöf2020-07-08-8/+13
|
* wip: multi-seat supportDaniel Eklöf2020-07-08-13/+36
| | | | | Compiles and runs, but mouse, clipboard and other things have been disabled.
* term: don't use deprecated fcft_size_adjust()Daniel Eklöf2020-07-07-97/+67
| | | | | | | | | | | | | | | | | | | | | | | | | When resizing the font on-the-fly, we now do a complete font-reload (this is basically what fcft_size_adjust() did anyway). To get the correct size, we maintain the current size ourselves. We get the initial size from the user-provided font pattern, by converting the string to an FcPattern, and using FcPatternGet() to retrieve both the FC_SIZE and FC_PIXEL_SIZE attributes. These attributes are then removed from the pattern, and the pattern is converted back to a string. The terminal struct maintains a copy of the font sizes. These are initially set to the sizes from the config. When the user resizes the font, the terminal-local sizes are adjusted. To ensure the primary and user-configured fallback fonts are resizes equally much, convert any pixel sizes to point sizes at this point. When the font size is reset, we reload the font sizes from the config (thus once again returning actual pixel-sizes, if that's what the user has configured).
* config: add 'blink' option to cursor section in footrcDaniel Eklöf2020-06-30-1/+2
| | | | | This option controls whether the default cursor should blink or not. The default is to *not* blink.
* Merge branch 'master' into sixel-performanceDaniel Eklöf2020-06-29-4/+27
|\
| * sixel: destroy all sixels when font size is decreasedDaniel Eklöf2020-06-29-1/+24
| | | | | | | | | | | | If changing the font size causes the cell size to decrease, either horizontally or vertically (or both), then delete all sixels since the grid space they allocated no longer is enough to hold the images.
| * term: use 'left_ptr' instead of 'hand2' as cursor when client is mouse grabbingDaniel Eklöf2020-06-29-3/+3
| |
* | scroll: destroy scrolled out sixels before scroll is appliedDaniel Eklöf2020-06-29-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | The logic that breaks out of sixel loops does not work for rows that has already wrapped around. Thus, we need to destroy sixels that are about to be scrolled out *before* we actually scroll. Since this is the *only* time we destroy sixels (instead of overwriting it), rename the sixel functions. And, since they now do a very specific thing, they can be greatly simplified (and thus faster).
* | sixel: overwrite: pass 'width' to sixel_overwrite_at_cursor()Daniel Eklöf2020-06-28-1/+1
|/ | | | This is necessary to handle multi-column characters correctly.
* sixel: split -> overwriteDaniel Eklöf2020-06-27-5/+6
|
* term: erasing characters now splits sixels instead of deleting themDaniel Eklöf2020-06-27-6/+4
|
* sixel: delete/split: early(ier) exit when there aren't in sixel imagesDaniel Eklöf2020-06-27-1/+4
| | | | Avoid unnecessary wrap checks if the sixel image list is empty.
* sixel: wip: split up image being overwritten, rather than erasing itDaniel Eklöf2020-06-23-1/+2
| | | | | | | | | | Instead of completely erasing a sixel image when it is being "overwritten" (text is printed somewhere within the image, or another sixel image is emitted within the first image), split it up into up to four pieces: 'above', 'below', 'to-the-left' and 'to-the-right'. This is currently very un-optimized, but seems to produce correct results.
* term: reset: set title to the user configured title, not "foot"Daniel Eklöf2020-06-22-2/+1
|
* term: ptmx: don't abort on EAGAIN when trying to read from ptxmDaniel Eklöf2020-06-19-0/+3
|
* sixel: do not reset palette after each imageDaniel Eklöf2020-06-10-0/+1
| | | | | | | | A client can re-use the palette between images. Resetting the palette breaks this. Now we initialize the palette on demand, and resets it when the palette size is changed (by the client).
* term: print_insert: early returnDaniel Eklöf2020-06-09-11/+12
|
* term: set an initial TIOCSWINSZ right after opening the ptyDaniel Eklöf2020-06-02-0/+8
| | | | | | | | Since foot is pretty aggressive about spawning the client early, it was possible for a fast client to read a 0x0 terminal size. Not all clients coped well. Closes #20.
* term: don't double fork new terminal windowsDaniel Eklöf2020-05-21-50/+43
| | | | | Instead, register their PIDs with the new reaper module and let it handle them.
* selection: handle viewport wrap around correctlyDaniel Eklöf2020-05-19-45/+26
| | | | | When the viewport wraps around, the selection points may be "incorrect".
* term: scrolling: calling function must clamp scroll amountDaniel Eklöf2020-05-19-4/+4
|
* term: erase_cell_range: set row->dirty before calling memset()Daniel Eklöf2020-05-17-2/+2
|
* term: scrolling: mark selection top if-statement as 'unlikely'Daniel Eklöf2020-05-17-4/+4
|
* term: scrolling: hopefully fix all selection/scrolling related crashesDaniel Eklöf2020-05-17-5/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When scrolling, there are a couple of cases where an existing selection must be canceled because we cannot meaningfully represent it after scrolling. These are when the selection is (partly) inside: * The top scrolling region * The bottom scrolling region * The new lines scrolled in. I.e. re-used lines For the scrolling regions, the real problem is when the selection crosses the scrolling region boundary; a selection that is completely inside a scrolling regions _might_ be possible to keep, but we would need to translate the selection coordinates to the new scrolling region lines. For simplicity, we cancel the selection if it touches the scrolling region. Period. The last item, newly scrolled in lines is when the selection covers very old lines and we're now wrapping around the scrollback history. Then there's a fourth problem case: when the user has started a selection, but hasn't yet moved the cursor. In this case, we have no end point. What's more problematic is that when the user (after scrolling) moves the cursor, we try to create a huge selection that covers mostly empty (NULL) rows, causing us to crash. This can happen e.g. when reverse scrolling in such a way that we wrap around the scrollback history. The actual viewport in this case is something like `-n - m`. But the selection we'll end up trying to create will be `m - (rows - n)`. This range may very well contain NULL rows. To deal with this, we simply cancel the selection.
* term: scrolling: sixel: simplify now that row count is clampedDaniel Eklöf2020-05-17-2/+2
|
* term: scrolling: in debug builds, verify all rows are allocatedDaniel Eklöf2020-05-16-0/+10
|
* term: scrolling: simplify, now that scroll row count is clampedDaniel Eklöf2020-05-16-11/+5
|
* term: scrolling: clamp number of rows to number of rows in scrolling regionDaniel Eklöf2020-05-16-12/+4
|
* grid: swap_row: remove unused parameter 'initialize'Daniel Eklöf2020-05-16-4/+4
|
* term: scrolling: clear selection *before* scrollingDaniel Eklöf2020-05-16-12/+15
| | | | | | | | | | | | We normally don't clear the selection when scrolling. The exception is when the selection covers re-used rows. I.e. rows that we scroll in and clear. In this case we cancel the selection (we _could_ modify it and keep as much as possible and only remove the re-used rows...). We must do this *before* scrolling, since scrolling will swap rows (when there's a scrolling region). When this happens, the selection is "corrupted", and canceling it afterwards will not work.
* selection: on_row_in_view() -> on_rows_in_view(), and now takes a rangeDaniel Eklöf2020-05-16-10/+12
| | | | | This allows us to check the selection once when scrolling, instead of once for each scrolled in line.
* Revert "term: print: line-wrap multi-column characters instead of cutting them in half"Daniel Eklöf2020-05-09-5/+3
| | | | | | | This reverts commit 8448296bb3c0fa96f5af5cb7ec563bb0c7e99093. Applications need to be multi-column character aware anyway, and they should deal with this.
* term: print: line-wrap multi-column characters instead of cutting them in halfDaniel Eklöf2020-05-09-3/+5
|
* term: don't register ptmx with FDM if we're shutting downDaniel Eklöf2020-05-04-2/+4
| | | | | This can happen when there's an error instantiating the terminal *after* we've spawned the slave process.
* term: set 'is_shutting_down' before calling term_destroy() on errorDaniel Eklöf2020-05-04-0/+1
|
* term: check return value when instantiating thread synchronization primitivesDaniel Eklöf2020-05-04-4/+25
|
* term: thrd_success isn't necessarily 0Daniel Eklöf2020-05-03-3/+3
|
* thrd_create(): handle errors correctlyDaniel Eklöf2020-05-03-13/+31
| | | | | | * Detect thrd_create() failures in all places where we instantiate threads * Log error correctl; thrd_create() does not return an errno value
* unicode-combining: store seen combining chains "globally" in the term structDaniel Eklöf2020-05-03-4/+4
| | | | | | | | | | | | | | | | | | | | Instead of storing combining data per cell, realize that most combinations are re-occurring and that there's lots of available space left in the unicode range, and store seen base+combining combinations chains in a per-terminal array. When we encounter a combining character, we first try to pre-compose, like before. If that fails, we then search for the current base+combining combo in the list of previously seen combinations. If not found there either, we allocate a new combo and add it to the list. Regardless, the result is an index into this array. We store this index, offsetted by COMB_CHARS_LO=0x40000000ul in the cell. When rendering, we need to check if the cell character is a plain character, or if it's a composed character (identified by checking if the cell character is >= COMB_CHARS_LO). Then we render the grapheme pretty much like before.
* unicode-combine: remove utf8proc dependencyDaniel Eklöf2020-05-02-1/+1
| | | | | | | | | | | | We only used utf8proc to try to pre-compose a glyph from a base and combining character. We can do this ourselves by using a pre-compiled table of valid pre-compositions. This table isn't _that_ big, and binary searching it is fast. That is, for a very small amount of code, and not too much extra RO data, we can get rid of the utf8proc dependency.
* unicode-combining: completely remove unicode combining characters when feature is disabledDaniel Eklöf2020-05-01-0/+3
|
* render: render combining charactersDaniel Eklöf2020-05-01-1/+1
| | | | | | | | | | | | | | | | | This is basically just a loop that renders additional glyphs on top off the base glyph. Since we now need access to the row struct, for the combining characters, the function prototype for 'render_cell()' has changed. When rendering the combining characters we also need to deal with broken fonts; some fonts use positive offsets (as if the combining character was a regular character), while others use a negative offset (to be used as if you had already advanced the pen position). We handle both - a positive offset is rendered just like a regular glyph. When we see a negative offset we simply add the width of a cell first.
* term: print: reset combining characters for this cellDaniel Eklöf2020-05-01-0/+1
| | | | | | | | | | | This is the *only* place combining characters are reset. In particular, we do *not* reset them in a normal cell erase. This is a performance design decision - clearing the combining characters in erase is way too slow. This way, we clear it only when we *have* to. Anything looking at the combining characters must first ensure the base character is not 0.
* util.h: new header file defining commonly used macrosDaniel Eklöf2020-05-01-4/+1
|
* term: don't enable ptmx FDM callback until Wayland window has been configuredDaniel Eklöf2020-04-30-4/+21
| | | | | | | | | | | | | The way things works right now, we cannot enable the ptmx FDM callback right away. We need to wait for the Wayland window to have been configured. Before the window is configured, we don't have a size, and no grid. Thus, if we try to process ptmx data we'll crash since we have no where to write it to. So, registering the ptmx fd with the FDM is now delayed until we've received the first 'configure' event from Wayland.
* term: start slave before loading fonts and starting rendering threadsDaniel Eklöf2020-04-30-8/+9
| | | | | This allows the client to load in parallel with our font loading, which should improve startup time.
* term: font size adjust: re-load fonts in parallelDaniel Eklöf2020-04-29-9/+30
|
* term: destroy: handle rendering threads not being initializedDaniel Eklöf2020-04-29-11/+15
| | | | | We sort of already did this. However, we did not handle the case where the thread array itself hadn't yet been allocated.
* term: initialize rendering worker threads after instantiating fontsDaniel Eklöf2020-04-29-3/+2
| | | | | | This ensures the resources (e.g. stack) used by the transient threads used to load the primary fonts can be re-used by the rendering worker threads.