mirror of
https://github.com/RGBCube/ZTerm
synced 2025-07-29 08:57:46 +00:00
Fix naming failures and use pub
This commit is contained in:
parent
5a8aee9602
commit
3883c63baa
1 changed files with 8 additions and 8 deletions
16
src/lib.zig
16
src/lib.zig
|
@ -3,9 +3,9 @@ const Mutex = std.Thread.Mutex;
|
||||||
const time = std.time;
|
const time = std.time;
|
||||||
|
|
||||||
const default_frame_rate = 150 * time.ns_per_ms;
|
const default_frame_rate = 150 * time.ns_per_ms;
|
||||||
const default_charset = [_][]u8{ "|", "/", "-", "\\" };
|
const default_charset = [_][]const u8{ "|", "/", "-", "\\" };
|
||||||
|
|
||||||
const Spinner = struct {
|
pub const Spinner = struct {
|
||||||
// When locked, the spinner will stop spinning.
|
// When locked, the spinner will stop spinning.
|
||||||
stop_lock: Mutex,
|
stop_lock: Mutex,
|
||||||
// Used to check if stopped.
|
// Used to check if stopped.
|
||||||
|
@ -15,22 +15,23 @@ const Spinner = struct {
|
||||||
charset: [][]const u8,
|
charset: [][]const u8,
|
||||||
message: []const u8,
|
message: []const u8,
|
||||||
|
|
||||||
export fn new(framerate: ?u64, charset: ?[][]const u8, message: ?[]const u8) Spinner {
|
pub fn new(framerate: ?u64, charset: ?[][]const u8, message: ?[]const u8) Spinner {
|
||||||
return Spinner{
|
return Spinner{
|
||||||
.thread_lock = Mutex{},
|
.stop_lock = Mutex{},
|
||||||
.ns_per_frame = framerate orelse default_frame_rate,
|
.stopped_lock = Mutex{},
|
||||||
|
.framerate = framerate orelse default_frame_rate,
|
||||||
.charset = charset orelse default_charset,
|
.charset = charset orelse default_charset,
|
||||||
.message = message orelse "",
|
.message = message orelse "",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export fn start(sp: *Spinner) void {
|
pub fn start(sp: *Spinner) void {
|
||||||
sp.stop_lock.unlock();
|
sp.stop_lock.unlock();
|
||||||
sp.stopped_lock.unlock();
|
sp.stopped_lock.unlock();
|
||||||
async sp.writer();
|
async sp.writer();
|
||||||
}
|
}
|
||||||
|
|
||||||
export fn stop(sp: *Spinner) void {
|
pub fn stop(sp: *Spinner) void {
|
||||||
sp.stop_lock.lock();
|
sp.stop_lock.lock();
|
||||||
sp.stopped_lock.lock();
|
sp.stopped_lock.lock();
|
||||||
}
|
}
|
||||||
|
@ -65,7 +66,6 @@ const Spinner = struct {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
test "asd" {
|
test "asd" {
|
||||||
var sp = Spinner.new(null, null, "Loading...");
|
var sp = Spinner.new(null, null, "Loading...");
|
||||||
sp.start();
|
sp.start();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue