terminal: fix up some of the manual handling, comments

This commit is contained in:
Mitchell Hashimoto
2026-01-19 12:17:07 -08:00
parent a8b31ceb84
commit ae8d2c7a3e
2 changed files with 12 additions and 11 deletions

View File

@@ -1804,7 +1804,7 @@ pub fn setAttribute(
self.manualStyleUpdate() catch |err| {
log.warn("setAttribute error restoring old style after failure err={}", .{err});
self.cursor.style = .{};
self.cursor.style_id = style.default_id;
self.manualStyleUpdate() catch unreachable;
};
}
@@ -1951,17 +1951,18 @@ pub fn setAttribute(
/// Call this whenever you manually change the cursor style.
///
/// This function can NOT fail if the cursor style is changing to the
/// default style.
///
/// If this returns an error, the style change did not take effect and
/// the cursor style is reverted back to the default.
/// the cursor style is reverted back to the default. The only scenario
/// this returns an error is if there is a physical memory allocation failure
/// or if there is no possible way to increase style capacity to store
/// the style.
///
/// Note that this can return any PageList capacity error, because it
/// is possible for the internal pagelist to not accommodate the new style
/// at all. This WILL attempt to resize our internal pages to fit the style
/// but it is possible that it cannot be done, in which case upstream callers
/// need to split the page or do something else.
///
/// NOTE(mitchellh): I think in the future we'll do page splitting
/// automatically here and remove this failure scenario.
/// This function WILL split pages as necessary to accommodate the new style.
/// So if OutOfSpace is returned, it means that even after splitting the page
/// there was still no room for the new style.
pub fn manualStyleUpdate(self: *Screen) PageList.IncreaseCapacityError!void {
defer self.assertIntegrity();
var page: *Page = &self.cursor.page_pin.node.data;

View File

@@ -1017,7 +1017,7 @@ pub fn restoreCursor(self: *Terminal) void {
log.warn("restoreCursor error updating style err={}", .{err});
const screen: *Screen = self.screens.active;
screen.cursor.style = .{};
screen.cursor.style_id = style.default_id;
self.screens.active.manualStyleUpdate() catch unreachable;
};
self.screens.active.charset = saved.charset;