Compare commits

...

62 commits

Author SHA1 Message Date
670f671713
build: enable ReleaseFast for release builds 2025-03-06 17:36:59 +01:00
1943d65924
Merge branch 'master' into zig-0.14 2025-03-06 17:14:56 +01:00
ce6df051fb
Merge branch 'master' into zig-0.14 2025-03-05 21:59:16 +01:00
f29e01f244
build: re-enable the zig fmt linting build step 2025-03-05 21:44:45 +01:00
4cdd439b4a
Merge branch 'master' into zig-0.14 2025-03-05 21:28:38 +01:00
0a195a4b79
Merge branch 'master' into zig-0.14 2025-03-05 17:58:18 +01:00
6421dae0c8
refactor: run zig fmt for zig-0.14 2025-03-05 17:12:08 +01:00
4a6f610514
Merge branch 'master' into zig-0.14 2025-03-05 14:33:05 +01:00
09832b1d3e
Merge branch 'master' into zig-0.14 2025-03-05 11:03:51 +01:00
c7f8c1e6a5
build: update to zig-0.14 2025-03-05 11:00:29 +01:00
be06cb839f
Merge commit '77a69410b8' into zig-0.14 2025-03-05 10:44:47 +01:00
77a69410b8 Squashed 'src/syntax/' changes from ba10d896..d5c1cd2a
d5c1cd2a Merge branch 'master' into zig-0.14
6b4feb7d update dep hash
46cd19ca update to latest zig
7214ee0a refactor: run zig fmt
b2238178 Set php's default LSP to intelephense
8b3a5ac1 refactor: run zig fmt
942e8dfd Merge commit 'f3c35545e3ba6038460bab1d130be54eb1067a29' into zig-0.14
f3c35545 Merge branch 'master' into zig-0.14
28bc77f4 feat: add astro file type support
be80b598 refactor: run zig fmt
670aa9ae build: update to zig 0.14.0-dev.3039
f81314c1 feat: add .ref to diff file type extensions
01558741 feat: add sql file type support
942053ff add systemverilog lsp and formatter
3711541e anonymous struct do not coerce anymore since zig commit d11bbde
da812e05 fix(config): add gui_config to file_types
ec62f6c7 fix: build without tree-sitter
1226f473 add JuliaFormatter as julia formatter
bc723309 add rustfmt as rust formatter
e719a3b6 Merge branch 'master' into zig-0.14
65e5e6cc Merge branch 'master' into zig-0.14
231c5c1f Merge branch 'master' into zig-0.14
2a345ab7 Merge branch 'master' into zig-0.14
51e33d7b Merge pull request #3 from alichraghi/master
0b566414 update to latest zig

