Skip to content

Commit

Permalink
Project initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentFoulon80 committed Apr 15, 2020
0 parents commit 3bd8af2
Show file tree
Hide file tree
Showing 6 changed files with 596 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/target
Cargo.lock
14 changes: 14 additions & 0 deletions Cargo.toml
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"}
34 changes: 34 additions & 0 deletions README.md
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
}
}
```
Loading

0 comments on commit 3bd8af2

Please sign in to comment.