Stuff, bother.
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/target
|
||||
**/*.rs.bk
|
||||
13
Cargo.toml
Normal file
13
Cargo.toml
Normal file
@@ -0,0 +1,13 @@
|
||||
[package]
|
||||
name = "tuigui"
|
||||
version = "0.1.0"
|
||||
authors = ["Adam Wick <awick@uhsure.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[[bin]]
|
||||
path = "src/main.rs"
|
||||
name = "example"
|
||||
|
||||
[dependencies]
|
||||
log = "^0.4.6"
|
||||
simplelog = "^0.5.3"
|
||||
11
src/errors.rs
Normal file
11
src/errors.rs
Normal file
@@ -0,0 +1,11 @@
|
||||
use std::fmt;
|
||||
|
||||
pub enum TUIGUIError {
|
||||
}
|
||||
|
||||
impl fmt::Display for TUIGUIError {
|
||||
fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result
|
||||
{
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
24
src/lib.rs
Normal file
24
src/lib.rs
Normal file
@@ -0,0 +1,24 @@
|
||||
extern crate log;
|
||||
|
||||
pub mod errors;
|
||||
|
||||
use self::errors::TUIGUIError;
|
||||
|
||||
pub type Widget = ();
|
||||
pub type Attribute = ();
|
||||
|
||||
pub trait Application {
|
||||
type Event;
|
||||
type AttributeName;
|
||||
|
||||
fn draw(&self) -> Vec<Widget>;
|
||||
fn starting(&mut self);
|
||||
fn handle_event(&mut self, e: Self::Event);
|
||||
fn get_color(&self, n: Self::AttributeName) -> Attribute;
|
||||
}
|
||||
|
||||
pub fn tuigui<App: Application>(mut a: App) -> Result<(), TUIGUIError>
|
||||
{
|
||||
a.starting();
|
||||
Ok(())
|
||||
}
|
||||
55
src/main.rs
Normal file
55
src/main.rs
Normal file
@@ -0,0 +1,55 @@
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
extern crate simplelog;
|
||||
|
||||
use simplelog::{Config,LevelFilter,TermLogger};
|
||||
use tuigui::{Application,Attribute,Widget,tuigui};
|
||||
use tuigui::errors::TUIGUIError;
|
||||
|
||||
struct Example {
|
||||
}
|
||||
|
||||
impl Example {
|
||||
fn new() -> Example {
|
||||
Example{}
|
||||
}
|
||||
}
|
||||
|
||||
impl Application for Example {
|
||||
type Event = ();
|
||||
type AttributeName = ();
|
||||
|
||||
fn draw(&self) -> Vec<Widget> {
|
||||
Vec::new()
|
||||
}
|
||||
|
||||
fn starting(&mut self) {
|
||||
|
||||
}
|
||||
|
||||
fn handle_event(&mut self, e: ()) {
|
||||
|
||||
}
|
||||
|
||||
fn get_color(&self, an: ()) -> Attribute {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fn example() -> Result<(),TUIGUIError>
|
||||
{
|
||||
tuigui(Example::new())
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _ = TermLogger::init(LevelFilter::Trace, Config::default());
|
||||
// Actually run the example
|
||||
match example() {
|
||||
Ok(()) => {
|
||||
trace!("Execution completed successfully.")
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("ERROR: Failed with {}", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user