bibliofile/src/main.rs

51 lines
1.1 KiB
Rust
Raw Normal View History

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.");
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
fn screen(line: &str){
let mut stdscr: i8 = 0;
let mut w: i32 = 0; //width
let mut h: i32 = 0; //height
ncurses::getmaxyx(&mut stdscr, &mut h, &mut w);
2023-03-17 02:58:32 +00:00
ncurses::initscr();
ncurses::clear();
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
}