git-subtree-dir: src/syntax
git-subtree-split: d5c1cd2a328ec75fd9b0feddbc9eb84b5f590939
2025-03-05 10:43:03 +01:00
a56d97c85d
fix: add Meta declarations post-merge 2025-03-04 21:18:49 +01:00
a959563bc7
Merge branch 'master' into zig-0.14 2025-03-04 21:15:14 +01:00
48f889d4cf
Merge branch 'master' into zig-0.14 2025-03-02 21:51:19 +01:00
d0ce904faa
fix: add missing Meta types 2025-02-28 21:48:23 +01:00
dceb433e9e
Merge branch 'master' into zig-0.14 2025-02-28 21:43:10 +01:00
4389eccdce
Merge branch 'master' into zig-0.14 2025-02-26 22:04:42 +01:00
8f9b2d15f7
Merge branch 'master' into zig-0.14 2025-02-25 21:40:53 +01:00
00f786e5dd
Merge branch 'master' into zig-0.14 2025-02-24 21:47:38 +01:00
a28edbe194
Merge branch 'master' into zig-0.14 2025-02-24 18:27:42 +01:00
43c6514cd6
Merge branch 'master' into zig-0.14 2025-02-23 21:56:24 +01:00
3ef51454cd
Merge branch 'master' into zig-0.14 2025-02-22 23:53:43 +01:00
a0514a6f7e
build: update to zig-0.14.0-dev.3280 2025-02-21 22:17:28 +01:00
9b197e7209
Merge branch 'master' into zig-0.14 2025-02-21 22:08:02 +01:00
cf86f0b356
Merge branch 'master' into zig-0.14 2025-02-20 22:07:57 +01:00
1403636cc2
Merge branch 'master' into zig-0.14 2025-02-20 22:02:59 +01:00
c41cd07085
Merge branch 'master' into zig-0.14 2025-02-20 21:22:59 +01:00
90bacba8d5
Merge branch 'master' into zig-0.14 2025-02-19 21:36:09 +01:00
4ee59e14ba
fix: add missing Meta declarations pulled in by last master merge 2025-02-14 10:09:15 +01:00
64ccbd3c14
Merge branch 'master' into zig-0.14 2025-02-13 21:07:49 +01:00
5fc2247bc3
Merge branch 'master' into zig-0.14 2025-02-13 12:08:54 +01:00
1ba46972da
Merge branch 'master' into zig-0.14 2025-02-13 08:48:02 +01:00
a469080bfe
Merge branch 'master' into zig-0.14 2025-02-12 18:20:12 +01:00
f447440e26
Merge branch 'master' into zig-0.14 2025-02-12 10:50:48 +01:00
d4e4271831
Merge branch 'master' into zig-0.14 2025-02-11 18:44:17 +01:00
66e2b95534
Merge branch 'master' into zig-0.14 2025-02-11 15:10:37 +01:00
0cd48c5eaa
Merge branch 'master' into zig-0.14 2025-02-11 13:32:11 +01:00
afd547e049
Merge branch 'master' into zig-0.14 2025-02-11 10:32:07 +01:00
2047190dd1
Merge branch 'master' into zig-0.14 2025-02-11 10:05:14 +01:00
23e702f961
build: update to zig-0.14.0-dev.3091 2025-02-09 21:52:17 +01:00
43b14d9147
Merge branch 'master' into zig-0.14 2025-02-09 21:49:45 +01:00
b9999a3d1e
Merge branch 'master' into zig-0.14 2025-02-07 22:21:55 +01:00
b96795325b
Merge branch 'master' into zig-0.14 2025-02-06 22:25:13 +01:00
53340d7ef0
Merge branch 'master' into zig-0.14 2025-02-06 22:18:42 +01:00
9b43f005f4
Merge branch 'master' into zig-0.14 2025-02-06 21:44:55 +01:00
265ed6d355
Merge branch 'master' into zig-0.14 2025-02-06 21:24:47 +01:00
1d59d1e46a
feat: add configuration and command to toggle display of inline diagnostics 2025-02-06 10:55:42 +01:00
4ae59d848a
refactor: move digit styles to fonts.zig 2025-02-05 22:49:50 +01:00
8964a361a7
feat: add line number styles 2025-02-05 22:27:58 +01:00
79799b248e Release 0.3.2
Fixes:
     - Allow get_version_info to succeed if git rev-parse fails. This allows building with version info on a detached HEAD.
 -----BEGIN PGP SIGNATURE-----
 
 iQGzBAABCAAdFiEETmz3I0/8ThRTEHT5jrHhu2YOP7kFAmejnMcACgkQjrHhu2YO
 P7nHrgv8Dc/LKL4WZ3n5JWdWxzheqtyAY9iEh0RjePS42vaUcwM59spp0JHrhoN0
 8sc042wdFVwE+smESoApWLkc6s9y+B3FvOiF1w/2fB6ttNILmuyUzLD5YiLwWGct
 DBPDaBBFME2Z5Itkf98dO7TZLOjx/lNeOUon85oLSU5KNldI8j4RmVWy+5su7ZW/
 UE+6Cl5GDRHjsK7DS0msPTucVtXPI/OM9W6aXrvyeU3e6O7tYVH+IzPlaCmsIiwT
 8k9yxt4APKyZcD99HxsUyoMNh2h2BhzifCCOhoJSS7e1n9JnFbQ4n9b1vsOUGwwa
 uub3o6jzXoD4jdSik8hHqoQ2zWub7O/bCcT9FakByx2eYf489TU4J2FHrdRh7prG
 m2G5/wicpEpxXwa74z0DQZvwhzAk0ibVBQOClYA1+R4TG2x8i0587ruMefWE7Qgy
 en5o1Ro+cretAADhA55T2PuTas6B1vgADM3LsLgpb6q/+5yllTcPZA2ixOUjbN0i
 vP0hpltS
 =Lq92
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQGzBAABCAAdFiEETmz3I0/8ThRTEHT5jrHhu2YOP7kFAmejnOAACgkQjrHhu2YO
 P7nvbgv+JCVucHGJtHhlIRTbIUdug1lbkpqOj8iKpjmk8rcBAH/uWlfgvLf6D5GM
 5YvqmvInVoDa0WLN7wyTIPqAmitXcQMV9DiqO3II1Etv33cuJ/c638DtAF6FJWDb
 klewZAyg5ml3Xsjbz9SD8MKygVdvJh+zIXxa81/4bAdJE7Xb6fd/jz4bGt2nvFde
 rkUpxmeBzZsrDLBwKRsQtpRbKYMgXR1bH0+sPgTh/+71qkKiutIvpFT2FCtCNqED
 8+/OKeeJhXT2sesGlcwGX+X3EAaXlHGLwjU91hwE/8FaOf6wq5bROEmwJv+fcFUo
 Fp7QG8mrIoZcAYWrrlA7ZrRwoMXiEhOmhdoTET2T6y7xrdiBuaI3t/BX2xUpwuhy
 uBeVgf8U+Jm2a6muHsrFJmQHpas2T0ZRn7grq7qVmOzDbTMqovWuKHUwTIgu4Q3d
 XEeBsbr08rjBHmjI1L1Q2+odjLz6y8qKAO8JpFvMEMJF7ROlk0gmhxRkFIxVjrXu
 wiVyDV2T
 =sVxf
 -----END PGP SIGNATURE-----

