Merge branch 'master' into zig-0.15
This commit is contained in:
commit
d6843c4fb9
4 changed files with 54 additions and 28 deletions
|
@ -6,8 +6,8 @@
|
|||
|
||||
.dependencies = .{
|
||||
.syntax = .{
|
||||
.url = "git+https://github.com/neurocyte/flow-syntax?ref=master#0221af1286fc419c2fb1caedd9b5f445254d7129",
|
||||
.hash = "flow_syntax-0.1.0-X8jOof0SAQAOewEP2MRQ1wlhOP6l_CgRCsPS55-ksbPu",
|
||||
.url = "git+https://github.com/neurocyte/flow-syntax?ref=master#2a74de8f73458ebfe46040559626d72adcf2f53b",
|
||||
.hash = "flow_syntax-0.1.0-X8jOoRQTAQCVIXPDVqsteIjQy2V5s-oTmTppmhH5hjbj",
|
||||
},
|
||||
.flags = .{
|
||||
.url = "git+https://github.com/neurocyte/flags?ref=main#984b27948da3e4e40a253f76c85b51ec1a9ada11",
|
||||
|
|
|
@ -187,7 +187,7 @@ pub const CurSel = struct {
|
|||
};
|
||||
}
|
||||
|
||||
fn selection_from_node(node: syntax.Node, root: Buffer.Root, metrics: Buffer.Metrics) error{NotFound}!Selection {
|
||||
pub fn selection_from_node(node: syntax.Node, root: Buffer.Root, metrics: Buffer.Metrics) error{NotFound}!Selection {
|
||||
return selection_from_range(node.getRange(), root, metrics);
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,8 @@ fn inspect_location(self: *Self, row: usize, col: usize) void {
|
|||
const syn = self.editor.syntax orelse return;
|
||||
const root = (self.editor.buffer orelse return).root;
|
||||
const col_pos = root.get_line_width_to_pos(row, col, self.editor.metrics) catch return;
|
||||
syn.highlights_at_point(self, dump_highlight, .{ .row = @intCast(row), .column = @intCast(col_pos) });
|
||||
if (!syn.highlights_at_point(self, dump_highlight, .{ .row = @intCast(row), .column = @intCast(col_pos) }))
|
||||
self.ast_at_point(syn, row, col_pos, root);
|
||||
}
|
||||
|
||||
fn get_buffer_text(self: *Self, buf: []u8, sel: Buffer.Selection) ?[]const u8 {
|
||||
|
@ -81,9 +82,57 @@ fn get_buffer_text(self: *Self, buf: []u8, sel: Buffer.Selection) ?[]const u8 {
|
|||
return root.get_range(sel, buf, null, null, self.plane.metrics(self.editor.tab_width)) catch return null;
|
||||
}
|
||||
|
||||
fn ast_at_point(self: *Self, syn: anytype, row: usize, col_pos: usize, root: Buffer.Root) void {
|
||||
const node = syn.node_at_point_range(.{
|
||||
.start_point = .{
|
||||
.row = @intCast(row),
|
||||
.column = @intCast(col_pos),
|
||||
},
|
||||
.end_point = .{
|
||||
.row = @intCast(row),
|
||||
.column = @intCast(col_pos),
|
||||
},
|
||||
.start_byte = 0,
|
||||
.end_byte = 0,
|
||||
}) catch return;
|
||||
if (node.isNull()) return;
|
||||
|
||||
const sel = ed.CurSel.selection_from_node(node, root, self.editor.metrics) catch return;
|
||||
|
||||
self.dump_ast_node(sel, &node);
|
||||
}
|
||||
|
||||
fn dump_highlight(self: *Self, range: syntax.Range, scope: []const u8, id: u32, _: usize, ast_node: *const syntax.Node) error{Stop}!void {
|
||||
const sel = self.pos_cache.range_to_selection(range, self.editor.get_current_root() orelse return, self.editor.metrics) orelse return;
|
||||
|
||||
self.dump_ast_node(sel, ast_node);
|
||||
|
||||
var buf: [1024]u8 = undefined;
|
||||
const text = self.get_buffer_text(&buf, sel) orelse "";
|
||||
if (self.editor.style_lookup(self.theme, scope, id)) |token| {
|
||||
if (text.len > 14) {
|
||||
_ = self.plane.print("scope: {s} -> \"{s}...\" matched: {s}", .{
|
||||
scope,
|
||||
text[0..15],
|
||||
Widget.scopes[token.id],
|
||||
}) catch {};
|
||||
} else {
|
||||
_ = self.plane.print("scope: {s} -> \"{s}\" matched: {s}", .{
|
||||
scope,
|
||||
text,
|
||||
Widget.scopes[token.id],
|
||||
}) catch {};
|
||||
}
|
||||
self.show_color("fg", token.style.fg);
|
||||
self.show_color("bg", token.style.bg);
|
||||
self.show_font(token.style.fs);
|
||||
_ = self.plane.print("\n", .{}) catch {};
|
||||
return;
|
||||
}
|
||||
_ = self.plane.print("scope: {s} -> \"{s}\"\n", .{ scope, text }) catch return;
|
||||
}
|
||||
|
||||
fn dump_ast_node(self: *Self, sel: Buffer.Selection, ast_node: *const syntax.Node) void {
|
||||
var update_match: enum { no, add, set } = .no;
|
||||
var match = ed.Match.from_selection(sel);
|
||||
if (self.theme) |theme| match.style = .{ .bg = theme.editor_gutter_modified.fg };
|
||||
|
@ -124,30 +173,6 @@ fn dump_highlight(self: *Self, range: syntax.Range, scope: []const u8, id: u32,
|
|||
}
|
||||
}
|
||||
self.last_node = @intFromPtr(ast_node);
|
||||
|
||||
var buf: [1024]u8 = undefined;
|
||||
const text = self.get_buffer_text(&buf, sel) orelse "";
|
||||
if (self.editor.style_lookup(self.theme, scope, id)) |token| {
|
||||
if (text.len > 14) {
|
||||
_ = self.plane.print("scope: {s} -> \"{s}...\" matched: {s}", .{
|
||||
scope,
|
||||
text[0..15],
|
||||
Widget.scopes[token.id],
|
||||
}) catch {};
|
||||
} else {
|
||||
_ = self.plane.print("scope: {s} -> \"{s}\" matched: {s}", .{
|
||||
scope,
|
||||
text,
|
||||
Widget.scopes[token.id],
|
||||
}) catch {};
|
||||
}
|
||||
self.show_color("fg", token.style.fg);
|
||||
self.show_color("bg", token.style.bg);
|
||||
self.show_font(token.style.fs);
|
||||
_ = self.plane.print("\n", .{}) catch {};
|
||||
return;
|
||||
}
|
||||
_ = self.plane.print("scope: {s} -> \"{s}\"\n", .{ scope, text }) catch return;
|
||||
}
|
||||
|
||||
fn show_color(self: *Self, tag: []const u8, c_: ?Widget.Theme.Color) void {
|
||||
|
|
|
@ -1504,6 +1504,7 @@ pub const fallbacks: []const FallBack = &[_]FallBack{
|
|||
.{ .ts = "keyword.type", .tm = "keyword.structure" },
|
||||
.{ .ts = "keyword.function", .tm = "storage.type.function" },
|
||||
.{ .ts = "constant.builtin", .tm = "keyword.constant" },
|
||||
.{ .ts = "text.title", .tm = "entity.name.section" },
|
||||
};
|
||||
|
||||
fn set_terminal_style(self: *Self) void {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue