|
@@ -6,6 +6,7 @@
|
|
|
#include <filesystem>
|
|
#include <filesystem>
|
|
|
#include <vector>
|
|
#include <vector>
|
|
|
#include <functional> // For std::function
|
|
#include <functional> // For std::function
|
|
|
|
|
+#include <cctype> // For std::isalnum
|
|
|
|
|
|
|
|
// Check if GTK is enabled in build
|
|
// Check if GTK is enabled in build
|
|
|
#ifdef LUMACS_WITH_GTK
|
|
#ifdef LUMACS_WITH_GTK
|
|
@@ -581,6 +582,37 @@ protected:
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
drawing_area->add_controller(context_menu_controller);
|
|
drawing_area->add_controller(context_menu_controller);
|
|
|
|
|
+
|
|
|
|
|
+ // Add motion handling for tooltips
|
|
|
|
|
+ auto motion_controller = Gtk::EventControllerMotion::create();
|
|
|
|
|
+ std::weak_ptr<Window> weak_window_motion = node->window;
|
|
|
|
|
+ motion_controller->signal_motion().connect([this, weak_window_motion, drawing_area](double x, double y) {
|
|
|
|
|
+ if (auto window = weak_window_motion.lock()) {
|
|
|
|
|
+ if (auto pos = resolve_screen_pos(window, x, y)) {
|
|
|
|
|
+ const auto& line_text = window->buffer().line(pos->line);
|
|
|
|
|
+
|
|
|
|
|
+ // Find word under cursor (alphanumeric only for simplicity)
|
|
|
|
|
+ size_t word_start = pos->column;
|
|
|
|
|
+ while (word_start > 0 && word_start <= line_text.length() && std::isalnum(line_text[word_start - 1])) {
|
|
|
|
|
+ word_start--;
|
|
|
|
|
+ }
|
|
|
|
|
+ size_t word_end = pos->column;
|
|
|
|
|
+ while (word_end < line_text.length() && std::isalnum(line_text[word_end])) {
|
|
|
|
|
+ word_end++;
|
|
|
|
|
+ }
|
|
|
|
|
+ std::string word = line_text.substr(word_start, word_end - word_start);
|
|
|
|
|
+
|
|
|
|
|
+ if (!word.empty()) {
|
|
|
|
|
+ drawing_area->set_tooltip_text("Symbol: " + word + "\nLine: " + std::to_string(pos->line + 1));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ drawing_area->set_tooltip_text(""); // Clear tooltip
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ drawing_area->set_tooltip_text(""); // Clear tooltip
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ drawing_area->add_controller(motion_controller);
|
|
|
|
|
|
|
|
// Store reference for single-window compatibility
|
|
// Store reference for single-window compatibility
|
|
|
if (!drawing_area_) {
|
|
if (!drawing_area_) {
|