termbox2
Version, currently 0.1.12 versions
- 0.1.2latestJun 2, 2025
- 0.1.1not indexedJun 2, 2025
github.com/homonoidian/termbox2.cr
Bindings for termbox2, and a tiny bit more
1 stars
1 dependent
License: MIT
Nothing has been indexed for 0.1.1 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.
Installation
# Add this to your shard.yml
dependencies:
termbox2:
github: homonoidian/termbox2.cr
version: ~> 0.1.1Then run:
shards installshard.yml
No shard.yml has been indexed for 0.1.1. You can read it on the repository.
Dependencies
Unknown: the shard.yml for this version has not been read yet.
README
This README is the one indexed from the repository at its latest ref, not from the tag for this version.
# termbox2
A tiny bindings shard plus a bit more for [termbox2](https://github.com/termbox/termbox2).
Docs & comments & stuff stolen from there. The library is pretty cool except for a bunch
of key event (key name) clashes which are too weird to even discuss, and the termbox2 devs
aren't those to blame (it seems).
## Installation
1. Add the dependency to your `shard.yml`:
```yaml
dependencies:
termbox2:
github: homonoidian/termbox2.cr
```
2. Run `shards install`
## Usage
```crystal
require "termbox2"
include Termbox
include Termbox::Event
Termbox.enable
# Can be changed to other modes dynamically, colors will
# scale with some effort. See `examples/hello.cr`
Termbox.set_output_mode(OutputMode::Truecolor)
Termbox.clear(bg: Color[0x11, 0x11, 0x11], fg: Color[0xec, 0xec, 0xec])
bg_1 = Color[0x11, 0x11, 0x11]
bg_2 = Color[0xa3, 0xa7, 0x2a]
cbg = bg_1
frametimer = 0
h = 0
# This guy will automatically Termbox.disable.
#
# If you won't use it, you'd have to Termbox.disable yourself.
Termbox.each(nap: 33.milliseconds) do |event|
# can be nil or mouse event or resize event or key event
if event.is_a?(KeyEvent)
if event.char == 'q'
break
else
end
end
Termbox.clear
Termbox.print(
x: Termbox.width // 2 - 10 + (-10..10).sample,
y: Termbox.height // 2 + (-1..1).sample,
fg: Color[h: h / 360, s: 0.5, l: 0.5],
bg: cbg,
object: "Going nuclear would be fun AF!!!",
)
if h > 360
h = 0
else
h += 1
end
cbg =
if frametimer > 10
frametimer = 0
if rand < 0.5
bg_2
else
bg_1
end
else
frametimer += 1
cbg
end
Termbox.present
end
```
## Development
TODO: Write development instructions here
## Contributing
1. Fork it (<https://github.com/homonoidian/termbox2.cr/fork>)
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request
## Contributors
- [Alexey Yurchenko](https://github.com/homonoidian) - creator and maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.1.1- Tagged
- Jun 2, 2025
- Commit
ef2ebd9c2ed1- Indexed
- not yet
Dependents
Repository
github.com/homonoidian/termbox2.cr
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 12, 2026
- Synced
- Aug 12, 2026
- Versions
- 2