Merge tag 'v0.3.2'
2025-02-05 18:16:03 +01:00
244e5ca9d7
feat(tui): add explicit width support 2025-02-05 16:42:21 +01:00
2b5edb94ec
docs(fonts): add some recommended font download urls to font test text 2025-02-05 16:41:01 +01:00
c351d3fdea
feat(home): add build version info to home screen 2025-02-05 16:40:31 +01:00
6f80e487aa
fix(editor): update cursor target column after nudge_insert/_delete 2025-02-05 16:38:44 +01:00
f5e3e84b59
refactor: run zig fmt 2025-02-05 11:06:57 +01:00
28c9ea991d
Merge branch lulvz/vim_keybinds 2025-02-05 10:54:08 +01:00
lulvz
24c2c3f51f refactor: specify Meta type for vim functions 2025-02-05 00:10:24 +00:00
Luís Tavares
8f1f1a9126
Merge branch 'neurocyte:master' into vim_keybinds 2025-02-05 00:04:45 +00:00
206e6c433a
docs: update minimum zig version 2025-02-04 23:41:11 +01:00
d503f3c197
fix: windows build with zig 0.14.0-dev.3039 2025-02-04 23:32:40 +01:00
53045123c6
build: update to zig 0.14.0-dev.3039 2025-02-04 22:59:18 +01:00
50 changed files with 757 additions and 682 deletions

View file

@ -31,7 +31,7 @@ Or check your favorite local system package repository.
Make sure your system meets the requirements listed above. Make sure your system meets the requirements listed above.
Flow builds with zig 0.13 at this time. Build with: Flow builds with zig 0.14.0 at this time. Build with:
```shell ```shell
zig build -Doptimize=ReleaseSafe zig build -Doptimize=ReleaseSafe

View file

@ -89,7 +89,7 @@ fn build_release(
.{ .cpu_arch = .x86_64, .os_tag = .windows }, .{ .cpu_arch = .x86_64, .os_tag = .windows },
.{ .cpu_arch = .aarch64, .os_tag = .windows }, .{ .cpu_arch = .aarch64, .os_tag = .windows },
}; };
const optimize = .ReleaseSafe; const optimize = .ReleaseFast;
var version = std.ArrayList(u8).init(b.allocator); var version = std.ArrayList(u8).init(b.allocator);
defer version.deinit(); defer version.deinit();
@ -583,7 +583,7 @@ pub fn build_exe(
}); });
lint_step.dependOn(&lints.step); lint_step.dependOn(&lints.step);
// b.default_step.dependOn(lint_step); b.default_step.dependOn(lint_step);
} }
fn gen_version_info( fn gen_version_info(

View file

@ -1 +1 @@
0.13.0 0.14.0

View file

@ -1,41 +1,42 @@
.{ .{
.name = "flow", .name = .flow,
.version = "0.2.0", .version = "0.2.0",
.minimum_zig_version = "0.13.0", .minimum_zig_version = "0.14.0",
.fingerprint = 0x52c0d670590aa80f,
.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",
}, },
.dizzy = .{ .dizzy = .{
.url = "https://github.com/neurocyte/dizzy/archive/455d18369cbb2a0458ba70be919cd378338d695e.tar.gz", .url = "https://github.com/neurocyte/dizzy/archive/455d18369cbb2a0458ba70be919cd378338d695e.tar.gz",
.hash = "1220220dbc7fe91c1c54438193ca765cebbcb7d58f35cdcaee404a9d2245a42a4362", .hash = "1220220dbc7fe91c1c54438193ca765cebbcb7d58f35cdcaee404a9d2245a42a4362",
}, },
.thespian = .{ .thespian = .{
.url = "https://github.com/neurocyte/thespian/archive/9ca04ddfc715e0f7d29d3f6b39269ad9bf174230.tar.gz", .url = "https://github.com/neurocyte/thespian/archive/78c9c1292c683478d8ac98d8318bc098442cc0b9.tar.gz",
.hash = "1220b05b5949454bf155a802d5034c060431b8bf59f9d4d2d5241397e9fd201d78d9", .hash = "thespian-0.0.1-owFOjsnnBgBCsKhYw9XeHnQw0Um9SJQECEZ0aqomc04m",
}, },
.themes = .{ .themes = .{
.url = "https://github.com/neurocyte/flow-themes/releases/download/master-59bf204551bcb238faddd06779063570e7e6d431/flow-themes.tar.gz", .url = "https://github.com/neurocyte/flow-themes/releases/download/master-59bf204551bcb238faddd06779063570e7e6d431/flow-themes.tar.gz",
.hash = "12209a213a392ea80ea5c7dde125e7161bb0278ac4b99db9df2b7af783710bcb09f7", .hash = "12209a213a392ea80ea5c7dde125e7161bb0278ac4b99db9df2b7af783710bcb09f7",
}, },
.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/e518e139417a9773f59624961b02e05b8fffff35.tar.gz", .url = "https://github.com/neurocyte/libvaxis/archive/da7d26fa0e86c721414bdcb82ea46cf0b4da5b68.tar.gz",
.hash = "122045fec2cedf3f68c20f961c42f3ca1e901238aec5a0c7b3b632cd21ce3b621f76", .hash = "1220fe019c2901695c959873ef9b1736bd04197d377ad1c520eff8affd5204dd2bc2",
}, },
.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,
}, },
}, },

View file

@ -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 &.{

View file

@ -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| {

View file

@ -55,7 +55,7 @@ file_type_icon: ?[]const u8 = null,
file_type_color: ?u24 = null, file_type_color: ?u24 = null,
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,
@ -71,26 +71,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;
}; };
@ -126,8 +126,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;
} }
@ -144,8 +144,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;
} }
}; };
@ -350,10 +350,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);
@ -367,10 +367,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 };
} }
@ -390,14 +390,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;
@ -408,7 +408,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 {
@ -420,8 +420,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
@ -432,7 +432,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| {
@ -442,7 +442,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;
@ -453,7 +453,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 {
@ -508,12 +508,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;
@ -670,7 +670,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;
} }
@ -724,7 +724,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;
} }
@ -1211,6 +1211,9 @@ pub const LoadFromFileError = error{
DanglingSurrogateHalf, DanglingSurrogateHalf,
ExpectedSecondSurrogateHalf, ExpectedSecondSurrogateHalf,
UnexpectedSecondSurrogateHalf, UnexpectedSecondSurrogateHalf,
LockViolation,
ProcessNotFound,
Canceled,
}; };
pub fn load_from_file( pub fn load_from_file(
@ -1302,6 +1305,7 @@ pub const StoreToFileError = error{
PathAlreadyExists, PathAlreadyExists,
PipeBusy, PipeBusy,
ProcessFdQuotaExceeded, ProcessFdQuotaExceeded,
ProcessNotFound,
ReadOnlyFileSystem, ReadOnlyFileSystem,
RenameAcrossMountPoints, RenameAcrossMountPoints,
SharingViolation, SharingViolation,

View file

@ -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 = &.{},

View file

@ -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 });

View file

@ -123,13 +123,13 @@ const Process = struct {
if (isdupe(self.backwards.getLastOrNull(), entry)) { if (isdupe(self.backwards.getLastOrNull(), entry)) {
if (self.current) |current| self.forwards.append(current) catch {}; if (self.current) |current| self.forwards.append(current) catch {};
const top = self.backwards.pop(); if (self.backwards.pop()) |top|
self.allocator.free(top.file_path); self.allocator.free(top.file_path);
tp.trace(tp.channel.all, tp.message.fmt(.{ "location", "back", entry.file_path, entry.cursor.row, entry.cursor.col, self.backwards.items.len, self.forwards.items.len })); tp.trace(tp.channel.all, tp.message.fmt(.{ "location", "back", entry.file_path, entry.cursor.row, entry.cursor.col, self.backwards.items.len, self.forwards.items.len }));
} else if (isdupe(self.forwards.getLastOrNull(), entry)) { } else if (isdupe(self.forwards.getLastOrNull(), entry)) {
if (self.current) |current| self.backwards.append(current) catch {}; if (self.current) |current| self.backwards.append(current) catch {};
const top = self.forwards.pop(); if (self.forwards.pop()) |top|
self.allocator.free(top.file_path); self.allocator.free(top.file_path);
tp.trace(tp.channel.all, tp.message.fmt(.{ "location", "forward", entry.file_path, entry.cursor.row, entry.cursor.col, self.backwards.items.len, self.forwards.items.len })); tp.trace(tp.channel.all, tp.message.fmt(.{ "location", "forward", entry.file_path, entry.cursor.row, entry.cursor.col, self.backwards.items.len, self.forwards.items.len }));
} else if (self.current) |current| { } else if (self.current) |current| {
try self.backwards.append(current); try self.backwards.append(current);

View file

@ -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;

View file

@ -25,7 +25,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,
@ -33,7 +33,11 @@ pub const std_options = .{
const renderer = @import("renderer"); const renderer = @import("renderer");
pub const panic = if (@hasDecl(renderer, "panic")) renderer.panic else std.builtin.default_panic; pub const panic = if (@hasDecl(renderer, "panic")) renderer.panic else default_panic;
fn default_panic(msg: []const u8, _: ?*std.builtin.StackTrace, ret_addr: ?usize) noreturn {
return std.debug.defaultPanic(msg, ret_addr);
}
pub fn main() anyerror!void { pub fn main() anyerror!void {
if (builtin.os.tag == .linux) { if (builtin.os.tag == .linux) {
@ -52,7 +56,7 @@ pub fn main() anyerror!void {
\\ \\
\\Pass in file names to be opened with an optional :LINE or :LINE:COL appended to the \\Pass in file names to be opened with an optional :LINE or :LINE:COL appended to the
\\file name to specify a specific location, or pass +<LINE> separately to set the line. \\file name to specify a specific location, or pass +<LINE> separately to set the line.
; ;
pub const descriptions = .{ pub const descriptions = .{
.project = "Set project directory (default: cwd)", .project = "Set project directory (default: cwd)",
@ -506,7 +510,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;
@ -565,7 +569,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),
@ -587,8 +591,8 @@ 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,
.Optional => |info| { .optional => |info| {
if (a == null and b == null) if (a == null and b == null)
return true; return true;
if (a == null or b == null) if (a == null or b == null)

View file

@ -924,10 +924,11 @@ const FilteredWalker = struct {
var containing = top; var containing = top;
var dirname_len = top.dirname_len; var dirname_len = top.dirname_len;
if (top.iter.next() catch { if (top.iter.next() catch {
var item = self.stack.pop(); var item_ = self.stack.pop();
if (self.stack.items.len != 0) { if (item_) |*item|
item.iter.dir.close(); if (self.stack.items.len != 0) {
} item.iter.dir.close();
};
continue; continue;
}) |base| { }) |base| {
self.name_buffer.shrinkRetainingCapacity(dirname_len); self.name_buffer.shrinkRetainingCapacity(dirname_len);
@ -958,10 +959,11 @@ const FilteredWalker = struct {
else => continue, else => continue,
} }
} else { } else {
var item = self.stack.pop(); var item_ = self.stack.pop();
if (self.stack.items.len != 0) { if (item_) |*item|
item.iter.dir.close(); if (self.stack.items.len != 0) {
} item.iter.dir.close();
};
} }
} }
return null; return null;

View file

@ -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)),

View file

@ -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;

View file

@ -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";
@ -25,6 +26,7 @@ no_alternate: bool,
event_buffer: std.ArrayList(u8), event_buffer: std.ArrayList(u8),
input_buffer: std.ArrayList(u8), input_buffer: std.ArrayList(u8),
mods: vaxis.Key.Modifiers = .{}, mods: vaxis.Key.Modifiers = .{},
queries_done: bool,
bracketed_paste: bool = false, bracketed_paste: bool = false,
bracketed_paste_buffer: std.ArrayList(u8), bracketed_paste_buffer: std.ArrayList(u8),
@ -61,6 +63,7 @@ pub fn init(allocator: std.mem.Allocator, handler_ctx: *anyopaque, no_alternate:
.handler_ctx = handler_ctx, .handler_ctx = handler_ctx,
.logger = log.logger(log_name), .logger = log.logger(log_name),
.loop = undefined, .loop = undefined,
.queries_done = false,
}; };
} }
@ -80,13 +83,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 orelse @returnAddress()); return std.debug.defaultPanic(msg, ret_addr orelse @returnAddress());
} }
pub fn run(self: *Self) !void { pub fn run(self: *Self) !void {
@ -152,6 +156,15 @@ pub fn process_renderer_event(self: *Self, msg: []const u8) !void {
const event = std.mem.bytesAsValue(vaxis.Event, input_); const event = std.mem.bytesAsValue(vaxis.Event, input_);
switch (event.*) { switch (event.*) {
.key_press => |key__| { .key_press => |key__| {
// Check for a cursor position response for our explicity width query. This will
// always be an F3 key with shift = true, and we must be looking for queries
if (key__.codepoint == vaxis.Key.f3 and key__.mods.shift and !self.queries_done) {
self.logger.print("explicit width capability detected", .{});
self.vx.caps.explicit_width = true;
self.vx.caps.unicode = .unicode;
self.vx.screen.width_method = .unicode;
return;
}
const key_ = filter_mods(normalize_shifted_alphas(key__)); const key_ = filter_mods(normalize_shifted_alphas(key__));
try self.sync_mod_state(key_.codepoint, key_.mods); try self.sync_mod_state(key_.codepoint, key_.mods);
const cbor_msg = try self.fmtmsg(.{ const cbor_msg = try self.fmtmsg(.{
@ -253,6 +266,7 @@ pub fn process_renderer_event(self: *Self, msg: []const u8) !void {
self.vx.caps.sgr_pixels = true; self.vx.caps.sgr_pixels = true;
}, },
.cap_da1 => { .cap_da1 => {
self.queries_done = true;
self.vx.enableDetectedFeatures(self.tty.anyWriter()) catch |e| self.logger.err("enable features", e); self.vx.enableDetectedFeatures(self.tty.anyWriter()) catch |e| self.logger.err("enable features", e);
try self.vx.setMouseMode(self.tty.anyWriter(), true); try self.vx.setMouseMode(self.tty.anyWriter(), true);
}, },

View file

@ -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 = .{};

View file

@ -18,8 +18,38 @@ pub const StyleBits = @import("tuirenderer").style;
const gui = @import("gui"); const gui = @import("gui");
const DropWriter = gui.DropWriter; const DropWriter = gui.DropWriter;
pub const style = StyleBits; pub const style = StyleBits;
pub const styles = @import("tuirenderer").styles;
pub const panic = win32.messageBoxThenPanic(.{ .title = "Flow Panic" }); pub const panic = messageBoxThenPanic(.{ .title = "Flow Panic" });
threadlocal var thread_is_panicing = false;
fn messageBoxThenPanic(
opt: struct {
title: [:0]const u8,
style: win32.MESSAGEBOX_STYLE = .{ .ICONASTERISK = 1 },
// TODO: add option/logic to include the stacktrace in the messagebox
},
) std.builtin.PanicFn {
return struct {
pub fn panic(
msg: []const u8,
_: ?*std.builtin.StackTrace,
ret_addr: ?usize,
) noreturn {
if (!thread_is_panicing) {
thread_is_panicing = true;
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
const msg_z: [:0]const u8 = if (std.fmt.allocPrintZ(
arena.allocator(),
"{s}",
.{msg},
)) |msg_z| msg_z else |_| "failed allocate error message";
_ = win32.MessageBoxA(null, msg_z, opt.title, opt.style);
}
std.debug.defaultPanic(msg, ret_addr);
}
}.panic;
}
allocator: std.mem.Allocator, allocator: std.mem.Allocator,
vx: vaxis.Vaxis, vx: vaxis.Vaxis,
@ -35,7 +65,7 @@ thread: ?std.Thread = null,
hwnd: ?win32.HWND = null, hwnd: ?win32.HWND = null,
title_buf: std.ArrayList(u16), title_buf: std.ArrayList(u16),
style: ?Style = null, style_: ?Style = null,
const global = struct { const global = struct {
var init_called: bool = false; var init_called: bool = false;
@ -344,12 +374,12 @@ fn update_window_title(self: *Self) void {
} }
pub fn set_terminal_style(self: *Self, style_: Style) void { pub fn set_terminal_style(self: *Self, style_: Style) void {
self.style = style_; self.style_ = style_;
self.update_window_style(); self.update_window_style();
} }
fn update_window_style(self: *Self) void { fn update_window_style(self: *Self) void {
const hwnd = self.hwnd orelse return; const hwnd = self.hwnd orelse return;
if (self.style) |style_| { if (self.style_) |style_| {
if (style_.bg) |color| gui.set_window_background(hwnd, @intCast(color.color)); if (style_.bg) |color| gui.set_window_background(hwnd, @intCast(color.color));
} }
} }

View file

@ -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);
} }

View file

@ -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);

View file

@ -9,7 +9,7 @@ pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{}); const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{}); const optimize = b.standardOptimizeOption(.{});
const tree_sitter_dep = b.dependency("tree-sitter", .{ const tree_sitter_dep = b.dependency("tree_sitter", .{
.target = target, .target = target,
.optimize = optimize, .optimize = optimize,
}); });

View file

@ -1,11 +1,13 @@
.{ .{
.name = "flow-syntax", .name = .flow_syntax,
.version = "0.0.1", .version = "0.1.0",
.fingerprint = 0x3ba2584ea1cec85f,
.minimum_zig_version = "0.14.0-dev.3451+d8d2aa9af",
.dependencies = .{ .dependencies = .{
.@"tree-sitter" = .{ .tree_sitter = .{
.url = "https://github.com/neurocyte/tree-sitter/releases/download/master-86dd4d2536f2748c5b4ea0e1e70678039a569aac/source.tar.gz", .url = "https://github.com/neurocyte/tree-sitter/releases/download/master-86dd4d2536f2748c5b4ea0e1e70678039a569aac/source.tar.gz",
.hash = "1220e9fba96c468283129e977767472dee00b16f356e5912431cec8f1a009b6691a2", .hash = "N-V-__8AACablCbp-6lsRoKDEp6Xd2dHLe4AsW81blkSQxzs",
}, },
}, },
.paths = .{ .paths = .{

View file

@ -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)));

View file

@ -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"},
@ -18,7 +21,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" },
}; };
@ -253,7 +256,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"},
}; };
@ -263,7 +266,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 = .{
@ -407,7 +410,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"},
}; };
@ -520,7 +523,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", "-" },
}; };

View file

@ -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 &.{

View file

@ -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,

View file

@ -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 {
@ -106,7 +106,7 @@ pub fn remove_all(self: *Self) void {
} }
pub fn pop(self: *Self) ?Widget { pub fn pop(self: *Self) ?Widget {
return if (self.widgets.popOrNull()) |ws| ws.widget else null; return if (self.widgets.pop()) |ws| ws.widget else null;
} }
pub fn empty(self: *const Self) bool { pub fn empty(self: *const Self) bool {

File diff suppressed because it is too large Load diff

View file

@ -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");
@ -33,7 +34,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();
@ -52,7 +53,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));
@ -182,10 +183,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);
} }
try self.plane.cursor_move_yx(@intCast(pos), 0); try self.plane.cursor_move_yx(@intCast(pos), 0);
try self.print_digits(linenum, self.render_style); try self.print_digits(linenum, self.render_style);
@ -340,7 +341,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 {
@ -438,7 +439,7 @@ fn int_width(n_: usize) usize {
fn print_digits(self: *Self, n_: anytype, style_: DigitStyle) !void { fn print_digits(self: *Self, n_: anytype, style_: DigitStyle) !void {
var n = n_; var n = n_;
var buf: [12][]const u8 = undefined; var buf: [12][]const u8 = undefined;
var digits = std.ArrayListUnmanaged([]const u8).initBuffer(&buf); var digits: std.ArrayListUnmanaged([]const u8) = .initBuffer(&buf);
while (true) { while (true) {
digits.addOneAssumeCapacity().* = get_digit(n % 10, style_); digits.addOneAssumeCapacity().* = get_digit(n % 10, style_);
n /= 10; n /= 10;

View file

@ -263,33 +263,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 = .{};
}; };

View file

@ -245,28 +245,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: {
@ -274,7 +275,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 {

View file

@ -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 {

View file

@ -48,7 +48,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,
@ -68,7 +68,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),
@ -180,7 +180,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 {};
@ -240,19 +240,19 @@ const cmds = struct {
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;
@ -264,7 +264,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 close_project(_: *Self, ctx: Ctx) Result { pub fn close_project(_: *Self, ctx: Ctx) Result {
var project_dir: []const u8 = undefined; var project_dir: []const u8 = undefined;
@ -304,7 +304,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();
@ -375,7 +375,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();
@ -383,7 +383,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();
@ -391,7 +391,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();
@ -399,19 +399,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;
@ -433,7 +433,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);
@ -443,7 +443,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;
@ -463,7 +463,7 @@ const cmds = struct {
if (tp.env.get().str("language").len == 0) if (tp.env.get().str("language").len == 0)
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;
@ -480,7 +480,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;
@ -496,7 +496,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) {
@ -506,7 +506,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))
@ -520,52 +520,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(input_view, false); try self.toggle_panel_view(input_view, 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();
@ -582,7 +582,7 @@ const cmds = struct {
gutter.mode = mode; gutter.mode = mode;
} }
} }
pub const gutter_mode_next_meta = .{ .description = "Next gutter mode" }; pub const gutter_mode_next_meta: Meta = .{ .description = "Next gutter mode" };
pub fn gutter_style_next(self: *Self, _: Ctx) Result { pub fn gutter_style_next(self: *Self, _: Ctx) Result {
const config = tui.config_mut(); const config = tui.config_mut();
@ -617,7 +617,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)) {
@ -629,7 +629,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;
@ -664,7 +664,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;
@ -708,8 +708,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;
@ -722,7 +722,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;
@ -740,12 +740,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) {
@ -755,7 +755,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;
@ -769,7 +769,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 }))
@ -781,7 +781,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 }))
@ -807,7 +807,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 }))
@ -835,7 +835,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;
@ -857,7 +857,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;
@ -871,7 +871,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;
@ -880,7 +880,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;
@ -889,13 +889,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;
@ -904,23 +904,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 {
@ -966,13 +966,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);
} }
} }

