|
@@ -31,7 +31,6 @@
|
|
#include <LibCore/DirIterator.h>
|
|
#include <LibCore/DirIterator.h>
|
|
#include <LibCore/File.h>
|
|
#include <LibCore/File.h>
|
|
#include <LibGUI/Application.h>
|
|
#include <LibGUI/Application.h>
|
|
-#include <LibGUI/CppLexer.h>
|
|
|
|
#include <LibGUI/Painter.h>
|
|
#include <LibGUI/Painter.h>
|
|
#include <LibGUI/ScrollBar.h>
|
|
#include <LibGUI/ScrollBar.h>
|
|
#include <LibGUI/SyntaxHighlighter.h>
|
|
#include <LibGUI/SyntaxHighlighter.h>
|
|
@@ -184,13 +183,16 @@ void Editor::mousemove_event(GUI::MouseEvent& event)
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ auto highlighter = wrapper().editor().syntax_highlighter();
|
|
|
|
+ if (!highlighter)
|
|
|
|
+ return;
|
|
|
|
+
|
|
bool hide_tooltip = true;
|
|
bool hide_tooltip = true;
|
|
- bool is_over_header = false;
|
|
|
|
|
|
+ bool is_over_link = false;
|
|
|
|
|
|
for (auto& span : document().spans()) {
|
|
for (auto& span : document().spans()) {
|
|
if (span.range.contains(m_previous_text_position) && !span.range.contains(text_position)) {
|
|
if (span.range.contains(m_previous_text_position) && !span.range.contains(text_position)) {
|
|
- auto token = static_cast<GUI::CppToken::Type>(reinterpret_cast<size_t>(span.data));
|
|
|
|
- if (token == GUI::CppToken::Type::IncludePath && span.is_underlined) {
|
|
|
|
|
|
+ if (highlighter->is_navigatable(span.data) && span.is_underlined) {
|
|
span.is_underlined = false;
|
|
span.is_underlined = false;
|
|
wrapper().editor().update();
|
|
wrapper().editor().update();
|
|
}
|
|
}
|
|
@@ -204,15 +206,15 @@ void Editor::mousemove_event(GUI::MouseEvent& event)
|
|
dbg() << "Hovering: " << adjusted_range << " \"" << hovered_span_text << "\"";
|
|
dbg() << "Hovering: " << adjusted_range << " \"" << hovered_span_text << "\"";
|
|
#endif
|
|
#endif
|
|
|
|
|
|
- auto token = static_cast<GUI::CppToken::Type>(reinterpret_cast<size_t>(span.data));
|
|
|
|
- if (token == GUI::CppToken::Type::IncludePath) {
|
|
|
|
- is_over_header = true;
|
|
|
|
|
|
+ if (highlighter->is_navigatable(span.data)) {
|
|
|
|
+ is_over_link = true;
|
|
bool was_underlined = span.is_underlined;
|
|
bool was_underlined = span.is_underlined;
|
|
span.is_underlined = event.modifiers() & Mod_Ctrl;
|
|
span.is_underlined = event.modifiers() & Mod_Ctrl;
|
|
if (span.is_underlined != was_underlined) {
|
|
if (span.is_underlined != was_underlined) {
|
|
wrapper().editor().update();
|
|
wrapper().editor().update();
|
|
}
|
|
}
|
|
- } else if (token == GUI::CppToken::Type::Identifier) {
|
|
|
|
|
|
+ }
|
|
|
|
+ if (highlighter->is_identifier(span.data)) {
|
|
show_documentation_tooltip_if_available(hovered_span_text, event.position().translated(screen_relative_rect().location()));
|
|
show_documentation_tooltip_if_available(hovered_span_text, event.position().translated(screen_relative_rect().location()));
|
|
hide_tooltip = false;
|
|
hide_tooltip = false;
|
|
}
|
|
}
|
|
@@ -223,13 +225,13 @@ void Editor::mousemove_event(GUI::MouseEvent& event)
|
|
if (hide_tooltip)
|
|
if (hide_tooltip)
|
|
m_documentation_tooltip_window->hide();
|
|
m_documentation_tooltip_window->hide();
|
|
|
|
|
|
- m_hovering_link = is_over_header && (event.modifiers() & Mod_Ctrl);
|
|
|
|
|
|
+ m_hovering_link = is_over_link && (event.modifiers() & Mod_Ctrl);
|
|
}
|
|
}
|
|
|
|
|
|
void Editor::mousedown_event(GUI::MouseEvent& event)
|
|
void Editor::mousedown_event(GUI::MouseEvent& event)
|
|
{
|
|
{
|
|
auto highlighter = wrapper().editor().syntax_highlighter();
|
|
auto highlighter = wrapper().editor().syntax_highlighter();
|
|
- if (!highlighter || highlighter->language() != GUI::SyntaxLanguage::Cpp) {
|
|
|
|
|
|
+ if (!highlighter) {
|
|
GUI::TextEditor::mousedown_event(event);
|
|
GUI::TextEditor::mousedown_event(event);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -247,8 +249,7 @@ void Editor::mousedown_event(GUI::MouseEvent& event)
|
|
|
|
|
|
for (auto& span : document().spans()) {
|
|
for (auto& span : document().spans()) {
|
|
if (span.range.contains(text_position)) {
|
|
if (span.range.contains(text_position)) {
|
|
- auto token = static_cast<GUI::CppToken::Type>(reinterpret_cast<size_t>(span.data));
|
|
|
|
- if (token != GUI::CppToken::Type::IncludePath) {
|
|
|
|
|
|
+ if (!highlighter->is_navigatable(span.data)) {
|
|
GUI::TextEditor::mousedown_event(event);
|
|
GUI::TextEditor::mousedown_event(event);
|
|
return;
|
|
return;
|
|
}
|
|
}
|