mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:58:12 +00:00
Shell: Add support for 'immediate' expressions as variable substitutions
This commit adds a few basic variable substitution operations: - length Find the length of a string or a list - length_across Find the lengths of things inside a list - remove_{suffix,prefix} Remove a suffix or a prefix from all the passed values - regex_replace Replace all matches of a given regex with a given template - split Split the given string with the given delimiter (or to its code points if the delimiter is empty) - concat_lists concatenates any given lists into one Closes #4316 (the ancient version of this same feature)
This commit is contained in:
parent
a303b69caa
commit
a45b2ea6fb
16 changed files with 911 additions and 37 deletions
|
@ -1518,6 +1518,26 @@ Vector<Line::CompletionSuggestion> Shell::complete_option(const String& program_
|
|||
return suggestions;
|
||||
}
|
||||
|
||||
Vector<Line::CompletionSuggestion> Shell::complete_immediate_function_name(const String& name, size_t offset)
|
||||
{
|
||||
Vector<Line::CompletionSuggestion> suggestions;
|
||||
|
||||
#define __ENUMERATE_SHELL_IMMEDIATE_FUNCTION(fn_name) \
|
||||
if (auto name_view = StringView { #fn_name }; name_view.starts_with(name)) { \
|
||||
suggestions.append({ name_view, " " }); \
|
||||
suggestions.last().input_offset = offset; \
|
||||
}
|
||||
|
||||
ENUMERATE_SHELL_IMMEDIATE_FUNCTIONS();
|
||||
|
||||
#undef __ENUMERATE_SHELL_IMMEDIATE_FUNCTION
|
||||
|
||||
if (m_editor)
|
||||
m_editor->suggest(offset);
|
||||
|
||||
return suggestions;
|
||||
}
|
||||
|
||||
void Shell::bring_cursor_to_beginning_of_a_line() const
|
||||
{
|
||||
struct winsize ws;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue