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

examples: add vmatrix.v showing a Matrix like terminal screen effect #21814

Merged
merged 2 commits into from
Jul 7, 2024

Conversation

mike-ward
Copy link
Contributor

A fun example of the, "Matrix" screen effect in V.

@Delta456
Copy link
Member

Delta456 commented Jul 6, 2024

The program tears apart when scrolling.

image

@spytheman
Copy link
Member

spytheman commented Jul 6, 2024

The program tears apart when scrolling.

A patch like this seems to work:

import term.termios
...
fn init_terminal() ! {
    mut old_state := termios.Termios{}
    termios.tcgetattr(0, mut old_state)
    // restore cursor, exit alternate buffer mode on Ctrl+C
    os.signal_opt(os.Signal.int, fn [mut old_state] (sig os.Signal) {
        println('\e[?1049l\e[?25h')
        termios.set_state(0, old_state)
        exit(0)
    })!
    // turn off cursor, enter alternate buffer mode
    print('\e[?1049h\e[?25l')
    mut new_state := old_state
    new_state.disable_echo()
    termios.set_state(0, new_state)
}

@spytheman
Copy link
Member

@spytheman spytheman changed the title vmatrix terminal screen effect examples: add vmatrix.v showing a Matrix like terminal screen effect Jul 6, 2024
@mike-ward
Copy link
Contributor Author

@spytheman Thanks for the patch. I'll add it.

@spytheman
Copy link
Member

@mike-ward happy to help.

Good work on the effect, the code is very readable.

@spytheman spytheman merged commit df18047 into vlang:master Jul 7, 2024
44 checks passed
@medvednikov
Copy link
Member

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.

4 participants