mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 08:16:13 +03:00
termio/exec: initial subprocess screen size should be sub padding
This commit is contained in:
@ -401,6 +401,7 @@ pub fn init(
|
|||||||
var io = try termio.Impl.init(alloc, .{
|
var io = try termio.Impl.init(alloc, .{
|
||||||
.grid_size = grid_size,
|
.grid_size = grid_size,
|
||||||
.screen_size = screen_size,
|
.screen_size = screen_size,
|
||||||
|
.padding = padding,
|
||||||
.full_config = config,
|
.full_config = config,
|
||||||
.config = try termio.Impl.DerivedConfig.init(alloc, config),
|
.config = try termio.Impl.DerivedConfig.init(alloc, config),
|
||||||
.resources_dir = app.resources_dir,
|
.resources_dir = app.resources_dir,
|
||||||
|
@ -222,14 +222,14 @@ fn display(
|
|||||||
|
|
||||||
// We can do better by doing this with pure internal screen state
|
// We can do better by doing this with pure internal screen state
|
||||||
// but this handles scroll regions.
|
// but this handles scroll regions.
|
||||||
const height = rect.bottom_right.y - rect.top_left.y + 1;
|
const height = rect.bottom_right.y - rect.top_left.y;
|
||||||
for (0..height) |_| terminal.index() catch |err| {
|
for (0..height) |_| terminal.index() catch |err| {
|
||||||
log.warn("failed to move cursor: {}", .{err});
|
log.warn("failed to move cursor: {}", .{err});
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
|
|
||||||
terminal.setCursorPos(
|
terminal.setCursorPos(
|
||||||
terminal.screen.cursor.y + 1,
|
terminal.screen.cursor.y,
|
||||||
rect.bottom_right.x + 1,
|
rect.bottom_right.x + 1,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -105,8 +105,6 @@ pub fn init(alloc: Allocator, opts: termio.Options) !Exec {
|
|||||||
);
|
);
|
||||||
errdefer term.deinit(alloc);
|
errdefer term.deinit(alloc);
|
||||||
term.color_palette = opts.config.palette;
|
term.color_palette = opts.config.palette;
|
||||||
term.width_px = opts.screen_size.width;
|
|
||||||
term.height_px = opts.screen_size.height;
|
|
||||||
|
|
||||||
// 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(alloc, opts.config.image_storage_limit);
|
||||||
@ -115,6 +113,10 @@ pub fn init(alloc: Allocator, opts: termio.Options) !Exec {
|
|||||||
var subprocess = try Subprocess.init(alloc, opts);
|
var subprocess = try Subprocess.init(alloc, opts);
|
||||||
errdefer subprocess.deinit();
|
errdefer subprocess.deinit();
|
||||||
|
|
||||||
|
// Initial width/height based on subprocess
|
||||||
|
term.width_px = subprocess.screen_size.width;
|
||||||
|
term.height_px = subprocess.screen_size.height;
|
||||||
|
|
||||||
return Exec{
|
return Exec{
|
||||||
.alloc = alloc,
|
.alloc = alloc,
|
||||||
.terminal = term,
|
.terminal = term,
|
||||||
@ -289,8 +291,8 @@ pub fn resize(
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Update our pixel sizes
|
// Update our pixel sizes
|
||||||
self.terminal.width_px = screen_size.width;
|
self.terminal.width_px = padded_size.width;
|
||||||
self.terminal.height_px = screen_size.height;
|
self.terminal.height_px = padded_size.height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -682,6 +684,9 @@ const Subprocess = struct {
|
|||||||
log.warn("shell could not be detected, no automatic shell integration will be injected", .{});
|
log.warn("shell could not be detected, no automatic shell integration will be injected", .{});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Our screen size should be our padded size
|
||||||
|
const padded_size = opts.screen_size.subPadding(opts.padding);
|
||||||
|
|
||||||
return .{
|
return .{
|
||||||
.arena = arena,
|
.arena = arena,
|
||||||
.env = env,
|
.env = env,
|
||||||
@ -689,7 +694,7 @@ const Subprocess = struct {
|
|||||||
.path = final_path,
|
.path = final_path,
|
||||||
.args = args,
|
.args = args,
|
||||||
.grid_size = opts.grid_size,
|
.grid_size = opts.grid_size,
|
||||||
.screen_size = opts.screen_size,
|
.screen_size = padded_size,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,9 @@ grid_size: renderer.GridSize,
|
|||||||
/// The size of the viewport in pixels.
|
/// The size of the viewport in pixels.
|
||||||
screen_size: renderer.ScreenSize,
|
screen_size: renderer.ScreenSize,
|
||||||
|
|
||||||
|
/// The padding of the viewport.
|
||||||
|
padding: renderer.Padding,
|
||||||
|
|
||||||
/// The full app configuration. This is only available during initialization.
|
/// The full app configuration. This is only available during initialization.
|
||||||
/// The memory it points to is NOT stable after the init call so any values
|
/// The memory it points to is NOT stable after the init call so any values
|
||||||
/// in here must be copied.
|
/// in here must be copied.
|
||||||
|
Reference in New Issue
Block a user