support set top/bottom margin with zero params

This commit is contained in:
Mitchell Hashimoto
2022-06-22 16:37:38 -07:00
parent 7dbe6b941e
commit df89dd08e1
2 changed files with 6 additions and 0 deletions

View File

@ -714,6 +714,11 @@ test "Terminal: setScrollingRegion" {
t.setScrollingRegion(7, 3); t.setScrollingRegion(7, 3);
try testing.expectEqual(@as(usize, 0), t.scrolling_region.top); try testing.expectEqual(@as(usize, 0), t.scrolling_region.top);
try testing.expectEqual(@as(usize, t.rows - 1), t.scrolling_region.bottom); try testing.expectEqual(@as(usize, t.rows - 1), t.scrolling_region.bottom);
// Scroll region with zero top and bottom
t.setScrollingRegion(0, 0);
try testing.expectEqual(@as(usize, 0), t.scrolling_region.top);
try testing.expectEqual(@as(usize, t.rows - 1), t.scrolling_region.bottom);
} }
test "Terminal: deleteLines" { test "Terminal: deleteLines" {

View File

@ -327,6 +327,7 @@ pub fn Stream(comptime Handler: type) type {
// DECSTBM - Set Top and Bottom Margins // DECSTBM - Set Top and Bottom Margins
// TODO: test // TODO: test
'r' => if (@hasDecl(T, "setTopAndBottomMargin")) switch (action.params.len) { 'r' => if (@hasDecl(T, "setTopAndBottomMargin")) switch (action.params.len) {
0 => try self.handler.setTopAndBottomMargin(0, 0),
1 => try self.handler.setTopAndBottomMargin(action.params[0], 0), 1 => try self.handler.setTopAndBottomMargin(action.params[0], 0),
2 => try self.handler.setTopAndBottomMargin(action.params[0], action.params[1]), 2 => try self.handler.setTopAndBottomMargin(action.params[0], action.params[1]),
else => log.warn("invalid DECSTBM command: {}", .{action}), else => log.warn("invalid DECSTBM command: {}", .{action}),