Compare commits
26 commits
master
...
writergate
Author | SHA1 | Date | |
---|---|---|---|
b94fbebb9f | |||
88fef7274b | |||
![]() |
05d8fe3708 | ||
![]() |
82c431c952 | ||
b60cd8907e | |||
e638862997 | |||
bc298e96d5 | |||
724dc9200d | |||
4cb6d0af05 | |||
891945bab1 | |||
4ee7a26817 | |||
625c89ab95 | |||
e5b20974e8 | |||
4e80bae8b8 | |||
8fb3602594 | |||
0a4c1a57b1 | |||
b258b2bb54 | |||
1fdfd41a4c | |||
e28169458e | |||
3e3bc2cd17 | |||
697ad50e1c | |||
eece7202b1 | |||
4d608d413a | |||
c21a673163 | |||
6fb364d64b | |||
0e3806ab98 |
58 changed files with 131 additions and 187 deletions
|
@ -1 +1 @@
|
||||||
0.14.1
|
0.15.0-dev.1034+bd97b6618
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
.hash = "dizzy-1.0.0-AAAAAM1wAAAiDbx_6RwcVEOBk8p2XOu8t9WPNc3K7kBK",
|
.hash = "dizzy-1.0.0-AAAAAM1wAAAiDbx_6RwcVEOBk8p2XOu8t9WPNc3K7kBK",
|
||||||
},
|
},
|
||||||
.thespian = .{
|
.thespian = .{
|
||||||
.url = "https://github.com/neurocyte/thespian/archive/ccdcbbff09f945eec063ebf889581db3e1312107.tar.gz",
|
.url = "git+https://github.com/neurocyte/thespian#4d317d7bf02eef26da56eddd2d49e46984b50572",
|
||||||
.hash = "thespian-0.0.1-owFOjlgaBgCqc3FCnB4Xyg8-9jyIDWgHSJMGx_nt5Kcc",
|
.hash = "thespian-0.0.1-owFOjuEaBgA9zNohtfOqnA8alObpvYjJNNDjEV8dKvLj",
|
||||||
},
|
},
|
||||||
.themes = .{
|
.themes = .{
|
||||||
.url = "https://github.com/neurocyte/flow-themes/releases/download/master-952f9f630ea9544088fd30293666ee0650b7a690/flow-themes.tar.gz",
|
.url = "https://github.com/neurocyte/flow-themes/releases/download/master-952f9f630ea9544088fd30293666ee0650b7a690/flow-themes.tar.gz",
|
||||||
|
@ -27,12 +27,12 @@
|
||||||
.hash = "fuzzig-0.1.1-AAAAALNIAQBmbHr-MPalGuR393Vem2pTQXI7_LXeNJgX",
|
.hash = "fuzzig-0.1.1-AAAAALNIAQBmbHr-MPalGuR393Vem2pTQXI7_LXeNJgX",
|
||||||
},
|
},
|
||||||
.vaxis = .{
|
.vaxis = .{
|
||||||
.url = "https://github.com/neurocyte/libvaxis/archive/6137cb4c44a7350996f0946a069739e5075d1f23.tar.gz",
|
.url = "https://github.com/neurocyte/libvaxis/archive/2a4137dadbe560b13b712fd3aa8a1c313fdd8c6e.tar.gz",
|
||||||
.hash = "vaxis-0.1.0-BWNV_HwOCQCw5wTV63hQGSc1QJzsNcytH6sGf1GBc0hP",
|
.hash = "vaxis-0.1.0-BWNV_KMOCQAe8oPD6cCn62Rg7oIVgF8FEWLpcAi7xDZQ",
|
||||||
},
|
},
|
||||||
.zeit = .{
|
.zeit = .{
|
||||||
.url = "https://github.com/rockorager/zeit/archive/8fd203f85f597f16e0a525c1f1ca1e0bffded809.tar.gz",
|
.url = "https://github.com/rockorager/zeit/archive/991f38266f86535e68431675e8feb84efa1f011b.tar.gz",
|
||||||
.hash = "zeit-0.0.0-AAAAACVbAgAiIzg1rccZU1qOfO_dKQKme7-37xmEQcqc",
|
.hash = "zeit-0.6.0-5I6bk0t7AgCPM_cY1DoqJB2pnmG7MMtpdO5IxNpryJDy",
|
||||||
},
|
},
|
||||||
.win32 = .{
|
.win32 = .{
|
||||||
.url = "https://github.com/marlersoft/zigwin32/archive/e8739b32a33ce48a3286aba31918b26a9dfc6ef0.tar.gz",
|
.url = "https://github.com/marlersoft/zigwin32/archive/e8739b32a33ce48a3286aba31918b26a9dfc6ef0.tar.gz",
|
||||||
|
|
|
@ -118,7 +118,6 @@ pub fn send(self: Self, from_: tp.pid_ref, m: tp.message) tp.result {
|
||||||
pub fn empty(allocator: Allocator) !Self {
|
pub fn empty(allocator: Allocator) !Self {
|
||||||
const child: type = struct {};
|
const child: type = struct {};
|
||||||
const widget = try allocator.create(child);
|
const widget = try allocator.create(child);
|
||||||
errdefer allocator.destroy(widget);
|
|
||||||
widget.* = .{};
|
widget.* = .{};
|
||||||
return .{
|
return .{
|
||||||
.ptr = widget,
|
.ptr = widget,
|
||||||
|
|
27
src/LSP.zig
27
src/LSP.zig
|
@ -17,34 +17,22 @@ const OutOfMemoryError = error{OutOfMemory};
|
||||||
const SendError = error{SendFailed};
|
const SendError = error{SendFailed};
|
||||||
const SpawnError = error{ThespianSpawnFailed};
|
const SpawnError = error{ThespianSpawnFailed};
|
||||||
|
|
||||||
pub fn open(
|
pub fn open(allocator: std.mem.Allocator, project: []const u8, cmd: tp.message) (error{ ThespianSpawnFailed, InvalidLspCommand } || cbor.Error)!Self {
|
||||||
allocator: std.mem.Allocator,
|
return .{ .allocator = allocator, .pid = try Process.create(allocator, project, cmd) };
|
||||||
project: []const u8,
|
|
||||||
cmd: tp.message,
|
|
||||||
) (error{ ThespianSpawnFailed, InvalidLspCommand } || cbor.Error)!*const Self {
|
|
||||||
const self = try allocator.create(Self);
|
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = .{
|
|
||||||
.allocator = allocator,
|
|
||||||
.pid = try Process.create(allocator, project, cmd),
|
|
||||||
};
|
|
||||||
return self;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deinit(self: *const Self) void {
|
pub fn deinit(self: Self) void {
|
||||||
self.pid.send(.{"close"}) catch {};
|
self.pid.send(.{"close"}) catch {};
|
||||||
self.pid.deinit();
|
self.pid.deinit();
|
||||||
self.allocator.destroy(self);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn term(self: *const Self) void {
|
pub fn term(self: Self) void {
|
||||||
self.pid.send(.{"term"}) catch {};
|
self.pid.send(.{"term"}) catch {};
|
||||||
self.pid.deinit();
|
self.pid.deinit();
|
||||||
self.allocator.destroy(self);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_request(
|
pub fn send_request(
|
||||||
self: *const Self,
|
self: Self,
|
||||||
allocator: std.mem.Allocator,
|
allocator: std.mem.Allocator,
|
||||||
method: []const u8,
|
method: []const u8,
|
||||||
m: anytype,
|
m: anytype,
|
||||||
|
@ -56,14 +44,14 @@ pub fn send_request(
|
||||||
return RequestContext(@TypeOf(ctx)).send(allocator, self.pid.ref(), ctx, tp.message.fmt(.{ "REQ", method, cb.items }));
|
return RequestContext(@TypeOf(ctx)).send(allocator, self.pid.ref(), ctx, tp.message.fmt(.{ "REQ", method, cb.items }));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_notification(self: *const Self, method: []const u8, m: anytype) (OutOfMemoryError || SendError)!void {
|
pub fn send_notification(self: Self, method: []const u8, m: anytype) (OutOfMemoryError || SendError)!void {
|
||||||
var cb = std.ArrayList(u8).init(self.allocator);
|
var cb = std.ArrayList(u8).init(self.allocator);
|
||||||
defer cb.deinit();
|
defer cb.deinit();
|
||||||
try cbor.writeValue(cb.writer(), m);
|
try cbor.writeValue(cb.writer(), m);
|
||||||
return self.send_notification_raw(method, cb.items);
|
return self.send_notification_raw(method, cb.items);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_notification_raw(self: *const Self, method: []const u8, cb: []const u8) SendError!void {
|
pub fn send_notification_raw(self: Self, method: []const u8, cb: []const u8) SendError!void {
|
||||||
self.pid.send(.{ "NTFY", method, cb }) catch return error.SendFailed;
|
self.pid.send(.{ "NTFY", method, cb }) catch return error.SendFailed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +144,6 @@ const Process = struct {
|
||||||
return error.InvalidLspCommand;
|
return error.InvalidLspCommand;
|
||||||
}
|
}
|
||||||
const self = try allocator.create(Process);
|
const self = try allocator.create(Process);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
var sp_tag_ = std.ArrayList(u8).init(allocator);
|
var sp_tag_ = std.ArrayList(u8).init(allocator);
|
||||||
defer sp_tag_.deinit();
|
defer sp_tag_.deinit();
|
||||||
try sp_tag_.appendSlice(tag);
|
try sp_tag_.appendSlice(tag);
|
||||||
|
|
|
@ -19,8 +19,8 @@ files: std.ArrayListUnmanaged(File) = .empty,
|
||||||
pending: std.ArrayListUnmanaged(File) = .empty,
|
pending: std.ArrayListUnmanaged(File) = .empty,
|
||||||
longest_file_path: usize = 0,
|
longest_file_path: usize = 0,
|
||||||
open_time: i64,
|
open_time: i64,
|
||||||
language_servers: std.StringHashMap(*const LSP),
|
language_servers: std.StringHashMap(LSP),
|
||||||
file_language_server: std.StringHashMap(*const LSP),
|
file_language_server: std.StringHashMap(LSP),
|
||||||
tasks: std.ArrayList(Task),
|
tasks: std.ArrayList(Task),
|
||||||
persistent: bool = false,
|
persistent: bool = false,
|
||||||
logger: log.Logger,
|
logger: log.Logger,
|
||||||
|
@ -74,8 +74,8 @@ pub fn init(allocator: std.mem.Allocator, name: []const u8) OutOfMemoryError!Sel
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.name = try allocator.dupe(u8, name),
|
.name = try allocator.dupe(u8, name),
|
||||||
.open_time = std.time.milliTimestamp(),
|
.open_time = std.time.milliTimestamp(),
|
||||||
.language_servers = std.StringHashMap(*const LSP).init(allocator),
|
.language_servers = std.StringHashMap(LSP).init(allocator),
|
||||||
.file_language_server = std.StringHashMap(*const LSP).init(allocator),
|
.file_language_server = std.StringHashMap(LSP).init(allocator),
|
||||||
.tasks = std.ArrayList(Task).init(allocator),
|
.tasks = std.ArrayList(Task).init(allocator),
|
||||||
.logger = log.logger("project"),
|
.logger = log.logger("project"),
|
||||||
.logger_lsp = log.logger("lsp"),
|
.logger_lsp = log.logger("lsp"),
|
||||||
|
@ -261,14 +261,11 @@ pub fn restore_state_v0(self: *Self, data: []const u8) error{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_language_server_instance(self: *Self, language_server: []const u8) StartLspError!*const LSP {
|
fn get_language_server_instance(self: *Self, language_server: []const u8) StartLspError!LSP {
|
||||||
if (self.language_servers.get(language_server)) |lsp| {
|
if (self.language_servers.get(language_server)) |lsp| {
|
||||||
if (lsp.pid.expired()) {
|
if (!lsp.pid.expired()) return lsp;
|
||||||
_ = self.language_servers.remove(language_server);
|
lsp.deinit();
|
||||||
lsp.deinit();
|
_ = self.language_servers.remove(language_server);
|
||||||
} else {
|
|
||||||
return lsp;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
const lsp = try LSP.open(self.allocator, self.name, .{ .buf = language_server });
|
const lsp = try LSP.open(self.allocator, self.name, .{ .buf = language_server });
|
||||||
errdefer lsp.deinit();
|
errdefer lsp.deinit();
|
||||||
|
@ -282,7 +279,7 @@ fn get_language_server_instance(self: *Self, language_server: []const u8) StartL
|
||||||
return lsp;
|
return lsp;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_or_start_language_server(self: *Self, file_path: []const u8, language_server: []const u8) StartLspError!*const LSP {
|
fn get_or_start_language_server(self: *Self, file_path: []const u8, language_server: []const u8) StartLspError!LSP {
|
||||||
const lsp = self.file_language_server.get(file_path) orelse blk: {
|
const lsp = self.file_language_server.get(file_path) orelse blk: {
|
||||||
const new_lsp = try self.get_language_server_instance(language_server);
|
const new_lsp = try self.get_language_server_instance(language_server);
|
||||||
const key = try self.allocator.dupe(u8, file_path);
|
const key = try self.allocator.dupe(u8, file_path);
|
||||||
|
@ -292,7 +289,7 @@ fn get_or_start_language_server(self: *Self, file_path: []const u8, language_ser
|
||||||
return lsp;
|
return lsp;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_language_server(self: *Self, file_path: []const u8) LspError!*const LSP {
|
fn get_language_server(self: *Self, file_path: []const u8) LspError!LSP {
|
||||||
const lsp = self.file_language_server.get(file_path) orelse return error.NoLsp;
|
const lsp = self.file_language_server.get(file_path) orelse return error.NoLsp;
|
||||||
if (lsp.pid.expired()) {
|
if (lsp.pid.expired()) {
|
||||||
if (self.file_language_server.fetchRemove(file_path)) |kv|
|
if (self.file_language_server.fetchRemove(file_path)) |kv|
|
||||||
|
@ -1513,7 +1510,7 @@ pub fn send_lsp_response(self: *Self, from: tp.pid_ref, cbor_id: []const u8, res
|
||||||
from.send_raw(.{ .buf = cb.items }) catch return error.ClientFailed;
|
from.send_raw(.{ .buf = cb.items }) catch return error.ClientFailed;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_lsp_init_request(self: *Self, lsp: *const LSP, project_path: []const u8, project_basename: []const u8, project_uri: []const u8, language_server: []const u8) !void {
|
fn send_lsp_init_request(self: *Self, lsp: LSP, project_path: []const u8, project_basename: []const u8, project_uri: []const u8, language_server: []const u8) !void {
|
||||||
const handler: struct {
|
const handler: struct {
|
||||||
language_server: []const u8,
|
language_server: []const u8,
|
||||||
lsp: LSP,
|
lsp: LSP,
|
||||||
|
|
|
@ -159,7 +159,6 @@ pub const Leaf = struct {
|
||||||
if (piece.len == 0)
|
if (piece.len == 0)
|
||||||
return if (!bol and !eol) &empty_leaf else if (bol and !eol) &empty_bol_leaf else if (!bol and eol) &empty_eol_leaf else &empty_line_leaf;
|
return if (!bol and !eol) &empty_leaf else if (bol and !eol) &empty_bol_leaf else if (!bol and eol) &empty_eol_leaf else &empty_line_leaf;
|
||||||
const node = try allocator.create(Node);
|
const node = try allocator.create(Node);
|
||||||
errdefer allocator.destroy(node);
|
|
||||||
node.* = .{ .leaf = .{ .buf = piece, .bol = bol, .eol = eol } };
|
node.* = .{ .leaf = .{ .buf = piece, .bol = bol, .eol = eol } };
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
@ -268,7 +267,6 @@ const Node = union(enum) {
|
||||||
|
|
||||||
fn new(allocator: Allocator, l: *const Node, r: *const Node) !*const Node {
|
fn new(allocator: Allocator, l: *const Node, r: *const Node) !*const Node {
|
||||||
const node = try allocator.create(Node);
|
const node = try allocator.create(Node);
|
||||||
errdefer allocator.destroy(node);
|
|
||||||
const l_weights_sum = l.weights_sum();
|
const l_weights_sum = l.weights_sum();
|
||||||
var weights_sum_ = Weights{};
|
var weights_sum_ = Weights{};
|
||||||
weights_sum_.add(l_weights_sum);
|
weights_sum_.add(l_weights_sum);
|
||||||
|
@ -1067,7 +1065,6 @@ const Node = union(enum) {
|
||||||
|
|
||||||
pub fn create(allocator: Allocator) error{OutOfMemory}!*Self {
|
pub fn create(allocator: Allocator) error{OutOfMemory}!*Self {
|
||||||
const self = try allocator.create(Self);
|
const self = try allocator.create(Self);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
const arena_a = if (builtin.is_test) allocator else std.heap.page_allocator;
|
const arena_a = if (builtin.is_test) allocator else std.heap.page_allocator;
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.arena = std.heap.ArenaAllocator.init(arena_a),
|
.arena = std.heap.ArenaAllocator.init(arena_a),
|
||||||
|
@ -1225,6 +1222,7 @@ pub const LoadFromFileError = error{
|
||||||
LockViolation,
|
LockViolation,
|
||||||
ProcessNotFound,
|
ProcessNotFound,
|
||||||
Canceled,
|
Canceled,
|
||||||
|
PermissionDenied,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn load_from_file(
|
pub fn load_from_file(
|
||||||
|
@ -1330,6 +1328,8 @@ pub const StoreToFileError = error{
|
||||||
SystemResources,
|
SystemResources,
|
||||||
Unexpected,
|
Unexpected,
|
||||||
WouldBlock,
|
WouldBlock,
|
||||||
|
PermissionDenied,
|
||||||
|
MessageTooBig,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn store_to_existing_file_const(self: *const Self, file_path: []const u8) StoreToFileError!void {
|
pub fn store_to_existing_file_const(self: *const Self, file_path: []const u8) StoreToFileError!void {
|
||||||
|
|
|
@ -66,7 +66,6 @@ const Process = struct {
|
||||||
|
|
||||||
pub fn create() !tp.pid {
|
pub fn create() !tp.pid {
|
||||||
const self = try allocator.create(Process);
|
const self = try allocator.create(Process);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.receiver = Receiver.init(Process.receive, self),
|
.receiver = Receiver.init(Process.receive, self),
|
||||||
};
|
};
|
||||||
|
|
|
@ -89,8 +89,8 @@
|
||||||
["ctrl+shift+d", "dupe_down"],
|
["ctrl+shift+d", "dupe_down"],
|
||||||
["ctrl+shift+z", "redo"],
|
["ctrl+shift+z", "redo"],
|
||||||
["ctrl+shift+w", "close_file_without_saving"],
|
["ctrl+shift+w", "close_file_without_saving"],
|
||||||
["ctrl+shift+l", "add_cursor_all_matches"],
|
["ctrl+shift+l", "run_async", "add_cursor_all_matches"],
|
||||||
["ctrl+shift+i", "toggle_inspector_view"],
|
["ctrl+shift+i", "run_async", "toggle_inspector_view"],
|
||||||
["ctrl+shift+m", "show_diagnostics"],
|
["ctrl+shift+m", "show_diagnostics"],
|
||||||
["ctrl+shift+enter", "smart_insert_line_before"],
|
["ctrl+shift+enter", "smart_insert_line_before"],
|
||||||
["ctrl+shift+end", "select_buffer_end"],
|
["ctrl+shift+end", "select_buffer_end"],
|
||||||
|
|
|
@ -65,7 +65,7 @@ const Handler = struct {
|
||||||
bindings: *const BindingSet,
|
bindings: *const BindingSet,
|
||||||
|
|
||||||
fn create(mode_name: []const u8, allocator: std.mem.Allocator, opts: anytype) !Mode {
|
fn create(mode_name: []const u8, allocator: std.mem.Allocator, opts: anytype) !Mode {
|
||||||
const self = try allocator.create(@This());
|
const self: *@This() = try allocator.create(@This());
|
||||||
errdefer allocator.destroy(self);
|
errdefer allocator.destroy(self);
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
|
|
22
src/log.zig
22
src/log.zig
|
@ -10,9 +10,14 @@ receiver: Receiver,
|
||||||
subscriber: ?tp.pid,
|
subscriber: ?tp.pid,
|
||||||
heap: [32 + 1024]u8,
|
heap: [32 + 1024]u8,
|
||||||
fba: std.heap.FixedBufferAllocator,
|
fba: std.heap.FixedBufferAllocator,
|
||||||
msg_store: MsgStoreT,
|
msg_store: MsgStore,
|
||||||
|
|
||||||
|
const MsgStore = std.DoublyLinkedList;
|
||||||
|
const MsgStoreEntry = struct {
|
||||||
|
data: []u8,
|
||||||
|
node: MsgStore.Node,
|
||||||
|
};
|
||||||
|
|
||||||
const MsgStoreT = std.DoublyLinkedList([]u8);
|
|
||||||
const Receiver = tp.Receiver(*Self);
|
const Receiver = tp.Receiver(*Self);
|
||||||
|
|
||||||
const StartArgs = struct {
|
const StartArgs = struct {
|
||||||
|
@ -38,7 +43,7 @@ fn init(args: StartArgs) !*Self {
|
||||||
.subscriber = null,
|
.subscriber = null,
|
||||||
.heap = undefined,
|
.heap = undefined,
|
||||||
.fba = std.heap.FixedBufferAllocator.init(&p.heap),
|
.fba = std.heap.FixedBufferAllocator.init(&p.heap),
|
||||||
.msg_store = MsgStoreT{},
|
.msg_store = MsgStore{},
|
||||||
};
|
};
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
@ -55,17 +60,18 @@ fn log(msg: []const u8) void {
|
||||||
fn store(self: *Self, m: tp.message) void {
|
fn store(self: *Self, m: tp.message) void {
|
||||||
const allocator: std.mem.Allocator = self.fba.allocator();
|
const allocator: std.mem.Allocator = self.fba.allocator();
|
||||||
const buf: []u8 = allocator.alloc(u8, m.len()) catch return;
|
const buf: []u8 = allocator.alloc(u8, m.len()) catch return;
|
||||||
var node: *MsgStoreT.Node = allocator.create(MsgStoreT.Node) catch return;
|
var msg: *MsgStoreEntry = allocator.create(MsgStoreEntry) catch return;
|
||||||
node.data = buf;
|
msg.data = buf;
|
||||||
@memcpy(buf, m.buf);
|
@memcpy(buf, m.buf);
|
||||||
self.msg_store.append(node);
|
self.msg_store.append(&msg.node);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn store_send(self: *Self) void {
|
fn store_send(self: *Self) void {
|
||||||
var node = self.msg_store.first;
|
var node = self.msg_store.first;
|
||||||
if (self.subscriber) |sub| {
|
if (self.subscriber) |sub| {
|
||||||
while (node) |node_| {
|
while (node) |node_| {
|
||||||
sub.send_raw(tp.message{ .buf = node_.data }) catch return;
|
const msg: *MsgStoreEntry = @fieldParentPtr("node", node_);
|
||||||
|
sub.send_raw(tp.message{ .buf = msg.data }) catch return;
|
||||||
node = node_.next;
|
node = node_.next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +79,7 @@ fn store_send(self: *Self) void {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn store_reset(self: *Self) void {
|
fn store_reset(self: *Self) void {
|
||||||
self.msg_store = MsgStoreT{};
|
self.msg_store = MsgStore{};
|
||||||
self.fba.reset();
|
self.fba.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -263,7 +263,6 @@ const Process = struct {
|
||||||
fn create() SpawnError!tp.pid {
|
fn create() SpawnError!tp.pid {
|
||||||
const allocator = std.heap.c_allocator;
|
const allocator = std.heap.c_allocator;
|
||||||
const self = try allocator.create(Process);
|
const self = try allocator.create(Process);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.parent = tp.self_pid().clone(),
|
.parent = tp.self_pid().clone(),
|
||||||
|
@ -756,7 +755,6 @@ fn request_path_files_async(a_: std.mem.Allocator, parent_: tp.pid_ref, project_
|
||||||
|
|
||||||
fn spawn_link(allocator: std.mem.Allocator, parent: tp.pid_ref, project: *Project, max: usize, path: []const u8) (SpawnError || std.fs.Dir.OpenError)!void {
|
fn spawn_link(allocator: std.mem.Allocator, parent: tp.pid_ref, project: *Project, max: usize, path: []const u8) (SpawnError || std.fs.Dir.OpenError)!void {
|
||||||
const self = try allocator.create(path_files);
|
const self = try allocator.create(path_files);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.project_name = try allocator.dupe(u8, project.name),
|
.project_name = try allocator.dupe(u8, project.name),
|
||||||
|
|
|
@ -125,7 +125,7 @@ pub fn install_crash_handler() void {
|
||||||
}
|
}
|
||||||
const act = std.posix.Sigaction{
|
const act = std.posix.Sigaction{
|
||||||
.handler = .{ .sigaction = handle_crash },
|
.handler = .{ .sigaction = handle_crash },
|
||||||
.mask = std.posix.empty_sigset,
|
.mask = std.posix.sigemptyset(),
|
||||||
.flags = (std.posix.SA.SIGINFO | std.posix.SA.RESTART),
|
.flags = (std.posix.SA.SIGINFO | std.posix.SA.RESTART),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -78,13 +78,9 @@ pub fn FullPanic(comptime panicFn: fn ([]const u8, ?usize) noreturn) type {
|
||||||
@branchHint(.cold);
|
@branchHint(.cold);
|
||||||
call("invalid error code", @returnAddress());
|
call("invalid error code", @returnAddress());
|
||||||
}
|
}
|
||||||
pub fn castTruncatedData() noreturn {
|
pub fn integerOutOfBounds() noreturn {
|
||||||
@branchHint(.cold);
|
@branchHint(.cold);
|
||||||
call("integer cast truncated bits", @returnAddress());
|
call("integer does not fit in destination type", @returnAddress());
|
||||||
}
|
|
||||||
pub fn negativeToUnsigned() noreturn {
|
|
||||||
@branchHint(.cold);
|
|
||||||
call("attempt to cast negative value to unsigned integer", @returnAddress());
|
|
||||||
}
|
}
|
||||||
pub fn integerOverflow() noreturn {
|
pub fn integerOverflow() noreturn {
|
||||||
@branchHint(.cold);
|
@branchHint(.cold);
|
||||||
|
@ -126,9 +122,9 @@ pub fn FullPanic(comptime panicFn: fn ([]const u8, ?usize) noreturn) type {
|
||||||
@branchHint(.cold);
|
@branchHint(.cold);
|
||||||
call("for loop over objects with non-equal lengths", @returnAddress());
|
call("for loop over objects with non-equal lengths", @returnAddress());
|
||||||
}
|
}
|
||||||
pub fn memcpyLenMismatch() noreturn {
|
pub fn copyLenMismatch() noreturn {
|
||||||
@branchHint(.cold);
|
@branchHint(.cold);
|
||||||
call("@memcpy arguments have non-equal lengths", @returnAddress());
|
call("source and destination arguments have non-equal lengths", @returnAddress());
|
||||||
}
|
}
|
||||||
pub fn memcpyAlias() noreturn {
|
pub fn memcpyAlias() noreturn {
|
||||||
@branchHint(.cold);
|
@branchHint(.cold);
|
||||||
|
@ -165,9 +161,11 @@ pub const sys_can_stack_trace = switch (builtin.cpu.arch) {
|
||||||
|
|
||||||
// `@returnAddress()` in LLVM 10 gives
|
// `@returnAddress()` in LLVM 10 gives
|
||||||
// "Non-Emscripten WebAssembly hasn't implemented __builtin_return_address".
|
// "Non-Emscripten WebAssembly hasn't implemented __builtin_return_address".
|
||||||
|
// On Emscripten, Zig only supports `@returnAddress()` in debug builds
|
||||||
|
// because Emscripten's implementation is very slow.
|
||||||
.wasm32,
|
.wasm32,
|
||||||
.wasm64,
|
.wasm64,
|
||||||
=> native_os == .emscripten,
|
=> native_os == .emscripten and builtin.mode == .Debug,
|
||||||
|
|
||||||
// `@returnAddress()` is unsupported in LLVM 13.
|
// `@returnAddress()` is unsupported in LLVM 13.
|
||||||
.bpfel,
|
.bpfel,
|
||||||
|
@ -586,15 +584,20 @@ pub fn defaultPanic(
|
||||||
|
|
||||||
// For backends that cannot handle the language features depended on by the
|
// For backends that cannot handle the language features depended on by the
|
||||||
// default panic handler, we have a simpler panic handler:
|
// default panic handler, we have a simpler panic handler:
|
||||||
if (builtin.zig_backend == .stage2_wasm or
|
switch (builtin.zig_backend) {
|
||||||
builtin.zig_backend == .stage2_arm or
|
.stage2_aarch64,
|
||||||
builtin.zig_backend == .stage2_aarch64 or
|
.stage2_arm,
|
||||||
builtin.zig_backend == .stage2_x86 or
|
.stage2_powerpc,
|
||||||
(builtin.zig_backend == .stage2_x86_64 and (builtin.target.ofmt != .elf and builtin.target.ofmt != .macho)) or
|
.stage2_riscv64,
|
||||||
builtin.zig_backend == .stage2_sparc64 or
|
.stage2_spirv,
|
||||||
builtin.zig_backend == .stage2_spirv64)
|
.stage2_wasm,
|
||||||
{
|
.stage2_x86,
|
||||||
@trap();
|
=> @trap(),
|
||||||
|
.stage2_x86_64 => switch (builtin.target.ofmt) {
|
||||||
|
.elf, .macho => {},
|
||||||
|
else => @trap(),
|
||||||
|
},
|
||||||
|
else => {},
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (builtin.os.tag) {
|
switch (builtin.os.tag) {
|
||||||
|
@ -615,9 +618,9 @@ pub fn defaultPanic(
|
||||||
// isn't visible on actual hardware if directly booted into
|
// isn't visible on actual hardware if directly booted into
|
||||||
inline for ([_]?*uefi.protocol.SimpleTextOutput{ uefi.system_table.std_err, uefi.system_table.con_out }) |o| {
|
inline for ([_]?*uefi.protocol.SimpleTextOutput{ uefi.system_table.std_err, uefi.system_table.con_out }) |o| {
|
||||||
if (o) |out| {
|
if (o) |out| {
|
||||||
_ = out.setAttribute(uefi.protocol.SimpleTextOutput.red);
|
out.setAttribute(.{ .foreground = .red }) catch {};
|
||||||
_ = out.outputString(exit_msg);
|
_ = out.outputString(exit_msg) catch {};
|
||||||
_ = out.setAttribute(uefi.protocol.SimpleTextOutput.white);
|
out.setAttribute(.{ .foreground = .white }) catch {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -752,7 +755,7 @@ pub const StackIterator = struct {
|
||||||
pub fn init(first_address: ?usize, fp: ?usize) StackIterator {
|
pub fn init(first_address: ?usize, fp: ?usize) StackIterator {
|
||||||
if (native_arch.isSPARC()) {
|
if (native_arch.isSPARC()) {
|
||||||
// Flush all the register windows on stack.
|
// Flush all the register windows on stack.
|
||||||
asm volatile (if (std.Target.sparc.featureSetHas(builtin.cpu.features, .v9))
|
asm volatile (if (builtin.cpu.has(.sparc, .v9))
|
||||||
"flushw"
|
"flushw"
|
||||||
else
|
else
|
||||||
"ta 3" // ST_FLUSH_WINDOWS
|
"ta 3" // ST_FLUSH_WINDOWS
|
||||||
|
@ -905,6 +908,8 @@ pub const StackIterator = struct {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (builtin.omit_frame_pointer) return null;
|
||||||
|
|
||||||
const fp = if (comptime native_arch.isSPARC())
|
const fp = if (comptime native_arch.isSPARC())
|
||||||
// On SPARC the offset is positive. (!)
|
// On SPARC the offset is positive. (!)
|
||||||
math.add(usize, it.fp, fp_offset) catch return null
|
math.add(usize, it.fp, fp_offset) catch return null
|
||||||
|
@ -1371,12 +1376,11 @@ pub fn attachSegfaultHandler() void {
|
||||||
windows_segfault_handle = windows.kernel32.AddVectoredExceptionHandler(0, handleSegfaultWindows);
|
windows_segfault_handle = windows.kernel32.AddVectoredExceptionHandler(0, handleSegfaultWindows);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var act = posix.Sigaction{
|
const act = posix.Sigaction{
|
||||||
.handler = .{ .sigaction = handleSegfaultPosix },
|
.handler = .{ .sigaction = handleSegfaultPosix },
|
||||||
.mask = posix.empty_sigset,
|
.mask = posix.sigemptyset(),
|
||||||
.flags = (posix.SA.SIGINFO | posix.SA.RESTART | posix.SA.RESETHAND),
|
.flags = (posix.SA.SIGINFO | posix.SA.RESTART | posix.SA.RESETHAND),
|
||||||
};
|
};
|
||||||
|
|
||||||
updateSegfaultHandler(&act);
|
updateSegfaultHandler(&act);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1388,9 +1392,9 @@ pub fn resetSegfaultHandler() void {
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var act = posix.Sigaction{
|
const act = posix.Sigaction{
|
||||||
.handler = .{ .handler = posix.SIG.DFL },
|
.handler = .{ .handler = posix.SIG.DFL },
|
||||||
.mask = posix.empty_sigset,
|
.mask = posix.sigemptyset(),
|
||||||
.flags = 0,
|
.flags = 0,
|
||||||
};
|
};
|
||||||
updateSegfaultHandler(&act);
|
updateSegfaultHandler(&act);
|
||||||
|
@ -1504,6 +1508,12 @@ fn handleSegfaultWindows(info: *windows.EXCEPTION_POINTERS) callconv(.winapi) c_
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handleSegfaultWindowsExtra(info: *windows.EXCEPTION_POINTERS, msg: u8, label: ?[]const u8) noreturn {
|
fn handleSegfaultWindowsExtra(info: *windows.EXCEPTION_POINTERS, msg: u8, label: ?[]const u8) noreturn {
|
||||||
|
// For backends that cannot handle the language features used by this segfault handler, we have a simpler one,
|
||||||
|
switch (builtin.zig_backend) {
|
||||||
|
.stage2_x86_64 => if (builtin.target.ofmt == .coff) @trap(),
|
||||||
|
else => {},
|
||||||
|
}
|
||||||
|
|
||||||
comptime assert(windows.CONTEXT != void);
|
comptime assert(windows.CONTEXT != void);
|
||||||
nosuspend switch (panic_stage) {
|
nosuspend switch (panic_stage) {
|
||||||
0 => {
|
0 => {
|
||||||
|
|
|
@ -85,7 +85,6 @@ const Process = struct {
|
||||||
|
|
||||||
pub fn create(allocator: std.mem.Allocator, query: []const u8, tag: [:0]const u8, stdin_behavior: std.process.Child.StdIo) !tp.pid {
|
pub fn create(allocator: std.mem.Allocator, query: []const u8, tag: [:0]const u8, stdin_behavior: std.process.Child.StdIo) !tp.pid {
|
||||||
const self = try allocator.create(Process);
|
const self = try allocator.create(Process);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.query = try allocator.dupe(u8, query),
|
.query = try allocator.dupe(u8, query),
|
||||||
|
|
|
@ -45,7 +45,6 @@ const Process = struct {
|
||||||
|
|
||||||
pub fn create(allocator: std.mem.Allocator) Error!tp.pid {
|
pub fn create(allocator: std.mem.Allocator) Error!tp.pid {
|
||||||
const self = try allocator.create(Process);
|
const self = try allocator.create(Process);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.parent = tp.self_pid().clone(),
|
.parent = tp.self_pid().clone(),
|
||||||
|
|
|
@ -156,7 +156,6 @@ const Process = struct {
|
||||||
return error.InvalidShellArg0;
|
return error.InvalidShellArg0;
|
||||||
|
|
||||||
const self = try allocator.create(Process);
|
const self = try allocator.create(Process);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.argv = argv,
|
.argv = argv,
|
||||||
|
|
|
@ -14,10 +14,7 @@ pub fn build(b: *std.Build) void {
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
});
|
});
|
||||||
|
|
||||||
const tree_sitter_host_dep = b.dependency("tree_sitter", .{
|
const tree_sitter_host_dep = b.dependency("tree_sitter", .{});
|
||||||
.target = b.graph.host,
|
|
||||||
.optimize = optimize,
|
|
||||||
});
|
|
||||||
|
|
||||||
const cbor_dep = b.dependency("cbor", .{
|
const cbor_dep = b.dependency("cbor", .{
|
||||||
.target = target,
|
.target = target,
|
||||||
|
@ -26,8 +23,11 @@ pub fn build(b: *std.Build) void {
|
||||||
|
|
||||||
const ts_bin_query_gen = b.addExecutable(.{
|
const ts_bin_query_gen = b.addExecutable(.{
|
||||||
.name = "ts_bin_query_gen",
|
.name = "ts_bin_query_gen",
|
||||||
.target = b.graph.host,
|
.root_module = b.createModule(.{
|
||||||
.root_source_file = b.path("src/ts_bin_query_gen.zig"),
|
.root_source_file = b.path("src/ts_bin_query_gen.zig"),
|
||||||
|
.target = b.graph.host,
|
||||||
|
.optimize = .Debug,
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
ts_bin_query_gen.linkLibC();
|
ts_bin_query_gen.linkLibC();
|
||||||
ts_bin_query_gen.root_module.addImport("cbor", cbor_dep.module("cbor"));
|
ts_bin_query_gen.root_module.addImport("cbor", cbor_dep.module("cbor"));
|
||||||
|
|
|
@ -2,16 +2,16 @@
|
||||||
.name = .flow_syntax,
|
.name = .flow_syntax,
|
||||||
.version = "0.1.0",
|
.version = "0.1.0",
|
||||||
.fingerprint = 0x3ba2584ea1cec85f,
|
.fingerprint = 0x3ba2584ea1cec85f,
|
||||||
.minimum_zig_version = "0.14.1",
|
.minimum_zig_version = "0.15.0-dev.1048+f43f89a70",
|
||||||
|
|
||||||
.dependencies = .{
|
.dependencies = .{
|
||||||
.tree_sitter = .{
|
.tree_sitter = .{
|
||||||
.url = "https://github.com/neurocyte/tree-sitter/releases/download/master-1c3ad59bd98ee430b166054030dac4c46d641e39/source.tar.gz",
|
.url = "https://github.com/neurocyte/tree-sitter/releases/download/master-f1f032d24f621e2ee4deab1c424d3bf9fb809f6e/source.tar.gz",
|
||||||
.hash = "N-V-__8AANMzUiemOR2eNnrtlMmAGHFqij6VYtDUiaFfn6Dw",
|
.hash = "tree_sitter-0.22.4-150-g7e3f5726-z0LhyN88UicDHlr22vQnOZ3DW9NWN1gOhDwLuCRXvrh2",
|
||||||
},
|
},
|
||||||
.cbor = .{
|
.cbor = .{
|
||||||
.url = "https://github.com/neurocyte/cbor/archive/1fccb83c70cd84e1dff57cc53f7db8fb99909a94.tar.gz",
|
.url = "git+https://github.com/neurocyte/cbor#6eccce0b984296e7d05c20d83933cb31530e4fac",
|
||||||
.hash = "cbor-1.0.0-RcQE_HvqAACcrLH7t3IDZOshgY2xqJA_UX330MvwSepb",
|
.hash = "cbor-1.0.0-RcQE_N3yAADXjbyvhsmTQ6lf22l1nYgePq5FT8NaC4ic",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
.paths = .{
|
.paths = .{
|
||||||
|
|
|
@ -62,7 +62,6 @@ pub const Error = CacheError || QueryParseError || QuerySerializeError;
|
||||||
|
|
||||||
pub fn create(allocator: std.mem.Allocator, opts: struct { lock: bool = false }) !*Self {
|
pub fn create(allocator: std.mem.Allocator, opts: struct { lock: bool = false }) !*Self {
|
||||||
const self = try allocator.create(Self);
|
const self = try allocator.create(Self);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.mutex = if (opts.lock) .{} else null,
|
.mutex = if (opts.lock) .{} else null,
|
||||||
|
|
|
@ -87,7 +87,7 @@ fn ft_func_name(comptime lang: []const u8) []const u8 {
|
||||||
return &func_name;
|
return &func_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const LangFn = *const fn () callconv(.C) ?*const treez.Language;
|
pub const LangFn = *const fn () callconv(.c) ?*const treez.Language;
|
||||||
|
|
||||||
pub const FirstLineMatch = struct {
|
pub const FirstLineMatch = struct {
|
||||||
prefix: ?[]const u8 = null,
|
prefix: ?[]const u8 = null,
|
||||||
|
|
|
@ -29,13 +29,9 @@ tree: ?*treez.Tree = null,
|
||||||
|
|
||||||
pub fn create(file_type: FileType, allocator: std.mem.Allocator, query_cache: *QueryCache) !*Self {
|
pub fn create(file_type: FileType, allocator: std.mem.Allocator, query_cache: *QueryCache) !*Self {
|
||||||
const query = try query_cache.get(file_type, .highlights);
|
const query = try query_cache.get(file_type, .highlights);
|
||||||
errdefer query_cache.release(query, .highlights);
|
|
||||||
const errors_query = try query_cache.get(file_type, .errors);
|
const errors_query = try query_cache.get(file_type, .errors);
|
||||||
errdefer query_cache.release(errors_query, .highlights);
|
|
||||||
const injections = try query_cache.get(file_type, .injections);
|
const injections = try query_cache.get(file_type, .injections);
|
||||||
errdefer if (injections) |injections_| query_cache.release(injections_, .injections);
|
|
||||||
const self = try allocator.create(Self);
|
const self = try allocator.create(Self);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.lang = file_type.lang_fn() orelse std.debug.panic("tree-sitter parser function failed for language: {s}", .{file_type.name}),
|
.lang = file_type.lang_fn() orelse std.debug.panic("tree-sitter parser function failed for language: {s}", .{file_type.name}),
|
||||||
|
@ -44,16 +40,17 @@ pub fn create(file_type: FileType, allocator: std.mem.Allocator, query_cache: *Q
|
||||||
.errors_query = errors_query,
|
.errors_query = errors_query,
|
||||||
.injections = injections,
|
.injections = injections,
|
||||||
};
|
};
|
||||||
|
errdefer self.destroy(query_cache);
|
||||||
try self.parser.setLanguage(self.lang);
|
try self.parser.setLanguage(self.lang);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn static_create_file_type(allocator: std.mem.Allocator, lang_name: []const u8, query_cache: *QueryCache) !*Self {
|
pub fn create_file_type_static(allocator: std.mem.Allocator, lang_name: []const u8, query_cache: *QueryCache) !*Self {
|
||||||
const file_type = FileType.get_by_name_static(lang_name) orelse return error.NotFound;
|
const file_type = FileType.get_by_name_static(lang_name) orelse return error.NotFound;
|
||||||
return create(file_type, allocator, query_cache);
|
return create(file_type, allocator, query_cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn static_create_guess_file_type_static(allocator: std.mem.Allocator, content: []const u8, file_path: ?[]const u8, query_cache: *QueryCache) !*Self {
|
pub fn create_guess_file_type_static(allocator: std.mem.Allocator, content: []const u8, file_path: ?[]const u8, query_cache: *QueryCache) !*Self {
|
||||||
const file_type = FileType.guess_static(file_path, content) orelse return error.NotFound;
|
const file_type = FileType.guess_static(file_path, content) orelse return error.NotFound;
|
||||||
return create(file_type, allocator, query_cache);
|
return create(file_type, allocator, query_cache);
|
||||||
}
|
}
|
||||||
|
@ -61,7 +58,6 @@ pub fn static_create_guess_file_type_static(allocator: std.mem.Allocator, conten
|
||||||
pub fn destroy(self: *Self, query_cache: *QueryCache) void {
|
pub fn destroy(self: *Self, query_cache: *QueryCache) void {
|
||||||
if (self.tree) |tree| tree.destroy();
|
if (self.tree) |tree| tree.destroy();
|
||||||
query_cache.release(self.query, .highlights);
|
query_cache.release(self.query, .highlights);
|
||||||
query_cache.release(self.errors_query, .highlights);
|
|
||||||
if (self.injections) |injections| query_cache.release(injections, .injections);
|
if (self.injections) |injections| query_cache.release(injections, .injections);
|
||||||
self.parser.destroy();
|
self.parser.destroy();
|
||||||
self.allocator.destroy(self);
|
self.allocator.destroy(self);
|
||||||
|
@ -102,7 +98,7 @@ pub fn refresh_from_buffer(self: *Self, buffer: anytype, metrics: anytype) !void
|
||||||
const input: Input = .{
|
const input: Input = .{
|
||||||
.payload = &state,
|
.payload = &state,
|
||||||
.read = struct {
|
.read = struct {
|
||||||
fn read(payload: ?*anyopaque, _: u32, position: treez.Point, bytes_read: *u32) callconv(.C) [*:0]const u8 {
|
fn read(payload: ?*anyopaque, _: u32, position: treez.Point, bytes_read: *u32) callconv(.c) [*:0]const u8 {
|
||||||
const ctx: *State = @ptrCast(@alignCast(payload orelse return ""));
|
const ctx: *State = @ptrCast(@alignCast(payload orelse return ""));
|
||||||
const result = ctx.buffer.get_from_pos(.{ .row = position.row, .col = position.column }, &ctx.result_buf, ctx.metrics);
|
const result = ctx.buffer.get_from_pos(.{ .row = position.row, .col = position.column }, &ctx.result_buf, ctx.metrics);
|
||||||
bytes_read.* = @intCast(result.len);
|
bytes_read.* = @intCast(result.len);
|
||||||
|
@ -128,7 +124,7 @@ pub fn refresh_from_string(self: *Self, content: [:0]const u8) !void {
|
||||||
const input: Input = .{
|
const input: Input = .{
|
||||||
.payload = &state,
|
.payload = &state,
|
||||||
.read = struct {
|
.read = struct {
|
||||||
fn read(payload: ?*anyopaque, _: u32, position: treez.Point, bytes_read: *u32) callconv(.C) [*:0]const u8 {
|
fn read(payload: ?*anyopaque, _: u32, position: treez.Point, bytes_read: *u32) callconv(.c) [*:0]const u8 {
|
||||||
bytes_read.* = 0;
|
bytes_read.* = 0;
|
||||||
const ctx: *State = @ptrCast(@alignCast(payload orelse return ""));
|
const ctx: *State = @ptrCast(@alignCast(payload orelse return ""));
|
||||||
const pos = (find_line_begin(ctx.content, position.row) orelse return "") + position.column;
|
const pos = (find_line_begin(ctx.content, position.row) orelse return "") + position.column;
|
||||||
|
|
|
@ -23,12 +23,12 @@ pub const InputEncoding = enum(c_uint) {
|
||||||
};
|
};
|
||||||
pub const Input = extern struct {
|
pub const Input = extern struct {
|
||||||
payload: ?*anyopaque,
|
payload: ?*anyopaque,
|
||||||
read: ?*const fn (payload: ?*anyopaque, byte_index: u32, position: Point, bytes_read: *u32) callconv(.C) [*:0]const u8,
|
read: ?*const fn (payload: ?*anyopaque, byte_index: u32, position: Point, bytes_read: *u32) callconv(.c) [*:0]const u8,
|
||||||
encoding: InputEncoding,
|
encoding: InputEncoding,
|
||||||
};
|
};
|
||||||
pub const Language = struct {
|
pub const Language = struct {
|
||||||
var dummy: @This() = .{};
|
var dummy: @This() = .{};
|
||||||
pub fn LangFn() callconv(.C) ?*const Language {
|
pub fn LangFn() callconv(.c) ?*const Language {
|
||||||
return &dummy;
|
return &dummy;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -91,7 +91,7 @@ const FileType = struct {
|
||||||
highlights: [:0]const u8,
|
highlights: [:0]const u8,
|
||||||
injections: ?[:0]const u8,
|
injections: ?[:0]const u8,
|
||||||
};
|
};
|
||||||
const LangFn = *const fn () callconv(.C) ?*const treez.Language;
|
const LangFn = *const fn () callconv(.c) ?*const treez.Language;
|
||||||
|
|
||||||
fn load_file_types(comptime Namespace: type) []const FileType {
|
fn load_file_types(comptime Namespace: type) []const FileType {
|
||||||
comptime switch (@typeInfo(Namespace)) {
|
comptime switch (@typeInfo(Namespace)) {
|
||||||
|
|
|
@ -285,7 +285,6 @@ pub const DeserializeError = error{
|
||||||
|
|
||||||
pub fn fromCbor(cb: []const u8, allocator: std.mem.Allocator) DeserializeError!struct { *TSQuery, *std.heap.ArenaAllocator } {
|
pub fn fromCbor(cb: []const u8, allocator: std.mem.Allocator) DeserializeError!struct { *TSQuery, *std.heap.ArenaAllocator } {
|
||||||
var arena = try allocator.create(std.heap.ArenaAllocator);
|
var arena = try allocator.create(std.heap.ArenaAllocator);
|
||||||
errdefer allocator.destroy(arena);
|
|
||||||
arena.* = std.heap.ArenaAllocator.init(allocator);
|
arena.* = std.heap.ArenaAllocator.init(allocator);
|
||||||
errdefer arena.deinit();
|
errdefer arena.deinit();
|
||||||
const query = try arena.allocator().create(TSQuery);
|
const query = try arena.allocator().create(TSQuery);
|
||||||
|
|
|
@ -48,7 +48,6 @@ pub fn Options(context: type) type {
|
||||||
pub fn create(ctx_type: type, allocator: std.mem.Allocator, parent: Plane, opts: Options(ctx_type)) error{OutOfMemory}!*State(ctx_type) {
|
pub fn create(ctx_type: type, allocator: std.mem.Allocator, parent: Plane, opts: Options(ctx_type)) error{OutOfMemory}!*State(ctx_type) {
|
||||||
const Self = State(ctx_type);
|
const Self = State(ctx_type);
|
||||||
const self = try allocator.create(Self);
|
const self = try allocator.create(Self);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
var n = try Plane.init(&opts.pos.opts(@typeName(Self)), parent);
|
var n = try Plane.init(&opts.pos.opts(@typeName(Self)), parent);
|
||||||
errdefer n.deinit();
|
errdefer n.deinit();
|
||||||
self.* = .{
|
self.* = .{
|
||||||
|
@ -58,7 +57,6 @@ pub fn create(ctx_type: type, allocator: std.mem.Allocator, parent: Plane, opts:
|
||||||
.opts = opts,
|
.opts = opts,
|
||||||
};
|
};
|
||||||
self.opts.label = try self.allocator.dupe(u8, opts.label);
|
self.opts.label = try self.allocator.dupe(u8, opts.label);
|
||||||
errdefer allocator.free(self.opts.label);
|
|
||||||
try self.init();
|
try self.init();
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,10 +58,9 @@ pub fn Options(context: type) type {
|
||||||
|
|
||||||
pub fn create(ctx_type: type, allocator: std.mem.Allocator, parent: Plane, opts: Options(ctx_type)) !Widget {
|
pub fn create(ctx_type: type, allocator: std.mem.Allocator, parent: Plane, opts: Options(ctx_type)) !Widget {
|
||||||
const Self = State(ctx_type);
|
const Self = State(ctx_type);
|
||||||
|
const self = try allocator.create(Self);
|
||||||
var n = try Plane.init(&opts.pos.opts(@typeName(Self)), parent);
|
var n = try Plane.init(&opts.pos.opts(@typeName(Self)), parent);
|
||||||
errdefer n.deinit();
|
errdefer n.deinit();
|
||||||
const self = try allocator.create(Self);
|
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.parent = parent,
|
.parent = parent,
|
||||||
.plane = n,
|
.plane = n,
|
||||||
|
|
|
@ -56,7 +56,6 @@ pub fn Options(context: type) type {
|
||||||
|
|
||||||
pub fn create(ctx_type: type, allocator: std.mem.Allocator, parent: Plane, opts: Options(ctx_type)) !*State(ctx_type) {
|
pub fn create(ctx_type: type, allocator: std.mem.Allocator, parent: Plane, opts: Options(ctx_type)) !*State(ctx_type) {
|
||||||
const self = try allocator.create(State(ctx_type));
|
const self = try allocator.create(State(ctx_type));
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
const container = try WidgetList.createH(allocator, parent, @typeName(@This()), .dynamic);
|
const container = try WidgetList.createH(allocator, parent, @typeName(@This()), .dynamic);
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
|
|
|
@ -59,7 +59,6 @@ pub fn Options(context: type) type {
|
||||||
|
|
||||||
pub fn create(ctx_type: type, allocator: std.mem.Allocator, parent: Widget, opts: Options(ctx_type)) !*State(ctx_type) {
|
pub fn create(ctx_type: type, allocator: std.mem.Allocator, parent: Widget, opts: Options(ctx_type)) !*State(ctx_type) {
|
||||||
const self = try allocator.create(State(ctx_type));
|
const self = try allocator.create(State(ctx_type));
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.plane = parent.plane.*,
|
.plane = parent.plane.*,
|
||||||
|
|
|
@ -224,7 +224,6 @@ pub fn hover(self: *Self) bool {
|
||||||
pub fn empty(allocator: Allocator, parent: Plane, layout_: Layout) !Self {
|
pub fn empty(allocator: Allocator, parent: Plane, layout_: Layout) !Self {
|
||||||
const child: type = struct { plane: Plane, layout: Layout };
|
const child: type = struct { plane: Plane, layout: Layout };
|
||||||
const widget = try allocator.create(child);
|
const widget = try allocator.create(child);
|
||||||
errdefer allocator.destroy(widget);
|
|
||||||
const n = try Plane.init(&(Box{}).opts("empty"), parent);
|
const n = try Plane.init(&(Box{}).opts("empty"), parent);
|
||||||
widget.* = .{ .plane = n, .layout = layout_ };
|
widget.* = .{ .plane = n, .layout = layout_ };
|
||||||
return .{
|
return .{
|
||||||
|
|
|
@ -32,24 +32,21 @@ after_render: *const fn (ctx: ?*anyopaque, theme: *const Widget.Theme) void = on
|
||||||
on_resize: *const fn (ctx: ?*anyopaque, self: *Self, pos_: Widget.Box) void = on_resize_default,
|
on_resize: *const fn (ctx: ?*anyopaque, self: *Self, pos_: Widget.Box) void = on_resize_default,
|
||||||
|
|
||||||
pub fn createH(allocator: Allocator, parent: Plane, name: [:0]const u8, layout_: Layout) error{OutOfMemory}!*Self {
|
pub fn createH(allocator: Allocator, parent: Plane, name: [:0]const u8, layout_: Layout) error{OutOfMemory}!*Self {
|
||||||
const self = try allocator.create(Self);
|
const self: *Self = try allocator.create(Self);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = try init(allocator, parent, name, .horizontal, layout_, Box{});
|
self.* = try init(allocator, parent, name, .horizontal, layout_, Box{});
|
||||||
self.plane.hide();
|
self.plane.hide();
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn createV(allocator: Allocator, parent: Plane, name: [:0]const u8, layout_: Layout) !*Self {
|
pub fn createV(allocator: Allocator, parent: Plane, name: [:0]const u8, layout_: Layout) !*Self {
|
||||||
const self = try allocator.create(Self);
|
const self: *Self = try allocator.create(Self);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = try init(allocator, parent, name, .vertical, layout_, Box{});
|
self.* = try init(allocator, parent, name, .vertical, layout_, Box{});
|
||||||
self.plane.hide();
|
self.plane.hide();
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn createBox(allocator: Allocator, parent: Plane, name: [:0]const u8, dir: Direction, layout_: Layout, box: Box) !*Self {
|
pub fn createBox(allocator: Allocator, parent: Plane, name: [:0]const u8, dir: Direction, layout_: Layout, box: Box) !*Self {
|
||||||
const self = try allocator.create(Self);
|
const self: *Self = try allocator.create(Self);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = try init(allocator, parent, name, dir, layout_, box);
|
self.* = try init(allocator, parent, name, dir, layout_, box);
|
||||||
self.plane.hide();
|
self.plane.hide();
|
||||||
return self;
|
return self;
|
||||||
|
|
|
@ -5941,8 +5941,7 @@ pub const EditorWidget = struct {
|
||||||
|
|
||||||
fn create(allocator: Allocator, parent: Plane, buffer_manager: *Buffer.Manager) !Widget {
|
fn create(allocator: Allocator, parent: Plane, buffer_manager: *Buffer.Manager) !Widget {
|
||||||
const container = try WidgetList.createH(allocator, parent, "editor.container", .dynamic);
|
const container = try WidgetList.createH(allocator, parent, "editor.container", .dynamic);
|
||||||
const self = try allocator.create(Self);
|
const self: *Self = try allocator.create(Self);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
try self.init(allocator, container.plane, buffer_manager);
|
try self.init(allocator, container.plane, buffer_manager);
|
||||||
try self.commands.init(&self.editor);
|
try self.commands.init(&self.editor);
|
||||||
const editorWidget = Widget.to(self);
|
const editorWidget = Widget.to(self);
|
||||||
|
|
|
@ -43,8 +43,7 @@ const Kind = enum { insert, modified, delete };
|
||||||
const Symbol = struct { kind: Kind, line: usize };
|
const Symbol = struct { kind: Kind, line: usize };
|
||||||
|
|
||||||
pub fn create(allocator: Allocator, parent: Widget, event_source: Widget, editor: *ed.Editor) !Widget {
|
pub fn create(allocator: Allocator, parent: Widget, event_source: Widget, editor: *ed.Editor) !Widget {
|
||||||
const self = try allocator.create(Self);
|
const self: *Self = try allocator.create(Self);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.plane = try Plane.init(&(Widget.Box{}).opts(@typeName(Self)), parent.plane.*),
|
.plane = try Plane.init(&(Widget.Box{}).opts(@typeName(Self)), parent.plane.*),
|
||||||
|
|
|
@ -47,8 +47,7 @@ const Entry = struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn create(allocator: Allocator, parent: Plane) !Widget {
|
pub fn create(allocator: Allocator, parent: Plane) !Widget {
|
||||||
const self = try allocator.create(Self);
|
const self: *Self = try allocator.create(Self);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.plane = try Plane.init(&(Widget.Box{}).opts(name), parent),
|
.plane = try Plane.init(&(Widget.Box{}).opts(name), parent),
|
||||||
|
|
|
@ -81,8 +81,7 @@ const Self = @This();
|
||||||
|
|
||||||
pub fn create(allocator: std.mem.Allocator, parent: Widget) !Widget {
|
pub fn create(allocator: std.mem.Allocator, parent: Widget) !Widget {
|
||||||
const logger = log.logger("home");
|
const logger = log.logger("home");
|
||||||
const self = try allocator.create(Self);
|
const self: *Self = try allocator.create(Self);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
var n = try Plane.init(&(Widget.Box{}).opts("editor"), parent.plane.*);
|
var n = try Plane.init(&(Widget.Box{}).opts("editor"), parent.plane.*);
|
||||||
errdefer n.deinit();
|
errdefer n.deinit();
|
||||||
|
|
||||||
|
@ -304,8 +303,6 @@ pub fn render(self: *Self, theme: *const Widget.Theme) bool {
|
||||||
self.position_menu(self.v_center(5, self.menu_len, 5), self.center(x, self.menu_w));
|
self.position_menu(self.v_center(5, self.menu_len, 5), self.center(x, self.menu_w));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.plane.dim_y() < 3 or self.plane.dim_x() < root.version.len + 4) return false;
|
|
||||||
|
|
||||||
self.plane.cursor_move_yx(
|
self.plane.cursor_move_yx(
|
||||||
@intCast(self.plane.dim_y() - 2),
|
@intCast(self.plane.dim_y() - 2),
|
||||||
@intCast(@max(self.plane.dim_x(), root.version.len + 3) - root.version.len - 3),
|
@intCast(@max(self.plane.dim_x(), root.version.len + 3) - root.version.len - 3),
|
||||||
|
@ -314,7 +311,6 @@ pub fn render(self: *Self, theme: *const Widget.Theme) bool {
|
||||||
_ = self.plane.print("{s}", .{root.version}) catch return false;
|
_ = self.plane.print("{s}", .{root.version}) catch return false;
|
||||||
if (builtin.mode == .Debug) {
|
if (builtin.mode == .Debug) {
|
||||||
const debug_warning_text = "debug build";
|
const debug_warning_text = "debug build";
|
||||||
if (self.plane.dim_y() < 4 or self.plane.dim_x() < debug_warning_text.len + 4) return false;
|
|
||||||
self.plane.cursor_move_yx(
|
self.plane.cursor_move_yx(
|
||||||
@intCast(self.plane.dim_y() - 3),
|
@intCast(self.plane.dim_y() - 3),
|
||||||
@intCast(@max(self.plane.dim_x(), debug_warning_text.len + 3) - debug_warning_text.len - 3),
|
@intCast(@max(self.plane.dim_x(), debug_warning_text.len + 3) - debug_warning_text.len - 3),
|
||||||
|
|
|
@ -14,8 +14,7 @@ view_rows: usize = 0,
|
||||||
lines: std.ArrayList([]const u8),
|
lines: std.ArrayList([]const u8),
|
||||||
|
|
||||||
pub fn create(allocator: Allocator, parent: Plane) !Widget {
|
pub fn create(allocator: Allocator, parent: Plane) !Widget {
|
||||||
const self = try allocator.create(Self);
|
const self: *Self = try allocator.create(Self);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.plane = try Plane.init(&(Widget.Box{}).opts(name), parent),
|
.plane = try Plane.init(&(Widget.Box{}).opts(name), parent),
|
||||||
|
|
|
@ -30,10 +30,9 @@ const Entry = struct {
|
||||||
const Buffer = ArrayList(Entry);
|
const Buffer = ArrayList(Entry);
|
||||||
|
|
||||||
pub fn create(allocator: Allocator, parent: Plane) !Widget {
|
pub fn create(allocator: Allocator, parent: Plane) !Widget {
|
||||||
|
const self: *Self = try allocator.create(Self);
|
||||||
var n = try Plane.init(&(Widget.Box{}).opts_vscroll(@typeName(Self)), parent);
|
var n = try Plane.init(&(Widget.Box{}).opts_vscroll(@typeName(Self)), parent);
|
||||||
errdefer n.deinit();
|
errdefer n.deinit();
|
||||||
const self = try allocator.create(Self);
|
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.parent = parent,
|
.parent = parent,
|
||||||
|
|
|
@ -26,8 +26,7 @@ const Self = @This();
|
||||||
|
|
||||||
pub fn create(allocator: Allocator, parent: Plane) !Widget {
|
pub fn create(allocator: Allocator, parent: Plane) !Widget {
|
||||||
const editor = tui.get_active_editor() orelse return error.NotFound;
|
const editor = tui.get_active_editor() orelse return error.NotFound;
|
||||||
const self = try allocator.create(Self);
|
const self: *Self = try allocator.create(Self);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.plane = try Plane.init(&(Widget.Box{}).opts_vscroll(name), parent),
|
.plane = try Plane.init(&(Widget.Box{}).opts_vscroll(name), parent),
|
||||||
.editor = editor,
|
.editor = editor,
|
||||||
|
|
|
@ -38,8 +38,7 @@ const Level = enum {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn create(allocator: Allocator, parent: Plane) !Widget {
|
pub fn create(allocator: Allocator, parent: Plane) !Widget {
|
||||||
const self = try allocator.create(Self);
|
const self: *Self = try allocator.create(Self);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = .{ .plane = try Plane.init(&(Widget.Box{}).opts(name), parent) };
|
self.* = .{ .plane = try Plane.init(&(Widget.Box{}).opts(name), parent) };
|
||||||
return Widget.to(self);
|
return Widget.to(self);
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,6 @@ pub const CreateError = error{ OutOfMemory, ThespianSpawnFailed };
|
||||||
|
|
||||||
pub fn create(allocator: std.mem.Allocator) CreateError!Widget {
|
pub fn create(allocator: std.mem.Allocator) CreateError!Widget {
|
||||||
const self = try allocator.create(Self);
|
const self = try allocator.create(Self);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.plane = tui.plane(),
|
.plane = tui.plane(),
|
||||||
|
|
|
@ -21,8 +21,7 @@ pub fn Create(options: type) type {
|
||||||
const Self = @This();
|
const Self = @This();
|
||||||
|
|
||||||
pub fn create(allocator: std.mem.Allocator, _: command.Context) !struct { tui.Mode, tui.MiniMode } {
|
pub fn create(allocator: std.mem.Allocator, _: command.Context) !struct { tui.Mode, tui.MiniMode } {
|
||||||
const self = try allocator.create(Self);
|
const self: *Self = try allocator.create(Self);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.input = std.ArrayList(u8).init(allocator),
|
.input = std.ArrayList(u8).init(allocator),
|
||||||
|
|
|
@ -35,8 +35,7 @@ pub fn Create(options: type) type {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn create(allocator: std.mem.Allocator, _: command.Context) !struct { tui.Mode, tui.MiniMode } {
|
pub fn create(allocator: std.mem.Allocator, _: command.Context) !struct { tui.Mode, tui.MiniMode } {
|
||||||
const self = try allocator.create(Self);
|
const self: *Self = try allocator.create(Self);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.file_path = std.ArrayList(u8).init(allocator),
|
.file_path = std.ArrayList(u8).init(allocator),
|
||||||
|
|
|
@ -28,8 +28,7 @@ commands: Commands = undefined,
|
||||||
|
|
||||||
pub fn create(allocator: Allocator, _: command.Context) !struct { tui.Mode, tui.MiniMode } {
|
pub fn create(allocator: Allocator, _: command.Context) !struct { tui.Mode, tui.MiniMode } {
|
||||||
const editor = tui.get_active_editor() orelse return error.NotFound;
|
const editor = tui.get_active_editor() orelse return error.NotFound;
|
||||||
const self = try allocator.create(Self);
|
const self: *Self = try allocator.create(Self);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.input_ = ArrayList(u8).init(allocator),
|
.input_ = ArrayList(u8).init(allocator),
|
||||||
|
|
|
@ -25,8 +25,7 @@ last_input: []u8 = "",
|
||||||
commands: Commands = undefined,
|
commands: Commands = undefined,
|
||||||
|
|
||||||
pub fn create(allocator: Allocator, _: command.Context) !struct { tui.Mode, tui.MiniMode } {
|
pub fn create(allocator: Allocator, _: command.Context) !struct { tui.Mode, tui.MiniMode } {
|
||||||
const self = try allocator.create(Self);
|
const self: *Self = try allocator.create(Self);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = .{ .allocator = allocator };
|
self.* = .{ .allocator = allocator };
|
||||||
try self.commands.init(self);
|
try self.commands.init(self);
|
||||||
if (tui.get_active_selection(self.allocator)) |text| {
|
if (tui.get_active_selection(self.allocator)) |text| {
|
||||||
|
|
|
@ -24,9 +24,8 @@ start: usize,
|
||||||
commands: Commands = undefined,
|
commands: Commands = undefined,
|
||||||
|
|
||||||
pub fn create(allocator: Allocator, _: command.Context) !struct { tui.Mode, tui.MiniMode } {
|
pub fn create(allocator: Allocator, _: command.Context) !struct { tui.Mode, tui.MiniMode } {
|
||||||
|
const self: *Self = try allocator.create(Self);
|
||||||
const editor = tui.get_active_editor() orelse return error.NotFound;
|
const editor = tui.get_active_editor() orelse return error.NotFound;
|
||||||
const self = try allocator.create(Self);
|
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.start = editor.get_primary().cursor.row + 1,
|
.start = editor.get_primary().cursor.row + 1,
|
||||||
|
|
|
@ -38,8 +38,7 @@ pub fn create(allocator: Allocator, ctx: command.Context) !struct { tui.Mode, tu
|
||||||
const direction: Direction = if (std.mem.indexOf(u8, operation_command, "_left")) |_| .left else .right;
|
const direction: Direction = if (std.mem.indexOf(u8, operation_command, "_left")) |_| .left else .right;
|
||||||
const operation: Operation = if (tui.get_active_editor()) |editor| if (editor.get_primary().selection) |_| .select else .move else .move;
|
const operation: Operation = if (tui.get_active_editor()) |editor| if (editor.get_primary().selection) |_| .select else .move else .move;
|
||||||
|
|
||||||
const self = try allocator.create(Self);
|
const self: *Self = try allocator.create(Self);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.direction = direction,
|
.direction = direction,
|
||||||
|
|
|
@ -38,8 +38,7 @@ buffer_manager: ?*BufferManager,
|
||||||
|
|
||||||
pub fn create(allocator: std.mem.Allocator) !tui.Mode {
|
pub fn create(allocator: std.mem.Allocator) !tui.Mode {
|
||||||
const mv = tui.mainview() orelse return error.NotFound;
|
const mv = tui.mainview() orelse return error.NotFound;
|
||||||
const self = try allocator.create(Self);
|
const self: *Self = try allocator.create(Self);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.modal = try ModalBackground.create(*Self, allocator, tui.mainview_widget(), .{ .ctx = self }),
|
.modal = try ModalBackground.create(*Self, allocator, tui.mainview_widget(), .{ .ctx = self }),
|
||||||
|
|
|
@ -47,8 +47,7 @@ pub fn Create(options: type) type {
|
||||||
|
|
||||||
pub fn create(allocator: std.mem.Allocator) !tui.Mode {
|
pub fn create(allocator: std.mem.Allocator) !tui.Mode {
|
||||||
const mv = tui.mainview() orelse return error.NotFound;
|
const mv = tui.mainview() orelse return error.NotFound;
|
||||||
const self = try allocator.create(Self);
|
const self: *Self = try allocator.create(Self);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.modal = try ModalBackground.create(*Self, allocator, tui.mainview_widget(), .{
|
.modal = try ModalBackground.create(*Self, allocator, tui.mainview_widget(), .{
|
||||||
|
|
|
@ -27,8 +27,7 @@ style_factory: ?*const fn (self: *Self, theme: *const Widget.Theme) Widget.Theme
|
||||||
const Self = @This();
|
const Self = @This();
|
||||||
|
|
||||||
pub fn create(allocator: Allocator, parent: Plane, event_source: ?Widget, event_sink: EventHandler) !Widget {
|
pub fn create(allocator: Allocator, parent: Plane, event_source: ?Widget, event_sink: EventHandler) !Widget {
|
||||||
const self = try allocator.create(Self);
|
const self: *Self = try allocator.create(Self);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.plane = try Plane.init(&(Widget.Box{}).opts(@typeName(Self)), parent),
|
.plane = try Plane.init(&(Widget.Box{}).opts(@typeName(Self)), parent),
|
||||||
.event_sink = event_sink,
|
.event_sink = event_sink,
|
||||||
|
|
|
@ -20,8 +20,7 @@ pub fn Create(comptime layout_: Widget.Layout) @import("widget.zig").CreateFunct
|
||||||
break :blk Widget.Layout{ .static = size };
|
break :blk Widget.Layout{ .static = size };
|
||||||
} else break :blk layout_;
|
} else break :blk layout_;
|
||||||
} else layout_;
|
} else layout_;
|
||||||
const self = try allocator.create(Self);
|
const self: *Self = try allocator.create(Self);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.plane = try Plane.init(&(Widget.Box{}).opts(@typeName(Self)), parent),
|
.plane = try Plane.init(&(Widget.Box{}).opts(@typeName(Self)), parent),
|
||||||
.layout_ = layout__,
|
.layout_ = layout__,
|
||||||
|
|
|
@ -30,8 +30,7 @@ pub fn create(allocator: std.mem.Allocator, parent: Plane, event_handler: ?Event
|
||||||
return error.WidgetInitFailed;
|
return error.WidgetInitFailed;
|
||||||
};
|
};
|
||||||
defer env.deinit();
|
defer env.deinit();
|
||||||
const self = try allocator.create(Self);
|
const self: *Self = try allocator.create(Self);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.plane = try Plane.init(&(Widget.Box{}).opts(@typeName(Self)), parent),
|
.plane = try Plane.init(&(Widget.Box{}).opts(@typeName(Self)), parent),
|
||||||
|
|
|
@ -12,8 +12,7 @@ plane: Plane,
|
||||||
const Self = @This();
|
const Self = @This();
|
||||||
|
|
||||||
pub fn create(allocator: std.mem.Allocator, parent: Plane, _: ?EventHandler, _: ?[]const u8) @import("widget.zig").CreateError!Widget {
|
pub fn create(allocator: std.mem.Allocator, parent: Plane, _: ?EventHandler, _: ?[]const u8) @import("widget.zig").CreateError!Widget {
|
||||||
const self = try allocator.create(Self);
|
const self: *Self = try allocator.create(Self);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.plane = try Plane.init(&(Widget.Box{}).opts(@typeName(Self)), parent),
|
.plane = try Plane.init(&(Widget.Box{}).opts(@typeName(Self)), parent),
|
||||||
|
|
|
@ -31,8 +31,7 @@ pub const width = idle_msg.len + 20;
|
||||||
|
|
||||||
pub fn create(allocator: Allocator, parent: Plane, _: ?EventHandler, _: ?[]const u8) @import("widget.zig").CreateError!Widget {
|
pub fn create(allocator: Allocator, parent: Plane, _: ?EventHandler, _: ?[]const u8) @import("widget.zig").CreateError!Widget {
|
||||||
const frame_rate = tp.env.get().num("frame-rate");
|
const frame_rate = tp.env.get().num("frame-rate");
|
||||||
const self = try allocator.create(Self);
|
const self: *Self = try allocator.create(Self);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.plane = try Plane.init(&(Widget.Box{}).opts(@typeName(Self)), parent),
|
.plane = try Plane.init(&(Widget.Box{}).opts(@typeName(Self)), parent),
|
||||||
.wipe_after_frames = @divTrunc(frame_rate, 2),
|
.wipe_after_frames = @divTrunc(frame_rate, 2),
|
||||||
|
|
|
@ -27,8 +27,7 @@ const Level = enum {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn create(allocator: std.mem.Allocator, parent: Plane, event_handler: ?EventHandler, _: ?[]const u8) @import("widget.zig").CreateError!Widget {
|
pub fn create(allocator: std.mem.Allocator, parent: Plane, event_handler: ?EventHandler, _: ?[]const u8) @import("widget.zig").CreateError!Widget {
|
||||||
const self = try allocator.create(Self);
|
const self: *Self = try allocator.create(Self);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.plane = try Plane.init(&(Widget.Box{}).opts(@typeName(Self)), parent),
|
.plane = try Plane.init(&(Widget.Box{}).opts(@typeName(Self)), parent),
|
||||||
.msg = std.ArrayList(u8).init(allocator),
|
.msg = std.ArrayList(u8).init(allocator),
|
||||||
|
|
|
@ -20,8 +20,7 @@ const Self = @This();
|
||||||
pub const width = 8;
|
pub const width = 8;
|
||||||
|
|
||||||
pub fn create(allocator: Allocator, parent: Plane, _: ?EventHandler, _: ?[]const u8) @import("widget.zig").CreateError!Widget {
|
pub fn create(allocator: Allocator, parent: Plane, _: ?EventHandler, _: ?[]const u8) @import("widget.zig").CreateError!Widget {
|
||||||
const self = try allocator.create(Self);
|
const self: *Self = try allocator.create(Self);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.plane = try Plane.init(&(Widget.Box{}).opts(@typeName(Self)), parent),
|
.plane = try Plane.init(&(Widget.Box{}).opts(@typeName(Self)), parent),
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,8 +19,7 @@ on_event: ?EventHandler,
|
||||||
const Self = @This();
|
const Self = @This();
|
||||||
|
|
||||||
pub fn create(allocator: Allocator, parent: Plane, event_handler: ?EventHandler, _: ?[]const u8) @import("widget.zig").CreateError!Widget {
|
pub fn create(allocator: Allocator, parent: Plane, event_handler: ?EventHandler, _: ?[]const u8) @import("widget.zig").CreateError!Widget {
|
||||||
const self = try allocator.create(Self);
|
const self: *Self = try allocator.create(Self);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.plane = try Plane.init(&(Widget.Box{}).opts(@typeName(Self)), parent),
|
.plane = try Plane.init(&(Widget.Box{}).opts(@typeName(Self)), parent),
|
||||||
.on_event = event_handler,
|
.on_event = event_handler,
|
||||||
|
|
|
@ -54,7 +54,6 @@ pub const Style = @"style.config";
|
||||||
|
|
||||||
pub fn create(allocator: std.mem.Allocator, parent: Plane, event_handler: ?EventHandler, _: ?[]const u8) @import("widget.zig").CreateError!Widget {
|
pub fn create(allocator: std.mem.Allocator, parent: Plane, event_handler: ?EventHandler, _: ?[]const u8) @import("widget.zig").CreateError!Widget {
|
||||||
const self = try allocator.create(TabBar);
|
const self = try allocator.create(TabBar);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = try TabBar.init(allocator, parent, event_handler);
|
self.* = try TabBar.init(allocator, parent, event_handler);
|
||||||
return Widget.to(self);
|
return Widget.to(self);
|
||||||
}
|
}
|
||||||
|
@ -448,7 +447,6 @@ const spacer = struct {
|
||||||
event_handler: ?EventHandler,
|
event_handler: ?EventHandler,
|
||||||
) @import("widget.zig").CreateError!Widget {
|
) @import("widget.zig").CreateError!Widget {
|
||||||
const self: *Self = try allocator.create(Self);
|
const self: *Self = try allocator.create(Self);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.plane = try Plane.init(&(Widget.Box{}).opts(@typeName(Self)), parent),
|
.plane = try Plane.init(&(Widget.Box{}).opts(@typeName(Self)), parent),
|
||||||
.layout_ = .{ .static = self.plane.egc_chunk_width(content, 0, 1) },
|
.layout_ = .{ .static = self.plane.egc_chunk_width(content, 0, 1) },
|
||||||
|
|
|
@ -120,9 +120,6 @@ fn init(allocator: Allocator) InitError!*Self {
|
||||||
const frame_clock = try tp.metronome.init(frame_time);
|
const frame_clock = try tp.metronome.init(frame_time);
|
||||||
|
|
||||||
var self = try allocator.create(Self);
|
var self = try allocator.create(Self);
|
||||||
// don't destroy
|
|
||||||
// if tui fails it is catastrophic anyway and we don't want to cause nock-on errors
|
|
||||||
// errdefer allocator.destroy(self);
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.config_ = conf,
|
.config_ = conf,
|
||||||
|
|
|
@ -21,7 +21,6 @@ pub fn start(a_: std.mem.Allocator, root_path_: []const u8) (SpawnError || std.f
|
||||||
|
|
||||||
fn spawn_link(allocator: std.mem.Allocator, root_path: []const u8) (SpawnError || std.fs.Dir.OpenError)!tp.pid {
|
fn spawn_link(allocator: std.mem.Allocator, root_path: []const u8) (SpawnError || std.fs.Dir.OpenError)!tp.pid {
|
||||||
const self = try allocator.create(tree_walker);
|
const self = try allocator.create(tree_walker);
|
||||||
errdefer allocator.destroy(self);
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.root_path = try allocator.dupe(u8, root_path),
|
.root_path = try allocator.dupe(u8, root_path),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue