mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
clean up uncessary hacks
This commit is contained in:
@ -73,13 +73,11 @@ fetch(url.href)
|
||||
run(config_str.ptr, config_str.len);
|
||||
await new Promise((resolve) => setTimeout(resolve, 500))
|
||||
const io = new Uint8ClampedArray(stdin, 4);
|
||||
const text = new TextEncoder().encode("hello world\n\r");
|
||||
const text = new TextEncoder().encode("hello world\r\n");
|
||||
io.set(text);
|
||||
const n = new Int32Array(stdin);
|
||||
console.error("storing");
|
||||
Atomics.store(n, 0, text.length)
|
||||
Atomics.notify(n, 0);
|
||||
console.error("done storing");
|
||||
function drawing() {
|
||||
requestAnimationFrame(() => {
|
||||
draw();
|
||||
@ -88,14 +86,13 @@ fetch(url.href)
|
||||
|
||||
}
|
||||
drawing()
|
||||
setTimeout(() => {
|
||||
const text = new TextEncoder().encode("🐏\n\r👍🏽\n\rM_ghostty\033[2;2H\033[48;2;240;40;40m\033[38;2;23;255;80mhello");
|
||||
setInterval(() => {
|
||||
// const text = new TextEncoder().encode("🐏\n\r👍🏽\n\rM_ghostty\033[2;2H\033[48;2;240;40;40m\033[38;2;23;255;80mhello");
|
||||
const text = new TextEncoder().encode("🐏\r\n👍🏽\r\nM_ghostty\033[48;2;240;40;40m\033[38;2;23;255;80mhello\r\n");
|
||||
const n = new Int32Array(stdin);
|
||||
console.error("storing");
|
||||
const place = Atomics.add(n, 0, text.length)
|
||||
const io = new Uint8ClampedArray(stdin, 4 + place);
|
||||
io.set(text);
|
||||
Atomics.notify(n, 0);
|
||||
console.error("done storing");
|
||||
}, 5000)
|
||||
})
|
||||
|
@ -795,6 +795,7 @@ export const importObject = {
|
||||
const read = Math.min(iov_len, bytes.length);
|
||||
const io = new Uint8ClampedArray(zjs.memory.buffer, iov_base, iov_len);
|
||||
io.set(bytes.slice(0, read));
|
||||
console.error(bytes[read-1]);
|
||||
bytes = bytes.slice(read);
|
||||
if (bytes.length === 0) bytes = null;
|
||||
nwritten += read;
|
||||
|
34
pkg/simdutf/vendor/simdutf.h
vendored
34
pkg/simdutf/vendor/simdutf.h
vendored
@ -619,9 +619,9 @@ enum {
|
||||
#ifndef SIMDUTF_IMPLEMENTATION_H
|
||||
#define SIMDUTF_IMPLEMENTATION_H
|
||||
#include <string>
|
||||
// #if !defined(SIMDUTF_NO_THREADS)
|
||||
// #include <atomic>
|
||||
// #endif
|
||||
#if !defined(SIMDUTF_NO_THREADS)
|
||||
#include <atomic>
|
||||
#endif
|
||||
#include <vector>
|
||||
#include <tuple>
|
||||
/* begin file include/simdutf/internal/isadetection.h */
|
||||
@ -3692,7 +3692,7 @@ class atomic_ptr {
|
||||
public:
|
||||
atomic_ptr(T *_ptr) : ptr{_ptr} {}
|
||||
|
||||
// #if defined(SIMDUTF_NO_THREADS)
|
||||
#if defined(SIMDUTF_NO_THREADS)
|
||||
operator const T*() const { return ptr; }
|
||||
const T& operator*() const { return *ptr; }
|
||||
const T* operator->() const { return ptr; }
|
||||
@ -3702,24 +3702,24 @@ public:
|
||||
T* operator->() { return ptr; }
|
||||
atomic_ptr& operator=(T *_ptr) { ptr = _ptr; return *this; }
|
||||
|
||||
// #else
|
||||
// operator const T*() const { return ptr.load(); }
|
||||
// const T& operator*() const { return *ptr; }
|
||||
// const T* operator->() const { return ptr.load(); }
|
||||
#else
|
||||
operator const T*() const { return ptr.load(); }
|
||||
const T& operator*() const { return *ptr; }
|
||||
const T* operator->() const { return ptr.load(); }
|
||||
|
||||
// operator T*() { return ptr.load(); }
|
||||
// T& operator*() { return *ptr; }
|
||||
// T* operator->() { return ptr.load(); }
|
||||
// atomic_ptr& operator=(T *_ptr) { ptr = _ptr; return *this; }
|
||||
operator T*() { return ptr.load(); }
|
||||
T& operator*() { return *ptr; }
|
||||
T* operator->() { return ptr.load(); }
|
||||
atomic_ptr& operator=(T *_ptr) { ptr = _ptr; return *this; }
|
||||
|
||||
// #endif
|
||||
#endif
|
||||
|
||||
private:
|
||||
// #if defined(SIMDUTF_NO_THREADS)
|
||||
#if defined(SIMDUTF_NO_THREADS)
|
||||
T* ptr;
|
||||
// #else
|
||||
// std::atomic<T*> ptr;
|
||||
// #endif
|
||||
#else
|
||||
std::atomic<T*> ptr;
|
||||
#endif
|
||||
};
|
||||
|
||||
class detect_best_supported_implementation_on_first_use;
|
||||
|
@ -64,7 +64,7 @@ font_grid_set: font.SharedGridSet,
|
||||
// Used to rate limit desktop notifications. Some platforms (notably macOS) will
|
||||
// run out of resources if desktop notifications are sent too fast and the OS
|
||||
// will kill Ghostty.
|
||||
last_notification_time: ?internal_os.Instant = null,
|
||||
last_notification_time: ?std.time.Instant = null,
|
||||
last_notification_digest: u64 = 0,
|
||||
|
||||
/// The conditional state of the configuration. See the equivalent field
|
||||
|
@ -21,6 +21,7 @@ const assert = std.debug.assert;
|
||||
const Allocator = std.mem.Allocator;
|
||||
const ArenaAllocator = std.heap.ArenaAllocator;
|
||||
const global_state = &@import("global.zig").state;
|
||||
const oni = @import("oniguruma");
|
||||
const crash = @import("crash/main.zig");
|
||||
const unicode = @import("unicode/main.zig");
|
||||
const renderer = @import("renderer.zig");
|
||||
@ -173,7 +174,7 @@ const Mouse = struct {
|
||||
/// The left click time was the last time the left click was done. This
|
||||
/// is always set on the first left click.
|
||||
left_click_count: u8 = 0,
|
||||
left_click_time: internal_os.Instant = undefined,
|
||||
left_click_time: std.time.Instant = undefined,
|
||||
|
||||
/// The last x/y sent for mouse reports.
|
||||
event_point: ?terminal.point.Coordinate = null,
|
||||
@ -255,7 +256,7 @@ const DerivedConfig = struct {
|
||||
links: []Link,
|
||||
|
||||
const Link = struct {
|
||||
regex: input.Link.Regex,
|
||||
regex: oni.Regex,
|
||||
action: input.Link.Action,
|
||||
highlight: input.Link.Highlight,
|
||||
};
|
||||
@ -2723,7 +2724,7 @@ pub fn mouseButtonCallback(
|
||||
|
||||
// If we are within the interval that the click would register
|
||||
// an increment then we do not extend the selection.
|
||||
if (internal_os.Instant.now()) |now| {
|
||||
if (std.time.Instant.now()) |now| {
|
||||
const since = now.since(self.mouse.left_click_time);
|
||||
if (since <= self.config.mouse_interval) {
|
||||
// Click interval very short, we may be increasing
|
||||
@ -2869,7 +2870,7 @@ pub fn mouseButtonCallback(
|
||||
self.mouse.left_click_ypos = pos.y;
|
||||
|
||||
// Setup our click counter and timer
|
||||
if (internal_os.Instant.now()) |now| {
|
||||
if (std.time.Instant.now()) |now| {
|
||||
// If we have mouse clicks, then we check if the time elapsed
|
||||
// is less than and our interval and if so, increase the count.
|
||||
if (self.mouse.left_click_count > 0) {
|
||||
@ -4477,7 +4478,7 @@ fn showDesktopNotification(self: *Surface, title: [:0]const u8, body: [:0]const
|
||||
// how fast identical notifications can be sent sequentially.
|
||||
const hash_algorithm = std.hash.Wyhash;
|
||||
|
||||
const now = try internal_os.Instant.now();
|
||||
const now = try std.time.Instant.now();
|
||||
|
||||
// Set a limit of one desktop notification per second so that the OS
|
||||
// doesn't kill us when we run out of resources.
|
||||
|
@ -127,18 +127,20 @@ pub const Artifact = enum {
|
||||
wasm_module,
|
||||
|
||||
pub fn detect() Artifact {
|
||||
// assert(builtin.output_mode == .Obj);
|
||||
// assert(builtin.link_mode == .Static);
|
||||
return .wasm_module;
|
||||
if (builtin.target.isWasm()) {
|
||||
// assert(builtin.output_mode == .Obj);
|
||||
// assert(builtin.link_mode == .Static);
|
||||
return .wasm_module;
|
||||
}
|
||||
|
||||
// return switch (builtin.output_mode) {
|
||||
// .Exe => .exe,
|
||||
// .Lib => .lib,
|
||||
// else => {
|
||||
// @compileLog(builtin.output_mode);
|
||||
// @compileError("unsupported artifact output mode");
|
||||
// },
|
||||
// };
|
||||
return switch (builtin.output_mode) {
|
||||
.Exe => .exe,
|
||||
.Lib => .lib,
|
||||
else => {
|
||||
@compileLog(builtin.output_mode);
|
||||
@compileError("unsupported artifact output mode");
|
||||
},
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -8,8 +8,6 @@ const oni = @import("oniguruma");
|
||||
const Mods = @import("key.zig").Mods;
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub const Regex = oni.Regex;
|
||||
|
||||
/// The regular expression that will be used to match the link. Ownership
|
||||
/// of this memory is up to the caller. The link will never free this memory.
|
||||
regex: []const u8,
|
||||
|
@ -44,16 +44,3 @@ pub const clickInterval = mouse.clickInterval;
|
||||
pub const open = openpkg.open;
|
||||
pub const pipe = pipepkg.pipe;
|
||||
pub const resourcesDir = resourcesdir.resourcesDir;
|
||||
pub const Instant = if (true) std.time.Instant else struct {
|
||||
pub fn now() !@This() {
|
||||
return .{};
|
||||
}
|
||||
pub fn order(self: *const Instant, other: Instant) std.math.Order {
|
||||
_ = self;
|
||||
_ = other;
|
||||
return .eq;
|
||||
}
|
||||
};
|
||||
pub fn sleep(nanosecond: u64) void {
|
||||
_ = nanosecond;
|
||||
}
|
||||
|
@ -1,20 +1,19 @@
|
||||
const std = @import("std");
|
||||
const Allocator = std.mem.Allocator;
|
||||
const oni = @import("oniguruma");
|
||||
const configpkg = @import("../config.zig");
|
||||
const inputpkg = @import("../input.zig");
|
||||
const terminal = @import("../terminal/main.zig");
|
||||
const point = terminal.point;
|
||||
const Screen = terminal.Screen;
|
||||
const Terminal = terminal.Terminal;
|
||||
const builtin = @import("builtin");
|
||||
const js = @import("zig-js");
|
||||
|
||||
const log = std.log.scoped(.renderer_link);
|
||||
|
||||
/// The link configuration needed for renderers.
|
||||
pub const Link = struct {
|
||||
/// The regular expression to match the link against.
|
||||
regex: inputpkg.Link.Regex,
|
||||
regex: oni.Regex,
|
||||
|
||||
/// The situations in which the link should be highlighted.
|
||||
highlight: inputpkg.Link.Highlight,
|
||||
|
@ -2,7 +2,6 @@ const std = @import("std");
|
||||
const Allocator = std.mem.Allocator;
|
||||
const gl = @import("opengl");
|
||||
const Size = @import("../size.zig").Size;
|
||||
const internal_os = @import("../../os/main.zig");
|
||||
|
||||
const log = std.log.scoped(.opengl_custom);
|
||||
|
||||
@ -48,11 +47,11 @@ pub const State = struct {
|
||||
|
||||
/// The first time a frame was drawn. This is used to update
|
||||
/// the time uniform.
|
||||
first_frame_time: internal_os.Instant,
|
||||
first_frame_time: std.time.Instant,
|
||||
|
||||
/// The last time a frame was drawn. This is used to update
|
||||
/// the time uniform.
|
||||
last_frame_time: internal_os.Instant,
|
||||
last_frame_time: std.time.Instant,
|
||||
|
||||
pub fn init(
|
||||
alloc: Allocator,
|
||||
@ -140,8 +139,8 @@ pub const State = struct {
|
||||
.vao = vao,
|
||||
.ebo = ebo,
|
||||
.fb_texture = fb_tex,
|
||||
.first_frame_time = try internal_os.Instant.now(),
|
||||
.last_frame_time = try internal_os.Instant.now(),
|
||||
.first_frame_time = try std.time.Instant.now(),
|
||||
.last_frame_time = try std.time.Instant.now(),
|
||||
};
|
||||
}
|
||||
|
||||
@ -184,7 +183,7 @@ pub const State = struct {
|
||||
/// this.
|
||||
pub fn newFrame(self: *State) !void {
|
||||
// Update our frame time
|
||||
const now = internal_os.Instant.now() catch self.first_frame_time;
|
||||
const now = std.time.Instant.now() catch self.first_frame_time;
|
||||
const since_ns: f32 = @floatFromInt(now.since(self.first_frame_time));
|
||||
const delta_ns: f32 = @floatFromInt(now.since(self.last_frame_time));
|
||||
self.uniforms.time = since_ns / std.time.ns_per_s;
|
||||
|
@ -35,7 +35,7 @@ pub const Placement = struct {
|
||||
/// The map used for storing images.
|
||||
pub const ImageMap = std.AutoHashMapUnmanaged(u32, struct {
|
||||
image: Image,
|
||||
transmit_time: internal_os.Instant,
|
||||
transmit_time: std.time.Instant,
|
||||
});
|
||||
|
||||
/// The state for a single image that is to be rendered. The image can be
|
||||
|
@ -346,7 +346,7 @@ pub const LoadingImage = struct {
|
||||
}
|
||||
|
||||
// Set our time
|
||||
self.image.transmit_time = internal_os.Instant.now() catch |err| {
|
||||
self.image.transmit_time = std.time.Instant.now() catch |err| {
|
||||
log.warn("failed to get time: {}", .{err});
|
||||
return error.InternalError;
|
||||
};
|
||||
@ -453,7 +453,7 @@ pub const Image = struct {
|
||||
format: command.Transmission.Format = .rgb,
|
||||
compression: command.Transmission.Compression = .none,
|
||||
data: []const u8 = "",
|
||||
transmit_time: internal_os.Instant = undefined,
|
||||
transmit_time: std.time.Instant = undefined,
|
||||
|
||||
pub const Error = error{
|
||||
InternalError,
|
||||
|
@ -496,7 +496,7 @@ pub const ImageStorage = struct {
|
||||
// bit is fine compared to the megabytes we're looking to save.
|
||||
const Candidate = struct {
|
||||
id: u32,
|
||||
time: internal_os.Instant,
|
||||
time: std.time.Instant,
|
||||
used: bool,
|
||||
};
|
||||
|
||||
|
@ -102,7 +102,7 @@ pub fn threadEnter(
|
||||
};
|
||||
|
||||
// Track our process start time for abnormal exits
|
||||
const process_start = try internal_os.Instant.now();
|
||||
const process_start = try std.time.Instant.now();
|
||||
|
||||
// Create our pipe that we'll use to kill our read thread.
|
||||
// pipe[0] is the read end, pipe[1] is the write end.
|
||||
@ -345,7 +345,7 @@ fn processExit(
|
||||
|
||||
// Determine how long the process was running for.
|
||||
const runtime_ms: ?u64 = runtime: {
|
||||
const process_end = internal_os.Instant.now() catch break :runtime null;
|
||||
const process_end = std.time.Instant.now() catch break :runtime null;
|
||||
const runtime_ns = process_end.since(execdata.start);
|
||||
const runtime_ms = runtime_ns / std.time.ns_per_ms;
|
||||
break :runtime runtime_ms;
|
||||
@ -603,7 +603,7 @@ pub const ThreadData = struct {
|
||||
const WRITE_REQ_PREALLOC = std.math.pow(usize, 2, 5);
|
||||
|
||||
/// Process start time and boolean of whether its already exited.
|
||||
start: internal_os.Instant,
|
||||
start: std.time.Instant,
|
||||
exited: bool = false,
|
||||
|
||||
/// The number of milliseconds below which we consider a process
|
||||
@ -1288,7 +1288,7 @@ const Subprocess = struct {
|
||||
const res = posix.waitpid(pid, std.c.W.NOHANG);
|
||||
log.debug("waitpid result={}", .{res.pid});
|
||||
if (res.pid != 0) break;
|
||||
internal_os.sleep(10 * std.time.ns_per_ms);
|
||||
std.time.sleep(10 * std.time.ns_per_ms);
|
||||
}
|
||||
},
|
||||
}
|
||||
@ -1311,7 +1311,7 @@ const Subprocess = struct {
|
||||
const pgid = c.getpgid(pid);
|
||||
if (pgid == my_pgid) {
|
||||
log.warn("pgid is our own, retrying", .{});
|
||||
internal_os.sleep(10 * std.time.ns_per_ms);
|
||||
std.time.sleep(10 * std.time.ns_per_ms);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ terminal_stream: terminal.Stream(StreamHandler),
|
||||
|
||||
/// Last time the cursor was reset. This is used to prevent message
|
||||
/// flooding with cursor resets.
|
||||
last_cursor_reset: ?internal_os.Instant = null,
|
||||
last_cursor_reset: ?std.time.Instant = null,
|
||||
|
||||
/// The configuration for this IO that is derived from the main
|
||||
/// configuration. This must be exported so that we don't need to
|
||||
@ -552,7 +552,7 @@ fn processOutputLocked(self: *Termio, buf: []const u8) void {
|
||||
// non-blink state so it is rendered if visible. If we're under
|
||||
// HEAVY read load, we don't want to send a ton of these so we
|
||||
// use a timer under the covers
|
||||
if (internal_os.Instant.now()) |now| cursor_reset: {
|
||||
if (std.time.Instant.now()) |now| cursor_reset: {
|
||||
if (self.last_cursor_reset) |last| {
|
||||
log.err("now: {} last: {}", .{ now, last });
|
||||
if (now.since(last) <= (500 * std.time.ns_per_ms)) {
|
||||
|
Reference in New Issue
Block a user