Added --fancy option.
This commit is contained in:
parent
f3b48aa7a8
commit
fd325a88ca
5 changed files with 20 additions and 26 deletions
|
@ -15,7 +15,7 @@ pub struct Clock {
|
|||
pub paused: bool,
|
||||
paused_at: Option<time::Instant>,
|
||||
pub color_index: Option<usize>,
|
||||
pub font: font::Font,
|
||||
pub font: &'static font::Font,
|
||||
}
|
||||
|
||||
impl Clock {
|
||||
|
@ -27,10 +27,7 @@ impl Clock {
|
|||
paused: false,
|
||||
paused_at: None,
|
||||
color_index: None,
|
||||
font: match config.plain {
|
||||
false => font::NORMAL,
|
||||
true => font::PLAIN,
|
||||
},
|
||||
font: config.font,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -162,8 +162,7 @@ pub const PLAIN: Font = Font {
|
|||
]],
|
||||
};
|
||||
|
||||
/*
|
||||
pub const FANCE: Font = Font {
|
||||
pub const CHROME: Font = Font {
|
||||
height: DIGIT_HEIGHT,
|
||||
width: 5,
|
||||
dot: '■',
|
||||
|
@ -239,4 +238,4 @@ pub const FANCE: Font = Font {
|
|||
" 🮐"
|
||||
]],
|
||||
};
|
||||
*/
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
|
||||
pub const COLOR: [&dyn termion::color::Color; 6] = [
|
||||
&termion::color::Cyan,
|
||||
&termion::color::Magenta,
|
||||
&termion::color::Green,
|
||||
&termion::color::Yellow,
|
||||
&termion::color::Blue,
|
||||
&termion::color::Red,
|
||||
&termion::color::LightGreen,
|
||||
&termion::color::LightYellow,
|
||||
&termion::color::LightMagenta,
|
||||
&termion::color::LightCyan,
|
||||
&termion::color::LightRed,
|
||||
&termion::color::LightBlue,
|
||||
];
|
||||
|
||||
// Maximum length of labels.
|
||||
|
@ -27,7 +27,8 @@ OPTIONS:
|
|||
-e, --exec [COMMAND] Execute COMMAND on alarm. Occurrences of {t} will
|
||||
be replaced by the alarm time in (HH:)MM:SS format.
|
||||
Occurrences of {l} by alarm label.
|
||||
-p, --plain Use simpler block chars.
|
||||
-p, --plain Use simpler block chars to draw the clock.
|
||||
-f, --fancy Use fancy clock style.
|
||||
-q, --quit Quit program after last alarm.
|
||||
|
||||
SIGNALS: <SIGUSR1> Reset clock.
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use crate::Config;
|
||||
use crate::clock::Clock;
|
||||
|
||||
pub struct Position {
|
||||
|
@ -11,7 +10,6 @@ pub struct Position {
|
|||
pub struct Layout {
|
||||
pub force_redraw: bool, // Redraw elements on screen.
|
||||
pub force_recalc: Arc<AtomicBool>, // Recalculate position of elements.
|
||||
pub plain: bool, // Plain style clock.
|
||||
pub width: u16,
|
||||
pub height: u16,
|
||||
clock_width: u16,
|
||||
|
@ -30,12 +28,11 @@ pub struct Layout {
|
|||
}
|
||||
|
||||
impl Layout {
|
||||
pub fn new(config: &Config) -> Layout {
|
||||
pub fn new(sigwinch: Arc<AtomicBool>) -> Layout {
|
||||
Layout {
|
||||
force_redraw: true,
|
||||
// May be set by signal handler (SIGWINCH).
|
||||
force_recalc: Arc::new(AtomicBool::new(true)),
|
||||
plain: config.plain,
|
||||
force_recalc: sigwinch,
|
||||
width: 0,
|
||||
height: 0,
|
||||
clock_width: 0,
|
||||
|
|
12
src/lib.rs
12
src/lib.rs
|
@ -18,7 +18,7 @@ use termion::raw::{IntoRawMode, RawTerminal};
|
|||
use termion::event::Key;
|
||||
use termion::input::TermRead;
|
||||
use buffer::Buffer;
|
||||
use clock::Clock;
|
||||
use clock::{Clock, font};
|
||||
use layout::Layout;
|
||||
use alarm::{Countdown, exec_command};
|
||||
pub use alarm::AlarmRoster;
|
||||
|
@ -41,8 +41,7 @@ pub fn run(
|
|||
spawned: &mut Option<process::Child>,
|
||||
) -> Result<(), std::io::Error>
|
||||
{
|
||||
let mut layout = Layout::new(&config);
|
||||
layout.force_recalc = sigwinch;
|
||||
let mut layout = Layout::new(sigwinch);
|
||||
// Initialise roster_width.
|
||||
layout.set_roster_width(alarm_roster.width());
|
||||
let mut clock = Clock::new(&config);
|
||||
|
@ -336,8 +335,8 @@ pub fn run(
|
|||
}
|
||||
|
||||
pub struct Config {
|
||||
plain: bool,
|
||||
quit: bool,
|
||||
font: &'static font::Font,
|
||||
command: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
|
@ -347,8 +346,8 @@ impl Config {
|
|||
-> Result<Config, String>
|
||||
{
|
||||
let mut config = Config {
|
||||
plain: false,
|
||||
quit: false,
|
||||
font: &font::NORMAL,
|
||||
command: None,
|
||||
};
|
||||
let mut iter = args.skip(1);
|
||||
|
@ -365,7 +364,8 @@ impl Config {
|
|||
println!("{} {}", NAME, VERSION);
|
||||
process::exit(0);
|
||||
},
|
||||
"-p" | "--plain" => config.plain = true,
|
||||
"-p" | "--plain" => config.font = &font::PLAIN,
|
||||
"-f" | "--fancy" => config.font = &font::CHROME,
|
||||
"-q" | "--quit" => config.quit = true,
|
||||
"-e" | "--exec" => {
|
||||
if let Some(e) = iter.next() {
|
||||
|
|
Loading…
Reference in a new issue