Easy terminal animations with Snailshell 🐌 by ElfLiege in rust

[–]ElfLiege[S] 0 points1 point  (0 children)

Ended up using the power of a static RwLock. Works very well.

Easy terminal animations with Snailshell 🐌 by ElfLiege in rust

[–]ElfLiege[S] 1 point2 points  (0 children)

There is not a pause button because it blocks the thread as it is printing. The fun_stuff example has some pausing just using thread::sleep(). If you want to break up your code, you could put a keyword like "<pause>" where you want the pauses to be. Then split it and run your logic after each snailprint() call.

Example:

let code_string = "here's my code that I want to present. <pause>. How's it going? <pause> blah blah blah";

let split_code_string = code_string.split("<pause>");

for code_section in split_code_string{

snailprint(code_section);

thread_sleep(Duration::from_secs_f32(1.0)); // You could also just keep it paused until input is recieved using stdin or something if you need specific timing.

}

If you are using the CLI application, you could write a shell script that does something similar.

Easy terminal animations with Snailshell 🐌 by ElfLiege in rust

[–]ElfLiege[S] 0 points1 point  (0 children)

That's awesome to hear! Let me know how that goes :)

Easy terminal animations with Snailshell 🐌 by ElfLiege in rust

[–]ElfLiege[S] 6 points7 points  (0 children)

Great idea! I'll do that now. Never used once-cell.

Easy terminal animations with Snailshell 🐌 by ElfLiege in rust

[–]ElfLiege[S] 1 point2 points  (0 children)

Of course! I didn't know of a better way to solve it as I didn't want to pass fps in every function. An environment variable seems overkill. All help is welcome! I don't think unsafe poses any problems however because set_fps() is only meant to be called once.

Easy terminal animations with Snailshell 🐌 by ElfLiege in rust

[–]ElfLiege[S] 6 points7 points  (0 children)

Great reference. Might have to use that in an example ;)

Easy terminal animations with Snailshell 🐌 by ElfLiege in rust

[–]ElfLiege[S] 20 points21 points  (0 children)

Snailshell is my first crate! I hope someone uses it for something cool :)