Skip to content

Commit

Permalink
Simplify canvas bounds checking
Browse files Browse the repository at this point in the history
  • Loading branch information
newsch committed May 29, 2019
1 parent 991d04f commit 6af4ea6
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,13 +321,8 @@ void front_setcharcursor(char ch) {

void redraw_canvas_win() {
// find max ranges to draw canvas
int max_x = view_max_x;
int max_y = view_max_y;

if (max_x >= view->canvas->num_cols - view->x)
(max_x = view->canvas->num_cols - view->x);
if (max_y >= view->canvas->num_rows - view->y)
(max_y = view->canvas->num_rows - view->y);
int max_x = min(view_max_x, view->canvas->num_cols - view->x);
int max_y = min(view_max_y, view->canvas->num_rows - view->y);

// draw canvas onto window
for (int x = 0; x < max_x; x++) {
Expand Down

0 comments on commit 6af4ea6

Please sign in to comment.