From 21ffa883f76c5850e2a54929467dff980f1d9ab1 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Thu, 31 Aug 2017 22:14:06 +0200 Subject: [PATCH] tweaks: use mnemonic constants instead of TRUE and FALSE And use these constants in another context too. --- src/files.c | 8 ++++---- src/move.c | 4 ++-- src/nano.h | 7 +++---- src/proto.h | 2 +- src/winio.c | 8 ++++---- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/files.c b/src/files.c index 9e2b784f..6a6bb1ca 100644 --- a/src/files.c +++ b/src/files.c @@ -639,16 +639,16 @@ void switch_to_adjacent_buffer(bool to_next) #endif } -/* Switch to the previous entry in the openfile filebuffer. */ +/* Switch to the previous entry in the list of open files. */ void switch_to_prev_buffer(void) { - switch_to_adjacent_buffer(FALSE); + switch_to_adjacent_buffer(BACKWARD); } -/* Switch to the next entry in the openfile filebuffer. */ +/* Switch to the next entry in the list of open files. */ void switch_to_next_buffer(void) { - switch_to_adjacent_buffer(TRUE); + switch_to_adjacent_buffer(FORWARD); } /* Delete an entry from the circular list of open files, and switch to the diff --git a/src/move.c b/src/move.c index 21cd2221..59a969f5 100644 --- a/src/move.c +++ b/src/move.c @@ -502,7 +502,7 @@ void do_up(bool scroll_only) set_proper_index_and_pww(&leftedge, target_column, FALSE); if (scroll_only) - edit_scroll(UPWARD, 1); + edit_scroll(BACKWARD, 1); edit_redraw(was_current, FLOWING); @@ -526,7 +526,7 @@ void do_down(bool scroll_only) set_proper_index_and_pww(&leftedge, target_column, TRUE); if (scroll_only) - edit_scroll(DOWNWARD, 1); + edit_scroll(FORWARD, 1); edit_redraw(was_current, FLOWING); diff --git a/src/nano.h b/src/nano.h index 28c688c9..1a77097a 100644 --- a/src/nano.h +++ b/src/nano.h @@ -132,6 +132,9 @@ #define DISABLE_WRAPJUSTIFY 1 #endif +#define BACKWARD FALSE +#define FORWARD TRUE + /* Enumeration types. */ typedef enum { NIX_FILE, DOS_FILE, MAC_FILE @@ -149,10 +152,6 @@ typedef enum { SOFTMARK, HARDMARK } mark_type; -typedef enum { - UPWARD, DOWNWARD -} scroll_dir; - typedef enum { CENTERING, FLOWING, STATIONARY } update_type; diff --git a/src/proto.h b/src/proto.h index 452eeb5c..8ee4eb0e 100644 --- a/src/proto.h +++ b/src/proto.h @@ -663,7 +663,7 @@ bool line_needs_update(const size_t old_column, const size_t new_column); int go_back_chunks(int nrows, filestruct **line, size_t *leftedge); int go_forward_chunks(int nrows, filestruct **line, size_t *leftedge); bool less_than_a_screenful(size_t was_lineno, size_t was_leftedge); -void edit_scroll(scroll_dir direction, int nrows); +void edit_scroll(bool direction, int nrows); #ifndef NANO_TINY size_t get_softwrap_breakpoint(const char *text, size_t leftedge, bool *end_of_line); diff --git a/src/winio.c b/src/winio.c index 4fe9db06..76cc4cc8 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2902,7 +2902,7 @@ bool less_than_a_screenful(size_t was_lineno, size_t was_leftedge) /* Scroll the edit window in the given direction and the given number of rows, * and draw new lines on the blank lines left after the scrolling. */ -void edit_scroll(scroll_dir direction, int nrows) +void edit_scroll(bool direction, int nrows) { filestruct *line; size_t leftedge; @@ -2912,7 +2912,7 @@ void edit_scroll(scroll_dir direction, int nrows) /* Move the top line of the edit window the requested number of rows up or * down, and reduce the number of rows with the amount we couldn't move. */ - if (direction == UPWARD) + if (direction == BACKWARD) nrows -= go_back_chunks(nrows, &openfile->edittop, &openfile->firstcolumn); else nrows -= go_forward_chunks(nrows, &openfile->edittop, &openfile->firstcolumn); @@ -2935,7 +2935,7 @@ void edit_scroll(scroll_dir direction, int nrows) /* Scroll the text of the edit window a number of rows up or down. */ scrollok(edit, TRUE); - wscrl(edit, (direction == UPWARD) ? -nrows : nrows); + wscrl(edit, (direction == BACKWARD) ? -nrows : nrows); scrollok(edit, FALSE); /* Part 2: nrows is now the number of rows in the scrolled region of the @@ -2951,7 +2951,7 @@ void edit_scroll(scroll_dir direction, int nrows) leftedge = openfile->firstcolumn; /* If we scrolled forward, move down to the start of the blank region. */ - if (direction == DOWNWARD) + if (direction == FORWARD) go_forward_chunks(editwinrows - nrows, &line, &leftedge); #ifndef NANO_TINY