feat: ASCII animation player + anim%save fix + gfortran 16 spec workaround#1828
Merged
krystophny merged 2 commits intomainfrom May 7, 2026
Merged
feat: ASCII animation player + anim%save fix + gfortran 16 spec workaround#1828krystophny merged 2 commits intomainfrom
krystophny merged 2 commits intomainfrom
Conversation
- Add fortplot_ascii_player module that parses the `=== Frame N ===`
format produced by save_animation('*.txt') and plays frames at a
chosen FPS, with optional ANSI clear-screen between frames.
- Add fortplot_play_ascii CLI app: file + --fps + --loop / --once /
--no-clear / --dry-run flags, sleeps via libc nanosleep.
- Tests: parse-header edge cases, frame count, dry-run, capture-to-unit,
missing-file/zero-fps error paths, plus an end-to-end test that
drives save_animation('*.txt') and the player together.
- Make `anim%save(...)` work directly, as documented in README. Routed
through a facade FuncAnimation that registers the save implementation
pointer up front, so users do not need to call save_animation() first
to wake the dispatcher.
- README: mention .txt as a supported animation format and how to play
it back; example/animation/README likewise.
- Work around a gfortran 16 -O0 miscompile of certain
`'{' // new_line('a') // <chunk>` deferred-length allocatable
concatenations in spec_to_json that produced an all-blanks header
and crashed test_spec downstream. MRE filed at
krystophny/gcc-dev#167; the fix routes the schema header through a
`len=*` formal so the buggy expansion is never emitted.
The C binding to nanosleep is POSIX-only and hangs the Windows runner (symbol is absent from MSVC libc and unreliable under MinGW). Replace sleep_ms with a system_clock-based busy wait that matches the existing fortplot pattern (animation_core, matplotlib_session). Resolves the test_ascii_player Windows timeout (exit 124) on PR #1828.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Test plan
Verification
Test fails on main (system gfortran 16, -O0)
```
$ git checkout main && fpm test test_spec
...
FAIL: rt line: parse succeeds
FAIL: rt line: mark type
...
At line 669 of file test/test_spec.f90
Fortran runtime error: Index '1' of dimension 1 of array 'parsed...%columns' below lower bound of
Error termination.
cmd_run:stopping due to failed executions
STOP 2
```
```
$ git checkout main && fpm test test_animation_txt_save # writes a .txt animation
(passes, but no way to play it back -- before this PR)
```
```
$ # README example pattern: anim%save("movie.txt", status=status)
Returns -1 with "Animation save implementation not initialized" before this PR.
```
Test passes after fix
```
$ make test 2>&1 | tail -3
ALL TESTS PASSED (fpm test)
```
```
$ fpm test test_spec 2>&1 | tail -4
=== Spec Test Summary ===
Tests passed: 158 / 158
All spec tests PASSED!
STOP 0
```
```
$ fpm test test_ascii_player test_ascii_player_e2e 2>&1 | tail -4
PASS test_ascii_player
PASS test_ascii_player_e2e
```
Player demo
```
$ fpm run --target fortplot_play_ascii -- /tmp/wave.txt --fps 24 --loop
=== Frame 1 ===
ascii animation
+--------------------------------------------------------------------------------+
|...|
... (animated)
```
Notes