summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibLine/Editor.cpp
AgeCommit message (Collapse)Author
2021-12-16LibLine: Switch all files to use east-constAli Mohammad Pur
2021-12-16LibLine: Update the prompt origin after resize + suggestion redisplayAli Mohammad Pur
2021-12-16LibLine: Take the prompt into account when adjusting for a scrolled viewAli Mohammad Pur
Otherwise we'd end up putting the prompt *after* the previous prompt instead of *over* it when showing suggestions that span more lines than are available without scrolling.
2021-11-11Everywhere: Pass AK::StringView by valueAndreas Kling
2021-11-10AK: Make ByteBuffer::try_* functions return ErrorOr<void>Andreas Kling
Same as Vector, ByteBuffer now also signals allocation failure by returning an ENOMEM Error instead of a bool, allowing us to use the TRY() and MUST() patterns.
2021-10-08Libraries: Fix -Wunreachable-code warnings from clangNico Weber
2021-09-07Everywhere: Behaviour => BehaviorAndreas Kling
2021-09-06Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safeAli Mohammad Pur
2021-09-06Everywhere: Use OOM-safe ByteBuffer APIs where possibleAli Mohammad Pur
If we can easily communicate failure, let's avoid asserting and report failure instead.
2021-09-02Userland: Migrate to argument-less deferred_invokesin-ack
Only one place used this argument and it was to hold on to a strong ref for the object. Since we already do that now, there's no need to keep this argument around since this can be easily captured. This commit contains no changes.
2021-08-22Everywhere: Rename get in ConfigFile::get_for_{lib,app,system} to opennetworkException
This patch brings the ConfigFile helpers for opening lib, app and system configs more inline with the regular ConfigFile::open functions.
2021-07-20LibLine: Avoid excessive write() syscalls when refreshing the displayAli Mohammad Pur
Previously, we were generating the display update one character at a time, and writing them one at a time to stderr, which is not buffered, doing so caused one syscall per character printed which is s l o w (TM) This commit makes LibLine write the update contents into a buffer, and flush it after all the update is generated :^)
2021-07-02AK: Implement String::find_any_of() and StringView::find_any_of()Max Wipfli
This implements StringUtils::find_any_of() and uses it in String::find_any_of() and StringView::find_any_of(). All uses of find_{first,last}_of have been replaced with find_any_of(), find() or find_last(). find_{first,last}_of have subsequently been removed.
2021-06-23LibLine: Recalculate the origin on resizeAli Mohammad Pur
2021-06-07LibLine: Actually remove the two levels of deferred_invokeAli Mohammad Pur
4d5cdcc89394259019828f123039104d6f4039e2 partially reverted the changes from d8c5eeceabbeaedc29823f12cc8a9cfac6f84686, but it reverted too much and reintroduced the bug. This commit finally fixes the actual bug. The author hasn't been in his best committing state today.
2021-06-07LibLine: Partially revert d8c5eec and remove unrelated codeAli Mohammad Pur
This is a partial revert of d8c5eeceabbeaedc29823f12cc8a9cfac6f84686 as it contained unrelated code that was committed accidentally, which broke history on LibLine.
2021-06-06LibLine: Keep the CSI bytes alive across read eventsAli Mohammad Pur
Otherwise we would lose the CSI parameters and intermediates if the whole sequence was split between two reads. Fixes #7835.
2021-06-06LibLine: Stop registering the Notifier as a child ObjectAli Mohammad Pur
We're already keeping it alive via `m_notifier`. This makes the event loop quitting logic simpler by making less deferred calls and removes a race condition where the notifier would be deleted before the second deferred_invoke() would be invoked, leading to a nullptr dereference. Fixes #7822.
2021-06-03Everywhere: Replace ctype.h to avoid narrowing conversionsMax Wipfli
This replaces ctype.h with CharacterType.h everywhere I could find issues with narrowing conversions. While using it will probably make sense almost everywhere in the future, the most critical places should have been addressed.
2021-05-24LibLine+Shell: Allow some programs to modify the current termiosAli Mohammad Pur
This setting can be controlled by setting the PROGRAMS_ALLOWED_TO_MODIFY_DEFAULT_TERMIOS _local_ shell variable to a list containing such programs.
2021-05-24LibLine: Add bracketed paste mode supportAli Mohammad Pur
This mode makes the editor insert all the "pasted" text into the buffer without interpreting it in any way.
2021-05-16LibLine: Make line management less broken when at the last lineAli Mohammad Pur
Previously, all sorts of weird stuff would happen when the editor was at the last line of the terminal (or when the printed line would be at the last line), this commit makes the editor scroll the terminal up before trying to write to a row that doesn't actually exist (yet). This fixes ^R search making a mess when initiated at the last line (especially with multiline prompts).
2021-05-12LibCore+Everywhere: Move OpenMode out of IODeviceAli Mohammad Pur
...and make it an enum class so people don't omit "OpenMode".
2021-05-11LibLine+Shell: Add dirty history flag and use itsin-ack
This patch adds a new flag called history_dirty to Line::Editor that is set when history is added to but written. Applications can leverage this flag to write history only when it changes. This patch adds an example usage of this functionality to Shell, which will now only save the history when it is dirty.
2021-05-07LibLine: Convert StringBuilder::appendf() => AK::FormatAndreas Kling
2021-04-25Everywhere: Remove empty line after function body opening curly braceLinus Groh
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-04-21LibLine: Convert String::format() => String::formatted()Andreas Kling
2021-04-19LibLine: Avoid trying to restore() if the editor isn't initializedAli Mohammad Pur
Fixes #6472.
2021-04-19LibLine: Redraw the suggestions when terminal size changesAli Mohammad Pur
2021-04-17LibLine: Check the terminal size at the start of get_line()AnotherTest
There are cases where the line editor could miss the WINCH signal (e.g. in the shell, while another program is in the foreground), This patch makes it so that LibLine notices the change in terminal size in such cases.
2021-04-17LibLine: Add support for ^X^EAnotherTest
This keybind opens the current buffer in an editor (determined by EDITOR from the env, or the default_text_editor key in the config file, and set to /bin/TextEditor by default), and later reads the file back into the buffer. Pretty handy :^)
2021-03-16LibLine: Make the DSR response parser a bit more robustAnotherTest
At the cost of using more read() syscalls, process the DSR response character-by-character. This avoids blocking forever waiting for an 'R' that will never come :P
2021-03-13LibLine: Treat DEL as backspace by defaultAnotherTest
This can come in handy when telneting in.
2021-03-13LibLine: Don't try to print chars larger than 63 in caret formAnotherTest
Instead, mask them as `\xbb` so that e.g. DEL becomes `\x7f`. Fixes #5752.
2021-03-12Everywhere: Remove klog(), dbg() and purge all LogStream usage :^)Andreas Kling
Good-bye LogStream. Long live AK::Format!
2021-03-11LibLine: Cleanup the suggestions before inserting a new code pointAnotherTest
Otherwise `reposition_cursor()` will move the cursor one character too far to the right, and since we don't redraw the entire buffer when the character is inserted at the end, the mistake won't be immediately fixed by a complete redraw. Fixes #5722
2021-03-07LibLine: Clear the buffer after invalidating prior written dataAnotherTest
Otherwise this would set m_chars_touched_in_the_middle to zero, which is exactly the wrong thing to do.
2021-02-24LibLine: Note that the search() call modifies the bufferAnotherTest
Fixes #5465.
2021-02-24LibLine: Update the drawn cursor value when updating lazilyAnotherTest
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-21LibLine: Make clear_lines() work when only clearing the current lineAnotherTest
2021-02-21LibLine: Update the lazy refresh data and flags in some more placesAnotherTest
These were forgotten in the last LibLine commit, any changes to m_buffer not going through insert() and remove_at_index() should also be updating these. Fixes #5440.
2021-02-20LibLine: Avoid refreshing the entire line when inserting at the endAnotherTest
This patchset allows the editor to avoid redrawing the entire line when the changes cause no unrecoverable style updates, and are at the end of the line (this applies to most normal typing situations). Cases that this does not resolve: - When the cursor is not at the end of the buffer - When a display refresh changes the styles on the already-drawn parts of the line - When the prompt has not yet been drawn, or has somehow changed Fixes #5296.
2021-02-07LibLine: Close the search editor when it's interruptedAnotherTest
Fixes #5233.
2021-01-31LibLine: Only print ascii characters in caret formAnotherTest
ctype's `iscntrl` truncates its input, making some codepoints appear as control characters. Avoid this by checking whether the character is in ascii to begin with.
2021-01-25Everywhere: Remove unnecessary debug comments.asynts
It would be tempting to uncomment these statements, but that won't work with the new changes. This was done with the following commands: find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec awk -i inplace '$0 !~ /\/\/#define/ { if (!toggle) { print; } else { toggle = !toggle } } ; $0 ~/\/\/#define/ { toggle = 1 }' {} \; find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec awk -i inplace '$0 !~ /\/\/ #define/ { if (!toggle) { print; } else { toggle = !toggle } } ; $0 ~/\/\/ #define/ { toggle = 1 }' {} \;
2021-01-16Everywhere: Replace a bundle of dbg with dbgln.asynts
These changes are arbitrarily divided into multiple commits to make it easier to find potentially introduced bugs with git bisect.
2021-01-12LibLine: Use StringView::find() to find '::' in history entriesAnotherTest
Fixes an issue mentioned in #4926.
2021-01-12Libraries: Move to Userland/Libraries/Andreas Kling