Last active
April 9, 2020 01:53
-
-
Save qhwa/7ef65acb13ec656cc13d7418d066cfcc to your computer and use it in GitHub Desktop.
Hello world from ExTermbox.
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
| alias ExTermbox.Bindings, as: Termbox | |
| alias ExTermbox.{Cell, EventManager, Event, Position} | |
| :ok = Termbox.init() | |
| {:ok, _pid} = EventManager.start_link() | |
| :ok = EventManager.subscribe(self()) | |
| for {ch, x} <- Enum.with_index('Hello, World! 你好世界!') do | |
| :ok = Termbox.put_cell(%Cell{position: %Position{x: x, y: 0}, ch: ch}) | |
| end | |
| for {ch, x} <- Enum.with_index('(Press <q> to quit)') do | |
| :ok = Termbox.put_cell(%Cell{position: %Position{x: x, y: 2}, ch: ch}) | |
| end | |
| Termbox.present() | |
| receive do | |
| {:event, %Event{ch: ?q}} -> | |
| :ok = EventManager.stop() | |
| :ok = Termbox.shutdown() | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment