mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
terminal: eraseLine resets wrap
This commit is contained in:
@ -1250,20 +1250,20 @@ pub fn eraseLine(
|
|||||||
// a contiguous block of memory.
|
// a contiguous block of memory.
|
||||||
if (!protected) {
|
if (!protected) {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
.right => row.fillSlice(
|
.right => {
|
||||||
self.screen.cursor.pen,
|
row.fillSlice(self.screen.cursor.pen, self.screen.cursor.x, self.cols);
|
||||||
self.screen.cursor.x,
|
|
||||||
self.cols,
|
|
||||||
),
|
|
||||||
|
|
||||||
.left => {
|
|
||||||
row.fillSlice(self.screen.cursor.pen, 0, self.screen.cursor.x + 1);
|
|
||||||
|
|
||||||
// Unsets pending wrap state
|
|
||||||
self.screen.cursor.pending_wrap = false;
|
self.screen.cursor.pending_wrap = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
.complete => row.fill(self.screen.cursor.pen),
|
.left => {
|
||||||
|
row.fillSlice(self.screen.cursor.pen, 0, self.screen.cursor.x + 1);
|
||||||
|
self.screen.cursor.pending_wrap = false;
|
||||||
|
},
|
||||||
|
|
||||||
|
.complete => {
|
||||||
|
row.fill(self.screen.cursor.pen);
|
||||||
|
self.screen.cursor.pending_wrap = false;
|
||||||
|
},
|
||||||
|
|
||||||
else => log.err("unimplemented erase line mode: {}", .{mode}),
|
else => log.err("unimplemented erase line mode: {}", .{mode}),
|
||||||
}
|
}
|
||||||
@ -1283,6 +1283,9 @@ pub fn eraseLine(
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// All modes will clear the pending wrap state
|
||||||
|
self.screen.cursor.pending_wrap = false;
|
||||||
|
|
||||||
const pen: Screen.Cell = if (!self.screen.cursor.pen.attrs.has_bg) .{} else .{
|
const pen: Screen.Cell = if (!self.screen.cursor.pen.attrs.has_bg) .{} else .{
|
||||||
.bg = self.screen.cursor.pen.bg,
|
.bg = self.screen.cursor.pen.bg,
|
||||||
.attrs = .{ .has_bg = true },
|
.attrs = .{ .has_bg = true },
|
||||||
@ -3111,6 +3114,24 @@ test "Terminal: setProtectedMode" {
|
|||||||
try testing.expect(!t.screen.cursor.pen.attrs.protected);
|
try testing.expect(!t.screen.cursor.pen.attrs.protected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "Terminal: eraseLine resets wrap" {
|
||||||
|
const alloc = testing.allocator;
|
||||||
|
var t = try init(alloc, 5, 5);
|
||||||
|
defer t.deinit(alloc);
|
||||||
|
|
||||||
|
for ("ABCDE") |c| try t.print(c);
|
||||||
|
try testing.expect(t.screen.cursor.pending_wrap);
|
||||||
|
t.eraseLine(.right, false);
|
||||||
|
try testing.expect(!t.screen.cursor.pending_wrap);
|
||||||
|
try t.print('B');
|
||||||
|
|
||||||
|
{
|
||||||
|
var str = try t.plainString(testing.allocator);
|
||||||
|
defer testing.allocator.free(str);
|
||||||
|
try testing.expectEqualStrings("ABCDB", str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
test "Terminal: eraseLine protected right" {
|
test "Terminal: eraseLine protected right" {
|
||||||
const alloc = testing.allocator;
|
const alloc = testing.allocator;
|
||||||
var t = try init(alloc, 10, 5);
|
var t = try init(alloc, 10, 5);
|
||||||
|
Reference in New Issue
Block a user