View file

@ -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" };
}; };

View file

@ -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} };
}; };
}; };
} }

View file

@ -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} };
}; };
}; };
} }

View file

@ -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} };
}; };

View file

@ -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} };
}; };

View file

@ -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} };
}; };

View file

@ -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" };
}; };

View file

@ -272,57 +272,58 @@ 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_pagedown(self: *Self, _: Ctx) Result { pub fn palette_menu_pagedown(self: *Self, _: Ctx) Result {
self.menu.select_last(); self.menu.select_last();
} }
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 {
self.menu.select_first(); self.menu.select_first();
} }
pub const palette_menu_pageup_meta = .{}; pub const palette_menu_pageup_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;
@ -330,7 +331,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;
@ -338,20 +339,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} };
}; };

View file

@ -366,6 +366,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 {
@ -383,7 +384,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| {
@ -398,7 +399,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) {
@ -410,7 +411,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)
@ -421,7 +422,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")) {
@ -436,33 +437,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;
@ -470,7 +471,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;
@ -478,22 +479,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} };
}; };
}; };
} }

View file

@ -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" };
}; };

View file

@ -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 {

View file

@ -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 and tui.config().show_fileicons) { if (self.file_icon.len > 0 and tui.config().show_fileicons) {
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 and tui.config().show_fileicons) { if (self.file_icon.len > 0 and tui.config().show_fileicons) {
self.render_file_icon(plane, theme); self.render_file_icon(plane, theme);

View file

@ -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);

View file

@ -428,7 +428,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,
@ -447,7 +447,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,
@ -462,7 +462,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 {

View file

@ -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 project_manager.start(); try project_manager.start();
@ -146,7 +146,7 @@ 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 save_config(); try save_config();
@ -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,53 +848,53 @@ 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 enter_mode_default(self, .{}); if (self.input_mode_outer_ == null) return enter_mode_default(self, .{});
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 {
if (get_active_selection(self.allocator)) |text| { if (get_active_selection(self.allocator)) |text| {
@ -908,43 +908,43 @@ const cmds = struct {
} }
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;
@ -985,27 +985,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 {
@ -1024,43 +1024,43 @@ fn current() *Self {
} }
pub fn rdr() *renderer { pub fn rdr() *renderer {
return &current().rdr; return &current().rdr_;
} }
pub fn message_filters() *MessageFilter.List { pub fn message_filters() *MessageFilter.List {
return &current().message_filters; return &current().message_filters_;
} }
pub fn input_listeners() *EventHandler.List { pub fn input_listeners() *EventHandler.List {
return &current().input_listeners; return &current().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 &current().config; return &current().config_;
} }
pub fn config_mut() *@import("config") { pub fn config_mut() *@import("config") {
return &current().config; return &current().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 {
@ -1084,9 +1084,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";
@ -1094,7 +1094,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 {
@ -1117,11 +1117,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 {
@ -1137,15 +1137,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 &current().theme; return &current().theme_;
} }
pub fn get_theme_by_name(name: []const u8) ?Widget.Theme { pub fn get_theme_by_name(name: []const u8) ?Widget.Theme {
@ -1263,15 +1263,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,
@ -1291,7 +1291,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 {

View file

@ -41,12 +41,12 @@ pub const Font = struct {
); );
if (hr < 0) std.debug.panic( if (hr < 0) std.debug.panic(
"CreateTextFormat '{}' height {d} failed, hresult=0x{x}", "CreateTextFormat '{}' height {d} failed, hresult=0x{x}",
.{ std.unicode.fmtUtf16le(face.slice()), size, @as(u32, @bitCast(hr)) }, .{ std.unicode.fmtUtf16Le(face.slice()), size, @as(u32, @bitCast(hr)) },
); );
} }
errdefer _ = text_format.IUnknown.Release(); errdefer _ = text_format.IUnknown.Release();
const cell_size = blk: { const cell_size: XY(u16) = blk: {
var text_layout: *win32.IDWriteTextLayout = undefined; var text_layout: *win32.IDWriteTextLayout = undefined;
{ {
const hr = global.dwrite_factory.CreateTextLayout( const hr = global.dwrite_factory.CreateTextLayout(

View file

@ -143,7 +143,7 @@ fn getConfig() *gui_config {
} }
fn getFieldDefault(field: std.builtin.Type.StructField) ?*const field.type { fn getFieldDefault(field: std.builtin.Type.StructField) ?*const field.type {
return @alignCast(@ptrCast(field.default_value orelse return null)); return @alignCast(@ptrCast(field.default_value_ptr orelse return null));
} }
fn getDefaultFontFace() FontFace { fn getDefaultFontFace() FontFace {