Skip to content

Instantly share code, notes, and snippets.

@qhwa
Last active April 9, 2020 01:53
Show Gist options
  • Select an option

  • Save qhwa/7ef65acb13ec656cc13d7418d066cfcc to your computer and use it in GitHub Desktop.

Select an option

Save qhwa/7ef65acb13ec656cc13d7418d066cfcc to your computer and use it in GitHub Desktop.
Hello world from ExTermbox.
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