{
"$ xns" : "Gtk",
"Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
+ "bool resize_end_child" : false,
+ "bool resize_start_child" : false,
+ "bool shrink_end_child" : false,
+ "bool shrink_start_child" : false,
+ "id" : "paned",
"items" : [
{
"$ xns" : "Gtk",
"* prop" : "start_child",
"Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
+ "bool hexpand" : true,
"int spacing" : 0,
"items" : [
{
"$ homogeneous" : false,
"$ xns" : "Gtk",
"Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
- "bool hexpand" : true,
+ "bool hexpand" : false,
+ "bool vexpand" : false,
"items" : [
{
"$ xns" : "Gtk",
+ "bool vexpand" : true,
"id" : "save_button",
"label" : "Save",
"listeners" : {
},
{
"$ xns" : "Gtk",
+ "Gtk.Justification justify" : "Gtk.Justification.LEFT",
"bool hexpand" : true,
- "xtype" : "Label"
+ "float xalign" : 0,
+ "id" : "helper",
+ "int margin_end" : 4,
+ "int margin_start" : 4,
+ "listeners" : {
+ "query_tooltip" : [
+ "(x, y, keyboard_tooltip, tooltip) => {",
+ "\tGLib.debug(\"using quiery tooltip?\");",
+ "\tvar lbl = new Gtk.Label(this.el.tooltip_markup);",
+ "\tlbl.width_request = 500;",
+ "\ttooltip.set_custom(lbl);",
+ "",
+ "\treturn true;",
+ "}",
+ ""
+ ]
+ },
+ "xtype" : "Label",
+ "| void setHelp" : [
+ "(Lsp.Hover? help) {",
+ "\tif (help == null || help.contents == null",
+ "\t\t|| help.contents.size < 1) {",
+ "\t\tthis.el.set_text(\"\");",
+ "\t\treturn;",
+ "\t}",
+ "\tvar sig = help.contents.get(0).value.split(\" \");",
+ "\tstring[] str = {};",
+ "\tfor(var i =0; i < sig.length; i++) {",
+ "\t",
+ "\t\tswitch(sig[i]) {",
+ "\t\t\tcase \"public\":",
+ "\t\t\tcase \"private\":",
+ "\t\t\tcase \"protected\":",
+ "\t\t\tcase \"async\":",
+ "\t\t\tcase \"class\":",
+ "\t\t\tcase \"{\":",
+ "\t\t\tcase \"}\":",
+ "\t\t\tcase \"(\":",
+ "\t\t\tcase \")\":",
+ "\t\t\t",
+ "\t\t\t\tstr += sig[i];",
+ "\t\t\t\tcontinue;",
+ "\t\t\t\t",
+ "\t\t\t\t",
+ "\t\t\tdefault:",
+ "\t",
+ "\t\t\t\tstr += (\"<span underline=\\\"single\\\" color=\\\"blue\\\" >\" + ",
+ "\t\t\t\t\tGLib.Markup.escape_text(sig[i])",
+ "\t\t\t\t\t+\"</span>\");",
+ "\t\t\tcontinue;",
+ "\t\t}",
+ "\t}",
+ "\tif (help.contents.size > 1) {",
+ "\t\tthis.el.tooltip_markup = GLib.Markup.escape_text(help.contents.get(1).value);",
+ "\t}",
+ "\t",
+ "\tthis.el.set_markup(string.joinv(\" \",str));",
+ "\t",
+ "}"
+ ]
},
{
"$ xns" : "Gtk",
"}",
""
],
+ "Gtk.Align halign" : "Gtk.Align.END",
"bool draw_value" : false,
"bool has_origin" : true,
"bool sensitive" : true,
"int digits" : 0,
- "int width_request" : 200,
+ "int width_request" : 150,
"listeners" : {
"change_value" : [
"(st, val ) => {",
},
{
"$ xns" : "Gtk",
+ "Gtk.Align halign" : "Gtk.Align.END",
"id" : "close_btn",
"items" : [
{
"\t\t\t(uint)iter.get_line(),",
"\t\t\t(uint)iter.get_line_offset()",
"\t\t);",
- "",
+ "\tthis.showHelp(iter);",
"",
"}",
""
" return ret;",
"}",
" "
+ ],
+ "| void showHelp" : [
+ "(Gtk.TextIter iter) {",
+ "\tvar back = iter.copy();",
+ "\tback.backward_char();",
+ "\t",
+ "\tvar forward = iter.copy();",
+ "\tforward.forward_char();",
+ "\t",
+ "\t// what's the character at the iter?",
+ "\tvar str = back.get_text(iter);",
+ "\tstr += iter.get_text(forward);",
+ "\tif (str.strip().length < 1) {",
+ "\t\treturn;",
+ "\t}",
+ "\tvar offset = iter.get_line_offset();",
+ "\tvar line = iter.get_line();",
+ "\tif (_this.prop != null) {",
+ "\t\t\t\t// ",
+ "\t\tline += _this.prop.start_line ; ",
+ "\t\t\t\t\t// this is based on Gtk using tabs (hence 1/2 chars);",
+ "\t\toffset += _this.node.node_pad.length;",
+ "\t\t\t\t\t// javascript listeners are indented 2 more spaces.",
+ "\t\tif (_this.prop.ptype == JsRender.NodePropType.LISTENER) {",
+ "\t\t\toffset += 2;",
+ "\t\t}",
+ "\t} ",
+ "\t",
+ "\tvar ls = _this.file.getLanguageServer();",
+ "\tls.hover.begin(",
+ "\t\t_this.file, line, offset,",
+ "\t\t( a, o) => {",
+ "\t\t\ttry {",
+ "\t\t\t\tvar res = ls.hover.end(o );",
+ "\t\t\t",
+ "\t\t\t\t_this.helper.setHelp(res);",
+ "\t\t\t} catch (GLib.Error e) {",
+ "\t\t\t\t// noop..",
+ "\t\t\t}",
+ "\t\t});",
+ "}\t",
+ "\t\t ",
+ ""
]
},
{
},
{
"$ xns" : "Gtk",
+ "listeners" : {
+ "pressed" : [
+ "(n_press, x, y) => {",
+ "\tGtk.TextIter iter;",
+ "\tint buffer_x, buffer_y;",
+ "\tvar gut = _this.view.el.get_gutter(Gtk.TextWindowType.LEFT);",
+ "\t",
+ "\t _this.view.el.window_to_buffer_coords (Gtk.TextWindowType.TEXT,",
+ "\t\t(int)x - gut.get_width(), (int)y,",
+ " \t\tout buffer_x, out buffer_y);",
+ "\t_this.view.el.get_iter_at_location (out iter, ",
+ "\t\t\tbuffer_x, buffer_y);;",
+ "\t",
+ "\t",
+ "\tif (_this.buffer.el.iter_has_context_class(iter, \"comment\") ||",
+ "\t\t_this.buffer.el.iter_has_context_class(iter, \"string\")",
+ "\t) { ",
+ "\t\treturn ;",
+ "\t}",
+ "\t_this.buffer.showHelp(iter);",
+ "\t ",
+ "\t\t ",
+ " ",
+ "}",
+ ""
+ ]
+ },
"xtype" : "GestureClick"
}
],
"Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
"bool hexpand" : true,
"bool vexpand" : true,
+ "bool visible" : false,
+ "id" : "navigation_holder",
"int spacing" : 0,
+ "int width_request" : 120,
"items" : [
{
"$ xns" : "Gtk",
"$ xns" : "Gtk",
"bool hexpand" : true,
"bool vexpand" : true,
- "bool visible" : false,
+ "bool visible" : true,
"id" : "navigationwindow",
"items" : [
{
],
"| void show" : [
"(Gee.ArrayList<Lsp.DocumentSymbol> syms) {",
- "\t_this.navigationwindow.el.show();",
+ "\t",
+ "\tif (!_this.navigation_holder.el.visible) {",
+ "\t\t_this.navigation_holder.el.show();",
+ "\t\t_this.paned.el.position = ",
+ "\t\t\t_this.paned.el.get_width() - 200;",
+ "\t}",
"\t//_this.navliststore.el.remove_all();",
"\t",
"\t",
}
return _Editor;
}
+ public Xcls_paned paned;
public Xcls_save_button save_button;
+ public Xcls_helper helper;
public Xcls_close_btn close_btn;
public Xcls_RightEditor RightEditor;
public Xcls_view view;
public Xcls_case_sensitive case_sensitive;
public Xcls_regex regex;
public Xcls_multiline multiline;
+ public Xcls_navigation_holder navigation_holder;
public Xcls_navigationwindow navigationwindow;
public Xcls_navigation navigation;
public Xcls_navigationselmodel navigationselmodel;
this.el.homogeneous = false;
this.el.hexpand = true;
this.el.vexpand = true;
- var child_1 = new Xcls_Paned1( _this );
- child_1.ref();
- this.el.append( child_1.el );
+ new Xcls_paned( _this );
+ this.el.append( _this.paned.el );
}
// user defined functions
return false;
});
}
- public class Xcls_Paned1 : Object
+ public class Xcls_paned : Object
{
public Gtk.Paned el;
private Editor _this;
// my vars (def)
// ctor
- public Xcls_Paned1(Editor _owner )
+ public Xcls_paned(Editor _owner )
{
_this = _owner;
+ _this.paned = this;
this.el = new Gtk.Paned( Gtk.Orientation.HORIZONTAL );
// my vars (dec)
// set gobject values
+ this.el.resize_start_child = false;
+ this.el.shrink_end_child = false;
+ this.el.resize_end_child = false;
+ this.el.shrink_start_child = false;
var child_1 = new Xcls_Box2( _this );
child_1.ref();
this.el.start_child = child_1.el;
- var child_2 = new Xcls_Box27( _this );
- child_2.ref();
- this.el.end_child = child_2.el;
+ new Xcls_navigation_holder( _this );
+ this.el.end_child = _this.navigation_holder.el;
}
// user defined functions
// my vars (dec)
// set gobject values
+ this.el.hexpand = true;
var child_1 = new Xcls_Box3( _this );
child_1.ref();
this.el.append( child_1.el );
// set gobject values
this.el.homogeneous = false;
- this.el.hexpand = true;
+ this.el.hexpand = false;
+ this.el.vexpand = false;
new Xcls_save_button( _this );
this.el.append( _this.save_button.el );
- var child_2 = new Xcls_Label5( _this );
- child_2.ref();
- this.el.append( child_2.el );
+ new Xcls_helper( _this );
+ this.el.append( _this.helper.el );
var child_3 = new Xcls_Scale6( _this );
child_3.ref();
this.el.append( child_3.el );
// my vars (dec)
// set gobject values
+ this.el.vexpand = true;
this.el.label = "Save";
//listeners
// user defined functions
}
- public class Xcls_Label5 : Object
+ public class Xcls_helper : Object
{
public Gtk.Label el;
private Editor _this;
// my vars (def)
// ctor
- public Xcls_Label5(Editor _owner )
+ public Xcls_helper(Editor _owner )
{
_this = _owner;
+ _this.helper = this;
this.el = new Gtk.Label( null );
// my vars (dec)
// set gobject values
+ this.el.margin_end = 4;
+ this.el.margin_start = 4;
+ this.el.justify = Gtk.Justification.LEFT;
this.el.hexpand = true;
+ this.el.xalign = 0f;
+
+ //listeners
+ this.el.query_tooltip.connect( (x, y, keyboard_tooltip, tooltip) => {
+ GLib.debug("using quiery tooltip?");
+ var lbl = new Gtk.Label(this.el.tooltip_markup);
+ lbl.width_request = 500;
+ tooltip.set_custom(lbl);
+
+ return true;
+ });
}
// user defined functions
+ public void setHelp (Lsp.Hover? help) {
+ if (help == null || help.contents == null
+ || help.contents.size < 1) {
+ this.el.set_text("");
+ return;
+ }
+ var sig = help.contents.get(0).value.split(" ");
+ string[] str = {};
+ for(var i =0; i < sig.length; i++) {
+
+ switch(sig[i]) {
+ case "public":
+ case "private":
+ case "protected":
+ case "async":
+ case "class":
+ case "{":
+ case "}":
+ case "(":
+ case ")":
+
+ str += sig[i];
+ continue;
+
+
+ default:
+
+ str += ("<span underline=\"single\" color=\"blue\" >" +
+ GLib.Markup.escape_text(sig[i])
+ +"</span>");
+ continue;
+ }
+ }
+ if (help.contents.size > 1) {
+ this.el.tooltip_markup = GLib.Markup.escape_text(help.contents.get(1).value);
+ }
+
+ this.el.set_markup(string.joinv(" ",str));
+
+ }
}
public class Xcls_Scale6 : Object
// my vars (dec)
// set gobject values
- this.el.width_request = 200;
+ this.el.width_request = 150;
this.el.has_origin = true;
+ this.el.halign = Gtk.Align.END;
this.el.draw_value = false;
this.el.digits = 0;
this.el.sensitive = true;
// set gobject values
this.el.icon_name = "window-close";
+ this.el.halign = Gtk.Align.END;
var child_1 = new Xcls_Image8( _this );
child_1.ref();
this.el.child = child_1.el;
(uint)iter.get_line(),
(uint)iter.get_line_offset()
);
-
+ this.showHelp(iter);
});
this.el.changed.connect( () => {
//print("TO STRING? " + ret);
return ret;
}
+ public void showHelp (Gtk.TextIter iter) {
+ var back = iter.copy();
+ back.backward_char();
+
+ var forward = iter.copy();
+ forward.forward_char();
+
+ // what's the character at the iter?
+ var str = back.get_text(iter);
+ str += iter.get_text(forward);
+ if (str.strip().length < 1) {
+ return;
+ }
+ var offset = iter.get_line_offset();
+ var line = iter.get_line();
+ if (_this.prop != null) {
+ //
+ line += _this.prop.start_line ;
+ // this is based on Gtk using tabs (hence 1/2 chars);
+ offset += _this.node.node_pad.length;
+ // javascript listeners are indented 2 more spaces.
+ if (_this.prop.ptype == JsRender.NodePropType.LISTENER) {
+ offset += 2;
+ }
+ }
+
+ var ls = _this.file.getLanguageServer();
+ ls.hover.begin(
+ _this.file, line, offset,
+ ( a, o) => {
+ try {
+ var res = ls.hover.end(o );
+
+ _this.helper.setHelp(res);
+ } catch (GLib.Error e) {
+ // noop..
+ }
+ });
+ }
}
public class Xcls_keystate : Object
// my vars (dec)
// set gobject values
+
+ //listeners
+ this.el.pressed.connect( (n_press, x, y) => {
+ Gtk.TextIter iter;
+ int buffer_x, buffer_y;
+ var gut = _this.view.el.get_gutter(Gtk.TextWindowType.LEFT);
+
+ _this.view.el.window_to_buffer_coords (Gtk.TextWindowType.TEXT,
+ (int)x - gut.get_width(), (int)y,
+ out buffer_x, out buffer_y);
+ _this.view.el.get_iter_at_location (out iter,
+ buffer_x, buffer_y);;
+
+
+ if (_this.buffer.el.iter_has_context_class(iter, "comment") ||
+ _this.buffer.el.iter_has_context_class(iter, "string")
+ ) {
+ return ;
+ }
+ _this.buffer.showHelp(iter);
+
+
+
+ });
}
// user defined functions
- public class Xcls_Box27 : Object
+ public class Xcls_navigation_holder : Object
{
public Gtk.Box el;
private Editor _this;
// my vars (def)
// ctor
- public Xcls_Box27(Editor _owner )
+ public Xcls_navigation_holder(Editor _owner )
{
_this = _owner;
+ _this.navigation_holder = this;
this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
// my vars (dec)
// set gobject values
+ this.el.width_request = 120;
this.el.hexpand = true;
this.el.vexpand = true;
+ this.el.visible = false;
var child_1 = new Xcls_Box28( _this );
child_1.ref();
this.el.append( child_1.el );
// set gobject values
this.el.hexpand = true;
this.el.vexpand = true;
- this.el.visible = false;
+ this.el.visible = true;
new Xcls_navigation( _this );
this.el.child = _this.navigation.el;
}
return row;
}
public void show (Gee.ArrayList<Lsp.DocumentSymbol> syms) {
- _this.navigationwindow.el.show();
+
+ if (!_this.navigation_holder.el.visible) {
+ _this.navigation_holder.el.show();
+ _this.paned.el.position =
+ _this.paned.el.get_width() - 200;
+ }
//_this.navliststore.el.remove_all();
}
}
- public class MarkupContent : Object {
+ public class MarkupContent : Object , Json.Serializable {
public string kind { get; set; }
public string value { get; set; }
this.kind = "markdown";
this.value = doc;
}
+ public bool deserialize_property (string property_name, out Value value, ParamSpec pspec, Json.Node property_node)
+ {
+
+ return default_deserialize_property (property_name, out value, pspec, property_node);
+ }
}
[CCode (default_value = "LSP_COMPLETION_ITEM_KIND_Text")]
}
public bool deserialize_property (string property_name, out Value value, ParamSpec pspec, Json.Node property_node) {
- error ("deserialization not supported");
+ //GLib.debug("deserialise property %s" , property_name);
+ if (property_name != "parameters") {
+ return default_deserialize_property (property_name, out value, pspec, property_node);
+ }
+ value = GLib.Value (typeof(Gee.ArrayList));
+ if (property_node.get_node_type () != Json.NodeType.ARRAY) {
+ // GLib.debug ("unexpected property node type for 'arguments' %s", property_node.get_node_type ().to_string ());
+ return false;
+ }
+ //GLib.debug("got child length of %d", (int) property_node.get_array ().get_length());
+ var arguments = new Gee.ArrayList<ParameterInformation>();
+
+ property_node.get_array ().foreach_element ((array, index, element) => {
+
+ var add= Json.gobject_deserialize ( typeof (ParameterInformation), array.get_element(index)) as ParameterInformation;
+ arguments.add( add);
+
+
+ });
+
+ value.set_object (arguments);
+ return true;
}
}
}
}
- public class ParameterInformation : Object {
+ public class ParameterInformation : Object, Json.Serializable {
public string label { get; set; }
public MarkupContent documentation { get; set; }
+
+ public bool deserialize_property (string property_name, out Value value, ParamSpec pspec, Json.Node property_node)
+ {
+
+ return default_deserialize_property (property_name, out value, pspec, property_node);
+ }
+
}
public class MarkedString : Object {
{
this.language = language;
this.value = value;
- GLib.debug("new marked string %s : %s", language, value);
+ //GLib.debug("new marked string %s : %s", language, value);
}
public string language { get; set; }
public string value { get; set; }
public class Hover : Object, Json.Serializable {
public Gee.List<MarkedString> contents { get; set; default = new Gee.ArrayList<MarkedString> (); }
+
public Range range { get; set; }
public new void Json.Serializable.set_property (ParamSpec pspec, Value value) {
return false;
}
var contents = new Gee.ArrayList<MarkedString>();
-
property_node.get_array ().foreach_element ((array, index, element) => {
+ if (element.get_node_type() == Json.NodeType.VALUE) {
+ var str = element.get_string();
+ contents.add ( new MarkedString( "", str ));
+
+ return;
+ }
+ if (element.get_node_type() != Json.NodeType.OBJECT) {
+ GLib.debug("got content: %s", element.get_node_type().to_string());
+ return;
+ }
+
var add = new MarkedString(
- array.get_object_element(index).get_string_member("language"),
- array.get_object_element(index).get_string_member("value")
+ element.get_object().get_string_member("language"),
+ element.get_object().get_string_member("value")
);
contents.add ( add );
-
-
-
public abstract void initialize_server();
public abstract async Lsp.Hover hover (JsRender.JsRender file, int line, int offset) throws GLib.Error;
public abstract void queueDocumentSymbols (JsRender.JsRender file);
public abstract async Gee.ArrayList<Lsp.DocumentSymbol> documentSymbols (JsRender.JsRender file) throws GLib.Error;
+ public abstract async Gee.ArrayList<Lsp.SignatureInformation> signatureHelp (JsRender.JsRender file, int line, int offset) throws GLib.Error;
}
}
var ret = new Gee.ArrayList<Lsp.DocumentSymbol>();
return ret;
}
+ public override async Gee.ArrayList<Lsp.SignatureInformation> signatureHelp (JsRender.JsRender file, int line, int offset) throws GLib.Error
+ {
+ return new Gee.ArrayList<Lsp.SignatureInformation>();
+ }
}
}
\ No newline at end of file
var ret = new Gee.ArrayList<Lsp.DocumentSymbol>();
return ret;
}
-
+ public override async Gee.ArrayList<Lsp.SignatureInformation> signatureHelp (JsRender.JsRender file, int line, int offset) throws GLib.Error
+ {
+ return new Gee.ArrayList<Lsp.SignatureInformation>();
+ }
+
}
}
\ No newline at end of file
});
}
- this.countdown = 4;
+ this.countdown = 2;
this.change_queue_file = file;
public override async Lsp.Hover hover (JsRender.JsRender file, int line, int offset) throws GLib.Error
{
/* partial_result_token , work_done_token context = null) */
- GLib.debug("get syntax %s", file.relpath);
+ GLib.debug("get hover %s %d %d", file.relpath, (int)line, (int)offset);
var ret = new Lsp.Hover();
//ret = null;
if (!this.isReady()) {
null,
out return_value
);
+ GLib.debug ("LS hover replied with %s", Json.to_string (Json.gvariant_serialize (return_value), true));
+ if (return_value == null) {
+ return ret;
+ }
-
- GLib.debug ("LS replied with %s", Json.to_string (Json.gvariant_serialize (return_value), true));
var json = Json.gvariant_serialize (return_value);
+ if (json.get_node_type() != Json.NodeType.OBJECT) {
+ return ret;
+ }
+
+
ret = Json.gobject_deserialize ( typeof (Lsp.Hover), json) as Lsp.Hover;
return ret;
});
}
- this.doc_countdown = 4;
+ this.doc_countdown = 2;
this.doc_queue_file = file;
}
);
- GLib.debug ("LS replied with %s", Json.to_string (Json.gvariant_serialize (return_value), true));
+ //GLib.debug ("LS replied with %s", Json.to_string (Json.gvariant_serialize (return_value), true));
var json = Json.gvariant_serialize (return_value);
}
-
+ public override async Gee.ArrayList<Lsp.SignatureInformation> signatureHelp (JsRender.JsRender file, int line, int offset) throws GLib.Error {
+ /* partial_result_token , work_done_token context = null) */
+ GLib.debug("get signatureHelp %s, %d, %d", file.relpath, line, offset);
+ var ret = new Gee.ArrayList<Lsp.SignatureInformation>();
+ //ret = null;
+ if (!this.isReady()) {
+ return ret;
+ }
+ Variant? return_value;
+ yield this.jsonrpc_client.call_async (
+ "textDocument/signatureHelp",
+ this.buildDict (
+
+ textDocument : this.buildDict ( ///TextDocumentItem;
+ uri: new GLib.Variant.string (file.to_url())
+ ),
+ position : this.buildDict (
+ line : new GLib.Variant.uint64 ( (uint) line) ,
+ character : new GLib.Variant.uint64 ( uint.max(0, (offset -1)))
+ )
+
+ ),
+ null,
+ out return_value
+ );
+
+
+ GLib.debug ("LS replied with %s", Json.to_string (Json.gvariant_serialize (return_value), true));
+ var json = Json.gvariant_serialize (return_value);
+ if (json.get_node_type() != Json.NodeType.ARRAY) {
+ return ret;
+ }
+
+
+
+ var ar = json.get_array();
+ GLib.debug ("LS replied with %D items", ar.get_length());
+ for(var i = 0; i < ar.get_length(); i++ ) {
+ var add= Json.gobject_deserialize ( typeof (Lsp.SignatureInformation), ar.get_element(i)) as Lsp.SignatureInformation;
+ ret.add( add);
+
+ }
+ return ret ;
+
+
+ }
}