mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
remove tracy usage from all files
This commit is contained in:
@ -30,7 +30,6 @@ const imgui = @import("imgui");
|
|||||||
const Pty = @import("pty.zig").Pty;
|
const Pty = @import("pty.zig").Pty;
|
||||||
const font = @import("font/main.zig");
|
const font = @import("font/main.zig");
|
||||||
const Command = @import("Command.zig");
|
const Command = @import("Command.zig");
|
||||||
const trace = @import("tracy").trace;
|
|
||||||
const terminal = @import("terminal/main.zig");
|
const terminal = @import("terminal/main.zig");
|
||||||
const configpkg = @import("config.zig");
|
const configpkg = @import("config.zig");
|
||||||
const input = @import("input.zig");
|
const input = @import("input.zig");
|
||||||
@ -1048,9 +1047,6 @@ fn queueRender(self: *Surface) !void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn sizeCallback(self: *Surface, size: apprt.SurfaceSize) !void {
|
pub fn sizeCallback(self: *Surface, size: apprt.SurfaceSize) !void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
const new_screen_size: renderer.ScreenSize = .{
|
const new_screen_size: renderer.ScreenSize = .{
|
||||||
.width = size.width,
|
.width = size.width,
|
||||||
.height = size.height,
|
.height = size.height,
|
||||||
@ -1453,9 +1449,6 @@ pub fn scrollCallback(
|
|||||||
yoff: f64,
|
yoff: f64,
|
||||||
scroll_mods: input.ScrollMods,
|
scroll_mods: input.ScrollMods,
|
||||||
) !void {
|
) !void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
// log.info("SCROLL: xoff={} yoff={} mods={}", .{ xoff, yoff, scroll_mods });
|
// log.info("SCROLL: xoff={} yoff={} mods={}", .{ xoff, yoff, scroll_mods });
|
||||||
|
|
||||||
// Always show the mouse again if it is hidden
|
// Always show the mouse again if it is hidden
|
||||||
@ -1919,9 +1912,6 @@ pub fn mouseButtonCallback(
|
|||||||
) !void {
|
) !void {
|
||||||
// log.debug("mouse action={} button={} mods={}", .{ action, button, mods });
|
// log.debug("mouse action={} button={} mods={}", .{ action, button, mods });
|
||||||
|
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
// If we have an inspector, we always queue a render
|
// If we have an inspector, we always queue a render
|
||||||
if (self.inspector) |insp| {
|
if (self.inspector) |insp| {
|
||||||
defer self.queueRender() catch {};
|
defer self.queueRender() catch {};
|
||||||
@ -2275,9 +2265,6 @@ pub fn cursorPosCallback(
|
|||||||
self: *Surface,
|
self: *Surface,
|
||||||
pos: apprt.CursorPos,
|
pos: apprt.CursorPos,
|
||||||
) !void {
|
) !void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
// Always show the mouse again if it is hidden
|
// Always show the mouse again if it is hidden
|
||||||
if (self.mouse.hidden) self.showMouse();
|
if (self.mouse.hidden) self.showMouse();
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ const builtin = @import("builtin");
|
|||||||
const build_config = @import("../build_config.zig");
|
const build_config = @import("../build_config.zig");
|
||||||
const assert = std.debug.assert;
|
const assert = std.debug.assert;
|
||||||
const Allocator = std.mem.Allocator;
|
const Allocator = std.mem.Allocator;
|
||||||
const trace = @import("tracy").trace;
|
|
||||||
const glfw = @import("glfw");
|
const glfw = @import("glfw");
|
||||||
const macos = @import("macos");
|
const macos = @import("macos");
|
||||||
const objc = @import("objc");
|
const objc = @import("objc");
|
||||||
@ -741,9 +740,6 @@ pub const Surface = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn charCallback(window: glfw.Window, codepoint: u21) void {
|
fn charCallback(window: glfw.Window, codepoint: u21) void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
const core_win = window.getUserPointer(CoreSurface) orelse return;
|
const core_win = window.getUserPointer(CoreSurface) orelse return;
|
||||||
|
|
||||||
// We need a key event in order to process the charcallback. If it
|
// We need a key event in order to process the charcallback. If it
|
||||||
@ -780,8 +776,6 @@ pub const Surface = struct {
|
|||||||
glfw_action: glfw.Action,
|
glfw_action: glfw.Action,
|
||||||
glfw_mods: glfw.Mods,
|
glfw_mods: glfw.Mods,
|
||||||
) void {
|
) void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
_ = scancode;
|
_ = scancode;
|
||||||
|
|
||||||
const core_win = window.getUserPointer(CoreSurface) orelse return;
|
const core_win = window.getUserPointer(CoreSurface) orelse return;
|
||||||
@ -954,9 +948,6 @@ pub const Surface = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn focusCallback(window: glfw.Window, focused: bool) void {
|
fn focusCallback(window: glfw.Window, focused: bool) void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
const core_win = window.getUserPointer(CoreSurface) orelse return;
|
const core_win = window.getUserPointer(CoreSurface) orelse return;
|
||||||
core_win.focusCallback(focused) catch |err| {
|
core_win.focusCallback(focused) catch |err| {
|
||||||
log.err("error in focus callback err={}", .{err});
|
log.err("error in focus callback err={}", .{err});
|
||||||
@ -965,9 +956,6 @@ pub const Surface = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn refreshCallback(window: glfw.Window) void {
|
fn refreshCallback(window: glfw.Window) void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
const core_win = window.getUserPointer(CoreSurface) orelse return;
|
const core_win = window.getUserPointer(CoreSurface) orelse return;
|
||||||
core_win.refreshCallback() catch |err| {
|
core_win.refreshCallback() catch |err| {
|
||||||
log.err("error in refresh callback err={}", .{err});
|
log.err("error in refresh callback err={}", .{err});
|
||||||
@ -976,9 +964,6 @@ pub const Surface = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn scrollCallback(window: glfw.Window, xoff: f64, yoff: f64) void {
|
fn scrollCallback(window: glfw.Window, xoff: f64, yoff: f64) void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
// Glfw doesn't support any of the scroll mods.
|
// Glfw doesn't support any of the scroll mods.
|
||||||
const scroll_mods: input.ScrollMods = .{};
|
const scroll_mods: input.ScrollMods = .{};
|
||||||
|
|
||||||
@ -994,9 +979,6 @@ pub const Surface = struct {
|
|||||||
unscaled_xpos: f64,
|
unscaled_xpos: f64,
|
||||||
unscaled_ypos: f64,
|
unscaled_ypos: f64,
|
||||||
) void {
|
) void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
const core_win = window.getUserPointer(CoreSurface) orelse return;
|
const core_win = window.getUserPointer(CoreSurface) orelse return;
|
||||||
|
|
||||||
// Convert our unscaled x/y to scaled.
|
// Convert our unscaled x/y to scaled.
|
||||||
@ -1026,9 +1008,6 @@ pub const Surface = struct {
|
|||||||
glfw_action: glfw.Action,
|
glfw_action: glfw.Action,
|
||||||
glfw_mods: glfw.Mods,
|
glfw_mods: glfw.Mods,
|
||||||
) void {
|
) void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
const core_win = window.getUserPointer(CoreSurface) orelse return;
|
const core_win = window.getUserPointer(CoreSurface) orelse return;
|
||||||
|
|
||||||
// Convert glfw button to input button
|
// Convert glfw button to input button
|
||||||
@ -1061,9 +1040,6 @@ pub const Surface = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn dropCallback(window: glfw.Window, paths: [][*:0]const u8) void {
|
fn dropCallback(window: glfw.Window, paths: [][*:0]const u8) void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
const surface = window.getUserPointer(CoreSurface) orelse return;
|
const surface = window.getUserPointer(CoreSurface) orelse return;
|
||||||
|
|
||||||
var list = std.ArrayList(u8).init(surface.alloc);
|
var list = std.ArrayList(u8).init(surface.alloc);
|
||||||
|
@ -10,6 +10,37 @@ const apprt = @import("apprt.zig");
|
|||||||
const font = @import("font/main.zig");
|
const font = @import("font/main.zig");
|
||||||
const rendererpkg = @import("renderer.zig");
|
const rendererpkg = @import("renderer.zig");
|
||||||
|
|
||||||
|
/// The build configuratin options. This may not be all available options
|
||||||
|
/// to `zig build` but it contains all the options that the Ghostty source
|
||||||
|
/// needs to know about at comptime.
|
||||||
|
///
|
||||||
|
/// We put this all in a single struct so that we can check compatibility
|
||||||
|
/// between options, make it easy to copy and mutate options for different
|
||||||
|
/// build types, etc.
|
||||||
|
pub const BuildConfig = struct {
|
||||||
|
app_runtime: apprt.Runtime = .none,
|
||||||
|
renderer: rendererpkg.Impl = .opengl,
|
||||||
|
font_backend: font.Backend = .freetype,
|
||||||
|
|
||||||
|
/// Configure the build options with our values.
|
||||||
|
pub fn addOptions(self: BuildConfig, step: *std.Build.Step.Options) void {
|
||||||
|
// We need to break these down individual because addOption doesn't
|
||||||
|
// support all types.
|
||||||
|
step.addOption(apprt.Runtime, "app_runtime", self.app_runtime);
|
||||||
|
step.addOption(font.Backend, "font_backend", self.font_backend);
|
||||||
|
step.addOption(rendererpkg.Impl, "renderer", self.renderer_impl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Rehydrate our BuildConfig from the comptime options.
|
||||||
|
pub fn fromOptions() BuildConfig {
|
||||||
|
return .{
|
||||||
|
.app_runtime = std.meta.stringToEnum(apprt.Runtime, @tagName(options.app_runtime)).?,
|
||||||
|
.font_backend = std.meta.stringToEnum(font.Backend, @tagName(options.font_backend)).?,
|
||||||
|
.renderer = std.meta.stringToEnum(rendererpkg.Impl, @tagName(options.renderer)).?,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/// The semantic version of this build.
|
/// The semantic version of this build.
|
||||||
pub const version = options.app_version;
|
pub const version = options.app_version;
|
||||||
pub const version_string = options.app_version_string;
|
pub const version_string = options.app_version_string;
|
||||||
@ -18,23 +49,11 @@ pub const version_string = options.app_version_string;
|
|||||||
/// building a standalone exe, an embedded lib, etc.
|
/// building a standalone exe, an embedded lib, etc.
|
||||||
pub const artifact = Artifact.detect();
|
pub const artifact = Artifact.detect();
|
||||||
|
|
||||||
/// The runtime to back exe artifacts with.
|
/// Our build configuration.
|
||||||
pub const app_runtime: apprt.Runtime = switch (artifact) {
|
pub const config = BuildConfig.fromOptions();
|
||||||
.lib => .none,
|
pub const app_runtime: apprt.Runtime = config.app_runtime;
|
||||||
else => std.meta.stringToEnum(apprt.Runtime, @tagName(options.app_runtime)).?,
|
pub const font_backend: font.Backend = config.font_backend;
|
||||||
};
|
pub const renderer: rendererpkg.Impl = config.renderer;
|
||||||
|
|
||||||
/// The font backend desired for the build.
|
|
||||||
pub const font_backend: font.Backend = std.meta.stringToEnum(
|
|
||||||
font.Backend,
|
|
||||||
@tagName(options.font_backend),
|
|
||||||
).?;
|
|
||||||
|
|
||||||
/// The renderer implementation to use.
|
|
||||||
pub const renderer: rendererpkg.Impl = std.meta.stringToEnum(
|
|
||||||
rendererpkg.Impl,
|
|
||||||
@tagName(options.renderer),
|
|
||||||
).?;
|
|
||||||
|
|
||||||
/// We want to integrate with Flatpak APIs.
|
/// We want to integrate with Flatpak APIs.
|
||||||
pub const flatpak = options.flatpak;
|
pub const flatpak = options.flatpak;
|
||||||
|
@ -2,7 +2,6 @@ const std = @import("std");
|
|||||||
const assert = std.debug.assert;
|
const assert = std.debug.assert;
|
||||||
const Allocator = std.mem.Allocator;
|
const Allocator = std.mem.Allocator;
|
||||||
const harfbuzz = @import("harfbuzz");
|
const harfbuzz = @import("harfbuzz");
|
||||||
const trace = @import("tracy").trace;
|
|
||||||
const font = @import("../main.zig");
|
const font = @import("../main.zig");
|
||||||
const Face = font.Face;
|
const Face = font.Face;
|
||||||
const DeferredFace = font.DeferredFace;
|
const DeferredFace = font.DeferredFace;
|
||||||
@ -106,9 +105,6 @@ pub const Shaper = struct {
|
|||||||
///
|
///
|
||||||
/// If there is not enough space in the cell buffer, an error is returned.
|
/// If there is not enough space in the cell buffer, an error is returned.
|
||||||
pub fn shape(self: *Shaper, run: font.shape.TextRun) ![]const font.shape.Cell {
|
pub fn shape(self: *Shaper, run: font.shape.TextRun) ![]const font.shape.Cell {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
// We only do shaping if the font is not a special-case. For special-case
|
// We only do shaping if the font is not a special-case. For special-case
|
||||||
// fonts, the codepoint == glyph_index so we don't need to run any shaping.
|
// fonts, the codepoint == glyph_index so we don't need to run any shaping.
|
||||||
if (run.font_index.special() == null) {
|
if (run.font_index.special() == null) {
|
||||||
|
@ -4,7 +4,6 @@ const Allocator = std.mem.Allocator;
|
|||||||
const font = @import("../main.zig");
|
const font = @import("../main.zig");
|
||||||
const shape = @import("../shape.zig");
|
const shape = @import("../shape.zig");
|
||||||
const terminal = @import("../../terminal/main.zig");
|
const terminal = @import("../../terminal/main.zig");
|
||||||
const trace = @import("tracy").trace;
|
|
||||||
|
|
||||||
/// A single text run. A text run is only valid for one Shaper instance and
|
/// A single text run. A text run is only valid for one Shaper instance and
|
||||||
/// until the next run is created. A text run never goes across multiple
|
/// until the next run is created. A text run never goes across multiple
|
||||||
@ -33,9 +32,6 @@ pub const RunIterator = struct {
|
|||||||
i: usize = 0,
|
i: usize = 0,
|
||||||
|
|
||||||
pub fn next(self: *RunIterator, alloc: Allocator) !?TextRun {
|
pub fn next(self: *RunIterator, alloc: Allocator) !?TextRun {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
// Trim the right side of a row that might be empty
|
// Trim the right side of a row that might be empty
|
||||||
const max: usize = max: {
|
const max: usize = max: {
|
||||||
var j: usize = self.row.lenCells();
|
var j: usize = self.row.lenCells();
|
||||||
|
26
src/main.zig
26
src/main.zig
@ -7,7 +7,6 @@ const glfw = @import("glfw");
|
|||||||
const glslang = @import("glslang");
|
const glslang = @import("glslang");
|
||||||
const macos = @import("macos");
|
const macos = @import("macos");
|
||||||
const oni = @import("oniguruma");
|
const oni = @import("oniguruma");
|
||||||
const tracy = @import("tracy");
|
|
||||||
const cli = @import("cli.zig");
|
const cli = @import("cli.zig");
|
||||||
const internal_os = @import("os/main.zig");
|
const internal_os = @import("os/main.zig");
|
||||||
const xev = @import("xev");
|
const xev = @import("xev");
|
||||||
@ -167,7 +166,6 @@ pub const GlobalState = struct {
|
|||||||
|
|
||||||
gpa: ?GPA,
|
gpa: ?GPA,
|
||||||
alloc: std.mem.Allocator,
|
alloc: std.mem.Allocator,
|
||||||
tracy: if (tracy.enabled) ?tracy.Allocator(null) else void,
|
|
||||||
action: ?cli.Action,
|
action: ?cli.Action,
|
||||||
logging: Logging,
|
logging: Logging,
|
||||||
|
|
||||||
@ -189,7 +187,6 @@ pub const GlobalState = struct {
|
|||||||
self.* = .{
|
self.* = .{
|
||||||
.gpa = null,
|
.gpa = null,
|
||||||
.alloc = undefined,
|
.alloc = undefined,
|
||||||
.tracy = undefined,
|
|
||||||
.action = null,
|
.action = null,
|
||||||
.logging = .{ .stderr = {} },
|
.logging = .{ .stderr = {} },
|
||||||
.resources_dir = null,
|
.resources_dir = null,
|
||||||
@ -213,19 +210,12 @@ pub const GlobalState = struct {
|
|||||||
break :gpa GPA{};
|
break :gpa GPA{};
|
||||||
};
|
};
|
||||||
|
|
||||||
self.alloc = alloc: {
|
self.alloc = if (self.gpa) |*value|
|
||||||
const base = if (self.gpa) |*value|
|
value.allocator()
|
||||||
value.allocator()
|
else if (builtin.link_libc)
|
||||||
else if (builtin.link_libc)
|
std.heap.c_allocator
|
||||||
std.heap.c_allocator
|
else
|
||||||
else
|
unreachable;
|
||||||
unreachable;
|
|
||||||
|
|
||||||
// If we're tracing, wrap the allocator
|
|
||||||
if (!tracy.enabled) break :alloc base;
|
|
||||||
self.tracy = tracy.allocator(base, null);
|
|
||||||
break :alloc self.tracy.?.allocator();
|
|
||||||
};
|
|
||||||
|
|
||||||
// We first try to parse any action that we may be executing.
|
// We first try to parse any action that we may be executing.
|
||||||
self.action = try cli.Action.detectCLI(self.alloc);
|
self.action = try cli.Action.detectCLI(self.alloc);
|
||||||
@ -292,10 +282,6 @@ pub const GlobalState = struct {
|
|||||||
// the point at which it will output if there were safety violations.
|
// the point at which it will output if there were safety violations.
|
||||||
_ = value.deinit();
|
_ = value.deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tracy.enabled) {
|
|
||||||
self.tracy = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
test {
|
test {
|
||||||
|
@ -19,7 +19,6 @@ const renderer = @import("../renderer.zig");
|
|||||||
const terminal = @import("../terminal/main.zig");
|
const terminal = @import("../terminal/main.zig");
|
||||||
const Terminal = terminal.Terminal;
|
const Terminal = terminal.Terminal;
|
||||||
const gl = @import("opengl");
|
const gl = @import("opengl");
|
||||||
const trace = @import("tracy").trace;
|
|
||||||
const math = @import("../math.zig");
|
const math = @import("../math.zig");
|
||||||
const Surface = @import("../Surface.zig");
|
const Surface = @import("../Surface.zig");
|
||||||
|
|
||||||
@ -946,9 +945,6 @@ pub fn rebuildCells(
|
|||||||
cursor_style_: ?renderer.CursorStyle,
|
cursor_style_: ?renderer.CursorStyle,
|
||||||
color_palette: *const terminal.color.Palette,
|
color_palette: *const terminal.color.Palette,
|
||||||
) !void {
|
) !void {
|
||||||
const t = trace(@src());
|
|
||||||
defer t.end();
|
|
||||||
|
|
||||||
// Bg cells at most will need space for the visible screen size
|
// Bg cells at most will need space for the visible screen size
|
||||||
self.cells_bg.clearRetainingCapacity();
|
self.cells_bg.clearRetainingCapacity();
|
||||||
try self.cells_bg.ensureTotalCapacity(self.alloc, screen.rows * screen.cols);
|
try self.cells_bg.ensureTotalCapacity(self.alloc, screen.rows * screen.cols);
|
||||||
@ -1344,9 +1340,6 @@ fn updateCell(
|
|||||||
x: usize,
|
x: usize,
|
||||||
y: usize,
|
y: usize,
|
||||||
) !bool {
|
) !bool {
|
||||||
const t = trace(@src());
|
|
||||||
defer t.end();
|
|
||||||
|
|
||||||
const BgFg = struct {
|
const BgFg = struct {
|
||||||
/// Background is optional because in un-inverted mode
|
/// Background is optional because in un-inverted mode
|
||||||
/// it may just be equivalent to the default background in
|
/// it may just be equivalent to the default background in
|
||||||
@ -1781,9 +1774,6 @@ fn flushAtlas(self: *OpenGL) !void {
|
|||||||
/// Render renders the current cell state. This will not modify any of
|
/// Render renders the current cell state. This will not modify any of
|
||||||
/// the cells.
|
/// the cells.
|
||||||
pub fn drawFrame(self: *OpenGL, surface: *apprt.Surface) !void {
|
pub fn drawFrame(self: *OpenGL, surface: *apprt.Surface) !void {
|
||||||
const t = trace(@src());
|
|
||||||
defer t.end();
|
|
||||||
|
|
||||||
// If we're in single-threaded more we grab a lock since we use shared data.
|
// If we're in single-threaded more we grab a lock since we use shared data.
|
||||||
if (single_threaded_draw) self.draw_mutex.lock();
|
if (single_threaded_draw) self.draw_mutex.lock();
|
||||||
defer if (single_threaded_draw) self.draw_mutex.unlock();
|
defer if (single_threaded_draw) self.draw_mutex.unlock();
|
||||||
|
@ -9,8 +9,6 @@ const renderer = @import("../renderer.zig");
|
|||||||
const apprt = @import("../apprt.zig");
|
const apprt = @import("../apprt.zig");
|
||||||
const configpkg = @import("../config.zig");
|
const configpkg = @import("../config.zig");
|
||||||
const BlockingQueue = @import("../blocking_queue.zig").BlockingQueue;
|
const BlockingQueue = @import("../blocking_queue.zig").BlockingQueue;
|
||||||
const tracy = @import("tracy");
|
|
||||||
const trace = tracy.trace;
|
|
||||||
const App = @import("../App.zig");
|
const App = @import("../App.zig");
|
||||||
|
|
||||||
const Allocator = std.mem.Allocator;
|
const Allocator = std.mem.Allocator;
|
||||||
@ -177,7 +175,6 @@ pub fn threadMain(self: *Thread) void {
|
|||||||
|
|
||||||
fn threadMain_(self: *Thread) !void {
|
fn threadMain_(self: *Thread) !void {
|
||||||
defer log.debug("renderer thread exited", .{});
|
defer log.debug("renderer thread exited", .{});
|
||||||
tracy.setThreadName("renderer");
|
|
||||||
|
|
||||||
// Run our thread start/end callbacks. This is important because some
|
// Run our thread start/end callbacks. This is important because some
|
||||||
// renderers have to do per-thread setup. For example, OpenGL has to set
|
// renderers have to do per-thread setup. For example, OpenGL has to set
|
||||||
@ -242,9 +239,6 @@ fn stopDrawTimer(self: *Thread) void {
|
|||||||
|
|
||||||
/// Drain the mailbox.
|
/// Drain the mailbox.
|
||||||
fn drainMailbox(self: *Thread) !void {
|
fn drainMailbox(self: *Thread) !void {
|
||||||
const zone = trace(@src());
|
|
||||||
defer zone.end();
|
|
||||||
|
|
||||||
while (self.mailbox.pop()) |message| {
|
while (self.mailbox.pop()) |message| {
|
||||||
log.debug("mailbox message={}", .{message});
|
log.debug("mailbox message={}", .{message});
|
||||||
switch (message) {
|
switch (message) {
|
||||||
@ -358,9 +352,6 @@ fn wakeupCallback(
|
|||||||
return .rearm;
|
return .rearm;
|
||||||
};
|
};
|
||||||
|
|
||||||
const zone = trace(@src());
|
|
||||||
defer zone.end();
|
|
||||||
|
|
||||||
const t = self_.?;
|
const t = self_.?;
|
||||||
|
|
||||||
// When we wake up, we check the mailbox. Mailbox producers should
|
// When we wake up, we check the mailbox. Mailbox producers should
|
||||||
@ -425,9 +416,6 @@ fn renderCallback(
|
|||||||
_: *xev.Completion,
|
_: *xev.Completion,
|
||||||
r: xev.Timer.RunError!void,
|
r: xev.Timer.RunError!void,
|
||||||
) xev.CallbackAction {
|
) xev.CallbackAction {
|
||||||
const zone = trace(@src());
|
|
||||||
defer zone.end();
|
|
||||||
|
|
||||||
_ = r catch unreachable;
|
_ = r catch unreachable;
|
||||||
const t = self_ orelse {
|
const t = self_ orelse {
|
||||||
// This shouldn't happen so we log it.
|
// This shouldn't happen so we log it.
|
||||||
@ -470,9 +458,6 @@ fn cursorTimerCallback(
|
|||||||
_: *xev.Completion,
|
_: *xev.Completion,
|
||||||
r: xev.Timer.RunError!void,
|
r: xev.Timer.RunError!void,
|
||||||
) xev.CallbackAction {
|
) xev.CallbackAction {
|
||||||
const zone = trace(@src());
|
|
||||||
defer zone.end();
|
|
||||||
|
|
||||||
_ = r catch |err| switch (err) {
|
_ = r catch |err| switch (err) {
|
||||||
// This is sent when our timer is canceled. That's fine.
|
// This is sent when our timer is canceled. That's fine.
|
||||||
error.Canceled => return .disarm,
|
error.Canceled => return .disarm,
|
||||||
|
@ -6,7 +6,6 @@ const Parser = @This();
|
|||||||
|
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const builtin = @import("builtin");
|
const builtin = @import("builtin");
|
||||||
const trace = @import("tracy").trace;
|
|
||||||
const testing = std.testing;
|
const testing = std.testing;
|
||||||
const table = @import("parse_table.zig").table;
|
const table = @import("parse_table.zig").table;
|
||||||
const osc = @import("osc.zig");
|
const osc = @import("osc.zig");
|
||||||
@ -231,9 +230,6 @@ pub fn deinit(self: *Parser) void {
|
|||||||
/// Up to 3 actions may need to be executed -- in order -- representing
|
/// Up to 3 actions may need to be executed -- in order -- representing
|
||||||
/// the state exit, transition, and entry actions.
|
/// the state exit, transition, and entry actions.
|
||||||
pub fn next(self: *Parser, c: u8) [3]?Action {
|
pub fn next(self: *Parser, c: u8) [3]?Action {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
// If we're processing UTF-8, we handle this manually.
|
// If we're processing UTF-8, we handle this manually.
|
||||||
if (self.state == .utf8) {
|
if (self.state == .utf8) {
|
||||||
return .{ self.next_utf8(c), null, null };
|
return .{ self.next_utf8(c), null, null };
|
||||||
|
@ -58,7 +58,6 @@ const assert = std.debug.assert;
|
|||||||
const Allocator = std.mem.Allocator;
|
const Allocator = std.mem.Allocator;
|
||||||
|
|
||||||
const ziglyph = @import("ziglyph");
|
const ziglyph = @import("ziglyph");
|
||||||
const trace = @import("tracy").trace;
|
|
||||||
const ansi = @import("ansi.zig");
|
const ansi = @import("ansi.zig");
|
||||||
const modes = @import("modes.zig");
|
const modes = @import("modes.zig");
|
||||||
const sgr = @import("sgr.zig");
|
const sgr = @import("sgr.zig");
|
||||||
@ -803,9 +802,6 @@ pub const RowIndexTag = enum {
|
|||||||
/// so it is 1-indexed. If the value is zero, it means that this
|
/// so it is 1-indexed. If the value is zero, it means that this
|
||||||
/// section of the screen is empty or disabled.
|
/// section of the screen is empty or disabled.
|
||||||
pub inline fn maxLen(self: RowIndexTag, screen: *const Screen) usize {
|
pub inline fn maxLen(self: RowIndexTag, screen: *const Screen) usize {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
return switch (self) {
|
return switch (self) {
|
||||||
// Screen can be any of the written rows
|
// Screen can be any of the written rows
|
||||||
.screen => screen.rowsWritten(),
|
.screen => screen.rowsWritten(),
|
||||||
@ -1177,9 +1173,6 @@ pub fn getCellPtr(self: *Screen, tag: RowIndexTag, y: usize, x: usize) *Cell {
|
|||||||
/// from index zero of the given row index type. This can therefore iterate
|
/// from index zero of the given row index type. This can therefore iterate
|
||||||
/// from row 0 of the active area, history, viewport, etc.
|
/// from row 0 of the active area, history, viewport, etc.
|
||||||
pub fn rowIterator(self: *Screen, tag: RowIndexTag) RowIterator {
|
pub fn rowIterator(self: *Screen, tag: RowIndexTag) RowIterator {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
return .{
|
return .{
|
||||||
.screen = self,
|
.screen = self,
|
||||||
.tag = tag,
|
.tag = tag,
|
||||||
@ -1234,9 +1227,6 @@ pub fn getLine(self: *Screen, pt: point.ScreenPoint) ?Line {
|
|||||||
/// Returns the row at the given index. This row is writable, although
|
/// Returns the row at the given index. This row is writable, although
|
||||||
/// only the active area should probably be written to.
|
/// only the active area should probably be written to.
|
||||||
pub fn getRow(self: *Screen, index: RowIndex) Row {
|
pub fn getRow(self: *Screen, index: RowIndex) Row {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
// Get our offset into storage
|
// Get our offset into storage
|
||||||
const offset = index.toScreen(self).screen * (self.cols + 1);
|
const offset = index.toScreen(self).screen * (self.cols + 1);
|
||||||
|
|
||||||
@ -1288,9 +1278,6 @@ pub fn copyRow(self: *Screen, dst: RowIndex, src: RowIndex) !void {
|
|||||||
///
|
///
|
||||||
/// This can be used to implement terminal scroll regions efficiently.
|
/// This can be used to implement terminal scroll regions efficiently.
|
||||||
pub fn scrollRegionUp(self: *Screen, top: RowIndex, bottom: RowIndex, count_req: usize) void {
|
pub fn scrollRegionUp(self: *Screen, top: RowIndex, bottom: RowIndex, count_req: usize) void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
// Avoid a lot of work if we're doing nothing.
|
// Avoid a lot of work if we're doing nothing.
|
||||||
if (count_req == 0) return;
|
if (count_req == 0) return;
|
||||||
|
|
||||||
@ -2091,9 +2078,6 @@ fn scrollRow(self: *Screen, idx: RowIndex) void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn scrollDelta(self: *Screen, delta: isize, viewport_only: bool) Allocator.Error!void {
|
fn scrollDelta(self: *Screen, delta: isize, viewport_only: bool) Allocator.Error!void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
// Just in case, to avoid a bunch of stuff below.
|
// Just in case, to avoid a bunch of stuff below.
|
||||||
if (delta == 0) return;
|
if (delta == 0) return;
|
||||||
|
|
||||||
@ -2585,9 +2569,6 @@ fn selectionSlices(self: *Screen, sel_raw: Selection) SelectionSlices {
|
|||||||
/// be truncated as they are shrunk. If they are grown, the new space is filled
|
/// be truncated as they are shrunk. If they are grown, the new space is filled
|
||||||
/// with zeros.
|
/// with zeros.
|
||||||
pub fn resizeWithoutReflow(self: *Screen, rows: usize, cols: usize) !void {
|
pub fn resizeWithoutReflow(self: *Screen, rows: usize, cols: usize) !void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
// If we're resizing to the same size, do nothing.
|
// If we're resizing to the same size, do nothing.
|
||||||
if (self.cols == cols and self.rows == rows) return;
|
if (self.cols == cols and self.rows == rows) return;
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@ const csi = @import("csi.zig");
|
|||||||
const kitty = @import("kitty.zig");
|
const kitty = @import("kitty.zig");
|
||||||
const sgr = @import("sgr.zig");
|
const sgr = @import("sgr.zig");
|
||||||
const Tabstops = @import("Tabstops.zig");
|
const Tabstops = @import("Tabstops.zig");
|
||||||
const trace = @import("tracy").trace;
|
|
||||||
const color = @import("color.zig");
|
const color = @import("color.zig");
|
||||||
const Screen = @import("Screen.zig");
|
const Screen = @import("Screen.zig");
|
||||||
const mouse_shape = @import("mouse_shape.zig");
|
const mouse_shape = @import("mouse_shape.zig");
|
||||||
@ -213,9 +212,6 @@ pub fn alternateScreen(
|
|||||||
alloc: Allocator,
|
alloc: Allocator,
|
||||||
options: AlternateScreenOptions,
|
options: AlternateScreenOptions,
|
||||||
) void {
|
) void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
//log.info("alt screen active={} options={} cursor={}", .{ self.active_screen, options, self.screen.cursor });
|
//log.info("alt screen active={} options={} cursor={}", .{ self.active_screen, options, self.screen.cursor });
|
||||||
|
|
||||||
// TODO: test
|
// TODO: test
|
||||||
@ -255,9 +251,6 @@ pub fn primaryScreen(
|
|||||||
alloc: Allocator,
|
alloc: Allocator,
|
||||||
options: AlternateScreenOptions,
|
options: AlternateScreenOptions,
|
||||||
) void {
|
) void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
//log.info("primary screen active={} options={}", .{ self.active_screen, options });
|
//log.info("primary screen active={} options={}", .{ self.active_screen, options });
|
||||||
|
|
||||||
// TODO: test
|
// TODO: test
|
||||||
@ -296,9 +289,6 @@ pub const DeccolmMode = enum(u1) {
|
|||||||
/// with the window. This will fix the grid at either 80 or 132 columns.
|
/// with the window. This will fix the grid at either 80 or 132 columns.
|
||||||
/// The rows will continue to be variable.
|
/// The rows will continue to be variable.
|
||||||
pub fn deccolm(self: *Terminal, alloc: Allocator, mode: DeccolmMode) !void {
|
pub fn deccolm(self: *Terminal, alloc: Allocator, mode: DeccolmMode) !void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
// If DEC mode 40 isn't enabled, then this is ignored. We also make
|
// If DEC mode 40 isn't enabled, then this is ignored. We also make
|
||||||
// sure that we don't have deccolm set because we want to fully ignore
|
// sure that we don't have deccolm set because we want to fully ignore
|
||||||
// set mode.
|
// set mode.
|
||||||
@ -327,9 +317,6 @@ pub fn deccolm(self: *Terminal, alloc: Allocator, mode: DeccolmMode) !void {
|
|||||||
|
|
||||||
/// Resize the underlying terminal.
|
/// Resize the underlying terminal.
|
||||||
pub fn resize(self: *Terminal, alloc: Allocator, cols: usize, rows: usize) !void {
|
pub fn resize(self: *Terminal, alloc: Allocator, cols: usize, rows: usize) !void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
// If our cols/rows didn't change then we're done
|
// If our cols/rows didn't change then we're done
|
||||||
if (self.cols == cols and self.rows == rows) return;
|
if (self.cols == cols and self.rows == rows) return;
|
||||||
|
|
||||||
@ -469,9 +456,6 @@ pub fn restoreCursor(self: *Terminal) void {
|
|||||||
|
|
||||||
/// TODO: test
|
/// TODO: test
|
||||||
pub fn setAttribute(self: *Terminal, attr: sgr.Attribute) !void {
|
pub fn setAttribute(self: *Terminal, attr: sgr.Attribute) !void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
switch (attr) {
|
switch (attr) {
|
||||||
.unset => {
|
.unset => {
|
||||||
self.screen.cursor.pen.fg = .none;
|
self.screen.cursor.pen.fg = .none;
|
||||||
@ -732,9 +716,6 @@ pub fn printString(self: *Terminal, str: []const u8) !void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn print(self: *Terminal, c: u21) !void {
|
pub fn print(self: *Terminal, c: u21) !void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
// log.debug("print={x} y={} x={}", .{ c, self.screen.cursor.y, self.screen.cursor.x });
|
// log.debug("print={x} y={} x={}", .{ c, self.screen.cursor.y, self.screen.cursor.x });
|
||||||
|
|
||||||
// If we're not on the main display, do nothing for now
|
// If we're not on the main display, do nothing for now
|
||||||
@ -971,9 +952,6 @@ pub fn print(self: *Terminal, c: u21) !void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn printCell(self: *Terminal, unmapped_c: u21) *Screen.Cell {
|
fn printCell(self: *Terminal, unmapped_c: u21) *Screen.Cell {
|
||||||
// const tracy = trace(@src());
|
|
||||||
// defer tracy.end();
|
|
||||||
|
|
||||||
const c: u21 = c: {
|
const c: u21 = c: {
|
||||||
// TODO: non-utf8 handling, gr
|
// TODO: non-utf8 handling, gr
|
||||||
|
|
||||||
@ -1034,9 +1012,6 @@ fn printCell(self: *Terminal, unmapped_c: u21) *Screen.Cell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn printWrap(self: *Terminal) !void {
|
fn printWrap(self: *Terminal) !void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
const row = self.screen.getRow(.{ .active = self.screen.cursor.y });
|
const row = self.screen.getRow(.{ .active = self.screen.cursor.y });
|
||||||
row.setWrapped(true);
|
row.setWrapped(true);
|
||||||
|
|
||||||
@ -1068,9 +1043,6 @@ pub fn printRepeat(self: *Terminal, count_req: usize) !void {
|
|||||||
///
|
///
|
||||||
/// Sets the cursor to the top left corner.
|
/// Sets the cursor to the top left corner.
|
||||||
pub fn decaln(self: *Terminal) !void {
|
pub fn decaln(self: *Terminal) !void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
// Reset margins, also sets cursor to top-left
|
// Reset margins, also sets cursor to top-left
|
||||||
self.scrolling_region = .{
|
self.scrolling_region = .{
|
||||||
.top = 0,
|
.top = 0,
|
||||||
@ -1117,9 +1089,6 @@ pub fn decaln(self: *Terminal) !void {
|
|||||||
///
|
///
|
||||||
/// This unsets the pending wrap state without wrapping.
|
/// This unsets the pending wrap state without wrapping.
|
||||||
pub fn index(self: *Terminal) !void {
|
pub fn index(self: *Terminal) !void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
// Unset pending wrap state
|
// Unset pending wrap state
|
||||||
self.screen.cursor.pending_wrap = false;
|
self.screen.cursor.pending_wrap = false;
|
||||||
|
|
||||||
@ -1170,9 +1139,6 @@ pub fn index(self: *Terminal) !void {
|
|||||||
/// * If the cursor is not on the top-most line of the scrolling region:
|
/// * If the cursor is not on the top-most line of the scrolling region:
|
||||||
/// move the cursor one line up
|
/// move the cursor one line up
|
||||||
pub fn reverseIndex(self: *Terminal) !void {
|
pub fn reverseIndex(self: *Terminal) !void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
if (self.screen.cursor.y != self.scrolling_region.top or
|
if (self.screen.cursor.y != self.scrolling_region.top or
|
||||||
self.screen.cursor.x < self.scrolling_region.left or
|
self.screen.cursor.x < self.scrolling_region.left or
|
||||||
self.screen.cursor.x > self.scrolling_region.right)
|
self.screen.cursor.x > self.scrolling_region.right)
|
||||||
@ -1191,9 +1157,6 @@ pub fn reverseIndex(self: *Terminal) !void {
|
|||||||
// greater than the bottom-most row it is adjusted to the bottom-most
|
// greater than the bottom-most row it is adjusted to the bottom-most
|
||||||
// row.
|
// row.
|
||||||
pub fn setCursorPos(self: *Terminal, row_req: usize, col_req: usize) void {
|
pub fn setCursorPos(self: *Terminal, row_req: usize, col_req: usize) void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
// If cursor origin mode is set the cursor row will be moved relative to
|
// If cursor origin mode is set the cursor row will be moved relative to
|
||||||
// the top margin row and adjusted to be above or at bottom-most row in
|
// the top margin row and adjusted to be above or at bottom-most row in
|
||||||
// the current scroll region.
|
// the current scroll region.
|
||||||
@ -1233,9 +1196,6 @@ pub fn eraseDisplay(
|
|||||||
mode: csi.EraseDisplay,
|
mode: csi.EraseDisplay,
|
||||||
protected_req: bool,
|
protected_req: bool,
|
||||||
) void {
|
) void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
// Erasing clears all attributes / colors _except_ the background
|
// Erasing clears all attributes / colors _except_ the background
|
||||||
const pen: Screen.Cell = switch (self.screen.cursor.pen.bg) {
|
const pen: Screen.Cell = switch (self.screen.cursor.pen.bg) {
|
||||||
.none => .{},
|
.none => .{},
|
||||||
@ -1384,9 +1344,6 @@ pub fn eraseLine(
|
|||||||
mode: csi.EraseLine,
|
mode: csi.EraseLine,
|
||||||
protected_req: bool,
|
protected_req: bool,
|
||||||
) void {
|
) void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
// We always fill with the background
|
// We always fill with the background
|
||||||
const pen: Screen.Cell = switch (self.screen.cursor.pen.bg) {
|
const pen: Screen.Cell = switch (self.screen.cursor.pen.bg) {
|
||||||
.none => .{},
|
.none => .{},
|
||||||
@ -1463,9 +1420,6 @@ pub fn eraseLine(
|
|||||||
///
|
///
|
||||||
/// Does not change the cursor position.
|
/// Does not change the cursor position.
|
||||||
pub fn deleteChars(self: *Terminal, count: usize) !void {
|
pub fn deleteChars(self: *Terminal, count: usize) !void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
if (count == 0) return;
|
if (count == 0) return;
|
||||||
|
|
||||||
// If our cursor is outside the margins then do nothing. We DO reset
|
// If our cursor is outside the margins then do nothing. We DO reset
|
||||||
@ -1510,9 +1464,6 @@ pub fn deleteChars(self: *Terminal, count: usize) !void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn eraseChars(self: *Terminal, count_req: usize) void {
|
pub fn eraseChars(self: *Terminal, count_req: usize) void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
const count = @max(count_req, 1);
|
const count = @max(count_req, 1);
|
||||||
|
|
||||||
// This resets the pending wrap state
|
// This resets the pending wrap state
|
||||||
@ -1556,9 +1507,6 @@ pub fn eraseChars(self: *Terminal, count_req: usize) void {
|
|||||||
|
|
||||||
/// Move the cursor to the left amount cells. If amount is 0, adjust it to 1.
|
/// Move the cursor to the left amount cells. If amount is 0, adjust it to 1.
|
||||||
pub fn cursorLeft(self: *Terminal, count_req: usize) void {
|
pub fn cursorLeft(self: *Terminal, count_req: usize) void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
// Wrapping behavior depends on various terminal modes
|
// Wrapping behavior depends on various terminal modes
|
||||||
const WrapMode = enum { none, reverse, reverse_extended };
|
const WrapMode = enum { none, reverse, reverse_extended };
|
||||||
const wrap_mode: WrapMode = wrap_mode: {
|
const wrap_mode: WrapMode = wrap_mode: {
|
||||||
@ -1665,9 +1613,6 @@ pub fn cursorLeft(self: *Terminal, count_req: usize) void {
|
|||||||
/// This sequence will not scroll the screen or scroll region. If amount is
|
/// This sequence will not scroll the screen or scroll region. If amount is
|
||||||
/// 0, adjust it to 1.
|
/// 0, adjust it to 1.
|
||||||
pub fn cursorRight(self: *Terminal, count_req: usize) void {
|
pub fn cursorRight(self: *Terminal, count_req: usize) void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
// Always resets pending wrap
|
// Always resets pending wrap
|
||||||
self.screen.cursor.pending_wrap = false;
|
self.screen.cursor.pending_wrap = false;
|
||||||
|
|
||||||
@ -1685,9 +1630,6 @@ pub fn cursorRight(self: *Terminal, count_req: usize) void {
|
|||||||
/// move distance then it is internally adjusted to the maximum. This sequence
|
/// move distance then it is internally adjusted to the maximum. This sequence
|
||||||
/// will not scroll the screen or scroll region. If amount is 0, adjust it to 1.
|
/// will not scroll the screen or scroll region. If amount is 0, adjust it to 1.
|
||||||
pub fn cursorDown(self: *Terminal, count_req: usize) void {
|
pub fn cursorDown(self: *Terminal, count_req: usize) void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
// Always resets pending wrap
|
// Always resets pending wrap
|
||||||
self.screen.cursor.pending_wrap = false;
|
self.screen.cursor.pending_wrap = false;
|
||||||
|
|
||||||
@ -1705,9 +1647,6 @@ pub fn cursorDown(self: *Terminal, count_req: usize) void {
|
|||||||
/// move distance then it is internally adjusted to the maximum. If amount is
|
/// move distance then it is internally adjusted to the maximum. If amount is
|
||||||
/// 0, adjust it to 1.
|
/// 0, adjust it to 1.
|
||||||
pub fn cursorUp(self: *Terminal, count_req: usize) void {
|
pub fn cursorUp(self: *Terminal, count_req: usize) void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
// Always resets pending wrap
|
// Always resets pending wrap
|
||||||
self.screen.cursor.pending_wrap = false;
|
self.screen.cursor.pending_wrap = false;
|
||||||
|
|
||||||
@ -1723,18 +1662,12 @@ pub fn cursorUp(self: *Terminal, count_req: usize) void {
|
|||||||
|
|
||||||
/// Backspace moves the cursor back a column (but not less than 0).
|
/// Backspace moves the cursor back a column (but not less than 0).
|
||||||
pub fn backspace(self: *Terminal) void {
|
pub fn backspace(self: *Terminal) void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
self.cursorLeft(1);
|
self.cursorLeft(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Horizontal tab moves the cursor to the next tabstop, clearing
|
/// Horizontal tab moves the cursor to the next tabstop, clearing
|
||||||
/// the screen to the left the tabstop.
|
/// the screen to the left the tabstop.
|
||||||
pub fn horizontalTab(self: *Terminal) !void {
|
pub fn horizontalTab(self: *Terminal) !void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
while (self.screen.cursor.x < self.scrolling_region.right) {
|
while (self.screen.cursor.x < self.scrolling_region.right) {
|
||||||
// Move the cursor right
|
// Move the cursor right
|
||||||
self.screen.cursor.x += 1;
|
self.screen.cursor.x += 1;
|
||||||
@ -1748,9 +1681,6 @@ pub fn horizontalTab(self: *Terminal) !void {
|
|||||||
|
|
||||||
// Same as horizontalTab but moves to the previous tabstop instead of the next.
|
// Same as horizontalTab but moves to the previous tabstop instead of the next.
|
||||||
pub fn horizontalTabBack(self: *Terminal) !void {
|
pub fn horizontalTabBack(self: *Terminal) !void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
// With origin mode enabled, our leftmost limit is the left margin.
|
// With origin mode enabled, our leftmost limit is the left margin.
|
||||||
const left_limit = if (self.modes.get(.origin)) self.scrolling_region.left else 0;
|
const left_limit = if (self.modes.get(.origin)) self.scrolling_region.left else 0;
|
||||||
|
|
||||||
@ -1786,9 +1716,6 @@ pub fn tabReset(self: *Terminal) void {
|
|||||||
|
|
||||||
/// Carriage return moves the cursor to the first column.
|
/// Carriage return moves the cursor to the first column.
|
||||||
pub fn carriageReturn(self: *Terminal) void {
|
pub fn carriageReturn(self: *Terminal) void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
// Always reset pending wrap state
|
// Always reset pending wrap state
|
||||||
self.screen.cursor.pending_wrap = false;
|
self.screen.cursor.pending_wrap = false;
|
||||||
|
|
||||||
@ -1803,9 +1730,6 @@ pub fn carriageReturn(self: *Terminal) void {
|
|||||||
|
|
||||||
/// Linefeed moves the cursor to the next line.
|
/// Linefeed moves the cursor to the next line.
|
||||||
pub fn linefeed(self: *Terminal) !void {
|
pub fn linefeed(self: *Terminal) !void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
try self.index();
|
try self.index();
|
||||||
if (self.modes.get(.linefeed)) self.carriageReturn();
|
if (self.modes.get(.linefeed)) self.carriageReturn();
|
||||||
}
|
}
|
||||||
@ -1818,9 +1742,6 @@ pub fn linefeed(self: *Terminal) !void {
|
|||||||
///
|
///
|
||||||
/// The inserted cells are colored according to the current SGR state.
|
/// The inserted cells are colored according to the current SGR state.
|
||||||
pub fn insertBlanks(self: *Terminal, count: usize) void {
|
pub fn insertBlanks(self: *Terminal, count: usize) void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
// Unset pending wrap state without wrapping. Note: this purposely
|
// Unset pending wrap state without wrapping. Note: this purposely
|
||||||
// happens BEFORE the scroll region check below, because that's what
|
// happens BEFORE the scroll region check below, because that's what
|
||||||
// xterm does.
|
// xterm does.
|
||||||
@ -1901,9 +1822,6 @@ pub fn insertBlanks(self: *Terminal, count: usize) void {
|
|||||||
///
|
///
|
||||||
/// Moves the cursor to the left margin.
|
/// Moves the cursor to the left margin.
|
||||||
pub fn insertLines(self: *Terminal, count: usize) !void {
|
pub fn insertLines(self: *Terminal, count: usize) !void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
// Rare, but happens
|
// Rare, but happens
|
||||||
if (count == 0) return;
|
if (count == 0) return;
|
||||||
|
|
||||||
@ -1965,9 +1883,6 @@ pub fn insertLines(self: *Terminal, count: usize) !void {
|
|||||||
///
|
///
|
||||||
/// Moves the cursor to the left margin.
|
/// Moves the cursor to the left margin.
|
||||||
pub fn deleteLines(self: *Terminal, count: usize) !void {
|
pub fn deleteLines(self: *Terminal, count: usize) !void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
// If the cursor is outside the scroll region we do nothing.
|
// If the cursor is outside the scroll region we do nothing.
|
||||||
if (self.screen.cursor.y < self.scrolling_region.top or
|
if (self.screen.cursor.y < self.scrolling_region.top or
|
||||||
self.screen.cursor.y > self.scrolling_region.bottom or
|
self.screen.cursor.y > self.scrolling_region.bottom or
|
||||||
@ -2024,9 +1939,6 @@ pub fn deleteLines(self: *Terminal, count: usize) !void {
|
|||||||
|
|
||||||
/// Scroll the text down by one row.
|
/// Scroll the text down by one row.
|
||||||
pub fn scrollDown(self: *Terminal, count: usize) !void {
|
pub fn scrollDown(self: *Terminal, count: usize) !void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
// Preserve the cursor
|
// Preserve the cursor
|
||||||
const cursor = self.screen.cursor;
|
const cursor = self.screen.cursor;
|
||||||
defer self.screen.cursor = cursor;
|
defer self.screen.cursor = cursor;
|
||||||
@ -2045,9 +1957,6 @@ pub fn scrollDown(self: *Terminal, count: usize) !void {
|
|||||||
///
|
///
|
||||||
/// Does not change the (absolute) cursor position.
|
/// Does not change the (absolute) cursor position.
|
||||||
pub fn scrollUp(self: *Terminal, count: usize) !void {
|
pub fn scrollUp(self: *Terminal, count: usize) !void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
// Preserve the cursor
|
// Preserve the cursor
|
||||||
const cursor = self.screen.cursor;
|
const cursor = self.screen.cursor;
|
||||||
defer self.screen.cursor = cursor;
|
defer self.screen.cursor = cursor;
|
||||||
@ -2072,9 +1981,6 @@ pub const ScrollViewport = union(enum) {
|
|||||||
|
|
||||||
/// Scroll the viewport of the terminal grid.
|
/// Scroll the viewport of the terminal grid.
|
||||||
pub fn scrollViewport(self: *Terminal, behavior: ScrollViewport) !void {
|
pub fn scrollViewport(self: *Terminal, behavior: ScrollViewport) !void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
try self.screen.scroll(switch (behavior) {
|
try self.screen.scroll(switch (behavior) {
|
||||||
.top => .{ .top = {} },
|
.top => .{ .top = {} },
|
||||||
.bottom => .{ .bottom = {} },
|
.bottom => .{ .bottom = {} },
|
||||||
@ -2095,9 +2001,6 @@ pub fn scrollViewport(self: *Terminal, behavior: ScrollViewport) !void {
|
|||||||
///
|
///
|
||||||
/// Top and bottom are 1-indexed.
|
/// Top and bottom are 1-indexed.
|
||||||
pub fn setTopAndBottomMargin(self: *Terminal, top_req: usize, bottom_req: usize) void {
|
pub fn setTopAndBottomMargin(self: *Terminal, top_req: usize, bottom_req: usize) void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
const top = @max(1, top_req);
|
const top = @max(1, top_req);
|
||||||
const bottom = @min(self.rows, if (bottom_req == 0) self.rows else bottom_req);
|
const bottom = @min(self.rows, if (bottom_req == 0) self.rows else bottom_req);
|
||||||
if (top >= bottom) return;
|
if (top >= bottom) return;
|
||||||
@ -2109,9 +2012,6 @@ pub fn setTopAndBottomMargin(self: *Terminal, top_req: usize, bottom_req: usize)
|
|||||||
|
|
||||||
/// DECSLRM
|
/// DECSLRM
|
||||||
pub fn setLeftAndRightMargin(self: *Terminal, left_req: usize, right_req: usize) void {
|
pub fn setLeftAndRightMargin(self: *Terminal, left_req: usize, right_req: usize) void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
// We must have this mode enabled to do anything
|
// We must have this mode enabled to do anything
|
||||||
if (!self.modes.get(.enable_left_and_right_margin)) return;
|
if (!self.modes.get(.enable_left_and_right_margin)) return;
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ const kitty = @import("kitty.zig");
|
|||||||
const modes = @import("modes.zig");
|
const modes = @import("modes.zig");
|
||||||
const osc = @import("osc.zig");
|
const osc = @import("osc.zig");
|
||||||
const sgr = @import("sgr.zig");
|
const sgr = @import("sgr.zig");
|
||||||
const trace = @import("tracy").trace;
|
|
||||||
const MouseShape = @import("mouse_shape.zig").MouseShape;
|
const MouseShape = @import("mouse_shape.zig").MouseShape;
|
||||||
|
|
||||||
const log = std.log.scoped(.stream);
|
const log = std.log.scoped(.stream);
|
||||||
@ -44,17 +43,11 @@ pub fn Stream(comptime Handler: type) type {
|
|||||||
|
|
||||||
/// Process a string of characters.
|
/// Process a string of characters.
|
||||||
pub fn nextSlice(self: *Self, c: []const u8) !void {
|
pub fn nextSlice(self: *Self, c: []const u8) !void {
|
||||||
const tracy = trace(@src());
|
|
||||||
defer tracy.end();
|
|
||||||
for (c) |single| try self.next(single);
|
for (c) |single| try self.next(single);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Process the next character and call any callbacks if necessary.
|
/// Process the next character and call any callbacks if necessary.
|
||||||
pub fn next(self: *Self, c: u8) !void {
|
pub fn next(self: *Self, c: u8) !void {
|
||||||
const tracy = trace(@src());
|
|
||||||
tracy.value(@as(u64, @intCast(c)));
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
// log.debug("char: {c}", .{c});
|
// log.debug("char: {c}", .{c});
|
||||||
const actions = self.parser.next(c);
|
const actions = self.parser.next(c);
|
||||||
for (actions) |action_opt| {
|
for (actions) |action_opt| {
|
||||||
@ -108,10 +101,6 @@ pub fn Stream(comptime Handler: type) type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn execute(self: *Self, c: u8) !void {
|
pub fn execute(self: *Self, c: u8) !void {
|
||||||
const tracy = trace(@src());
|
|
||||||
tracy.value(@as(u64, @intCast(c)));
|
|
||||||
defer tracy.end();
|
|
||||||
|
|
||||||
switch (@as(ansi.C0, @enumFromInt(c))) {
|
switch (@as(ansi.C0, @enumFromInt(c))) {
|
||||||
// We ignore SOH/STX: https://github.com/microsoft/terminal/issues/10786
|
// We ignore SOH/STX: https://github.com/microsoft/terminal/issues/10786
|
||||||
.NUL, .SOH, .STX => {},
|
.NUL, .SOH, .STX => {},
|
||||||
|
@ -16,8 +16,6 @@ const terminal = @import("../terminal/main.zig");
|
|||||||
const terminfo = @import("../terminfo/main.zig");
|
const terminfo = @import("../terminfo/main.zig");
|
||||||
const xev = @import("xev");
|
const xev = @import("xev");
|
||||||
const renderer = @import("../renderer.zig");
|
const renderer = @import("../renderer.zig");
|
||||||
const tracy = @import("tracy");
|
|
||||||
const trace = tracy.trace;
|
|
||||||
const apprt = @import("../apprt.zig");
|
const apprt = @import("../apprt.zig");
|
||||||
const fastmem = @import("../fastmem.zig");
|
const fastmem = @import("../fastmem.zig");
|
||||||
const internal_os = @import("../os/main.zig");
|
const internal_os = @import("../os/main.zig");
|
||||||
@ -1514,9 +1512,6 @@ const ReadThread = struct {
|
|||||||
ev: *EventData,
|
ev: *EventData,
|
||||||
buf: []const u8,
|
buf: []const u8,
|
||||||
) void {
|
) void {
|
||||||
const zone = trace(@src());
|
|
||||||
defer zone.end();
|
|
||||||
|
|
||||||
// log.info("DATA: {d}", .{n});
|
// log.info("DATA: {d}", .{n});
|
||||||
// log.info("DATA: {any}", .{buf[0..@intCast(usize, n)]});
|
// log.info("DATA: {any}", .{buf[0..@intCast(usize, n)]});
|
||||||
|
|
||||||
|
@ -7,8 +7,6 @@ const builtin = @import("builtin");
|
|||||||
const xev = @import("xev");
|
const xev = @import("xev");
|
||||||
const termio = @import("../termio.zig");
|
const termio = @import("../termio.zig");
|
||||||
const BlockingQueue = @import("../blocking_queue.zig").BlockingQueue;
|
const BlockingQueue = @import("../blocking_queue.zig").BlockingQueue;
|
||||||
const tracy = @import("tracy");
|
|
||||||
const trace = tracy.trace;
|
|
||||||
|
|
||||||
const Allocator = std.mem.Allocator;
|
const Allocator = std.mem.Allocator;
|
||||||
const log = std.log.scoped(.io_thread);
|
const log = std.log.scoped(.io_thread);
|
||||||
@ -142,7 +140,6 @@ pub fn threadMain(self: *Thread) void {
|
|||||||
|
|
||||||
fn threadMain_(self: *Thread) !void {
|
fn threadMain_(self: *Thread) !void {
|
||||||
defer log.debug("IO thread exited", .{});
|
defer log.debug("IO thread exited", .{});
|
||||||
tracy.setThreadName("pty io");
|
|
||||||
|
|
||||||
// Run our thread start/end callbacks. This allows the implementation
|
// Run our thread start/end callbacks. This allows the implementation
|
||||||
// to hook into the event loop as needed.
|
// to hook into the event loop as needed.
|
||||||
@ -162,9 +159,6 @@ fn threadMain_(self: *Thread) !void {
|
|||||||
|
|
||||||
/// Drain the mailbox, handling all the messages in our terminal implementation.
|
/// Drain the mailbox, handling all the messages in our terminal implementation.
|
||||||
fn drainMailbox(self: *Thread) !void {
|
fn drainMailbox(self: *Thread) !void {
|
||||||
const zone = trace(@src());
|
|
||||||
defer zone.end();
|
|
||||||
|
|
||||||
// This holds the mailbox lock for the duration of the drain. The
|
// This holds the mailbox lock for the duration of the drain. The
|
||||||
// expectation is that all our message handlers will be non-blocking
|
// expectation is that all our message handlers will be non-blocking
|
||||||
// ENOUGH to not mess up throughput on producers.
|
// ENOUGH to not mess up throughput on producers.
|
||||||
@ -290,9 +284,6 @@ fn wakeupCallback(
|
|||||||
return .rearm;
|
return .rearm;
|
||||||
};
|
};
|
||||||
|
|
||||||
const zone = trace(@src());
|
|
||||||
defer zone.end();
|
|
||||||
|
|
||||||
const t = self_.?;
|
const t = self_.?;
|
||||||
|
|
||||||
// When we wake up, we check the mailbox. Mailbox producers should
|
// When we wake up, we check the mailbox. Mailbox producers should
|
||||||
|
Reference in New Issue
Block a user