Skip to content

Commit b60190d

Browse files
committed
Docs + Polish + Remove bw mode
1 parent 7a247b8 commit b60190d

3 files changed

Lines changed: 24 additions & 29 deletions

File tree

src/app.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub struct App {
1414
/// Is the application running?
1515
pub running: bool,
1616

17+
pub verbose: bool,
1718
pub file_path: String,
1819
pub volume: utils::brain_volume::BrainVolume,
1920
pub image_cache: utils::slice_cache::SliceCache,
@@ -30,6 +31,7 @@ pub struct App {
3031
impl App {
3132
/// Constructs a new instance of [`App`].
3233
pub fn new(
34+
verbose: bool,
3335
file_path: &str,
3436
color_mode: utils::colors::ColorMode,
3537
) -> std::result::Result<Self, Box<dyn error::Error + Send + Sync>> {
@@ -52,9 +54,12 @@ impl App {
5254
utils::colors::ColorMap::Inferno
5355
};
5456

55-
println!("Data loaded in: {:?}", duration);
57+
if verbose {
58+
println!("Data loaded in: {:?}", duration);
59+
}
5660

5761
Ok(Self {
62+
verbose,
5863
running: true,
5964
file_path: file_path.to_string(),
6065
volume: volume,

src/main.rs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,20 @@ use std::io;
99
use tui::backend::CrosstermBackend;
1010
use tui::Terminal;
1111

12-
/// headjack - Terminal UI 3D volume brain imaging viewer
12+
13+
static LONG_ABOUT: &'static str =
14+
"headjack - Interactive NIfTI Viewer for the Terminal\n\n\
15+
Interactive controls:\n\
16+
\t- Arrow keys / WSAD: Move slice (Post.-Ant. / Left-Right)\n\
17+
\t\tNavigate metadata\n\
18+
\t- ZX: Move slice (Inf.-Sup.)\n\
19+
\t- Tab: Toggle metadata view\n\
20+
\t- C: Toggle color map\n\
21+
\t- Q / Esc / Ctrl+C: Quit";
22+
23+
/// headjack - Interactive NIfTI Viewer for the Terminal
1324
#[derive(Parser, Debug)]
14-
#[command(author, version, about, long_about = None)]
25+
#[command(author, version, about, long_about=LONG_ABOUT)]
1526
struct Args {
1627
/// Image file name (.nii or .nii.gz)
1728
#[arg(index = 1)]
@@ -20,26 +31,24 @@ struct Args {
2031
/// ANSI color mode for terminals not supporting true color (24bit).
2132
#[arg(short, long, action)]
2233
ansi: bool,
23-
24-
/// Black and white color mode for terminals not supporting any color (what year is this?).
34+
35+
/// Verbose (debug) output.
2536
#[arg(short, long, action)]
26-
bw: bool,
37+
verbose: bool,
2738
}
2839

2940
fn main() -> anyhow::Result<()> {
3041
// Read args
3142
let args = Args::parse();
3243

33-
let color_mode = if args.bw {
34-
ColorMode::Bw
35-
} else if args.ansi {
44+
let color_mode = if args.ansi {
3645
ColorMode::Ansi256
3746
} else {
3847
ColorMode::TrueColor
3948
};
4049

4150
// Create an application.
42-
let mut app = App::new(&args.input, color_mode)
51+
let mut app = App::new(args.verbose, &args.input, color_mode)
4352
.map_err(|e| anyhow!(e))
4453
.with_context(|| format!("Failed to load data '{}'", &args.input))?;
4554

src/utils/colors.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
pub enum ColorMode {
33
TrueColor,
44
Ansi256,
5-
Bw,
65
}
76

87
struct HjColor(colorous::Color);
@@ -41,9 +40,6 @@ pub fn calc_termcolor_rational(mode: ColorMode, map: colorous::Gradient, val: us
4140
ColorMode::Ansi256 => {
4241
tui::style::Color::Indexed(ansi_colours::ansi256_from_rgb(rgb))
4342
},
44-
ColorMode::Bw => {
45-
if val > (val_max/2) { tui::style::Color::White } else { tui::style::Color::Black }
46-
},
4743
}
4844
}
4945

@@ -57,9 +53,6 @@ pub fn calc_termcolor_continuous(mode: ColorMode, map: colorous::Gradient, val:
5753
ColorMode::Ansi256 => {
5854
tui::style::Color::Indexed(ansi_colours::ansi256_from_rgb(rgb))
5955
},
60-
ColorMode::Bw => {
61-
if val > 0.5 { tui::style::Color::White } else { tui::style::Color::Black }
62-
},
6356
}
6457
}
6558

@@ -73,9 +66,6 @@ pub fn calc_termcolor_inverted_rational(mode: ColorMode, map: colorous::Gradient
7366
ColorMode::Ansi256 => {
7467
tui::style::Color::Indexed(ansi_colours::ansi256_from_rgb(rgb))
7568
},
76-
ColorMode::Bw => {
77-
if val <= (val_max/2) { tui::style::Color::White } else { tui::style::Color::Black }
78-
},
7969
}
8070
}
8171

@@ -89,9 +79,6 @@ pub fn calc_termcolor_inverted_continuous(mode: ColorMode, map: colorous::Gradie
8979
ColorMode::Ansi256 => {
9080
tui::style::Color::Indexed(ansi_colours::ansi256_from_rgb(rgb))
9181
},
92-
ColorMode::Bw => {
93-
if val <= 0.5 { tui::style::Color::White } else { tui::style::Color::Black }
94-
},
9582
}
9683
}
9784

@@ -128,9 +115,6 @@ impl ColorMapper {
128115
ColorMode::Ansi256 => {
129116
tui::style::Color::Indexed(ansi_colours::ansi256_from_rgb(rgb))
130117
},
131-
ColorMode::Bw => {
132-
if value > 0.5 { tui::style::Color::White } else { tui::style::Color::Black }
133-
},
134118
}
135119
}
136120

@@ -144,9 +128,6 @@ impl ColorMapper {
144128
ColorMode::Ansi256 => {
145129
tui::style::Color::Indexed(ansi_colours::ansi256_from_rgb(rgb))
146130
},
147-
ColorMode::Bw => {
148-
if value <= 0.5 { tui::style::Color::White } else { tui::style::Color::Black }
149-
},
150131
}
151132
}
152133
}

0 commit comments

Comments
 (0)