Zig 0.14: Rename imports to remove new namespace collisions

This now fails with errors like "error: duplicate struct member name 'layout'"
This commit is contained in:
LN Liberda
2025-03-10 00:42:41 +01:00
parent 881a03cb66
commit a58537d6d3
11 changed files with 84 additions and 84 deletions

View File

@ -24,7 +24,7 @@ const global_state = &@import("global.zig").state;
const oni = @import("oniguruma"); const oni = @import("oniguruma");
const crash = @import("crash/main.zig"); const crash = @import("crash/main.zig");
const unicode = @import("unicode/main.zig"); const unicode = @import("unicode/main.zig");
const renderer = @import("renderer.zig"); const renderer_mod = @import("renderer.zig");
const termio = @import("termio.zig"); const termio = @import("termio.zig");
const objc = @import("objc"); const objc = @import("objc");
const imgui = @import("imgui"); const imgui = @import("imgui");
@ -36,13 +36,13 @@ const configpkg = @import("config.zig");
const input = @import("input.zig"); const input = @import("input.zig");
const App = @import("App.zig"); const App = @import("App.zig");
const internal_os = @import("os/main.zig"); const internal_os = @import("os/main.zig");
const inspector = @import("inspector/main.zig"); const inspector_mod = @import("inspector/main.zig");
const SurfaceMouse = @import("surface_mouse.zig"); const SurfaceMouse = @import("surface_mouse.zig");
const log = std.log.scoped(.surface); const log = std.log.scoped(.surface);
// The renderer implementation to use. // The renderer implementation to use.
const Renderer = renderer.Renderer; const Renderer = renderer_mod.Renderer;
/// Minimum window size in cells. This is used to prevent the window from /// Minimum window size in cells. This is used to prevent the window from
/// being resized to a size that is too small to be useful. These defaults /// being resized to a size that is too small to be useful. These defaults
@ -70,10 +70,10 @@ font_metrics: font.Metrics,
renderer: Renderer, renderer: Renderer,
/// The render state /// The render state
renderer_state: renderer.State, renderer_state: renderer_mod.State,
/// The renderer thread manager /// The renderer thread manager
renderer_thread: renderer.Thread, renderer_thread: renderer_mod.Thread,
/// The actual thread /// The actual thread
renderer_thr: std.Thread, renderer_thr: std.Thread,
@ -113,10 +113,10 @@ io_thread: termio.Thread,
io_thr: std.Thread, io_thr: std.Thread,
/// Terminal inspector /// Terminal inspector
inspector: ?*inspector.Inspector = null, inspector: ?*inspector_mod.Inspector = null,
/// All our sizing information. /// All our sizing information.
size: renderer.Size, size: renderer_mod.Size,
/// The configuration derived from the main config. We "derive" it so that /// The configuration derived from the main config. We "derive" it so that
/// we don't have a shared pointer hanging around that we need to worry about /// we don't have a shared pointer hanging around that we need to worry about
@ -339,7 +339,7 @@ const DerivedConfig = struct {
self.arena.deinit(); self.arena.deinit();
} }
fn scaledPadding(self: *const DerivedConfig, x_dpi: f32, y_dpi: f32) renderer.Padding { fn scaledPadding(self: *const DerivedConfig, x_dpi: f32, y_dpi: f32) renderer_mod.Padding {
const padding_top: u32 = padding_top: { const padding_top: u32 = padding_top: {
const padding_top: f32 = @floatFromInt(self.window_padding_top); const padding_top: f32 = @floatFromInt(self.window_padding_top);
break :padding_top @intFromFloat(@floor(padding_top * y_dpi / 72)); break :padding_top @intFromFloat(@floor(padding_top * y_dpi / 72));
@ -431,8 +431,8 @@ pub fn init(
); );
// Build our size struct which has all the sizes we need. // Build our size struct which has all the sizes we need.
const size: renderer.Size = size: { const size: renderer_mod.Size = size: {
var size: renderer.Size = .{ var size: renderer_mod.Size = .{
.screen = screen: { .screen = screen: {
const surface_size = try rt_surface.getSize(); const surface_size = try rt_surface.getSize();
break :screen .{ break :screen .{
@ -445,7 +445,7 @@ pub fn init(
.padding = .{}, .padding = .{},
}; };
const explicit: renderer.Padding = derived_config.scaledPadding( const explicit: renderer_mod.Padding = derived_config.scaledPadding(
x_dpi, x_dpi,
y_dpi, y_dpi,
); );
@ -475,7 +475,7 @@ pub fn init(
errdefer alloc.destroy(mutex); errdefer alloc.destroy(mutex);
// Create the renderer thread // Create the renderer thread
var render_thread = try renderer.Thread.init( var render_thread = try renderer_mod.Thread.init(
alloc, alloc,
config, config,
rt_surface, rt_surface,
@ -611,7 +611,7 @@ pub fn init(
// Start our renderer thread // Start our renderer thread
self.renderer_thr = try std.Thread.spawn( self.renderer_thr = try std.Thread.spawn(
.{}, .{},
renderer.Thread.threadMain, renderer_mod.Thread.threadMain,
.{&self.renderer_thread}, .{&self.renderer_thread},
); );
self.renderer_thr.setName("renderer") catch {}; self.renderer_thr.setName("renderer") catch {};
@ -736,9 +736,9 @@ pub fn activateInspector(self: *Surface) !void {
if (self.inspector != null) return; if (self.inspector != null) return;
// Setup the inspector // Setup the inspector
const ptr = try self.alloc.create(inspector.Inspector); const ptr = try self.alloc.create(inspector_mod.Inspector);
errdefer self.alloc.destroy(ptr); errdefer self.alloc.destroy(ptr);
ptr.* = try inspector.Inspector.init(self); ptr.* = try inspector_mod.Inspector.init(self);
self.inspector = ptr; self.inspector = ptr;
// Put the inspector onto the render state // Put the inspector onto the render state
@ -1091,7 +1091,7 @@ fn mouseRefreshLinks(
} }
/// Called when our renderer health state changes. /// Called when our renderer health state changes.
fn updateRendererHealth(self: *Surface, health: renderer.Health) void { fn updateRendererHealth(self: *Surface, health: renderer_mod.Health) void {
log.warn("renderer health status change status={}", .{health}); log.warn("renderer health status change status={}", .{health});
_ = self.rt_app.performAction( _ = self.rt_app.performAction(
.{ .surface = self }, .{ .surface = self },
@ -1163,7 +1163,7 @@ pub fn updateConfig(
// We need to store our configs in a heap-allocated pointer so that // We need to store our configs in a heap-allocated pointer so that
// our messages aren't huge. // our messages aren't huge.
var renderer_message = try renderer.Message.initChangeConfig(self.alloc, config); var renderer_message = try renderer_mod.Message.initChangeConfig(self.alloc, config);
errdefer renderer_message.deinit(); errdefer renderer_message.deinit();
var termio_config_ptr = try self.alloc.create(termio.Termio.DerivedConfig); var termio_config_ptr = try self.alloc.create(termio.Termio.DerivedConfig);
errdefer self.alloc.destroy(termio_config_ptr); errdefer self.alloc.destroy(termio_config_ptr);
@ -1497,7 +1497,7 @@ fn setSelection(self: *Surface, sel_: ?terminal.Selection) !void {
/// Change the cell size for the terminal grid. This can happen as /// Change the cell size for the terminal grid. This can happen as
/// a result of changing the font size at runtime. /// a result of changing the font size at runtime.
fn setCellSize(self: *Surface, size: renderer.CellSize) !void { fn setCellSize(self: *Surface, size: renderer_mod.CellSize) !void {
// Update our cell size within our size struct // Update our cell size within our size struct
self.size.cell = size; self.size.cell = size;
self.balancePaddingIfNeeded(); self.balancePaddingIfNeeded();
@ -1573,7 +1573,7 @@ pub fn sizeCallback(self: *Surface, size: apprt.SurfaceSize) !void {
crash.sentry.thread_state = self.crashThreadState(); crash.sentry.thread_state = self.crashThreadState();
defer crash.sentry.thread_state = null; defer crash.sentry.thread_state = null;
const new_screen_size: renderer.ScreenSize = .{ const new_screen_size: renderer_mod.ScreenSize = .{
.width = size.width, .width = size.width,
.height = size.height, .height = size.height,
}; };
@ -1586,7 +1586,7 @@ pub fn sizeCallback(self: *Surface, size: apprt.SurfaceSize) !void {
try self.resize(new_screen_size); try self.resize(new_screen_size);
} }
fn resize(self: *Surface, size: renderer.ScreenSize) !void { fn resize(self: *Surface, size: renderer_mod.ScreenSize) !void {
// Save our screen size // Save our screen size
self.size.screen = size; self.size.screen = size;
self.balancePaddingIfNeeded(); self.balancePaddingIfNeeded();
@ -1667,7 +1667,7 @@ pub fn preeditCallback(self: *Surface, preedit_: ?[]const u8) !void {
var it = view.iterator(); var it = view.iterator();
// Allocate the codepoints slice // Allocate the codepoints slice
const Codepoint = renderer.State.Preedit.Codepoint; const Codepoint = renderer_mod.State.Preedit.Codepoint;
var codepoints: std.ArrayListUnmanaged(Codepoint) = .{}; var codepoints: std.ArrayListUnmanaged(Codepoint) = .{};
defer codepoints.deinit(self.alloc); defer codepoints.deinit(self.alloc);
while (it.nextCodepoint()) |cp| { while (it.nextCodepoint()) |cp| {
@ -1734,7 +1734,7 @@ pub fn keyCallback(
defer crash.sentry.thread_state = null; defer crash.sentry.thread_state = null;
// Setup our inspector event if we have an inspector. // Setup our inspector event if we have an inspector.
var insp_ev: ?inspector.key.Event = if (self.inspector != null) ev: { var insp_ev: ?inspector_mod.key.Event = if (self.inspector != null) ev: {
var copy = event; var copy = event;
copy.utf8 = ""; copy.utf8 = "";
if (event.utf8.len > 0) copy.utf8 = try self.alloc.dupe(u8, event.utf8); if (event.utf8.len > 0) copy.utf8 = try self.alloc.dupe(u8, event.utf8);
@ -1898,7 +1898,7 @@ pub fn keyCallback(
fn maybeHandleBinding( fn maybeHandleBinding(
self: *Surface, self: *Surface,
event: input.KeyEvent, event: input.KeyEvent,
insp_ev: ?*inspector.key.Event, insp_ev: ?*inspector_mod.key.Event,
) !?InputEffect { ) !?InputEffect {
switch (event.action) { switch (event.action) {
// Release events never trigger a binding but we need to check if // Release events never trigger a binding but we need to check if
@ -2106,7 +2106,7 @@ fn endKeySequence(
fn encodeKey( fn encodeKey(
self: *Surface, self: *Surface,
event: input.KeyEvent, event: input.KeyEvent,
insp_ev: ?*inspector.key.Event, insp_ev: ?*inspector_mod.key.Event,
) !?termio.Message.WriteReq { ) !?termio.Message.WriteReq {
// Build up our encoder. Under different modes and // Build up our encoder. Under different modes and
// inputs there are many keybindings that result in no encoding // inputs there are many keybindings that result in no encoding
@ -2749,7 +2749,7 @@ fn mouseReport(
const final: u8 = if (action == .release) 'm' else 'M'; const final: u8 = if (action == .release) 'm' else 'M';
// The position has to be adjusted to the terminal space. // The position has to be adjusted to the terminal space.
const coord: renderer.Coordinate.Terminal = (renderer.Coordinate{ const coord: renderer_mod.Coordinate.Terminal = (renderer_mod.Coordinate{
.surface = .{ .surface = .{
.x = pos.x, .x = pos.x,
.y = pos.y, .y = pos.y,
@ -3819,7 +3819,7 @@ pub fn colorSchemeCallback(self: *Surface, scheme: apprt.ColorScheme) !void {
pub fn posToViewport(self: Surface, xpos: f64, ypos: f64) terminal.point.Coordinate { pub fn posToViewport(self: Surface, xpos: f64, ypos: f64) terminal.point.Coordinate {
// Get our grid cell // Get our grid cell
const coord: renderer.Coordinate = .{ .surface = .{ .x = xpos, .y = ypos } }; const coord: renderer_mod.Coordinate = .{ .surface = .{ .x = xpos, .y = ypos } };
const grid = coord.convert(.grid, self.size).grid; const grid = coord.convert(.grid, self.size).grid;
return .{ .x = grid.x, .y = grid.y }; return .{ .x = grid.x, .y = grid.y };
} }

View File

@ -43,7 +43,7 @@ const c = @import("c.zig").c;
const version = @import("version.zig"); const version = @import("version.zig");
const inspector = @import("inspector.zig"); const inspector = @import("inspector.zig");
const key = @import("key.zig"); const key = @import("key.zig");
const winproto = @import("winproto.zig"); const winproto_mod = @import("winproto.zig");
const testing = std.testing; const testing = std.testing;
const adwaita = @import("adwaita.zig"); const adwaita = @import("adwaita.zig");
@ -58,7 +58,7 @@ app: *c.GtkApplication,
ctx: *c.GMainContext, ctx: *c.GMainContext,
/// State and logic for the underlying windowing protocol. /// State and logic for the underlying windowing protocol.
winproto: winproto.App, winproto: winproto_mod.App,
/// True if the app was launched with single instance mode. /// True if the app was launched with single instance mode.
single_instance: bool, single_instance: bool,
@ -401,7 +401,7 @@ pub fn init(core_app: *CoreApp, opts: Options) !App {
} }
// Setup our windowing protocol logic // Setup our windowing protocol logic
var winproto_app = try winproto.App.init( var winproto_app = try winproto_mod.App.init(
core_app.alloc, core_app.alloc,
display, display,
app_id, app_id,

View File

@ -32,7 +32,7 @@ const ClipboardConfirmationWindow = @import("ClipboardConfirmationWindow.zig");
const ResizeOverlay = @import("ResizeOverlay.zig"); const ResizeOverlay = @import("ResizeOverlay.zig");
const URLWidget = @import("URLWidget.zig"); const URLWidget = @import("URLWidget.zig");
const CloseDialog = @import("CloseDialog.zig"); const CloseDialog = @import("CloseDialog.zig");
const inspector = @import("inspector.zig"); const inspector_mod = @import("inspector.zig");
const gtk_key = @import("key.zig"); const gtk_key = @import("key.zig");
const c = @import("c.zig").c; const c = @import("c.zig").c;
const Builder = @import("Builder.zig"); const Builder = @import("Builder.zig");
@ -290,7 +290,7 @@ size: apprt.SurfaceSize,
cursor_pos: apprt.CursorPos, cursor_pos: apprt.CursorPos,
/// Inspector state. /// Inspector state.
inspector: ?*inspector.Inspector = null, inspector: ?*inspector_mod.Inspector = null,
/// Key input states. See gtkKeyPressed for detailed descriptions. /// Key input states. See gtkKeyPressed for detailed descriptions.
in_keyevent: IMKeyEvent = .false, in_keyevent: IMKeyEvent = .false,
@ -703,7 +703,7 @@ pub fn controlInspector(
// If we already have an inspector, we don't need to show anything. // If we already have an inspector, we don't need to show anything.
if (self.inspector != null) return; if (self.inspector != null) return;
self.inspector = inspector.Inspector.create( self.inspector = inspector_mod.Inspector.create(
self, self,
.{ .window = {} }, .{ .window = {} },
) catch |err| { ) catch |err| {

View File

@ -34,7 +34,7 @@ const TabView = @import("TabView.zig");
const HeaderBar = @import("headerbar.zig"); const HeaderBar = @import("headerbar.zig");
const CloseDialog = @import("CloseDialog.zig"); const CloseDialog = @import("CloseDialog.zig");
const version = @import("version.zig"); const version = @import("version.zig");
const winproto = @import("winproto.zig"); const winproto_mod = @import("winproto.zig");
const log = std.log.scoped(.gtk); const log = std.log.scoped(.gtk);
@ -69,7 +69,7 @@ toast_overlay: *c.GtkWidget,
adw_tab_overview_focus_timer: ?c.guint = null, adw_tab_overview_focus_timer: ?c.guint = null,
/// State and logic for windowing protocol for a window. /// State and logic for windowing protocol for a window.
winproto: winproto.Window, winproto: winproto_mod.Window,
pub const DerivedConfig = struct { pub const DerivedConfig = struct {
background_opacity: f64, background_opacity: f64,
@ -693,7 +693,7 @@ fn gtkRealize(_: *c.GtkWindow, ud: ?*anyopaque) callconv(.C) bool {
const self = userdataSelf(ud.?); const self = userdataSelf(ud.?);
// Initialize our window protocol logic // Initialize our window protocol logic
if (winproto.Window.init( if (winproto_mod.Window.init(
self.app.core_app.alloc, self.app.core_app.alloc,
&self.app.winproto, &self.app.winproto,
self, self,

View File

@ -7,7 +7,7 @@ const builtin = @import("builtin");
const apprt = @import("../apprt.zig"); const apprt = @import("../apprt.zig");
const font = @import("../font/main.zig"); const font = @import("../font/main.zig");
const renderer = @import("../renderer.zig"); const renderer_mod = @import("../renderer.zig");
const Command = @import("../Command.zig"); const Command = @import("../Command.zig");
const WasmTarget = @import("../os/wasm/target.zig").Target; const WasmTarget = @import("../os/wasm/target.zig").Target;
@ -28,7 +28,7 @@ wasm_target: WasmTarget,
/// Comptime interfaces /// Comptime interfaces
app_runtime: apprt.Runtime = .none, app_runtime: apprt.Runtime = .none,
renderer: renderer.Impl = .opengl, renderer: renderer_mod.Impl = .opengl,
font_backend: font.Backend = .freetype, font_backend: font.Backend = .freetype,
/// Feature flags /// Feature flags
@ -122,10 +122,10 @@ pub fn init(b: *std.Build) !Config {
) orelse apprt.Runtime.default(target.result); ) orelse apprt.Runtime.default(target.result);
config.renderer = b.option( config.renderer = b.option(
renderer.Impl, renderer_mod.Impl,
"renderer", "renderer",
"The app runtime to use. Not all values supported on all platforms.", "The app runtime to use. Not all values supported on all platforms.",
) orelse renderer.Impl.default(target.result, wasm_target); ) orelse renderer_mod.Impl.default(target.result, wasm_target);
//--------------------------------------------------------------- //---------------------------------------------------------------
// Feature Flags // Feature Flags
@ -395,7 +395,7 @@ pub fn addOptions(self: *const Config, step: *std.Build.Step.Options) !void {
step.addOption(bool, "sentry", self.sentry); step.addOption(bool, "sentry", self.sentry);
step.addOption(apprt.Runtime, "app_runtime", self.app_runtime); step.addOption(apprt.Runtime, "app_runtime", self.app_runtime);
step.addOption(font.Backend, "font_backend", self.font_backend); step.addOption(font.Backend, "font_backend", self.font_backend);
step.addOption(renderer.Impl, "renderer", self.renderer); step.addOption(renderer_mod.Impl, "renderer", self.renderer);
step.addOption(ExeEntrypoint, "exe_entrypoint", self.exe_entrypoint); step.addOption(ExeEntrypoint, "exe_entrypoint", self.exe_entrypoint);
step.addOption(WasmTarget, "wasm_target", self.wasm_target); step.addOption(WasmTarget, "wasm_target", self.wasm_target);
step.addOption(bool, "wasm_shared", self.wasm_shared); step.addOption(bool, "wasm_shared", self.wasm_shared);
@ -436,7 +436,7 @@ pub fn fromOptions() Config {
.flatpak = options.flatpak, .flatpak = options.flatpak,
.app_runtime = std.meta.stringToEnum(apprt.Runtime, @tagName(options.app_runtime)).?, .app_runtime = std.meta.stringToEnum(apprt.Runtime, @tagName(options.app_runtime)).?,
.font_backend = std.meta.stringToEnum(font.Backend, @tagName(options.font_backend)).?, .font_backend = std.meta.stringToEnum(font.Backend, @tagName(options.font_backend)).?,
.renderer = std.meta.stringToEnum(renderer.Impl, @tagName(options.renderer)).?, .renderer = std.meta.stringToEnum(renderer_mod.Impl, @tagName(options.renderer)).?,
.exe_entrypoint = std.meta.stringToEnum(ExeEntrypoint, @tagName(options.exe_entrypoint)).?, .exe_entrypoint = std.meta.stringToEnum(ExeEntrypoint, @tagName(options.exe_entrypoint)).?,
.wasm_target = std.meta.stringToEnum(WasmTarget, @tagName(options.wasm_target)).?, .wasm_target = std.meta.stringToEnum(WasmTarget, @tagName(options.wasm_target)).?,
.wasm_shared = options.wasm_shared, .wasm_shared = options.wasm_shared,

View File

@ -3,7 +3,7 @@
const std = @import("std"); const std = @import("std");
const Allocator = std.mem.Allocator; const Allocator = std.mem.Allocator;
const Inspector = @import("../inspector/main.zig").Inspector; const Inspector = @import("../inspector/main.zig").Inspector;
const terminal = @import("../terminal/main.zig"); const terminal_mod = @import("../terminal/main.zig");
const inputpkg = @import("../input.zig"); const inputpkg = @import("../input.zig");
const renderer = @import("../renderer.zig"); const renderer = @import("../renderer.zig");
@ -14,7 +14,7 @@ const renderer = @import("../renderer.zig");
mutex: *std.Thread.Mutex, mutex: *std.Thread.Mutex,
/// The terminal data. /// The terminal data.
terminal: *terminal.Terminal, terminal: *terminal_mod.Terminal,
/// The terminal inspector, if any. This will be null while the inspector /// The terminal inspector, if any. This will be null while the inspector
/// is not active and will be set when it is active. /// is not active and will be set when it is active.
@ -34,7 +34,7 @@ pub const Mouse = struct {
/// The point on the viewport where the mouse currently is. We use /// The point on the viewport where the mouse currently is. We use
/// viewport points to avoid the complexity of mapping the mouse to /// viewport points to avoid the complexity of mapping the mouse to
/// the renderer state. /// the renderer state.
point: ?terminal.point.Coordinate = null, point: ?terminal_mod.point.Coordinate = null,
/// The mods that are currently active for the last mouse event. /// The mods that are currently active for the last mouse event.
/// This could really just be mods in general and we probably will /// This could really just be mods in general and we probably will
@ -80,11 +80,11 @@ pub const Preedit = struct {
/// into the available space. /// into the available space.
pub fn range( pub fn range(
self: *const Preedit, self: *const Preedit,
start: terminal.size.CellCountInt, start: terminal_mod.size.CellCountInt,
max: terminal.size.CellCountInt, max: terminal_mod.size.CellCountInt,
) struct { ) struct {
start: terminal.size.CellCountInt, start: terminal_mod.size.CellCountInt,
end: terminal.size.CellCountInt, end: terminal_mod.size.CellCountInt,
cp_offset: usize, cp_offset: usize,
} { } {
// If our width is greater than the number of cells we have // If our width is greater than the number of cells we have
@ -96,7 +96,7 @@ pub const Preedit = struct {
// Rebuild our width in reverse order. This is because we want // Rebuild our width in reverse order. This is because we want
// to offset by the end cells, not the start cells (if we have to). // to offset by the end cells, not the start cells (if we have to).
var w: terminal.size.CellCountInt = 0; var w: terminal_mod.size.CellCountInt = 0;
for (0..self.codepoints.len) |i| { for (0..self.codepoints.len) |i| {
const reverse_i = self.codepoints.len - i - 1; const reverse_i = self.codepoints.len - i - 1;
const cp = self.codepoints[reverse_i]; const cp = self.codepoints[reverse_i];

View File

@ -8,7 +8,7 @@ const assert = std.debug.assert;
const xev = @import("../global.zig").xev; const xev = @import("../global.zig").xev;
const crash = @import("../crash/main.zig"); const crash = @import("../crash/main.zig");
const internal_os = @import("../os/main.zig"); const internal_os = @import("../os/main.zig");
const renderer = @import("../renderer.zig"); const renderer_mod = @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("../datastruct/main.zig").BlockingQueue; const BlockingQueue = @import("../datastruct/main.zig").BlockingQueue;
@ -23,7 +23,7 @@ const CURSOR_BLINK_INTERVAL = 600;
/// The type used for sending messages to the IO thread. For now this is /// The type used for sending messages to the IO thread. For now this is
/// hardcoded with a capacity. We can make this a comptime parameter in /// hardcoded with a capacity. We can make this a comptime parameter in
/// the future if we want it configurable. /// the future if we want it configurable.
pub const Mailbox = BlockingQueue(renderer.Message, 64); pub const Mailbox = BlockingQueue(renderer_mod.Message, 64);
/// Allocator used for some state /// Allocator used for some state
alloc: std.mem.Allocator, alloc: std.mem.Allocator,
@ -67,10 +67,10 @@ cursor_c_cancel: xev.Completion = .{},
surface: *apprt.Surface, surface: *apprt.Surface,
/// The underlying renderer implementation. /// The underlying renderer implementation.
renderer: *renderer.Renderer, renderer: *renderer_mod.Renderer,
/// Pointer to the shared state that is used to generate the final render. /// Pointer to the shared state that is used to generate the final render.
state: *renderer.State, state: *renderer_mod.State,
/// The mailbox that can be used to send this thread messages. Note /// The mailbox that can be used to send this thread messages. Note
/// this is a blocking queue so if it is full you will get errors (or block). /// this is a blocking queue so if it is full you will get errors (or block).
@ -117,8 +117,8 @@ pub fn init(
alloc: Allocator, alloc: Allocator,
config: *const configpkg.Config, config: *const configpkg.Config,
surface: *apprt.Surface, surface: *apprt.Surface,
renderer_impl: *renderer.Renderer, renderer_impl: *renderer_mod.Renderer,
state: *renderer.State, state: *renderer_mod.State,
app_mailbox: App.Mailbox, app_mailbox: App.Mailbox,
) !Thread { ) !Thread {
// Create our event loop. // Create our event loop.
@ -209,7 +209,7 @@ fn threadMain_(self: *Thread) !void {
self.setQosClass(); self.setQosClass();
// Run our loop start/end callbacks if the renderer cares. // Run our loop start/end callbacks if the renderer cares.
const has_loop = @hasDecl(renderer.Renderer, "loopEnter"); const has_loop = @hasDecl(renderer_mod.Renderer, "loopEnter");
if (has_loop) try self.renderer.loopEnter(self); if (has_loop) try self.renderer.loopEnter(self);
defer if (has_loop) self.renderer.loopExit(); defer if (has_loop) self.renderer.loopExit();
@ -278,7 +278,7 @@ fn setQosClass(self: *const Thread) void {
fn startDrawTimer(self: *Thread) void { fn startDrawTimer(self: *Thread) void {
// If our renderer doesn't support animations then we never run this. // If our renderer doesn't support animations then we never run this.
if (!@hasDecl(renderer.Renderer, "hasAnimations")) return; if (!@hasDecl(renderer_mod.Renderer, "hasAnimations")) return;
if (!self.renderer.hasAnimations()) return; if (!self.renderer.hasAnimations()) return;
if (self.config.custom_shader_animation == .false) return; if (self.config.custom_shader_animation == .false) return;
@ -442,7 +442,7 @@ fn drainMailbox(self: *Thread) !void {
.inspector => |v| self.flags.has_inspector = v, .inspector => |v| self.flags.has_inspector = v,
.macos_display_id => |v| { .macos_display_id => |v| {
if (@hasDecl(renderer.Renderer, "setMacOSDisplayID")) { if (@hasDecl(renderer_mod.Renderer, "setMacOSDisplayID")) {
try self.renderer.setMacOSDisplayID(v); try self.renderer.setMacOSDisplayID(v);
} }
}, },
@ -466,8 +466,8 @@ fn drawFrame(self: *Thread, now: bool) void {
// If we're doing single-threaded GPU calls then we just wake up the // If we're doing single-threaded GPU calls then we just wake up the
// app thread to redraw at this point. // app thread to redraw at this point.
if (renderer.Renderer == renderer.OpenGL and if (renderer_mod.Renderer == renderer_mod.OpenGL and
renderer.OpenGL.single_threaded_draw) renderer_mod.OpenGL.single_threaded_draw)
{ {
_ = self.app_mailbox.push( _ = self.app_mailbox.push(
.{ .redraw_surface = self.surface }, .{ .redraw_surface = self.surface },

View File

@ -11,7 +11,7 @@ const Allocator = std.mem.Allocator;
const unicode = @import("../unicode/main.zig"); const unicode = @import("../unicode/main.zig");
const ansi = @import("ansi.zig"); const ansi = @import("ansi.zig");
const modes = @import("modes.zig"); const modes_mod = @import("modes.zig");
const charsets = @import("charsets.zig"); const charsets = @import("charsets.zig");
const csi = @import("csi.zig"); const csi = @import("csi.zig");
const hyperlink = @import("hyperlink.zig"); const hyperlink = @import("hyperlink.zig");
@ -20,7 +20,7 @@ const point = @import("point.zig");
const sgr = @import("sgr.zig"); const sgr = @import("sgr.zig");
const Tabstops = @import("Tabstops.zig"); const Tabstops = @import("Tabstops.zig");
const color = @import("color.zig"); const color = @import("color.zig");
const mouse_shape = @import("mouse_shape.zig"); const mouse_shape_mod = @import("mouse_shape.zig");
const size = @import("size.zig"); const size = @import("size.zig");
const pagepkg = @import("page.zig"); const pagepkg = @import("page.zig");
@ -87,10 +87,10 @@ color_palette: struct {
previous_char: ?u21 = null, previous_char: ?u21 = null,
/// The modes that this terminal currently has active. /// The modes that this terminal currently has active.
modes: modes.ModeState = .{}, modes: modes_mod.ModeState = .{},
/// The most recently set mouse shape for the terminal. /// The most recently set mouse shape for the terminal.
mouse_shape: mouse_shape.MouseShape = .text, mouse_shape: mouse_shape_mod.MouseShape = .text,
/// These are just a packed set of flags we may set on the terminal. /// These are just a packed set of flags we may set on the terminal.
flags: packed struct { flags: packed struct {
@ -196,7 +196,7 @@ pub const Options = struct {
/// The default mode state. When the terminal gets a reset, it /// The default mode state. When the terminal gets a reset, it
/// will revert back to this state. /// will revert back to this state.
default_modes: modes.ModePacked = .{}, default_modes: modes_mod.ModePacked = .{},
}; };
/// Initialize a new terminal. /// Initialize a new terminal.

View File

@ -1721,7 +1721,7 @@ pub const Page = struct {
const dirty_start = alignForward(usize, cells_end, @alignOf(usize)); const dirty_start = alignForward(usize, cells_end, @alignOf(usize));
const dirty_end: usize = dirty_start + (dirty_usize_length * @sizeOf(usize)); const dirty_end: usize = dirty_start + (dirty_usize_length * @sizeOf(usize));
const styles_layout = style.Set.layout(cap.styles); const styles_layout = style.Set.layout_sim(cap.styles);
const styles_start = alignForward(usize, dirty_end, style.Set.base_align); const styles_start = alignForward(usize, dirty_end, style.Set.base_align);
const styles_end = styles_start + styles_layout.total_size; const styles_end = styles_start + styles_layout.total_size;
@ -1739,7 +1739,7 @@ pub const Page = struct {
const string_end = string_start + string_layout.total_size; const string_end = string_start + string_layout.total_size;
const hyperlink_count = @divFloor(cap.hyperlink_bytes, @sizeOf(hyperlink.Set.Item)); const hyperlink_count = @divFloor(cap.hyperlink_bytes, @sizeOf(hyperlink.Set.Item));
const hyperlink_set_layout = hyperlink.Set.layout(@intCast(hyperlink_count)); const hyperlink_set_layout = hyperlink.Set.layout_sim(@intCast(hyperlink_count));
const hyperlink_set_start = alignForward(usize, string_end, hyperlink.Set.base_align); const hyperlink_set_start = alignForward(usize, string_end, hyperlink.Set.base_align);
const hyperlink_set_end = hyperlink_set_start + hyperlink_set_layout.total_size; const hyperlink_set_end = hyperlink_set_start + hyperlink_set_layout.total_size;

View File

@ -10,7 +10,7 @@ const fastmem = @import("../fastmem.zig");
/// A reference counted set. /// A reference counted set.
/// ///
/// This set is created with some capacity in mind. You can determine /// This set is created with some capacity in mind. You can determine
/// the exact memory requirement of a given capacity by calling `layout` /// the exact memory requirement of a given capacity by calling `layout_sim`
/// and checking the total size. /// and checking the total size.
/// ///
/// When the set exceeds capacity, an `OutOfMemory` or `NeedsRehash` error /// When the set exceeds capacity, an `OutOfMemory` or `NeedsRehash` error
@ -147,7 +147,7 @@ pub fn RefCountedSet(
/// ///
/// The returned layout `cap` property will be 1 more than the number /// The returned layout `cap` property will be 1 more than the number
/// of items that the set can actually store, since ID 0 is reserved. /// of items that the set can actually store, since ID 0 is reserved.
pub fn layout(cap: usize) Layout { pub fn layout_sim(cap: usize) Layout {
// Experimentally, this load factor works quite well. // Experimentally, this load factor works quite well.
const load_factor = 0.8125; const load_factor = 0.8125;

View File

@ -16,7 +16,7 @@ const termio = @import("../termio.zig");
const Command = @import("../Command.zig"); const Command = @import("../Command.zig");
const Pty = @import("../pty.zig").Pty; const Pty = @import("../pty.zig").Pty;
const StreamHandler = @import("stream_handler.zig").StreamHandler; const StreamHandler = @import("stream_handler.zig").StreamHandler;
const terminal = @import("../terminal/main.zig"); const terminal_mod = @import("../terminal/main.zig");
const terminfo = @import("../terminfo/main.zig"); const terminfo = @import("../terminfo/main.zig");
const xev = @import("../global.zig").xev; const xev = @import("../global.zig").xev;
const renderer = @import("../renderer.zig"); const renderer = @import("../renderer.zig");
@ -41,7 +41,7 @@ config: DerivedConfig,
/// The terminal emulator internal state. This is the abstract "terminal" /// The terminal emulator internal state. This is the abstract "terminal"
/// that manages input, grid updating, etc. and is renderer-agnostic. It /// that manages input, grid updating, etc. and is renderer-agnostic. It
/// just stores internal state about a grid. /// just stores internal state about a grid.
terminal: terminal.Terminal, terminal: terminal_mod.Terminal,
/// The shared render state /// The shared render state
renderer_state: *renderer.State, renderer_state: *renderer.State,
@ -64,7 +64,7 @@ mailbox: termio.Mailbox,
/// The stream parser. This parses the stream of escape codes and so on /// The stream parser. This parses the stream of escape codes and so on
/// from the child process and calls callbacks in the stream handler. /// from the child process and calls callbacks in the stream handler.
terminal_stream: terminal.Stream(StreamHandler), terminal_stream: terminal_mod.Stream(StreamHandler),
/// Last time the cursor was reset. This is used to prevent message /// Last time the cursor was reset. This is used to prevent message
/// flooding with cursor resets. /// flooding with cursor resets.
@ -76,9 +76,9 @@ last_cursor_reset: ?std.time.Instant = null,
pub const DerivedConfig = struct { pub const DerivedConfig = struct {
arena: ArenaAllocator, arena: ArenaAllocator,
palette: terminal.color.Palette, palette: terminal_mod.color.Palette,
image_storage_limit: usize, image_storage_limit: usize,
cursor_style: terminal.CursorStyle, cursor_style: terminal_mod.CursorStyle,
cursor_blink: ?bool, cursor_blink: ?bool,
cursor_color: ?configpkg.Config.Color, cursor_color: ?configpkg.Config.Color,
cursor_invert: bool, cursor_invert: bool,
@ -128,8 +128,8 @@ pub const DerivedConfig = struct {
/// to run a child process. /// to run a child process.
pub fn init(self: *Termio, alloc: Allocator, opts: termio.Options) !void { pub fn init(self: *Termio, alloc: Allocator, opts: termio.Options) !void {
// The default terminal modes based on our config. // The default terminal modes based on our config.
const default_modes: terminal.ModePacked = modes: { const default_modes: terminal_mod.ModePacked = modes: {
var modes: terminal.ModePacked = .{}; var modes: terminal_mod.ModePacked = .{};
// Setup our initial grapheme cluster support if enabled. We use a // Setup our initial grapheme cluster support if enabled. We use a
// switch to ensure we get a compiler error if more cases are added. // switch to ensure we get a compiler error if more cases are added.
@ -145,7 +145,7 @@ pub fn init(self: *Termio, alloc: Allocator, opts: termio.Options) !void {
}; };
// Create our terminal // Create our terminal
var term = try terminal.Terminal.init(alloc, opts: { var term = try terminal_mod.Terminal.init(alloc, opts: {
const grid_size = opts.size.grid(); const grid_size = opts.size.grid();
break :opts .{ break :opts .{
.cols = grid_size.columns, .cols = grid_size.columns,
@ -510,7 +510,7 @@ pub fn clearScreen(self: *Termio, td: *ThreadData, history: bool) !void {
} }
/// Scroll the viewport /// Scroll the viewport
pub fn scrollViewport(self: *Termio, scroll: terminal.Terminal.ScrollViewport) !void { pub fn scrollViewport(self: *Termio, scroll: terminal_mod.Terminal.ScrollViewport) !void {
self.renderer_state.mutex.lock(); self.renderer_state.mutex.lock();
defer self.renderer_state.mutex.unlock(); defer self.renderer_state.mutex.unlock();
try self.terminal.scrollViewport(scroll); try self.terminal.scrollViewport(scroll);