summaryrefslogtreecommitdiff
path: root/src/edit.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/edit.zig')
-rw-r--r--src/edit.zig33
1 files changed, 13 insertions, 20 deletions
diff --git a/src/edit.zig b/src/edit.zig
index c6c59604..5fa18c2c 100644
--- a/src/edit.zig
+++ b/src/edit.zig
@@ -12,7 +12,6 @@ const sam = @import("sam_edit.zig");
const panes = @import("panes.zig");
const body_layer = @import("body_layer.zig");
const config = @import("config.zig");
-const pdf_enabled = panes.Pdf.enabled;
const lsp = @import("lsp/lsp.zig");
const syntax = @import("syntax.zig");
const platform = pardes.platform;
@@ -178,10 +177,11 @@ pub fn clipYank(p: *Pardes, pane: *Pane, main_only: bool) void {
const named = v.register;
v.register = '+';
defer v.register = named;
- if (comptime pdf_enabled) if (pane.pdf) |pv| {
- if (pv.selection_text.len > 0) setYank(p, pv.selection_text);
+ // A kind's pane: what it has selected (Kind.Slot.selection).
+ if (pane.addon) |k| {
+ if (k.selection.len > 0) setYank(p, k.selection);
return;
- };
+ }
if (pane.body.nsel > 0 and !main_only) {
normal.replaySels(p, &pane.body, .{ .normal = .{ .role = .yank } });
} else {
@@ -200,7 +200,7 @@ pub fn paneText(p: *Pardes, pane: *Pane) ![]u8 {
const from = modal.lineStartOffset(tag, pane.tag_top);
const cut = modal.lineStartOffset(tag, pane.tag_top + pane.tag_rows);
const shown = if (cut < tag.len) tag[from .. cut - 1] else tag[from..];
- return std.fmt.allocPrint(arena, "{s}\n{s}", .{ shown, try body_layer.bodyText(p, arena, pane) });
+ return std.fmt.allocPrint(arena, "{s}\n{s}", .{ shown, try body_layer.bodyText(arena, pane) });
}
pub fn pointerSourceLine(pane: *Pane, terminal_lines: []const []const u8, row: i32) []const u8 {
@@ -212,13 +212,13 @@ pub fn pointerSourceLine(pane: *Pane, terminal_lines: []const []const u8, row: i
pub fn capturePointerSelection(p: *Pardes, pane: *Pane, slot: usize) !void {
var gesture = pane.sel[slot];
- if (pane.hasPdf()) return;
+ if (pane.addon != null) return;
if (gesture.state != .done or @min(gesture.r0, gesture.r1) < pane.tag_rows) return;
if (pane.pointerSelection(gesture) != null) return;
pane.clearPointerSelection(slot);
// Refresh the source map before translating the rendered rectangle.
const raw = pane.isTerminal() and pane.body.mode == .tty;
- const body = try body_layer.bodyText(p, p.scratch.allocator(), pane);
+ const body = try body_layer.bodyText(p.scratch.allocator(), pane);
const terminal_lines = if (pane.file == null and !raw) try panes.terminal.cursorLines(p, pane) else &.{};
const first = @max(0, @min(gesture.r0, gesture.r1) - pane.tag_rows);
const logical_rows = if (pane.body_rows > 0) pane.body_rows else pane.rows;
@@ -352,8 +352,7 @@ pub fn spanHas(r: i32, c: i32, ar: i32, ac: i32, br: i32, bc: i32) bool {
/// the active modal selection as text, if any
pub fn currentSelText(p: *Pardes, pane: *Pane) ?[]const u8 {
- if (comptime pdf_enabled) if (p.view().frontend.native_images) if (pane.pdf) |pv|
- if (pv.selection != null and pv.selection_text.len > 0) return pv.selection_text;
+ if (pane.addon) |k| if (k.selection.len > 0) return k.selection;
if (!pane.body.vsel.active) return null;
return vselText(p, &pane.body);
}
@@ -390,10 +389,7 @@ pub fn paneCursorLines(p: *Pardes, t: *Text) ![]const []const u8 {
}
const pane = t.pane() orelse return &.{};
if (pane.file) |*f| return panes.File.cursorLines(arena, pane, f);
- if (pane.hasPdf()) {
- if (comptime pdf_enabled) return panes.Pdf.textLines(pane.pdf.?, p.pdf_gpa, arena);
- unreachable;
- }
+ if (pane.addon != null) return &.{};
return panes.terminal.cursorLines(p, pane);
}
@@ -422,7 +418,7 @@ pub fn pinPaneCursor(p: *Pardes, t: *Text) void {
}
const pane = t.pane() orelse return;
pane.pinCursor();
- if (pane.file == null and !pane.hasPdf())
+ if (pane.file == null and pane.addon == null)
t.cur_col = paneByteAtDisplay(p, t, t.cur_row, 0, t.cur_col);
}
@@ -436,10 +432,7 @@ pub fn flatSurface(p: *Pardes, t: *Text) ![]const u8 {
}
const pane = t.pane() orelse return "";
if (pane.file) |f| return f.content;
- if (pane.hasPdf()) {
- if (comptime pdf_enabled) return pane.pdf.?.ensureText(p.pdf_gpa);
- unreachable;
- }
+ if (pane.addon != null) return "";
const lines = try panes.terminal.cursorLines(p, pane);
return panes.terminal.flatSurface(p, pane, lines);
}
@@ -465,7 +458,7 @@ fn editText(p: *Pardes, t: *Text, lo: i32, hi: i32, col: i32) ?panes.EditText {
if (t.what != .body) return .{ .text = t.own orelse &.{}, .row0 = 0 };
const pane = t.pane() orelse return null;
if (pane.file) |f| return .{ .text = f.content, .row0 = 0 };
- if (pane.addon != null or pane.hasPdf()) return null;
+ if (pane.addon != null) return null;
return panes.terminal.editText(p, pane, lo, hi, col);
}
@@ -583,7 +576,7 @@ pub fn clampFileCursor(t: *Text) bool {
}
pub fn enterInsert(p: *Pardes, t: *Text, where: InsertAt, cnt: usize) void {
- if (t.what == .body) if (t.pane()) |pane| if (pane.hasPdf()) return;
+ if (t.what == .body) if (t.pane()) |pane| if (pane.addon != null) return;
pinPaneCursor(p, t);
_ = clampFileCursor(t);
// snapshot once per insert session (WITH the pre-insert selection) so