mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
eraseChars respects pen
This commit is contained in:
@ -558,7 +558,7 @@ pub fn deleteChars(self: *Window, count: usize) !void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn eraseChars(self: *Window, count: usize) !void {
|
pub fn eraseChars(self: *Window, count: usize) !void {
|
||||||
try self.terminal.eraseChars(count);
|
try self.terminal.eraseChars(self.alloc, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deleteLines(self: *Window, count: usize) !void {
|
pub fn deleteLines(self: *Window, count: usize) !void {
|
||||||
|
@ -312,21 +312,17 @@ pub fn deleteChars(self: *Terminal, count: usize) !void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: test, docs
|
// TODO: test, docs
|
||||||
pub fn eraseChars(self: *Terminal, count: usize) !void {
|
pub fn eraseChars(self: *Terminal, alloc: Allocator, count: usize) !void {
|
||||||
var line = &self.screen.items[self.cursor.y];
|
|
||||||
|
|
||||||
// Our last index is at most the end of the number of chars we have
|
// Our last index is at most the end of the number of chars we have
|
||||||
// in the current line.
|
// in the current line.
|
||||||
const end = @minimum(line.items.len, self.cursor.x + count);
|
const end = @minimum(self.cols, self.cursor.x + count);
|
||||||
|
|
||||||
// Do nothing if we have no values.
|
|
||||||
if (self.cursor.x >= line.items.len) return;
|
|
||||||
|
|
||||||
// Shift
|
// Shift
|
||||||
var i: usize = self.cursor.x;
|
var x: usize = self.cursor.x;
|
||||||
while (i < end) : (i += 1) {
|
while (x < end) : (x += 1) {
|
||||||
line.items[i].char = 0;
|
const cell = try self.getOrPutCell(alloc, x, self.cursor.y);
|
||||||
// TODO: retain graphical attributes
|
cell.* = self.cursor.pen;
|
||||||
|
cell.char = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ pub fn Stream(comptime Handler: type) type {
|
|||||||
//log.debug("char: {}", .{c});
|
//log.debug("char: {}", .{c});
|
||||||
const actions = self.parser.next(c);
|
const actions = self.parser.next(c);
|
||||||
for (actions) |action_opt| {
|
for (actions) |action_opt| {
|
||||||
if (action_opt) |action| log.info("action: {}", .{action});
|
// if (action_opt) |action| log.info("action: {}", .{action});
|
||||||
switch (action_opt orelse continue) {
|
switch (action_opt orelse continue) {
|
||||||
.print => |p| if (@hasDecl(T, "print")) try self.handler.print(p),
|
.print => |p| if (@hasDecl(T, "print")) try self.handler.print(p),
|
||||||
.execute => |code| try self.execute(code),
|
.execute => |code| try self.execute(code),
|
||||||
|
Reference in New Issue
Block a user