Compare commits
No commits in common. "c537adbcddc58cba623c08f722f08aa7e3ea84f1" and "53e724f26587352f1f4d7c115734788b9d7cb65d" have entirely different histories.
c537adbcdd
...
53e724f265
11 changed files with 26 additions and 56 deletions
|
|
@ -293,7 +293,6 @@ pub fn build_exe(
|
|||
.imports = &.{
|
||||
.{ .name = "cbor", .module = cbor_mod },
|
||||
.{ .name = "thespian", .module = thespian_mod },
|
||||
.{ .name = "CaseData", .module = zg_dep.module("CaseData") },
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -477,6 +476,7 @@ pub fn build_exe(
|
|||
.{ .name = "color", .module = color_mod },
|
||||
.{ .name = "diff", .module = diff_mod },
|
||||
.{ .name = "help.md", .module = help_mod },
|
||||
.{ .name = "CaseData", .module = zg_dep.module("CaseData") },
|
||||
.{ .name = "fuzzig", .module = fuzzig_dep.module("fuzzig") },
|
||||
.{ .name = "zeit", .module = zeit_mod },
|
||||
},
|
||||
|
|
@ -502,7 +502,6 @@ pub fn build_exe(
|
|||
exe.root_module.addImport("flags", flags_dep.module("flags"));
|
||||
exe.root_module.addImport("cbor", cbor_mod);
|
||||
exe.root_module.addImport("config", config_mod);
|
||||
exe.root_module.addImport("Buffer", Buffer_mod);
|
||||
exe.root_module.addImport("tui", tui_mod);
|
||||
exe.root_module.addImport("thespian", thespian_mod);
|
||||
exe.root_module.addImport("log", log_mod);
|
||||
|
|
@ -544,7 +543,6 @@ pub fn build_exe(
|
|||
check_exe.root_module.addImport("flags", flags_dep.module("flags"));
|
||||
check_exe.root_module.addImport("cbor", cbor_mod);
|
||||
check_exe.root_module.addImport("config", config_mod);
|
||||
check_exe.root_module.addImport("Buffer", Buffer_mod);
|
||||
check_exe.root_module.addImport("tui", tui_mod);
|
||||
check_exe.root_module.addImport("thespian", thespian_mod);
|
||||
check_exe.root_module.addImport("log", log_mod);
|
||||
|
|
@ -552,7 +550,6 @@ pub fn build_exe(
|
|||
check_exe.root_module.addImport("renderer", renderer_mod);
|
||||
check_exe.root_module.addImport("input", input_mod);
|
||||
check_exe.root_module.addImport("syntax", syntax_mod);
|
||||
check_exe.root_module.addImport("color", color_mod);
|
||||
check_exe.root_module.addImport("version_info", b.createModule(.{ .root_source_file = version_info_file }));
|
||||
check_step.dependOn(&check_exe.step);
|
||||
|
||||
|
|
|
|||
|
|
@ -59,13 +59,3 @@ pub fn utf8_sanitize(allocator: std.mem.Allocator, input: []const u8) error{
|
|||
for (input) |byte| try writer.writeAll(try raw_byte_to_utf8(byte, &buf));
|
||||
return output.toOwnedSlice(allocator);
|
||||
}
|
||||
|
||||
pub const CaseData = @import("CaseData");
|
||||
var case_data: ?CaseData = null;
|
||||
var case_data_arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
|
||||
|
||||
pub fn get_case_data() *CaseData {
|
||||
if (case_data) |*cd| return cd;
|
||||
case_data = CaseData.init(case_data_arena.allocator()) catch @panic("CaseData.init");
|
||||
return &case_data.?;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
fontface: []const u8 = "Cascadia Code",
|
||||
fontface: [] const u8 = "Cascadia Code",
|
||||
fontsize: u8 = 14,
|
||||
|
||||
initial_window_x: u16 = 1087,
|
||||
|
|
|
|||
|
|
@ -102,6 +102,7 @@
|
|||
"line_numbers": "absolute",
|
||||
"cursor": "beam",
|
||||
"press": [
|
||||
["jk", "enter_mode", "normal"],
|
||||
["<Esc>", "enter_mode", "normal"],
|
||||
["<Del>", "delete_forward"],
|
||||
["<BS>", "delete_backward"],
|
||||
|
|
|
|||
14
src/main.zig
14
src/main.zig
|
|
@ -41,8 +41,6 @@ pub fn main() anyerror!void {
|
|||
}
|
||||
|
||||
const a = std.heap.c_allocator;
|
||||
const case_data = @import("Buffer").unicode.get_case_data();
|
||||
_ = case_data; // no need to free case_data as it is globally static
|
||||
|
||||
const Flags = struct {
|
||||
pub const description =
|
||||
|
|
@ -72,8 +70,6 @@ pub fn main() anyerror!void {
|
|||
.syntax_report_timing = "Report syntax highlighting time",
|
||||
.exec = "Execute a command on startup",
|
||||
.literal = "Disable :LINE and +LINE syntax",
|
||||
.scratch = "Open a scratch (temporary) buffer on start",
|
||||
.new_file = "Create a new untitled file on start",
|
||||
.version = "Show build version and exit",
|
||||
};
|
||||
|
||||
|
|
@ -87,8 +83,6 @@ pub fn main() anyerror!void {
|
|||
.language = 'l',
|
||||
.exec = 'e',
|
||||
.literal = 'L',
|
||||
.scratch = 'S',
|
||||
.new_file = 'n',
|
||||
.version = 'v',
|
||||
};
|
||||
|
||||
|
|
@ -110,8 +104,6 @@ pub fn main() anyerror!void {
|
|||
syntax_report_timing: bool,
|
||||
exec: ?[]const u8,
|
||||
literal: bool,
|
||||
scratch: bool,
|
||||
new_file: bool,
|
||||
version: bool,
|
||||
};
|
||||
|
||||
|
|
@ -322,12 +314,6 @@ pub fn main() anyerror!void {
|
|||
try tui_proc.send(.{ "cmd", "show_home" });
|
||||
}
|
||||
|
||||
if (args.new_file) {
|
||||
try tui_proc.send(.{ "cmd", "create_new_file", .{} });
|
||||
} else if (args.scratch) {
|
||||
try tui_proc.send(.{ "cmd", "create_scratch_buffer", .{} });
|
||||
}
|
||||
|
||||
if (args.exec) |exec_str| {
|
||||
var cmds = std.mem.splitScalar(u8, exec_str, ';');
|
||||
while (cmds.next()) |cmd| try tui_proc.send(.{ "cmd", cmd, .{} });
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ pub fn build(b: *std.Build) void {
|
|||
.{ .name = "treez", .module = tree_sitter_dep.module("treez") },
|
||||
ts_queryfile(b, tree_sitter_dep, "queries/cmake/highlights.scm"),
|
||||
ts_queryfile(b, tree_sitter_dep, "tree-sitter-agda/queries/highlights.scm"),
|
||||
ts_queryfile(b, tree_sitter_dep, "tree-sitter-astro/queries/highlights.scm"),
|
||||
ts_queryfile(b, tree_sitter_dep, "tree-sitter-bash/queries/highlights.scm"),
|
||||
ts_queryfile(b, tree_sitter_dep, "tree-sitter-c-sharp/queries/highlights.scm"),
|
||||
ts_queryfile(b, tree_sitter_dep, "tree-sitter-c/queries/highlights.scm"),
|
||||
|
|
@ -81,7 +80,6 @@ pub fn build(b: *std.Build) void {
|
|||
ts_queryfile(b, tree_sitter_dep, "nvim-treesitter/queries/verilog/highlights.scm"),
|
||||
|
||||
ts_queryfile(b, tree_sitter_dep, "queries/cmake/injections.scm"),
|
||||
ts_queryfile(b, tree_sitter_dep, "tree-sitter-astro/queries/injections.scm"),
|
||||
ts_queryfile(b, tree_sitter_dep, "tree-sitter-cpp/queries/injections.scm"),
|
||||
ts_queryfile(b, tree_sitter_dep, "tree-sitter-elixir/queries/injections.scm"),
|
||||
ts_queryfile(b, tree_sitter_dep, "tree-sitter-gitcommit/queries/injections.scm"),
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
.dependencies = .{
|
||||
.@"tree-sitter" = .{
|
||||
.url = "https://github.com/neurocyte/tree-sitter/releases/download/master-86dd4d2536f2748c5b4ea0e1e70678039a569aac/source.tar.gz",
|
||||
.hash = "1220e9fba96c468283129e977767472dee00b16f356e5912431cec8f1a009b6691a2",
|
||||
.url = "https://github.com/neurocyte/tree-sitter/releases/download/master-69775ce3ba8a5e331bba9feb760d1ba31394eea7/source.tar.gz",
|
||||
.hash = "1220f9702ca6257f5464b31e576b1e92b0f441bf0e61733c4a2fbf95b7c0c55a3e22",
|
||||
},
|
||||
},
|
||||
.paths = .{
|
||||
|
|
|
|||
|
|
@ -4,14 +4,6 @@ pub const agda = .{
|
|||
.comment = "--",
|
||||
};
|
||||
|
||||
pub const astro = .{
|
||||
.description = "Astro",
|
||||
.icon = "",
|
||||
.extensions = .{"astro"},
|
||||
.comment = "//",
|
||||
.language_server = .{ "astro-ls", "--stdio" },
|
||||
};
|
||||
|
||||
pub const bash = .{
|
||||
.description = "Bash",
|
||||
.color = 0x3e474a,
|
||||
|
|
@ -445,7 +437,7 @@ pub const scheme = .{
|
|||
pub const sql = .{
|
||||
.description = "SQL",
|
||||
.icon = "",
|
||||
.extensions = .{"sql"},
|
||||
.extensions = .{ "sql" },
|
||||
.comment = "--",
|
||||
};
|
||||
|
||||
|
|
@ -472,7 +464,7 @@ pub const verilog = .{
|
|||
.highlights = "nvim-treesitter/queries/verilog/highlights.scm",
|
||||
.injections = "nvim-treesitter/queries/verilog/injections.scm",
|
||||
.language_server = .{"verible-verilog-ls"},
|
||||
.formatter = .{ "verible-verilog-format", "-" },
|
||||
.formatter = .{ "verible-verilog-format", "-" }
|
||||
};
|
||||
|
||||
pub const toml = .{
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ const tracy = @import("tracy");
|
|||
const text_manip = @import("text_manip");
|
||||
const syntax = @import("syntax");
|
||||
const project_manager = @import("project_manager");
|
||||
const CaseData = @import("CaseData");
|
||||
const root_mod = @import("root");
|
||||
|
||||
const Plane = @import("renderer").Plane;
|
||||
|
|
@ -349,6 +350,8 @@ pub const Editor = struct {
|
|||
} = null,
|
||||
} = null,
|
||||
|
||||
case_data: ?CaseData = null,
|
||||
|
||||
const WhitespaceMode = enum { indent, leading, eol, tabs, visible, full, none };
|
||||
const StyleCache = std.AutoHashMap(u32, ?Widget.Theme.Token);
|
||||
|
||||
|
|
@ -465,6 +468,7 @@ pub const Editor = struct {
|
|||
self.handlers.deinit();
|
||||
self.logger.deinit();
|
||||
if (self.buffer) |p| self.buffer_manager.retire(p, meta.items);
|
||||
if (self.case_data) |cd| cd.deinit();
|
||||
}
|
||||
|
||||
fn from_whitespace_mode(whitespace_mode: []const u8) WhitespaceMode {
|
||||
|
|
@ -488,6 +492,12 @@ pub const Editor = struct {
|
|||
Widget.need_render();
|
||||
}
|
||||
|
||||
fn get_case_data(self: *Self) *CaseData {
|
||||
if (self.case_data) |*cd| return cd;
|
||||
self.case_data = CaseData.init(self.allocator) catch @panic("CaseData.init");
|
||||
return &self.case_data.?;
|
||||
}
|
||||
|
||||
fn buf_for_update(self: *Self) !*const Buffer {
|
||||
if (!self.pause_undo) {
|
||||
self.cursels_saved.clearAndFree();
|
||||
|
|
@ -4072,10 +4082,7 @@ pub const Editor = struct {
|
|||
} else if (ctx.args.match(.{tp.extract(&file_path)}) catch false) {
|
||||
try self.open_scratch(file_path, "", null);
|
||||
self.clamp();
|
||||
} else {
|
||||
try self.open_scratch("*scratch*", "", null);
|
||||
self.clamp();
|
||||
}
|
||||
} else return error.InvalidOpenScratchBufferArgument;
|
||||
}
|
||||
pub const open_scratch_buffer_meta = .{ .arguments = &.{ .string, .string } };
|
||||
|
||||
|
|
@ -4959,7 +4966,7 @@ pub const Editor = struct {
|
|||
var sfa = std.heap.stackFallback(4096, self.allocator);
|
||||
const cut_text = copy_selection(root, sel.*, sfa.get(), self.metrics) catch return error.Stop;
|
||||
defer allocator.free(cut_text);
|
||||
const ucased = Buffer.unicode.get_case_data().toUpperStr(allocator, cut_text) catch return error.Stop;
|
||||
const ucased = self.get_case_data().toUpperStr(allocator, cut_text) catch return error.Stop;
|
||||
defer allocator.free(ucased);
|
||||
root = try self.delete_selection(root, cursel, allocator);
|
||||
root = self.insert(root, cursel, ucased, allocator) catch return error.Stop;
|
||||
|
|
@ -4987,7 +4994,7 @@ pub const Editor = struct {
|
|||
var sfa = std.heap.stackFallback(4096, self.allocator);
|
||||
const cut_text = copy_selection(root, sel.*, sfa.get(), self.metrics) catch return error.Stop;
|
||||
defer allocator.free(cut_text);
|
||||
const ucased = Buffer.unicode.get_case_data().toLowerStr(allocator, cut_text) catch return error.Stop;
|
||||
const ucased = self.get_case_data().toLowerStr(allocator, cut_text) catch return error.Stop;
|
||||
defer allocator.free(ucased);
|
||||
root = try self.delete_selection(root, cursel, allocator);
|
||||
root = self.insert(root, cursel, ucased, allocator) catch return error.Stop;
|
||||
|
|
@ -5018,9 +5025,9 @@ pub const Editor = struct {
|
|||
self_: *Self,
|
||||
result: *std.ArrayList(u8),
|
||||
|
||||
const Error = @typeInfo(@typeInfo(@TypeOf(Buffer.unicode.CaseData.toUpperStr)).Fn.return_type.?).ErrorUnion.error_set;
|
||||
const Error = @typeInfo(@typeInfo(@TypeOf(CaseData.toUpperStr)).Fn.return_type.?).ErrorUnion.error_set;
|
||||
pub fn write(writer: *@This(), bytes: []const u8) Error!void {
|
||||
const cd = Buffer.unicode.get_case_data();
|
||||
const cd = writer.self_.get_case_data();
|
||||
const flipped = if (cd.isLowerStr(bytes))
|
||||
try cd.toUpperStr(writer.self_.allocator, bytes)
|
||||
else
|
||||
|
|
|
|||
|
|
@ -465,8 +465,7 @@ const cmds = struct {
|
|||
}
|
||||
}
|
||||
try command.executeName("create_scratch_buffer", command.fmt(.{name.items}));
|
||||
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…" };
|
||||
|
||||
|
|
|
|||
|
|
@ -868,7 +868,7 @@ const cmds = struct {
|
|||
|
||||
pub fn exit_overlay_mode(self: *Self, _: Ctx) Result {
|
||||
self.rdr.cursor_disable();
|
||||
if (self.input_mode_outer == null) return enter_mode_default(self, .{});
|
||||
if (self.input_mode_outer == null) return;
|
||||
if (self.input_mode) |*mode| mode.deinit();
|
||||
self.input_mode = self.input_mode_outer;
|
||||
self.input_mode_outer = null;
|
||||
|
|
@ -1290,8 +1290,7 @@ pub fn message(comptime fmt: anytype, args: anytype) void {
|
|||
tp.self_pid().send(.{ "message", std.fmt.bufPrint(&buf, fmt, args) catch @panic("too large") }) catch {};
|
||||
}
|
||||
|
||||
pub fn render_file_icon(self: *renderer.Plane, icon: []const u8, color: u24) void {
|
||||
var cell = self.cell_init();
|
||||
pub fn render_file_icon(self: *renderer.Plane, icon: []const u8, color: u24) void { var cell = self.cell_init();
|
||||
_ = self.at_cursor_cell(&cell) catch return;
|
||||
if (!(color == 0xFFFFFF or color == 0x000000 or color == 0x000001)) {
|
||||
cell.set_fg_rgb(@intCast(color)) catch {};
|
||||
|
|
@ -1308,3 +1307,4 @@ pub fn render_match_cell(self: *renderer.Plane, y: usize, x: usize, theme_: *con
|
|||
cell.set_style(theme_.editor_match);
|
||||
_ = self.putc(&cell) catch {};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue