-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3bd8af2
Showing
6 changed files
with
596 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/target | ||
Cargo.lock |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[package] | ||
name = "console_engine" | ||
description = "A simple console framework that provides display and keyboard features" | ||
version = "0.1.0" | ||
authors = ["Vincent Foulon <[email protected]>"] | ||
repository = "https://github.com/VincentFoulon80/console_engine" | ||
readme = "README.md" | ||
license = "MIT" | ||
edition = "2018" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
termion = { git = "https://gitlab.redox-os.org/Jezza/termion", branch = "windows-support", package = "termion"} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Console Engine | ||
|
||
This library provides simple features for handling user's input and display for terminal applications. | ||
It uses [Termion](https://crates.io/crates/termion) as main tool for handling the screen and inputs. You don't have to worry about initalizing anything because the lib will handle this for you. | ||
|
||
# example usage | ||
```rust | ||
use console_engine::pixel; | ||
use termion::color; | ||
use termion::event::Key; | ||
|
||
fn main() { | ||
// initializes a screen of 20x10 characters with a target of 1 frame per second | ||
// coordinates will range from [0,0] to [19,9] | ||
let mut engine = console_engine::ConsoleEngine::init(20, 10, 1); | ||
let value = 14; | ||
// main loop, be aware that you'll have to break it because ctrl+C is captured | ||
loop { | ||
engine.wait_frame(); // wait for next frame + capture inputs | ||
engine.clear_screen(); // reset the screen | ||
|
||
engine.line(0, 0, 9, 9, pixel::pxl('#')); // draw a line of '#' from [0,0] to [9,9] | ||
engine.print(0, 4, format!("Result: {}", value)); // prints some value at [0,4] | ||
|
||
engine.set_pxl(4, 0, pixel::pxl_fg('O', color::Cyan)); // write a majestic cyan 'O' at [4,0] | ||
|
||
if engine.is_key_pressed(Key::Char('q')) { // if the user presses 'q' : | ||
break; // exits app | ||
} | ||
|
||
engine.draw(); // draw the screen | ||
} | ||
} | ||
``` |
Oops, something went wrong.