summaryrefslogtreecommitdiff
path: root/Shell/LineEditor.h
AgeCommit message (Collapse)Author
2020-02-06LibCore: Remove leading C from filenamesAndreas Kling
2020-01-18Meta: Add license header to source filesAndreas Kling
As suggested by Joshua, this commit adds the 2-clause BSD license as a comment block to the top of every source file. For the first pass, I've just added myself for simplicity. I encourage everyone to add themselves as copyright holders of any file they've added or modified in some significant way. If I've added myself in error somewhere, feel free to replace it with the appropriate copyright holder instead. Going forward, all new source files should include a license header.
2019-12-17Shell: Tab completion now gives suggestionsJesse Buhagiar
Pushing the TAB key in the shell now prints suggestions to terminal. This makes it easier to the user to actually see what files are available before executing the command they currently have typed.
2019-12-11Shell: Tab completion for pathsWilliam McPherson
If the cursor is in front of a token that is not the first token, we try to split it on the last slash. If there is a slash, the first part is the directory to search and the second part is the token to complete. If there is no slash, we search the current directory and use the entire token for completion. If we find a single match and it's a directory, we add a slash. If it's a normal file, we add a space, unless there already is one. Also renamed cut_mismatching_chars() parameters to be more appropriate.
2019-12-11Shell: Improve tab completion behaviourWilliam McPherson
A space is added if only one match is found, but we avoid adding redundant spaces. We complete "empty" tokens, i.e. when the cursor is at the start of the line or in front of a space. For example: mkdir test cd test touch test chmod +x test export PATH=/home/anon/test Now if you press tab, or space and then tab, you will get "test". Notice that you also get a space. Completion is now done relative to the cursor. You can enter two words and then go back and complete the first one.
2019-12-11Shell: Refactor append/insert procedureWilliam McPherson
This patch just factors out the procedure of adding characters at the cursor position. It makes tab completion code much nicer.
2019-12-11Shell: Improve readability of cache_path()William McPherson
I prefer String::format over StringBuilder here. Also simplified a weird continue statement.
2019-12-09AK: Use size_t for the length of stringsAndreas Kling
Using int was a mistake. This patch changes String, StringImpl, StringView and StringBuilder to use size_t instead of int for lengths. Obviously a lot of code needs to change as a result of this.
2019-12-05Shell: Cache PATH for faster tab completionWilliam McPherson
This patch reduces the O(n) tab completion to something like O(log(n)). The cache is just a sorted vector of strings and we binary search it to get a string matching our input, and then check the surrounding strings to see if we need to remove any characters. Also we no longer stat each file every time. Also added an #include in BinarySearch since it was using size_t. Oops. If `export` is called, we recache. Need to implement the `hash` builtin for when an executable has been added to a directory in PATH.
2019-09-15Shell: Tab completion for programs in PATHwillmcpherson2
This patch adds a function to LineEditor that takes the current shell buffer, searches PATH for the first program that starts with that buffer and then compares that to any other programs starting with the buffer to remove any mismatching characters off the end. The result is appended to the buffer. This may be faster with a data structure but that seems overkill.
2019-09-06AK: Rename <AK/AKString.h> to <AK/String.h>Andreas Kling
This was a workaround to be able to build on case-insensitive file systems where it might get confused about <string.h> vs <String.h>. Let's just not support building that way, so String.h can have an objectively nicer name. :^)
2019-08-18Shell: Support forward deleteConrad Pankoff
2019-07-19Shell: Implement support for terminal clearing with ^L.Andreas Kling
Make LineEditor::get_line() responsible for printing the prompt. That way we can re-prompt after clearing the screen on ^L. This makes the Serenity Terminal feel a little bit more like home :^)
2019-06-07Meta: Tweak .clang-format to not wrap braces after enums.Andreas Kling
2019-05-28Add clang-format fileRobin Burchell
Also run it across the whole tree to get everything using the One True Style. We don't yet run this in an automated fashion as it's a little slow, but there is a snippet to do so in makeall.sh.
2019-05-07Shell: Make ^W and ^U work when cursor is not at the end of the line.Andreas Kling
2019-05-07Shell: Allow browsing history with up/down arrow keys.Andreas Kling
2019-05-07Shell: Move line editing to a separate class.Andreas Kling
To be clear, there isn't really any line editing yet. But there is going to be, so let's have it in its own class.