Fix #8049 - language server hover and editor hover (not supported for gtkview / rooview)
[roobuilder] / src / Builder4 / Editor.bjs
index 0033aa4..29ed59d 100644 (file)
@@ -57,7 +57,7 @@
         " \tBuilderApplication.settings.editor_font_size_updated.connect(",
         " \t\t() => {",
         " \t\t\tBuilderApplication.settings.editor_font_size_inchange = true;",
-        " \t\t\tGLib.debug(\"update range\");",
+        " \t\t//\tGLib.debug(\"update range\");",
         " \t\t \tthis.el.set_value (BuilderApplication.settings.editor_font_size);",
         " \t\t \tBuilderApplication.settings.editor_font_size_inchange = false;",
         " \t\t}",
         "this.el.completion.add_provider(",
         "\tnew Palete.CompletionProvider(_this)",
         ");",
-        "  ",
+        " ",
+        "var hover = this.el.get_hover();",
+        "hover.add_provider(new Palete.HoverProvider(_this));",
+        "",
         "//this.el.completion.unblock_interactive();",
         "this.el.completion.select_on_show = true; // select",
         "//this.el.completion.remember_info_visibility\t = true;",
          ]
         },
         {
+         "# bool is_control" : false,
          "$ xns" : "Gtk",
+         "id" : "keystate",
          "listeners" : {
+          "key_pressed" : [
+           "(keyval, keycode, state) => {",
+           "",
+           " \tif (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {",
+           " \t\tthis.is_control = true;",
+           "\t}",
+           "\treturn false;",
+           "}",
+           ""
+          ],
           "key_released" : [
            "(keyval, keycode, state) => {",
            "",
-           "  ",
+           " \t if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {",
+           " \t\tthis.is_control = false;",
+           "\t}",
            "    if (keyval == Gdk.Key.s && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
            "        GLib.debug(\"SAVE: ctrl-S  pressed\");",
            "        _this.saveContents();",
           ]
          },
          "xtype" : "EventControllerKey"
+        },
+        {
+         "# double distance" : "0.0f",
+         "$ xns" : "Gtk",
+         "Gtk.EventControllerScrollFlags flags" : "Gtk.EventControllerScrollFlags.VERTICAL",
+         "listeners" : {
+          "scroll" : [
+           "(dx, dy) => {",
+           "\tif (!_this.keystate.is_control) {",
+           "\t\treturn false;",
+           "\t}",
+           "\t //GLib.debug(\"scroll %f\",  dy);",
+           "\t",
+           "\tthis.distance += dy;",
+           "\t",
+           "\t//GLib.debug(\"scroll %f / %f\",  dy, this.distance);",
+           " ",
+           "\t if (this.distance < -1) {",
+           " ",
+           "\t\tBuilderApplication.settings.editor_font_size ++;",
+           "\t\tthis.distance = 0;",
+           "\t}",
+           "\tif (this.distance > 1) {",
+           "\t\tBuilderApplication.settings.editor_font_size --;",
+           "\t\tthis.distance = 0;",
+           "\t}",
+           "\t ",
+           "\treturn true;",
+           "}",
+           ""
+          ]
+         },
+         "xtype" : "EventControllerScroll"
         }
        ],
        "listeners" : {