diff --git a/src/Window.zig b/src/Window.zig index 80c0482e8..ef3f520c3 100644 --- a/src/Window.zig +++ b/src/Window.zig @@ -748,6 +748,10 @@ pub fn setMode(self: *Window, mode: terminal.Mode, enabled: bool) !void { self.terminal.setCursorPos(1, 1); }, + .autowrap => { + self.terminal.mode_autowrap = enabled; + }, + .bracketed_paste => self.bracketed_paste = true, else => if (enabled) log.warn("unimplemented mode: {}", .{mode}), diff --git a/src/terminal/Terminal.zig b/src/terminal/Terminal.zig index 068fd7df2..fc8690d8b 100644 --- a/src/terminal/Terminal.zig +++ b/src/terminal/Terminal.zig @@ -44,6 +44,7 @@ scrolling_region: ScrollingRegion, /// Modes // TODO: turn into a bitset probably mode_origin: bool = false, +mode_autowrap: bool = true, mode_reverse_colors: bool = false, /// Scrolling region is the area of the screen designated where scrolling @@ -202,7 +203,7 @@ pub fn print(self: *Terminal, c: u21) !void { defer tracy.end(); // If we're soft-wrapping, then handle that first. - if (self.cursor.pending_wrap) { + if (self.cursor.pending_wrap and self.mode_autowrap) { // Mark that the cell is wrapped, which guarantees that there is // at least one cell after it in the next row. const cell = self.screen.getCell(self.cursor.y, self.cursor.x); diff --git a/src/terminal/ansi.zig b/src/terminal/ansi.zig index b649b561f..b2e73be63 100644 --- a/src/terminal/ansi.zig +++ b/src/terminal/ansi.zig @@ -50,6 +50,9 @@ pub const Mode = enum(u16) { /// the current scroll region. origin = 6, + /// Enable or disable automatic line wrapping. + autowrap = 7, + /// Bracket clipboard paste contents in delimiter sequences. /// /// When pasting from the (e.g. system) clipboard add "ESC [ 2 0 0 ~"