diff options
Diffstat (limited to 'core/exec.zig')
| -rw-r--r-- | core/exec.zig | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/core/exec.zig b/core/exec.zig index 601d43dc..6804a22e 100644 --- a/core/exec.zig +++ b/core/exec.zig @@ -110,12 +110,12 @@ fn spanHas(r: i32, c: i32, ar: i32, ac: i32, br: i32, bc: i32) bool { /// anywhere else. pub fn operandAt(p: *Pardes, pane: *Pane, clicked: Pane.Sel, borrow: bool, for_look: bool) PointerOperand { const visible = clicked.r0 - @as(i32, pane.tag_rows); - const wrapped = pane.wrapAt(visible); + const wrapped = pane.wrapAt(p.settings.tab, visible); const raw = pane.isTerminal() and pane.body.mode == .tty and clicked.r0 >= pane.tag_rows; const row = if (raw) @as(i32, @intCast(panes.Term.grid(pane.terminal).offset)) + visible else wrapped.line; - const raw_line = if (raw) modal.lineSlice(body_layer.bodyText(p.scratch.allocator(), pane) catch "", @intCast(@max(0, visible))) else ""; + const raw_line = if (raw) modal.lineSlice(body_layer.bodyText(p.settings.tab, p.scratch.allocator(), pane) catch "", @intCast(@max(0, visible))) else ""; const col = if (raw) - @as(i32, @intCast(panes.File.rawAtDisplay(raw_line, @intCast(@max(0, clicked.c0))))) + @as(i32, @intCast(panes.File.rawAtDisplay(p.settings.tab, raw_line, @intCast(@max(0, clicked.c0))))) else if (clicked.r0 >= pane.tag_rows) edit.paneByteAtDisplay( p.editor(), @@ -144,7 +144,7 @@ pub fn operandAt(p: *Pardes, pane: *Pane, clicked: Pane.Sel, borrow: bool, for_l lo -|= span.prompt_bytes; hi -|= span.prompt_bytes; } else if (!span.raw_terminal and raw) { - const prefix = panes.Term.promptPrefix(pane.terminal, row, raw_line); + const prefix = panes.Term.promptPrefix(p.settings.tab, pane.terminal, row, raw_line); lo += prefix; hi += prefix; } @@ -186,11 +186,11 @@ pub fn operandAt(p: *Pardes, pane: *Pane, clicked: Pane.Sel, borrow: bool, for_l var expanded = clicked; if (pane.file != null) { result.file_word = .{ .row = row, .lo = 0, .hi = hi }; - expanded = fileWordCells(pane, clicked, row, 0, hi) orelse return result; + expanded = fileWordCells(p.settings.tab, pane, clicked, row, 0, hi) orelse return result; } else { const shown = if (raw) raw_line else got.line; expanded.c0 = 0; - expanded.c1 = @as(i32, @intCast(panes.File.rawDisplayCol(shown, shown.len))) - 1; + expanded.c1 = @as(i32, @intCast(panes.File.rawDisplayCol(p.settings.tab, shown, shown.len))) - 1; } result.preview = expanded; result.expanded = expanded; @@ -212,7 +212,7 @@ pub fn operandAt(p: *Pardes, pane: *Pane, clicked: Pane.Sel, borrow: bool, for_l const hi = std.math.cast(i32, b.hi) orelse return result; result.text = line[b.lo..b.hi]; result.file_word = .{ .row = row, .lo = lo, .hi = hi }; - const expanded = fileWordCells(pane, clicked, row, lo, hi) orelse clicked; + const expanded = fileWordCells(p.settings.tab, pane, clicked, row, lo, hi) orelse clicked; result.preview = expanded; result.expanded = expanded; return result; @@ -228,15 +228,15 @@ pub fn operandAt(p: *Pardes, pane: *Pane, clicked: Pane.Sel, borrow: bool, for_l /// The cells bytes `lo..hi` of a file pane's line `row` take on screen, /// soft-wrapped or not, as `clicked` reshaped; null when scrolled off. -fn fileWordCells(pane: *Pane, clicked: Pane.Sel, row: i32, lo: i32, hi: i32) ?Pane.Sel { - const first = pane.wrapRow(row, lo); - const last = pane.wrapRow(row, hi - 1); +fn fileWordCells(tab: u16, pane: *Pane, clicked: Pane.Sel, row: i32, lo: i32, hi: i32) ?Pane.Sel { + const first = pane.wrapRow(tab, row, lo); + const last = pane.wrapRow(tab, row, hi - 1); if (first.row < 0 or last.row < 0) return null; var cells = clicked; cells.r0 = first.row + @as(i32, pane.tag_rows); - cells.c0 = @as(i32, panes.File.gutterWidth(pane)) + first.pad + panes.File.displayOffset(pane, row, first.at, lo); + cells.c0 = @as(i32, panes.File.gutterWidth(pane)) + first.pad + panes.File.displayOffset(tab, pane, row, first.at, lo); cells.r1 = last.row + @as(i32, pane.tag_rows); - cells.c1 = @as(i32, panes.File.gutterWidth(pane)) + last.pad + panes.File.displayEndOffset(pane, row, last.at, hi - 1); + cells.c1 = @as(i32, panes.File.gutterWidth(pane)) + last.pad + panes.File.displayEndOffset(tab, pane, row, last.at, hi - 1); return cells; } @@ -1038,8 +1038,6 @@ pub fn applySettingBuiltin(p: *Pardes, setting: config.Runtime.Setting, arg: ?[] } else if (!p.settings.apply(setting, arg)) { var said: pardes.Kind.Buf(96) = .{}; p.reportFailure(v.active, said.print("{s}{s}: takes {s}", .{ setting.word, if (tag == .tab) ": invalid tab width" else "", comptime config.Runtime.takes(tag).? })); - } else if (tag == .tab) { - config.tab_now = p.settings.tab; }, // Said with what it takes: its words, its range. else => if (!p.settings.apply(setting, arg)) { @@ -1124,7 +1122,7 @@ test "the acme chords act once per selection, not once on the primary" { .{ .anchor = 0, .head = 6 }, .{ .anchor = 7, .head = 13 }, }; - pane.body.setRanges(pane.file.?.content, &ranges, &.{}, 0, true); + pane.body.setRanges(config.tab_width, pane.file.?.content, &ranges, &.{}, 0, true); try std.testing.expectEqual(@as(u16, 1), pane.body.nsel); const before = p.view().ncol; |
