mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-02-20 22:55:03 +00:00
Shell: highlight runnable commands
And display in red the command which will result in something like "no command, or is directory" (inspired by the fish shell).
This commit is contained in:
committed by
Andreas Kling
parent
e799da1fb6
commit
2b4b9d212e
@@ -367,9 +367,15 @@ RefPtr<Value> BarewordLiteral::run(RefPtr<Shell>)
|
||||
void BarewordLiteral::highlight_in_editor(Line::Editor& editor, Shell& shell, HighlightMetadata metadata)
|
||||
{
|
||||
if (metadata.is_first_in_list) {
|
||||
editor.stylize({ m_position.start_offset, m_position.end_offset }, { Line::Style::Bold });
|
||||
if (shell.is_runnable(m_text))
|
||||
editor.stylize({ m_position.start_offset, m_position.end_offset }, { Line::Style::Bold });
|
||||
else {
|
||||
editor.stylize({ m_position.start_offset, m_position.end_offset }, { Line::Style::Foreground(Line::Style::XtermColor::Red) });
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_text.starts_with('-')) {
|
||||
if (m_text == "--") {
|
||||
editor.stylize({ m_position.start_offset, m_position.end_offset }, { Line::Style::Foreground(Line::Style::XtermColor::Green) });
|
||||
|
||||
Reference in New Issue
Block a user