Compare commits
4 commits
a98d4e02a7
...
aee7c30c65
| Author | SHA1 | Date | |
|---|---|---|---|
| aee7c30c65 | |||
| 009972309c | |||
| 68a5de5aa7 | |||
| 1ebdae310e |
6 changed files with 121 additions and 22 deletions
|
|
@ -44,6 +44,7 @@ file_utf8_sanitized: bool = false,
|
||||||
hidden: bool = false,
|
hidden: bool = false,
|
||||||
ephemeral: bool = false,
|
ephemeral: bool = false,
|
||||||
meta: ?[]const u8 = null,
|
meta: ?[]const u8 = null,
|
||||||
|
lsp_version: usize = 1,
|
||||||
|
|
||||||
undo_history: ?*UndoNode = null,
|
undo_history: ?*UndoNode = null,
|
||||||
redo_history: ?*UndoNode = null,
|
redo_history: ?*UndoNode = null,
|
||||||
|
|
|
||||||
|
|
@ -271,7 +271,6 @@ pub const Editor = struct {
|
||||||
file_path: ?[]const u8,
|
file_path: ?[]const u8,
|
||||||
buffer: ?*Buffer,
|
buffer: ?*Buffer,
|
||||||
buffer_manager: *Buffer.Manager,
|
buffer_manager: *Buffer.Manager,
|
||||||
lsp_version: usize = 1,
|
|
||||||
pause_undo: bool = false,
|
pause_undo: bool = false,
|
||||||
pause_undo_root: ?Buffer.Root = null,
|
pause_undo_root: ?Buffer.Root = null,
|
||||||
|
|
||||||
|
|
@ -331,6 +330,7 @@ pub const Editor = struct {
|
||||||
dirty: bool = false,
|
dirty: bool = false,
|
||||||
eol_mode: Buffer.EolMode = .lf,
|
eol_mode: Buffer.EolMode = .lf,
|
||||||
utf8_sanitized: bool = false,
|
utf8_sanitized: bool = false,
|
||||||
|
indent_mode: IndentMode = .spaces,
|
||||||
} = .{},
|
} = .{},
|
||||||
|
|
||||||
file_type: ?file_type_config = null,
|
file_type: ?file_type_config = null,
|
||||||
|
|
@ -642,7 +642,7 @@ pub const Editor = struct {
|
||||||
project_manager.did_open(
|
project_manager.did_open(
|
||||||
file_path,
|
file_path,
|
||||||
ft,
|
ft,
|
||||||
self.lsp_version,
|
new_buf.lsp_version,
|
||||||
try content.toOwnedSlice(std.heap.c_allocator),
|
try content.toOwnedSlice(std.heap.c_allocator),
|
||||||
new_buf.is_ephemeral(),
|
new_buf.is_ephemeral(),
|
||||||
) catch |e|
|
) catch |e|
|
||||||
|
|
@ -1644,11 +1644,12 @@ pub const Editor = struct {
|
||||||
|
|
||||||
if (token_from(self.last.root) != token_from(root)) {
|
if (token_from(self.last.root) != token_from(root)) {
|
||||||
try self.send_editor_update(self.last.root, root, eol_mode);
|
try self.send_editor_update(self.last.root, root, eol_mode);
|
||||||
self.lsp_version += 1;
|
if (self.buffer) |buf|
|
||||||
|
buf.lsp_version += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.last.eol_mode != eol_mode or self.last.utf8_sanitized != utf8_sanitized)
|
if (self.last.eol_mode != eol_mode or self.last.utf8_sanitized != utf8_sanitized or self.last.indent_mode != self.indent_mode)
|
||||||
try self.send_editor_eol_mode(eol_mode, utf8_sanitized);
|
try self.send_editor_eol_mode(eol_mode, utf8_sanitized, self.indent_mode);
|
||||||
|
|
||||||
if (self.last.dirty != dirty)
|
if (self.last.dirty != dirty)
|
||||||
try self.send_editor_dirty(dirty);
|
try self.send_editor_dirty(dirty);
|
||||||
|
|
@ -1769,14 +1770,14 @@ pub const Editor = struct {
|
||||||
|
|
||||||
fn send_editor_update(self: *const Self, old_root: ?Buffer.Root, new_root: ?Buffer.Root, eol_mode: Buffer.EolMode) !void {
|
fn send_editor_update(self: *const Self, old_root: ?Buffer.Root, new_root: ?Buffer.Root, eol_mode: Buffer.EolMode) !void {
|
||||||
_ = try self.handlers.msg(.{ "E", "update", token_from(new_root), token_from(old_root), @intFromEnum(eol_mode) });
|
_ = try self.handlers.msg(.{ "E", "update", token_from(new_root), token_from(old_root), @intFromEnum(eol_mode) });
|
||||||
if (self.syntax) |_| if (self.file_path) |file_path| if (old_root != null and new_root != null)
|
if (self.buffer) |buffer| if (self.syntax) |_| if (self.file_path) |file_path| if (old_root != null and new_root != null)
|
||||||
project_manager.did_change(file_path, self.lsp_version, try text_from_root(new_root, eol_mode), try text_from_root(old_root, eol_mode), eol_mode) catch {};
|
project_manager.did_change(file_path, buffer.lsp_version, try text_from_root(new_root, eol_mode), try text_from_root(old_root, eol_mode), eol_mode) catch {};
|
||||||
if (self.enable_auto_save)
|
if (self.enable_auto_save)
|
||||||
tp.self_pid().send(.{ "cmd", "save_file", .{} }) catch {};
|
tp.self_pid().send(.{ "cmd", "save_file", .{} }) catch {};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_editor_eol_mode(self: *const Self, eol_mode: Buffer.EolMode, utf8_sanitized: bool) !void {
|
fn send_editor_eol_mode(self: *const Self, eol_mode: Buffer.EolMode, utf8_sanitized: bool, indent_mode: IndentMode) !void {
|
||||||
_ = try self.handlers.msg(.{ "E", "eol_mode", @intFromEnum(eol_mode), utf8_sanitized });
|
_ = try self.handlers.msg(.{ "E", "eol_mode", eol_mode, utf8_sanitized, indent_mode });
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clamp_abs(self: *Self, abs: bool) void {
|
fn clamp_abs(self: *Self, abs: bool) void {
|
||||||
|
|
@ -5986,11 +5987,11 @@ pub const Editor = struct {
|
||||||
const root = try self.buf_root();
|
const root = try self.buf_root();
|
||||||
try root.store(content.writer(std.heap.c_allocator), try self.buf_eol_mode());
|
try root.store(content.writer(std.heap.c_allocator), try self.buf_eol_mode());
|
||||||
|
|
||||||
if (self.file_path) |file_path|
|
if (self.buffer) |buffer| if (self.file_path) |file_path|
|
||||||
project_manager.did_open(
|
project_manager.did_open(
|
||||||
file_path,
|
file_path,
|
||||||
ft,
|
ft,
|
||||||
self.lsp_version,
|
buffer.lsp_version,
|
||||||
try content.toOwnedSlice(std.heap.c_allocator),
|
try content.toOwnedSlice(std.heap.c_allocator),
|
||||||
if (self.buffer) |p| p.is_ephemeral() else true,
|
if (self.buffer) |p| p.is_ephemeral() else true,
|
||||||
) catch |e|
|
) catch |e|
|
||||||
|
|
|
||||||
|
|
@ -1303,6 +1303,10 @@ pub fn write_restore_info(self: *Self) void {
|
||||||
const buffer_manager = tui.get_buffer_manager() orelse @panic("tabs no buffer manager");
|
const buffer_manager = tui.get_buffer_manager() orelse @panic("tabs no buffer manager");
|
||||||
buffer_manager.write_state(writer) catch return;
|
buffer_manager.write_state(writer) catch return;
|
||||||
|
|
||||||
|
if (self.widgets.get("tabs")) |tabs_widget|
|
||||||
|
if (tabs_widget.dynamic_cast(@import("status/tabs.zig").TabBar)) |tabs|
|
||||||
|
tabs.write_state(writer) catch return;
|
||||||
|
|
||||||
const file_name = root.get_restore_file_name() catch return;
|
const file_name = root.get_restore_file_name() catch return;
|
||||||
var file = std.fs.createFileAbsolute(file_name, .{ .truncate = true }) catch return;
|
var file = std.fs.createFileAbsolute(file_name, .{ .truncate = true }) catch return;
|
||||||
defer file.close();
|
defer file.close();
|
||||||
|
|
@ -1324,6 +1328,19 @@ fn read_restore_info(self: *Self) !void {
|
||||||
if (!try cbor.matchValue(&iter, cbor.extract(&editor_file_path))) return error.Stop;
|
if (!try cbor.matchValue(&iter, cbor.extract(&editor_file_path))) return error.Stop;
|
||||||
try self.buffer_manager.extract_state(&iter);
|
try self.buffer_manager.extract_state(&iter);
|
||||||
|
|
||||||
|
if (self.widgets.get("tabs")) |tabs_widget|
|
||||||
|
if (tabs_widget.dynamic_cast(@import("status/tabs.zig").TabBar)) |tabs|
|
||||||
|
tabs.extract_state(&iter) catch |e| {
|
||||||
|
const logger = log.logger("mainview");
|
||||||
|
defer logger.deinit();
|
||||||
|
logger.print_err("mainview", "failed to restore tabs: {}", .{e});
|
||||||
|
};
|
||||||
|
|
||||||
|
const buffers = try self.buffer_manager.list_unordered(self.allocator);
|
||||||
|
defer self.allocator.free(buffers);
|
||||||
|
for (buffers) |buffer| if (!buffer.is_ephemeral())
|
||||||
|
send_buffer_did_open(self.allocator, buffer) catch {};
|
||||||
|
|
||||||
if (editor_file_path) |file_path| {
|
if (editor_file_path) |file_path| {
|
||||||
try tp.self_pid().send(.{ "cmd", "navigate", .{ .file = file_path } });
|
try tp.self_pid().send(.{ "cmd", "navigate", .{ .file = file_path } });
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1331,6 +1348,21 @@ fn read_restore_info(self: *Self) !void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn send_buffer_did_open(allocator: std.mem.Allocator, buffer: *Buffer) !void {
|
||||||
|
const ft = try file_type_config.get(buffer.file_type_name orelse return) orelse return;
|
||||||
|
var content = std.ArrayListUnmanaged(u8).empty;
|
||||||
|
defer content.deinit(allocator);
|
||||||
|
try buffer.root.store(content.writer(allocator), buffer.file_eol_mode);
|
||||||
|
|
||||||
|
try project_manager.did_open(
|
||||||
|
buffer.get_file_path(),
|
||||||
|
ft,
|
||||||
|
buffer.lsp_version,
|
||||||
|
try content.toOwnedSlice(allocator),
|
||||||
|
buffer.is_ephemeral(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
fn get_next_mru_buffer(self: *Self) ?[]const u8 {
|
fn get_next_mru_buffer(self: *Self) ?[]const u8 {
|
||||||
const buffers = self.buffer_manager.list_most_recently_used(self.allocator) catch return null;
|
const buffers = self.buffer_manager.list_most_recently_used(self.allocator) catch return null;
|
||||||
defer self.allocator.free(buffers);
|
defer self.allocator.free(buffers);
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ const std = @import("std");
|
||||||
const Allocator = std.mem.Allocator;
|
const Allocator = std.mem.Allocator;
|
||||||
const tp = @import("thespian");
|
const tp = @import("thespian");
|
||||||
const tracy = @import("tracy");
|
const tracy = @import("tracy");
|
||||||
|
const config = @import("config");
|
||||||
const Buffer = @import("Buffer");
|
const Buffer = @import("Buffer");
|
||||||
const root = @import("root");
|
const root = @import("root");
|
||||||
const project_manager = @import("project_manager");
|
const project_manager = @import("project_manager");
|
||||||
|
|
@ -35,6 +36,7 @@ detailed: bool = false,
|
||||||
file: bool = false,
|
file: bool = false,
|
||||||
eol_mode: Buffer.EolMode = .lf,
|
eol_mode: Buffer.EolMode = .lf,
|
||||||
utf8_sanitized: bool = false,
|
utf8_sanitized: bool = false,
|
||||||
|
indent_mode: config.IndentMode = .spaces,
|
||||||
|
|
||||||
const project_icon = "";
|
const project_icon = "";
|
||||||
const Self = @This();
|
const Self = @This();
|
||||||
|
|
@ -155,15 +157,19 @@ fn render_detailed(self: *Self, plane: *Plane, theme: *const Widget.Theme) void
|
||||||
_ = plane.print("{s} ({s})", .{ self.name, project_name }) catch {};
|
_ = plane.print("{s} ({s})", .{ self.name, project_name }) catch {};
|
||||||
} else {
|
} else {
|
||||||
const eol_mode = switch (self.eol_mode) {
|
const eol_mode = switch (self.eol_mode) {
|
||||||
.lf => " [↩ = ␊]",
|
.lf => "[↩ = ␊]",
|
||||||
.crlf => " [↩ = ␍␊]",
|
.crlf => "[↩ = ␍␊]",
|
||||||
|
};
|
||||||
|
const indent_mode = switch (self.indent_mode) {
|
||||||
|
.spaces, .auto => "[⭾ = ␠]",
|
||||||
|
.tabs => "[⭾ = ␉]",
|
||||||
};
|
};
|
||||||
|
|
||||||
_ = plane.putstr(if (!self.file_exists) "" else if (self.file_dirty) "" else "") catch {};
|
_ = plane.putstr(if (!self.file_exists) "" else if (self.file_dirty) "" else "") catch {};
|
||||||
_ = plane.print(" {s}:{d}:{d}", .{ self.name, self.line + 1, self.column + 1 }) catch {};
|
_ = plane.print(" {s}:{d}:{d}", .{ self.name, self.line + 1, self.column + 1 }) catch {};
|
||||||
_ = plane.print(" of {d} lines", .{self.lines}) catch {};
|
_ = plane.print(" of {d} lines", .{self.lines}) catch {};
|
||||||
if (self.file_type.len > 0)
|
if (self.file_type.len > 0)
|
||||||
_ = plane.print(" ({s}){s}", .{ self.file_type, eol_mode }) catch {};
|
_ = plane.print(" ({s}) {s}{s}", .{ self.file_type, eol_mode, indent_mode }) catch {};
|
||||||
|
|
||||||
if (self.utf8_sanitized) {
|
if (self.utf8_sanitized) {
|
||||||
plane.set_style(.{ .fg = theme.editor_error.fg.? });
|
plane.set_style(.{ .fg = theme.editor_error.fg.? });
|
||||||
|
|
@ -214,13 +220,12 @@ fn process_event(self: *Self, m: tp.message) error{Exit}!bool {
|
||||||
var file_type: []const u8 = undefined;
|
var file_type: []const u8 = undefined;
|
||||||
var file_icon: []const u8 = undefined;
|
var file_icon: []const u8 = undefined;
|
||||||
var file_dirty: bool = undefined;
|
var file_dirty: bool = undefined;
|
||||||
var eol_mode: Buffer.EolModeTag = @intFromEnum(Buffer.EolMode.lf);
|
|
||||||
if (try m.match(.{ tp.any, "pos", tp.extract(&self.lines), tp.extract(&self.line), tp.extract(&self.column) }))
|
if (try m.match(.{ tp.any, "pos", tp.extract(&self.lines), tp.extract(&self.line), tp.extract(&self.column) }))
|
||||||
return false;
|
return false;
|
||||||
if (try m.match(.{ tp.any, "dirty", tp.extract(&file_dirty) })) {
|
if (try m.match(.{ tp.any, "dirty", tp.extract(&file_dirty) })) {
|
||||||
self.file_dirty = file_dirty;
|
self.file_dirty = file_dirty;
|
||||||
} else if (try m.match(.{ tp.any, "eol_mode", tp.extract(&eol_mode), tp.extract(&self.utf8_sanitized) })) {
|
} else if (try m.match(.{ tp.any, "eol_mode", tp.extract(&self.eol_mode), tp.extract(&self.utf8_sanitized), tp.extract(&self.indent_mode) })) {
|
||||||
self.eol_mode = @enumFromInt(eol_mode);
|
//
|
||||||
} else if (try m.match(.{ tp.any, "save", tp.extract(&file_path) })) {
|
} else if (try m.match(.{ tp.any, "save", tp.extract(&file_path) })) {
|
||||||
@memcpy(self.name_buf[0..file_path.len], file_path);
|
@memcpy(self.name_buf[0..file_path.len], file_path);
|
||||||
self.name = self.name_buf[0..file_path.len];
|
self.name = self.name_buf[0..file_path.len];
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ const std = @import("std");
|
||||||
const Allocator = std.mem.Allocator;
|
const Allocator = std.mem.Allocator;
|
||||||
const tp = @import("thespian");
|
const tp = @import("thespian");
|
||||||
const Buffer = @import("Buffer");
|
const Buffer = @import("Buffer");
|
||||||
|
const config = @import("config");
|
||||||
|
|
||||||
const Plane = @import("renderer").Plane;
|
const Plane = @import("renderer").Plane;
|
||||||
const command = @import("command");
|
const command = @import("command");
|
||||||
|
|
@ -22,6 +23,7 @@ buf: [256]u8 = undefined,
|
||||||
rendered: [:0]const u8 = "",
|
rendered: [:0]const u8 = "",
|
||||||
eol_mode: Buffer.EolMode = .lf,
|
eol_mode: Buffer.EolMode = .lf,
|
||||||
utf8_sanitized: bool = false,
|
utf8_sanitized: bool = false,
|
||||||
|
indent_mode: config.IndentMode = .spaces,
|
||||||
padding: ?usize,
|
padding: ?usize,
|
||||||
leader: ?Leader,
|
leader: ?Leader,
|
||||||
style: ?DigitStyle,
|
style: ?DigitStyle,
|
||||||
|
|
@ -90,7 +92,11 @@ fn format(self: *Self) void {
|
||||||
.lf => "",
|
.lf => "",
|
||||||
.crlf => " [␍␊]",
|
.crlf => " [␍␊]",
|
||||||
};
|
};
|
||||||
std.fmt.format(writer, "{s} Ln ", .{eol_mode}) catch {};
|
const indent_mode = switch (self.indent_mode) {
|
||||||
|
.spaces, .auto => "",
|
||||||
|
.tabs => " [⭾]",
|
||||||
|
};
|
||||||
|
std.fmt.format(writer, "{s}{s} Ln ", .{ eol_mode, indent_mode }) catch {};
|
||||||
self.format_count(writer, self.line + 1, self.padding orelse 0) catch {};
|
self.format_count(writer, self.line + 1, self.padding orelse 0) catch {};
|
||||||
std.fmt.format(writer, ", Col ", .{}) catch {};
|
std.fmt.format(writer, ", Col ", .{}) catch {};
|
||||||
self.format_count(writer, self.column + 1, self.padding orelse 0) catch {};
|
self.format_count(writer, self.column + 1, self.padding orelse 0) catch {};
|
||||||
|
|
@ -115,11 +121,9 @@ fn format_count(self: *Self, writer: anytype, value: usize, width: usize) !void
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn receive(self: *Self, _: *Button.State(Self), _: tp.pid_ref, m: tp.message) error{Exit}!bool {
|
pub fn receive(self: *Self, _: *Button.State(Self), _: tp.pid_ref, m: tp.message) error{Exit}!bool {
|
||||||
var eol_mode: Buffer.EolModeTag = @intFromEnum(Buffer.EolMode.lf);
|
|
||||||
if (try m.match(.{ "E", "pos", tp.extract(&self.lines), tp.extract(&self.line), tp.extract(&self.column) })) {
|
if (try m.match(.{ "E", "pos", tp.extract(&self.lines), tp.extract(&self.line), tp.extract(&self.column) })) {
|
||||||
self.format();
|
self.format();
|
||||||
} else if (try m.match(.{ "E", "eol_mode", tp.extract(&eol_mode), tp.extract(&self.utf8_sanitized) })) {
|
} else if (try m.match(.{ "E", "eol_mode", tp.extract(&self.eol_mode), tp.extract(&self.utf8_sanitized), tp.extract(&self.indent_mode) })) {
|
||||||
self.eol_mode = @enumFromInt(eol_mode);
|
|
||||||
self.format();
|
self.format();
|
||||||
} else if (try m.match(.{ "E", "open", tp.more })) {
|
} else if (try m.match(.{ "E", "open", tp.more })) {
|
||||||
self.eol_mode = .lf;
|
self.eol_mode = .lf;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
const cbor = @import("cbor");
|
||||||
const tp = @import("thespian");
|
const tp = @import("thespian");
|
||||||
const root = @import("root");
|
const root = @import("root");
|
||||||
|
|
||||||
|
|
@ -64,7 +65,7 @@ pub fn create(allocator: std.mem.Allocator, parent: Plane, event_handler: ?Event
|
||||||
return Widget.to(self);
|
return Widget.to(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
const TabBar = struct {
|
pub const TabBar = struct {
|
||||||
allocator: std.mem.Allocator,
|
allocator: std.mem.Allocator,
|
||||||
plane: Plane,
|
plane: Plane,
|
||||||
widget_list: *WidgetList,
|
widget_list: *WidgetList,
|
||||||
|
|
@ -267,6 +268,45 @@ const TabBar = struct {
|
||||||
if (buffer_manager.buffer_from_ref(tab.buffer_ref)) |buffer|
|
if (buffer_manager.buffer_from_ref(tab.buffer_ref)) |buffer|
|
||||||
tp.self_pid().send(.{ "cmd", "navigate", .{ .file = buffer.get_file_path() } }) catch {};
|
tp.self_pid().send(.{ "cmd", "navigate", .{ .file = buffer.get_file_path() } }) catch {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn write_state(self: *const Self, writer: Buffer.MetaWriter) error{OutOfMemory}!void {
|
||||||
|
try cbor.writeArrayHeader(writer, self.tabs.len);
|
||||||
|
for (self.tabs) |tab| try cbor.writeValue(writer, ref_to_name(tab.buffer_ref));
|
||||||
|
}
|
||||||
|
|
||||||
|
fn ref_to_name(buffer_ref: usize) ?[]const u8 {
|
||||||
|
const buffer_manager = tui.get_buffer_manager() orelse @panic("tabs no buffer manager");
|
||||||
|
return if (buffer_manager.buffer_from_ref(buffer_ref)) |buffer| buffer.get_file_path() else null;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn extract_state(self: *Self, iter: *[]const u8) !void {
|
||||||
|
var iter2 = iter.*;
|
||||||
|
self.allocator.free(self.tabs);
|
||||||
|
self.tabs = &.{};
|
||||||
|
|
||||||
|
var result: std.ArrayListUnmanaged(TabBarTab) = .{};
|
||||||
|
errdefer result.deinit(self.allocator);
|
||||||
|
|
||||||
|
var count = cbor.decodeArrayHeader(&iter2) catch return error.MatchTabArrayFailed;
|
||||||
|
while (count > 0) : (count -= 1) {
|
||||||
|
var buffer_name: ?[]const u8 = undefined;
|
||||||
|
if (!(cbor.matchValue(&iter2, cbor.extract(&buffer_name)) catch false)) return error.MatchTabBufferNameFailed;
|
||||||
|
if (buffer_name) |name| if (name_to_ref(name)) |buffer_ref| {
|
||||||
|
(try result.addOne(self.allocator)).* = .{
|
||||||
|
.buffer_ref = buffer_ref,
|
||||||
|
.widget = try Tab.create(self, buffer_ref, &self.tab_style, self.event_handler),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
self.tabs = try result.toOwnedSlice(self.allocator);
|
||||||
|
iter.* = iter2;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn name_to_ref(buffer_name: []const u8) ?usize {
|
||||||
|
const buffer_manager = tui.get_buffer_manager() orelse @panic("tabs no buffer manager");
|
||||||
|
return if (buffer_manager.get_buffer_for_file(buffer_name)) |buffer| buffer_manager.buffer_to_ref(buffer) else null;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const Tab = struct {
|
const Tab = struct {
|
||||||
|
|
@ -457,6 +497,22 @@ const Tab = struct {
|
||||||
const basename = if (basename_begin) |begin| file_path[begin + 1 ..] else file_path;
|
const basename = if (basename_begin) |begin| file_path[begin + 1 ..] else file_path;
|
||||||
return basename;
|
return basename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn write_state(self: *const @This(), writer: Buffer.MetaWriter) error{OutOfMemory}!void {
|
||||||
|
try cbor.writeArrayHeader(writer, 9);
|
||||||
|
try cbor.writeValue(writer, self.get_file_path());
|
||||||
|
try cbor.writeValue(writer, self.file_exists);
|
||||||
|
try cbor.writeValue(writer, self.file_eol_mode);
|
||||||
|
try cbor.writeValue(writer, self.hidden);
|
||||||
|
try cbor.writeValue(writer, self.ephemeral);
|
||||||
|
try cbor.writeValue(writer, self.meta);
|
||||||
|
try cbor.writeValue(writer, self.file_type_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn extract_state(self: *@This(), iter: *[]const u8) !void {
|
||||||
|
_ = self;
|
||||||
|
_ = iter;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const spacer = struct {
|
const spacer = struct {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue