Skip to content

Commit

Permalink
Added new source file for printing to display
Browse files Browse the repository at this point in the history
  • Loading branch information
WGUNDERWOOD committed May 3, 2024
1 parent d5ecf97 commit 94acf7c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
1 change: 0 additions & 1 deletion notes.org
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
** Documentation
** Tidy up code
** Find todos
** New source files: print.rs
** Tests better output
** Better file backup
* Bugs
Expand Down
17 changes: 6 additions & 11 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@ use std::fs;

const TAB: i8 = 2;

const YELLOW: &str = "\x1b[33m\x1b[1m";
const PINK: &str = "\x1b[35m\x1b[1m";
const RESET: &str = "\x1b[00m\x1b[0m";

mod comments;
mod format;
mod indent;
mod parse;
mod print;
mod regexes;
mod subs;
mod wrap;
mod write;
use crate::format::*;
use crate::parse::Cli;
use crate::parse::*;
use crate::print::*;
use crate::write::*;

#[cfg(test)]
Expand All @@ -38,13 +36,11 @@ fn main() {
|| f.ends_with(".sty")
|| f.ends_with(".cls")));

// print script name
println!("{}", String::new() + PINK + "tex-fmt" + RESET);
print_script_name();

for filename in filenames {
// print file name
if debug {
println!("{}", String::new() + YELLOW + &filename + RESET);
print_file_name(&filename);
}

// read lines from file
Expand All @@ -54,8 +50,7 @@ fn main() {
let new_file = format_file(&file, debug);

if print {
// print new file
println!("{}", &new_file);
print_file(&new_file);
} else {
backup_file(&filename);
write_file(&filename, &new_file);
Expand Down
15 changes: 15 additions & 0 deletions src/print.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const PINK: &str = "\x1b[35m\x1b[1m";
const RESET: &str = "\x1b[00m\x1b[0m";
const YELLOW: &str = "\x1b[33m\x1b[1m";

pub fn print_script_name() {
println!("{}", String::new() + PINK + "tex-fmt" + RESET);
}

pub fn print_file_name(filename: &str) {
println!("{}", String::new() + YELLOW + filename + RESET);
}

pub fn print_file(new_file: &str) {
println!("{}", new_file);
}

0 comments on commit 94acf7c

Please sign in to comment.