mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-14 11:35:48 +00:00
terminal: add semantic_content enum to cell
This commit is contained in:
@@ -1994,7 +1994,12 @@ pub const Cell = packed struct(u64) {
|
||||
/// the hyperlink_set to get the actual hyperlink data.
|
||||
hyperlink: bool = false,
|
||||
|
||||
_padding: u18 = 0,
|
||||
/// The semantic type of the content of this cell. This is used
|
||||
/// by the semantic prompt (OSC 133) set of sequences to understand
|
||||
/// boundary points for content.
|
||||
semantic_content: SemanticContent = .output,
|
||||
|
||||
_padding: u16 = 0,
|
||||
|
||||
pub const ContentTag = enum(u2) {
|
||||
/// A single codepoint, could be zero to be empty cell.
|
||||
@@ -2033,6 +2038,19 @@ pub const Cell = packed struct(u64) {
|
||||
spacer_head = 3,
|
||||
};
|
||||
|
||||
pub const SemanticContent = enum(u2) {
|
||||
/// Regular output content, such as command output.
|
||||
output = 0,
|
||||
|
||||
/// Content that is part of user input, such as the command
|
||||
/// to execute at a prompt.
|
||||
input = 1,
|
||||
|
||||
/// Content that is part of prompt emitted by the interactive
|
||||
/// application, such as "user@host >"
|
||||
prompt = 2,
|
||||
};
|
||||
|
||||
/// Helper to make a cell that just has a codepoint.
|
||||
pub fn init(cp: u21) Cell {
|
||||
// We have to use this bitCast here to ensure that our memory is
|
||||
@@ -2166,6 +2184,10 @@ test "Cell is zero by default" {
|
||||
const cell = Cell.init(0);
|
||||
const cell_int: u64 = @bitCast(cell);
|
||||
try std.testing.expectEqual(@as(u64, 0), cell_int);
|
||||
|
||||
// The zero value should be output type for semantic content.
|
||||
// This is very important for our assumptions elsewhere.
|
||||
try std.testing.expectEqual(Cell.SemanticContent.output, cell.semantic_content);
|
||||
}
|
||||
|
||||
test "Page capacity adjust cols down" {
|
||||
|
||||
Reference in New Issue
Block a user