terminal: linefeed mode

This commit is contained in:
Mitchell Hashimoto
2023-10-12 20:46:26 -07:00
parent 8c61f8d890
commit 5ce50d08a1
6 changed files with 100 additions and 10 deletions

View File

@@ -1522,6 +1522,7 @@ pub fn linefeed(self: *Terminal) !void {
defer tracy.end();
try self.index();
if (self.modes.get(.linefeed)) self.carriageReturn();
}
/// Inserts spaces at current cursor position moving existing cell contents
@@ -2319,6 +2320,22 @@ test "Terminal: linefeed unsets pending wrap" {
try testing.expect(t.screen.cursor.pending_wrap == false);
}
test "Terminal: linefeed mode automatic carriage return" {
var t = try init(testing.allocator, 10, 10);
defer t.deinit(testing.allocator);
// Basic grid writing
t.modes.set(.linefeed, true);
try t.printString("123456");
try t.linefeed();
try t.print('X');
{
var str = try t.plainString(testing.allocator);
defer testing.allocator.free(str);
try testing.expectEqualStrings("123456\nX", str);
}
}
test "Terminal: carriage return unsets pending wrap" {
var t = try init(testing.allocator, 5, 80);
defer t.deinit(testing.allocator);