Skip to content

Commit

Permalink
print beats better
Browse files Browse the repository at this point in the history
  • Loading branch information
ahdinosaur committed May 26, 2018
1 parent bea4354 commit 93051e5
Showing 1 changed file with 29 additions and 20 deletions.
49 changes: 29 additions & 20 deletions src/interface.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
extern crate ncurses;

use ncurses;
use ncurses::{WchResult};
use std::sync::mpsc::{channel, Sender};
use std::thread::spawn;
Expand Down Expand Up @@ -86,8 +85,6 @@ impl Terminal {
Message::Time(time) => {
ncurses::clear();
ncurses::mv(0, 0);
print_beat(time);
print_bar(time);
print_time(time);
print_signature(signature);
print_tempo(tempo);
Expand All @@ -108,30 +105,42 @@ impl Terminal {
}
}

pub fn print_beat (time: clock::Time) {
if time.is_first_tick() {
if time.is_first_beat() {
ncurses::printw("SUPER ");
}
pub fn print_time (time: clock::Time) {
ncurses::printw("ticks since beat: ");
let ticks_since_beat = time.ticks_since_beat();
ncurses::printw(format!("{}\n", ticks_since_beat).as_ref());
if ticks_since_beat.to_integer() == 0 {
ncurses::printw("BEAT");
} else {
for i in 0..ticks_since_beat.to_integer() {
ncurses::printw("-");
}
}
ncurses::printw("\n");
}

pub fn print_bar (time: clock::Time) {
if time.is_first_bar() {
ncurses::printw("YAY YAY YAY");
ncurses::printw("beats since bar: ");
let beats_since_bar = time.beats_since_bar();
ncurses::printw(format!("{}\n", beats_since_bar).as_ref());
if beats_since_bar.to_integer() == 0 {
ncurses::printw("BAR");
} else {
for i in 0..beats_since_bar.to_integer() {
ncurses::printw("X");
}
}
ncurses::printw("\n");
}

pub fn print_time (time: clock::Time) {
ncurses::printw("ticks since beat: ");
ncurses::printw(format!("{}\n", time.ticks_since_beat()).as_ref());
ncurses::printw("beats since bar: ");
ncurses::printw(format!("{}\n", time.beats_since_bar()).as_ref());
ncurses::printw("bars since loop: ");
ncurses::printw(format!("{}\n", time.bars_since_loop()).as_ref());
let bars_since_loop = time.bars_since_loop();
ncurses::printw(format!("{}\n", bars_since_loop).as_ref());
if bars_since_loop.to_integer() == 0 {
ncurses::printw("LOOP");
} else {
for i in 0..bars_since_loop.to_integer() {
ncurses::printw("&");
}
}
ncurses::printw("\n");
}

pub fn print_signature (signature: clock::Signature) {
Expand Down

0 comments on commit 93051e5

Please sign in to comment.