Skip to content

Commit

Permalink
fix(code): no more unnecessary comments
Browse files Browse the repository at this point in the history
  • Loading branch information
JeromeSchmied committed Mar 23, 2024
1 parent 830a169 commit 57dd807
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 50 deletions.
4 changes: 0 additions & 4 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,8 @@ impl App {

pub fn play_pause(&mut self, prev_poll_t: &mut Duration) {
if self.paused() {
// println!("Resuming: poll() = {:?}\r", prev_poll_t);
self.poll_t = *prev_poll_t;
} else {
// println!("Pausing...\r");
*prev_poll_t = self.poll_t;
self.poll_t = Duration::MAX;
}
Expand All @@ -79,7 +77,6 @@ impl App {
.checked_sub(self.poll_t.checked_div(div).unwrap_or(DEF_DUR))
.unwrap_or(DEF_DUR);
}
// println!("poll time is now: {:?}\r", self.poll_t());
}
pub fn slower(&mut self, big: bool) {
if !self.paused {
Expand All @@ -89,7 +86,6 @@ impl App {
.checked_add(self.poll_t.checked_div(div).unwrap_or(DEF_DUR))
.unwrap_or(DEF_DUR);
}
// println!("poll time is now: {:?}\r", self.poll_t());
}

pub fn next(&mut self) {
Expand Down
4 changes: 0 additions & 4 deletions src/kmaps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use crossterm::event::KeyCode;
pub const PLAY_PAUSE: KeyCode = KeyCode::Char(' ');

pub const SLOWER: KeyCode = KeyCode::Char('j');

pub const SLOWER_BIG: KeyCode = KeyCode::Char('J');

pub const FASTER: KeyCode = KeyCode::Char('k');
Expand All @@ -18,7 +17,4 @@ pub const RESET: KeyCode = KeyCode::Char('R');
pub const NEXT: KeyCode = KeyCode::Char('n');
pub const PREV: KeyCode = KeyCode::Char('p');

pub const BIGGER: KeyCode = KeyCode::Char('+');
pub const SMALLER: KeyCode = KeyCode::Char('-');

pub const HELP: KeyCode = KeyCode::Char('?');
21 changes: 1 addition & 20 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl Universe {
} else if ch == '_' || ch == ' ' || ch == '0' {
cells.push(Cell::Dead);
} else {
eprintln!("Can't do nothing with this character: {ch}");
eprintln!("can't do nothing with this character: {ch}");
}
}
}
Expand All @@ -98,8 +98,6 @@ impl Universe {
.filter(|cell| cell == &&Cell::Alive)
.count();

// println!("{}\r", &figur);

if wh < figur.height() || wh < figur.width() {
return Err(HandleError::TooBig);
}
Expand All @@ -112,7 +110,6 @@ impl Universe {
};

let (start_row, start_col) = ((wh - figur.height()) / 2, (wh - figur.width()) / 2);
// println!("\r");

let mut j = 0;
for row in start_row as usize..start_row as usize + figur.height() as usize {
Expand Down Expand Up @@ -185,22 +182,6 @@ impl Universe {
}
}

// impl fmt::Display for Universe {
// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// writeln!(f, "╭{}╮\r", "─".repeat(self.width as usize * 2))?;
// for line in self.cells.as_slice().chunks(self.width as usize) {
// write!(f, "│")?;
// for &cell in line {
// let symbol = if cell == Cell::Dead { ' ' } else { '◼' }; // ◻
// write!(f, "{symbol} ")?;
// }
// writeln!(f, "│\r")?;
// }
// writeln!(f, "╰{}╯\r", "─".repeat(self.width as usize * 2))?;
// Ok(())
// }
// }

impl fmt::Display for Universe {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
for line in self.cells.as_slice().chunks(self.width as usize) {
Expand Down
23 changes: 1 addition & 22 deletions src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ pub fn ui(f: &mut Frame, app: &App) {
.constraints([Constraint::Min(0), Constraint::Length(1)])
.split(f.size());

// let current_shape = shapes::get(app.wh, app.i()).unwrap();

let main_chunks = Layout::default()
.direction(Direction::Horizontal)
.constraints([Constraint::Percentage(50)])
Expand All @@ -32,12 +30,6 @@ pub fn ui(f: &mut Frame, app: &App) {
.title("Conway's Game of Life");
let universe = Paragraph::new(app.universe.to_string()).block(cgol);

// let shape = Paragraph::new(current_shape.to_string()).block(
// Block::default()
// .borders(Borders::ALL)
// .border_type(BorderType::Rounded),
// );
// f.render_widget(universe, Rect::new(0, 0, app.wh() * 2 + 2, app.wh() + 2));
f.render_widget(
universe,
Rect::new(
Expand All @@ -47,7 +39,6 @@ pub fn ui(f: &mut Frame, app: &App) {
main_chunks[0].height - 1,
),
);
// f.render_widget(shape, main_chunks[1]);

let footer = Layout::default()
.direction(Direction::Horizontal)
Expand All @@ -58,7 +49,6 @@ pub fn ui(f: &mut Frame, app: &App) {
"[q]uit, [r]estart, [R]eset, [n]ext, [p]revious, play[ ]pause, 'k': faster, 'j': slower",
Style::default().fg(Color::Yellow),
);
// let key_notes_footer = Paragraph::new(current_keys_hint);

let stat_style = Style::default().fg(Color::LightBlue);
let poll_t = Span::styled(
Expand All @@ -72,21 +62,10 @@ pub fn ui(f: &mut Frame, app: &App) {
),
stat_style,
);
// let area_size = Span::styled(format!("Area size: {}", f.size()), stat_style);
// let wh = Span::styled(format!("wh: {:?}", app.wh()), stat_style);

let div = Span::styled(" | ", Style::default().fg(Color::White));
let current_stats = vec![
current_keys_hint,
div.clone(),
poll_t,
// div.clone(),
// area_size,
// div.clone(),
// wh,
];
let current_stats = vec![current_keys_hint, div.clone(), poll_t];
let footer_data = Line::from(current_stats);

// f.render_widget(key_notes_footer, footer[0]);
f.render_widget(footer_data, footer[0]);
}

0 comments on commit 57dd807

Please sign in to comment.