aboutsummaryrefslogtreecommitdiff
path: root/terminal.c (follow)
Commit message (Collapse)AuthorAgeLines
...
* term: reset: don't access rows directlyDaniel Eklöf2019-11-29-2/+2
| | | | | | | We've just re-set the grid offsets, meaning rows 0..term->rows may not all have been initialized. Call grid_row_and_alloc() to ensure they are.
* term: xcursor: use 'hand2' instead of 'left_ptr' when mouse trackingDaniel Eklöf2019-11-29-13/+5
| | | | | Mouse tracking always reports clicks, so using a cursor that suggests you can click makes sense I think.
* term: xcursor cleanupDaniel Eklöf2019-11-29-4/+11
| | | | | | | | | | Show 'text' cursor when: * we have no mouse tracking enabled * forced selection has been enabled (shift being held down) * We're *not* scrollback searching In all other cases, show the 'left_ptr' cursor.
* terminal: use the 'text' xcursor pointer whenever selection is possibleDaniel Eklöf2019-11-28-0/+14
|
* async: first synchronous write may succeed partiallyDaniel Eklöf2019-11-28-2/+3
| | | | | | | | | When trying to write (to e.g. the slave, or to a clipboard receiver), we first try to send the data synchronously, and only if that fails do we switch to asynchronous mode. However, the first synchronous may (in fact, is likely to) succeed partially.
* font: pass dpi=96 to fontconfigDaniel Eklöf2019-11-26-4/+4
| | | | TODO: use actual output PPI. Question is *which* output...
* font: move metrics from terminal struct to font structDaniel Eklöf2019-11-26-17/+2
|
* term: shutdown: handle *not* being unmappedDaniel Eklöf2019-11-21-0/+14
| | | | | | | | | | When we're shutting down a terminal, we destroy our Wayland window, and assume that will unmap us. There are cases when this isn't true (most likely when e.g. a screen locker is active, and the unmap is being deferred). Handle by explicitly setting focused to NULL.
* fonts: use 'weight' and 'slant', not 'style' when loading fontsDaniel Eklöf2019-11-19-3/+3
|
* term: report_mouse_click(): legacy mode only supports rows/cols up to 223.Daniel Eklöf2019-11-18-2/+8
| | | | | | In the legacy mouse reporting mode, line and column numbers are limited to 223 (255-32). In case the current coordinate falls outside this, simply ignore it (don't report it).
* term: assert(false) on MOUSE_X10Daniel Eklöf2019-11-18-3/+15
| | | | | This mouse mode is never enabled. I.e. we don't support it. Add asserts to catch usage of it, should we ever decide to implement it.
* term: try to improve on a performance regressionDaniel Eklöf2019-11-17-17/+7
| | | | | | | | When support was added for DECOM (absolute/relative row addressing), a small but noticeable (~3.5%) performance regression was introduced. Try to improve the situation by simplifying the relative-to-absolute conversion; only the row needs to be transformed.
* Revert "term: new function: term_autowrap()"Daniel Eklöf2019-11-17-15/+0
| | | | This reverts commit 686405b7031736445eeb35206e4a797a8dd78d91.
* term: new function: term_autowrap()Daniel Eklöf2019-11-17-0/+15
| | | | | | | Adds a linebreak (+ scroll if necessary) if we're in a deferred wrap and auto-margins are enabled. Return true when we wrapped, false otherwise.
* term: save/restore charsets on save/restore cursor+attributesDaniel Eklöf2019-11-17-0/+1
|
* term: move charset variables into an anonymous structDaniel Eklöf2019-11-17-5/+5
|
* term: restore_cursor: restore lcf flagDaniel Eklöf2019-11-17-0/+1
|
* term: move lcf flag into 'cursor' structDaniel Eklöf2019-11-17-4/+4
|
* term: add struct cursorDaniel Eklöf2019-11-17-23/+23
|
* term: rename: print_needs_wrap -> lcf (Last Column Flag)Daniel Eklöf2019-11-17-4/+4
|
* term: cursor_{up,down}: limit cursor movements based on origin modeDaniel Eklöf2019-11-16-2/+8
|
* term: add tab-stop list to terminal structDaniel Eklöf2019-11-16-0/+2
| | | | This list is intended to store tab stop columns
* csi: implement DECOM - switch cursor origin between absolute and relativeDaniel Eklöf2019-11-05-0/+32
| | | | | | | | | | | The default is absolute mode, where 0,0 is the upper left corner of the screen. In relative mode, the origin is relative the top scroll margin. Internally, we always track the current cursor position in absolute mode. Every time we the client *sets* or *queries* the cursor position in relative mode, we translate it to absolute.
* terminal: ptmx: ignore *both* EPOLLIN and EPOLLOUT on EPOLLHUPDaniel Eklöf2019-11-05-5/+11
|
* terminal: use async_write() when writing to ptmxDaniel Eklöf2019-11-04-50/+20
|
* selection: send primary/clipboard data asynchronouslyDaniel Eklöf2019-11-04-0/+1
| | | | TODO: try writing synchronously first
* terminal: add comments describing the sync/async writing modesDaniel Eklöf2019-11-04-1/+25
|
* terminal: malloc_trim() is a GNU extensionDaniel Eklöf2019-11-03-0/+4
|
* terminal: trim memory after free:ing a terminalDaniel Eklöf2019-11-03-0/+3
| | | | | | | | | | | | | A terminal with lots of scrollback history will have allocated a lot of memory. Normally, free() wont return this memory to the OS, and we don't seem to trigger the automatic trim calls. This means the server would accumulate quite a lot of memory over time, as terminals come and go. Now we explicitly trim the memory every time a terminal is destroyed.
* terminal: ptmx fdm handler: tag unlikely branchesDaniel Eklöf2019-11-03-3/+3
|
* terminal: comments and cleanupDaniel Eklöf2019-11-03-0/+9
|
* terminal: cleanup asynchronous ptmx output handlingDaniel Eklöf2019-11-03-37/+41
| | | | | Break out actual writing to a separate function, and call this function both from the synchronous and the asynchronous code paths.
* term: asynchronous writes to slaveDaniel Eklöf2019-11-03-21/+98
| | | | | | | | | | Make ptmx non-blocking. Then, when writing data to the slave would have blocked, use the FDM to asynchronously write the remaining data. This is done by enabling EPOLLOUT on ptmx, and enqueueing all outgoing data. The FDM handler will go through the enqueued data, and once all of it has been written, we turn off EPOLLOUT again (thus switching back to synchronous writes)
* Rename: vt_to_slave() -> term_to_slave()Daniel Eklöf2019-11-02-3/+23
|
* misc: fdm already logs failuresDaniel Eklöf2019-11-02-18/+4
|
* terminal: don't get stuck waiting for misbehaving slaves to terminateDaniel Eklöf2019-11-02-4/+64
| | | | | | | | | | | | | | While unusual, it *is* possible for a client *not* to terminate when we close ptmx. We need to handle this *somehow*. Since it is so unusual, we'll go with a fairly easy, but synchronous method: * Register a signal handler for SIGALRM, and setup a 2 second alarm * Wait for slave to die * If it didn't die, sent SIGTERM, then re-set the alarm for another 2 seconds. * If it still hasn't died, send SIGKILL (this time without an alarm).
* terminal: 'child_ret' variables isn't neededDaniel Eklöf2019-11-02-5/+3
|
* timerfd: read() returns -1 with errno == EAGAIN, not 0Daniel Eklöf2019-11-02-15/+9
| | | | | | When there hasn't been a timeout (or in our case, there was a timeout, but we reset the timer before we got to the read()), read() returns, not 0, but -1 with errno == EAGAIN.
* timerfd: use non-blocking mode, fixes dead lockDaniel Eklöf2019-11-02-4/+19
| | | | | | | | | | | Since we cancel the timers every now and then, there's a (small) chance that one handler cancels a timer that has triggered in the same epoll() iteration. When this happens, read() blocks. Fix by making the timer FDs non-blocking, and simply returning when we read 0 bytes.
* term_init(): initialize slave TERM from term_init() argumentDaniel Eklöf2019-11-01-2/+2
|
* slave: set TERM environment variable in slave processDaniel Eklöf2019-11-01-1/+1
|
* terminal: call user-defined callback when destroying terminalDaniel Eklöf2019-11-01-1/+8
| | | | main uses this to get the exit code of the terminal.
* term_shutdown(): cleanupDaniel Eklöf2019-11-01-49/+35
| | | | | * Close FDs, then delay destruction to next epoll() call * Destroy window before destroying terminal
* terminal: fdm_del() closes the FDDaniel Eklöf2019-11-01-20/+6
|
* terminal: delayed rendering: fdm_delayed_render() may be called with is_armged==falseDaniel Eklöf2019-11-01-1/+2
| | | | This would happen if *both* timers triggered in the same epoll() call.
* terminal: no need to check for EAGAIN - we don't use non-blockingDaniel Eklöf2019-11-01-18/+10
|
* Don't use non-blocking FDsDaniel Eklöf2019-11-01-19/+5
| | | | | We use epoll() to determine when we can read/write FDs so there's absolutely no need for non-blocking.
* term: fdm_shutdown(): remove debug outputDaniel Eklöf2019-10-30-1/+0
|
* term: term_shutdown(): set exit value in waylandDaniel Eklöf2019-10-30-5/+7
|
* term: assign client PID to term->slaveDaniel Eklöf2019-10-30-1/+1
|
* term: term_init(): create wayland window *last*Daniel Eklöf2019-10-30-48/+57
| | | | | * Configure all FDs *completely* before moving on * Start client before creating the wayland window
* term: add term_shutdown()Daniel Eklöf2019-10-30-32/+102
| | | | | | | | | | | | | | | | This function unmaps the terminal window, removes itself from the wayland list of terminals and then finally destroys itself. We ensure we don't get any callbacks/events referring to a free:d terminal struct, we close all terminal related FDs and unmap the wayland window. Then, to be really really sure there aren't any (by the FDM) queued up events, we delay the self-destruction to the next FDM poll iteration, by opening an event FD and adding it to the FDM. The callback for the event FD removes the FD from the FDM again, and closes it. And then proceeds to destroy the terminal.
* wayland: track multiple terminalsDaniel Eklöf2019-10-30-1/+1
| | | | | The wayland 'term' member is gone and replaced by a list, 'terms'. This list contains all currently running terminal (windows).
* term: move client startup to a new function, slave_spawn()Daniel Eklöf2019-10-30-58/+5
|
* term: break out font initialization to a separate functionDaniel Eklöf2019-10-30-32/+41
|
* term: break out render worker threads initialization to a separate functionDaniel Eklöf2019-10-30-21/+50
|
* term: break out color cube initialization to a separate functionDaniel Eklöf2019-10-30-24/+23
|
* term: require all font variants to loadDaniel Eklöf2019-10-30-5/+5
|
* slave: rename slave_spawn() -> slave_exec()Daniel Eklöf2019-10-30-1/+1
|
* term: no need to stack-allocate an array of worker contextsDaniel Eklöf2019-10-28-6/+9
|
* render worker context: allocate, and let worker threads freeDaniel Eklöf2019-10-28-4/+5
| | | | | | | | | | Since we now initialize the worker threads from term_init(), which returns before the threads terminate, we can no longer use stack-allocated worker contexts. We _could_ put them in the terminal struct. But a simpler solution is to allocate them in term_init(), and let the threads free them when they don't need them anymore.
* term: open FDs before allocating terminal structDaniel Eklöf2019-10-28-42/+69
|
* term: integrate directly with FDMDaniel Eklöf2019-10-28-5/+222
|
* terminal: implement term_init() and term_destroy()Daniel Eklöf2019-10-28-0/+348
|
* term: wayland struct is now not a part of the terminal structDaniel Eklöf2019-10-27-3/+3
| | | | | | We do however need access to it, so provide a pointer. The difference is that now we can have a *single* wayland instance, but multiple terminal instances.
* kbd: move into waylandDaniel Eklöf2019-10-27-3/+3
|
* term: add term_reset_view() - make view follow end-of-output againDaniel Eklöf2019-08-28-0/+10
|
* term: remove commented out codeDaniel Eklöf2019-08-23-27/+0
|
* scrolling: optimize row access by assuming number of rows is a power of 2Daniel Eklöf2019-08-22-18/+45
| | | | | | | | | | | | | | | | | | | With this assumption, we can replace 'a % b' with 'a & (b - 1)'. In terms of instructions, this means a fast 'and' instead of a slow 'div'. Further optimize scrolling by: * not double-initializing empty rows. Previously, grid_row_alloc() called calloc(), which was then followed by a memset() when scrolling. This is of course unnecessary. * Don't loop the entire set of visible rows (this was done to ensure all visible rows had been allocated, and to prefetch the cell contents). This isn't necessary; only newly pulled in rows can be NULL. For now, don't prefetch at all.
* term: rename colors256 -> tableDaniel Eklöf2019-08-21-1/+1
|
* term: use colors256 array for *all* colorsDaniel Eklöf2019-08-21-4/+0
| | | | | | That is, remove the 'regular' and 'bright' color arrays. This is possible since the 256-color array is defined such that the first 16 colors map to the regular and bright colors.
* csi: move 256-color table into the terminal structDaniel Eklöf2019-08-21-0/+2
|
* erase-cells: don't memset when keeping background colorDaniel Eklöf2019-08-20-4/+6
|
* term: don't send mouse events if shift is being pressedDaniel Eklöf2019-08-08-0/+15
|
* term: cancel selection when scrolling wrapsDaniel Eklöf2019-08-05-2/+8
| | | | | | | | | | If we scroll enough, we'll eventually end up wrapping around the entire scrollback buffer. At this point, a selection is no longer valid, so cancel it. Note: this was very obvious when scrolling in the alt screen, since its scrollback buffer is what you see on the screen (i.e. it has no scrollback).
* term: re-order switch-cases to be in X button orderDaniel Eklöf2019-08-05-3/+3
|
* term: fix mouse button mapping to X button numbersDaniel Eklöf2019-08-05-2/+2
| | | | BACK should be 4, FORWARD 5.
* term: cell erase: reset *all* attributes *except* backgroundDaniel Eklöf2019-08-03-4/+1
|
* cell: pack more efficiently and store glyph as a wcharDaniel Eklöf2019-08-02-3/+4
| | | | | | | | | | | The 'attributes' struct is now 8 bytes and naturally packed (used to be 9 bytes, artificially packed). 'cell' struct is now 12 bytes, naturally packed (used to be 13 bytes, artificially packed). Furthermore, the glyph is stored as a wchar instead of a char*. This makes it easier (faster) to do glyph lookup when rendering.
* term: implement resetDaniel Eklöf2019-08-01-0/+82
|
* term: break out 'flash' to a separate 'term' functionDaniel Eklöf2019-07-30-0/+17
|
* render: add a 'clean' bit to each cell; only render cells that aren't cleanDaniel Eklöf2019-07-30-8/+16
| | | | | | | | | | | This patch takes a bit from the foreground color value in a cell (todo: split up foreground/background into bitfields with a separate field for 'foreground/background' has been set), and only re-renders cells that aren't marked as clean. Note: we use a 'clean' bit rather than a 'dirty' bit to make it easy to erase cells - we can (keep doing) do that by simply memsetting a cell range to 0.
* term: make sure to update 'current row' when restoring saved cursorDaniel Eklöf2019-07-23-0/+8
|
* term: track current window title in terminal structDaniel Eklöf2019-07-21-0/+9
|
* terminal: foreground/background in cell attributes are now uint32_tDaniel Eklöf2019-07-16-2/+1
| | | | This reduces the cell size, and thus improves the cache behavour
* csi: implement FocusIn/Out eventsDaniel Eklöf2019-07-16-0/+16
|
* Use vt_to_slave() instead of calling write(term->ptmx, ...) everywhereDaniel Eklöf2019-07-15-1/+2
|
* selection: add a selection APIDaniel Eklöf2019-07-11-2/+17
|
* grid: prefetch cells in grid_row()Daniel Eklöf2019-07-10-4/+4
|
* terminal: scrolling: prefetch cells of scrolled in linesDaniel Eklöf2019-07-10-17/+28
| | | | | | | | | | | | | Since newly scrolled in lines will be erased, we want them in the cache. So, allocate and prefetch new lines, then repair non-scrolling regions (to give the prefetch time to actually fetch the data). Finally, erase the newly scrolled in lines. This also fixes a bug where the fixup for the non-scrolling regions could crash on an unallocated row (we were accessing rows that would be, but hadn't yet been, scrolled in).
* terminal: scrolling: better debug log messagesDaniel Eklöf2019-07-10-1/+5
|
* grid: don't pre-allocate the entire grid (with all scrollback lines)Daniel Eklöf2019-07-10-1/+0
| | | | | | | | | | The row array may now contain NULL pointers. This means the corresponding row hasn't yet been allocated and initialized. On a resize, we explicitly allocate the visible rows. Uninitialized rows are then allocated the first time they are referenced.
* terminal: add term_linefeed() and term_reverse_index()Daniel Eklöf2019-07-10-0/+18
| | | | | | | | linefeed moves cursor down one row (columns stays the same), or, if the cursor is at the last row, scrolls up one row. reverse_index does the opposite; it moves the cursor *up* one row, or, if the cursor is at the top row, scrolls *down* one row.
* terminal: add term_damage_view()Daniel Eklöf2019-07-10-0/+7
| | | | | This ensures everything *visible* (i.e. maybe scrolled back content) is re-rendered.
* wip: initial scroll back supportDaniel Eklöf2019-07-09-2/+14
| | | | | | | | | | | | | | | | | | | | | | | Can scroll up and down, and stops when the beginning/end of history is reached. However, it probably breaks when the entire scrollback buffer has been filled - we need to detect when the view has wrapped around to the current terminal offset. The detection of when we've reached the bottom of the history is also flawed, and only works when we overshoot the bottom with at least a page. Resizing the windows while in a view most likely doesn't work. The view will not detect a wrapped around scrollback buffer. I.e. if the user has scrolled back, and is stationary at a view, but there is still output being produced. Then eventually the scrollback buffer will wrap around. In this case, the correct thing to do is make the view start following the beginning of the history. Right now it doesn't, meaning once the scrollback buffer wraps around, you'll start seeing command output...
* cleanupDaniel Eklöf2019-07-09-264/+7
|
* wip: grid is now represented as a grid, not a linear arrayDaniel Eklöf2019-07-08-31/+111
| | | | | | | | | | | | The grid is now represented with an array of row *pointers*. Each row contains an array of cells (the row's columns). The main point of having row pointers is we can now move rows around almost for free. This is useful when scrolling with scroll margins for example, where we previously had to copy the lines in the margins. Now it's just a matter of swapping two pointers.
* grid: grid_memset() -> grid_memclear()Daniel Eklöf2019-07-07-4/+3
|
* csi: implement URXVT style mouse event reportingDaniel Eklöf2019-07-05-10/+12
|
* term: implement MOUSE_SGR mouse event reporting styleDaniel Eklöf2019-07-05-5/+26
| | | | | This style is enabled with the \e[?1006h sequence, and changes how mouse events (button presses, releases and motion events).