1
Fork 0
mirror of https://github.com/RGBCube/ZTerm synced 2025-07-28 16:37: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
const std = @import("std");
const time = std.time;
const zterm = @import("zterm");
pub fn main() !void {
var sp = zterm.Spinner{
.loading_charset = [_][]const u8{"⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷"};
.loading_charset = &[_][]const u8{"⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷"},
.loading_message = "Selling all your data to the CCP...",
.finished_charset = "✓",
.finished_message = "Lock your doors.",
};
try sp.start();
var stdOut = std.io.getOut();
try stdOut.writeAll("Calculating very important stuff...");
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();
}

View file

@ -1,17 +1,22 @@
const Spinner = @import("src/Spinner.zig");
const std = @import("std");
const time = std.time;
const zterm = struct {
const Spinner = @import("src/Spinner.zig");
};
pub fn main() !void {
var sp = Spinner{
.loading_message = "Loading",
.finished_message = "Done",
var sp = zterm.Spinner{
.loading_charset = &[_][]const u8{"", "", "", "", "", "", "", ""},
.loading_message = "Selling all your data to the CCP...",
.finished_charset = "",
.finished_message = "Lock your doors.",
};
try sp.start();
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();
}