mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 00:36:07 +03:00
change u1 in mode to bool
This commit is contained in:
@ -1069,7 +1069,7 @@ fn renderTimerCallback(t: *libuv.Timer) void {
|
||||
win.grid.background = bg;
|
||||
win.grid.foreground = fg;
|
||||
}
|
||||
if (win.terminal.modes.reverse_colors == 1) {
|
||||
if (win.terminal.modes.reverse_colors) {
|
||||
win.grid.background = fg;
|
||||
win.grid.foreground = bg;
|
||||
}
|
||||
@ -1080,7 +1080,7 @@ fn renderTimerCallback(t: *libuv.Timer) void {
|
||||
g: f32,
|
||||
b: f32,
|
||||
a: f32,
|
||||
} = if (win.terminal.modes.reverse_colors == 1) .{
|
||||
} = if (win.terminal.modes.reverse_colors) .{
|
||||
.r = @intToFloat(f32, fg.r) / 255,
|
||||
.g = @intToFloat(f32, fg.g) / 255,
|
||||
.b = @intToFloat(f32, fg.b) / 255,
|
||||
@ -1167,7 +1167,7 @@ pub fn setCursorCol(self: *Window, col: u16) !void {
|
||||
}
|
||||
|
||||
pub fn setCursorRow(self: *Window, row: u16) !void {
|
||||
if (self.terminal.modes.origin == 1) {
|
||||
if (self.terminal.modes.origin) {
|
||||
// TODO
|
||||
log.err("setCursorRow: implement origin mode", .{});
|
||||
unreachable;
|
||||
@ -1234,19 +1234,19 @@ pub fn setTopAndBottomMargin(self: *Window, top: u16, bot: u16) !void {
|
||||
pub fn setMode(self: *Window, mode: terminal.Mode, enabled: bool) !void {
|
||||
switch (mode) {
|
||||
.reverse_colors => {
|
||||
self.terminal.modes.reverse_colors = @boolToInt(enabled);
|
||||
self.terminal.modes.reverse_colors = enabled;
|
||||
|
||||
// Schedule a render since we changed colors
|
||||
try self.render_timer.schedule();
|
||||
},
|
||||
|
||||
.origin => {
|
||||
self.terminal.modes.origin = @boolToInt(enabled);
|
||||
self.terminal.modes.origin = enabled;
|
||||
self.terminal.setCursorPos(1, 1);
|
||||
},
|
||||
|
||||
.autowrap => {
|
||||
self.terminal.modes.autowrap = @boolToInt(enabled);
|
||||
self.terminal.modes.autowrap = enabled;
|
||||
},
|
||||
|
||||
.cursor_visible => {
|
||||
@ -1323,7 +1323,7 @@ pub fn deviceStatusReport(
|
||||
const pos: struct {
|
||||
x: usize,
|
||||
y: usize,
|
||||
} = if (self.terminal.modes.origin == 1) .{
|
||||
} = if (self.terminal.modes.origin) .{
|
||||
// TODO: what do we do if cursor is outside scrolling region?
|
||||
.x = self.terminal.screen.cursor.x,
|
||||
.y = self.terminal.screen.cursor.y -| self.terminal.scrolling_region.top,
|
||||
|
@ -61,12 +61,12 @@ scrolling_region: ScrollingRegion,
|
||||
modes: packed struct {
|
||||
const Self = @This();
|
||||
|
||||
reverse_colors: u1 = 0, // 5,
|
||||
origin: u1 = 0, // 6
|
||||
autowrap: u1 = 1, // 7
|
||||
reverse_colors: bool = false, // 5,
|
||||
origin: bool = false, // 6
|
||||
autowrap: bool = true, // 7
|
||||
|
||||
deccolm: u1 = 0, // 3,
|
||||
deccolm_supported: u1 = 0, // 40
|
||||
deccolm: bool = false, // 3,
|
||||
deccolm_supported: bool = false, // 40
|
||||
|
||||
mouse_event: MouseEvents = .none,
|
||||
mouse_format: MouseFormat = .x10,
|
||||
@ -223,10 +223,10 @@ pub fn deccolm(self: *Terminal, alloc: Allocator, mode: DeccolmMode) !void {
|
||||
// bit. If the mode "?40" is set, then "?3" (DECCOLM) is supported. This
|
||||
// doesn't exactly match VT100 semantics but modern terminals no longer
|
||||
// blindly accept mode 3 since its so weird in modern practice.
|
||||
if (self.modes.deccolm_supported == 0) return;
|
||||
if (!self.modes.deccolm_supported) return;
|
||||
|
||||
// Enable it
|
||||
self.modes.deccolm = @enumToInt(mode);
|
||||
self.modes.deccolm = mode == .@"132_cols";
|
||||
|
||||
// Resize -- we can set cols to 0 because deccolm will force it
|
||||
try self.resize(alloc, 0, self.rows);
|
||||
@ -243,7 +243,7 @@ pub fn setDeccolmSupported(self: *Terminal, v: bool) void {
|
||||
const tracy = trace(@src());
|
||||
defer tracy.end();
|
||||
|
||||
self.modes.deccolm_supported = @boolToInt(v);
|
||||
self.modes.deccolm_supported = v;
|
||||
}
|
||||
|
||||
/// Resize the underlying terminal.
|
||||
@ -254,8 +254,8 @@ pub fn resize(self: *Terminal, alloc: Allocator, cols_req: usize, rows: usize) !
|
||||
// If we have deccolm supported then we are fixed at either 80 or 132
|
||||
// columns depending on if mode 3 is set or not.
|
||||
// TODO: test
|
||||
const cols: usize = if (self.modes.deccolm_supported == 1)
|
||||
@as(usize, if (self.modes.deccolm == 1) 132 else 80)
|
||||
const cols: usize = if (self.modes.deccolm_supported)
|
||||
@as(usize, if (self.modes.deccolm) 132 else 80)
|
||||
else
|
||||
cols_req;
|
||||
|
||||
@ -396,7 +396,7 @@ pub fn print(self: *Terminal, c: u21) !void {
|
||||
if (width == 0) return;
|
||||
|
||||
// If we're soft-wrapping, then handle that first.
|
||||
if (self.screen.cursor.pending_wrap and self.modes.autowrap == 1)
|
||||
if (self.screen.cursor.pending_wrap and self.modes.autowrap)
|
||||
_ = self.printWrap();
|
||||
|
||||
switch (width) {
|
||||
@ -624,7 +624,7 @@ pub fn setCursorPos(self: *Terminal, row_req: usize, col_req: usize) void {
|
||||
y_offset: usize = 0,
|
||||
x_max: usize,
|
||||
y_max: usize,
|
||||
} = if (self.modes.origin == 1) .{
|
||||
} = if (self.modes.origin) .{
|
||||
.x_offset = 0, // TODO: left/right margins
|
||||
.y_offset = self.scrolling_region.top,
|
||||
.x_max = self.cols, // TODO: left/right margins
|
||||
@ -656,7 +656,7 @@ pub fn setCursorColAbsolute(self: *Terminal, col_req: usize) void {
|
||||
|
||||
// TODO: test
|
||||
|
||||
assert(self.modes.origin == 0); // TODO
|
||||
assert(!self.modes.origin); // TODO
|
||||
|
||||
if (self.status_display != .main) return; // TODO
|
||||
|
||||
@ -1351,7 +1351,7 @@ test "Terminal: setCursorPosition" {
|
||||
try testing.expect(!t.screen.cursor.pending_wrap);
|
||||
|
||||
// Origin mode
|
||||
t.modes.origin = 1;
|
||||
t.modes.origin = true;
|
||||
|
||||
// No change without a scroll region
|
||||
t.setCursorPos(81, 81);
|
||||
|
Reference in New Issue
Block a user