mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
core: remove more hasdecls
This commit is contained in:
@ -747,11 +747,7 @@ pub fn handleMessage(self: *Surface, msg: Message) !void {
|
|||||||
},
|
},
|
||||||
|
|
||||||
.report_title => |style| {
|
.report_title => |style| {
|
||||||
const title: ?[:0]const u8 = title: {
|
const title: ?[:0]const u8 = self.rt_surface.getTitle();
|
||||||
if (!@hasDecl(apprt.runtime.Surface, "getTitle")) break :title null;
|
|
||||||
break :title self.rt_surface.getTitle();
|
|
||||||
};
|
|
||||||
|
|
||||||
const data = switch (style) {
|
const data = switch (style) {
|
||||||
.csi_21_t => try std.fmt.allocPrint(
|
.csi_21_t => try std.fmt.allocPrint(
|
||||||
self.alloc,
|
self.alloc,
|
||||||
@ -901,7 +897,6 @@ fn modsChanged(self: *Surface, mods: input.Mods) void {
|
|||||||
/// 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.Health) void {
|
||||||
log.warn("renderer health status change status={}", .{health});
|
log.warn("renderer health status change status={}", .{health});
|
||||||
if (!@hasDecl(apprt.runtime.Surface, "updateRendererHealth")) return;
|
|
||||||
self.rt_surface.updateRendererHealth(health);
|
self.rt_surface.updateRendererHealth(health);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1158,11 +1153,9 @@ fn setSelection(self: *Surface, sel_: ?terminal.Selection) !void {
|
|||||||
|
|
||||||
// Check if our runtime supports the selection clipboard at all.
|
// Check if our runtime supports the selection clipboard at all.
|
||||||
// We can save a lot of work if it doesn't.
|
// We can save a lot of work if it doesn't.
|
||||||
if (@hasDecl(apprt.runtime.Surface, "supportsClipboard")) {
|
|
||||||
if (!self.rt_surface.supportsClipboard(clipboard)) {
|
if (!self.rt_surface.supportsClipboard(clipboard)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const buf = self.io.terminal.screen.selectionString(self.alloc, .{
|
const buf = self.io.terminal.screen.selectionString(self.alloc, .{
|
||||||
.sel = sel,
|
.sel = sel,
|
||||||
|
@ -411,7 +411,6 @@ pub const Surface = struct {
|
|||||||
/// Initialize the surface into the given self pointer. This gives a
|
/// Initialize the surface into the given self pointer. This gives a
|
||||||
/// stable pointer to the destination that can be used for callbacks.
|
/// stable pointer to the destination that can be used for callbacks.
|
||||||
pub fn init(self: *Surface, app: *App) !void {
|
pub fn init(self: *Surface, app: *App) !void {
|
||||||
|
|
||||||
// Create our window
|
// Create our window
|
||||||
const win = glfw.Window.create(
|
const win = glfw.Window.create(
|
||||||
640,
|
640,
|
||||||
@ -715,6 +714,23 @@ pub const Surface = struct {
|
|||||||
self.window.setInputModeCursor(if (visible) .normal else .hidden);
|
self.window.setInputModeCursor(if (visible) .normal else .hidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn updateRendererHealth(self: *const Surface, health: renderer.Health) void {
|
||||||
|
// We don't support this in GLFW.
|
||||||
|
_ = self;
|
||||||
|
_ = health;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn supportsClipboard(
|
||||||
|
self: *const Surface,
|
||||||
|
clipboard_type: apprt.Clipboard,
|
||||||
|
) bool {
|
||||||
|
_ = self;
|
||||||
|
return switch (clipboard_type) {
|
||||||
|
.standard => true,
|
||||||
|
.selection, .primary => comptime builtin.os.tag == .linux,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/// Start an async clipboard request.
|
/// Start an async clipboard request.
|
||||||
pub fn clipboardRequest(
|
pub fn clipboardRequest(
|
||||||
self: *Surface,
|
self: *Surface,
|
||||||
|
@ -9,6 +9,7 @@ const configpkg = @import("../../config.zig");
|
|||||||
const apprt = @import("../../apprt.zig");
|
const apprt = @import("../../apprt.zig");
|
||||||
const font = @import("../../font/main.zig");
|
const font = @import("../../font/main.zig");
|
||||||
const input = @import("../../input.zig");
|
const input = @import("../../input.zig");
|
||||||
|
const renderer = @import("../../renderer.zig");
|
||||||
const terminal = @import("../../terminal/main.zig");
|
const terminal = @import("../../terminal/main.zig");
|
||||||
const CoreSurface = @import("../../Surface.zig");
|
const CoreSurface = @import("../../Surface.zig");
|
||||||
const internal_os = @import("../../os/main.zig");
|
const internal_os = @import("../../os/main.zig");
|
||||||
@ -942,6 +943,19 @@ pub fn mouseOverLink(self: *Surface, uri_: ?[]const u8) void {
|
|||||||
self.url_widget = URLWidget.init(self, uriZ);
|
self.url_widget = URLWidget.init(self, uriZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn supportsClipboard(
|
||||||
|
self: *const Surface,
|
||||||
|
clipboard_type: apprt.Clipboard,
|
||||||
|
) bool {
|
||||||
|
_ = self;
|
||||||
|
return switch (clipboard_type) {
|
||||||
|
.standard,
|
||||||
|
.selection,
|
||||||
|
.primary,
|
||||||
|
=> true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
pub fn clipboardRequest(
|
pub fn clipboardRequest(
|
||||||
self: *Surface,
|
self: *Surface,
|
||||||
clipboard_type: apprt.Clipboard,
|
clipboard_type: apprt.Clipboard,
|
||||||
@ -1907,3 +1921,9 @@ pub fn present(self: *Surface) void {
|
|||||||
|
|
||||||
self.grabFocus();
|
self.grabFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn updateRendererHealth(self: *const Surface, health: renderer.Health) void {
|
||||||
|
// We don't support this in GTK.
|
||||||
|
_ = self;
|
||||||
|
_ = health;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user