summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibVT/Terminal.h
AgeCommit message (Collapse)Author
2022-07-14LibVT: Remove Vector<Kernel::KString> title stackLiav A
When using the kernel console, there's no such concept of title at all. Also, this makes vim to crash the kernel due to dereferencing a null pointer, so let's remove this as this is clearly not needed when using the kernel virtual console.
2022-06-22LibVT+Kernel: Separate the caret shapes and its steadinessMichaล‚ Lach
Currently CursorStyle enum handles both the styles and the steadiness or blinking of the terminal caret, which doubles the amount of its entries. This commit changes CursorStyle to CursorShape and moves the blinking option to a seperate boolean value.
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-03-13Libraries: Use default constructors/destructors in LibVTLenny Maiorani
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules "The compiler is more likely to get the default semantics right and you cannot implement these functions better than the compiler."
2022-02-16LibVT: Use NNOP<KString> to store window titles in the KernelIdan Horowitz
This will allow us to eventually propagate allocation failure.
2021-12-28LibVT: Handle window resize after history overflowryanb-dev
Addresses an issue in which a window resize event after history overflow would cause the Terminal to crash due to a failed assertion. The problematic assertion was removed and the logic updated to support inserting lines even when the start of the history is at an offset (due to an overflow). Resolves #10987
2021-11-11Everywhere: Pass AK::StringView by valueAndreas Kling
2021-10-02LibVT: Implement G0..G3 and VT100 translation tableJelle Raaijmakers
2021-10-02LibVT: Implement support for Cursor Keys Mode (DECCKM)Jelle Raaijmakers
2021-10-02LibVT: Add stubs for DECPNM, DECPAMJelle Raaijmakers
Still not implemented, but provides easier to grasp FIXMEs.
2021-07-09LibVT: Always check intermediate bytes in CSI sequencesDaniel Bertalan
Previously, we only checked the intermediate bytes for those escape sequences that performed different operations based on their intermediate bytes. This lead to a crash when `CSI ?1001 r` was incorrectly parsed as `CSI Pt ; Pb r` (note the missing question mark), as seen in #8559.
2021-06-23LibVT+Terminal: Implement line wrappingAli Mohammad Pur
This commit implements line wrapping in the terminal, and tries its best to move the cursor to the "correct" position.
2021-06-23LibVT: Keep track of the 'true' line endingsAli Mohammad Pur
2021-06-10LibVT: Implement `DECIC`/`DECDC`Daniel Bertalan
This commit adds support for these escape sequences that are used for scrolling multiple lines at once. In the current, unoptimized implementation, these just call the `scroll_left` and `scroll_right` APIs multiple times. It's a VT420 feature.
2021-06-10Kernel+LibVT: Fix selection with scrollback wrap-aroundDaniel Bertalan
If lines are removed from the tail of the scrollback buffer, the previous line indices will refer to different lines; therefore we need to offset them.
2021-06-10LibVT: Implement `DECFI` and `DECBI`Daniel Bertalan
These escape sequences are the horizontal scrolling equivalents of `IND` and `RI`. Normally, they move the cursor forward or backward. But if they hit the margins (which we just treat as the first and last columns), they scroll the line. Another VT420 feature done.
2021-06-10Kernel+LibVT: Implement left-right scrollingDaniel Bertalan
This commit implements the left/right scrolling used in the `ICH`/`DCH` escape sequences for `VirtualConsole`. This brings us one step closer to VT420/xterm compatibility. We can now finally remove the last escape sequence related `ifdef`s.
2021-06-10Kernel+LibVT: Add function for deleting a range of charactersDaniel Bertalan
Previously, this was done by telling the client to put a space at each character in the range. This was inefficient, because a large number of function calls took place and incorrect, as the ANSI standard dictates that character attributes should be cleared as well. The newly added `clear_in_line` function solves this issue. It performs just one bounds check when it's called and can be implemented as a pretty tight loop.
2021-06-10LibVT+Kernel: Support clearing the scrollback bufferDaniel Bertalan
As per the `xterm ctlseqs` documentation, `\e3J` should clear the scrollback buffer, and leave the visible lines unchanged. This commit fixes a FIXME.
2021-06-10LibVT+Kernel: Clean up scroll APIDaniel Bertalan
This commit cleans up some of the `#ifdef`-ed code smell in `Terminal`, by extending the scroll APIs to take a range of lines as a parameter. This makes it possible to use the same code for `IL`/`DL` as for scrolling. Note that the current scrolling implementation is very naive, and does many insertions/deletions in the middle of arrays, whereas swaps should be enough. This optimization will come in a later commit. The `linefeed` override was removed from `VirtualConsole`. Previously, it exhibited incorrect behavior by moving to column 0. Now that we use the method defined in `Terminal`, code which relied on this behavior stopped working. We go instead go through the TTY layer which handles the various output flags. Passing the input character-by-character seems a bit excessive, so a fix for it will come in another PR.
2021-06-05LibVT: Don't return a history size if alternate buffer is usedTim Schumacher
The line history is unavailable if the alternate screen buffer is currently enabled. However, since TerminalWidget uses the history size to offset its line numbers when rendering, it will try to render inaccessible lines once the history is not empty anymore.
2021-05-29LibVT: Add missing cursor movement escape sequencesDaniel Bertalan
This commit adds support for the following ANSI escape sequences: - `CNL` - Cursor Next Line - `CPL` - Cursor Previous Line - `VPR` - Line Position Relative - `HPA` - Character Position Absolute - `HPR` - Character Position Relative
2021-05-24LibVT: Add Alternate Screen Buffer supportDaniel Bertalan
The Alternate Screen Buffer is used by full-screen terminal applications (like `vim` and `nano`). Its data is stored separately from the normal buffer, therefore after applications using it exit, everything looks like it was before, the bottom of their interfaces isn't visible. An interesting feature is that it does not support scrollback, so it consumes less memory by not having to allocate lines for history. Because of the need to save and restore state between the switches, some correctness issues relating to it were also fixed in this commit.
2021-05-24LibVT: Implement Bracketed Paste ModeDaniel Bertalan
This mode allow us to escape any data that was not directly typed by the user. `vim` currently uses this. If we implement it in the shell, we could prevent newlines from being injected into the shell by pasting text or dragging files into it (see #7276).
2021-05-24LibVT: Add title stack supportDaniel Bertalan
This feature allows applications to reset the window title once they exited. It is used by `vim` if `set title` is enabled.
2021-05-24LibVT+Kernel: Add support for setting cursor stylesDaniel Bertalan
This commit introduces support for 3 new escape sequences: 1. Stop blinking cursor mode 2. `DECTCEM` mode (enable/disable cursor) 3. `DECSCUSR` (set cursor style) `TerminalWidget` now supports the following cursor types: block, underline and vertical bar. Each of these can blink or be steady. `VirtualConsole` ignores these (just as we were doing before).
2021-05-17LibVT: Fix newline handlingDaniel Bertalan
Before this commit, we would jump to the first column after receiving the '\n' line feed character. This is not the correct behavior, as it should only move the cursor now. Translating the typed Return key into the correct CR LF ("\r\n") is the TTY's job, which was fixed in #7184. Fixes #6820 Fixes #6960
2021-05-16Kernel/Graphics + SystemServer: Support text mode properlyLiav A
As we removed the support of VBE modesetting that was done by GRUB early on boot, we need to determine if we can modeset the resolution with our drivers, and if not, we should enable text mode and ensure that SystemServer knows about it too. Also, SystemServer should first check if there's a framebuffer device node, which is an indication that text mode was not even if it was requested. Then, if it doesn't find it, it should check what boot_mode argument the user specified (in case it's self-test). This way if we try to use bochs-display device (which is not VGA compatible) and request a text mode, it will not honor the request and will continue with graphical mode. Also try to print critical messages with mininum memory allocations possible. In LibVT, We make the implementation flexible for kernel-specific methods that are implemented in ConsoleImpl class.
2021-05-16LibVT: fix SM/RM not respecting private markersDaniel Bertalan
Since we now store intermediate characters separately, the intermediates should be checked for the presence of the '?' DEC private marker, not the first parameter.
2021-05-16LibVT: Implement new ANSI escape sequence parserDaniel Bertalan
This commit replaces the former, hand-written parser with a new one that can be generated automatically according to a state change diagram. The new `EscapeSequenceParser` class provides a more ergonomic interface to dealing with escape sequences. This interface has been inspired by Alacritty's [vte library](https://github.com/alacritty/vte/). I tried to avoid changing the application logic inside the `Terminal` class. While this code has not been thoroughly tested, I can't find regressions in the basic command line utilities or `vttest`. `Terminal` now displays nicer debug messages when it encounters an unknown escape sequence. Defensive programming and bounds checks have been added where we access parameters, and as a result, we can now endure 4-5 seconds of `cat /dev/urandom`. :D We generate EscapeSequenceStateMachine.h when building the in-kernel LibVT, and we assume that the file is already in place when the userland library is being built. This will probably cause problems later on, but I can't find a way to do it nicely.
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-02-23Everywhere: Rename ASSERT => VERIFYAndreas Kling
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED) Since all of these checks are done in release builds as well, let's rename them to VERIFY to prevent confusion, as everyone is used to assertions being compiled out in release. We can introduce a new ASSERT macro that is specifically for debug checks, but I'm doing this wholesale conversion first since we've accumulated thousands of these already, and it's not immediately obvious which ones are suitable for ASSERT.
2021-02-20LibVT: Give proper names to remaining VTxxx control functionsAndreas Kling
2021-02-20LibVT: Give proper names to SD and SUAndreas Kling
2021-02-20LibVT: Move control function doc comments to Terminal.h headerAndreas Kling
Putting the little documentation comment about what each VTxxx control function does in the header allows them to be picked up by IDE's.
2021-02-20LibVT: Give proper names to SCOSC and SCORCAndreas Kling
2021-01-12Libraries: Move to Userland/Libraries/Andreas Kling