build: update to zig 0.14.0-dev.3039
This commit is contained in:
parent
1764b3259c
commit
53045123c6
41 changed files with 648 additions and 623 deletions
|
@ -1 +1 @@
|
||||||
0.13.0
|
0.14.0-dev.3039+e61acd8eb
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
.dependencies = .{
|
.dependencies = .{
|
||||||
.syntax = .{ .path = "src/syntax" },
|
.syntax = .{ .path = "src/syntax" },
|
||||||
.flags = .{
|
.flags = .{
|
||||||
.url = "https://github.com/n0s4/flags/archive/b3905aa990719ff567f1c5a2f89e6dd3292d8533.tar.gz",
|
.url = "https://github.com/n0s4/flags/archive/372501d1576b5723829bcba98e41361132c7b618.tar.gz",
|
||||||
.hash = "1220930a42f8da3fb7f723e3ad3f6dcc6db76327dd8d26274566423192d53e91b2bb",
|
.hash = "1220ae181067a549c7a99cc0868193a7889b151381410419191ab1a79304f914336e",
|
||||||
},
|
},
|
||||||
.tracy = .{
|
.tracy = .{
|
||||||
.url = "https://github.com/neurocyte/zig-tracy/archive/e04e31c64498149a324491b8534758e6af43a5c2.tar.gz",
|
.url = "https://github.com/neurocyte/zig-tracy/archive/e04e31c64498149a324491b8534758e6af43a5c2.tar.gz",
|
||||||
|
@ -18,28 +18,28 @@
|
||||||
.hash = "1220220dbc7fe91c1c54438193ca765cebbcb7d58f35cdcaee404a9d2245a42a4362",
|
.hash = "1220220dbc7fe91c1c54438193ca765cebbcb7d58f35cdcaee404a9d2245a42a4362",
|
||||||
},
|
},
|
||||||
.thespian = .{
|
.thespian = .{
|
||||||
.url = "https://github.com/neurocyte/thespian/archive/db3ad5f45e707a04eaa51aa657995abe43ce967a.tar.gz",
|
.url = "https://github.com/neurocyte/thespian/archive/063c441c30aafd212b4d8e97555590594855a082.tar.gz",
|
||||||
.hash = "1220bbfd147f41fa49d2e5406096f3529c62e9335f4d2a89ae381e679a76ce398f1f",
|
.hash = "1220d04b3ac1fd1584796d8047a24cccca834592bb2ee7175e1692a1fc6d6d791fb1",
|
||||||
},
|
},
|
||||||
.themes = .{
|
.themes = .{
|
||||||
.url = "https://github.com/neurocyte/flow-themes/releases/download/master-618a7801d3383049adfe18cc09f5f5086c66995f/flow-themes.tar.gz",
|
.url = "https://github.com/neurocyte/flow-themes/releases/download/master-618a7801d3383049adfe18cc09f5f5086c66995f/flow-themes.tar.gz",
|
||||||
.hash = "1220019ed92f48fb94d4ae82bba17b11d0ba06f17ed31cd66613b3c048b1d2382095",
|
.hash = "1220019ed92f48fb94d4ae82bba17b11d0ba06f17ed31cd66613b3c048b1d2382095",
|
||||||
},
|
},
|
||||||
.fuzzig = .{
|
.fuzzig = .{
|
||||||
.url = "https://github.com/fjebaker/fuzzig/archive/0fd156d5097365151e85a85eef9d8cf0eebe7b00.tar.gz",
|
.url = "https://github.com/fjebaker/fuzzig/archive/44c04733c7c0fee3db83672aaaaf4ed03e943156.tar.gz",
|
||||||
.hash = "122019f077d09686b1ec47928ca2b4bf264422f3a27afc5b49dafb0129a4ceca0d01",
|
.hash = "1220666c7afe30f6a51ae477f7755e9b6a5341723bfcb5de349817b5d0912b96f9ad",
|
||||||
},
|
},
|
||||||
.vaxis = .{
|
.vaxis = .{
|
||||||
.url = "https://github.com/neurocyte/libvaxis/archive/d899244bc0a3775b59c18e90eb41acee11675f96.tar.gz",
|
.url = "https://github.com/neurocyte/libvaxis/archive/eb0fe09b1b3d1ad282b6f372672748f0459211eb.tar.gz",
|
||||||
.hash = "12207e33747072d878fce61f587c133124dc95f4ae8aab7d2b3f467699586af07c77",
|
.hash = "1220cd97dea400cc5a76ceb9d9bbeff4b5aa81e2703d354a5d4de3483b315d4eb437",
|
||||||
},
|
},
|
||||||
.zeit = .{
|
.zeit = .{
|
||||||
.url = "https://github.com/rockorager/zeit/archive/8fd203f85f597f16e0a525c1f1ca1e0bffded809.tar.gz",
|
.url = "https://github.com/rockorager/zeit/archive/8fd203f85f597f16e0a525c1f1ca1e0bffded809.tar.gz",
|
||||||
.hash = "122022233835adc719535a8e7cefdd2902a67bbfb7ef198441ca9ce89c0593f488c2",
|
.hash = "122022233835adc719535a8e7cefdd2902a67bbfb7ef198441ca9ce89c0593f488c2",
|
||||||
},
|
},
|
||||||
.win32 = .{
|
.win32 = .{
|
||||||
.url = "https://github.com/marlersoft/zigwin32/archive/259b6f353a48968d7e3171573db4fd898b046188.tar.gz",
|
.url = "https://github.com/marlersoft/zigwin32/archive/e8739b32a33ce48a3286aba31918b26a9dfc6ef0.tar.gz",
|
||||||
.hash = "1220925614447b54ccc9894bbba8b202c6a8b750267890edab7732064867e46f3217",
|
.hash = "1220219ca4acfa5804ca39945f92554e93507b077c03605b7a4c1c0401f0c7121339",
|
||||||
.lazy = true,
|
.lazy = true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -16,7 +16,7 @@ pub const VTable = struct {
|
||||||
|
|
||||||
pub fn to_owned(pimpl: anytype) Self {
|
pub fn to_owned(pimpl: anytype) Self {
|
||||||
const impl = @typeInfo(@TypeOf(pimpl));
|
const impl = @typeInfo(@TypeOf(pimpl));
|
||||||
const child: type = impl.Pointer.child;
|
const child: type = impl.pointer.child;
|
||||||
return .{
|
return .{
|
||||||
.ptr = pimpl,
|
.ptr = pimpl,
|
||||||
.vtable = comptime &.{
|
.vtable = comptime &.{
|
||||||
|
@ -56,7 +56,7 @@ var none = {};
|
||||||
|
|
||||||
pub fn to_unowned(pimpl: anytype) Self {
|
pub fn to_unowned(pimpl: anytype) Self {
|
||||||
const impl = @typeInfo(@TypeOf(pimpl));
|
const impl = @typeInfo(@TypeOf(pimpl));
|
||||||
const child: type = impl.Pointer.child;
|
const child: type = impl.pointer.child;
|
||||||
return .{
|
return .{
|
||||||
.ptr = pimpl,
|
.ptr = pimpl,
|
||||||
.vtable = comptime &.{
|
.vtable = comptime &.{
|
||||||
|
@ -79,7 +79,7 @@ pub fn to_unowned(pimpl: anytype) Self {
|
||||||
|
|
||||||
pub fn bind(pimpl: anytype, comptime f: *const fn (ctx: @TypeOf(pimpl), from: tp.pid_ref, m: tp.message) tp.result) Self {
|
pub fn bind(pimpl: anytype, comptime f: *const fn (ctx: @TypeOf(pimpl), from: tp.pid_ref, m: tp.message) tp.result) Self {
|
||||||
const impl = @typeInfo(@TypeOf(pimpl));
|
const impl = @typeInfo(@TypeOf(pimpl));
|
||||||
const child: type = impl.Pointer.child;
|
const child: type = impl.pointer.child;
|
||||||
return .{
|
return .{
|
||||||
.ptr = pimpl,
|
.ptr = pimpl,
|
||||||
.vtable = comptime &.{
|
.vtable = comptime &.{
|
||||||
|
|
|
@ -172,9 +172,9 @@ const Process = struct {
|
||||||
const frame = tracy.initZone(@src(), .{ .name = module_name });
|
const frame = tracy.initZone(@src(), .{ .name = module_name });
|
||||||
defer frame.deinit();
|
defer frame.deinit();
|
||||||
errdefer self.deinit();
|
errdefer self.deinit();
|
||||||
var method: []u8 = "";
|
var method: []const u8 = "";
|
||||||
var bytes: []u8 = "";
|
var bytes: []const u8 = "";
|
||||||
var err: []u8 = "";
|
var err: []const u8 = "";
|
||||||
var code: u32 = 0;
|
var code: u32 = 0;
|
||||||
var cbor_id: []const u8 = "";
|
var cbor_id: []const u8 = "";
|
||||||
|
|
||||||
|
@ -259,7 +259,7 @@ const Process = struct {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_output(self: *Process, bytes: []u8) Error!void {
|
fn handle_output(self: *Process, bytes: []const u8) Error!void {
|
||||||
try self.recv_buf.appendSlice(bytes);
|
try self.recv_buf.appendSlice(bytes);
|
||||||
self.write_log("### RECV:\n{s}\n###\n", .{bytes});
|
self.write_log("### RECV:\n{s}\n###\n", .{bytes});
|
||||||
self.frame_message_recv() catch |e| {
|
self.frame_message_recv() catch |e| {
|
||||||
|
|
|
@ -51,7 +51,7 @@ mtime: i64,
|
||||||
utime: i64,
|
utime: i64,
|
||||||
|
|
||||||
pub const EolMode = enum { lf, crlf };
|
pub const EolMode = enum { lf, crlf };
|
||||||
pub const EolModeTag = @typeInfo(EolMode).Enum.tag_type;
|
pub const EolModeTag = @typeInfo(EolMode).@"enum".tag_type;
|
||||||
|
|
||||||
const UndoNode = struct {
|
const UndoNode = struct {
|
||||||
root: Root,
|
root: Root,
|
||||||
|
@ -66,26 +66,26 @@ const UndoBranch = struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const WalkerMut = struct {
|
pub const WalkerMut = struct {
|
||||||
keep_walking: bool = false,
|
keep_walking_: bool = false,
|
||||||
found: bool = false,
|
found_: bool = false,
|
||||||
replace: ?Root = null,
|
replace: ?Root = null,
|
||||||
err: ?anyerror = null,
|
err: ?anyerror = null,
|
||||||
|
|
||||||
pub const keep_walking = WalkerMut{ .keep_walking = true };
|
pub const keep_walking = WalkerMut{ .keep_walking_ = true };
|
||||||
pub const stop = WalkerMut{ .keep_walking = false };
|
pub const stop = WalkerMut{ .keep_walking_ = false };
|
||||||
pub const found = WalkerMut{ .found = true };
|
pub const found = WalkerMut{ .found_ = true };
|
||||||
|
|
||||||
const F = *const fn (ctx: *anyopaque, leaf: *const Leaf, metrics: Metrics) WalkerMut;
|
const F = *const fn (ctx: *anyopaque, leaf: *const Leaf, metrics: Metrics) WalkerMut;
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Walker = struct {
|
pub const Walker = struct {
|
||||||
keep_walking: bool = false,
|
keep_walking_: bool = false,
|
||||||
found: bool = false,
|
found_: bool = false,
|
||||||
err: ?anyerror = null,
|
err: ?anyerror = null,
|
||||||
|
|
||||||
pub const keep_walking = Walker{ .keep_walking = true };
|
pub const keep_walking = Walker{ .keep_walking_ = true };
|
||||||
pub const stop = Walker{ .keep_walking = false };
|
pub const stop = Walker{ .keep_walking_ = false };
|
||||||
pub const found = Walker{ .found = true };
|
pub const found = Walker{ .found_ = true };
|
||||||
|
|
||||||
const F = *const fn (ctx: *anyopaque, leaf: *const Leaf, metrics: Metrics) Walker;
|
const F = *const fn (ctx: *anyopaque, leaf: *const Leaf, metrics: Metrics) Walker;
|
||||||
};
|
};
|
||||||
|
@ -121,8 +121,8 @@ pub const Branch = struct {
|
||||||
fn merge_results_const(_: *const Branch, left: Walker, right: Walker) Walker {
|
fn merge_results_const(_: *const Branch, left: Walker, right: Walker) Walker {
|
||||||
var result = Walker{};
|
var result = Walker{};
|
||||||
result.err = if (left.err) |_| left.err else right.err;
|
result.err = if (left.err) |_| left.err else right.err;
|
||||||
result.keep_walking = left.keep_walking and right.keep_walking;
|
result.keep_walking_ = left.keep_walking_ and right.keep_walking_;
|
||||||
result.found = left.found or right.found;
|
result.found_ = left.found_ or right.found_;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,8 +139,8 @@ pub const Branch = struct {
|
||||||
else
|
else
|
||||||
Node.new(allocator, new_left, new_right) catch |e| return .{ .err = e };
|
Node.new(allocator, new_left, new_right) catch |e| return .{ .err = e };
|
||||||
}
|
}
|
||||||
result.keep_walking = left.keep_walking and right.keep_walking;
|
result.keep_walking_ = left.keep_walking_ and right.keep_walking_;
|
||||||
result.found = left.found or right.found;
|
result.found_ = left.found_ or right.found_;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -345,10 +345,10 @@ const Node = union(enum) {
|
||||||
switch (self.*) {
|
switch (self.*) {
|
||||||
.node => |*node| {
|
.node => |*node| {
|
||||||
const left = node.left.walk_const(f, ctx, metrics);
|
const left = node.left.walk_const(f, ctx, metrics);
|
||||||
if (!left.keep_walking) {
|
if (!left.keep_walking_) {
|
||||||
var result = Walker{};
|
var result = Walker{};
|
||||||
result.err = left.err;
|
result.err = left.err;
|
||||||
result.found = left.found;
|
result.found_ = left.found_;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
const right = node.right.walk_const(f, ctx, metrics);
|
const right = node.right.walk_const(f, ctx, metrics);
|
||||||
|
@ -362,10 +362,10 @@ const Node = union(enum) {
|
||||||
switch (self.*) {
|
switch (self.*) {
|
||||||
.node => |*node| {
|
.node => |*node| {
|
||||||
const left = node.left.walk(allocator, f, ctx, metrics);
|
const left = node.left.walk(allocator, f, ctx, metrics);
|
||||||
if (!left.keep_walking) {
|
if (!left.keep_walking_) {
|
||||||
var result = WalkerMut{};
|
var result = WalkerMut{};
|
||||||
result.err = left.err;
|
result.err = left.err;
|
||||||
result.found = left.found;
|
result.found_ = left.found_;
|
||||||
if (left.replace) |p| {
|
if (left.replace) |p| {
|
||||||
result.replace = Node.new(allocator, p, node.right) catch |e| return .{ .err = e };
|
result.replace = Node.new(allocator, p, node.right) catch |e| return .{ .err = e };
|
||||||
}
|
}
|
||||||
|
@ -385,14 +385,14 @@ const Node = union(enum) {
|
||||||
if (line >= left_bols)
|
if (line >= left_bols)
|
||||||
return node.right.walk_from_line_begin_const_internal(line - left_bols, f, ctx, metrics);
|
return node.right.walk_from_line_begin_const_internal(line - left_bols, f, ctx, metrics);
|
||||||
const left_result = node.left.walk_from_line_begin_const_internal(line, f, ctx, metrics);
|
const left_result = node.left.walk_from_line_begin_const_internal(line, f, ctx, metrics);
|
||||||
const right_result = if (left_result.found and left_result.keep_walking) node.right.walk_const(f, ctx, metrics) else Walker{};
|
const right_result = if (left_result.found_ and left_result.keep_walking_) node.right.walk_const(f, ctx, metrics) else Walker{};
|
||||||
return node.merge_results_const(left_result, right_result);
|
return node.merge_results_const(left_result, right_result);
|
||||||
},
|
},
|
||||||
.leaf => |*l| {
|
.leaf => |*l| {
|
||||||
if (line == 0) {
|
if (line == 0) {
|
||||||
var result = f(ctx, l, metrics);
|
var result = f(ctx, l, metrics);
|
||||||
if (result.err) |_| return result;
|
if (result.err) |_| return result;
|
||||||
result.found = true;
|
result.found_ = true;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
return Walker.keep_walking;
|
return Walker.keep_walking;
|
||||||
|
@ -403,7 +403,7 @@ const Node = union(enum) {
|
||||||
pub fn walk_from_line_begin_const(self: *const Node, line: usize, f: Walker.F, ctx: *anyopaque, metrics: Metrics) !bool {
|
pub fn walk_from_line_begin_const(self: *const Node, line: usize, f: Walker.F, ctx: *anyopaque, metrics: Metrics) !bool {
|
||||||
const result = self.walk_from_line_begin_const_internal(line, f, ctx, metrics);
|
const result = self.walk_from_line_begin_const_internal(line, f, ctx, metrics);
|
||||||
if (result.err) |e| return e;
|
if (result.err) |e| return e;
|
||||||
return result.found;
|
return result.found_;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn walk_from_line_begin_internal(self: *const Node, allocator: Allocator, line: usize, f: WalkerMut.F, ctx: *anyopaque, metrics: Metrics) WalkerMut {
|
fn walk_from_line_begin_internal(self: *const Node, allocator: Allocator, line: usize, f: WalkerMut.F, ctx: *anyopaque, metrics: Metrics) WalkerMut {
|
||||||
|
@ -415,8 +415,8 @@ const Node = union(enum) {
|
||||||
if (right_result.replace) |p| {
|
if (right_result.replace) |p| {
|
||||||
var result = WalkerMut{};
|
var result = WalkerMut{};
|
||||||
result.err = right_result.err;
|
result.err = right_result.err;
|
||||||
result.found = right_result.found;
|
result.found_ = right_result.found_;
|
||||||
result.keep_walking = right_result.keep_walking;
|
result.keep_walking_ = right_result.keep_walking_;
|
||||||
result.replace = if (p.is_empty())
|
result.replace = if (p.is_empty())
|
||||||
node.left
|
node.left
|
||||||
else
|
else
|
||||||
|
@ -427,7 +427,7 @@ const Node = union(enum) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const left_result = node.left.walk_from_line_begin_internal(allocator, line, f, ctx, metrics);
|
const left_result = node.left.walk_from_line_begin_internal(allocator, line, f, ctx, metrics);
|
||||||
const right_result = if (left_result.found and left_result.keep_walking) node.right.walk(allocator, f, ctx, metrics) else WalkerMut{};
|
const right_result = if (left_result.found_ and left_result.keep_walking_) node.right.walk(allocator, f, ctx, metrics) else WalkerMut{};
|
||||||
return node.merge_results(allocator, left_result, right_result);
|
return node.merge_results(allocator, left_result, right_result);
|
||||||
},
|
},
|
||||||
.leaf => |*l| {
|
.leaf => |*l| {
|
||||||
|
@ -437,7 +437,7 @@ const Node = union(enum) {
|
||||||
result.replace = null;
|
result.replace = null;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
result.found = true;
|
result.found_ = true;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
return WalkerMut.keep_walking;
|
return WalkerMut.keep_walking;
|
||||||
|
@ -448,7 +448,7 @@ const Node = union(enum) {
|
||||||
pub fn walk_from_line_begin(self: *const Node, allocator: Allocator, line: usize, f: WalkerMut.F, ctx: *anyopaque, metrics: Metrics) !struct { bool, ?Root } {
|
pub fn walk_from_line_begin(self: *const Node, allocator: Allocator, line: usize, f: WalkerMut.F, ctx: *anyopaque, metrics: Metrics) !struct { bool, ?Root } {
|
||||||
const result = self.walk_from_line_begin_internal(allocator, line, f, ctx, metrics);
|
const result = self.walk_from_line_begin_internal(allocator, line, f, ctx, metrics);
|
||||||
if (result.err) |e| return e;
|
if (result.err) |e| return e;
|
||||||
return .{ result.found, result.replace };
|
return .{ result.found_, result.replace };
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_line_node(self: *const Node, line: usize) ?*const Node {
|
fn find_line_node(self: *const Node, line: usize) ?*const Node {
|
||||||
|
@ -503,12 +503,12 @@ const Node = union(enum) {
|
||||||
if (ret.err) |e| return .{ .err = e };
|
if (ret.err) |e| return .{ .err = e };
|
||||||
buf = buf[bytes..];
|
buf = buf[bytes..];
|
||||||
ctx.abs_col += @intCast(cols);
|
ctx.abs_col += @intCast(cols);
|
||||||
if (!ret.keep_walking) return Walker.stop;
|
if (!ret.keep_walking_) return Walker.stop;
|
||||||
}
|
}
|
||||||
if (leaf.eol) {
|
if (leaf.eol) {
|
||||||
const ret = ctx.walker_f(ctx.walker_ctx, "\n", 1, metrics);
|
const ret = ctx.walker_f(ctx.walker_ctx, "\n", 1, metrics);
|
||||||
if (ret.err) |e| return .{ .err = e };
|
if (ret.err) |e| return .{ .err = e };
|
||||||
if (!ret.keep_walking) return Walker.stop;
|
if (!ret.keep_walking_) return Walker.stop;
|
||||||
ctx.abs_col = 0;
|
ctx.abs_col = 0;
|
||||||
}
|
}
|
||||||
return Walker.keep_walking;
|
return Walker.keep_walking;
|
||||||
|
@ -665,7 +665,7 @@ const Node = union(enum) {
|
||||||
var result = WalkerMut.keep_walking;
|
var result = WalkerMut.keep_walking;
|
||||||
if (ctx.delete_next_bol and ctx.bytes == 0) {
|
if (ctx.delete_next_bol and ctx.bytes == 0) {
|
||||||
result.replace = Leaf.new(ctx.allocator, leaf.buf, false, leaf.eol) catch |e| return .{ .err = e };
|
result.replace = Leaf.new(ctx.allocator, leaf.buf, false, leaf.eol) catch |e| return .{ .err = e };
|
||||||
result.keep_walking = false;
|
result.keep_walking_ = false;
|
||||||
ctx.delete_next_bol = false;
|
ctx.delete_next_bol = false;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -719,7 +719,7 @@ const Node = union(enum) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ctx.bytes == 0 and !ctx.delete_next_bol)
|
if (ctx.bytes == 0 and !ctx.delete_next_bol)
|
||||||
result.keep_walking = false;
|
result.keep_walking_ = false;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -1206,6 +1206,9 @@ pub const LoadFromFileError = error{
|
||||||
DanglingSurrogateHalf,
|
DanglingSurrogateHalf,
|
||||||
ExpectedSecondSurrogateHalf,
|
ExpectedSecondSurrogateHalf,
|
||||||
UnexpectedSecondSurrogateHalf,
|
UnexpectedSecondSurrogateHalf,
|
||||||
|
LockViolation,
|
||||||
|
ProcessNotFound,
|
||||||
|
Canceled,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn load_from_file(
|
pub fn load_from_file(
|
||||||
|
@ -1296,6 +1299,7 @@ pub const StoreToFileError = error{
|
||||||
PathAlreadyExists,
|
PathAlreadyExists,
|
||||||
PipeBusy,
|
PipeBusy,
|
||||||
ProcessFdQuotaExceeded,
|
ProcessFdQuotaExceeded,
|
||||||
|
ProcessNotFound,
|
||||||
ReadOnlyFileSystem,
|
ReadOnlyFileSystem,
|
||||||
RenameAcrossMountPoints,
|
RenameAcrossMountPoints,
|
||||||
SharingViolation,
|
SharingViolation,
|
||||||
|
|
|
@ -26,7 +26,7 @@ const Vtable = struct {
|
||||||
meta: Metadata,
|
meta: Metadata,
|
||||||
};
|
};
|
||||||
|
|
||||||
const Metadata = struct {
|
pub const Metadata = struct {
|
||||||
description: []const u8 = &[_]u8{},
|
description: []const u8 = &[_]u8{},
|
||||||
arguments: []const ArgumentType = &[_]ArgumentType{},
|
arguments: []const ArgumentType = &[_]ArgumentType{},
|
||||||
};
|
};
|
||||||
|
@ -216,7 +216,7 @@ fn getTargetType(comptime Namespace: type) type {
|
||||||
fn getCommands(comptime Namespace: type) []const CmdDef(*getTargetType(Namespace)) {
|
fn getCommands(comptime Namespace: type) []const CmdDef(*getTargetType(Namespace)) {
|
||||||
@setEvalBranchQuota(10_000);
|
@setEvalBranchQuota(10_000);
|
||||||
comptime switch (@typeInfo(Namespace)) {
|
comptime switch (@typeInfo(Namespace)) {
|
||||||
.Struct => |info| {
|
.@"struct" => |info| {
|
||||||
var count = 0;
|
var count = 0;
|
||||||
const Target = getTargetType(Namespace);
|
const Target = getTargetType(Namespace);
|
||||||
// @compileLog(Namespace, Target);
|
// @compileLog(Namespace, Target);
|
||||||
|
@ -257,14 +257,14 @@ pub fn Collection(comptime Namespace: type) type {
|
||||||
fields_var[i] = .{
|
fields_var[i] = .{
|
||||||
.name = cmd.name,
|
.name = cmd.name,
|
||||||
.type = Clsr,
|
.type = Clsr,
|
||||||
.default_value = null,
|
.default_value_ptr = null,
|
||||||
.is_comptime = false,
|
.is_comptime = false,
|
||||||
.alignment = if (@sizeOf(Clsr) > 0) @alignOf(Clsr) else 0,
|
.alignment = if (@sizeOf(Clsr) > 0) @alignOf(Clsr) else 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const fields: [cmds.len]std.builtin.Type.StructField = fields_var;
|
const fields: [cmds.len]std.builtin.Type.StructField = fields_var;
|
||||||
const Fields = @Type(.{
|
const Fields = @Type(.{
|
||||||
.Struct = .{
|
.@"struct" = .{
|
||||||
.is_tuple = false,
|
.is_tuple = false,
|
||||||
.layout = .auto,
|
.layout = .auto,
|
||||||
.decls = &.{},
|
.decls = &.{},
|
||||||
|
|
|
@ -29,7 +29,7 @@ pub fn parse_key_events(allocator: std.mem.Allocator, str: []const u8) ParseErro
|
||||||
var iter = std.mem.tokenizeScalar(u8, item, '+');
|
var iter = std.mem.tokenizeScalar(u8, item, '+');
|
||||||
loop: while (iter.next()) |part| {
|
loop: while (iter.next()) |part| {
|
||||||
if (part.len == 0) return parse_error("empty part in '{s}'", .{str});
|
if (part.len == 0) return parse_error("empty part in '{s}'", .{str});
|
||||||
const modsInfo = @typeInfo(input.ModSet).Struct;
|
const modsInfo = @typeInfo(input.ModSet).@"struct";
|
||||||
inline for (modsInfo.fields) |field| {
|
inline for (modsInfo.fields) |field| {
|
||||||
if (std.mem.eql(u8, part, field.name)) {
|
if (std.mem.eql(u8, part, field.name)) {
|
||||||
if (@field(mods, field.name)) return parse_error("duplicate modifier '{s}' in '{s}'", .{ part, str });
|
if (@field(mods, field.name)) return parse_error("duplicate modifier '{s}' in '{s}'", .{ part, str });
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const tp = @import("thespian");
|
const tp = @import("thespian");
|
||||||
|
|
||||||
const fba = std.heap.FixedBufferAllocator;
|
|
||||||
|
|
||||||
const Self = @This();
|
const Self = @This();
|
||||||
|
|
||||||
pub const max_log_message = tp.max_message_size - 128;
|
pub const max_log_message = tp.max_message_size - 128;
|
||||||
|
@ -11,7 +9,7 @@ allocator: std.mem.Allocator,
|
||||||
receiver: Receiver,
|
receiver: Receiver,
|
||||||
subscriber: ?tp.pid,
|
subscriber: ?tp.pid,
|
||||||
heap: [32 + 1024]u8,
|
heap: [32 + 1024]u8,
|
||||||
fba: fba,
|
fba: std.heap.FixedBufferAllocator,
|
||||||
msg_store: MsgStoreT,
|
msg_store: MsgStoreT,
|
||||||
|
|
||||||
const MsgStoreT = std.DoublyLinkedList([]u8);
|
const MsgStoreT = std.DoublyLinkedList([]u8);
|
||||||
|
@ -39,7 +37,7 @@ fn init(args: StartArgs) !*Self {
|
||||||
.receiver = Receiver.init(Self.receive, p),
|
.receiver = Receiver.init(Self.receive, p),
|
||||||
.subscriber = null,
|
.subscriber = null,
|
||||||
.heap = undefined,
|
.heap = undefined,
|
||||||
.fba = fba.init(&p.heap),
|
.fba = std.heap.FixedBufferAllocator.init(&p.heap),
|
||||||
.msg_store = MsgStoreT{},
|
.msg_store = MsgStoreT{},
|
||||||
};
|
};
|
||||||
return p;
|
return p;
|
||||||
|
|
|
@ -24,7 +24,7 @@ pub const application_title = "Flow Control";
|
||||||
pub const application_subtext = "a programmer's text editor";
|
pub const application_subtext = "a programmer's text editor";
|
||||||
pub const application_description = application_title ++ ": " ++ application_subtext;
|
pub const application_description = application_title ++ ": " ++ application_subtext;
|
||||||
|
|
||||||
pub const std_options = .{
|
pub const std_options: std.Options = .{
|
||||||
// .log_level = if (builtin.mode == .Debug) .debug else .warn,
|
// .log_level = if (builtin.mode == .Debug) .debug else .warn,
|
||||||
.log_level = if (builtin.mode == .Debug) .info else .warn,
|
.log_level = if (builtin.mode == .Debug) .info else .warn,
|
||||||
.logFn = log.std_log_function,
|
.logFn = log.std_log_function,
|
||||||
|
@ -512,7 +512,7 @@ fn read_cbor_config(
|
||||||
else => return e,
|
else => return e,
|
||||||
}) {
|
}) {
|
||||||
var known = false;
|
var known = false;
|
||||||
inline for (@typeInfo(T).Struct.fields) |field_info|
|
inline for (@typeInfo(T).@"struct".fields) |field_info|
|
||||||
if (comptime std.mem.eql(u8, "include_files", field_info.name)) {
|
if (comptime std.mem.eql(u8, "include_files", field_info.name)) {
|
||||||
if (std.mem.eql(u8, field_name, field_info.name)) {
|
if (std.mem.eql(u8, field_name, field_info.name)) {
|
||||||
known = true;
|
known = true;
|
||||||
|
@ -571,7 +571,7 @@ fn write_text_config_file(comptime T: type, data: T, file_name: []const u8) !voi
|
||||||
|
|
||||||
pub fn write_config_to_writer(comptime T: type, data: T, writer: anytype) !void {
|
pub fn write_config_to_writer(comptime T: type, data: T, writer: anytype) !void {
|
||||||
const default: T = .{};
|
const default: T = .{};
|
||||||
inline for (@typeInfo(T).Struct.fields) |field_info| {
|
inline for (@typeInfo(T).@"struct".fields) |field_info| {
|
||||||
if (config_eql(
|
if (config_eql(
|
||||||
field_info.type,
|
field_info.type,
|
||||||
@field(data, field_info.name),
|
@field(data, field_info.name),
|
||||||
|
@ -593,7 +593,7 @@ fn config_eql(comptime T: type, a: T, b: T) bool {
|
||||||
else => {},
|
else => {},
|
||||||
}
|
}
|
||||||
switch (@typeInfo(T)) {
|
switch (@typeInfo(T)) {
|
||||||
.Bool, .Int, .Float, .Enum => return a == b,
|
.bool, .int, .float, .@"enum" => return a == b,
|
||||||
else => {},
|
else => {},
|
||||||
}
|
}
|
||||||
@compileError("unsupported config type " ++ @typeName(T));
|
@compileError("unsupported config type " ++ @typeName(T));
|
||||||
|
|
|
@ -37,7 +37,7 @@ pub const option = enum {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn init(nopts: *const Options, parent_: Plane) !Plane {
|
pub fn init(nopts: *const Options, parent_: Plane) !Plane {
|
||||||
const opts = .{
|
const opts: vaxis.Window.ChildOptions = .{
|
||||||
.x_off = @as(i17, @intCast(nopts.x)),
|
.x_off = @as(i17, @intCast(nopts.x)),
|
||||||
.y_off = @as(i17, @intCast(nopts.y)),
|
.y_off = @as(i17, @intCast(nopts.y)),
|
||||||
.width = @as(u16, @intCast(nopts.cols)),
|
.width = @as(u16, @intCast(nopts.cols)),
|
||||||
|
|
|
@ -8,7 +8,7 @@ pub const key = vaxis.Key;
|
||||||
pub const Key = u21;
|
pub const Key = u21;
|
||||||
|
|
||||||
pub const Mouse = vaxis.Mouse.Button;
|
pub const Mouse = vaxis.Mouse.Button;
|
||||||
pub const MouseType = @typeInfo(Mouse).Enum.tag_type;
|
pub const MouseType = @typeInfo(Mouse).@"enum".tag_type;
|
||||||
|
|
||||||
pub const mouse = struct {
|
pub const mouse = struct {
|
||||||
pub const MOTION: Mouse = vaxis.Mouse.Button.none;
|
pub const MOTION: Mouse = vaxis.Mouse.Button.none;
|
||||||
|
|
|
@ -12,6 +12,7 @@ pub const Cell = @import("Cell.zig");
|
||||||
pub const CursorShape = vaxis.Cell.CursorShape;
|
pub const CursorShape = vaxis.Cell.CursorShape;
|
||||||
|
|
||||||
pub const style = @import("style.zig").StyleBits;
|
pub const style = @import("style.zig").StyleBits;
|
||||||
|
pub const styles = @import("style.zig");
|
||||||
|
|
||||||
const Self = @This();
|
const Self = @This();
|
||||||
pub const log_name = "vaxis";
|
pub const log_name = "vaxis";
|
||||||
|
@ -80,13 +81,14 @@ var panic_cleanup: ?struct {
|
||||||
vx: *vaxis.Vaxis,
|
vx: *vaxis.Vaxis,
|
||||||
} = null;
|
} = null;
|
||||||
pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, ret_addr: ?usize) noreturn {
|
pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, ret_addr: ?usize) noreturn {
|
||||||
|
_ = error_return_trace; // TODO: what to do with this in zig-0.14?
|
||||||
const cleanup = panic_cleanup;
|
const cleanup = panic_cleanup;
|
||||||
panic_cleanup = null;
|
panic_cleanup = null;
|
||||||
if (cleanup) |self| {
|
if (cleanup) |self| {
|
||||||
self.vx.deinit(self.allocator, self.tty.anyWriter());
|
self.vx.deinit(self.allocator, self.tty.anyWriter());
|
||||||
self.tty.deinit();
|
self.tty.deinit();
|
||||||
}
|
}
|
||||||
return std.builtin.default_panic(msg, error_return_trace, ret_addr);
|
return std.debug.defaultPanic(msg, ret_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run(self: *Self) !void {
|
pub fn run(self: *Self) !void {
|
||||||
|
|
|
@ -4,11 +4,11 @@ pub const StyleBits = packed struct(u5) {
|
||||||
undercurl: bool = false,
|
undercurl: bool = false,
|
||||||
underline: bool = false,
|
underline: bool = false,
|
||||||
italic: bool = false,
|
italic: bool = false,
|
||||||
|
|
||||||
pub const struck: StyleBits = .{ .struck = true };
|
|
||||||
pub const bold: StyleBits = .{ .bold = true };
|
|
||||||
pub const undercurl: StyleBits = .{ .undercurl = true };
|
|
||||||
pub const underline: StyleBits = .{ .underline = true };
|
|
||||||
pub const italic: StyleBits = .{ .italic = true };
|
|
||||||
pub const normal: StyleBits = .{};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub const struck: StyleBits = .{ .struck = true };
|
||||||
|
pub const bold: StyleBits = .{ .bold = true };
|
||||||
|
pub const undercurl: StyleBits = .{ .undercurl = true };
|
||||||
|
pub const underline: StyleBits = .{ .underline = true };
|
||||||
|
pub const italic: StyleBits = .{ .italic = true };
|
||||||
|
pub const normal: StyleBits = .{};
|
||||||
|
|
|
@ -134,7 +134,7 @@ const Process = struct {
|
||||||
|
|
||||||
fn receive(self: *Process, _: tp.pid_ref, m: tp.message) tp.result {
|
fn receive(self: *Process, _: tp.pid_ref, m: tp.message) tp.result {
|
||||||
errdefer self.deinit();
|
errdefer self.deinit();
|
||||||
var bytes: []u8 = "";
|
var bytes: []const u8 = "";
|
||||||
|
|
||||||
if (try m.match(.{ "input", tp.extract(&bytes) })) {
|
if (try m.match(.{ "input", tp.extract(&bytes) })) {
|
||||||
const sp = self.sp orelse return tp.exit_error(error.Closed, null);
|
const sp = self.sp orelse return tp.exit_error(error.Closed, null);
|
||||||
|
@ -155,7 +155,7 @@ const Process = struct {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_output(self: *Process, bytes: []u8) !void {
|
fn handle_output(self: *Process, bytes: []const u8) !void {
|
||||||
try self.output.appendSlice(bytes);
|
try self.output.appendSlice(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -187,7 +187,7 @@ const Process = struct {
|
||||||
|
|
||||||
fn receive(self: *Process, _: tp.pid_ref, m: tp.message) tp.result {
|
fn receive(self: *Process, _: tp.pid_ref, m: tp.message) tp.result {
|
||||||
errdefer self.deinit();
|
errdefer self.deinit();
|
||||||
var bytes: []u8 = "";
|
var bytes: []const u8 = "";
|
||||||
|
|
||||||
if (try m.match(.{ "input", tp.extract(&bytes) })) {
|
if (try m.match(.{ "input", tp.extract(&bytes) })) {
|
||||||
const sp = self.sp orelse return tp.exit_error(error.Closed, null);
|
const sp = self.sp orelse return tp.exit_error(error.Closed, null);
|
||||||
|
|
|
@ -88,7 +88,7 @@ fn ft_func_name(comptime lang: []const u8) []const u8 {
|
||||||
|
|
||||||
const LangFn = *const fn () callconv(.C) ?*const treez.Language;
|
const LangFn = *const fn () callconv(.C) ?*const treez.Language;
|
||||||
|
|
||||||
const FirstLineMatch = struct {
|
pub const FirstLineMatch = struct {
|
||||||
prefix: ?[]const u8 = null,
|
prefix: ?[]const u8 = null,
|
||||||
content: ?[]const u8 = null,
|
content: ?[]const u8 = null,
|
||||||
};
|
};
|
||||||
|
@ -105,7 +105,7 @@ fn vec(comptime args: anytype) []const []const u8 {
|
||||||
|
|
||||||
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)) {
|
||||||
.Struct => |info| {
|
.@"struct" => |info| {
|
||||||
var count = 0;
|
var count = 0;
|
||||||
for (info.decls) |_| {
|
for (info.decls) |_| {
|
||||||
// @compileLog(decl.name, @TypeOf(@field(Namespace, decl.name)));
|
// @compileLog(decl.name, @TypeOf(@field(Namespace, decl.name)));
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
const file_type = @import("file_type.zig");
|
||||||
|
const FirstLineMatch = file_type.FirstLineMatch;
|
||||||
|
|
||||||
pub const agda = .{
|
pub const agda = .{
|
||||||
.description = "Agda",
|
.description = "Agda",
|
||||||
.extensions = .{"agda"},
|
.extensions = .{"agda"},
|
||||||
|
@ -10,7 +13,7 @@ pub const bash = .{
|
||||||
.icon = "",
|
.icon = "",
|
||||||
.extensions = .{ "sh", "bash", ".profile" },
|
.extensions = .{ "sh", "bash", ".profile" },
|
||||||
.comment = "#",
|
.comment = "#",
|
||||||
.first_line_matches = .{ .prefix = "#!", .content = "sh" },
|
.first_line_matches = FirstLineMatch{ .prefix = "#!", .content = "sh" },
|
||||||
.formatter = .{ "shfmt", "--indent", "4" },
|
.formatter = .{ "shfmt", "--indent", "4" },
|
||||||
.language_server = .{ "bash-language-server", "start" },
|
.language_server = .{ "bash-language-server", "start" },
|
||||||
};
|
};
|
||||||
|
@ -245,7 +248,7 @@ pub const lua = .{
|
||||||
.extensions = .{"lua"},
|
.extensions = .{"lua"},
|
||||||
.comment = "--",
|
.comment = "--",
|
||||||
.injections = "tree-sitter-lua/queries/injections.scm",
|
.injections = "tree-sitter-lua/queries/injections.scm",
|
||||||
.first_line_matches = .{ .prefix = "--", .content = "lua" },
|
.first_line_matches = FirstLineMatch{ .prefix = "--", .content = "lua" },
|
||||||
.language_server = .{"lua-lsp"},
|
.language_server = .{"lua-lsp"},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -255,7 +258,7 @@ pub const mail = .{
|
||||||
.extensions = .{ "eml", "mbox" },
|
.extensions = .{ "eml", "mbox" },
|
||||||
.comment = ">",
|
.comment = ">",
|
||||||
.highlights = "tree-sitter-mail/queries/mail/highlights.scm",
|
.highlights = "tree-sitter-mail/queries/mail/highlights.scm",
|
||||||
.first_line_matches = .{ .prefix = "From" },
|
.first_line_matches = FirstLineMatch{ .prefix = "From" },
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const make = .{
|
pub const make = .{
|
||||||
|
@ -398,7 +401,7 @@ pub const python = .{
|
||||||
.icon = "",
|
.icon = "",
|
||||||
.extensions = .{ "py", "pyi" },
|
.extensions = .{ "py", "pyi" },
|
||||||
.comment = "#",
|
.comment = "#",
|
||||||
.first_line_matches = .{ .prefix = "#!", .content = "python" },
|
.first_line_matches = FirstLineMatch{ .prefix = "#!", .content = "python" },
|
||||||
.language_server = .{"pylsp"},
|
.language_server = .{"pylsp"},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -511,7 +514,7 @@ pub const xml = .{
|
||||||
.extensions = .{"xml"},
|
.extensions = .{"xml"},
|
||||||
.comment = "<!--",
|
.comment = "<!--",
|
||||||
.highlights = "tree-sitter-xml/queries/xml/highlights.scm",
|
.highlights = "tree-sitter-xml/queries/xml/highlights.scm",
|
||||||
.first_line_matches = .{ .prefix = "<?xml " },
|
.first_line_matches = FirstLineMatch{ .prefix = "<?xml " },
|
||||||
.formatter = .{ "xmllint", "--format", "-" },
|
.formatter = .{ "xmllint", "--format", "-" },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ pub fn to_unowned(pimpl: anytype) Self {
|
||||||
|
|
||||||
pub fn bind(pimpl: anytype, comptime f: *const fn (ctx: @TypeOf(pimpl), from: tp.pid_ref, m: tp.message) Error!bool) Self {
|
pub fn bind(pimpl: anytype, comptime f: *const fn (ctx: @TypeOf(pimpl), from: tp.pid_ref, m: tp.message) Error!bool) Self {
|
||||||
const impl = @typeInfo(@TypeOf(pimpl));
|
const impl = @typeInfo(@TypeOf(pimpl));
|
||||||
const child: type = impl.Pointer.child;
|
const child: type = impl.pointer.child;
|
||||||
return .{
|
return .{
|
||||||
.ptr = pimpl,
|
.ptr = pimpl,
|
||||||
.vtable = comptime &.{
|
.vtable = comptime &.{
|
||||||
|
|
|
@ -55,7 +55,7 @@ pub const VTable = struct {
|
||||||
|
|
||||||
pub fn to(pimpl: anytype) Self {
|
pub fn to(pimpl: anytype) Self {
|
||||||
const impl = @typeInfo(@TypeOf(pimpl));
|
const impl = @typeInfo(@TypeOf(pimpl));
|
||||||
const child: type = impl.Pointer.child;
|
const child: type = impl.pointer.child;
|
||||||
return .{
|
return .{
|
||||||
.ptr = pimpl,
|
.ptr = pimpl,
|
||||||
.plane = &pimpl.plane,
|
.plane = &pimpl.plane,
|
||||||
|
|
|
@ -23,7 +23,7 @@ plane: Plane,
|
||||||
parent: Plane,
|
parent: Plane,
|
||||||
allocator: Allocator,
|
allocator: Allocator,
|
||||||
widgets: ArrayList(WidgetState),
|
widgets: ArrayList(WidgetState),
|
||||||
layout: Layout,
|
layout_: Layout,
|
||||||
direction: Direction,
|
direction: Direction,
|
||||||
box: ?Widget.Box = null,
|
box: ?Widget.Box = null,
|
||||||
ctx: ?*anyopaque = null,
|
ctx: ?*anyopaque = null,
|
||||||
|
@ -58,7 +58,7 @@ fn init(allocator: Allocator, parent: Plane, name: [:0]const u8, dir: Direction,
|
||||||
.parent = parent,
|
.parent = parent,
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.widgets = ArrayList(WidgetState).init(allocator),
|
.widgets = ArrayList(WidgetState).init(allocator),
|
||||||
.layout = layout_,
|
.layout_ = layout_,
|
||||||
.direction = dir,
|
.direction = dir,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ pub fn widget(self: *Self) Widget {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn layout(self: *Self) Widget.Layout {
|
pub fn layout(self: *Self) Widget.Layout {
|
||||||
return self.layout;
|
return self.layout_;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deinit(self: *Self, allocator: std.mem.Allocator) void {
|
pub fn deinit(self: *Self, allocator: std.mem.Allocator) void {
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -8,6 +8,7 @@ const root = @import("root");
|
||||||
|
|
||||||
const Plane = @import("renderer").Plane;
|
const Plane = @import("renderer").Plane;
|
||||||
const style = @import("renderer").style;
|
const style = @import("renderer").style;
|
||||||
|
const styles = @import("renderer").styles;
|
||||||
const input = @import("input");
|
const input = @import("input");
|
||||||
const command = @import("command");
|
const command = @import("command");
|
||||||
const EventHandler = @import("EventHandler");
|
const EventHandler = @import("EventHandler");
|
||||||
|
@ -31,7 +32,7 @@ highlight: bool,
|
||||||
symbols: bool,
|
symbols: bool,
|
||||||
width: usize = 4,
|
width: usize = 4,
|
||||||
editor: *ed.Editor,
|
editor: *ed.Editor,
|
||||||
diff: diff.AsyncDiffer,
|
diff_: diff.AsyncDiffer,
|
||||||
diff_symbols: std.ArrayList(Symbol),
|
diff_symbols: std.ArrayList(Symbol),
|
||||||
|
|
||||||
const Self = @This();
|
const Self = @This();
|
||||||
|
@ -50,7 +51,7 @@ pub fn create(allocator: Allocator, parent: Widget, event_source: Widget, editor
|
||||||
.highlight = tui.config().highlight_current_line_gutter,
|
.highlight = tui.config().highlight_current_line_gutter,
|
||||||
.symbols = tui.config().gutter_symbols,
|
.symbols = tui.config().gutter_symbols,
|
||||||
.editor = editor,
|
.editor = editor,
|
||||||
.diff = try diff.create(),
|
.diff_ = try diff.create(),
|
||||||
.diff_symbols = std.ArrayList(Symbol).init(allocator),
|
.diff_symbols = std.ArrayList(Symbol).init(allocator),
|
||||||
};
|
};
|
||||||
try tui.message_filters().add(MessageFilter.bind(self, filter_receive));
|
try tui.message_filters().add(MessageFilter.bind(self, filter_receive));
|
||||||
|
@ -168,10 +169,10 @@ pub fn render_linear(self: *Self, theme: *const Widget.Theme) void {
|
||||||
if (linenum > self.lines) return;
|
if (linenum > self.lines) return;
|
||||||
if (linenum == self.line + 1) {
|
if (linenum == self.line + 1) {
|
||||||
self.plane.set_style(.{ .fg = theme.editor_gutter_active.fg });
|
self.plane.set_style(.{ .fg = theme.editor_gutter_active.fg });
|
||||||
self.plane.on_styles(style.bold);
|
self.plane.on_styles(styles.bold);
|
||||||
} else {
|
} else {
|
||||||
self.plane.set_style(.{ .fg = theme.editor_gutter.fg });
|
self.plane.set_style(.{ .fg = theme.editor_gutter.fg });
|
||||||
self.plane.off_styles(style.bold);
|
self.plane.off_styles(styles.bold);
|
||||||
}
|
}
|
||||||
_ = self.plane.print_aligned_right(@intCast(pos), "{s}", .{std.fmt.bufPrintZ(&buf, "{d} ", .{linenum}) catch return}) catch {};
|
_ = self.plane.print_aligned_right(@intCast(pos), "{s}", .{std.fmt.bufPrintZ(&buf, "{d} ", .{linenum}) catch return}) catch {};
|
||||||
if (self.highlight and linenum == self.line + 1)
|
if (self.highlight and linenum == self.line + 1)
|
||||||
|
@ -315,7 +316,7 @@ fn diff_update(self: *Self) !void {
|
||||||
const new = editor.get_current_root() orelse return;
|
const new = editor.get_current_root() orelse return;
|
||||||
const old = if (editor.buffer) |buffer| buffer.last_save orelse return else return;
|
const old = if (editor.buffer) |buffer| buffer.last_save orelse return else return;
|
||||||
const eol_mode = if (editor.buffer) |buffer| buffer.file_eol_mode else return;
|
const eol_mode = if (editor.buffer) |buffer| buffer.file_eol_mode else return;
|
||||||
return self.diff.diff(diff_result, new, old, eol_mode);
|
return self.diff_.diff(diff_result, new, old, eol_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn diff_result(from: tp.pid_ref, edits: []diff.Diff) void {
|
fn diff_result(from: tp.pid_ref, edits: []diff.Diff) void {
|
||||||
|
|
|
@ -262,33 +262,34 @@ fn select_next(self: *Self, dir: enum { up, down }) void {
|
||||||
const cmds = struct {
|
const cmds = struct {
|
||||||
pub const Target = Self;
|
pub const Target = Self;
|
||||||
const Ctx = command.Context;
|
const Ctx = command.Context;
|
||||||
|
const Meta = command.Metadata;
|
||||||
const Result = command.Result;
|
const Result = command.Result;
|
||||||
|
|
||||||
pub fn goto_prev_file(self: *Self, _: Ctx) Result {
|
pub fn goto_prev_file(self: *Self, _: Ctx) Result {
|
||||||
self.select_next(.up);
|
self.select_next(.up);
|
||||||
self.menu.activate_selected();
|
self.menu.activate_selected();
|
||||||
}
|
}
|
||||||
pub const goto_prev_file_meta = .{ .description = "Navigate to previous file in the file list" };
|
pub const goto_prev_file_meta: Meta = .{ .description = "Navigate to previous file in the file list" };
|
||||||
|
|
||||||
pub fn goto_next_file(self: *Self, _: Ctx) Result {
|
pub fn goto_next_file(self: *Self, _: Ctx) Result {
|
||||||
self.select_next(.down);
|
self.select_next(.down);
|
||||||
self.menu.activate_selected();
|
self.menu.activate_selected();
|
||||||
}
|
}
|
||||||
pub const goto_next_file_meta = .{ .description = "Navigate to next file in the file list" };
|
pub const goto_next_file_meta: Meta = .{ .description = "Navigate to next file in the file list" };
|
||||||
|
|
||||||
pub fn select_prev_file(self: *Self, _: Ctx) Result {
|
pub fn select_prev_file(self: *Self, _: Ctx) Result {
|
||||||
self.select_next(.up);
|
self.select_next(.up);
|
||||||
}
|
}
|
||||||
pub const select_prev_file_meta = .{ .description = "Select previous file in the file list" };
|
pub const select_prev_file_meta: Meta = .{ .description = "Select previous file in the file list" };
|
||||||
|
|
||||||
pub fn select_next_file(self: *Self, _: Ctx) Result {
|
pub fn select_next_file(self: *Self, _: Ctx) Result {
|
||||||
self.select_next(.down);
|
self.select_next(.down);
|
||||||
}
|
}
|
||||||
pub const select_next_file_meta = .{ .description = "Select next file in the file list" };
|
pub const select_next_file_meta: Meta = .{ .description = "Select next file in the file list" };
|
||||||
|
|
||||||
pub fn goto_selected_file(self: *Self, _: Ctx) Result {
|
pub fn goto_selected_file(self: *Self, _: Ctx) Result {
|
||||||
if (self.menu.selected == null) return tp.exit_error(error.NoSelectedFile, @errorReturnTrace());
|
if (self.menu.selected == null) return tp.exit_error(error.NoSelectedFile, @errorReturnTrace());
|
||||||
self.menu.activate_selected();
|
self.menu.activate_selected();
|
||||||
}
|
}
|
||||||
pub const goto_selected_file_meta = .{};
|
pub const goto_selected_file_meta: Meta = .{};
|
||||||
};
|
};
|
||||||
|
|
|
@ -243,28 +243,29 @@ const Commands = command.Collection(cmds);
|
||||||
const cmds = struct {
|
const cmds = struct {
|
||||||
pub const Target = Self;
|
pub const Target = Self;
|
||||||
const Ctx = command.Context;
|
const Ctx = command.Context;
|
||||||
|
const Meta = command.Metadata;
|
||||||
const Result = command.Result;
|
const Result = command.Result;
|
||||||
|
|
||||||
pub fn save_all(_: *Self, _: Ctx) Result {
|
pub fn save_all(_: *Self, _: Ctx) Result {
|
||||||
if (tui.get_buffer_manager()) |bm|
|
if (tui.get_buffer_manager()) |bm|
|
||||||
bm.save_all() catch |e| return tp.exit_error(e, @errorReturnTrace());
|
bm.save_all() catch |e| return tp.exit_error(e, @errorReturnTrace());
|
||||||
}
|
}
|
||||||
pub const save_all_meta = .{ .description = "Save all changed files" };
|
pub const save_all_meta: Meta = .{ .description = "Save all changed files" };
|
||||||
|
|
||||||
pub fn home_menu_down(self: *Self, _: Ctx) Result {
|
pub fn home_menu_down(self: *Self, _: Ctx) Result {
|
||||||
self.menu.select_down();
|
self.menu.select_down();
|
||||||
}
|
}
|
||||||
pub const home_menu_down_meta = .{};
|
pub const home_menu_down_meta: Meta = .{};
|
||||||
|
|
||||||
pub fn home_menu_up(self: *Self, _: Ctx) Result {
|
pub fn home_menu_up(self: *Self, _: Ctx) Result {
|
||||||
self.menu.select_up();
|
self.menu.select_up();
|
||||||
}
|
}
|
||||||
pub const home_menu_up_meta = .{};
|
pub const home_menu_up_meta: Meta = .{};
|
||||||
|
|
||||||
pub fn home_menu_activate(self: *Self, _: Ctx) Result {
|
pub fn home_menu_activate(self: *Self, _: Ctx) Result {
|
||||||
self.menu.activate_selected();
|
self.menu.activate_selected();
|
||||||
}
|
}
|
||||||
pub const home_menu_activate_meta = .{};
|
pub const home_menu_activate_meta: Meta = .{};
|
||||||
|
|
||||||
pub fn home_sheeran(self: *Self, _: Ctx) Result {
|
pub fn home_sheeran(self: *Self, _: Ctx) Result {
|
||||||
self.fire = if (self.fire) |*fire| ret: {
|
self.fire = if (self.fire) |*fire| ret: {
|
||||||
|
@ -272,7 +273,7 @@ const cmds = struct {
|
||||||
break :ret null;
|
break :ret null;
|
||||||
} else try Fire.init(self.allocator, self.plane);
|
} else try Fire.init(self.allocator, self.plane);
|
||||||
}
|
}
|
||||||
pub const home_sheeran_meta = .{};
|
pub const home_sheeran_meta: Meta = .{};
|
||||||
};
|
};
|
||||||
|
|
||||||
const Fire = struct {
|
const Fire = struct {
|
||||||
|
|
|
@ -7,6 +7,7 @@ const syntax = @import("syntax");
|
||||||
|
|
||||||
const Plane = @import("renderer").Plane;
|
const Plane = @import("renderer").Plane;
|
||||||
const style = @import("renderer").style;
|
const style = @import("renderer").style;
|
||||||
|
const styles = @import("renderer").styles;
|
||||||
const EventHandler = @import("EventHandler");
|
const EventHandler = @import("EventHandler");
|
||||||
|
|
||||||
const tui = @import("tui.zig");
|
const tui = @import("tui.zig");
|
||||||
|
@ -168,31 +169,31 @@ fn show_color(self: *Self, tag: []const u8, c_: ?Widget.Theme.Color) void {
|
||||||
fn show_font(self: *Self, font: ?Widget.Theme.FontStyle) void {
|
fn show_font(self: *Self, font: ?Widget.Theme.FontStyle) void {
|
||||||
if (font) |fs| switch (fs) {
|
if (font) |fs| switch (fs) {
|
||||||
.normal => {
|
.normal => {
|
||||||
self.plane.set_styles(style.normal);
|
self.plane.set_styles(styles.normal);
|
||||||
_ = self.plane.print(" normal", .{}) catch return;
|
_ = self.plane.print(" normal", .{}) catch return;
|
||||||
},
|
},
|
||||||
.bold => {
|
.bold => {
|
||||||
self.plane.set_styles(style.bold);
|
self.plane.set_styles(styles.bold);
|
||||||
_ = self.plane.print(" bold", .{}) catch return;
|
_ = self.plane.print(" bold", .{}) catch return;
|
||||||
},
|
},
|
||||||
.italic => {
|
.italic => {
|
||||||
self.plane.set_styles(style.italic);
|
self.plane.set_styles(styles.italic);
|
||||||
_ = self.plane.print(" italic", .{}) catch return;
|
_ = self.plane.print(" italic", .{}) catch return;
|
||||||
},
|
},
|
||||||
.underline => {
|
.underline => {
|
||||||
self.plane.set_styles(style.underline);
|
self.plane.set_styles(styles.underline);
|
||||||
_ = self.plane.print(" underline", .{}) catch return;
|
_ = self.plane.print(" underline", .{}) catch return;
|
||||||
},
|
},
|
||||||
.undercurl => {
|
.undercurl => {
|
||||||
self.plane.set_styles(style.undercurl);
|
self.plane.set_styles(styles.undercurl);
|
||||||
_ = self.plane.print(" undercurl", .{}) catch return;
|
_ = self.plane.print(" undercurl", .{}) catch return;
|
||||||
},
|
},
|
||||||
.strikethrough => {
|
.strikethrough => {
|
||||||
self.plane.set_styles(style.struck);
|
self.plane.set_styles(styles.struck);
|
||||||
_ = self.plane.print(" strikethrough", .{}) catch return;
|
_ = self.plane.print(" strikethrough", .{}) catch return;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
self.plane.set_styles(style.normal);
|
self.plane.set_styles(styles.normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reset_style(self: *Self) void {
|
fn reset_style(self: *Self) void {
|
||||||
|
|
|
@ -47,7 +47,7 @@ views_widget: Widget,
|
||||||
active_view: ?usize = 0,
|
active_view: ?usize = 0,
|
||||||
panels: ?*WidgetList = null,
|
panels: ?*WidgetList = null,
|
||||||
last_match_text: ?[]const u8 = null,
|
last_match_text: ?[]const u8 = null,
|
||||||
location_history: location_history,
|
location_history_: location_history,
|
||||||
buffer_manager: Buffer.Manager,
|
buffer_manager: Buffer.Manager,
|
||||||
find_in_files_state: enum { init, adding, done } = .done,
|
find_in_files_state: enum { init, adding, done } = .done,
|
||||||
file_list_type: FileListType = .find_in_files,
|
file_list_type: FileListType = .find_in_files,
|
||||||
|
@ -67,7 +67,7 @@ pub fn create(allocator: std.mem.Allocator) !Widget {
|
||||||
.widgets = undefined,
|
.widgets = undefined,
|
||||||
.widgets_widget = undefined,
|
.widgets_widget = undefined,
|
||||||
.floating_views = WidgetStack.init(allocator),
|
.floating_views = WidgetStack.init(allocator),
|
||||||
.location_history = try location_history.create(),
|
.location_history_ = try location_history.create(),
|
||||||
.views = undefined,
|
.views = undefined,
|
||||||
.views_widget = undefined,
|
.views_widget = undefined,
|
||||||
.buffer_manager = Buffer.Manager.init(allocator),
|
.buffer_manager = Buffer.Manager.init(allocator),
|
||||||
|
@ -179,7 +179,7 @@ fn bottom_bar_primary_drag(self: *Self, y: usize) tp.result {
|
||||||
};
|
};
|
||||||
const h = self.plane.dim_y();
|
const h = self.plane.dim_y();
|
||||||
self.panel_height = @max(1, h - @min(h, y + 1));
|
self.panel_height = @max(1, h - @min(h, y + 1));
|
||||||
panels.layout = .{ .static = self.panel_height.? };
|
panels.layout_ = .{ .static = self.panel_height.? };
|
||||||
if (self.panel_height == 1) {
|
if (self.panel_height == 1) {
|
||||||
self.panel_height = null;
|
self.panel_height = null;
|
||||||
command.executeName("toggle_panel", .{}) catch {};
|
command.executeName("toggle_panel", .{}) catch {};
|
||||||
|
@ -241,25 +241,26 @@ fn check_all_not_dirty(self: *const Self) command.Result {
|
||||||
const cmds = struct {
|
const cmds = struct {
|
||||||
pub const Target = Self;
|
pub const Target = Self;
|
||||||
const Ctx = command.Context;
|
const Ctx = command.Context;
|
||||||
|
const Meta = command.Metadata;
|
||||||
const Result = command.Result;
|
const Result = command.Result;
|
||||||
|
|
||||||
pub fn quit(self: *Self, _: Ctx) Result {
|
pub fn quit(self: *Self, _: Ctx) Result {
|
||||||
try self.check_all_not_dirty();
|
try self.check_all_not_dirty();
|
||||||
try tp.self_pid().send("quit");
|
try tp.self_pid().send("quit");
|
||||||
}
|
}
|
||||||
pub const quit_meta = .{ .description = "Quit (exit) Flow Control" };
|
pub const quit_meta: Meta = .{ .description = "Quit (exit) Flow Control" };
|
||||||
|
|
||||||
pub fn quit_without_saving(_: *Self, _: Ctx) Result {
|
pub fn quit_without_saving(_: *Self, _: Ctx) Result {
|
||||||
try tp.self_pid().send("quit");
|
try tp.self_pid().send("quit");
|
||||||
}
|
}
|
||||||
pub const quit_without_saving_meta = .{ .description = "Quit without saving" };
|
pub const quit_without_saving_meta: Meta = .{ .description = "Quit without saving" };
|
||||||
|
|
||||||
pub fn open_project_cwd(self: *Self, _: Ctx) Result {
|
pub fn open_project_cwd(self: *Self, _: Ctx) Result {
|
||||||
try project_manager.open(".");
|
try project_manager.open(".");
|
||||||
if (self.top_bar) |bar| _ = try bar.msg(.{ "PRJ", "open" });
|
if (self.top_bar) |bar| _ = try bar.msg(.{ "PRJ", "open" });
|
||||||
if (self.bottom_bar) |bar| _ = try bar.msg(.{ "PRJ", "open" });
|
if (self.bottom_bar) |bar| _ = try bar.msg(.{ "PRJ", "open" });
|
||||||
}
|
}
|
||||||
pub const open_project_cwd_meta = .{};
|
pub const open_project_cwd_meta: Meta = .{};
|
||||||
|
|
||||||
pub fn open_project_dir(self: *Self, ctx: Ctx) Result {
|
pub fn open_project_dir(self: *Self, ctx: Ctx) Result {
|
||||||
var project_dir: []const u8 = undefined;
|
var project_dir: []const u8 = undefined;
|
||||||
|
@ -271,7 +272,7 @@ const cmds = struct {
|
||||||
if (self.top_bar) |bar| _ = try bar.msg(.{ "PRJ", "open" });
|
if (self.top_bar) |bar| _ = try bar.msg(.{ "PRJ", "open" });
|
||||||
if (self.bottom_bar) |bar| _ = try bar.msg(.{ "PRJ", "open" });
|
if (self.bottom_bar) |bar| _ = try bar.msg(.{ "PRJ", "open" });
|
||||||
}
|
}
|
||||||
pub const open_project_dir_meta = .{ .arguments = &.{.string} };
|
pub const open_project_dir_meta: Meta = .{ .arguments = &.{.string} };
|
||||||
|
|
||||||
pub fn change_project(self: *Self, ctx: Ctx) Result {
|
pub fn change_project(self: *Self, ctx: Ctx) Result {
|
||||||
var project_dir: []const u8 = undefined;
|
var project_dir: []const u8 = undefined;
|
||||||
|
@ -296,7 +297,7 @@ const cmds = struct {
|
||||||
if (try project_manager.request_most_recent_file(self.allocator)) |file_path|
|
if (try project_manager.request_most_recent_file(self.allocator)) |file_path|
|
||||||
self.show_file_async_and_free(file_path);
|
self.show_file_async_and_free(file_path);
|
||||||
}
|
}
|
||||||
pub const change_project_meta = .{ .arguments = &.{.string} };
|
pub const change_project_meta: Meta = .{ .arguments = &.{.string} };
|
||||||
|
|
||||||
pub fn navigate(self: *Self, ctx: Ctx) Result {
|
pub fn navigate(self: *Self, ctx: Ctx) Result {
|
||||||
tui.reset_drag_context();
|
tui.reset_drag_context();
|
||||||
|
@ -364,7 +365,7 @@ const cmds = struct {
|
||||||
}
|
}
|
||||||
tui.need_render();
|
tui.need_render();
|
||||||
}
|
}
|
||||||
pub const navigate_meta = .{ .arguments = &.{.object} };
|
pub const navigate_meta: Meta = .{ .arguments = &.{.object} };
|
||||||
|
|
||||||
pub fn open_help(self: *Self, _: Ctx) Result {
|
pub fn open_help(self: *Self, _: Ctx) Result {
|
||||||
tui.reset_drag_context();
|
tui.reset_drag_context();
|
||||||
|
@ -372,7 +373,7 @@ const cmds = struct {
|
||||||
try command.executeName("open_scratch_buffer", command.fmt(.{ "help", @embedFile("help.md"), "markdown" }));
|
try command.executeName("open_scratch_buffer", command.fmt(.{ "help", @embedFile("help.md"), "markdown" }));
|
||||||
tui.need_render();
|
tui.need_render();
|
||||||
}
|
}
|
||||||
pub const open_help_meta = .{ .description = "Open help" };
|
pub const open_help_meta: Meta = .{ .description = "Open help" };
|
||||||
|
|
||||||
pub fn open_font_test_text(self: *Self, _: Ctx) Result {
|
pub fn open_font_test_text(self: *Self, _: Ctx) Result {
|
||||||
tui.reset_drag_context();
|
tui.reset_drag_context();
|
||||||
|
@ -380,7 +381,7 @@ const cmds = struct {
|
||||||
try command.executeName("open_scratch_buffer", command.fmt(.{ "font test", @import("fonts.zig").font_test_text, "text" }));
|
try command.executeName("open_scratch_buffer", command.fmt(.{ "font test", @import("fonts.zig").font_test_text, "text" }));
|
||||||
tui.need_render();
|
tui.need_render();
|
||||||
}
|
}
|
||||||
pub const open_font_test_text_meta = .{ .description = "Open font glyph test text" };
|
pub const open_font_test_text_meta: Meta = .{ .description = "Open font glyph test text" };
|
||||||
|
|
||||||
pub fn open_version_info(self: *Self, _: Ctx) Result {
|
pub fn open_version_info(self: *Self, _: Ctx) Result {
|
||||||
tui.reset_drag_context();
|
tui.reset_drag_context();
|
||||||
|
@ -388,19 +389,19 @@ const cmds = struct {
|
||||||
try command.executeName("open_scratch_buffer", command.fmt(.{ "version", root.version_info, "diff" }));
|
try command.executeName("open_scratch_buffer", command.fmt(.{ "version", root.version_info, "diff" }));
|
||||||
tui.need_render();
|
tui.need_render();
|
||||||
}
|
}
|
||||||
pub const open_version_info_meta = .{ .description = "Show build version information" };
|
pub const open_version_info_meta: Meta = .{ .description = "Show build version information" };
|
||||||
|
|
||||||
pub fn open_config(_: *Self, _: Ctx) Result {
|
pub fn open_config(_: *Self, _: Ctx) Result {
|
||||||
const file_name = try root.get_config_file_name(@import("config"));
|
const file_name = try root.get_config_file_name(@import("config"));
|
||||||
try tp.self_pid().send(.{ "cmd", "navigate", .{ .file = file_name[0 .. file_name.len - 5] } });
|
try tp.self_pid().send(.{ "cmd", "navigate", .{ .file = file_name[0 .. file_name.len - 5] } });
|
||||||
}
|
}
|
||||||
pub const open_config_meta = .{ .description = "Edit configuration file" };
|
pub const open_config_meta: Meta = .{ .description = "Edit configuration file" };
|
||||||
|
|
||||||
pub fn open_gui_config(_: *Self, _: Ctx) Result {
|
pub fn open_gui_config(_: *Self, _: Ctx) Result {
|
||||||
const file_name = try root.get_config_file_name(@import("gui_config"));
|
const file_name = try root.get_config_file_name(@import("gui_config"));
|
||||||
try tp.self_pid().send(.{ "cmd", "navigate", .{ .file = file_name[0 .. file_name.len - ".json".len] } });
|
try tp.self_pid().send(.{ "cmd", "navigate", .{ .file = file_name[0 .. file_name.len - ".json".len] } });
|
||||||
}
|
}
|
||||||
pub const open_gui_config_meta = .{ .description = "Edit gui configuration file" };
|
pub const open_gui_config_meta: Meta = .{ .description = "Edit gui configuration file" };
|
||||||
|
|
||||||
pub fn open_tabs_style_config(self: *Self, _: Ctx) Result {
|
pub fn open_tabs_style_config(self: *Self, _: Ctx) Result {
|
||||||
const Style = @import("status/tabs.zig").Style;
|
const Style = @import("status/tabs.zig").Style;
|
||||||
|
@ -422,7 +423,7 @@ const cmds = struct {
|
||||||
}));
|
}));
|
||||||
if (self.get_active_buffer()) |buffer| buffer.mark_not_ephemeral();
|
if (self.get_active_buffer()) |buffer| buffer.mark_not_ephemeral();
|
||||||
}
|
}
|
||||||
pub const open_tabs_style_config_meta = .{ .description = "Edit tab styles configuration file" };
|
pub const open_tabs_style_config_meta: Meta = .{ .description = "Edit tab styles configuration file" };
|
||||||
|
|
||||||
pub fn create_scratch_buffer(self: *Self, ctx: Ctx) Result {
|
pub fn create_scratch_buffer(self: *Self, ctx: Ctx) Result {
|
||||||
const args = try ctx.args.clone(self.allocator);
|
const args = try ctx.args.clone(self.allocator);
|
||||||
|
@ -432,7 +433,7 @@ const cmds = struct {
|
||||||
try command.executeName("open_scratch_buffer", .{ .args = args });
|
try command.executeName("open_scratch_buffer", .{ .args = args });
|
||||||
tui.need_render();
|
tui.need_render();
|
||||||
}
|
}
|
||||||
pub const create_scratch_buffer_meta = .{ .arguments = &.{ .string, .string, .string } };
|
pub const create_scratch_buffer_meta: Meta = .{ .arguments = &.{ .string, .string, .string } };
|
||||||
|
|
||||||
pub fn create_new_file(self: *Self, _: Ctx) Result {
|
pub fn create_new_file(self: *Self, _: Ctx) Result {
|
||||||
var n: usize = 1;
|
var n: usize = 1;
|
||||||
|
@ -451,7 +452,7 @@ const cmds = struct {
|
||||||
try command.executeName("create_scratch_buffer", command.fmt(.{name.items}));
|
try command.executeName("create_scratch_buffer", command.fmt(.{name.items}));
|
||||||
try command.executeName("change_file_type", .{});
|
try command.executeName("change_file_type", .{});
|
||||||
}
|
}
|
||||||
pub const create_new_file_meta = .{ .description = "Create: New File…" };
|
pub const create_new_file_meta: Meta = .{ .description = "Create: New File…" };
|
||||||
|
|
||||||
pub fn delete_buffer(self: *Self, ctx: Ctx) Result {
|
pub fn delete_buffer(self: *Self, ctx: Ctx) Result {
|
||||||
var file_path: []const u8 = undefined;
|
var file_path: []const u8 = undefined;
|
||||||
|
@ -468,7 +469,7 @@ const cmds = struct {
|
||||||
logger.print("deleted buffer {s}", .{file_path});
|
logger.print("deleted buffer {s}", .{file_path});
|
||||||
tui.need_render();
|
tui.need_render();
|
||||||
}
|
}
|
||||||
pub const delete_buffer_meta = .{ .arguments = &.{.string} };
|
pub const delete_buffer_meta: Meta = .{ .arguments = &.{.string} };
|
||||||
|
|
||||||
pub fn close_buffer(self: *Self, ctx: Ctx) Result {
|
pub fn close_buffer(self: *Self, ctx: Ctx) Result {
|
||||||
var file_path: []const u8 = undefined;
|
var file_path: []const u8 = undefined;
|
||||||
|
@ -484,7 +485,7 @@ const cmds = struct {
|
||||||
_ = self.buffer_manager.close_buffer(buffer);
|
_ = self.buffer_manager.close_buffer(buffer);
|
||||||
tui.need_render();
|
tui.need_render();
|
||||||
}
|
}
|
||||||
pub const close_buffer_meta = .{ .arguments = &.{.string} };
|
pub const close_buffer_meta: Meta = .{ .arguments = &.{.string} };
|
||||||
|
|
||||||
pub fn restore_session(self: *Self, _: Ctx) Result {
|
pub fn restore_session(self: *Self, _: Ctx) Result {
|
||||||
if (tp.env.get().str("project").len == 0) {
|
if (tp.env.get().str("project").len == 0) {
|
||||||
|
@ -494,7 +495,7 @@ const cmds = struct {
|
||||||
try self.read_restore_info();
|
try self.read_restore_info();
|
||||||
tui.need_render();
|
tui.need_render();
|
||||||
}
|
}
|
||||||
pub const restore_session_meta = .{};
|
pub const restore_session_meta: Meta = .{};
|
||||||
|
|
||||||
pub fn toggle_panel(self: *Self, _: Ctx) Result {
|
pub fn toggle_panel(self: *Self, _: Ctx) Result {
|
||||||
if (self.is_panel_view_showing(logview))
|
if (self.is_panel_view_showing(logview))
|
||||||
|
@ -506,52 +507,52 @@ const cmds = struct {
|
||||||
else
|
else
|
||||||
try self.toggle_panel_view(logview, false);
|
try self.toggle_panel_view(logview, false);
|
||||||
}
|
}
|
||||||
pub const toggle_panel_meta = .{ .description = "Toggle panel" };
|
pub const toggle_panel_meta: Meta = .{ .description = "Toggle panel" };
|
||||||
|
|
||||||
pub fn toggle_logview(self: *Self, _: Ctx) Result {
|
pub fn toggle_logview(self: *Self, _: Ctx) Result {
|
||||||
try self.toggle_panel_view(logview, false);
|
try self.toggle_panel_view(logview, false);
|
||||||
}
|
}
|
||||||
pub const toggle_logview_meta = .{};
|
pub const toggle_logview_meta: Meta = .{};
|
||||||
|
|
||||||
pub fn show_logview(self: *Self, _: Ctx) Result {
|
pub fn show_logview(self: *Self, _: Ctx) Result {
|
||||||
try self.toggle_panel_view(logview, true);
|
try self.toggle_panel_view(logview, true);
|
||||||
}
|
}
|
||||||
pub const show_logview_meta = .{ .description = "View log" };
|
pub const show_logview_meta: Meta = .{ .description = "View log" };
|
||||||
|
|
||||||
pub fn toggle_inputview(self: *Self, _: Ctx) Result {
|
pub fn toggle_inputview(self: *Self, _: Ctx) Result {
|
||||||
try self.toggle_panel_view(@import("inputview.zig"), false);
|
try self.toggle_panel_view(@import("inputview.zig"), false);
|
||||||
}
|
}
|
||||||
pub const toggle_inputview_meta = .{ .description = "Toggle raw input log" };
|
pub const toggle_inputview_meta: Meta = .{ .description = "Toggle raw input log" };
|
||||||
|
|
||||||
pub fn toggle_inspector_view(self: *Self, _: Ctx) Result {
|
pub fn toggle_inspector_view(self: *Self, _: Ctx) Result {
|
||||||
try self.toggle_panel_view(@import("inspector_view.zig"), false);
|
try self.toggle_panel_view(@import("inspector_view.zig"), false);
|
||||||
}
|
}
|
||||||
pub const toggle_inspector_view_meta = .{ .description = "Toggle inspector view" };
|
pub const toggle_inspector_view_meta: Meta = .{ .description = "Toggle inspector view" };
|
||||||
|
|
||||||
pub fn show_inspector_view(self: *Self, _: Ctx) Result {
|
pub fn show_inspector_view(self: *Self, _: Ctx) Result {
|
||||||
try self.toggle_panel_view(@import("inspector_view.zig"), true);
|
try self.toggle_panel_view(@import("inspector_view.zig"), true);
|
||||||
}
|
}
|
||||||
pub const show_inspector_view_meta = .{};
|
pub const show_inspector_view_meta: Meta = .{};
|
||||||
|
|
||||||
pub fn jump_back(self: *Self, _: Ctx) Result {
|
pub fn jump_back(self: *Self, _: Ctx) Result {
|
||||||
try self.location_history.back(location_jump);
|
try self.location_history_.back(location_jump);
|
||||||
}
|
}
|
||||||
pub const jump_back_meta = .{ .description = "Navigate back to previous history location" };
|
pub const jump_back_meta: Meta = .{ .description = "Navigate back to previous history location" };
|
||||||
|
|
||||||
pub fn jump_forward(self: *Self, _: Ctx) Result {
|
pub fn jump_forward(self: *Self, _: Ctx) Result {
|
||||||
try self.location_history.forward(location_jump);
|
try self.location_history_.forward(location_jump);
|
||||||
}
|
}
|
||||||
pub const jump_forward_meta = .{ .description = "Navigate forward to next history location" };
|
pub const jump_forward_meta: Meta = .{ .description = "Navigate forward to next history location" };
|
||||||
|
|
||||||
pub fn show_home(self: *Self, _: Ctx) Result {
|
pub fn show_home(self: *Self, _: Ctx) Result {
|
||||||
return self.create_home();
|
return self.create_home();
|
||||||
}
|
}
|
||||||
pub const show_home_meta = .{};
|
pub const show_home_meta: Meta = .{};
|
||||||
|
|
||||||
pub fn add_split(self: *Self, _: Ctx) Result {
|
pub fn add_split(self: *Self, _: Ctx) Result {
|
||||||
return self.create_home_split();
|
return self.create_home_split();
|
||||||
}
|
}
|
||||||
pub const add_split_meta = .{};
|
pub const add_split_meta: Meta = .{};
|
||||||
|
|
||||||
pub fn gutter_mode_next(self: *Self, _: Ctx) Result {
|
pub fn gutter_mode_next(self: *Self, _: Ctx) Result {
|
||||||
const config = tui.config_mut();
|
const config = tui.config_mut();
|
||||||
|
@ -576,7 +577,7 @@ const cmds = struct {
|
||||||
gutter.relative = lnr;
|
gutter.relative = lnr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub const gutter_mode_next_meta = .{ .description = "Next gutter mode" };
|
pub const gutter_mode_next_meta: Meta = .{ .description = "Next gutter mode" };
|
||||||
|
|
||||||
pub fn goto_next_file_or_diagnostic(self: *Self, ctx: Ctx) Result {
|
pub fn goto_next_file_or_diagnostic(self: *Self, ctx: Ctx) Result {
|
||||||
if (self.is_panel_view_showing(filelist_view)) {
|
if (self.is_panel_view_showing(filelist_view)) {
|
||||||
|
@ -588,7 +589,7 @@ const cmds = struct {
|
||||||
try command.executeName("goto_next_diagnostic", ctx);
|
try command.executeName("goto_next_diagnostic", ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub const goto_next_file_or_diagnostic_meta = .{ .description = "Navigate to next file or diagnostic location" };
|
pub const goto_next_file_or_diagnostic_meta: Meta = .{ .description = "Navigate to next file or diagnostic location" };
|
||||||
|
|
||||||
pub fn goto_prev_file_or_diagnostic(self: *Self, ctx: Ctx) Result {
|
pub fn goto_prev_file_or_diagnostic(self: *Self, ctx: Ctx) Result {
|
||||||
if (self.is_panel_view_showing(filelist_view)) {
|
if (self.is_panel_view_showing(filelist_view)) {
|
||||||
|
@ -600,7 +601,7 @@ const cmds = struct {
|
||||||
try command.executeName("goto_prev_diagnostic", ctx);
|
try command.executeName("goto_prev_diagnostic", ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub const goto_prev_file_or_diagnostic_meta = .{ .description = "Navigate to previous file or diagnostic location" };
|
pub const goto_prev_file_or_diagnostic_meta: Meta = .{ .description = "Navigate to previous file or diagnostic location" };
|
||||||
|
|
||||||
pub fn add_diagnostic(self: *Self, ctx: Ctx) Result {
|
pub fn add_diagnostic(self: *Self, ctx: Ctx) Result {
|
||||||
var file_path: []const u8 = undefined;
|
var file_path: []const u8 = undefined;
|
||||||
|
@ -635,7 +636,7 @@ const cmds = struct {
|
||||||
ed.Diagnostic.to_severity(severity),
|
ed.Diagnostic.to_severity(severity),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
pub const add_diagnostic_meta = .{ .arguments = &.{ .string, .string, .string, .string, .integer, .integer, .integer, .integer, .integer } };
|
pub const add_diagnostic_meta: Meta = .{ .arguments = &.{ .string, .string, .string, .string, .integer, .integer, .integer, .integer, .integer } };
|
||||||
|
|
||||||
pub fn rename_symbol_item(self: *Self, ctx: Ctx) Result {
|
pub fn rename_symbol_item(self: *Self, ctx: Ctx) Result {
|
||||||
const editor = self.get_active_editor() orelse return;
|
const editor = self.get_active_editor() orelse return;
|
||||||
|
@ -679,8 +680,8 @@ const cmds = struct {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub const rename_symbol_item_meta = .{ .arguments = &.{.array} };
|
pub const rename_symbol_item_meta: Meta = .{ .arguments = &.{.array} };
|
||||||
pub const rename_symbol_item_elem_meta = .{ .arguments = &.{ .string, .integer, .integer, .integer, .integer, .string } };
|
pub const rename_symbol_item_elem_meta: Meta = .{ .arguments = &.{ .string, .integer, .integer, .integer, .integer, .string } };
|
||||||
|
|
||||||
pub fn clear_diagnostics(self: *Self, ctx: Ctx) Result {
|
pub fn clear_diagnostics(self: *Self, ctx: Ctx) Result {
|
||||||
var file_path: []const u8 = undefined;
|
var file_path: []const u8 = undefined;
|
||||||
|
@ -693,7 +694,7 @@ const cmds = struct {
|
||||||
if (self.file_list_type == .diagnostics and self.is_panel_view_showing(filelist_view))
|
if (self.file_list_type == .diagnostics and self.is_panel_view_showing(filelist_view))
|
||||||
try self.toggle_panel_view(filelist_view, false);
|
try self.toggle_panel_view(filelist_view, false);
|
||||||
}
|
}
|
||||||
pub const clear_diagnostics_meta = .{ .arguments = &.{.string} };
|
pub const clear_diagnostics_meta: Meta = .{ .arguments = &.{.string} };
|
||||||
|
|
||||||
pub fn show_diagnostics(self: *Self, _: Ctx) Result {
|
pub fn show_diagnostics(self: *Self, _: Ctx) Result {
|
||||||
const editor = self.get_active_editor() orelse return;
|
const editor = self.get_active_editor() orelse return;
|
||||||
|
@ -711,12 +712,12 @@ const cmds = struct {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub const show_diagnostics_meta = .{ .description = "Show diagnostics panel" };
|
pub const show_diagnostics_meta: Meta = .{ .description = "Show diagnostics panel" };
|
||||||
|
|
||||||
pub fn open_previous_file(self: *Self, _: Ctx) Result {
|
pub fn open_previous_file(self: *Self, _: Ctx) Result {
|
||||||
self.show_file_async(self.get_next_mru_buffer() orelse return error.Stop);
|
self.show_file_async(self.get_next_mru_buffer() orelse return error.Stop);
|
||||||
}
|
}
|
||||||
pub const open_previous_file_meta = .{ .description = "Open the previous file" };
|
pub const open_previous_file_meta: Meta = .{ .description = "Open the previous file" };
|
||||||
|
|
||||||
pub fn system_paste(self: *Self, _: Ctx) Result {
|
pub fn system_paste(self: *Self, _: Ctx) Result {
|
||||||
if (builtin.os.tag == .windows) {
|
if (builtin.os.tag == .windows) {
|
||||||
|
@ -726,7 +727,7 @@ const cmds = struct {
|
||||||
}
|
}
|
||||||
tui.rdr().request_system_clipboard();
|
tui.rdr().request_system_clipboard();
|
||||||
}
|
}
|
||||||
pub const system_paste_meta = .{ .description = "Paste from system clipboard" };
|
pub const system_paste_meta: Meta = .{ .description = "Paste from system clipboard" };
|
||||||
|
|
||||||
pub fn find_in_files_query(self: *Self, ctx: Ctx) Result {
|
pub fn find_in_files_query(self: *Self, ctx: Ctx) Result {
|
||||||
var query: []const u8 = undefined;
|
var query: []const u8 = undefined;
|
||||||
|
@ -740,7 +741,7 @@ const cmds = struct {
|
||||||
defer rg.deinit();
|
defer rg.deinit();
|
||||||
self.find_in_files_state = .init;
|
self.find_in_files_state = .init;
|
||||||
}
|
}
|
||||||
pub const find_in_files_query_meta = .{ .arguments = &.{.string} };
|
pub const find_in_files_query_meta: Meta = .{ .arguments = &.{.string} };
|
||||||
|
|
||||||
pub fn shell_execute_log(self: *Self, ctx: Ctx) Result {
|
pub fn shell_execute_log(self: *Self, ctx: Ctx) Result {
|
||||||
if (!try ctx.args.match(.{ tp.string, tp.more }))
|
if (!try ctx.args.match(.{ tp.string, tp.more }))
|
||||||
|
@ -752,7 +753,7 @@ const cmds = struct {
|
||||||
.exit = shell.log_exit_err_handler,
|
.exit = shell.log_exit_err_handler,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
pub const shell_execute_log_meta = .{ .arguments = &.{.string} };
|
pub const shell_execute_log_meta: Meta = .{ .arguments = &.{.string} };
|
||||||
|
|
||||||
pub fn shell_execute_insert(self: *Self, ctx: Ctx) Result {
|
pub fn shell_execute_insert(self: *Self, ctx: Ctx) Result {
|
||||||
if (!try ctx.args.match(.{ tp.string, tp.more }))
|
if (!try ctx.args.match(.{ tp.string, tp.more }))
|
||||||
|
@ -778,7 +779,7 @@ const cmds = struct {
|
||||||
};
|
};
|
||||||
try shell.execute(self.allocator, cmd, .{ .out = handlers.out });
|
try shell.execute(self.allocator, cmd, .{ .out = handlers.out });
|
||||||
}
|
}
|
||||||
pub const shell_execute_insert_meta = .{ .arguments = &.{.string} };
|
pub const shell_execute_insert_meta: Meta = .{ .arguments = &.{.string} };
|
||||||
|
|
||||||
pub fn shell_execute_stream(self: *Self, ctx: Ctx) Result {
|
pub fn shell_execute_stream(self: *Self, ctx: Ctx) Result {
|
||||||
if (!try ctx.args.match(.{ tp.string, tp.more }))
|
if (!try ctx.args.match(.{ tp.string, tp.more }))
|
||||||
|
@ -806,7 +807,7 @@ const cmds = struct {
|
||||||
const buffer_ref = self.buffer_manager.buffer_to_ref(buffer);
|
const buffer_ref = self.buffer_manager.buffer_to_ref(buffer);
|
||||||
try shell.execute(self.allocator, cmd, .{ .context = buffer_ref, .out = handlers.out, .err = handlers.out, .exit = handlers.exit });
|
try shell.execute(self.allocator, cmd, .{ .context = buffer_ref, .out = handlers.out, .err = handlers.out, .exit = handlers.exit });
|
||||||
}
|
}
|
||||||
pub const shell_execute_stream_meta = .{ .arguments = &.{.string} };
|
pub const shell_execute_stream_meta: Meta = .{ .arguments = &.{.string} };
|
||||||
|
|
||||||
pub fn shell_execute_stream_output(self: *Self, ctx: Ctx) Result {
|
pub fn shell_execute_stream_output(self: *Self, ctx: Ctx) Result {
|
||||||
var buffer_ref: usize = 0;
|
var buffer_ref: usize = 0;
|
||||||
|
@ -829,7 +830,7 @@ const cmds = struct {
|
||||||
buffer.update(root_);
|
buffer.update(root_);
|
||||||
tui.need_render();
|
tui.need_render();
|
||||||
}
|
}
|
||||||
pub const shell_execute_stream_output_meta = .{ .arguments = &.{ .integer, .string } };
|
pub const shell_execute_stream_output_meta: Meta = .{ .arguments = &.{ .integer, .string } };
|
||||||
|
|
||||||
pub fn shell_execute_stream_output_complete(self: *Self, ctx: Ctx) Result {
|
pub fn shell_execute_stream_output_complete(self: *Self, ctx: Ctx) Result {
|
||||||
var buffer_ref: usize = 0;
|
var buffer_ref: usize = 0;
|
||||||
|
@ -843,7 +844,7 @@ const cmds = struct {
|
||||||
buffer.mark_clean();
|
buffer.mark_clean();
|
||||||
tui.need_render();
|
tui.need_render();
|
||||||
}
|
}
|
||||||
pub const shell_execute_stream_output_complete_meta = .{ .arguments = &.{ .integer, .string } };
|
pub const shell_execute_stream_output_complete_meta: Meta = .{ .arguments = &.{ .integer, .string } };
|
||||||
|
|
||||||
pub fn adjust_fontsize(_: *Self, ctx: Ctx) Result {
|
pub fn adjust_fontsize(_: *Self, ctx: Ctx) Result {
|
||||||
var amount: f32 = undefined;
|
var amount: f32 = undefined;
|
||||||
|
@ -852,7 +853,7 @@ const cmds = struct {
|
||||||
if (build_options.gui)
|
if (build_options.gui)
|
||||||
tui.rdr().adjust_fontsize(amount);
|
tui.rdr().adjust_fontsize(amount);
|
||||||
}
|
}
|
||||||
pub const adjust_fontsize_meta = .{ .arguments = &.{.float} };
|
pub const adjust_fontsize_meta: Meta = .{ .arguments = &.{.float} };
|
||||||
|
|
||||||
pub fn set_fontsize(_: *Self, ctx: Ctx) Result {
|
pub fn set_fontsize(_: *Self, ctx: Ctx) Result {
|
||||||
var fontsize: f32 = undefined;
|
var fontsize: f32 = undefined;
|
||||||
|
@ -861,13 +862,13 @@ const cmds = struct {
|
||||||
if (build_options.gui)
|
if (build_options.gui)
|
||||||
tui.rdr().set_fontsize(fontsize);
|
tui.rdr().set_fontsize(fontsize);
|
||||||
}
|
}
|
||||||
pub const set_fontsize_meta = .{ .arguments = &.{.float} };
|
pub const set_fontsize_meta: Meta = .{ .arguments = &.{.float} };
|
||||||
|
|
||||||
pub fn reset_fontsize(_: *Self, _: Ctx) Result {
|
pub fn reset_fontsize(_: *Self, _: Ctx) Result {
|
||||||
if (build_options.gui)
|
if (build_options.gui)
|
||||||
tui.rdr().reset_fontsize();
|
tui.rdr().reset_fontsize();
|
||||||
}
|
}
|
||||||
pub const reset_fontsize_meta = .{ .description = "Reset font to configured size" };
|
pub const reset_fontsize_meta: Meta = .{ .description = "Reset font to configured size" };
|
||||||
|
|
||||||
pub fn set_fontface(_: *Self, ctx: Ctx) Result {
|
pub fn set_fontface(_: *Self, ctx: Ctx) Result {
|
||||||
var fontface: []const u8 = undefined;
|
var fontface: []const u8 = undefined;
|
||||||
|
@ -876,23 +877,23 @@ const cmds = struct {
|
||||||
if (build_options.gui)
|
if (build_options.gui)
|
||||||
tui.rdr().set_fontface(fontface);
|
tui.rdr().set_fontface(fontface);
|
||||||
}
|
}
|
||||||
pub const set_fontface_meta = .{ .arguments = &.{.float} };
|
pub const set_fontface_meta: Meta = .{ .arguments = &.{.float} };
|
||||||
|
|
||||||
pub fn reset_fontface(_: *Self, _: Ctx) Result {
|
pub fn reset_fontface(_: *Self, _: Ctx) Result {
|
||||||
if (build_options.gui)
|
if (build_options.gui)
|
||||||
tui.rdr().reset_fontface();
|
tui.rdr().reset_fontface();
|
||||||
}
|
}
|
||||||
pub const reset_fontface_meta = .{ .description = "Reset font to configured face" };
|
pub const reset_fontface_meta: Meta = .{ .description = "Reset font to configured face" };
|
||||||
|
|
||||||
pub fn next_tab(self: *Self, _: Ctx) Result {
|
pub fn next_tab(self: *Self, _: Ctx) Result {
|
||||||
_ = try self.widgets_widget.msg(.{"next_tab"});
|
_ = try self.widgets_widget.msg(.{"next_tab"});
|
||||||
}
|
}
|
||||||
pub const next_tab_meta = .{ .description = "Switch to next tab" };
|
pub const next_tab_meta: Meta = .{ .description = "Switch to next tab" };
|
||||||
|
|
||||||
pub fn previous_tab(self: *Self, _: Ctx) Result {
|
pub fn previous_tab(self: *Self, _: Ctx) Result {
|
||||||
_ = try self.widgets_widget.msg(.{"previous_tab"});
|
_ = try self.widgets_widget.msg(.{"previous_tab"});
|
||||||
}
|
}
|
||||||
pub const previous_tab_meta = .{ .description = "Switch to previous tab" };
|
pub const previous_tab_meta: Meta = .{ .description = "Switch to previous tab" };
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn handle_editor_event(self: *Self, _: tp.pid_ref, m: tp.message) tp.result {
|
pub fn handle_editor_event(self: *Self, _: tp.pid_ref, m: tp.message) tp.result {
|
||||||
|
@ -938,13 +939,13 @@ pub fn location_update(self: *Self, m: tp.message) tp.result {
|
||||||
if (try m.match(.{ tp.any, tp.any, tp.any, tp.extract(&row), tp.extract(&col) })) {
|
if (try m.match(.{ tp.any, tp.any, tp.any, tp.extract(&row), tp.extract(&col) })) {
|
||||||
if (row == 0 and col == 0) return;
|
if (row == 0 and col == 0) return;
|
||||||
project_manager.update_mru(file_path, row, col, ephemeral) catch {};
|
project_manager.update_mru(file_path, row, col, ephemeral) catch {};
|
||||||
return self.location_history.update(file_path, .{ .row = row + 1, .col = col + 1 }, null);
|
return self.location_history_.update(file_path, .{ .row = row + 1, .col = col + 1 }, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
var sel: location_history.Selection = .{};
|
var sel: location_history.Selection = .{};
|
||||||
if (try m.match(.{ tp.any, tp.any, tp.any, tp.extract(&row), tp.extract(&col), tp.extract(&sel.begin.row), tp.extract(&sel.begin.col), tp.extract(&sel.end.row), tp.extract(&sel.end.col) })) {
|
if (try m.match(.{ tp.any, tp.any, tp.any, tp.extract(&row), tp.extract(&col), tp.extract(&sel.begin.row), tp.extract(&sel.begin.col), tp.extract(&sel.end.row), tp.extract(&sel.end.col) })) {
|
||||||
project_manager.update_mru(file_path, row, col, ephemeral) catch {};
|
project_manager.update_mru(file_path, row, col, ephemeral) catch {};
|
||||||
return self.location_history.update(file_path, .{ .row = row + 1, .col = col + 1 }, sel);
|
return self.location_history_.update(file_path, .{ .row = row + 1, .col = col + 1 }, sel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,38 +21,39 @@ const Commands = command.Collection(cmds_);
|
||||||
const cmds_ = struct {
|
const cmds_ = struct {
|
||||||
pub const Target = void;
|
pub const Target = void;
|
||||||
const Ctx = command.Context;
|
const Ctx = command.Context;
|
||||||
|
const Meta = command.Metadata;
|
||||||
const Result = command.Result;
|
const Result = command.Result;
|
||||||
|
|
||||||
pub fn w(_: *void, _: Ctx) Result {
|
pub fn w(_: *void, _: Ctx) Result {
|
||||||
try cmd("save_file", .{});
|
try cmd("save_file", .{});
|
||||||
}
|
}
|
||||||
pub const w_meta = .{ .description = "w (write/save file)" };
|
pub const w_meta: Meta = .{ .description = "w (write/save file)" };
|
||||||
|
|
||||||
pub fn q(_: *void, _: Ctx) Result {
|
pub fn q(_: *void, _: Ctx) Result {
|
||||||
try cmd("quit", .{});
|
try cmd("quit", .{});
|
||||||
}
|
}
|
||||||
pub const q_meta = .{ .description = "q (quit)" };
|
pub const q_meta: Meta = .{ .description = "q (quit)" };
|
||||||
|
|
||||||
pub fn @"q!"(_: *void, _: Ctx) Result {
|
pub fn @"q!"(_: *void, _: Ctx) Result {
|
||||||
try cmd("quit_without_saving", .{});
|
try cmd("quit_without_saving", .{});
|
||||||
}
|
}
|
||||||
pub const @"q!_meta" = .{ .description = "q! (quit without saving)" };
|
pub const @"q!_meta": Meta = .{ .description = "q! (quit without saving)" };
|
||||||
|
|
||||||
pub fn wq(_: *void, _: Ctx) Result {
|
pub fn wq(_: *void, _: Ctx) Result {
|
||||||
try cmd("save_file", command.fmt(.{ "then", .{ "quit", .{} } }));
|
try cmd("save_file", command.fmt(.{ "then", .{ "quit", .{} } }));
|
||||||
}
|
}
|
||||||
pub const wq_meta = .{ .description = "wq (write/save file and quit)" };
|
pub const wq_meta: Meta = .{ .description = "wq (write/save file and quit)" };
|
||||||
|
|
||||||
pub fn o(_: *void, _: Ctx) Result {
|
pub fn o(_: *void, _: Ctx) Result {
|
||||||
try cmd("open_file", .{});
|
try cmd("open_file", .{});
|
||||||
}
|
}
|
||||||
pub const o_meta = .{ .description = "o (open file)" };
|
pub const o_meta: Meta = .{ .description = "o (open file)" };
|
||||||
|
|
||||||
pub fn @"wq!"(_: *void, _: Ctx) Result {
|
pub fn @"wq!"(_: *void, _: Ctx) Result {
|
||||||
cmd("save_file", .{}) catch {};
|
cmd("save_file", .{}) catch {};
|
||||||
try cmd("quit_without_saving", .{});
|
try cmd("quit_without_saving", .{});
|
||||||
}
|
}
|
||||||
pub const @"wq!_meta" = .{ .description = "wq! (write/save file and quit without saving)" };
|
pub const @"wq!_meta": Meta = .{ .description = "wq! (write/save file and quit without saving)" };
|
||||||
|
|
||||||
pub fn save_selection(_: *void, _: Ctx) Result {
|
pub fn save_selection(_: *void, _: Ctx) Result {
|
||||||
const logger = log.logger("helix-mode");
|
const logger = log.logger("helix-mode");
|
||||||
|
@ -65,10 +66,10 @@ const cmds_ = struct {
|
||||||
.begin = .{ .row = sel.begin.row, .col = sel.begin.col },
|
.begin = .{ .row = sel.begin.row, .col = sel.begin.col },
|
||||||
.end = .{ .row = sel.end.row, .col = sel.end.col },
|
.end = .{ .row = sel.end.row, .col = sel.end.col },
|
||||||
} else null;
|
} else null;
|
||||||
mv.location_history.update(file_path, .{
|
mv.location_history_.update(file_path, .{
|
||||||
.row = primary.cursor.row + 1,
|
.row = primary.cursor.row + 1,
|
||||||
.col = primary.cursor.col + 1,
|
.col = primary.cursor.col + 1,
|
||||||
}, sel);
|
}, sel);
|
||||||
}
|
}
|
||||||
pub const save_selection_meta = .{ .description = "Save current selection to location history" };
|
pub const save_selection_meta: Meta = .{ .description = "Save current selection to location history" };
|
||||||
};
|
};
|
||||||
|
|
|
@ -67,18 +67,19 @@ pub fn Create(options: type) type {
|
||||||
const cmds = struct {
|
const cmds = struct {
|
||||||
pub const Target = Self;
|
pub const Target = Self;
|
||||||
const Ctx = command.Context;
|
const Ctx = command.Context;
|
||||||
|
const Meta = command.Metadata;
|
||||||
const Result = command.Result;
|
const Result = command.Result;
|
||||||
|
|
||||||
pub fn mini_mode_reset(self: *Self, _: Ctx) Result {
|
pub fn mini_mode_reset(self: *Self, _: Ctx) Result {
|
||||||
self.input.clearRetainingCapacity();
|
self.input.clearRetainingCapacity();
|
||||||
self.update_mini_mode_text();
|
self.update_mini_mode_text();
|
||||||
}
|
}
|
||||||
pub const mini_mode_reset_meta = .{ .description = "Clear input" };
|
pub const mini_mode_reset_meta: Meta = .{ .description = "Clear input" };
|
||||||
|
|
||||||
pub fn mini_mode_cancel(_: *Self, _: Ctx) Result {
|
pub fn mini_mode_cancel(_: *Self, _: Ctx) Result {
|
||||||
command.executeName("exit_mini_mode", .{}) catch {};
|
command.executeName("exit_mini_mode", .{}) catch {};
|
||||||
}
|
}
|
||||||
pub const mini_mode_cancel_meta = .{ .description = "Cancel input" };
|
pub const mini_mode_cancel_meta: Meta = .{ .description = "Cancel input" };
|
||||||
|
|
||||||
pub fn mini_mode_delete_backwards(self: *Self, _: Ctx) Result {
|
pub fn mini_mode_delete_backwards(self: *Self, _: Ctx) Result {
|
||||||
if (self.input.items.len > 0) {
|
if (self.input.items.len > 0) {
|
||||||
|
@ -86,7 +87,7 @@ pub fn Create(options: type) type {
|
||||||
}
|
}
|
||||||
self.update_mini_mode_text();
|
self.update_mini_mode_text();
|
||||||
}
|
}
|
||||||
pub const mini_mode_delete_backwards_meta = .{ .description = "Delete backwards" };
|
pub const mini_mode_delete_backwards_meta: Meta = .{ .description = "Delete backwards" };
|
||||||
|
|
||||||
pub fn mini_mode_insert_code_point(self: *Self, ctx: Ctx) Result {
|
pub fn mini_mode_insert_code_point(self: *Self, ctx: Ctx) Result {
|
||||||
var egc: u32 = 0;
|
var egc: u32 = 0;
|
||||||
|
@ -97,7 +98,7 @@ pub fn Create(options: type) type {
|
||||||
try self.input.appendSlice(buf[0..bytes]);
|
try self.input.appendSlice(buf[0..bytes]);
|
||||||
self.update_mini_mode_text();
|
self.update_mini_mode_text();
|
||||||
}
|
}
|
||||||
pub const mini_mode_insert_code_point_meta = .{ .arguments = &.{.integer} };
|
pub const mini_mode_insert_code_point_meta: Meta = .{ .arguments = &.{.integer} };
|
||||||
|
|
||||||
pub fn mini_mode_insert_bytes(self: *Self, ctx: Ctx) Result {
|
pub fn mini_mode_insert_bytes(self: *Self, ctx: Ctx) Result {
|
||||||
var bytes: []const u8 = undefined;
|
var bytes: []const u8 = undefined;
|
||||||
|
@ -106,18 +107,18 @@ pub fn Create(options: type) type {
|
||||||
try self.input.appendSlice(bytes);
|
try self.input.appendSlice(bytes);
|
||||||
self.update_mini_mode_text();
|
self.update_mini_mode_text();
|
||||||
}
|
}
|
||||||
pub const mini_mode_insert_bytes_meta = .{ .arguments = &.{.string} };
|
pub const mini_mode_insert_bytes_meta: Meta = .{ .arguments = &.{.string} };
|
||||||
|
|
||||||
pub fn mini_mode_select(self: *Self, _: Ctx) Result {
|
pub fn mini_mode_select(self: *Self, _: Ctx) Result {
|
||||||
options.select(self);
|
options.select(self);
|
||||||
self.update_mini_mode_text();
|
self.update_mini_mode_text();
|
||||||
}
|
}
|
||||||
pub const mini_mode_select_meta = .{ .description = "Select" };
|
pub const mini_mode_select_meta: Meta = .{ .description = "Select" };
|
||||||
|
|
||||||
pub fn mini_mode_paste(self: *Self, ctx: Ctx) Result {
|
pub fn mini_mode_paste(self: *Self, ctx: Ctx) Result {
|
||||||
return mini_mode_insert_bytes(self, ctx);
|
return mini_mode_insert_bytes(self, ctx);
|
||||||
}
|
}
|
||||||
pub const mini_mode_paste_meta = .{ .arguments = &.{.string} };
|
pub const mini_mode_paste_meta: Meta = .{ .arguments = &.{.string} };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -250,6 +250,7 @@ pub fn Create(options: type) type {
|
||||||
const cmds = struct {
|
const cmds = struct {
|
||||||
pub const Target = Self;
|
pub const Target = Self;
|
||||||
const Ctx = command.Context;
|
const Ctx = command.Context;
|
||||||
|
const Meta = command.Metadata;
|
||||||
const Result = command.Result;
|
const Result = command.Result;
|
||||||
|
|
||||||
pub fn mini_mode_reset(self: *Self, _: Ctx) Result {
|
pub fn mini_mode_reset(self: *Self, _: Ctx) Result {
|
||||||
|
@ -257,18 +258,18 @@ pub fn Create(options: type) type {
|
||||||
self.file_path.clearRetainingCapacity();
|
self.file_path.clearRetainingCapacity();
|
||||||
self.update_mini_mode_text();
|
self.update_mini_mode_text();
|
||||||
}
|
}
|
||||||
pub const mini_mode_reset_meta = .{ .description = "Clear input" };
|
pub const mini_mode_reset_meta: Meta = .{ .description = "Clear input" };
|
||||||
|
|
||||||
pub fn mini_mode_cancel(_: *Self, _: Ctx) Result {
|
pub fn mini_mode_cancel(_: *Self, _: Ctx) Result {
|
||||||
command.executeName("exit_mini_mode", .{}) catch {};
|
command.executeName("exit_mini_mode", .{}) catch {};
|
||||||
}
|
}
|
||||||
pub const mini_mode_cancel_meta = .{ .description = "Cancel input" };
|
pub const mini_mode_cancel_meta: Meta = .{ .description = "Cancel input" };
|
||||||
|
|
||||||
pub fn mini_mode_delete_to_previous_path_segment(self: *Self, _: Ctx) Result {
|
pub fn mini_mode_delete_to_previous_path_segment(self: *Self, _: Ctx) Result {
|
||||||
self.delete_to_previous_path_segment();
|
self.delete_to_previous_path_segment();
|
||||||
self.update_mini_mode_text();
|
self.update_mini_mode_text();
|
||||||
}
|
}
|
||||||
pub const mini_mode_delete_to_previous_path_segment_meta = .{ .description = "Delete to previous path segment" };
|
pub const mini_mode_delete_to_previous_path_segment_meta: Meta = .{ .description = "Delete to previous path segment" };
|
||||||
|
|
||||||
pub fn mini_mode_delete_backwards(self: *Self, _: Ctx) Result {
|
pub fn mini_mode_delete_backwards(self: *Self, _: Ctx) Result {
|
||||||
if (self.file_path.items.len > 0) {
|
if (self.file_path.items.len > 0) {
|
||||||
|
@ -277,25 +278,25 @@ pub fn Create(options: type) type {
|
||||||
}
|
}
|
||||||
self.update_mini_mode_text();
|
self.update_mini_mode_text();
|
||||||
}
|
}
|
||||||
pub const mini_mode_delete_backwards_meta = .{ .description = "Delete backwards" };
|
pub const mini_mode_delete_backwards_meta: Meta = .{ .description = "Delete backwards" };
|
||||||
|
|
||||||
pub fn mini_mode_try_complete_file(self: *Self, _: Ctx) Result {
|
pub fn mini_mode_try_complete_file(self: *Self, _: Ctx) Result {
|
||||||
self.try_complete_file() catch |e| return tp.exit_error(e, @errorReturnTrace());
|
self.try_complete_file() catch |e| return tp.exit_error(e, @errorReturnTrace());
|
||||||
self.update_mini_mode_text();
|
self.update_mini_mode_text();
|
||||||
}
|
}
|
||||||
pub const mini_mode_try_complete_file_meta = .{ .description = "Complete file" };
|
pub const mini_mode_try_complete_file_meta: Meta = .{ .description = "Complete file" };
|
||||||
|
|
||||||
pub fn mini_mode_try_complete_file_forward(self: *Self, ctx: Ctx) Result {
|
pub fn mini_mode_try_complete_file_forward(self: *Self, ctx: Ctx) Result {
|
||||||
self.complete_trigger_count = 0;
|
self.complete_trigger_count = 0;
|
||||||
return mini_mode_try_complete_file(self, ctx);
|
return mini_mode_try_complete_file(self, ctx);
|
||||||
}
|
}
|
||||||
pub const mini_mode_try_complete_file_forward_meta = .{ .description = "Complete file forward" };
|
pub const mini_mode_try_complete_file_forward_meta: Meta = .{ .description = "Complete file forward" };
|
||||||
|
|
||||||
pub fn mini_mode_reverse_complete_file(self: *Self, _: Ctx) Result {
|
pub fn mini_mode_reverse_complete_file(self: *Self, _: Ctx) Result {
|
||||||
self.reverse_complete_file() catch |e| return tp.exit_error(e, @errorReturnTrace());
|
self.reverse_complete_file() catch |e| return tp.exit_error(e, @errorReturnTrace());
|
||||||
self.update_mini_mode_text();
|
self.update_mini_mode_text();
|
||||||
}
|
}
|
||||||
pub const mini_mode_reverse_complete_file_meta = .{ .description = "Reverse complete file" };
|
pub const mini_mode_reverse_complete_file_meta: Meta = .{ .description = "Reverse complete file" };
|
||||||
|
|
||||||
pub fn mini_mode_insert_code_point(self: *Self, ctx: Ctx) Result {
|
pub fn mini_mode_insert_code_point(self: *Self, ctx: Ctx) Result {
|
||||||
var egc: u32 = 0;
|
var egc: u32 = 0;
|
||||||
|
@ -307,7 +308,7 @@ pub fn Create(options: type) type {
|
||||||
try self.file_path.appendSlice(buf[0..bytes]);
|
try self.file_path.appendSlice(buf[0..bytes]);
|
||||||
self.update_mini_mode_text();
|
self.update_mini_mode_text();
|
||||||
}
|
}
|
||||||
pub const mini_mode_insert_code_point_meta = .{ .arguments = &.{.integer} };
|
pub const mini_mode_insert_code_point_meta: Meta = .{ .arguments = &.{.integer} };
|
||||||
|
|
||||||
pub fn mini_mode_insert_bytes(self: *Self, ctx: Ctx) Result {
|
pub fn mini_mode_insert_bytes(self: *Self, ctx: Ctx) Result {
|
||||||
var bytes: []const u8 = undefined;
|
var bytes: []const u8 = undefined;
|
||||||
|
@ -317,18 +318,18 @@ pub fn Create(options: type) type {
|
||||||
try self.file_path.appendSlice(bytes);
|
try self.file_path.appendSlice(bytes);
|
||||||
self.update_mini_mode_text();
|
self.update_mini_mode_text();
|
||||||
}
|
}
|
||||||
pub const mini_mode_insert_bytes_meta = .{ .arguments = &.{.string} };
|
pub const mini_mode_insert_bytes_meta: Meta = .{ .arguments = &.{.string} };
|
||||||
|
|
||||||
pub fn mini_mode_select(self: *Self, _: Ctx) Result {
|
pub fn mini_mode_select(self: *Self, _: Ctx) Result {
|
||||||
options.select(self);
|
options.select(self);
|
||||||
self.update_mini_mode_text();
|
self.update_mini_mode_text();
|
||||||
}
|
}
|
||||||
pub const mini_mode_select_meta = .{ .description = "Select" };
|
pub const mini_mode_select_meta: Meta = .{ .description = "Select" };
|
||||||
|
|
||||||
pub fn mini_mode_paste(self: *Self, ctx: Ctx) Result {
|
pub fn mini_mode_paste(self: *Self, ctx: Ctx) Result {
|
||||||
return mini_mode_insert_bytes(self, ctx);
|
return mini_mode_insert_bytes(self, ctx);
|
||||||
}
|
}
|
||||||
pub const mini_mode_paste_meta = .{ .arguments = &.{.string} };
|
pub const mini_mode_paste_meta: Meta = .{ .arguments = &.{.string} };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ const name = " find";
|
||||||
const Commands = command.Collection(cmds);
|
const Commands = command.Collection(cmds);
|
||||||
|
|
||||||
allocator: Allocator,
|
allocator: Allocator,
|
||||||
input: ArrayList(u8),
|
input_: ArrayList(u8),
|
||||||
last_input: ArrayList(u8),
|
last_input: ArrayList(u8),
|
||||||
start_view: ed.View,
|
start_view: ed.View,
|
||||||
start_cursor: ed.Cursor,
|
start_cursor: ed.Cursor,
|
||||||
|
@ -31,7 +31,7 @@ pub fn create(allocator: Allocator, _: command.Context) !struct { tui.Mode, tui.
|
||||||
const self: *Self = try allocator.create(Self);
|
const self: *Self = try allocator.create(Self);
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.input = ArrayList(u8).init(allocator),
|
.input_ = ArrayList(u8).init(allocator),
|
||||||
.last_input = ArrayList(u8).init(allocator),
|
.last_input = ArrayList(u8).init(allocator),
|
||||||
.start_view = editor.view,
|
.start_view = editor.view,
|
||||||
.start_cursor = editor.get_primary().cursor,
|
.start_cursor = editor.get_primary().cursor,
|
||||||
|
@ -41,7 +41,7 @@ pub fn create(allocator: Allocator, _: command.Context) !struct { tui.Mode, tui.
|
||||||
if (editor.get_primary().selection) |sel| ret: {
|
if (editor.get_primary().selection) |sel| ret: {
|
||||||
const text = editor.get_selection(sel, self.allocator) catch break :ret;
|
const text = editor.get_selection(sel, self.allocator) catch break :ret;
|
||||||
defer self.allocator.free(text);
|
defer self.allocator.free(text);
|
||||||
try self.input.appendSlice(text);
|
try self.input_.appendSlice(text);
|
||||||
}
|
}
|
||||||
var mode = try keybind.mode("mini/find", allocator, .{
|
var mode = try keybind.mode("mini/find", allocator, .{
|
||||||
.insert_command = "mini_mode_insert_bytes",
|
.insert_command = "mini_mode_insert_bytes",
|
||||||
|
@ -52,7 +52,7 @@ pub fn create(allocator: Allocator, _: command.Context) !struct { tui.Mode, tui.
|
||||||
|
|
||||||
pub fn deinit(self: *Self) void {
|
pub fn deinit(self: *Self) void {
|
||||||
self.commands.deinit();
|
self.commands.deinit();
|
||||||
self.input.deinit();
|
self.input_.deinit();
|
||||||
self.last_input.deinit();
|
self.last_input.deinit();
|
||||||
self.allocator.destroy(self);
|
self.allocator.destroy(self);
|
||||||
}
|
}
|
||||||
|
@ -73,24 +73,24 @@ pub fn receive(self: *Self, _: tp.pid_ref, m: tp.message) error{Exit}!bool {
|
||||||
fn insert_code_point(self: *Self, c: u32) !void {
|
fn insert_code_point(self: *Self, c: u32) !void {
|
||||||
var buf: [16]u8 = undefined;
|
var buf: [16]u8 = undefined;
|
||||||
const bytes = input.ucs32_to_utf8(&[_]u32{c}, &buf) catch |e| return tp.exit_error(e, @errorReturnTrace());
|
const bytes = input.ucs32_to_utf8(&[_]u32{c}, &buf) catch |e| return tp.exit_error(e, @errorReturnTrace());
|
||||||
try self.input.appendSlice(buf[0..bytes]);
|
try self.input_.appendSlice(buf[0..bytes]);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn insert_bytes(self: *Self, bytes: []const u8) !void {
|
fn insert_bytes(self: *Self, bytes: []const u8) !void {
|
||||||
try self.input.appendSlice(bytes);
|
try self.input_.appendSlice(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flush_input(self: *Self) !void {
|
fn flush_input(self: *Self) !void {
|
||||||
if (self.input.items.len > 0) {
|
if (self.input_.items.len > 0) {
|
||||||
if (eql(u8, self.input.items, self.last_input.items))
|
if (eql(u8, self.input_.items, self.last_input.items))
|
||||||
return;
|
return;
|
||||||
self.last_input.clearRetainingCapacity();
|
self.last_input.clearRetainingCapacity();
|
||||||
try self.last_input.appendSlice(self.input.items);
|
try self.last_input.appendSlice(self.input_.items);
|
||||||
self.editor.find_operation = .goto_next_match;
|
self.editor.find_operation = .goto_next_match;
|
||||||
const primary = self.editor.get_primary();
|
const primary = self.editor.get_primary();
|
||||||
primary.selection = null;
|
primary.selection = null;
|
||||||
primary.cursor = self.start_cursor;
|
primary.cursor = self.start_cursor;
|
||||||
try self.editor.find_in_buffer(self.input.items);
|
try self.editor.find_in_buffer(self.input_.items);
|
||||||
} else {
|
} else {
|
||||||
self.editor.get_primary().selection = null;
|
self.editor.get_primary().selection = null;
|
||||||
self.editor.init_matches_update();
|
self.editor.init_matches_update();
|
||||||
|
@ -114,9 +114,9 @@ fn find_history_prev(self: *Self) void {
|
||||||
if (pos > 0) self.history_pos = pos - 1;
|
if (pos > 0) self.history_pos = pos - 1;
|
||||||
} else {
|
} else {
|
||||||
self.history_pos = history.items.len - 1;
|
self.history_pos = history.items.len - 1;
|
||||||
if (self.input.items.len > 0)
|
if (self.input_.items.len > 0)
|
||||||
self.editor.push_find_history(self.editor.allocator.dupe(u8, self.input.items) catch return);
|
self.editor.push_find_history(self.editor.allocator.dupe(u8, self.input_.items) catch return);
|
||||||
if (eql(u8, history.items[self.history_pos.?], self.input.items) and self.history_pos.? > 0)
|
if (eql(u8, history.items[self.history_pos.?], self.input_.items) and self.history_pos.? > 0)
|
||||||
self.history_pos = self.history_pos.? - 1;
|
self.history_pos = self.history_pos.? - 1;
|
||||||
}
|
}
|
||||||
self.load_history(self.history_pos.?);
|
self.load_history(self.history_pos.?);
|
||||||
|
@ -134,39 +134,40 @@ fn find_history_next(self: *Self) void {
|
||||||
|
|
||||||
fn load_history(self: *Self, pos: usize) void {
|
fn load_history(self: *Self, pos: usize) void {
|
||||||
if (self.editor.find_history) |*history| {
|
if (self.editor.find_history) |*history| {
|
||||||
self.input.clearRetainingCapacity();
|
self.input_.clearRetainingCapacity();
|
||||||
self.input.appendSlice(history.items[pos]) catch {};
|
self.input_.appendSlice(history.items[pos]) catch {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_mini_mode_text(self: *Self) void {
|
fn update_mini_mode_text(self: *Self) void {
|
||||||
if (tui.mini_mode()) |mini_mode| {
|
if (tui.mini_mode()) |mini_mode| {
|
||||||
mini_mode.text = self.input.items;
|
mini_mode.text = self.input_.items;
|
||||||
mini_mode.cursor = tui.egc_chunk_width(self.input.items, 0, 8);
|
mini_mode.cursor = tui.egc_chunk_width(self.input_.items, 0, 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const cmds = struct {
|
const cmds = struct {
|
||||||
pub const Target = Self;
|
pub const Target = Self;
|
||||||
const Ctx = command.Context;
|
const Ctx = command.Context;
|
||||||
|
const Meta = command.Metadata;
|
||||||
const Result = command.Result;
|
const Result = command.Result;
|
||||||
|
|
||||||
pub fn mini_mode_reset(self: *Self, _: Ctx) Result {
|
pub fn mini_mode_reset(self: *Self, _: Ctx) Result {
|
||||||
self.input.clearRetainingCapacity();
|
self.input_.clearRetainingCapacity();
|
||||||
self.update_mini_mode_text();
|
self.update_mini_mode_text();
|
||||||
}
|
}
|
||||||
pub const mini_mode_reset_meta = .{ .description = "Clear input" };
|
pub const mini_mode_reset_meta: Meta = .{ .description = "Clear input" };
|
||||||
|
|
||||||
pub fn mini_mode_cancel(self: *Self, _: Ctx) Result {
|
pub fn mini_mode_cancel(self: *Self, _: Ctx) Result {
|
||||||
self.cancel();
|
self.cancel();
|
||||||
}
|
}
|
||||||
pub const mini_mode_cancel_meta = .{ .description = "Cancel input" };
|
pub const mini_mode_cancel_meta: Meta = .{ .description = "Cancel input" };
|
||||||
|
|
||||||
pub fn mini_mode_select(self: *Self, _: Ctx) Result {
|
pub fn mini_mode_select(self: *Self, _: Ctx) Result {
|
||||||
self.editor.push_find_history(self.input.items);
|
self.editor.push_find_history(self.input_.items);
|
||||||
self.cmd("exit_mini_mode", .{}) catch {};
|
self.cmd("exit_mini_mode", .{}) catch {};
|
||||||
}
|
}
|
||||||
pub const mini_mode_select_meta = .{ .description = "Select" };
|
pub const mini_mode_select_meta: Meta = .{ .description = "Select" };
|
||||||
|
|
||||||
pub fn mini_mode_insert_code_point(self: *Self, ctx: Ctx) Result {
|
pub fn mini_mode_insert_code_point(self: *Self, ctx: Ctx) Result {
|
||||||
var egc: u32 = 0;
|
var egc: u32 = 0;
|
||||||
|
@ -175,7 +176,7 @@ const cmds = struct {
|
||||||
self.insert_code_point(egc) catch |e| return tp.exit_error(e, @errorReturnTrace());
|
self.insert_code_point(egc) catch |e| return tp.exit_error(e, @errorReturnTrace());
|
||||||
self.update_mini_mode_text();
|
self.update_mini_mode_text();
|
||||||
}
|
}
|
||||||
pub const mini_mode_insert_code_point_meta = .{ .arguments = &.{.integer} };
|
pub const mini_mode_insert_code_point_meta: Meta = .{ .arguments = &.{.integer} };
|
||||||
|
|
||||||
pub fn mini_mode_insert_bytes(self: *Self, ctx: Ctx) Result {
|
pub fn mini_mode_insert_bytes(self: *Self, ctx: Ctx) Result {
|
||||||
var bytes: []const u8 = undefined;
|
var bytes: []const u8 = undefined;
|
||||||
|
@ -184,28 +185,28 @@ const cmds = struct {
|
||||||
self.insert_bytes(bytes) catch |e| return tp.exit_error(e, @errorReturnTrace());
|
self.insert_bytes(bytes) catch |e| return tp.exit_error(e, @errorReturnTrace());
|
||||||
self.update_mini_mode_text();
|
self.update_mini_mode_text();
|
||||||
}
|
}
|
||||||
pub const mini_mode_insert_bytes_meta = .{ .arguments = &.{.string} };
|
pub const mini_mode_insert_bytes_meta: Meta = .{ .arguments = &.{.string} };
|
||||||
|
|
||||||
pub fn mini_mode_delete_backwards(self: *Self, _: Ctx) Result {
|
pub fn mini_mode_delete_backwards(self: *Self, _: Ctx) Result {
|
||||||
self.input.resize(self.input.items.len - tui.egc_last(self.input.items).len) catch {};
|
self.input_.resize(self.input_.items.len - tui.egc_last(self.input_.items).len) catch {};
|
||||||
self.update_mini_mode_text();
|
self.update_mini_mode_text();
|
||||||
}
|
}
|
||||||
pub const mini_mode_delete_backwards_meta = .{ .description = "Delete backwards" };
|
pub const mini_mode_delete_backwards_meta: Meta = .{ .description = "Delete backwards" };
|
||||||
|
|
||||||
pub fn mini_mode_history_prev(self: *Self, _: Ctx) Result {
|
pub fn mini_mode_history_prev(self: *Self, _: Ctx) Result {
|
||||||
self.find_history_prev();
|
self.find_history_prev();
|
||||||
self.update_mini_mode_text();
|
self.update_mini_mode_text();
|
||||||
}
|
}
|
||||||
pub const mini_mode_history_prev_meta = .{ .description = "History previous" };
|
pub const mini_mode_history_prev_meta: Meta = .{ .description = "History previous" };
|
||||||
|
|
||||||
pub fn mini_mode_history_next(self: *Self, _: Ctx) Result {
|
pub fn mini_mode_history_next(self: *Self, _: Ctx) Result {
|
||||||
self.find_history_next();
|
self.find_history_next();
|
||||||
self.update_mini_mode_text();
|
self.update_mini_mode_text();
|
||||||
}
|
}
|
||||||
pub const mini_mode_history_next_meta = .{ .description = "History next" };
|
pub const mini_mode_history_next_meta: Meta = .{ .description = "History next" };
|
||||||
|
|
||||||
pub fn mini_mode_paste(self: *Self, ctx: Ctx) Result {
|
pub fn mini_mode_paste(self: *Self, ctx: Ctx) Result {
|
||||||
return mini_mode_insert_bytes(self, ctx);
|
return mini_mode_insert_bytes(self, ctx);
|
||||||
}
|
}
|
||||||
pub const mini_mode_paste_meta = .{ .arguments = &.{.string} };
|
pub const mini_mode_paste_meta: Meta = .{ .arguments = &.{.string} };
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,7 +19,7 @@ const max_query_size = 1024;
|
||||||
|
|
||||||
allocator: Allocator,
|
allocator: Allocator,
|
||||||
buf: [max_query_size]u8 = undefined,
|
buf: [max_query_size]u8 = undefined,
|
||||||
input: []u8 = "",
|
input_: []u8 = "",
|
||||||
last_buf: [max_query_size]u8 = undefined,
|
last_buf: [max_query_size]u8 = undefined,
|
||||||
last_input: []u8 = "",
|
last_input: []u8 = "",
|
||||||
commands: Commands = undefined,
|
commands: Commands = undefined,
|
||||||
|
@ -31,7 +31,7 @@ pub fn create(allocator: Allocator, _: command.Context) !struct { tui.Mode, tui.
|
||||||
if (tui.get_active_selection(self.allocator)) |text| {
|
if (tui.get_active_selection(self.allocator)) |text| {
|
||||||
defer self.allocator.free(text);
|
defer self.allocator.free(text);
|
||||||
@memcpy(self.buf[0..text.len], text);
|
@memcpy(self.buf[0..text.len], text);
|
||||||
self.input = self.buf[0..text.len];
|
self.input_ = self.buf[0..text.len];
|
||||||
}
|
}
|
||||||
var mode = try keybind.mode("mini/find_in_files", allocator, .{
|
var mode = try keybind.mode("mini/find_in_files", allocator, .{
|
||||||
.insert_command = "mini_mode_insert_bytes",
|
.insert_command = "mini_mode_insert_bytes",
|
||||||
|
@ -59,55 +59,56 @@ pub fn receive(self: *Self, _: tp.pid_ref, m: tp.message) error{Exit}!bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn insert_code_point(self: *Self, c: u32) !void {
|
fn insert_code_point(self: *Self, c: u32) !void {
|
||||||
if (self.input.len + 6 >= self.buf.len)
|
if (self.input_.len + 6 >= self.buf.len)
|
||||||
return;
|
return;
|
||||||
const bytes = try input.ucs32_to_utf8(&[_]u32{c}, self.buf[self.input.len..]);
|
const bytes = try input.ucs32_to_utf8(&[_]u32{c}, self.buf[self.input_.len..]);
|
||||||
self.input = self.buf[0 .. self.input.len + bytes];
|
self.input_ = self.buf[0 .. self.input_.len + bytes];
|
||||||
}
|
}
|
||||||
|
|
||||||
fn insert_bytes(self: *Self, bytes_: []const u8) !void {
|
fn insert_bytes(self: *Self, bytes_: []const u8) !void {
|
||||||
const bytes = bytes_[0..@min(self.buf.len - self.input.len, bytes_.len)];
|
const bytes = bytes_[0..@min(self.buf.len - self.input_.len, bytes_.len)];
|
||||||
const newlen = self.input.len + bytes.len;
|
const newlen = self.input_.len + bytes.len;
|
||||||
@memcpy(self.buf[self.input.len..newlen], bytes);
|
@memcpy(self.buf[self.input_.len..newlen], bytes);
|
||||||
self.input = self.buf[0..newlen];
|
self.input_ = self.buf[0..newlen];
|
||||||
}
|
}
|
||||||
|
|
||||||
fn start_query(self: *Self) !void {
|
fn start_query(self: *Self) !void {
|
||||||
if (self.input.len < 2 or eql(u8, self.input, self.last_input))
|
if (self.input_.len < 2 or eql(u8, self.input_, self.last_input))
|
||||||
return;
|
return;
|
||||||
@memcpy(self.last_buf[0..self.input.len], self.input);
|
@memcpy(self.last_buf[0..self.input_.len], self.input_);
|
||||||
self.last_input = self.last_buf[0..self.input.len];
|
self.last_input = self.last_buf[0..self.input_.len];
|
||||||
try command.executeName("find_in_files_query", command.fmt(.{self.input}));
|
try command.executeName("find_in_files_query", command.fmt(.{self.input_}));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_mini_mode_text(self: *Self) void {
|
fn update_mini_mode_text(self: *Self) void {
|
||||||
if (tui.mini_mode()) |mini_mode| {
|
if (tui.mini_mode()) |mini_mode| {
|
||||||
mini_mode.text = self.input;
|
mini_mode.text = self.input_;
|
||||||
mini_mode.cursor = tui.egc_chunk_width(self.input, 0, 8);
|
mini_mode.cursor = tui.egc_chunk_width(self.input_, 0, 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const cmds = struct {
|
const cmds = struct {
|
||||||
pub const Target = Self;
|
pub const Target = Self;
|
||||||
const Ctx = command.Context;
|
const Ctx = command.Context;
|
||||||
|
const Meta = command.Metadata;
|
||||||
const Result = command.Result;
|
const Result = command.Result;
|
||||||
|
|
||||||
pub fn mini_mode_reset(self: *Self, _: Ctx) Result {
|
pub fn mini_mode_reset(self: *Self, _: Ctx) Result {
|
||||||
self.input = "";
|
self.input_ = "";
|
||||||
self.update_mini_mode_text();
|
self.update_mini_mode_text();
|
||||||
}
|
}
|
||||||
pub const mini_mode_reset_meta = .{ .description = "Clear input" };
|
pub const mini_mode_reset_meta: Meta = .{ .description = "Clear input" };
|
||||||
|
|
||||||
pub fn mini_mode_cancel(_: *Self, _: Ctx) Result {
|
pub fn mini_mode_cancel(_: *Self, _: Ctx) Result {
|
||||||
command.executeName("exit_mini_mode", .{}) catch {};
|
command.executeName("exit_mini_mode", .{}) catch {};
|
||||||
}
|
}
|
||||||
pub const mini_mode_cancel_meta = .{ .description = "Cancel input" };
|
pub const mini_mode_cancel_meta: Meta = .{ .description = "Cancel input" };
|
||||||
|
|
||||||
pub fn mini_mode_select(_: *Self, _: Ctx) Result {
|
pub fn mini_mode_select(_: *Self, _: Ctx) Result {
|
||||||
command.executeName("goto_selected_file", .{}) catch {};
|
command.executeName("goto_selected_file", .{}) catch {};
|
||||||
return command.executeName("exit_mini_mode", .{});
|
return command.executeName("exit_mini_mode", .{});
|
||||||
}
|
}
|
||||||
pub const mini_mode_select_meta = .{ .description = "Select" };
|
pub const mini_mode_select_meta: Meta = .{ .description = "Select" };
|
||||||
|
|
||||||
pub fn mini_mode_insert_code_point(self: *Self, ctx: Ctx) Result {
|
pub fn mini_mode_insert_code_point(self: *Self, ctx: Ctx) Result {
|
||||||
var egc: u32 = 0;
|
var egc: u32 = 0;
|
||||||
|
@ -116,7 +117,7 @@ const cmds = struct {
|
||||||
self.insert_code_point(egc) catch |e| return tp.exit_error(e, @errorReturnTrace());
|
self.insert_code_point(egc) catch |e| return tp.exit_error(e, @errorReturnTrace());
|
||||||
self.update_mini_mode_text();
|
self.update_mini_mode_text();
|
||||||
}
|
}
|
||||||
pub const mini_mode_insert_code_point_meta = .{ .arguments = &.{.integer} };
|
pub const mini_mode_insert_code_point_meta: Meta = .{ .arguments = &.{.integer} };
|
||||||
|
|
||||||
pub fn mini_mode_insert_bytes(self: *Self, ctx: Ctx) Result {
|
pub fn mini_mode_insert_bytes(self: *Self, ctx: Ctx) Result {
|
||||||
var bytes: []const u8 = undefined;
|
var bytes: []const u8 = undefined;
|
||||||
|
@ -125,16 +126,16 @@ const cmds = struct {
|
||||||
self.insert_bytes(bytes) catch |e| return tp.exit_error(e, @errorReturnTrace());
|
self.insert_bytes(bytes) catch |e| return tp.exit_error(e, @errorReturnTrace());
|
||||||
self.update_mini_mode_text();
|
self.update_mini_mode_text();
|
||||||
}
|
}
|
||||||
pub const mini_mode_insert_bytes_meta = .{ .arguments = &.{.string} };
|
pub const mini_mode_insert_bytes_meta: Meta = .{ .arguments = &.{.string} };
|
||||||
|
|
||||||
pub fn mini_mode_delete_backwards(self: *Self, _: Ctx) Result {
|
pub fn mini_mode_delete_backwards(self: *Self, _: Ctx) Result {
|
||||||
self.input = self.input[0 .. self.input.len - tui.egc_last(self.input).len];
|
self.input_ = self.input_[0 .. self.input_.len - tui.egc_last(self.input_).len];
|
||||||
self.update_mini_mode_text();
|
self.update_mini_mode_text();
|
||||||
}
|
}
|
||||||
pub const mini_mode_delete_backwards_meta = .{ .description = "Delete backwards" };
|
pub const mini_mode_delete_backwards_meta: Meta = .{ .description = "Delete backwards" };
|
||||||
|
|
||||||
pub fn mini_mode_paste(self: *Self, ctx: Ctx) Result {
|
pub fn mini_mode_paste(self: *Self, ctx: Ctx) Result {
|
||||||
return mini_mode_insert_bytes(self, ctx);
|
return mini_mode_insert_bytes(self, ctx);
|
||||||
}
|
}
|
||||||
pub const mini_mode_paste_meta = .{ .arguments = &.{.string} };
|
pub const mini_mode_paste_meta: Meta = .{ .arguments = &.{.string} };
|
||||||
};
|
};
|
||||||
|
|
|
@ -82,13 +82,14 @@ fn insert_bytes(self: *Self, bytes: []const u8) void {
|
||||||
const cmds = struct {
|
const cmds = struct {
|
||||||
pub const Target = Self;
|
pub const Target = Self;
|
||||||
const Ctx = command.Context;
|
const Ctx = command.Context;
|
||||||
|
const Meta = command.Metadata;
|
||||||
const Result = command.Result;
|
const Result = command.Result;
|
||||||
|
|
||||||
pub fn mini_mode_reset(self: *Self, _: Ctx) Result {
|
pub fn mini_mode_reset(self: *Self, _: Ctx) Result {
|
||||||
self.input = null;
|
self.input = null;
|
||||||
self.update_mini_mode_text();
|
self.update_mini_mode_text();
|
||||||
}
|
}
|
||||||
pub const mini_mode_reset_meta = .{ .description = "Clear input" };
|
pub const mini_mode_reset_meta: Meta = .{ .description = "Clear input" };
|
||||||
|
|
||||||
pub fn mini_mode_cancel(self: *Self, _: Ctx) Result {
|
pub fn mini_mode_cancel(self: *Self, _: Ctx) Result {
|
||||||
self.input = null;
|
self.input = null;
|
||||||
|
@ -96,7 +97,7 @@ const cmds = struct {
|
||||||
self.goto();
|
self.goto();
|
||||||
command.executeName("exit_mini_mode", .{}) catch {};
|
command.executeName("exit_mini_mode", .{}) catch {};
|
||||||
}
|
}
|
||||||
pub const mini_mode_cancel_meta = .{ .description = "Cancel input" };
|
pub const mini_mode_cancel_meta: Meta = .{ .description = "Cancel input" };
|
||||||
|
|
||||||
pub fn mini_mode_delete_backwards(self: *Self, _: Ctx) Result {
|
pub fn mini_mode_delete_backwards(self: *Self, _: Ctx) Result {
|
||||||
if (self.input) |linenum| {
|
if (self.input) |linenum| {
|
||||||
|
@ -106,7 +107,7 @@ const cmds = struct {
|
||||||
self.goto();
|
self.goto();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub const mini_mode_delete_backwards_meta = .{ .description = "Delete backwards" };
|
pub const mini_mode_delete_backwards_meta: Meta = .{ .description = "Delete backwards" };
|
||||||
|
|
||||||
pub fn mini_mode_insert_code_point(self: *Self, ctx: Ctx) Result {
|
pub fn mini_mode_insert_code_point(self: *Self, ctx: Ctx) Result {
|
||||||
var keypress: usize = 0;
|
var keypress: usize = 0;
|
||||||
|
@ -119,7 +120,7 @@ const cmds = struct {
|
||||||
self.update_mini_mode_text();
|
self.update_mini_mode_text();
|
||||||
self.goto();
|
self.goto();
|
||||||
}
|
}
|
||||||
pub const mini_mode_insert_code_point_meta = .{ .arguments = &.{.integer} };
|
pub const mini_mode_insert_code_point_meta: Meta = .{ .arguments = &.{.integer} };
|
||||||
|
|
||||||
pub fn mini_mode_insert_bytes(self: *Self, ctx: Ctx) Result {
|
pub fn mini_mode_insert_bytes(self: *Self, ctx: Ctx) Result {
|
||||||
var bytes: []const u8 = undefined;
|
var bytes: []const u8 = undefined;
|
||||||
|
@ -129,5 +130,5 @@ const cmds = struct {
|
||||||
self.update_mini_mode_text();
|
self.update_mini_mode_text();
|
||||||
self.goto();
|
self.goto();
|
||||||
}
|
}
|
||||||
pub const mini_mode_insert_bytes_meta = .{ .arguments = &.{.string} };
|
pub const mini_mode_insert_bytes_meta: Meta = .{ .arguments = &.{.string} };
|
||||||
};
|
};
|
||||||
|
|
|
@ -87,6 +87,7 @@ fn execute_operation(self: *Self, ctx: command.Context) command.Result {
|
||||||
const cmds = struct {
|
const cmds = struct {
|
||||||
pub const Target = Self;
|
pub const Target = Self;
|
||||||
const Ctx = command.Context;
|
const Ctx = command.Context;
|
||||||
|
const Meta = command.Metadata;
|
||||||
const Result = command.Result;
|
const Result = command.Result;
|
||||||
|
|
||||||
pub fn mini_mode_insert_code_point(self: *Self, ctx: Ctx) Result {
|
pub fn mini_mode_insert_code_point(self: *Self, ctx: Ctx) Result {
|
||||||
|
@ -97,7 +98,7 @@ const cmds = struct {
|
||||||
const bytes = input.ucs32_to_utf8(&[_]u32{code_point}, &buf) catch return error.InvalidMoveToCharCodePoint;
|
const bytes = input.ucs32_to_utf8(&[_]u32{code_point}, &buf) catch return error.InvalidMoveToCharCodePoint;
|
||||||
return self.execute_operation(command.fmt(.{buf[0..bytes]}));
|
return self.execute_operation(command.fmt(.{buf[0..bytes]}));
|
||||||
}
|
}
|
||||||
pub const mini_mode_insert_code_point_meta = .{ .arguments = &.{.integer} };
|
pub const mini_mode_insert_code_point_meta: Meta = .{ .arguments = &.{.integer} };
|
||||||
|
|
||||||
pub fn mini_mode_insert_bytes(self: *Self, ctx: Ctx) Result {
|
pub fn mini_mode_insert_bytes(self: *Self, ctx: Ctx) Result {
|
||||||
var bytes: []const u8 = undefined;
|
var bytes: []const u8 = undefined;
|
||||||
|
@ -105,10 +106,10 @@ const cmds = struct {
|
||||||
return error.InvalidMoveToCharInsertBytesArgument;
|
return error.InvalidMoveToCharInsertBytesArgument;
|
||||||
return self.execute_operation(ctx);
|
return self.execute_operation(ctx);
|
||||||
}
|
}
|
||||||
pub const mini_mode_insert_bytes_meta = .{ .arguments = &.{.string} };
|
pub const mini_mode_insert_bytes_meta: Meta = .{ .arguments = &.{.string} };
|
||||||
|
|
||||||
pub fn mini_mode_cancel(_: *Self, _: Ctx) Result {
|
pub fn mini_mode_cancel(_: *Self, _: Ctx) Result {
|
||||||
command.executeName("exit_mini_mode", .{}) catch {};
|
command.executeName("exit_mini_mode", .{}) catch {};
|
||||||
}
|
}
|
||||||
pub const mini_mode_cancel_meta = .{ .description = "Cancel input" };
|
pub const mini_mode_cancel_meta: Meta = .{ .description = "Cancel input" };
|
||||||
};
|
};
|
||||||
|
|
|
@ -272,47 +272,48 @@ const Commands = command.Collection(cmds);
|
||||||
const cmds = struct {
|
const cmds = struct {
|
||||||
pub const Target = Self;
|
pub const Target = Self;
|
||||||
const Ctx = command.Context;
|
const Ctx = command.Context;
|
||||||
|
const Meta = command.Metadata;
|
||||||
const Result = command.Result;
|
const Result = command.Result;
|
||||||
|
|
||||||
pub fn palette_menu_top(self: *Self, _: Ctx) Result {
|
pub fn palette_menu_top(self: *Self, _: Ctx) Result {
|
||||||
self.menu.select_first();
|
self.menu.select_first();
|
||||||
}
|
}
|
||||||
pub const palette_menu_top_meta = .{};
|
pub const palette_menu_top_meta: Meta = .{};
|
||||||
|
|
||||||
pub fn palette_menu_down(self: *Self, _: Ctx) Result {
|
pub fn palette_menu_down(self: *Self, _: Ctx) Result {
|
||||||
self.menu.select_down();
|
self.menu.select_down();
|
||||||
}
|
}
|
||||||
pub const palette_menu_down_meta = .{};
|
pub const palette_menu_down_meta: Meta = .{};
|
||||||
|
|
||||||
pub fn palette_menu_up(self: *Self, _: Ctx) Result {
|
pub fn palette_menu_up(self: *Self, _: Ctx) Result {
|
||||||
self.menu.select_up();
|
self.menu.select_up();
|
||||||
}
|
}
|
||||||
pub const palette_menu_up_meta = .{};
|
pub const palette_menu_up_meta: Meta = .{};
|
||||||
|
|
||||||
pub fn palette_menu_activate(self: *Self, _: Ctx) Result {
|
pub fn palette_menu_activate(self: *Self, _: Ctx) Result {
|
||||||
self.menu.activate_selected();
|
self.menu.activate_selected();
|
||||||
}
|
}
|
||||||
pub const palette_menu_activate_meta = .{};
|
pub const palette_menu_activate_meta: Meta = .{};
|
||||||
|
|
||||||
pub fn palette_menu_activate_quick(self: *Self, _: Ctx) Result {
|
pub fn palette_menu_activate_quick(self: *Self, _: Ctx) Result {
|
||||||
if (self.menu.selected orelse 0 > 0) self.menu.activate_selected();
|
if (self.menu.selected orelse 0 > 0) self.menu.activate_selected();
|
||||||
}
|
}
|
||||||
pub const palette_menu_activate_quick_meta = .{};
|
pub const palette_menu_activate_quick_meta: Meta = .{};
|
||||||
|
|
||||||
pub fn palette_menu_cancel(self: *Self, _: Ctx) Result {
|
pub fn palette_menu_cancel(self: *Self, _: Ctx) Result {
|
||||||
try self.cmd("exit_overlay_mode", .{});
|
try self.cmd("exit_overlay_mode", .{});
|
||||||
}
|
}
|
||||||
pub const palette_menu_cancel_meta = .{};
|
pub const palette_menu_cancel_meta: Meta = .{};
|
||||||
|
|
||||||
pub fn overlay_delete_word_left(self: *Self, _: Ctx) Result {
|
pub fn overlay_delete_word_left(self: *Self, _: Ctx) Result {
|
||||||
self.delete_word() catch |e| return tp.exit_error(e, @errorReturnTrace());
|
self.delete_word() catch |e| return tp.exit_error(e, @errorReturnTrace());
|
||||||
}
|
}
|
||||||
pub const overlay_delete_word_left_meta = .{ .description = "Delete word to the left" };
|
pub const overlay_delete_word_left_meta: Meta = .{ .description = "Delete word to the left" };
|
||||||
|
|
||||||
pub fn overlay_delete_backwards(self: *Self, _: Ctx) Result {
|
pub fn overlay_delete_backwards(self: *Self, _: Ctx) Result {
|
||||||
self.delete_code_point() catch |e| return tp.exit_error(e, @errorReturnTrace());
|
self.delete_code_point() catch |e| return tp.exit_error(e, @errorReturnTrace());
|
||||||
}
|
}
|
||||||
pub const overlay_delete_backwards_meta = .{ .description = "Delete backwards" };
|
pub const overlay_delete_backwards_meta: Meta = .{ .description = "Delete backwards" };
|
||||||
|
|
||||||
pub fn overlay_insert_code_point(self: *Self, ctx: Ctx) Result {
|
pub fn overlay_insert_code_point(self: *Self, ctx: Ctx) Result {
|
||||||
var egc: u32 = 0;
|
var egc: u32 = 0;
|
||||||
|
@ -320,7 +321,7 @@ const cmds = struct {
|
||||||
return error.InvalidOpenRecentInsertCodePointArgument;
|
return error.InvalidOpenRecentInsertCodePointArgument;
|
||||||
self.insert_code_point(egc) catch |e| return tp.exit_error(e, @errorReturnTrace());
|
self.insert_code_point(egc) catch |e| return tp.exit_error(e, @errorReturnTrace());
|
||||||
}
|
}
|
||||||
pub const overlay_insert_code_point_meta = .{ .arguments = &.{.integer} };
|
pub const overlay_insert_code_point_meta: Meta = .{ .arguments = &.{.integer} };
|
||||||
|
|
||||||
pub fn overlay_insert_bytes(self: *Self, ctx: Ctx) Result {
|
pub fn overlay_insert_bytes(self: *Self, ctx: Ctx) Result {
|
||||||
var bytes: []const u8 = undefined;
|
var bytes: []const u8 = undefined;
|
||||||
|
@ -328,20 +329,20 @@ const cmds = struct {
|
||||||
return error.InvalidOpenRecentInsertBytesArgument;
|
return error.InvalidOpenRecentInsertBytesArgument;
|
||||||
self.insert_bytes(bytes) catch |e| return tp.exit_error(e, @errorReturnTrace());
|
self.insert_bytes(bytes) catch |e| return tp.exit_error(e, @errorReturnTrace());
|
||||||
}
|
}
|
||||||
pub const overlay_insert_bytes_meta = .{ .arguments = &.{.string} };
|
pub const overlay_insert_bytes_meta: Meta = .{ .arguments = &.{.string} };
|
||||||
|
|
||||||
pub fn overlay_toggle_panel(self: *Self, _: Ctx) Result {
|
pub fn overlay_toggle_panel(self: *Self, _: Ctx) Result {
|
||||||
return self.cmd_async("toggle_panel");
|
return self.cmd_async("toggle_panel");
|
||||||
}
|
}
|
||||||
pub const overlay_toggle_panel_meta = .{};
|
pub const overlay_toggle_panel_meta: Meta = .{};
|
||||||
|
|
||||||
pub fn overlay_toggle_inputview(self: *Self, _: Ctx) Result {
|
pub fn overlay_toggle_inputview(self: *Self, _: Ctx) Result {
|
||||||
return self.cmd_async("toggle_inputview");
|
return self.cmd_async("toggle_inputview");
|
||||||
}
|
}
|
||||||
pub const overlay_toggle_inputview_meta = .{};
|
pub const overlay_toggle_inputview_meta: Meta = .{};
|
||||||
|
|
||||||
pub fn mini_mode_paste(self: *Self, ctx: Ctx) Result {
|
pub fn mini_mode_paste(self: *Self, ctx: Ctx) Result {
|
||||||
return overlay_insert_bytes(self, ctx);
|
return overlay_insert_bytes(self, ctx);
|
||||||
}
|
}
|
||||||
pub const mini_mode_paste_meta = .{ .arguments = &.{.string} };
|
pub const mini_mode_paste_meta: Meta = .{ .arguments = &.{.string} };
|
||||||
};
|
};
|
||||||
|
|
|
@ -373,6 +373,7 @@ pub fn Create(options: type) type {
|
||||||
const cmds = struct {
|
const cmds = struct {
|
||||||
pub const Target = Self;
|
pub const Target = Self;
|
||||||
const Ctx = command.Context;
|
const Ctx = command.Context;
|
||||||
|
const Meta = command.Metadata;
|
||||||
const Result = command.Result;
|
const Result = command.Result;
|
||||||
|
|
||||||
pub fn palette_menu_down(self: *Self, _: Ctx) Result {
|
pub fn palette_menu_down(self: *Self, _: Ctx) Result {
|
||||||
|
@ -390,7 +391,7 @@ pub fn Create(options: type) type {
|
||||||
self.menu.select_down();
|
self.menu.select_down();
|
||||||
self.selection_updated();
|
self.selection_updated();
|
||||||
}
|
}
|
||||||
pub const palette_menu_down_meta = .{};
|
pub const palette_menu_down_meta: Meta = .{};
|
||||||
|
|
||||||
pub fn palette_menu_up(self: *Self, _: Ctx) Result {
|
pub fn palette_menu_up(self: *Self, _: Ctx) Result {
|
||||||
if (self.menu.selected) |selected| {
|
if (self.menu.selected) |selected| {
|
||||||
|
@ -405,7 +406,7 @@ pub fn Create(options: type) type {
|
||||||
self.menu.select_up();
|
self.menu.select_up();
|
||||||
self.selection_updated();
|
self.selection_updated();
|
||||||
}
|
}
|
||||||
pub const palette_menu_up_meta = .{};
|
pub const palette_menu_up_meta: Meta = .{};
|
||||||
|
|
||||||
pub fn palette_menu_pagedown(self: *Self, _: Ctx) Result {
|
pub fn palette_menu_pagedown(self: *Self, _: Ctx) Result {
|
||||||
if (self.total_items > self.view_rows) {
|
if (self.total_items > self.view_rows) {
|
||||||
|
@ -417,7 +418,7 @@ pub fn Create(options: type) type {
|
||||||
self.menu.select_last();
|
self.menu.select_last();
|
||||||
self.selection_updated();
|
self.selection_updated();
|
||||||
}
|
}
|
||||||
pub const palette_menu_pagedown_meta = .{};
|
pub const palette_menu_pagedown_meta: Meta = .{};
|
||||||
|
|
||||||
pub fn palette_menu_pageup(self: *Self, _: Ctx) Result {
|
pub fn palette_menu_pageup(self: *Self, _: Ctx) Result {
|
||||||
if (self.view_pos > self.view_rows)
|
if (self.view_pos > self.view_rows)
|
||||||
|
@ -428,7 +429,7 @@ pub fn Create(options: type) type {
|
||||||
self.menu.select_first();
|
self.menu.select_first();
|
||||||
self.selection_updated();
|
self.selection_updated();
|
||||||
}
|
}
|
||||||
pub const palette_menu_pageup_meta = .{};
|
pub const palette_menu_pageup_meta: Meta = .{};
|
||||||
|
|
||||||
pub fn palette_menu_delete_item(self: *Self, _: Ctx) Result {
|
pub fn palette_menu_delete_item(self: *Self, _: Ctx) Result {
|
||||||
if (@hasDecl(options, "delete_item")) {
|
if (@hasDecl(options, "delete_item")) {
|
||||||
|
@ -443,33 +444,33 @@ pub fn Create(options: type) type {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub const palette_menu_delete_item_meta = .{};
|
pub const palette_menu_delete_item_meta: Meta = .{};
|
||||||
|
|
||||||
pub fn palette_menu_activate(self: *Self, _: Ctx) Result {
|
pub fn palette_menu_activate(self: *Self, _: Ctx) Result {
|
||||||
self.menu.activate_selected();
|
self.menu.activate_selected();
|
||||||
}
|
}
|
||||||
pub const palette_menu_activate_meta = .{};
|
pub const palette_menu_activate_meta: Meta = .{};
|
||||||
|
|
||||||
pub fn palette_menu_activate_quick(self: *Self, _: Ctx) Result {
|
pub fn palette_menu_activate_quick(self: *Self, _: Ctx) Result {
|
||||||
if (self.menu.selected orelse 0 > 0) self.menu.activate_selected();
|
if (self.menu.selected orelse 0 > 0) self.menu.activate_selected();
|
||||||
}
|
}
|
||||||
pub const palette_menu_activate_quick_meta = .{};
|
pub const palette_menu_activate_quick_meta: Meta = .{};
|
||||||
|
|
||||||
pub fn palette_menu_cancel(self: *Self, _: Ctx) Result {
|
pub fn palette_menu_cancel(self: *Self, _: Ctx) Result {
|
||||||
if (@hasDecl(options, "cancel")) try options.cancel(self);
|
if (@hasDecl(options, "cancel")) try options.cancel(self);
|
||||||
try self.cmd("exit_overlay_mode", .{});
|
try self.cmd("exit_overlay_mode", .{});
|
||||||
}
|
}
|
||||||
pub const palette_menu_cancel_meta = .{};
|
pub const palette_menu_cancel_meta: Meta = .{};
|
||||||
|
|
||||||
pub fn overlay_delete_word_left(self: *Self, _: Ctx) Result {
|
pub fn overlay_delete_word_left(self: *Self, _: Ctx) Result {
|
||||||
self.delete_word() catch |e| return tp.exit_error(e, @errorReturnTrace());
|
self.delete_word() catch |e| return tp.exit_error(e, @errorReturnTrace());
|
||||||
}
|
}
|
||||||
pub const overlay_delete_word_left_meta = .{ .description = "Delete word to the left" };
|
pub const overlay_delete_word_left_meta: Meta = .{ .description = "Delete word to the left" };
|
||||||
|
|
||||||
pub fn overlay_delete_backwards(self: *Self, _: Ctx) Result {
|
pub fn overlay_delete_backwards(self: *Self, _: Ctx) Result {
|
||||||
self.delete_code_point() catch |e| return tp.exit_error(e, @errorReturnTrace());
|
self.delete_code_point() catch |e| return tp.exit_error(e, @errorReturnTrace());
|
||||||
}
|
}
|
||||||
pub const overlay_delete_backwards_meta = .{ .description = "Delete backwards" };
|
pub const overlay_delete_backwards_meta: Meta = .{ .description = "Delete backwards" };
|
||||||
|
|
||||||
pub fn overlay_insert_code_point(self: *Self, ctx: Ctx) Result {
|
pub fn overlay_insert_code_point(self: *Self, ctx: Ctx) Result {
|
||||||
var egc: u32 = 0;
|
var egc: u32 = 0;
|
||||||
|
@ -477,7 +478,7 @@ pub fn Create(options: type) type {
|
||||||
return error.InvalidPaletteInsertCodePointArgument;
|
return error.InvalidPaletteInsertCodePointArgument;
|
||||||
self.insert_code_point(egc) catch |e| return tp.exit_error(e, @errorReturnTrace());
|
self.insert_code_point(egc) catch |e| return tp.exit_error(e, @errorReturnTrace());
|
||||||
}
|
}
|
||||||
pub const overlay_insert_code_point_meta = .{ .arguments = &.{.integer} };
|
pub const overlay_insert_code_point_meta: Meta = .{ .arguments = &.{.integer} };
|
||||||
|
|
||||||
pub fn overlay_insert_bytes(self: *Self, ctx: Ctx) Result {
|
pub fn overlay_insert_bytes(self: *Self, ctx: Ctx) Result {
|
||||||
var bytes: []const u8 = undefined;
|
var bytes: []const u8 = undefined;
|
||||||
|
@ -485,22 +486,22 @@ pub fn Create(options: type) type {
|
||||||
return error.InvalidPaletteInsertBytesArgument;
|
return error.InvalidPaletteInsertBytesArgument;
|
||||||
self.insert_bytes(bytes) catch |e| return tp.exit_error(e, @errorReturnTrace());
|
self.insert_bytes(bytes) catch |e| return tp.exit_error(e, @errorReturnTrace());
|
||||||
}
|
}
|
||||||
pub const overlay_insert_bytes_meta = .{ .arguments = &.{.string} };
|
pub const overlay_insert_bytes_meta: Meta = .{ .arguments = &.{.string} };
|
||||||
|
|
||||||
pub fn overlay_toggle_panel(self: *Self, _: Ctx) Result {
|
pub fn overlay_toggle_panel(self: *Self, _: Ctx) Result {
|
||||||
return self.cmd_async("toggle_panel");
|
return self.cmd_async("toggle_panel");
|
||||||
}
|
}
|
||||||
pub const overlay_toggle_panel_meta = .{};
|
pub const overlay_toggle_panel_meta: Meta = .{};
|
||||||
|
|
||||||
pub fn overlay_toggle_inputview(self: *Self, _: Ctx) Result {
|
pub fn overlay_toggle_inputview(self: *Self, _: Ctx) Result {
|
||||||
return self.cmd_async("toggle_inputview");
|
return self.cmd_async("toggle_inputview");
|
||||||
}
|
}
|
||||||
pub const overlay_toggle_inputview_meta = .{};
|
pub const overlay_toggle_inputview_meta: Meta = .{};
|
||||||
|
|
||||||
pub fn mini_mode_paste(self: *Self, ctx: Ctx) Result {
|
pub fn mini_mode_paste(self: *Self, ctx: Ctx) Result {
|
||||||
return overlay_insert_bytes(self, ctx);
|
return overlay_insert_bytes(self, ctx);
|
||||||
}
|
}
|
||||||
pub const mini_mode_paste_meta = .{ .arguments = &.{.string} };
|
pub const mini_mode_paste_meta: Meta = .{ .arguments = &.{.string} };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,33 +17,34 @@ const Commands = command.Collection(cmds_);
|
||||||
const cmds_ = struct {
|
const cmds_ = struct {
|
||||||
pub const Target = void;
|
pub const Target = void;
|
||||||
const Ctx = command.Context;
|
const Ctx = command.Context;
|
||||||
|
const Meta = command.Metadata;
|
||||||
const Result = command.Result;
|
const Result = command.Result;
|
||||||
|
|
||||||
pub fn w(_: *void, _: Ctx) Result {
|
pub fn w(_: *void, _: Ctx) Result {
|
||||||
try cmd("save_file", .{});
|
try cmd("save_file", .{});
|
||||||
}
|
}
|
||||||
pub const w_meta = .{ .description = "w (write file)" };
|
pub const w_meta: Meta = .{ .description = "w (write file)" };
|
||||||
|
|
||||||
pub fn q(_: *void, _: Ctx) Result {
|
pub fn q(_: *void, _: Ctx) Result {
|
||||||
try cmd("quit", .{});
|
try cmd("quit", .{});
|
||||||
}
|
}
|
||||||
pub const q_meta = .{ .description = "q (quit)" };
|
pub const q_meta: Meta = .{ .description = "q (quit)" };
|
||||||
|
|
||||||
pub fn @"q!"(_: *void, _: Ctx) Result {
|
pub fn @"q!"(_: *void, _: Ctx) Result {
|
||||||
try cmd("quit_without_saving", .{});
|
try cmd("quit_without_saving", .{});
|
||||||
}
|
}
|
||||||
pub const @"q!_meta" = .{ .description = "q! (quit without saving)" };
|
pub const @"q!_meta": Meta = .{ .description = "q! (quit without saving)" };
|
||||||
|
|
||||||
pub fn wq(_: *void, _: Ctx) Result {
|
pub fn wq(_: *void, _: Ctx) Result {
|
||||||
try cmd("save_file", command.fmt(.{ "then", .{ "quit", .{} } }));
|
try cmd("save_file", command.fmt(.{ "then", .{ "quit", .{} } }));
|
||||||
}
|
}
|
||||||
pub const wq_meta = .{ .description = "wq (write file and quit)" };
|
pub const wq_meta: Meta = .{ .description = "wq (write file and quit)" };
|
||||||
|
|
||||||
pub fn @"wq!"(_: *void, _: Ctx) Result {
|
pub fn @"wq!"(_: *void, _: Ctx) Result {
|
||||||
cmd("save_file", .{}) catch {};
|
cmd("save_file", .{}) catch {};
|
||||||
try cmd("quit_without_saving", .{});
|
try cmd("quit_without_saving", .{});
|
||||||
}
|
}
|
||||||
pub const @"wq!_meta" = .{ .description = "wq! (write file and quit without saving)" };
|
pub const @"wq!_meta": Meta = .{ .description = "wq! (write file and quit without saving)" };
|
||||||
|
|
||||||
pub fn enter_mode_at_next_char(self: *void, ctx: Ctx) Result {
|
pub fn enter_mode_at_next_char(self: *void, ctx: Ctx) Result {
|
||||||
_ = self; // autofix
|
_ = self; // autofix
|
||||||
|
@ -52,7 +53,7 @@ const cmds_ = struct {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const enter_mode_at_next_char_meta = .{ .description = "Move forward one char and change mode" };
|
pub const enter_mode_at_next_char_meta: Meta = .{ .description = "Move forward one char and change mode" };
|
||||||
|
|
||||||
pub fn enter_mode_on_newline_down(self: *void, ctx: Ctx) Result {
|
pub fn enter_mode_on_newline_down(self: *void, ctx: Ctx) Result {
|
||||||
_ = self; // autofix
|
_ = self; // autofix
|
||||||
|
@ -61,7 +62,7 @@ const cmds_ = struct {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const enter_mode_on_newline_down_meta = .{ .description = "Insert a newline and change mode" };
|
pub const enter_mode_on_newline_down_meta: Meta = .{ .description = "Insert a newline and change mode" };
|
||||||
|
|
||||||
pub fn enter_mode_on_newline_up(self: *void, ctx: Ctx) Result {
|
pub fn enter_mode_on_newline_up(self: *void, ctx: Ctx) Result {
|
||||||
_ = self; // autofix
|
_ = self; // autofix
|
||||||
|
@ -69,7 +70,7 @@ const cmds_ = struct {
|
||||||
//TODO
|
//TODO
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
pub const enter_mode_on_newline_up_meta = .{ .description = "Insert a newline above the current line and change mode" };
|
pub const enter_mode_on_newline_up_meta: Meta = .{ .description = "Insert a newline above the current line and change mode" };
|
||||||
|
|
||||||
pub fn enter_mode_at_line_begin(self: *void, ctx: Ctx) Result {
|
pub fn enter_mode_at_line_begin(self: *void, ctx: Ctx) Result {
|
||||||
_ = self; // autofix
|
_ = self; // autofix
|
||||||
|
@ -78,7 +79,7 @@ const cmds_ = struct {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const enter_mode_at_line_begin_meta = .{ .description = "Goto line begin and change mode" };
|
pub const enter_mode_at_line_begin_meta: Meta = .{ .description = "Goto line begin and change mode" };
|
||||||
|
|
||||||
pub fn enter_mode_at_line_end(self: *void, ctx: Ctx) Result {
|
pub fn enter_mode_at_line_end(self: *void, ctx: Ctx) Result {
|
||||||
_ = self; // autofix
|
_ = self; // autofix
|
||||||
|
@ -86,7 +87,7 @@ const cmds_ = struct {
|
||||||
//TODO
|
//TODO
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
pub const enter_mode_at_line_end_meta = .{ .description = "Goto line end and change mode" };
|
pub const enter_mode_at_line_end_meta: Meta = .{ .description = "Goto line end and change mode" };
|
||||||
|
|
||||||
pub fn copy_line(self: *void, ctx: Ctx) Result {
|
pub fn copy_line(self: *void, ctx: Ctx) Result {
|
||||||
_ = self; // autofix
|
_ = self; // autofix
|
||||||
|
@ -95,7 +96,7 @@ const cmds_ = struct {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const copy_line_meta = .{ .description = "Copies the current line" };
|
pub const copy_line_meta: Meta = .{ .description = "Copies the current line" };
|
||||||
|
|
||||||
pub fn delete_line(self: *void, ctx: Ctx) Result {
|
pub fn delete_line(self: *void, ctx: Ctx) Result {
|
||||||
_ = self; // autofix
|
_ = self; // autofix
|
||||||
|
@ -110,5 +111,5 @@ const cmds_ = struct {
|
||||||
//try self.update_buf(root);
|
//try self.update_buf(root);
|
||||||
//self.clamp();
|
//self.clamp();
|
||||||
}
|
}
|
||||||
pub const delete_line_meta = .{ .description = "Delete the current line without copying" };
|
pub const delete_line_meta: Meta = .{ .description = "Delete the current line without copying" };
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,7 +6,7 @@ const EventHandler = @import("EventHandler");
|
||||||
const Widget = @import("../Widget.zig");
|
const Widget = @import("../Widget.zig");
|
||||||
|
|
||||||
plane: Plane,
|
plane: Plane,
|
||||||
layout: Widget.Layout,
|
layout_: Widget.Layout,
|
||||||
on_event: ?EventHandler,
|
on_event: ?EventHandler,
|
||||||
|
|
||||||
const Self = @This();
|
const Self = @This();
|
||||||
|
@ -17,7 +17,7 @@ pub fn Create(comptime layout_: Widget.Layout) @import("widget.zig").CreateFunct
|
||||||
const self: *Self = try allocator.create(Self);
|
const self: *Self = try allocator.create(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_,
|
||||||
.on_event = event_handler,
|
.on_event = event_handler,
|
||||||
};
|
};
|
||||||
return Widget.to(self);
|
return Widget.to(self);
|
||||||
|
@ -31,7 +31,7 @@ pub fn deinit(self: *Self, allocator: std.mem.Allocator) void {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn layout(self: *Self) Widget.Layout {
|
pub fn layout(self: *Self) Widget.Layout {
|
||||||
return self.layout;
|
return self.layout_;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn render(self: *Self, theme: *const Widget.Theme) bool {
|
pub fn render(self: *Self, theme: *const Widget.Theme) bool {
|
||||||
|
|
|
@ -7,6 +7,7 @@ const root = @import("root");
|
||||||
|
|
||||||
const Plane = @import("renderer").Plane;
|
const Plane = @import("renderer").Plane;
|
||||||
const style = @import("renderer").style;
|
const style = @import("renderer").style;
|
||||||
|
const styles = @import("renderer").styles;
|
||||||
const command = @import("command");
|
const command = @import("command");
|
||||||
const EventHandler = @import("EventHandler");
|
const EventHandler = @import("EventHandler");
|
||||||
|
|
||||||
|
@ -101,7 +102,7 @@ pub fn render(self: *Self, btn: *Button.State(Self), theme: *const Widget.Theme)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_mini_mode(plane: *Plane, theme: *const Widget.Theme) void {
|
fn render_mini_mode(plane: *Plane, theme: *const Widget.Theme) void {
|
||||||
plane.off_styles(style.italic);
|
plane.off_styles(styles.italic);
|
||||||
const mini_mode = tui.mini_mode() orelse return;
|
const mini_mode = tui.mini_mode() orelse return;
|
||||||
_ = plane.print(" {s}", .{mini_mode.text}) catch {};
|
_ = plane.print(" {s}", .{mini_mode.text}) catch {};
|
||||||
if (mini_mode.cursor) |cursor| {
|
if (mini_mode.cursor) |cursor| {
|
||||||
|
@ -129,7 +130,7 @@ fn render_mini_mode(plane: *Plane, theme: *const Widget.Theme) void {
|
||||||
// Content save cog
|
// Content save cog
|
||||||
// Content save all
|
// Content save all
|
||||||
fn render_normal(self: *Self, plane: *Plane, theme: *const Widget.Theme) void {
|
fn render_normal(self: *Self, plane: *Plane, theme: *const Widget.Theme) void {
|
||||||
plane.on_styles(style.italic);
|
plane.on_styles(styles.italic);
|
||||||
_ = plane.putstr(" ") catch {};
|
_ = plane.putstr(" ") catch {};
|
||||||
if (self.file_icon.len > 0) {
|
if (self.file_icon.len > 0) {
|
||||||
self.render_file_icon(plane, theme);
|
self.render_file_icon(plane, theme);
|
||||||
|
@ -141,7 +142,7 @@ fn render_normal(self: *Self, plane: *Plane, theme: *const Widget.Theme) void {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_detailed(self: *Self, plane: *Plane, theme: *const Widget.Theme) void {
|
fn render_detailed(self: *Self, plane: *Plane, theme: *const Widget.Theme) void {
|
||||||
plane.on_styles(style.italic);
|
plane.on_styles(styles.italic);
|
||||||
_ = plane.putstr(" ") catch {};
|
_ = plane.putstr(" ") catch {};
|
||||||
if (self.file_icon.len > 0) {
|
if (self.file_icon.len > 0) {
|
||||||
self.render_file_icon(plane, theme);
|
self.render_file_icon(plane, theme);
|
||||||
|
|
|
@ -3,6 +3,7 @@ const Allocator = std.mem.Allocator;
|
||||||
|
|
||||||
const Plane = @import("renderer").Plane;
|
const Plane = @import("renderer").Plane;
|
||||||
const style = @import("renderer").style;
|
const style = @import("renderer").style;
|
||||||
|
const styles = @import("renderer").styles;
|
||||||
const command = @import("command");
|
const command = @import("command");
|
||||||
const EventHandler = @import("EventHandler");
|
const EventHandler = @import("EventHandler");
|
||||||
|
|
||||||
|
@ -52,7 +53,7 @@ pub fn render(_: *void, self: *Button.State(void), theme: *const Widget.Theme) b
|
||||||
self.plane.set_style(style_label);
|
self.plane.set_style(style_label);
|
||||||
self.plane.fill(" ");
|
self.plane.fill(" ");
|
||||||
self.plane.home();
|
self.plane.home();
|
||||||
self.plane.on_styles(style.bold);
|
self.plane.on_styles(styles.bold);
|
||||||
var buf: [31:0]u8 = undefined;
|
var buf: [31:0]u8 = undefined;
|
||||||
if (!is_mini_mode() and !is_overlay_mode()) {
|
if (!is_mini_mode() and !is_overlay_mode()) {
|
||||||
render_logo(self, theme, style_label);
|
render_logo(self, theme, style_label);
|
||||||
|
@ -60,7 +61,7 @@ pub fn render(_: *void, self: *Button.State(void), theme: *const Widget.Theme) b
|
||||||
_ = self.plane.putstr(" ") catch {};
|
_ = self.plane.putstr(" ") catch {};
|
||||||
}
|
}
|
||||||
self.plane.set_style(style_label);
|
self.plane.set_style(style_label);
|
||||||
self.plane.on_styles(style.bold);
|
self.plane.on_styles(styles.bold);
|
||||||
_ = self.plane.putstr(std.fmt.bufPrintZ(&buf, "{s} ", .{tui.get_mode()}) catch return false) catch {};
|
_ = self.plane.putstr(std.fmt.bufPrintZ(&buf, "{s} ", .{tui.get_mode()}) catch return false) catch {};
|
||||||
if (is_mini_mode())
|
if (is_mini_mode())
|
||||||
render_separator(self, theme);
|
render_separator(self, theme);
|
||||||
|
|
|
@ -425,7 +425,7 @@ const Tab = struct {
|
||||||
|
|
||||||
const spacer = struct {
|
const spacer = struct {
|
||||||
plane: Plane,
|
plane: Plane,
|
||||||
layout: Widget.Layout,
|
layout_: Widget.Layout,
|
||||||
on_event: ?EventHandler,
|
on_event: ?EventHandler,
|
||||||
content: []const u8,
|
content: []const u8,
|
||||||
fg: colors,
|
fg: colors,
|
||||||
|
@ -444,7 +444,7 @@ const spacer = struct {
|
||||||
const self: *Self = try allocator.create(Self);
|
const self: *Self = try allocator.create(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) },
|
||||||
.on_event = event_handler,
|
.on_event = event_handler,
|
||||||
.content = content,
|
.content = content,
|
||||||
.fg = fg,
|
.fg = fg,
|
||||||
|
@ -459,7 +459,7 @@ const spacer = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn layout(self: *Self) Widget.Layout {
|
pub fn layout(self: *Self) Widget.Layout {
|
||||||
return self.layout;
|
return self.layout_;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn render(self: *Self, theme: *const Widget.Theme) bool {
|
pub fn render(self: *Self, theme: *const Widget.Theme) bool {
|
||||||
|
|
340
src/tui/tui.zig
340
src/tui/tui.zig
|
@ -20,29 +20,29 @@ const MainView = @import("mainview.zig");
|
||||||
const Allocator = std.mem.Allocator;
|
const Allocator = std.mem.Allocator;
|
||||||
|
|
||||||
allocator: Allocator,
|
allocator: Allocator,
|
||||||
rdr: renderer,
|
rdr_: renderer,
|
||||||
config: @import("config"),
|
config_: @import("config"),
|
||||||
frame_time: usize, // in microseconds
|
frame_time: usize, // in microseconds
|
||||||
frame_clock: tp.metronome,
|
frame_clock: tp.metronome,
|
||||||
frame_clock_running: bool = false,
|
frame_clock_running: bool = false,
|
||||||
frame_last_time: i64 = 0,
|
frame_last_time: i64 = 0,
|
||||||
receiver: Receiver,
|
receiver: Receiver,
|
||||||
mainview: ?Widget = null,
|
mainview_: ?Widget = null,
|
||||||
message_filters: MessageFilter.List,
|
message_filters_: MessageFilter.List,
|
||||||
input_mode: ?Mode = null,
|
input_mode_: ?Mode = null,
|
||||||
delayed_init_done: bool = false,
|
delayed_init_done: bool = false,
|
||||||
delayed_init_input_mode: ?Mode = null,
|
delayed_init_input_mode: ?Mode = null,
|
||||||
input_mode_outer: ?Mode = null,
|
input_mode_outer_: ?Mode = null,
|
||||||
input_listeners: EventHandler.List,
|
input_listeners_: EventHandler.List,
|
||||||
keyboard_focus: ?Widget = null,
|
keyboard_focus: ?Widget = null,
|
||||||
mini_mode: ?MiniMode = null,
|
mini_mode_: ?MiniMode = null,
|
||||||
hover_focus: ?*Widget = null,
|
hover_focus: ?*Widget = null,
|
||||||
last_hover_x: c_int = -1,
|
last_hover_x: c_int = -1,
|
||||||
last_hover_y: c_int = -1,
|
last_hover_y: c_int = -1,
|
||||||
commands: Commands = undefined,
|
commands: Commands = undefined,
|
||||||
logger: log.Logger,
|
logger: log.Logger,
|
||||||
drag_source: ?*Widget = null,
|
drag_source: ?*Widget = null,
|
||||||
theme: Widget.Theme,
|
theme_: Widget.Theme,
|
||||||
idle_frame_count: usize = 0,
|
idle_frame_count: usize = 0,
|
||||||
unrendered_input_events_count: usize = 0,
|
unrendered_input_events_count: usize = 0,
|
||||||
init_timer: ?tp.timeout,
|
init_timer: ?tp.timeout,
|
||||||
|
@ -53,8 +53,8 @@ render_pending: bool = false,
|
||||||
keepalive_timer: ?tp.Cancellable = null,
|
keepalive_timer: ?tp.Cancellable = null,
|
||||||
mouse_idle_timer: ?tp.Cancellable = null,
|
mouse_idle_timer: ?tp.Cancellable = null,
|
||||||
default_cursor: keybind.CursorShape = .default,
|
default_cursor: keybind.CursorShape = .default,
|
||||||
fontface: []const u8 = "",
|
fontface_: []const u8 = "",
|
||||||
fontfaces: std.ArrayListUnmanaged([]const u8) = .{},
|
fontfaces_: std.ArrayListUnmanaged([]const u8) = .{},
|
||||||
enable_mouse_idle_timer: bool = false,
|
enable_mouse_idle_timer: bool = false,
|
||||||
|
|
||||||
const keepalive = std.time.us_per_day * 365; // one year
|
const keepalive = std.time.us_per_day * 365; // one year
|
||||||
|
@ -106,32 +106,32 @@ fn init(allocator: Allocator) !*Self {
|
||||||
var self = try allocator.create(Self);
|
var self = try allocator.create(Self);
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.config = conf,
|
.config_ = conf,
|
||||||
.rdr = try renderer.init(allocator, self, tp.env.get().is("no-alternate"), dispatch_initialized),
|
.rdr_ = try renderer.init(allocator, self, tp.env.get().is("no-alternate"), dispatch_initialized),
|
||||||
.frame_time = frame_time,
|
.frame_time = frame_time,
|
||||||
.frame_clock = frame_clock,
|
.frame_clock = frame_clock,
|
||||||
.frame_clock_running = true,
|
.frame_clock_running = true,
|
||||||
.receiver = Receiver.init(receive, self),
|
.receiver = Receiver.init(receive, self),
|
||||||
.message_filters = MessageFilter.List.init(allocator),
|
.message_filters_ = MessageFilter.List.init(allocator),
|
||||||
.input_listeners = EventHandler.List.init(allocator),
|
.input_listeners_ = EventHandler.List.init(allocator),
|
||||||
.logger = log.logger("tui"),
|
.logger = log.logger("tui"),
|
||||||
.init_timer = if (build_options.gui) null else try tp.timeout.init_ms(init_delay, tp.message.fmt(
|
.init_timer = if (build_options.gui) null else try tp.timeout.init_ms(init_delay, tp.message.fmt(
|
||||||
.{"init"},
|
.{"init"},
|
||||||
)),
|
)),
|
||||||
.theme = theme_,
|
.theme_ = theme_,
|
||||||
.no_sleep = tp.env.get().is("no-sleep"),
|
.no_sleep = tp.env.get().is("no-sleep"),
|
||||||
};
|
};
|
||||||
instance_ = self;
|
instance_ = self;
|
||||||
defer instance_ = null;
|
defer instance_ = null;
|
||||||
|
|
||||||
self.default_cursor = std.meta.stringToEnum(keybind.CursorShape, conf.default_cursor) orelse .default;
|
self.default_cursor = std.meta.stringToEnum(keybind.CursorShape, conf.default_cursor) orelse .default;
|
||||||
self.config.default_cursor = @tagName(self.default_cursor);
|
self.config_.default_cursor = @tagName(self.default_cursor);
|
||||||
self.rdr.handler_ctx = self;
|
self.rdr_.handler_ctx = self;
|
||||||
self.rdr.dispatch_input = dispatch_input;
|
self.rdr_.dispatch_input = dispatch_input;
|
||||||
self.rdr.dispatch_mouse = dispatch_mouse;
|
self.rdr_.dispatch_mouse = dispatch_mouse;
|
||||||
self.rdr.dispatch_mouse_drag = dispatch_mouse_drag;
|
self.rdr_.dispatch_mouse_drag = dispatch_mouse_drag;
|
||||||
self.rdr.dispatch_event = dispatch_event;
|
self.rdr_.dispatch_event = dispatch_event;
|
||||||
try self.rdr.run();
|
try self.rdr_.run();
|
||||||
|
|
||||||
try frame_clock.start();
|
try frame_clock.start();
|
||||||
try self.commands.init(self);
|
try self.commands.init(self);
|
||||||
|
@ -144,10 +144,10 @@ fn init(allocator: Allocator) !*Self {
|
||||||
try self.listen_sigwinch();
|
try self.listen_sigwinch();
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
self.mainview = try MainView.create(allocator);
|
self.mainview_ = try MainView.create(allocator);
|
||||||
resize();
|
resize();
|
||||||
self.set_terminal_style();
|
self.set_terminal_style();
|
||||||
try self.rdr.render();
|
try self.rdr_.render();
|
||||||
try save_config();
|
try save_config();
|
||||||
try self.init_input_namespace();
|
try self.init_input_namespace();
|
||||||
if (tp.env.get().is("restore-session")) {
|
if (tp.env.get().is("restore-session")) {
|
||||||
|
@ -159,19 +159,19 @@ fn init(allocator: Allocator) !*Self {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init_input_namespace(self: *Self) !void {
|
fn init_input_namespace(self: *Self) !void {
|
||||||
var mode_parts = std.mem.splitScalar(u8, self.config.input_mode, '/');
|
var mode_parts = std.mem.splitScalar(u8, self.config_.input_mode, '/');
|
||||||
const namespace_name = mode_parts.first();
|
const namespace_name = mode_parts.first();
|
||||||
keybind.set_namespace(namespace_name) catch {
|
keybind.set_namespace(namespace_name) catch {
|
||||||
self.logger.print_err("keybind", "unknown mode {s}", .{namespace_name});
|
self.logger.print_err("keybind", "unknown mode {s}", .{namespace_name});
|
||||||
try keybind.set_namespace("flow");
|
try keybind.set_namespace("flow");
|
||||||
self.config.input_mode = "flow";
|
self.config_.input_mode = "flow";
|
||||||
try save_config();
|
try save_config();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init_delayed(self: *Self) !void {
|
fn init_delayed(self: *Self) !void {
|
||||||
self.delayed_init_done = true;
|
self.delayed_init_done = true;
|
||||||
if (self.input_mode) |_| {} else {
|
if (self.input_mode_) |_| {} else {
|
||||||
if (self.delayed_init_input_mode) |delayed_init_input_mode| {
|
if (self.delayed_init_input_mode) |delayed_init_input_mode| {
|
||||||
try enter_input_mode(self, delayed_init_input_mode);
|
try enter_input_mode(self, delayed_init_input_mode);
|
||||||
self.delayed_init_input_mode = null;
|
self.delayed_init_input_mode = null;
|
||||||
|
@ -192,24 +192,24 @@ fn deinit(self: *Self) void {
|
||||||
t.deinit();
|
t.deinit();
|
||||||
self.keepalive_timer = null;
|
self.keepalive_timer = null;
|
||||||
}
|
}
|
||||||
if (self.input_mode) |*m| {
|
if (self.input_mode_) |*m| {
|
||||||
m.deinit();
|
m.deinit();
|
||||||
self.input_mode = null;
|
self.input_mode_ = null;
|
||||||
}
|
}
|
||||||
if (self.delayed_init_input_mode) |*m| {
|
if (self.delayed_init_input_mode) |*m| {
|
||||||
m.deinit();
|
m.deinit();
|
||||||
self.delayed_init_input_mode = null;
|
self.delayed_init_input_mode = null;
|
||||||
}
|
}
|
||||||
self.commands.deinit();
|
self.commands.deinit();
|
||||||
if (self.mainview) |*mv| mv.deinit(self.allocator);
|
if (self.mainview_) |*mv| mv.deinit(self.allocator);
|
||||||
self.message_filters.deinit();
|
self.message_filters_.deinit();
|
||||||
self.input_listeners.deinit();
|
self.input_listeners_.deinit();
|
||||||
if (self.frame_clock_running)
|
if (self.frame_clock_running)
|
||||||
self.frame_clock.stop() catch {};
|
self.frame_clock.stop() catch {};
|
||||||
if (self.sigwinch_signal) |sig| sig.deinit();
|
if (self.sigwinch_signal) |sig| sig.deinit();
|
||||||
self.frame_clock.deinit();
|
self.frame_clock.deinit();
|
||||||
self.rdr.stop();
|
self.rdr_.stop();
|
||||||
self.rdr.deinit();
|
self.rdr_.deinit();
|
||||||
self.logger.deinit();
|
self.logger.deinit();
|
||||||
self.allocator.destroy(self);
|
self.allocator.destroy(self);
|
||||||
}
|
}
|
||||||
|
@ -253,7 +253,7 @@ fn receive(self: *Self, from: tp.pid_ref, m: tp.message) tp.result {
|
||||||
|
|
||||||
fn receive_safe(self: *Self, from: tp.pid_ref, m: tp.message) !void {
|
fn receive_safe(self: *Self, from: tp.pid_ref, m: tp.message) !void {
|
||||||
if (try m.match(.{ "RDR", tp.more })) {
|
if (try m.match(.{ "RDR", tp.more })) {
|
||||||
self.rdr.process_renderer_event(m.buf) catch |e| switch (e) {
|
self.rdr_.process_renderer_event(m.buf) catch |e| switch (e) {
|
||||||
error.UnexpectedRendererEvent => return tp.unexpected(m),
|
error.UnexpectedRendererEvent => return tp.unexpected(m),
|
||||||
else => return e,
|
else => return e,
|
||||||
};
|
};
|
||||||
|
@ -263,7 +263,7 @@ fn receive_safe(self: *Self, from: tp.pid_ref, m: tp.message) !void {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.message_filters.filter(from, m) catch |e| return self.logger.err("filter", e))
|
if (self.message_filters_.filter(from, m) catch |e| return self.logger.err("filter", e))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var cmd: []const u8 = undefined;
|
var cmd: []const u8 = undefined;
|
||||||
|
@ -302,7 +302,7 @@ fn receive_safe(self: *Self, from: tp.pid_ref, m: tp.message) !void {
|
||||||
if (builtin.os.tag != .windows)
|
if (builtin.os.tag != .windows)
|
||||||
if (try m.match(.{"sigwinch"})) {
|
if (try m.match(.{"sigwinch"})) {
|
||||||
try self.listen_sigwinch();
|
try self.listen_sigwinch();
|
||||||
self.rdr.sigwinch() catch |e| return self.logger.err("query_resize", e);
|
self.rdr_.sigwinch() catch |e| return self.logger.err("query_resize", e);
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -390,14 +390,14 @@ fn receive_safe(self: *Self, from: tp.pid_ref, m: tp.message) !void {
|
||||||
|
|
||||||
var fontface_: []const u8 = undefined;
|
var fontface_: []const u8 = undefined;
|
||||||
if (try m.match(.{ "fontface", "current", tp.extract(&fontface_) })) {
|
if (try m.match(.{ "fontface", "current", tp.extract(&fontface_) })) {
|
||||||
if (self.fontface.len > 0) self.allocator.free(self.fontface);
|
if (self.fontface_.len > 0) self.allocator.free(self.fontface_);
|
||||||
self.fontface = "";
|
self.fontface_ = "";
|
||||||
self.fontface = try self.allocator.dupe(u8, fontface_);
|
self.fontface_ = try self.allocator.dupe(u8, fontface_);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (try m.match(.{ "fontface", tp.extract(&fontface_) })) {
|
if (try m.match(.{ "fontface", tp.extract(&fontface_) })) {
|
||||||
try self.fontfaces.append(self.allocator, try self.allocator.dupe(u8, fontface_));
|
try self.fontfaces_.append(self.allocator, try self.allocator.dupe(u8, fontface_));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -420,20 +420,20 @@ fn render(self: *Self) void {
|
||||||
{
|
{
|
||||||
const frame = tracy.initZone(@src(), .{ .name = "tui update" });
|
const frame = tracy.initZone(@src(), .{ .name = "tui update" });
|
||||||
defer frame.deinit();
|
defer frame.deinit();
|
||||||
if (self.mainview) |mv| mv.update();
|
if (self.mainview_) |mv| mv.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
const more = ret: {
|
const more = ret: {
|
||||||
const frame = tracy.initZone(@src(), .{ .name = "tui render" });
|
const frame = tracy.initZone(@src(), .{ .name = "tui render" });
|
||||||
defer frame.deinit();
|
defer frame.deinit();
|
||||||
self.rdr.stdplane().erase();
|
self.rdr_.stdplane().erase();
|
||||||
break :ret if (self.mainview) |mv| mv.render(&self.theme) else false;
|
break :ret if (self.mainview_) |mv| mv.render(&self.theme_) else false;
|
||||||
};
|
};
|
||||||
|
|
||||||
{
|
{
|
||||||
const frame = tracy.initZone(@src(), .{ .name = renderer.log_name ++ " render" });
|
const frame = tracy.initZone(@src(), .{ .name = renderer.log_name ++ " render" });
|
||||||
defer frame.deinit();
|
defer frame.deinit();
|
||||||
self.rdr.render() catch |e| self.logger.err("render", e);
|
self.rdr_.render() catch |e| self.logger.err("render", e);
|
||||||
tracy.frameMark();
|
tracy.frameMark();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -457,13 +457,13 @@ fn render(self: *Self) void {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn active_event_handler(self: *Self) ?EventHandler {
|
fn active_event_handler(self: *Self) ?EventHandler {
|
||||||
const mode = self.input_mode orelse return null;
|
const mode = self.input_mode_ orelse return null;
|
||||||
return mode.event_handler orelse mode.input_handler;
|
return mode.event_handler orelse mode.input_handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dispatch_flush_input_event(self: *Self) !void {
|
fn dispatch_flush_input_event(self: *Self) !void {
|
||||||
var buf: [32]u8 = undefined;
|
var buf: [32]u8 = undefined;
|
||||||
const mode = self.input_mode orelse return;
|
const mode = self.input_mode_ orelse return;
|
||||||
try mode.input_handler.send(tp.self_pid(), try tp.message.fmtbuf(&buf, .{"F"}));
|
try mode.input_handler.send(tp.self_pid(), try tp.message.fmtbuf(&buf, .{"F"}));
|
||||||
if (mode.event_handler) |eh| try eh.send(tp.self_pid(), try tp.message.fmtbuf(&buf, .{"F"}));
|
if (mode.event_handler) |eh| try eh.send(tp.self_pid(), try tp.message.fmtbuf(&buf, .{"F"}));
|
||||||
}
|
}
|
||||||
|
@ -480,14 +480,14 @@ fn dispatch_input(ctx: *anyopaque, cbor_msg: []const u8) void {
|
||||||
const m: tp.message = .{ .buf = cbor_msg };
|
const m: tp.message = .{ .buf = cbor_msg };
|
||||||
const from = tp.self_pid();
|
const from = tp.self_pid();
|
||||||
self.unrendered_input_events_count += 1;
|
self.unrendered_input_events_count += 1;
|
||||||
self.input_listeners.send(from, m) catch {};
|
self.input_listeners_.send(from, m) catch {};
|
||||||
if (self.keyboard_focus) |w|
|
if (self.keyboard_focus) |w|
|
||||||
if (w.send(from, m) catch |e| ret: {
|
if (w.send(from, m) catch |e| ret: {
|
||||||
self.logger.err("focus", e);
|
self.logger.err("focus", e);
|
||||||
break :ret false;
|
break :ret false;
|
||||||
})
|
})
|
||||||
return;
|
return;
|
||||||
if (self.input_mode) |mode|
|
if (self.input_mode_) |mode|
|
||||||
mode.input_handler.send(from, m) catch |e| self.logger.err("input handler", e);
|
mode.input_handler.send(from, m) catch |e| self.logger.err("input handler", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -535,7 +535,7 @@ fn find_coord_widget(self: *Self, y: usize, x: usize) ?*Widget {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
var ctx: Ctx = .{ .y = y, .x = x };
|
var ctx: Ctx = .{ .y = y, .x = x };
|
||||||
if (self.mainview) |*mv| _ = mv.walk(&ctx, Ctx.find);
|
if (self.mainview_) |*mv| _ = mv.walk(&ctx, Ctx.find);
|
||||||
return ctx.widget;
|
return ctx.widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -552,7 +552,7 @@ fn is_live_widget_ptr(self: *Self, w_: *Widget) bool {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
var ctx: Ctx = .{ .w = w_ };
|
var ctx: Ctx = .{ .w = w_ };
|
||||||
return if (self.mainview) |*mv| mv.walk(&ctx, Ctx.find) else false;
|
return if (self.mainview_) |*mv| mv.walk(&ctx, Ctx.find) else false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_widgets(self: *Self, from: tp.pid_ref, m: tp.message) error{Exit}!bool {
|
fn send_widgets(self: *Self, from: tp.pid_ref, m: tp.message) error{Exit}!bool {
|
||||||
|
@ -561,7 +561,7 @@ fn send_widgets(self: *Self, from: tp.pid_ref, m: tp.message) error{Exit}!bool {
|
||||||
tp.trace(tp.channel.widget, m);
|
tp.trace(tp.channel.widget, m);
|
||||||
return if (self.keyboard_focus) |w|
|
return if (self.keyboard_focus) |w|
|
||||||
w.send(from, m)
|
w.send(from, m)
|
||||||
else if (self.mainview) |mv|
|
else if (self.mainview_) |mv|
|
||||||
mv.send(from, m)
|
mv.send(from, m)
|
||||||
else
|
else
|
||||||
false;
|
false;
|
||||||
|
@ -569,7 +569,7 @@ fn send_widgets(self: *Self, from: tp.pid_ref, m: tp.message) error{Exit}!bool {
|
||||||
|
|
||||||
fn send_mouse(self: *Self, y: c_int, x: c_int, from: tp.pid_ref, m: tp.message) tp.result {
|
fn send_mouse(self: *Self, y: c_int, x: c_int, from: tp.pid_ref, m: tp.message) tp.result {
|
||||||
tp.trace(tp.channel.input, m);
|
tp.trace(tp.channel.input, m);
|
||||||
_ = self.input_listeners.send(from, m) catch {};
|
_ = self.input_listeners_.send(from, m) catch {};
|
||||||
if (self.keyboard_focus) |w| {
|
if (self.keyboard_focus) |w| {
|
||||||
_ = try w.send(from, m);
|
_ = try w.send(from, m);
|
||||||
return;
|
return;
|
||||||
|
@ -580,7 +580,7 @@ fn send_mouse(self: *Self, y: c_int, x: c_int, from: tp.pid_ref, m: tp.message)
|
||||||
|
|
||||||
fn send_mouse_drag(self: *Self, y: c_int, x: c_int, from: tp.pid_ref, m: tp.message) tp.result {
|
fn send_mouse_drag(self: *Self, y: c_int, x: c_int, from: tp.pid_ref, m: tp.message) tp.result {
|
||||||
tp.trace(tp.channel.input, m);
|
tp.trace(tp.channel.input, m);
|
||||||
_ = self.input_listeners.send(from, m) catch {};
|
_ = self.input_listeners_.send(from, m) catch {};
|
||||||
if (self.keyboard_focus) |w| {
|
if (self.keyboard_focus) |w| {
|
||||||
_ = try w.send(from, m);
|
_ = try w.send(from, m);
|
||||||
return;
|
return;
|
||||||
|
@ -625,21 +625,21 @@ pub fn refresh_hover() void {
|
||||||
|
|
||||||
pub fn save_config() !void {
|
pub fn save_config() !void {
|
||||||
const self = current();
|
const self = current();
|
||||||
try root.write_config(self.config, self.allocator);
|
try root.write_config(self.config_, self.allocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_mainview_focused() bool {
|
pub fn is_mainview_focused() bool {
|
||||||
const self = current();
|
const self = current();
|
||||||
return self.mini_mode == null and self.input_mode_outer == null;
|
return self.mini_mode_ == null and self.input_mode_outer_ == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn enter_overlay_mode(self: *Self, mode: type) command.Result {
|
fn enter_overlay_mode(self: *Self, mode: type) command.Result {
|
||||||
command.executeName("disable_fast_scroll", .{}) catch {};
|
command.executeName("disable_fast_scroll", .{}) catch {};
|
||||||
command.executeName("disable_jump_mode", .{}) catch {};
|
command.executeName("disable_jump_mode", .{}) catch {};
|
||||||
if (self.mini_mode) |_| try cmds.exit_mini_mode(self, .{});
|
if (self.mini_mode_) |_| try cmds.exit_mini_mode(self, .{});
|
||||||
if (self.input_mode_outer) |_| try cmds.exit_overlay_mode(self, .{});
|
if (self.input_mode_outer_) |_| try cmds.exit_overlay_mode(self, .{});
|
||||||
self.input_mode_outer = self.input_mode;
|
self.input_mode_outer_ = self.input_mode_;
|
||||||
self.input_mode = try mode.create(self.allocator);
|
self.input_mode_ = try mode.create(self.allocator);
|
||||||
refresh_hover();
|
refresh_hover();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -648,106 +648,106 @@ fn get_input_mode(self: *Self, mode_name: []const u8) !Mode {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn enter_input_mode(self: *Self, new_mode: Mode) command.Result {
|
fn enter_input_mode(self: *Self, new_mode: Mode) command.Result {
|
||||||
if (self.mini_mode) |_| try cmds.exit_mini_mode(self, .{});
|
if (self.mini_mode_) |_| try cmds.exit_mini_mode(self, .{});
|
||||||
if (self.input_mode_outer) |_| try cmds.exit_overlay_mode(self, .{});
|
if (self.input_mode_outer_) |_| try cmds.exit_overlay_mode(self, .{});
|
||||||
if (self.input_mode) |*m| {
|
if (self.input_mode_) |*m| {
|
||||||
m.deinit();
|
m.deinit();
|
||||||
self.input_mode = null;
|
self.input_mode_ = null;
|
||||||
}
|
}
|
||||||
self.input_mode = new_mode;
|
self.input_mode_ = new_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn refresh_input_mode(self: *Self) command.Result {
|
fn refresh_input_mode(self: *Self) command.Result {
|
||||||
const mode = (self.input_mode orelse return).mode;
|
const mode = (self.input_mode_ orelse return).mode;
|
||||||
var new_mode = self.get_input_mode(mode) catch ret: {
|
var new_mode = self.get_input_mode(mode) catch ret: {
|
||||||
self.logger.print("unknown mode {s}", .{mode});
|
self.logger.print("unknown mode {s}", .{mode});
|
||||||
break :ret try self.get_input_mode(keybind.default_mode);
|
break :ret try self.get_input_mode(keybind.default_mode);
|
||||||
};
|
};
|
||||||
errdefer new_mode.deinit();
|
errdefer new_mode.deinit();
|
||||||
if (self.input_mode) |*m| {
|
if (self.input_mode_) |*m| {
|
||||||
m.deinit();
|
m.deinit();
|
||||||
self.input_mode = null;
|
self.input_mode_ = null;
|
||||||
}
|
}
|
||||||
self.input_mode = new_mode;
|
self.input_mode_ = new_mode;
|
||||||
}
|
}
|
||||||
pub const enter_mode_meta = .{ .arguments = &.{.string} };
|
|
||||||
|
|
||||||
const cmds = struct {
|
const cmds = struct {
|
||||||
pub const Target = Self;
|
pub const Target = Self;
|
||||||
const Ctx = command.Context;
|
const Ctx = command.Context;
|
||||||
|
const Meta = command.Metadata;
|
||||||
const Result = command.Result;
|
const Result = command.Result;
|
||||||
|
|
||||||
pub fn restart(_: *Self, _: Ctx) Result {
|
pub fn restart(_: *Self, _: Ctx) Result {
|
||||||
try tp.self_pid().send("restart");
|
try tp.self_pid().send("restart");
|
||||||
}
|
}
|
||||||
pub const restart_meta = .{ .description = "Restart flow (without saving)" };
|
pub const restart_meta: Meta = .{ .description = "Restart flow (without saving)" };
|
||||||
|
|
||||||
pub fn force_terminate(self: *Self, _: Ctx) Result {
|
pub fn force_terminate(self: *Self, _: Ctx) Result {
|
||||||
self.deinit();
|
self.deinit();
|
||||||
root.print_exit_status({}, "FORCE TERMINATE");
|
root.print_exit_status({}, "FORCE TERMINATE");
|
||||||
root.exit(99);
|
root.exit(99);
|
||||||
}
|
}
|
||||||
pub const force_terminate_meta = .{ .description = "Force quit without saving" };
|
pub const force_terminate_meta: Meta = .{ .description = "Force quit without saving" };
|
||||||
|
|
||||||
pub fn set_theme(self: *Self, ctx: Ctx) Result {
|
pub fn set_theme(self: *Self, ctx: Ctx) Result {
|
||||||
var name: []const u8 = undefined;
|
var name: []const u8 = undefined;
|
||||||
if (!try ctx.args.match(.{tp.extract(&name)}))
|
if (!try ctx.args.match(.{tp.extract(&name)}))
|
||||||
return tp.exit_error(error.InvalidSetThemeArgument, null);
|
return tp.exit_error(error.InvalidSetThemeArgument, null);
|
||||||
self.theme = get_theme_by_name(name) orelse {
|
self.theme_ = get_theme_by_name(name) orelse {
|
||||||
self.logger.print("theme not found: {s}", .{name});
|
self.logger.print("theme not found: {s}", .{name});
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
self.config.theme = self.theme.name;
|
self.config_.theme = self.theme_.name;
|
||||||
self.set_terminal_style();
|
self.set_terminal_style();
|
||||||
self.logger.print("theme: {s}", .{self.theme.description});
|
self.logger.print("theme: {s}", .{self.theme_.description});
|
||||||
try save_config();
|
try save_config();
|
||||||
}
|
}
|
||||||
pub const set_theme_meta = .{ .arguments = &.{.string} };
|
pub const set_theme_meta: Meta = .{ .arguments = &.{.string} };
|
||||||
|
|
||||||
pub fn theme_next(self: *Self, _: Ctx) Result {
|
pub fn theme_next(self: *Self, _: Ctx) Result {
|
||||||
self.theme = get_next_theme_by_name(self.theme.name);
|
self.theme_ = get_next_theme_by_name(self.theme_.name);
|
||||||
self.config.theme = self.theme.name;
|
self.config_.theme = self.theme_.name;
|
||||||
self.set_terminal_style();
|
self.set_terminal_style();
|
||||||
self.logger.print("theme: {s}", .{self.theme.description});
|
self.logger.print("theme: {s}", .{self.theme_.description});
|
||||||
try save_config();
|
try save_config();
|
||||||
}
|
}
|
||||||
pub const theme_next_meta = .{ .description = "Switch to next color theme" };
|
pub const theme_next_meta: Meta = .{ .description = "Switch to next color theme" };
|
||||||
|
|
||||||
pub fn theme_prev(self: *Self, _: Ctx) Result {
|
pub fn theme_prev(self: *Self, _: Ctx) Result {
|
||||||
self.theme = get_prev_theme_by_name(self.theme.name);
|
self.theme_ = get_prev_theme_by_name(self.theme_.name);
|
||||||
self.config.theme = self.theme.name;
|
self.config_.theme = self.theme_.name;
|
||||||
self.set_terminal_style();
|
self.set_terminal_style();
|
||||||
self.logger.print("theme: {s}", .{self.theme.description});
|
self.logger.print("theme: {s}", .{self.theme_.description});
|
||||||
try save_config();
|
try save_config();
|
||||||
}
|
}
|
||||||
pub const theme_prev_meta = .{ .description = "Switch to previous color theme" };
|
pub const theme_prev_meta: Meta = .{ .description = "Switch to previous color theme" };
|
||||||
|
|
||||||
pub fn toggle_whitespace_mode(self: *Self, _: Ctx) Result {
|
pub fn toggle_whitespace_mode(self: *Self, _: Ctx) Result {
|
||||||
self.config.whitespace_mode = if (std.mem.eql(u8, self.config.whitespace_mode, "none"))
|
self.config_.whitespace_mode = if (std.mem.eql(u8, self.config_.whitespace_mode, "none"))
|
||||||
"indent"
|
"indent"
|
||||||
else if (std.mem.eql(u8, self.config.whitespace_mode, "indent"))
|
else if (std.mem.eql(u8, self.config_.whitespace_mode, "indent"))
|
||||||
"leading"
|
"leading"
|
||||||
else if (std.mem.eql(u8, self.config.whitespace_mode, "leading"))
|
else if (std.mem.eql(u8, self.config_.whitespace_mode, "leading"))
|
||||||
"eol"
|
"eol"
|
||||||
else if (std.mem.eql(u8, self.config.whitespace_mode, "eol"))
|
else if (std.mem.eql(u8, self.config_.whitespace_mode, "eol"))
|
||||||
"tabs"
|
"tabs"
|
||||||
else if (std.mem.eql(u8, self.config.whitespace_mode, "tabs"))
|
else if (std.mem.eql(u8, self.config_.whitespace_mode, "tabs"))
|
||||||
"visible"
|
"visible"
|
||||||
else if (std.mem.eql(u8, self.config.whitespace_mode, "visible"))
|
else if (std.mem.eql(u8, self.config_.whitespace_mode, "visible"))
|
||||||
"full"
|
"full"
|
||||||
else
|
else
|
||||||
"none";
|
"none";
|
||||||
try save_config();
|
try save_config();
|
||||||
var buf: [32]u8 = undefined;
|
var buf: [32]u8 = undefined;
|
||||||
const m = try tp.message.fmtbuf(&buf, .{ "whitespace_mode", self.config.whitespace_mode });
|
const m = try tp.message.fmtbuf(&buf, .{ "whitespace_mode", self.config_.whitespace_mode });
|
||||||
_ = try self.send_widgets(tp.self_pid(), m);
|
_ = try self.send_widgets(tp.self_pid(), m);
|
||||||
self.logger.print("whitespace rendering {s}", .{self.config.whitespace_mode});
|
self.logger.print("whitespace rendering {s}", .{self.config_.whitespace_mode});
|
||||||
}
|
}
|
||||||
pub const toggle_whitespace_mode_meta = .{ .description = "Switch to next whitespace rendering mode" };
|
pub const toggle_whitespace_mode_meta: Meta = .{ .description = "Switch to next whitespace rendering mode" };
|
||||||
|
|
||||||
pub fn toggle_input_mode(self: *Self, _: Ctx) Result {
|
pub fn toggle_input_mode(self: *Self, _: Ctx) Result {
|
||||||
var it = std.mem.splitScalar(u8, self.config.input_mode, '/');
|
var it = std.mem.splitScalar(u8, self.config_.input_mode, '/');
|
||||||
self.config.input_mode = it.first();
|
self.config_.input_mode = it.first();
|
||||||
|
|
||||||
const namespaces = keybind.get_namespaces(self.allocator) catch |e| return tp.exit_error(e, @errorReturnTrace());
|
const namespaces = keybind.get_namespaces(self.allocator) catch |e| return tp.exit_error(e, @errorReturnTrace());
|
||||||
defer {
|
defer {
|
||||||
|
@ -755,18 +755,18 @@ const cmds = struct {
|
||||||
self.allocator.free(namespaces);
|
self.allocator.free(namespaces);
|
||||||
}
|
}
|
||||||
var found = false;
|
var found = false;
|
||||||
self.config.input_mode = blk: for (namespaces) |namespace| {
|
self.config_.input_mode = blk: for (namespaces) |namespace| {
|
||||||
if (found) break :blk try self.allocator.dupe(u8, namespace);
|
if (found) break :blk try self.allocator.dupe(u8, namespace);
|
||||||
if (std.mem.eql(u8, namespace, self.config.input_mode))
|
if (std.mem.eql(u8, namespace, self.config_.input_mode))
|
||||||
found = true;
|
found = true;
|
||||||
} else try self.allocator.dupe(u8, namespaces[0]);
|
} else try self.allocator.dupe(u8, namespaces[0]);
|
||||||
|
|
||||||
try save_config();
|
try save_config();
|
||||||
self.logger.print("input mode {s}", .{self.config.input_mode});
|
self.logger.print("input mode {s}", .{self.config_.input_mode});
|
||||||
try keybind.set_namespace(self.config.input_mode);
|
try keybind.set_namespace(self.config_.input_mode);
|
||||||
return self.refresh_input_mode();
|
return self.refresh_input_mode();
|
||||||
}
|
}
|
||||||
pub const toggle_input_mode_meta = .{ .description = "Switch to next input mode" };
|
pub const toggle_input_mode_meta: Meta = .{ .description = "Switch to next input mode" };
|
||||||
|
|
||||||
pub fn enter_mode(self: *Self, ctx: Ctx) Result {
|
pub fn enter_mode(self: *Self, ctx: Ctx) Result {
|
||||||
var mode: []const u8 = undefined;
|
var mode: []const u8 = undefined;
|
||||||
|
@ -785,42 +785,42 @@ const cmds = struct {
|
||||||
}
|
}
|
||||||
return self.enter_input_mode(new_mode);
|
return self.enter_input_mode(new_mode);
|
||||||
}
|
}
|
||||||
pub const enter_mode_meta = .{ .arguments = &.{.string} };
|
pub const enter_mode_meta: Meta = .{ .arguments = &.{.string} };
|
||||||
|
|
||||||
pub fn enter_mode_default(self: *Self, _: Ctx) Result {
|
pub fn enter_mode_default(self: *Self, _: Ctx) Result {
|
||||||
return enter_mode(self, Ctx.fmt(.{keybind.default_mode}));
|
return enter_mode(self, Ctx.fmt(.{keybind.default_mode}));
|
||||||
}
|
}
|
||||||
pub const enter_mode_default_meta = .{};
|
pub const enter_mode_default_meta: Meta = .{};
|
||||||
|
|
||||||
pub fn open_command_palette(self: *Self, _: Ctx) Result {
|
pub fn open_command_palette(self: *Self, _: Ctx) Result {
|
||||||
return self.enter_overlay_mode(@import("mode/overlay/command_palette.zig").Type);
|
return self.enter_overlay_mode(@import("mode/overlay/command_palette.zig").Type);
|
||||||
}
|
}
|
||||||
pub const open_command_palette_meta = .{ .description = "Show/Run commands" };
|
pub const open_command_palette_meta: Meta = .{ .description = "Show/Run commands" };
|
||||||
|
|
||||||
pub fn insert_command_name(self: *Self, _: Ctx) Result {
|
pub fn insert_command_name(self: *Self, _: Ctx) Result {
|
||||||
return self.enter_overlay_mode(@import("mode/overlay/list_all_commands_palette.zig").Type);
|
return self.enter_overlay_mode(@import("mode/overlay/list_all_commands_palette.zig").Type);
|
||||||
}
|
}
|
||||||
pub const insert_command_name_meta = .{ .description = "Insert command name" };
|
pub const insert_command_name_meta: Meta = .{ .description = "Insert command name" };
|
||||||
|
|
||||||
pub fn open_recent(self: *Self, _: Ctx) Result {
|
pub fn open_recent(self: *Self, _: Ctx) Result {
|
||||||
return self.enter_overlay_mode(@import("mode/overlay/open_recent.zig"));
|
return self.enter_overlay_mode(@import("mode/overlay/open_recent.zig"));
|
||||||
}
|
}
|
||||||
pub const open_recent_meta = .{ .description = "Open recent file" };
|
pub const open_recent_meta: Meta = .{ .description = "Open recent file" };
|
||||||
|
|
||||||
pub fn open_recent_project(self: *Self, _: Ctx) Result {
|
pub fn open_recent_project(self: *Self, _: Ctx) Result {
|
||||||
return self.enter_overlay_mode(@import("mode/overlay/open_recent_project.zig").Type);
|
return self.enter_overlay_mode(@import("mode/overlay/open_recent_project.zig").Type);
|
||||||
}
|
}
|
||||||
pub const open_recent_project_meta = .{ .description = "Open recent project" };
|
pub const open_recent_project_meta: Meta = .{ .description = "Open recent project" };
|
||||||
|
|
||||||
pub fn switch_buffers(self: *Self, _: Ctx) Result {
|
pub fn switch_buffers(self: *Self, _: Ctx) Result {
|
||||||
return self.enter_overlay_mode(@import("mode/overlay/buffer_palette.zig").Type);
|
return self.enter_overlay_mode(@import("mode/overlay/buffer_palette.zig").Type);
|
||||||
}
|
}
|
||||||
pub const switch_buffers_meta = .{ .description = "Switch buffers" };
|
pub const switch_buffers_meta: Meta = .{ .description = "Switch buffers" };
|
||||||
|
|
||||||
pub fn select_task(self: *Self, _: Ctx) Result {
|
pub fn select_task(self: *Self, _: Ctx) Result {
|
||||||
return self.enter_overlay_mode(@import("mode/overlay/task_palette.zig").Type);
|
return self.enter_overlay_mode(@import("mode/overlay/task_palette.zig").Type);
|
||||||
}
|
}
|
||||||
pub const select_task_meta = .{ .description = "Select a task to run" };
|
pub const select_task_meta: Meta = .{ .description = "Select a task to run" };
|
||||||
|
|
||||||
pub fn add_task(self: *Self, ctx: Ctx) Result {
|
pub fn add_task(self: *Self, ctx: Ctx) Result {
|
||||||
return enter_mini_mode(self, struct {
|
return enter_mini_mode(self, struct {
|
||||||
|
@ -840,7 +840,7 @@ const cmds = struct {
|
||||||
}
|
}
|
||||||
}, ctx);
|
}, ctx);
|
||||||
}
|
}
|
||||||
pub const add_task_meta = .{ .description = "Add a task to run" };
|
pub const add_task_meta: Meta = .{ .description = "Add a task to run" };
|
||||||
|
|
||||||
pub fn delete_task(_: *Self, ctx: Ctx) Result {
|
pub fn delete_task(_: *Self, ctx: Ctx) Result {
|
||||||
var task: []const u8 = undefined;
|
var task: []const u8 = undefined;
|
||||||
|
@ -848,94 +848,94 @@ const cmds = struct {
|
||||||
return error.InvalidDeleteTaskArgument;
|
return error.InvalidDeleteTaskArgument;
|
||||||
project_manager.delete_task(task) catch |e| return tp.exit_error(e, @errorReturnTrace());
|
project_manager.delete_task(task) catch |e| return tp.exit_error(e, @errorReturnTrace());
|
||||||
}
|
}
|
||||||
pub const delete_task_meta = .{};
|
pub const delete_task_meta: Meta = .{};
|
||||||
|
|
||||||
pub fn change_theme(self: *Self, _: Ctx) Result {
|
pub fn change_theme(self: *Self, _: Ctx) Result {
|
||||||
return self.enter_overlay_mode(@import("mode/overlay/theme_palette.zig").Type);
|
return self.enter_overlay_mode(@import("mode/overlay/theme_palette.zig").Type);
|
||||||
}
|
}
|
||||||
pub const change_theme_meta = .{ .description = "Select color theme" };
|
pub const change_theme_meta: Meta = .{ .description = "Select color theme" };
|
||||||
|
|
||||||
pub fn change_file_type(self: *Self, _: Ctx) Result {
|
pub fn change_file_type(self: *Self, _: Ctx) Result {
|
||||||
return self.enter_overlay_mode(@import("mode/overlay/file_type_palette.zig").Type);
|
return self.enter_overlay_mode(@import("mode/overlay/file_type_palette.zig").Type);
|
||||||
}
|
}
|
||||||
pub const change_file_type_meta = .{ .description = "Change file type" };
|
pub const change_file_type_meta: Meta = .{ .description = "Change file type" };
|
||||||
|
|
||||||
pub fn change_fontface(self: *Self, _: Ctx) Result {
|
pub fn change_fontface(self: *Self, _: Ctx) Result {
|
||||||
if (build_options.gui)
|
if (build_options.gui)
|
||||||
self.rdr.get_fontfaces();
|
self.rdr_.get_fontfaces();
|
||||||
}
|
}
|
||||||
pub const change_fontface_meta = .{ .description = "Select font face" };
|
pub const change_fontface_meta: Meta = .{ .description = "Select font face" };
|
||||||
|
|
||||||
pub fn exit_overlay_mode(self: *Self, _: Ctx) Result {
|
pub fn exit_overlay_mode(self: *Self, _: Ctx) Result {
|
||||||
self.rdr.cursor_disable();
|
self.rdr_.cursor_disable();
|
||||||
if (self.input_mode_outer == null) return;
|
if (self.input_mode_outer_ == null) return;
|
||||||
if (self.input_mode) |*mode| mode.deinit();
|
if (self.input_mode_) |*mode| mode.deinit();
|
||||||
self.input_mode = self.input_mode_outer;
|
self.input_mode_ = self.input_mode_outer_;
|
||||||
self.input_mode_outer = null;
|
self.input_mode_outer_ = null;
|
||||||
refresh_hover();
|
refresh_hover();
|
||||||
}
|
}
|
||||||
pub const exit_overlay_mode_meta = .{};
|
pub const exit_overlay_mode_meta: Meta = .{};
|
||||||
|
|
||||||
pub fn find(self: *Self, ctx: Ctx) Result {
|
pub fn find(self: *Self, ctx: Ctx) Result {
|
||||||
return enter_mini_mode(self, @import("mode/mini/find.zig"), ctx);
|
return enter_mini_mode(self, @import("mode/mini/find.zig"), ctx);
|
||||||
}
|
}
|
||||||
pub const find_meta = .{ .description = "Find in current file" };
|
pub const find_meta: Meta = .{ .description = "Find in current file" };
|
||||||
|
|
||||||
pub fn find_in_files(self: *Self, ctx: Ctx) Result {
|
pub fn find_in_files(self: *Self, ctx: Ctx) Result {
|
||||||
return enter_mini_mode(self, @import("mode/mini/find_in_files.zig"), ctx);
|
return enter_mini_mode(self, @import("mode/mini/find_in_files.zig"), ctx);
|
||||||
}
|
}
|
||||||
pub const find_in_files_meta = .{ .description = "Find in all project files" };
|
pub const find_in_files_meta: Meta = .{ .description = "Find in all project files" };
|
||||||
|
|
||||||
pub fn goto(self: *Self, ctx: Ctx) Result {
|
pub fn goto(self: *Self, ctx: Ctx) Result {
|
||||||
return enter_mini_mode(self, @import("mode/mini/goto.zig"), ctx);
|
return enter_mini_mode(self, @import("mode/mini/goto.zig"), ctx);
|
||||||
}
|
}
|
||||||
pub const goto_meta = .{ .description = "Goto line" };
|
pub const goto_meta: Meta = .{ .description = "Goto line" };
|
||||||
|
|
||||||
pub fn move_to_char(self: *Self, ctx: Ctx) Result {
|
pub fn move_to_char(self: *Self, ctx: Ctx) Result {
|
||||||
return enter_mini_mode(self, @import("mode/mini/move_to_char.zig"), ctx);
|
return enter_mini_mode(self, @import("mode/mini/move_to_char.zig"), ctx);
|
||||||
}
|
}
|
||||||
pub const move_to_char_meta = .{ .description = "Move cursor to matching character" };
|
pub const move_to_char_meta: Meta = .{ .description = "Move cursor to matching character" };
|
||||||
|
|
||||||
pub fn open_file(self: *Self, ctx: Ctx) Result {
|
pub fn open_file(self: *Self, ctx: Ctx) Result {
|
||||||
return enter_mini_mode(self, @import("mode/mini/open_file.zig"), ctx);
|
return enter_mini_mode(self, @import("mode/mini/open_file.zig"), ctx);
|
||||||
}
|
}
|
||||||
pub const open_file_meta = .{ .description = "Open file" };
|
pub const open_file_meta: Meta = .{ .description = "Open file" };
|
||||||
|
|
||||||
pub fn save_as(self: *Self, ctx: Ctx) Result {
|
pub fn save_as(self: *Self, ctx: Ctx) Result {
|
||||||
return enter_mini_mode(self, @import("mode/mini/save_as.zig"), ctx);
|
return enter_mini_mode(self, @import("mode/mini/save_as.zig"), ctx);
|
||||||
}
|
}
|
||||||
pub const save_as_meta = .{ .description = "Save as" };
|
pub const save_as_meta: Meta = .{ .description = "Save as" };
|
||||||
|
|
||||||
fn enter_mini_mode(self: *Self, comptime mode: anytype, ctx: Ctx) !void {
|
fn enter_mini_mode(self: *Self, comptime mode: anytype, ctx: Ctx) !void {
|
||||||
command.executeName("disable_fast_scroll", .{}) catch {};
|
command.executeName("disable_fast_scroll", .{}) catch {};
|
||||||
command.executeName("disable_jump_mode", .{}) catch {};
|
command.executeName("disable_jump_mode", .{}) catch {};
|
||||||
const input_mode_, const mini_mode_ = try mode.create(self.allocator, ctx);
|
const input_mode_, const mini_mode_ = try mode.create(self.allocator, ctx);
|
||||||
if (self.mini_mode) |_| try exit_mini_mode(self, .{});
|
if (self.mini_mode_) |_| try exit_mini_mode(self, .{});
|
||||||
if (self.input_mode_outer) |_| try exit_overlay_mode(self, .{});
|
if (self.input_mode_outer_) |_| try exit_overlay_mode(self, .{});
|
||||||
if (self.input_mode_outer != null) @panic("exit_overlay_mode failed");
|
if (self.input_mode_outer_ != null) @panic("exit_overlay_mode failed");
|
||||||
self.input_mode_outer = self.input_mode;
|
self.input_mode_outer_ = self.input_mode_;
|
||||||
self.input_mode = input_mode_;
|
self.input_mode_ = input_mode_;
|
||||||
self.mini_mode = mini_mode_;
|
self.mini_mode_ = mini_mode_;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exit_mini_mode(self: *Self, _: Ctx) Result {
|
pub fn exit_mini_mode(self: *Self, _: Ctx) Result {
|
||||||
self.rdr.cursor_disable();
|
self.rdr_.cursor_disable();
|
||||||
if (self.mini_mode) |_| {} else return;
|
if (self.mini_mode_) |_| {} else return;
|
||||||
if (self.input_mode) |*mode| mode.deinit();
|
if (self.input_mode_) |*mode| mode.deinit();
|
||||||
self.input_mode = self.input_mode_outer;
|
self.input_mode_ = self.input_mode_outer_;
|
||||||
self.input_mode_outer = null;
|
self.input_mode_outer_ = null;
|
||||||
self.mini_mode = null;
|
self.mini_mode_ = null;
|
||||||
}
|
}
|
||||||
pub const exit_mini_mode_meta = .{};
|
pub const exit_mini_mode_meta: Meta = .{};
|
||||||
|
|
||||||
pub fn open_keybind_config(self: *Self, _: Ctx) Result {
|
pub fn open_keybind_config(self: *Self, _: Ctx) Result {
|
||||||
var mode_parts = std.mem.splitScalar(u8, self.config.input_mode, '/');
|
var mode_parts = std.mem.splitScalar(u8, self.config_.input_mode, '/');
|
||||||
const namespace_name = mode_parts.first();
|
const namespace_name = mode_parts.first();
|
||||||
const file_name = try keybind.get_or_create_namespace_config_file(self.allocator, namespace_name);
|
const file_name = try keybind.get_or_create_namespace_config_file(self.allocator, namespace_name);
|
||||||
try tp.self_pid().send(.{ "cmd", "navigate", .{ .file = file_name } });
|
try tp.self_pid().send(.{ "cmd", "navigate", .{ .file = file_name } });
|
||||||
self.logger.print("restart flow to use changed key bindings", .{});
|
self.logger.print("restart flow to use changed key bindings", .{});
|
||||||
}
|
}
|
||||||
pub const open_keybind_config_meta = .{ .description = "Edit key bindings" };
|
pub const open_keybind_config_meta: Meta = .{ .description = "Edit key bindings" };
|
||||||
|
|
||||||
pub fn run_async(self: *Self, ctx: Ctx) Result {
|
pub fn run_async(self: *Self, ctx: Ctx) Result {
|
||||||
var iter = ctx.args.buf;
|
var iter = ctx.args.buf;
|
||||||
|
@ -976,27 +976,27 @@ const cmds = struct {
|
||||||
}
|
}
|
||||||
try tp.self_pid().send_raw(.{ .buf = msg_cb.items });
|
try tp.self_pid().send_raw(.{ .buf = msg_cb.items });
|
||||||
}
|
}
|
||||||
pub const run_async_meta = .{};
|
pub const run_async_meta: Meta = .{};
|
||||||
|
|
||||||
pub fn enter_vim_mode(_: *Self, _: Ctx) Result {
|
pub fn enter_vim_mode(_: *Self, _: Ctx) Result {
|
||||||
try @import("mode/vim.zig").init();
|
try @import("mode/vim.zig").init();
|
||||||
}
|
}
|
||||||
pub const enter_vim_mode_meta = .{};
|
pub const enter_vim_mode_meta: Meta = .{};
|
||||||
|
|
||||||
pub fn exit_vim_mode(_: *Self, _: Ctx) Result {
|
pub fn exit_vim_mode(_: *Self, _: Ctx) Result {
|
||||||
@import("mode/vim.zig").deinit();
|
@import("mode/vim.zig").deinit();
|
||||||
}
|
}
|
||||||
pub const exit_vim_mode_meta = .{};
|
pub const exit_vim_mode_meta: Meta = .{};
|
||||||
|
|
||||||
pub fn enter_helix_mode(_: *Self, _: Ctx) Result {
|
pub fn enter_helix_mode(_: *Self, _: Ctx) Result {
|
||||||
try @import("mode/helix.zig").init();
|
try @import("mode/helix.zig").init();
|
||||||
}
|
}
|
||||||
pub const enter_helix_mode_meta = .{};
|
pub const enter_helix_mode_meta: Meta = .{};
|
||||||
|
|
||||||
pub fn exit_helix_mode(_: *Self, _: Ctx) Result {
|
pub fn exit_helix_mode(_: *Self, _: Ctx) Result {
|
||||||
@import("mode/helix.zig").deinit();
|
@import("mode/helix.zig").deinit();
|
||||||
}
|
}
|
||||||
pub const exit_helix_mode_meta = .{};
|
pub const exit_helix_mode_meta: Meta = .{};
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const MiniMode = struct {
|
pub const MiniMode = struct {
|
||||||
|
@ -1015,43 +1015,43 @@ fn current() *Self {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn rdr() *renderer {
|
pub fn rdr() *renderer {
|
||||||
return ¤t().rdr;
|
return ¤t().rdr_;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn message_filters() *MessageFilter.List {
|
pub fn message_filters() *MessageFilter.List {
|
||||||
return ¤t().message_filters;
|
return ¤t().message_filters_;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn input_listeners() *EventHandler.List {
|
pub fn input_listeners() *EventHandler.List {
|
||||||
return ¤t().input_listeners;
|
return ¤t().input_listeners_;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn input_mode() ?*Mode {
|
pub fn input_mode() ?*Mode {
|
||||||
return if (current().input_mode) |*p| p else null;
|
return if (current().input_mode_) |*p| p else null;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn input_mode_outer() ?*Mode {
|
pub fn input_mode_outer() ?*Mode {
|
||||||
return if (current().input_mode_outer) |*p| p else null;
|
return if (current().input_mode_outer_) |*p| p else null;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mini_mode() ?*MiniMode {
|
pub fn mini_mode() ?*MiniMode {
|
||||||
return if (current().mini_mode) |*p| p else null;
|
return if (current().mini_mode_) |*p| p else null;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn config() *const @import("config") {
|
pub fn config() *const @import("config") {
|
||||||
return ¤t().config;
|
return ¤t().config_;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn config_mut() *@import("config") {
|
pub fn config_mut() *@import("config") {
|
||||||
return ¤t().config;
|
return ¤t().config_;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mainview() ?*MainView {
|
pub fn mainview() ?*MainView {
|
||||||
return if (current().mainview) |*mv| mv.dynamic_cast(MainView) else null;
|
return if (current().mainview_) |*mv| mv.dynamic_cast(MainView) else null;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mainview_widget() Widget {
|
pub fn mainview_widget() Widget {
|
||||||
return current().mainview orelse @panic("tui main view not found");
|
return current().mainview_ orelse @panic("tui main view not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_active_editor() ?*@import("editor.zig").Editor {
|
pub fn get_active_editor() ?*@import("editor.zig").Editor {
|
||||||
|
@ -1075,9 +1075,9 @@ fn context_check() void {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_mode() []const u8 {
|
pub fn get_mode() []const u8 {
|
||||||
return if (current().mini_mode) |m|
|
return if (current().mini_mode_) |m|
|
||||||
m.name
|
m.name
|
||||||
else if (current().input_mode) |m|
|
else if (current().input_mode_) |m|
|
||||||
m.name
|
m.name
|
||||||
else
|
else
|
||||||
"INI";
|
"INI";
|
||||||
|
@ -1085,7 +1085,7 @@ pub fn get_mode() []const u8 {
|
||||||
|
|
||||||
pub fn get_keybind_mode() ?Mode {
|
pub fn get_keybind_mode() ?Mode {
|
||||||
const self = current();
|
const self = current();
|
||||||
return self.input_mode orelse self.delayed_init_input_mode;
|
return self.input_mode_ orelse self.delayed_init_input_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn reset_drag_context() void {
|
pub fn reset_drag_context() void {
|
||||||
|
@ -1108,11 +1108,11 @@ pub fn resize() void {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn plane() renderer.Plane {
|
pub fn plane() renderer.Plane {
|
||||||
return current().rdr.stdplane();
|
return current().rdr_.stdplane();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn stdplane(self: *Self) renderer.Plane {
|
fn stdplane(self: *Self) renderer.Plane {
|
||||||
return self.rdr.stdplane();
|
return self.rdr_.stdplane();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn egc_chunk_width(chunk: []const u8, abs_col: usize, tab_width: usize) usize {
|
pub fn egc_chunk_width(chunk: []const u8, abs_col: usize, tab_width: usize) usize {
|
||||||
|
@ -1128,15 +1128,15 @@ pub fn screen() Widget.Box {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fontface() []const u8 {
|
pub fn fontface() []const u8 {
|
||||||
return current().fontface;
|
return current().fontface_;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fontfaces(allocator: std.mem.Allocator) error{OutOfMemory}![][]const u8 {
|
pub fn fontfaces(allocator: std.mem.Allocator) error{OutOfMemory}![][]const u8 {
|
||||||
return current().fontfaces.toOwnedSlice(allocator);
|
return current().fontfaces_.toOwnedSlice(allocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn theme() *const Widget.Theme {
|
pub fn theme() *const Widget.Theme {
|
||||||
return ¤t().theme;
|
return ¤t().theme_;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_theme_by_name(name: []const u8) ?Widget.Theme {
|
pub fn get_theme_by_name(name: []const u8) ?Widget.Theme {
|
||||||
|
@ -1254,15 +1254,15 @@ pub const fallbacks: []const FallBack = &[_]FallBack{
|
||||||
};
|
};
|
||||||
|
|
||||||
fn set_terminal_style(self: *Self) void {
|
fn set_terminal_style(self: *Self) void {
|
||||||
if (build_options.gui or self.config.enable_terminal_color_scheme) {
|
if (build_options.gui or self.config_.enable_terminal_color_scheme) {
|
||||||
self.rdr.set_terminal_style(self.theme.editor);
|
self.rdr_.set_terminal_style(self.theme_.editor);
|
||||||
self.rdr.set_terminal_cursor_color(self.theme.editor_cursor.bg.?);
|
self.rdr_.set_terminal_cursor_color(self.theme_.editor_cursor.bg.?);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_cursor_shape() renderer.CursorShape {
|
pub fn get_cursor_shape() renderer.CursorShape {
|
||||||
const self = current();
|
const self = current();
|
||||||
const shape = if (self.input_mode) |mode| mode.cursor_shape orelse self.default_cursor else self.default_cursor;
|
const shape = if (self.input_mode_) |mode| mode.cursor_shape orelse self.default_cursor else self.default_cursor;
|
||||||
return switch (shape) {
|
return switch (shape) {
|
||||||
.default => .default,
|
.default => .default,
|
||||||
.block_blink => .block_blink,
|
.block_blink => .block_blink,
|
||||||
|
@ -1282,7 +1282,7 @@ pub fn is_cursor_beam() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_selection_style() @import("Buffer").Selection.Style {
|
pub fn get_selection_style() @import("Buffer").Selection.Style {
|
||||||
return if (current().input_mode) |mode| mode.selection_style else .normal;
|
return if (current().input_mode_) |mode| mode.selection_style else .normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn message(comptime fmt: anytype, args: anytype) void {
|
pub fn message(comptime fmt: anytype, args: anytype) void {
|
||||||
|
|
Loading…
Add table
Reference in a new issue