1
Fork 0
mirror of https://github.com/RGBCube/ZTerm synced 2025-07-29 08:57:46 +00:00

Fix example

This commit is contained in:
RGBCube 2023-05-17 23:45:07 +03:00
parent 9eeb776fe5
commit 7f5fdc55ea
2 changed files with 18 additions and 10 deletions

View file

@ -11,19 +11,22 @@ The contents will be briefly covered here.
```zig ```zig
const std = @import("std"); const std = @import("std");
const time = std.time;
const zterm = @import("zterm"); const zterm = @import("zterm");
pub fn main() !void { pub fn main() !void {
var sp = zterm.Spinner{ var sp = zterm.Spinner{
.loading_charset = [_][]const u8{"⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷"}; .loading_charset = &[_][]const u8{"⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷"},
.loading_message = "Selling all your data to the CCP...", .loading_message = "Selling all your data to the CCP...",
.finished_charset = "✓", .finished_charset = "✓",
.finished_message = "Lock your doors.", .finished_message = "Lock your doors.",
}; };
try sp.start(); try sp.start();
var stdOut = std.io.getOut(); time.sleep(3 * time.ns_per_s);
try stdOut.writeAll("Calculating very important stuff..."); var stdOut = std.io.getStdOut();
try stdOut.writeAll("\rCalculating very important stuff while selling your data...\n");
time.sleep(2 * time.ns_per_s);
try sp.stop(); try sp.stop();
} }

View file

@ -1,17 +1,22 @@
const Spinner = @import("src/Spinner.zig");
const std = @import("std"); const std = @import("std");
const time = std.time; const time = std.time;
const zterm = struct {
const Spinner = @import("src/Spinner.zig");
};
pub fn main() !void { pub fn main() !void {
var sp = Spinner{ var sp = zterm.Spinner{
.loading_message = "Loading", .loading_charset = &[_][]const u8{"", "", "", "", "", "", "", ""},
.finished_message = "Done", .loading_message = "Selling all your data to the CCP...",
.finished_charset = "",
.finished_message = "Lock your doors.",
}; };
try sp.start(); try sp.start();
time.sleep(3 * time.ns_per_s); time.sleep(3 * time.ns_per_s);
var stdOut = std.io.getStdOut();
try stdOut.writeAll("\rCalculating very important stuff while selling your data...\n");
time.sleep(2 * time.ns_per_s);
try sp.stop(); try sp.stop();
} }