tweaks: use a boolean instead of an enumeration of two values

master
Benno Schulenberg 2020-12-19 16:40:21 +01:00
parent 208146f2f2
commit 96e4fec31c
4 changed files with 7 additions and 10 deletions

View File

@ -257,10 +257,6 @@ typedef enum {
OVERWRITE, APPEND, PREPEND
} kind_of_writing_type;
typedef enum {
SOFTMARK, HARDMARK
} mark_type;
typedef enum {
CENTERING, FLOWING, STATIONARY
} update_type;
@ -547,8 +543,8 @@ typedef struct openfilestruct {
/* The line in the file where the mark is set; NULL if not set. */
size_t mark_x;
/* The mark's x position in the above line. */
mark_type kind_of_mark;
/* Whether it is a soft (with Shift) or a hard mark. */
bool softmark;
/* Whether a marked region was made by holding Shift. */
format_type fmt;
/* The file's format -- Unix or DOS or Mac. */
char *lock_filename;

View File

@ -81,6 +81,7 @@ void make_new_buffer(void)
#endif
#ifndef NANO_TINY
openfile->mark = NULL;
openfile->softmark = FALSE;
openfile->fmt = NIX_FILE;

View File

@ -1528,7 +1528,7 @@ void process_a_keystroke(void)
print_view_warning();
else {
#ifndef NANO_TINY
if (openfile->mark && openfile->kind_of_mark == SOFTMARK) {
if (openfile->mark && openfile->softmark) {
openfile->mark = NULL;
refresh_needed = TRUE;
}
@ -1602,7 +1602,7 @@ void process_a_keystroke(void)
if (shift_held && !openfile->mark) {
openfile->mark = openfile->current;
openfile->mark_x = openfile->current_x;
openfile->kind_of_mark = SOFTMARK;
openfile->softmark = TRUE;
}
#endif
@ -1614,7 +1614,7 @@ void process_a_keystroke(void)
* discard a soft mark. And when the marked region covers a
* different set of lines, reset the "last line too" flag. */
if (openfile->mark) {
if (!shift_held && openfile->kind_of_mark == SOFTMARK &&
if (!shift_held && openfile->softmark &&
(openfile->current != was_current ||
openfile->current_x != was_x ||
wanted_to_move(shortcut->func))) {

View File

@ -50,8 +50,8 @@ void do_mark(void)
if (!openfile->mark) {
openfile->mark = openfile->current;
openfile->mark_x = openfile->current_x;
openfile->softmark = FALSE;
statusbar(_("Mark Set"));
openfile->kind_of_mark = HARDMARK;
} else {
openfile->mark = NULL;
statusbar(_("Mark Unset"));