Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

builtin: implement unbuffer_stdout/0 #20662

Merged
merged 1 commit into from
Jan 26, 2024

Conversation

spytheman
Copy link
Member

@spytheman spytheman commented Jan 26, 2024

This API addresses this Discord discussion: https://discord.com/channels/592103645835821068/592294828432424960/1161031983506411533

With it, you can implement a simple progress bar, using code like this:

import time
unbuffer_stdout()
for _ in 0 .. 10 {
	print('*')
	time.sleep(100 * time.millisecond)
}
println(' done')

Note that each * will appear in your terminal right away. If you comment the unbuffer_stdout() call, then each star will be buffered, and you will see the whole bar, only at the end (after the println() call).

@spytheman spytheman merged commit 2a68e2b into vlang:master Jan 26, 2024
54 checks passed
@spytheman spytheman deleted the builtin_add_unbuffer_stdout branch January 26, 2024 15:47
raw-bin pushed a commit to raw-bin/v that referenced this pull request Jan 29, 2024
raw-bin pushed a commit to raw-bin/v that referenced this pull request Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant