mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 00:36:07 +03:00
termio/exec: get compiler errors gone
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const Allocator = std.mem.Allocator;
|
const Allocator = std.mem.Allocator;
|
||||||
const font = @import("../font/main.zig");
|
const font = @import("../font/main.zig");
|
||||||
|
const terminal = @import("../terminal/main.zig");
|
||||||
|
|
||||||
const log = std.log.scoped(.renderer_size);
|
const log = std.log.scoped(.renderer_size);
|
||||||
|
|
||||||
@ -61,7 +62,7 @@ pub const ScreenSize = struct {
|
|||||||
|
|
||||||
/// The dimensions of the grid itself, in rows/columns units.
|
/// The dimensions of the grid itself, in rows/columns units.
|
||||||
pub const GridSize = struct {
|
pub const GridSize = struct {
|
||||||
const Unit = u32;
|
const Unit = terminal.size.CellCountInt;
|
||||||
|
|
||||||
columns: Unit = 0,
|
columns: Unit = 0,
|
||||||
rows: Unit = 0,
|
rows: Unit = 0,
|
||||||
|
@ -77,10 +77,15 @@ pub const ImageStorage = struct {
|
|||||||
/// can be loaded. If this limit is lower, this will do an eviction
|
/// can be loaded. If this limit is lower, this will do an eviction
|
||||||
/// if necessary. If the value is zero, then Kitty image protocol will
|
/// if necessary. If the value is zero, then Kitty image protocol will
|
||||||
/// be disabled.
|
/// be disabled.
|
||||||
pub fn setLimit(self: *ImageStorage, alloc: Allocator, limit: usize) !void {
|
pub fn setLimit(
|
||||||
|
self: *ImageStorage,
|
||||||
|
alloc: Allocator,
|
||||||
|
s: *terminal.Screen,
|
||||||
|
limit: usize,
|
||||||
|
) !void {
|
||||||
// Special case disabling by quickly deleting all
|
// Special case disabling by quickly deleting all
|
||||||
if (limit == 0) {
|
if (limit == 0) {
|
||||||
self.deinit(alloc);
|
self.deinit(alloc, s);
|
||||||
self.* = .{};
|
self.* = .{};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ pub const kitty = @import("kitty.zig");
|
|||||||
pub const modes = @import("modes.zig");
|
pub const modes = @import("modes.zig");
|
||||||
pub const page = @import("page.zig");
|
pub const page = @import("page.zig");
|
||||||
pub const parse_table = @import("parse_table.zig");
|
pub const parse_table = @import("parse_table.zig");
|
||||||
|
pub const size = @import("size.zig");
|
||||||
pub const x11_color = @import("x11_color.zig");
|
pub const x11_color = @import("x11_color.zig");
|
||||||
|
|
||||||
pub const Charset = charsets.Charset;
|
pub const Charset = charsets.Charset;
|
||||||
|
@ -145,8 +145,16 @@ pub fn init(alloc: Allocator, opts: termio.Options) !Exec {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set the image size limits
|
// Set the image size limits
|
||||||
try term.screen.kitty_images.setLimit(alloc, opts.config.image_storage_limit);
|
try term.screen.kitty_images.setLimit(
|
||||||
try term.secondary_screen.kitty_images.setLimit(alloc, opts.config.image_storage_limit);
|
alloc,
|
||||||
|
&term.screen,
|
||||||
|
opts.config.image_storage_limit,
|
||||||
|
);
|
||||||
|
try term.secondary_screen.kitty_images.setLimit(
|
||||||
|
alloc,
|
||||||
|
&term.secondary_screen,
|
||||||
|
opts.config.image_storage_limit,
|
||||||
|
);
|
||||||
|
|
||||||
// Set default cursor blink settings
|
// Set default cursor blink settings
|
||||||
term.modes.set(
|
term.modes.set(
|
||||||
@ -395,10 +403,12 @@ pub fn changeConfig(self: *Exec, config: *DerivedConfig) !void {
|
|||||||
// Set the image size limits
|
// Set the image size limits
|
||||||
try self.terminal.screen.kitty_images.setLimit(
|
try self.terminal.screen.kitty_images.setLimit(
|
||||||
self.alloc,
|
self.alloc,
|
||||||
|
&self.terminal.screen,
|
||||||
config.image_storage_limit,
|
config.image_storage_limit,
|
||||||
);
|
);
|
||||||
try self.terminal.secondary_screen.kitty_images.setLimit(
|
try self.terminal.secondary_screen.kitty_images.setLimit(
|
||||||
self.alloc,
|
self.alloc,
|
||||||
|
&self.terminal.secondary_screen,
|
||||||
config.image_storage_limit,
|
config.image_storage_limit,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -464,11 +474,15 @@ pub fn clearScreen(self: *Exec, history: bool) !void {
|
|||||||
if (self.terminal.active_screen == .alternate) return;
|
if (self.terminal.active_screen == .alternate) return;
|
||||||
|
|
||||||
// Clear our scrollback
|
// Clear our scrollback
|
||||||
if (history) self.terminal.eraseDisplay(self.alloc, .scrollback, false);
|
if (history) self.terminal.eraseDisplay(.scrollback, false);
|
||||||
|
|
||||||
// If we're not at a prompt, we just delete above the cursor.
|
// If we're not at a prompt, we just delete above the cursor.
|
||||||
if (!self.terminal.cursorIsAtPrompt()) {
|
if (!self.terminal.cursorIsAtPrompt()) {
|
||||||
try self.terminal.screen.clear(.above_cursor);
|
self.terminal.screen.clearRows(
|
||||||
|
.{ .active = .{ .y = 0 } },
|
||||||
|
.{ .active = .{ .y = self.terminal.screen.cursor.y - 1 } },
|
||||||
|
false,
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -478,7 +492,7 @@ pub fn clearScreen(self: *Exec, history: bool) !void {
|
|||||||
// clear the full screen in the next eraseDisplay call.
|
// clear the full screen in the next eraseDisplay call.
|
||||||
self.terminal.markSemanticPrompt(.command);
|
self.terminal.markSemanticPrompt(.command);
|
||||||
assert(!self.terminal.cursorIsAtPrompt());
|
assert(!self.terminal.cursorIsAtPrompt());
|
||||||
self.terminal.eraseDisplay(self.alloc, .complete, false);
|
self.terminal.eraseDisplay(.complete, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we reached here it means we're at a prompt, so we send a form-feed.
|
// If we reached here it means we're at a prompt, so we send a form-feed.
|
||||||
@ -494,17 +508,20 @@ pub fn scrollViewport(self: *Exec, scroll: terminal.Terminal.ScrollViewport) !vo
|
|||||||
|
|
||||||
/// Jump the viewport to the prompt.
|
/// Jump the viewport to the prompt.
|
||||||
pub fn jumpToPrompt(self: *Exec, delta: isize) !void {
|
pub fn jumpToPrompt(self: *Exec, delta: isize) !void {
|
||||||
const wakeup: bool = wakeup: {
|
_ = self;
|
||||||
self.renderer_state.mutex.lock();
|
_ = delta;
|
||||||
defer self.renderer_state.mutex.unlock();
|
// TODO(paged-terminal)
|
||||||
break :wakeup self.terminal.screen.jump(.{
|
// const wakeup: bool = wakeup: {
|
||||||
.prompt_delta = delta,
|
// self.renderer_state.mutex.lock();
|
||||||
});
|
// defer self.renderer_state.mutex.unlock();
|
||||||
};
|
// break :wakeup self.terminal.screen.jump(.{
|
||||||
|
// .prompt_delta = delta,
|
||||||
if (wakeup) {
|
// });
|
||||||
try self.renderer_wakeup.notify();
|
// };
|
||||||
}
|
//
|
||||||
|
// if (wakeup) {
|
||||||
|
// try self.renderer_wakeup.notify();
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Called when the child process exited abnormally but before
|
/// Called when the child process exited abnormally but before
|
||||||
@ -2007,7 +2024,7 @@ const StreamHandler = struct {
|
|||||||
try self.queueRender();
|
try self.queueRender();
|
||||||
}
|
}
|
||||||
|
|
||||||
self.terminal.eraseDisplay(self.alloc, mode, protected);
|
self.terminal.eraseDisplay(mode, protected);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn eraseLine(self: *StreamHandler, mode: terminal.EraseLine, protected: bool) !void {
|
pub fn eraseLine(self: *StreamHandler, mode: terminal.EraseLine, protected: bool) !void {
|
||||||
@ -2015,7 +2032,7 @@ const StreamHandler = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn deleteChars(self: *StreamHandler, count: usize) !void {
|
pub fn deleteChars(self: *StreamHandler, count: usize) !void {
|
||||||
try self.terminal.deleteChars(count);
|
self.terminal.deleteChars(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn eraseChars(self: *StreamHandler, count: usize) !void {
|
pub fn eraseChars(self: *StreamHandler, count: usize) !void {
|
||||||
@ -2023,7 +2040,7 @@ const StreamHandler = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn insertLines(self: *StreamHandler, count: usize) !void {
|
pub fn insertLines(self: *StreamHandler, count: usize) !void {
|
||||||
try self.terminal.insertLines(count);
|
self.terminal.insertLines(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn insertBlanks(self: *StreamHandler, count: usize) !void {
|
pub fn insertBlanks(self: *StreamHandler, count: usize) !void {
|
||||||
@ -2031,11 +2048,11 @@ const StreamHandler = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn deleteLines(self: *StreamHandler, count: usize) !void {
|
pub fn deleteLines(self: *StreamHandler, count: usize) !void {
|
||||||
try self.terminal.deleteLines(count);
|
self.terminal.deleteLines(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn reverseIndex(self: *StreamHandler) !void {
|
pub fn reverseIndex(self: *StreamHandler) !void {
|
||||||
try self.terminal.reverseIndex();
|
self.terminal.reverseIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn index(self: *StreamHandler) !void {
|
pub fn index(self: *StreamHandler) !void {
|
||||||
@ -2183,9 +2200,9 @@ const StreamHandler = struct {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (enabled)
|
if (enabled)
|
||||||
self.terminal.alternateScreen(self.alloc, opts)
|
self.terminal.alternateScreen(opts)
|
||||||
else
|
else
|
||||||
self.terminal.primaryScreen(self.alloc, opts);
|
self.terminal.primaryScreen(opts);
|
||||||
|
|
||||||
// Schedule a render since we changed screens
|
// Schedule a render since we changed screens
|
||||||
try self.queueRender();
|
try self.queueRender();
|
||||||
@ -2198,9 +2215,9 @@ const StreamHandler = struct {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (enabled)
|
if (enabled)
|
||||||
self.terminal.alternateScreen(self.alloc, opts)
|
self.terminal.alternateScreen(opts)
|
||||||
else
|
else
|
||||||
self.terminal.primaryScreen(self.alloc, opts);
|
self.terminal.primaryScreen(opts);
|
||||||
|
|
||||||
// Schedule a render since we changed screens
|
// Schedule a render since we changed screens
|
||||||
try self.queueRender();
|
try self.queueRender();
|
||||||
@ -2424,7 +2441,7 @@ const StreamHandler = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn restoreCursor(self: *StreamHandler) !void {
|
pub fn restoreCursor(self: *StreamHandler) !void {
|
||||||
self.terminal.restoreCursor();
|
try self.terminal.restoreCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn enquiry(self: *StreamHandler) !void {
|
pub fn enquiry(self: *StreamHandler) !void {
|
||||||
@ -2433,11 +2450,11 @@ const StreamHandler = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn scrollDown(self: *StreamHandler, count: usize) !void {
|
pub fn scrollDown(self: *StreamHandler, count: usize) !void {
|
||||||
try self.terminal.scrollDown(count);
|
self.terminal.scrollDown(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn scrollUp(self: *StreamHandler, count: usize) !void {
|
pub fn scrollUp(self: *StreamHandler, count: usize) !void {
|
||||||
try self.terminal.scrollUp(count);
|
self.terminal.scrollUp(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setActiveStatusDisplay(
|
pub fn setActiveStatusDisplay(
|
||||||
@ -2467,7 +2484,7 @@ const StreamHandler = struct {
|
|||||||
pub fn fullReset(
|
pub fn fullReset(
|
||||||
self: *StreamHandler,
|
self: *StreamHandler,
|
||||||
) !void {
|
) !void {
|
||||||
self.terminal.fullReset(self.alloc);
|
self.terminal.fullReset();
|
||||||
try self.setMouseShape(.text);
|
try self.setMouseShape(.text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ pub fn threadMain(self: *Thread) void {
|
|||||||
\\Please free up some pty devices and try again.
|
\\Please free up some pty devices and try again.
|
||||||
;
|
;
|
||||||
|
|
||||||
t.eraseDisplay(alloc, .complete, false);
|
t.eraseDisplay(.complete, false);
|
||||||
t.printString(str) catch {};
|
t.printString(str) catch {};
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -197,7 +197,7 @@ pub fn threadMain(self: *Thread) void {
|
|||||||
\\Out of memory. This terminal is non-functional. Please close it and try again.
|
\\Out of memory. This terminal is non-functional. Please close it and try again.
|
||||||
;
|
;
|
||||||
|
|
||||||
t.eraseDisplay(alloc, .complete, false);
|
t.eraseDisplay(.complete, false);
|
||||||
t.printString(str) catch {};
|
t.printString(str) catch {};
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user