mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
Cell GPU cache must also key by screen type (primary/alternate)
This commit is contained in:
13
src/Grid.zig
13
src/Grid.zig
@ -16,7 +16,13 @@ const lru = @import("lru.zig");
|
|||||||
|
|
||||||
const log = std.log.scoped(.grid);
|
const log = std.log.scoped(.grid);
|
||||||
|
|
||||||
const CellsLRU = lru.AutoHashMap(terminal.Screen.RowHeader.Id, std.ArrayListUnmanaged(GPUCell));
|
// The LRU is keyed by (screen, row_id) since we need to cache rows
|
||||||
|
// separately for alt screens. By storing that in the key, we very likely
|
||||||
|
// have the cache already for when the primary screen is reactivated.
|
||||||
|
const CellsLRU = lru.AutoHashMap(struct {
|
||||||
|
screen: terminal.Terminal.ScreenType,
|
||||||
|
row_id: terminal.Screen.RowHeader.Id,
|
||||||
|
}, std.ArrayListUnmanaged(GPUCell));
|
||||||
|
|
||||||
alloc: std.mem.Allocator,
|
alloc: std.mem.Allocator,
|
||||||
|
|
||||||
@ -379,7 +385,10 @@ pub fn rebuildCells(self: *Grid, term: *Terminal) !void {
|
|||||||
defer y += 1;
|
defer y += 1;
|
||||||
|
|
||||||
// Get our value from the cache.
|
// Get our value from the cache.
|
||||||
const gop = try self.cells_lru.getOrPut(self.alloc, row.getId());
|
const gop = try self.cells_lru.getOrPut(self.alloc, .{
|
||||||
|
.screen = term.active_screen,
|
||||||
|
.row_id = row.getId(),
|
||||||
|
});
|
||||||
if (!row.isDirty() and gop.found_existing) {
|
if (!row.isDirty() and gop.found_existing) {
|
||||||
var i: usize = self.cells.items.len;
|
var i: usize = self.cells.items.len;
|
||||||
for (gop.value_ptr.items) |cell| {
|
for (gop.value_ptr.items) |cell| {
|
||||||
|
@ -27,7 +27,7 @@ const log = std.log.scoped(.terminal);
|
|||||||
const TABSTOP_INTERVAL = 8;
|
const TABSTOP_INTERVAL = 8;
|
||||||
|
|
||||||
/// Screen type is an enum that tracks whether a screen is primary or alternate.
|
/// Screen type is an enum that tracks whether a screen is primary or alternate.
|
||||||
const ScreenType = enum {
|
pub const ScreenType = enum {
|
||||||
primary,
|
primary,
|
||||||
alternate,
|
alternate,
|
||||||
};
|
};
|
||||||
@ -172,6 +172,8 @@ pub fn alternateScreen(self: *Terminal, options: AlternateScreenOptions) void {
|
|||||||
const tracy = trace(@src());
|
const tracy = trace(@src());
|
||||||
defer tracy.end();
|
defer tracy.end();
|
||||||
|
|
||||||
|
//log.info("alt screen active={} options={} cursor={}", .{ self.active_screen, options, self.screen.cursor });
|
||||||
|
|
||||||
// TODO: test
|
// TODO: test
|
||||||
// TODO(mitchellh): what happens if we enter alternate screen multiple times?
|
// TODO(mitchellh): what happens if we enter alternate screen multiple times?
|
||||||
// for now, we ignore...
|
// for now, we ignore...
|
||||||
@ -199,6 +201,8 @@ pub fn primaryScreen(self: *Terminal, options: AlternateScreenOptions) void {
|
|||||||
const tracy = trace(@src());
|
const tracy = trace(@src());
|
||||||
defer tracy.end();
|
defer tracy.end();
|
||||||
|
|
||||||
|
//log.info("primary screen active={} options={}", .{ self.active_screen, options });
|
||||||
|
|
||||||
// TODO: test
|
// TODO: test
|
||||||
// TODO(mitchellh): what happens if we enter alternate screen multiple times?
|
// TODO(mitchellh): what happens if we enter alternate screen multiple times?
|
||||||
if (self.active_screen == .primary) return;
|
if (self.active_screen == .primary) return;
|
||||||
|
@ -51,7 +51,8 @@ pub fn Stream(comptime Handler: type) type {
|
|||||||
const actions = self.parser.next(c);
|
const actions = self.parser.next(c);
|
||||||
for (actions) |action_opt| {
|
for (actions) |action_opt| {
|
||||||
// if (action_opt) |action| {
|
// if (action_opt) |action| {
|
||||||
// log.info("action: {}", .{action});
|
// if (action != .print)
|
||||||
|
// log.info("action: {}", .{action});
|
||||||
// }
|
// }
|
||||||
switch (action_opt orelse continue) {
|
switch (action_opt orelse continue) {
|
||||||
.print => |p| if (@hasDecl(T, "print")) try self.handler.print(p),
|
.print => |p| if (@hasDecl(T, "print")) try self.handler.print(p),
|
||||||
|
Reference in New Issue
Block a user