src/Builder4/Editor.bjs
authorAlan Knowles <alan@roojs.com>
Sun, 24 Mar 2024 03:03:43 +0000 (11:03 +0800)
committerAlan Knowles <alan@roojs.com>
Sun, 24 Mar 2024 03:03:43 +0000 (11:03 +0800)
src/Builder4/Editor.vala

src/Builder4/Editor.bjs
src/Builder4/Editor.vala

index 22ebd73..208c140 100644 (file)
               "pressed" : [
                "(n_press, x, y) => {",
                "\tGtk.TextIter iter;",
-               "\tint buffer_x, buffer_y;",
-               "\t_this.view.el.window_to_buffer_coords (",
-               "\t\tGtk.TextWindowType.TEXT, ",
-               "\t\t(int)x, (int)y, out  buffer_x, out  buffer_y",
-               "\t);",
-               "\tGLib.debug(\"converted %d, %d to %d %d\", ",
-               "\t\t(int)x, (int)y,  buffer_x,  buffer_y",
-               "\t\t);",
+               "",
+               "\tvar gut = _this.view.el.get_gutter(Gtk.TextWindowType.TEXT);",
                "\t",
+               "\t ",
                "\t_this.view.el.get_iter_at_location (out  iter,  ",
-               "\t\t\tbuffer_x,  buffer_y);",
+               "\t\t\t(int)x - gut.get_width(),  (int)y);",
                "\tif (_this.buffer.el.iter_has_context_class(iter, \"comment\") ||",
                "\t\t_this.buffer.el.iter_has_context_class(iter, \"string\")",
                "\t) { ",
index b33f74f..1fa0e01 100644 (file)
@@ -1316,17 +1316,12 @@ public class Editor : Object
                        //listeners
                        this.el.pressed.connect( (n_press, x, y) => {
                                Gtk.TextIter iter;
-                               int buffer_x, buffer_y;
-                               _this.view.el.window_to_buffer_coords (
-                                       Gtk.TextWindowType.TEXT, 
-                                       (int)x, (int)y, out  buffer_x, out  buffer_y
-                               );
-                               GLib.debug("converted %d, %d to %d %d", 
-                                       (int)x, (int)y,  buffer_x,  buffer_y
-                                       );
+                       
+                               var gut = _this.view.el.get_gutter(Gtk.TextWindowType.TEXT);
                                
+                                
                                _this.view.el.get_iter_at_location (out  iter,  
-                                               buffer_x,  buffer_y);
+                                               (int)x - gut.get_width(),  (int)y);
                                if (_this.buffer.el.iter_has_context_class(iter, "comment") ||
                                        _this.buffer.el.iter_has_context_class(iter, "string")
                                ) {