mirror of
https://github.com/RGBCube/serenity
synced 2025-05-29 13:05:06 +00:00
Spreadsheet: Highlight the source causing an exception in red
This commit makes the cell editor highlight the likely source of the exception in red.
This commit is contained in:
parent
b34b681811
commit
aa5b43a2bc
3 changed files with 21 additions and 0 deletions
|
@ -53,6 +53,19 @@ void CellSyntaxHighlighter::rehighlight(Gfx::Palette palette)
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
nullptr);
|
nullptr);
|
||||||
|
|
||||||
|
if (m_cell && m_cell->exception()) {
|
||||||
|
auto range = m_cell->exception()->source_ranges().first();
|
||||||
|
GUI::TextRange text_range { { range.start.line - 1, range.start.column }, { range.end.line - 1, range.end.column - 1 } };
|
||||||
|
m_editor->document().spans().prepend({ text_range,
|
||||||
|
Color::Black,
|
||||||
|
Color::Red,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
nullptr });
|
||||||
|
}
|
||||||
|
m_editor->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
CellSyntaxHighlighter::~CellSyntaxHighlighter()
|
CellSyntaxHighlighter::~CellSyntaxHighlighter()
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "Cell.h"
|
||||||
#include <LibGUI/JSSyntaxHighlighter.h>
|
#include <LibGUI/JSSyntaxHighlighter.h>
|
||||||
#include <LibGUI/SyntaxHighlighter.h>
|
#include <LibGUI/SyntaxHighlighter.h>
|
||||||
|
|
||||||
|
@ -37,6 +38,10 @@ public:
|
||||||
virtual ~CellSyntaxHighlighter() override;
|
virtual ~CellSyntaxHighlighter() override;
|
||||||
|
|
||||||
virtual void rehighlight(Gfx::Palette) override;
|
virtual void rehighlight(Gfx::Palette) override;
|
||||||
|
void set_cell(const Cell* cell) { m_cell = cell; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
const Cell* m_cell { nullptr };
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,6 +142,7 @@ void SpreadsheetWidget::setup_tabs(NonnullRefPtrVector<Sheet> new_sheets)
|
||||||
update();
|
update();
|
||||||
};
|
};
|
||||||
m_cell_value_editor->set_enabled(true);
|
m_cell_value_editor->set_enabled(true);
|
||||||
|
static_cast<CellSyntaxHighlighter*>(const_cast<GUI::SyntaxHighlighter*>(m_cell_value_editor->syntax_highlighter()))->set_cell(&cell);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,9 +170,11 @@ void SpreadsheetWidget::setup_tabs(NonnullRefPtrVector<Sheet> new_sheets)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
m_cell_value_editor->set_enabled(true);
|
m_cell_value_editor->set_enabled(true);
|
||||||
|
static_cast<CellSyntaxHighlighter*>(const_cast<GUI::SyntaxHighlighter*>(m_cell_value_editor->syntax_highlighter()))->set_cell(cells.first());
|
||||||
};
|
};
|
||||||
m_selected_view->on_selection_dropped = [&]() {
|
m_selected_view->on_selection_dropped = [&]() {
|
||||||
m_cell_value_editor->set_enabled(false);
|
m_cell_value_editor->set_enabled(false);
|
||||||
|
static_cast<CellSyntaxHighlighter*>(const_cast<GUI::SyntaxHighlighter*>(m_cell_value_editor->syntax_highlighter()))->set_cell(nullptr);
|
||||||
m_cell_value_editor->set_text("");
|
m_cell_value_editor->set_text("");
|
||||||
m_current_cell_label->set_enabled(false);
|
m_current_cell_label->set_enabled(false);
|
||||||
m_current_cell_label->set_text("");
|
m_current_cell_label->set_text("");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue