Skip to content

Commit

Permalink
Replace 'printw' calls by 'addstr' calls
Browse files Browse the repository at this point in the history
Because the usage of 'printw' is deprecated.
Also see: jeaye/ncurses-rs#172
  • Loading branch information
Stef Gijsberts committed May 7, 2021
1 parent 8544c82 commit 368527c
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 38 deletions.
8 changes: 4 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn main() {
let mode = args.next().unwrap();

initscr();
printw("Welcome to chess trainer!\n");
addstr("Welcome to chess trainer!\n");

match &mode[..] {
"oddness" => {
Expand Down Expand Up @@ -60,10 +60,10 @@ fn cycle<State: ModeState, Prop: Property<State> + PartialEq>(mut state: State)
let mut correct_answers = 0;

loop {
printw(&format!("{}", state));
addstr(&format!("{}", state));

let location = state.next();
printw(&format!("{}? [", location));
addstr(&format!("{}? [", location));

let answer = Prop::calculate(&state, &location);

Expand Down Expand Up @@ -94,7 +94,7 @@ fn cycle<State: ModeState, Prop: Property<State> + PartialEq>(mut state: State)
);
let ratio = format!("{:.*}", 2, correct_answers as f32 / total_answers as f32);

printw(&format!(
addstr(&format!(
"]: {} Time of thinking: {}ms. Speed: {} answers/sec. Success ratio: {}\n",
result, time, speed, ratio
));
Expand Down
12 changes: 6 additions & 6 deletions src/mode/property/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ impl Property<Empty> for Color {
}

fn print_help() {
printw("==========================================================\n");
printw(" COLOR GUESSING MODE\n");
printw("----------------------------------------------------------\n");
printw("Type [w] or [4] if you think specified position is [white]\n");
printw("and type [b] or [6] if you think the position is [black].\n");
printw("==========================================================\n");
addstr("==========================================================\n");
addstr(" COLOR GUESSING MODE\n");
addstr("----------------------------------------------------------\n");
addstr("Type [w] or [4] if you think specified position is [white]\n");
addstr("and type [b] or [6] if you think the position is [black].\n");
addstr("==========================================================\n");
}
}
12 changes: 6 additions & 6 deletions src/mode/property/column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ impl Property<Empty> for ColumnOddness {
}

fn print_help() {
printw("===================================================================\n");
printw(" COLUMN ODDNESS GUESSING MODE\n");
printw("-------------------------------------------------------------------\n");
printw("Type [e] or [2] if you think column of specified position is [even]\n");
printw("and type [o] or [1] if you think the column is [odd].\n");
printw("===================================================================\n");
addstr("===================================================================\n");
addstr(" COLUMN ODDNESS GUESSING MODE\n");
addstr("-------------------------------------------------------------------\n");
addstr("Type [e] or [2] if you think column of specified position is [even]\n");
addstr("and type [o] or [1] if you think the column is [odd].\n");
addstr("===================================================================\n");
}
}
12 changes: 6 additions & 6 deletions src/mode/property/height.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ impl Property<Empty> for Height {
}

fn print_help() {
printw("==========================================================\n");
printw(" HEIGHT GUESSING MODE\n");
printw("----------------------------------------------------------\n");
printw("Type [0], [1], [2] or [3] if you think specified position\n");
printw("belongs to outermost circle, outer or inner one or center.\n");
printw("==========================================================\n");
addstr("==========================================================\n");
addstr(" HEIGHT GUESSING MODE\n");
addstr("----------------------------------------------------------\n");
addstr("Type [0], [1], [2] or [3] if you think specified position\n");
addstr("belongs to outermost circle, outer or inner one or center.\n");
addstr("==========================================================\n");
}
}
12 changes: 6 additions & 6 deletions src/mode/property/knight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ impl Property<PreviousLocation> for KnightDistance {
}

fn print_help() {
printw("=========================================================\n");
printw(" KNIGHT DISTANCE GUESSING MODE\n");
printw("---------------------------------------------------------\n");
printw("Type [1], [2], [3] or [4] if you think this number equals\n");
printw(" to amount of knight's moves from 1st to 2nd position.\n");
printw("=========================================================\n");
addstr("=========================================================\n");
addstr(" KNIGHT DISTANCE GUESSING MODE\n");
addstr("---------------------------------------------------------\n");
addstr("Type [1], [2], [3] or [4] if you think this number equals\n");
addstr(" to amount of knight's moves from 1st to 2nd position.\n");
addstr("=========================================================\n");
}
}

Expand Down
20 changes: 10 additions & 10 deletions src/mode/property/quadrant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ impl Property<SideContainer> for Quadrant {
}

fn print_help() {
printw("==========================================================\n");
printw(" QUADRANT GUESSING MODE\n");
printw("----------------------------------------------------------\n");
printw(" Use NUM-section on your keyboard:\n");
printw(" ---------------------------------\n");
printw(" [1] means [left-bottom]\n");
printw(" [3] means [right-bottom]\n");
printw(" [7] means [left-top]\n");
printw(" [9] means [right-top]\n");
printw("==========================================================\n");
addstr("==========================================================\n");
addstr(" QUADRANT GUESSING MODE\n");
addstr("----------------------------------------------------------\n");
addstr(" Use NUM-section on your keyboard:\n");
addstr(" ---------------------------------\n");
addstr(" [1] means [left-bottom]\n");
addstr(" [3] means [right-bottom]\n");
addstr(" [7] means [left-top]\n");
addstr(" [9] means [right-top]\n");
addstr("==========================================================\n");
}
}

Expand Down

0 comments on commit 368527c

Please sign in to comment.