mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 14:58:46 +00:00
LibLine: Support multiline editing
This commit also updates Shell, which uses actual_rendered_length.
This commit is contained in:
parent
22b20c381f
commit
a6fd969d93
Notes:
sideshowbarker
2024-07-19 05:21:25 +09:00
Author: https://github.com/alimpfard
Commit: a6fd969d93
Pull-request: https://github.com/SerenityOS/serenity/pull/2632
3 changed files with 181 additions and 87 deletions
|
@ -126,7 +126,8 @@ String Shell::prompt() const
|
|||
};
|
||||
|
||||
auto the_prompt = build_prompt();
|
||||
auto prompt_length = editor->actual_rendered_string_length(the_prompt);
|
||||
auto prompt_metrics = editor->actual_rendered_string_metrics(the_prompt);
|
||||
auto prompt_length = prompt_metrics.line_lengths.last();
|
||||
|
||||
if (m_should_continue != ExitCodeOrContinuationRequest::Nothing) {
|
||||
const auto format_string = "\033[34m%.*-s\033[m";
|
||||
|
@ -1769,10 +1770,8 @@ bool Shell::read_single_line()
|
|||
if (line.is_empty())
|
||||
return true;
|
||||
|
||||
// FIXME: This might be a bit counter-intuitive, since we put nothing
|
||||
// between the two lines, even though the user has pressed enter
|
||||
// but since the LineEditor cannot yet handle literal newlines
|
||||
// inside the text, we opt to do this the wrong way (for the time being)
|
||||
if (!m_complete_line_builder.is_empty())
|
||||
m_complete_line_builder.append("\n");
|
||||
m_complete_line_builder.append(line);
|
||||
|
||||
auto complete_or_exit_code = run_command(m_complete_line_builder.string_view());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue