2023-03-17 03:22:09 +00:00
|
|
|
/*
|
|
|
|
Program: Bibliofile
|
|
|
|
Language: Rustc 1.68.0
|
|
|
|
ide: Visual Studio Code
|
|
|
|
Operating system: Linux Mint 21.1
|
|
|
|
Purpose: ncurses based ereader and library manager for Linux terminal environments.
|
|
|
|
Last edited: 10:18 PM 3/16/23
|
|
|
|
*/
|
|
|
|
|
2023-03-17 02:10:15 +00:00
|
|
|
use std::fs::File;
|
|
|
|
use std::io::prelude::*;
|
|
|
|
use std::env;
|
2023-03-17 02:58:32 +00:00
|
|
|
extern crate ncurses;
|
2023-03-17 02:10:15 +00:00
|
|
|
|
2023-03-17 03:22:09 +00:00
|
|
|
|
|
|
|
//initial function. Reads the ebook passed by argument.
|
|
|
|
//TODO: add visual library to pull up ebooks.
|
2023-03-17 02:10:15 +00:00
|
|
|
fn main() -> std::io::Result<()> {
|
|
|
|
let args: Vec<String> = env::args().collect();
|
2023-03-17 03:22:09 +00:00
|
|
|
|
2023-03-17 02:10:15 +00:00
|
|
|
let filename = &args[1];
|
|
|
|
|
|
|
|
let mut file = File::open(filename).expect("cannot open file.");
|
|
|
|
let mut contents = String::new();
|
|
|
|
file.read_to_string(&mut contents).expect("unreadable file.");
|
|
|
|
|
2023-03-17 18:59:57 +00:00
|
|
|
|
|
|
|
screen(&contents);
|
2023-03-17 02:10:15 +00:00
|
|
|
Ok(())
|
2023-03-17 02:58:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-03-17 03:22:09 +00:00
|
|
|
|
|
|
|
//screen init function
|
2023-03-17 18:59:57 +00:00
|
|
|
fn screen(line: &str){
|
|
|
|
|
2023-03-17 02:58:32 +00:00
|
|
|
ncurses::initscr();
|
2023-03-17 18:59:57 +00:00
|
|
|
ncurses::addstr(line);
|
2023-03-17 02:58:32 +00:00
|
|
|
ncurses::refresh();
|
|
|
|
ncurses::getch();
|
|
|
|
ncurses::endwin();
|
|
|
|
|
2023-03-17 01:11:57 +00:00
|
|
|
}
|