commit 8e8cb40334a0a54d86e906006e3a5be7b6434b79 Author: Adam Wick Date: Tue Feb 12 10:56:32 2019 -0800 Stuff, bother. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..53eaa21 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..269262b --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "tuigui" +version = "0.1.0" +authors = ["Adam Wick "] +edition = "2018" + +[[bin]] +path = "src/main.rs" +name = "example" + +[dependencies] +log = "^0.4.6" +simplelog = "^0.5.3" diff --git a/src/errors.rs b/src/errors.rs new file mode 100644 index 0000000..3871534 --- /dev/null +++ b/src/errors.rs @@ -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(()) + } +} \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..4586b6f --- /dev/null +++ b/src/lib.rs @@ -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; + fn starting(&mut self); + fn handle_event(&mut self, e: Self::Event); + fn get_color(&self, n: Self::AttributeName) -> Attribute; +} + +pub fn tuigui(mut a: App) -> Result<(), TUIGUIError> +{ + a.starting(); + Ok(()) +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..944229a --- /dev/null +++ b/src/main.rs @@ -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 { + 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); + } + } +}