aboutsummaryrefslogtreecommitdiff
path: root/terminal.c (follow)
Commit message (Collapse)AuthorAgeLines
* Send text_input_rectangle requests for text-inputTadeo Kondrak2021-01-29-0/+16
|
* terminal: fix encoding of mouse buttons 6 and 7 in mouse eventsDaniel Eklöf2021-01-26-5/+1
| | | | | | | | | | | | | | | | | These two buttons were encoded using the *exact* same numbers as button 4 and 5 (scroll wheel up/down), making it impossible to distinguish them. The relevant section from XTerm’s control sequences documentation is: Some wheel mice can send additional button events, e.g., by tilting the scroll wheel left and right. Additional buttons are encoded like the wheel mice, o by adding 64 (for buttons 6 and 7), or o by adding 128 (for buttons 8 through 11).
* terminal: add/exclude missing headersJan Beich2021-01-23-0/+3
| | | | | | | | | | | | terminal.c:3:10: fatal error: 'malloc.h' file not found #include <malloc.h> ^~~~~~~~~~ terminal.c:1512:9: error: implicit declaration of function 'sigaction' is invalid in C99 [-Werror,-Wimplicit-function-declaration] sigaction(SIGALRM, &(const struct sigaction){.sa_handler = &sig_alarm}, NULL); ^ terminal.c:1532:21: error: implicit declaration of function 'kill' is invalid in C99 [-Werror,-Wimplicit-function-declaration] kill(term->slave, kill_signal); ^
* term: remove client application’s pid from reaper when shutting downDaniel Eklöf2021-01-21-0/+3
| | | | | | | | | | When we are shutting down the terminal, we explicitly wait for the child application to terminate (with a timeout, after which the child process is killed). I.e. there’s no need to let the reaper handle it. In fact, doing so leads to a crash since we will have destroyed (and thus free:d) the terminal instance when the reaper callback is called.
* terminal: reaper callback: don’t close ptmx if already closedDaniel Eklöf2021-01-21-2/+5
|
* terminal: shutdown (or --hold) when the client process terminatesDaniel Eklöf2021-01-21-6/+19
| | | | | | | | | Shutdown the terminal when the client process terminates, not when the ptmx file descriptor is closed. This fixes an issue where the terminal remains running after the client process has terminated, if it spawned child processes that inherited the ptmx file descriptor.
* term: fix builds with debug logging enabledDaniel Eklöf2020-12-20-1/+1
| | | | DPI_AWARE_ON has been renamed to DPI_AWARE_YES
* fonts: size fonts using the scaling factor when output scaling is enabledDaniel Eklöf2020-12-17-16/+47
| | | | | | | | | | | | | | | | | | | This extends the new ‘dpi-aware’ option with a new default value, ‘auto’. When set to ‘auto’, fonts are sized using monitors’ DPI when output scaling is disabled. When output scaling is enabled, fonts are instead sized using the scaling factor. The reasoning here is that a user that has enabled output scaling is obviously *not* relying on DPI scaling. Output scaling can also be a way to compensate for different viewing distances, in which case we do *not* want to break that by using DPI scaling. Users can still force DPI-only font sizing by setting ‘dpi-aware=yes’, or disable it completely by setting ‘dpi-aware=no’.
* term: enabling application synchronized updates clear pending grid refreshDaniel Eklöf2020-12-14-9/+13
| | | | | | | | | | | This fixes issues with de-synchronized frames being rendered; we may have scheduled a redraw earlier, that hasn’t yet triggered (probably because we’re waiting for a frame callback), when we enable application synchronized updates. This means we risk rendering a partially updated state when the frame callback finally arrives, if the application hasn’t yet ended its synchronized update.
* config: add ‘notify’ to possible values for ‘bell’ in foot.iniDaniel Eklöf2020-12-10-5/+20
| | | | | When `bell=notify`, foot will trigger a desktop notification when it receives a BEL in an unfocused window.
* ime: store wchar version of pre-edit string in terminal structDaniel Eklöf2020-12-07-0/+2
|
* codespell: currenly -> currently, second instanceDaniel Eklöf2020-12-07-1/+1
|
* codespell: currenly -> currentlyDaniel Eklöf2020-12-07-1/+1
|
* ime: add functions to enable/disable IME, simplify code that enables IMEDaniel Eklöf2020-12-07-6/+68
| | | | | | | | | | | | | | | | | We may want to be able to enable/disable IME run-time, even though we have received an ‘enter’ IME event. This enables us to do that. Also add functions to enable/disable IME on a per-terminal instance basis. A terminal may have multiple seats focusing it, and enabling/disabling IME in a terminal instance enables/disables IME on all those seats. Finally, the code to enable IME is simplified; the *only* surface that can ever receive ‘enter’ IME events is the main grid. All other surfaces are sub-surfaces, without their own keyboard focus.
* ime: make IME compile-time optionalDaniel Eklöf2020-12-07-4/+14
|
* ime: render pre-edit textDaniel Eklöf2020-12-07-0/+9
| | | | | | | | | | | | | | This is done by allocating cells for the pre-edit text when receiving the text-input::done() call, and populating them by converting the utf-8 formatted pre-edit text to wchars. We also convert the pre-edit cursor position to cell positions (it can cover multiple cells). When rendering, we simply render the pre-edit cells on-top off the regular grid. While doing so, we also mark the underlying, “real”, cells as dirty, to ensure they are re-rendered when the pre-edit text is modified or removed.
* csi: add new private mode that makes the Escape key emit "\E[27;1;27~"Craig Barnes2020-11-29-0/+1
| | | | | | | | | | This mode can be set by client programs with the DECSET, DECRST, XTSAVE and XTRESTORE sequences by using 27127 as the parameter. The sequence "\E[27;1;27~" is encoded in the same way as is done by xterm's "modifyOtherKeys" mode. Even though xterm itself never emits such a sequence for the Escape key, many programs already have support for parsing this style of key sequence.
* term: remove read-only properties copied from the configDaniel Eklöf2020-11-26-47/+32
| | | | Use the config directly instead.
* sixel: change default max size to 10000x10000Daniel Eklöf2020-11-23-0/+2
| | | | | It used to be the size of the window. This caused images to be cropped when the application emitting them didn’t change the max size.
* pgo: feed VT data through fdm_ptmx(), not vt_from_slave()Daniel Eklöf2020-11-22-1/+3
| | | | | | | | | | | | | | | | | fdm_ptmx(), the FDM callback handler for ptmx data, is just as much in the hot path as vt_from_slave(). It is also slightly more complicated than a read() followed by a call to vt_from_slave(). As a result, some benchmarks performed significantly worse in a partial PGO build than in a full PGO build, since fdm_ptmx() wasn’t PGO:d. To be able to feed data through fdm_ptmx(), we need to set up the delayed rendering timer FDs, configure the timeout values, and provide a readable FD it can read the VT data from. The latter is done with a memory FD. This ensures *all* VT data is loaded into memory before we feed it to the parser.
* terminal: use 96, not 75, for DPI when being DPI unawareDaniel Eklöf2020-11-19-4/+4
|
* config: add ‘dpi-aware’ option, defaulting to enabledDaniel Eklöf2020-11-19-11/+61
| | | | | | | | | | When disabled, foot no longers uses outputs’ DPI to scale the font. Instead, it uses the outputs’ scaling factor. That is, instead of appending “:dpi=123” to the fontconfig string, modify the “:pixelsize” or “:size” attribute. Closes #206
* csi: implement “CSI ? 1035” - toggle Num Lock overrideDaniel Eklöf2020-11-11-0/+1
| | | | | This adds a num_lock_modifier state to the terminal, and hooks up “CSI?1035h/l” to toggle it.
* tiocswinsz: fix compilation error on e.g. ppc64Daniel Eklöf2020-10-29-1/+1
| | | | | | | | | | | | | | | | | | | | | | | On some platforms, TIOCSWINSZ has a very large value, > 0x80000000. On some platforms, the `request` argument to `ioctl(3)` is an `int`. For platforms where both of the above is true, gcc will warn (and error out if compiled with `-Werror`) on: ioctl(fd, TIOCSWINSZ, ...) To silence this warning, we need to cast `TIOCSWINSZ` to an integer. However, doing this on platforms where `request` is an `unsigned long` will result in `TIOCSWINSZ` being sign-extended (and thus we end up with an invalid value). It seems that casting to `unsigned int` works in both cases; it silences the long -> int conversion warning, while also preserving the correct value in all cases.
* config: add font-bold, font-italic and font-bold-italic optionsDaniel Eklöf2020-10-20-50/+102
| | | | | | | | | | These options lets the user configure custom fonts and styles, to use with the bold and italic cell attributes. By default, they are unset, meaning we use the bold/italic variants of the regular font. Closes #169.
* term: reset: enable/disable cursor blink depending on user configurationDaniel Eklöf2020-10-13-1/+4
|
* term: reset: kill blink timerDaniel Eklöf2020-10-13-0/+1
|
* term: remove unneeded blink.active fieldDaniel Eklöf2020-10-13-3/+0
| | | | We now use the timer FD instead; if it is -1, blinking is not active.
* term: instantiate cursor blink timer on-demandDaniel Eklöf2020-10-13-9/+21
|
* term: create/destroy blink timer on-demandDaniel Eklöf2020-10-13-15/+21
| | | | | | | | Blinking text is uncommon. It doesn’t make that much sense to keep a timer opened (but unarmed) at all times. This patch makes it so the timer is instantiated on-demand, and destroyed again when it no longer is needed.
* term: subpixel changed: fix build with LOG_ENABLE_DBG=1Daniel Eklöf2020-10-13-6/+6
|
* Merge branch 'scroll-up-down-while-selecting' into masterDaniel Eklöf2020-10-12-0/+6
|\ | | | | | | Closes #149
| * selection: auto-scroll: selection keeps scrolling while mouse is outside gridDaniel Eklöf2020-10-11-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Moving the mouse outside the grid while we have an on-going selection now starts a timer. The interval of this timer depends on the mouse’s distance from the grid - the further away the mouse is, the shorter interval. On each timer timeout, we scroll one line, and update the selection. Thus, the shorter the interval, the faster we scroll. The timer is canceled as soon as the mouse enters the grid again, or the selection is either canceled or finalized. The timer FD is created and destroyed on-demand. Most of the logic is now in selection.c. The exception is the calculation of the timer interval, which depends on the mouse’s position. Thus, this is done in input.c. The scroll+selection update logic needs to know a) which direction we’re scrolling in, and b) which *column* the selection should be updated with. If the mouse is outside the grid’s left or right margins, the stored mouse column will be -1. I.e. we don’t know whether the mouse is on the left or right side of the grid. This is why the caller, that starts the timer, must provide this value. The same applies to top and bottom margins, but since we already have the scroll *direction*, which row value to use can be derived from this.
* | csi: implement ‘CSI ? 1042 h/l’ - enable/disable bell-is-urgentDaniel Eklöf2020-10-11-1/+2
|/
* term: update sixel rows/cols *after* cell dimension change, *before* resizeDaniel Eklöf2020-10-09-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-09-0/+14
|
* bell: optionally render margins in red when receiving BELDaniel Eklöf2020-10-08-0/+17
| | | | | | | | | | | Add anew config option, ‘bell=none|set-urgency’. When set to ‘set-urgency’, the margins will be painted in red (if the window did not have keyboard focus). This is intended as a cheap replacement for the ‘urgency’ hint, that doesn’t (yet) exist on Wayland. Closes #157
* term: cursor-left: unlikely -> likely for reverse-wrapDaniel Eklöf2020-10-06-1/+1
| | | | | Since reverse wrap-around is enabled by default, we’re *likely* to take this branch.
* term: enable reverse wrap-around by defaultDaniel Eklöf2020-10-06-0/+2
| | | | | Since we’re now doing reverse auto-wrapping by default, we add ‘bw’ (‘auto_left_margin’)to terminfo.
* term: cursor-left: don’t do reverse-wrapping unless auto-margins are enabledDaniel Eklöf2020-10-03-1/+1
| | | | This matches XTerm’s behavior.
* term: cursor-left: reverse-wrap when cursor is at the left marginDaniel Eklöf2020-10-02-3/+38
| | | | Assuming the private mode ‘reverse-wrap’ has been enabled.
* Revert "term: cursor-left: reduce move count by one when lcf=true"Daniel Eklöf2020-10-02-5/+0
| | | | | | | This reverts commit 02e3e4ac9b2703a0a867211c2482eab257cbc311. This broke at least Emacs. Cursor movement at the margins *is* undefined, and the behavior we’re now reverting to matches XTerm.
* term: cursor-left: reduce move count by one when lcf=trueDaniel Eklöf2020-10-01-0/+5
| | | | | | | | | | | | 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.
* term: add term_damage_cursor() and term_damage_margins()Daniel Eklöf2020-09-29-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).