1
0
Fork 0
forked from fun/fun

Added some progress bar foo to Console class. (0.37.48)

This commit is contained in:
Johannes Findeisen 2026-01-13 03:18:37 +01:00
commit 44cf629016
5 changed files with 147 additions and 7 deletions

View file

@ -503,10 +503,6 @@ void vm_print_output(VM *vm) {
printf("\n");
}
}
/* If the last item was partial (from echo), terminate the line for cleanliness */
if (vm->output_count > 0 && vm->output_is_partial[vm->output_count - 1]) {
printf("\n");
}
}
void vm_run(VM *vm, Bytecode *entry) {
@ -853,6 +849,18 @@ void vm_run(VM *vm, Bytecode *entry) {
}
break;
}
/* Stream console output in realtime for scripts:
* When PRINT/ECHO pushed items into the VM's output buffer, flush them
* immediately to stdout and clear the buffer to avoid end-of-run bursts.
* This keeps REPL compatibility (REPL still prints after each submit),
* while regular script execution shows progress bars live.
*/
if (inst.op == OP_PRINT || inst.op == OP_ECHO) {
vm_print_output(vm);
vm_clear_output(vm);
fflush(stdout);
}
}
g_active_vm = NULL;
}