diff options
author | AnotherTest <ali.mpfard@gmail.com> | 2020-06-26 16:43:55 +0430 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-06-27 15:39:03 +0200 |
commit | a6fd969d93654c1105008dcd032a96753cbd62f1 (patch) | |
tree | 87abdaee9afb2d3a2206bfd37b4e39cbbdf7ea28 /Shell/Shell.cpp | |
parent | 22b20c381f584900adff143fc76ae5ef6e31b2cf (diff) | |
download | serenity-a6fd969d93654c1105008dcd032a96753cbd62f1.zip |
LibLine: Support multiline editing
This commit also updates Shell, which uses actual_rendered_length.
Diffstat (limited to 'Shell/Shell.cpp')
-rw-r--r-- | Shell/Shell.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/Shell/Shell.cpp b/Shell/Shell.cpp index ef210441e0..db41a684d4 100644 --- a/Shell/Shell.cpp +++ b/Shell/Shell.cpp @@ -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()); |