From c6cfebdb75dd529588156a2ba9ceb5ca62bab49e Mon Sep 17 00:00:00 2001 From: Nathan Vegdahl Date: Thu, 29 Jan 2015 20:35:19 -0800 Subject: [PATCH] Commented out the GUI modules until I can figure out how to get it working again. The rust SDL2 bindings have changed in a way that makes the lifetimes very strict. This is probably a good thing from a safety standpoint, but means I'll likely need to re-architect the GUI drawing code. For now I'm going to leave that on the back-burner and focus on getting the console version working. --- Cargo.toml | 9 ++++++--- src/files.rs | 4 ++-- src/main.rs | 40 ++++++++++++++++++++-------------------- src/term_ui/mod.rs | 10 ++++++++-- 4 files changed, 36 insertions(+), 27 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8bff2c8..6f9bd29 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,8 +8,8 @@ authors = ["Nathan Vegdahl "] name = "led" path = "src/main.rs" -[dependencies] -sdl2 = "0.0.17" +[dependencies.sdl2] +git = "https://github.com/AngryLawyer/rust-sdl2.git" [dependencies.docopt] git = "https://github.com/docopt/docopt.rs.git" @@ -18,4 +18,7 @@ git = "https://github.com/docopt/docopt.rs.git" git = "https://github.com/gchp/rustbox.git" [dependencies.freetype-rs] -git = "https://github.com/PistonDevelopers/freetype-rs.git" \ No newline at end of file +git = "https://github.com/PistonDevelopers/freetype-rs.git" + +[dependencies] +rustc-serialize = "*" \ No newline at end of file diff --git a/src/files.rs b/src/files.rs index 0215c4f..074cccb 100644 --- a/src/files.rs +++ b/src/files.rs @@ -1,5 +1,5 @@ -use std::io::{IoResult, BufferedReader, BufferedWriter}; -use std::io::fs::File; +use std::old_io::{IoResult, BufferedReader, BufferedWriter}; +use std::old_io::fs::File; use std::path::Path; use buffer::line::{Line, LineEnding, line_ending_to_str}; diff --git a/src/main.rs b/src/main.rs index 4fed8e1..a960c24 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,24 +3,24 @@ extern crate rustbox; extern crate docopt; extern crate "rustc-serialize" as rustc_serialize; -extern crate freetype; -extern crate sdl2; +//extern crate freetype; +//extern crate sdl2; use std::path::Path; use docopt::Docopt; use editor::Editor; use term_ui::TermUI; use term_ui::formatter::ConsoleLineFormatter; -use gui::GUI; -use gui::formatter::GUILineFormatter; +//use gui::GUI; +//use gui::formatter::GUILineFormatter; mod string_utils; mod buffer; mod files; mod editor; mod term_ui; -mod font; -mod gui; +//mod font; +//mod gui; @@ -37,7 +37,7 @@ Options: // Struct for storing command-line arguments -#[derive(RustcDecodable, Show)] +#[derive(RustcDecodable, Debug)] struct Args { arg_file: Option, flag_gui: bool, @@ -54,19 +54,19 @@ fn main() { // Initialize and start UI if args.flag_gui { - // Load file, if specified - let editor = if let Option::Some(s) = args.arg_file { - Editor::new_from_file(GUILineFormatter::new(4), &Path::new(s.as_slice())) - } - else { - Editor::new(GUILineFormatter::new(4)) - }; - - // GUI - sdl2::init(sdl2::INIT_VIDEO); - let mut ui = GUI::new_from_editor(editor); - ui.main_ui_loop(); - sdl2::quit(); + // // Load file, if specified + // let editor = if let Option::Some(s) = args.arg_file { + // Editor::new_from_file(GUILineFormatter::new(4), &Path::new(s.as_slice())) + // } + // else { + // Editor::new(GUILineFormatter::new(4)) + // }; + // + // // GUI + // sdl2::init(sdl2::INIT_VIDEO); + // let mut ui = GUI::new_from_editor(editor); + // ui.main_ui_loop(); + // sdl2::quit(); } else { // Load file, if specified diff --git a/src/term_ui/mod.rs b/src/term_ui/mod.rs index 205e0ac..0fdd161 100644 --- a/src/term_ui/mod.rs +++ b/src/term_ui/mod.rs @@ -43,7 +43,10 @@ pub struct TermUI { impl TermUI { pub fn new() -> TermUI { - let rb = rustbox::RustBox::init(&[Some(rustbox::InitOption::BufferStderr)]).unwrap(); + let rb = match rustbox::RustBox::init(&[Some(rustbox::InitOption::BufferStderr)]) { + Ok(rbox) => rbox, + Err(_) => panic!("Could not create Rustbox instance."), + }; let w = rb.width(); let h = rb.height(); let mut editor = Editor::new(ConsoleLineFormatter::new(4)); @@ -58,7 +61,10 @@ impl TermUI { } pub fn new_from_editor(ed: Editor) -> TermUI { - let rb = rustbox::RustBox::init(&[Some(rustbox::InitOption::BufferStderr)]).unwrap(); + let rb = match rustbox::RustBox::init(&[Some(rustbox::InitOption::BufferStderr)]) { + Ok(rbox) => rbox, + Err(_) => panic!("Could not create Rustbox instance."), + }; let w = rb.width(); let h = rb.height(); let mut editor = ed;