build: update to zig 0.14.0-dev.3039
This commit is contained in:
parent
1764b3259c
commit
53045123c6
41 changed files with 648 additions and 623 deletions
|
@ -67,18 +67,19 @@ pub fn Create(options: type) type {
|
|||
const cmds = struct {
|
||||
pub const Target = Self;
|
||||
const Ctx = command.Context;
|
||||
const Meta = command.Metadata;
|
||||
const Result = command.Result;
|
||||
|
||||
pub fn mini_mode_reset(self: *Self, _: Ctx) Result {
|
||||
self.input.clearRetainingCapacity();
|
||||
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 {
|
||||
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 {
|
||||
if (self.input.items.len > 0) {
|
||||
|
@ -86,7 +87,7 @@ pub fn Create(options: type) type {
|
|||
}
|
||||
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 {
|
||||
var egc: u32 = 0;
|
||||
|
@ -97,7 +98,7 @@ pub fn Create(options: type) type {
|
|||
try self.input.appendSlice(buf[0..bytes]);
|
||||
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 {
|
||||
var bytes: []const u8 = undefined;
|
||||
|
@ -106,18 +107,18 @@ pub fn Create(options: type) type {
|
|||
try self.input.appendSlice(bytes);
|
||||
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 {
|
||||
options.select(self);
|
||||
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 {
|
||||
return mini_mode_insert_bytes(self, ctx);
|
||||
}
|
||||
pub const mini_mode_paste_meta = .{ .arguments = &.{.string} };
|
||||
pub const mini_mode_paste_meta: Meta = .{ .arguments = &.{.string} };
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -250,6 +250,7 @@ pub fn Create(options: type) type {
|
|||
const cmds = struct {
|
||||
pub const Target = Self;
|
||||
const Ctx = command.Context;
|
||||
const Meta = command.Metadata;
|
||||
const Result = command.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.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 {
|
||||
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 {
|
||||
self.delete_to_previous_path_segment();
|
||||
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 {
|
||||
if (self.file_path.items.len > 0) {
|
||||
|
@ -277,25 +278,25 @@ pub fn Create(options: type) type {
|
|||
}
|
||||
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 {
|
||||
self.try_complete_file() catch |e| return tp.exit_error(e, @errorReturnTrace());
|
||||
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 {
|
||||
self.complete_trigger_count = 0;
|
||||
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 {
|
||||
self.reverse_complete_file() catch |e| return tp.exit_error(e, @errorReturnTrace());
|
||||
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 {
|
||||
var egc: u32 = 0;
|
||||
|
@ -307,7 +308,7 @@ pub fn Create(options: type) type {
|
|||
try self.file_path.appendSlice(buf[0..bytes]);
|
||||
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 {
|
||||
var bytes: []const u8 = undefined;
|
||||
|
@ -317,18 +318,18 @@ pub fn Create(options: type) type {
|
|||
try self.file_path.appendSlice(bytes);
|
||||
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 {
|
||||
options.select(self);
|
||||
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 {
|
||||
return mini_mode_insert_bytes(self, ctx);
|
||||
}
|
||||
pub const mini_mode_paste_meta = .{ .arguments = &.{.string} };
|
||||
pub const mini_mode_paste_meta: Meta = .{ .arguments = &.{.string} };
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ const name = " find";
|
|||
const Commands = command.Collection(cmds);
|
||||
|
||||
allocator: Allocator,
|
||||
input: ArrayList(u8),
|
||||
input_: ArrayList(u8),
|
||||
last_input: ArrayList(u8),
|
||||
start_view: ed.View,
|
||||
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);
|
||||
self.* = .{
|
||||
.allocator = allocator,
|
||||
.input = ArrayList(u8).init(allocator),
|
||||
.input_ = ArrayList(u8).init(allocator),
|
||||
.last_input = ArrayList(u8).init(allocator),
|
||||
.start_view = editor.view,
|
||||
.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: {
|
||||
const text = editor.get_selection(sel, self.allocator) catch break :ret;
|
||||
defer self.allocator.free(text);
|
||||
try self.input.appendSlice(text);
|
||||
try self.input_.appendSlice(text);
|
||||
}
|
||||
var mode = try keybind.mode("mini/find", allocator, .{
|
||||
.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 {
|
||||
self.commands.deinit();
|
||||
self.input.deinit();
|
||||
self.input_.deinit();
|
||||
self.last_input.deinit();
|
||||
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 {
|
||||
var buf: [16]u8 = undefined;
|
||||
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 {
|
||||
try self.input.appendSlice(bytes);
|
||||
try self.input_.appendSlice(bytes);
|
||||
}
|
||||
|
||||
fn flush_input(self: *Self) !void {
|
||||
if (self.input.items.len > 0) {
|
||||
if (eql(u8, self.input.items, self.last_input.items))
|
||||
if (self.input_.items.len > 0) {
|
||||
if (eql(u8, self.input_.items, self.last_input.items))
|
||||
return;
|
||||
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;
|
||||
const primary = self.editor.get_primary();
|
||||
primary.selection = null;
|
||||
primary.cursor = self.start_cursor;
|
||||
try self.editor.find_in_buffer(self.input.items);
|
||||
try self.editor.find_in_buffer(self.input_.items);
|
||||
} else {
|
||||
self.editor.get_primary().selection = null;
|
||||
self.editor.init_matches_update();
|
||||
|
@ -114,9 +114,9 @@ fn find_history_prev(self: *Self) void {
|
|||
if (pos > 0) self.history_pos = pos - 1;
|
||||
} else {
|
||||
self.history_pos = history.items.len - 1;
|
||||
if (self.input.items.len > 0)
|
||||
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 (self.input_.items.len > 0)
|
||||
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)
|
||||
self.history_pos = self.history_pos.? - 1;
|
||||
}
|
||||
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 {
|
||||
if (self.editor.find_history) |*history| {
|
||||
self.input.clearRetainingCapacity();
|
||||
self.input.appendSlice(history.items[pos]) catch {};
|
||||
self.input_.clearRetainingCapacity();
|
||||
self.input_.appendSlice(history.items[pos]) catch {};
|
||||
}
|
||||
}
|
||||
|
||||
fn update_mini_mode_text(self: *Self) void {
|
||||
if (tui.mini_mode()) |mini_mode| {
|
||||
mini_mode.text = self.input.items;
|
||||
mini_mode.cursor = tui.egc_chunk_width(self.input.items, 0, 8);
|
||||
mini_mode.text = self.input_.items;
|
||||
mini_mode.cursor = tui.egc_chunk_width(self.input_.items, 0, 8);
|
||||
}
|
||||
}
|
||||
|
||||
const cmds = struct {
|
||||
pub const Target = Self;
|
||||
const Ctx = command.Context;
|
||||
const Meta = command.Metadata;
|
||||
const Result = command.Result;
|
||||
|
||||
pub fn mini_mode_reset(self: *Self, _: Ctx) Result {
|
||||
self.input.clearRetainingCapacity();
|
||||
self.input_.clearRetainingCapacity();
|
||||
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 {
|
||||
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 {
|
||||
self.editor.push_find_history(self.input.items);
|
||||
self.editor.push_find_history(self.input_.items);
|
||||
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 {
|
||||
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.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 {
|
||||
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.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 {
|
||||
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();
|
||||
}
|
||||
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 {
|
||||
self.find_history_prev();
|
||||
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 {
|
||||
self.find_history_next();
|
||||
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 {
|
||||
return mini_mode_insert_bytes(self, ctx);
|
||||
}
|
||||
pub const mini_mode_paste_meta = .{ .arguments = &.{.string} };
|
||||
pub const mini_mode_paste_meta: Meta = .{ .arguments = &.{.string} };
|
||||
};
|
||||
|
|
|
@ -19,7 +19,7 @@ const max_query_size = 1024;
|
|||
|
||||
allocator: Allocator,
|
||||
buf: [max_query_size]u8 = undefined,
|
||||
input: []u8 = "",
|
||||
input_: []u8 = "",
|
||||
last_buf: [max_query_size]u8 = undefined,
|
||||
last_input: []u8 = "",
|
||||
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| {
|
||||
defer self.allocator.free(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, .{
|
||||
.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 {
|
||||
if (self.input.len + 6 >= self.buf.len)
|
||||
if (self.input_.len + 6 >= self.buf.len)
|
||||
return;
|
||||
const bytes = try input.ucs32_to_utf8(&[_]u32{c}, self.buf[self.input.len..]);
|
||||
self.input = self.buf[0 .. self.input.len + bytes];
|
||||
const bytes = try input.ucs32_to_utf8(&[_]u32{c}, self.buf[self.input_.len..]);
|
||||
self.input_ = self.buf[0 .. self.input_.len + bytes];
|
||||
}
|
||||
|
||||
fn insert_bytes(self: *Self, bytes_: []const u8) !void {
|
||||
const bytes = bytes_[0..@min(self.buf.len - self.input.len, bytes_.len)];
|
||||
const newlen = self.input.len + bytes.len;
|
||||
@memcpy(self.buf[self.input.len..newlen], bytes);
|
||||
self.input = self.buf[0..newlen];
|
||||
const bytes = bytes_[0..@min(self.buf.len - self.input_.len, bytes_.len)];
|
||||
const newlen = self.input_.len + bytes.len;
|
||||
@memcpy(self.buf[self.input_.len..newlen], bytes);
|
||||
self.input_ = self.buf[0..newlen];
|
||||
}
|
||||
|
||||
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;
|
||||
@memcpy(self.last_buf[0..self.input.len], self.input);
|
||||
self.last_input = self.last_buf[0..self.input.len];
|
||||
try command.executeName("find_in_files_query", command.fmt(.{self.input}));
|
||||
@memcpy(self.last_buf[0..self.input_.len], self.input_);
|
||||
self.last_input = self.last_buf[0..self.input_.len];
|
||||
try command.executeName("find_in_files_query", command.fmt(.{self.input_}));
|
||||
}
|
||||
|
||||
fn update_mini_mode_text(self: *Self) void {
|
||||
if (tui.mini_mode()) |mini_mode| {
|
||||
mini_mode.text = self.input;
|
||||
mini_mode.cursor = tui.egc_chunk_width(self.input, 0, 8);
|
||||
mini_mode.text = self.input_;
|
||||
mini_mode.cursor = tui.egc_chunk_width(self.input_, 0, 8);
|
||||
}
|
||||
}
|
||||
|
||||
const cmds = struct {
|
||||
pub const Target = Self;
|
||||
const Ctx = command.Context;
|
||||
const Meta = command.Metadata;
|
||||
const Result = command.Result;
|
||||
|
||||
pub fn mini_mode_reset(self: *Self, _: Ctx) Result {
|
||||
self.input = "";
|
||||
self.input_ = "";
|
||||
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 {
|
||||
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 {
|
||||
command.executeName("goto_selected_file", .{}) catch {};
|
||||
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 {
|
||||
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.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 {
|
||||
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.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 {
|
||||
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();
|
||||
}
|
||||
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 {
|
||||
return mini_mode_insert_bytes(self, ctx);
|
||||
}
|
||||
pub const mini_mode_paste_meta = .{ .arguments = &.{.string} };
|
||||
pub const mini_mode_paste_meta: Meta = .{ .arguments = &.{.string} };
|
||||
};
|
||||
|
|
|
@ -82,13 +82,14 @@ fn insert_bytes(self: *Self, bytes: []const u8) void {
|
|||
const cmds = struct {
|
||||
pub const Target = Self;
|
||||
const Ctx = command.Context;
|
||||
const Meta = command.Metadata;
|
||||
const Result = command.Result;
|
||||
|
||||
pub fn mini_mode_reset(self: *Self, _: Ctx) Result {
|
||||
self.input = null;
|
||||
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 {
|
||||
self.input = null;
|
||||
|
@ -96,7 +97,7 @@ const cmds = struct {
|
|||
self.goto();
|
||||
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 {
|
||||
if (self.input) |linenum| {
|
||||
|
@ -106,7 +107,7 @@ const cmds = struct {
|
|||
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 {
|
||||
var keypress: usize = 0;
|
||||
|
@ -119,7 +120,7 @@ const cmds = struct {
|
|||
self.update_mini_mode_text();
|
||||
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 {
|
||||
var bytes: []const u8 = undefined;
|
||||
|
@ -129,5 +130,5 @@ const cmds = struct {
|
|||
self.update_mini_mode_text();
|
||||
self.goto();
|
||||
}
|
||||
pub const mini_mode_insert_bytes_meta = .{ .arguments = &.{.string} };
|
||||
pub const mini_mode_insert_bytes_meta: Meta = .{ .arguments = &.{.string} };
|
||||
};
|
||||
|
|
|
@ -87,6 +87,7 @@ fn execute_operation(self: *Self, ctx: command.Context) command.Result {
|
|||
const cmds = struct {
|
||||
pub const Target = Self;
|
||||
const Ctx = command.Context;
|
||||
const Meta = command.Metadata;
|
||||
const Result = command.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;
|
||||
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 {
|
||||
var bytes: []const u8 = undefined;
|
||||
|
@ -105,10 +106,10 @@ const cmds = struct {
|
|||
return error.InvalidMoveToCharInsertBytesArgument;
|
||||
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 {
|
||||
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" };
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue