mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
terminal: add protected mode flag to cursor pen
This commit is contained in:
@ -232,6 +232,7 @@ pub const Cell = struct {
|
||||
strikethrough: bool = false,
|
||||
underline: sgr.Attribute.Underline = .none,
|
||||
underline_color: bool = false,
|
||||
protected: bool = false,
|
||||
|
||||
/// True if this is a wide character. This char takes up
|
||||
/// two cells. The following cell ALWAYS is a space.
|
||||
|
@ -1728,6 +1728,24 @@ pub fn kittyGraphics(
|
||||
return kitty.graphics.execute(alloc, self, cmd);
|
||||
}
|
||||
|
||||
/// Set the character protection mode for the terminal.
|
||||
pub fn setProtectedMode(self: *Terminal, mode: ansi.ProtectedMode) void {
|
||||
switch (mode) {
|
||||
.off => {
|
||||
self.screen.cursor.pen.attrs.protected = false;
|
||||
},
|
||||
|
||||
// TODO: ISO/DEC have very subtle differences, so we should track that.
|
||||
.iso => {
|
||||
self.screen.cursor.pen.attrs.protected = true;
|
||||
},
|
||||
|
||||
.dec => {
|
||||
self.screen.cursor.pen.attrs.protected = true;
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// Full reset
|
||||
pub fn fullReset(self: *Terminal, alloc: Allocator) void {
|
||||
self.primaryScreen(alloc, .{ .clear_on_exit = true, .cursor_save = true });
|
||||
@ -2953,3 +2971,19 @@ test "Terminal: saveCursor with screen change" {
|
||||
try testing.expect(t.screen.charset.gr == .G3);
|
||||
try testing.expect(t.modes.get(.origin));
|
||||
}
|
||||
|
||||
test "Terminal: setProtectedMode" {
|
||||
const alloc = testing.allocator;
|
||||
var t = try init(alloc, 3, 3);
|
||||
defer t.deinit(alloc);
|
||||
|
||||
try testing.expect(!t.screen.cursor.pen.attrs.protected);
|
||||
t.setProtectedMode(.off);
|
||||
try testing.expect(!t.screen.cursor.pen.attrs.protected);
|
||||
t.setProtectedMode(.iso);
|
||||
try testing.expect(t.screen.cursor.pen.attrs.protected);
|
||||
t.setProtectedMode(.dec);
|
||||
try testing.expect(t.screen.cursor.pen.attrs.protected);
|
||||
t.setProtectedMode(.off);
|
||||
try testing.expect(!t.screen.cursor.pen.attrs.protected);
|
||||
}
|
||||
|
@ -111,3 +111,11 @@ pub const ModifyKeyFormat = union(enum) {
|
||||
function_keys: void,
|
||||
other_keys: enum { none, numeric_except, numeric },
|
||||
};
|
||||
|
||||
/// The protection modes that can be set for the terminal. See DECSCA and
|
||||
/// ESC V, W.
|
||||
pub const ProtectedMode = enum {
|
||||
off,
|
||||
iso, // ESC V, W
|
||||
dec, // CSI Ps " q
|
||||
};
|
||||
|
@ -28,6 +28,7 @@ pub const DeviceAttributeReq = ansi.DeviceAttributeReq;
|
||||
pub const DeviceStatusReq = ansi.DeviceStatusReq;
|
||||
pub const Mode = modes.Mode;
|
||||
pub const ModifyKeyFormat = ansi.ModifyKeyFormat;
|
||||
pub const ProtectedMode = ansi.ProtectedMode;
|
||||
pub const StatusLineType = ansi.StatusLineType;
|
||||
pub const StatusDisplay = ansi.StatusDisplay;
|
||||
pub const EraseDisplay = csi.EraseDisplay;
|
||||
|
Reference in New Issue
Block a user