1
1

tweaks: improve a comment, and reshuffle two functions plus some lines

Этот коммит содержится в:
Benno Schulenberg 2022-07-24 11:51:56 +02:00
родитель d4a1dbd4a9
Коммит 05eaa0f0d7
11 изменённых файлов: 67 добавлений и 63 удалений

Просмотреть файл

@ -720,8 +720,8 @@ char *browse_in(const char *inpath)
}
#ifdef ENABLE_OPERATINGDIR
/* If the resulting path isn't in the operating directory, use
* the operating directory instead. */
/* If the resulting path isn't in the operating directory,
* use the operating directory instead. */
if (outside_of_confinement(path, FALSE))
path = mallocstrcpy(path, operating_dir);
#endif

Просмотреть файл

@ -574,13 +574,14 @@ void redecorate_after_switch(void)
/* Prevent a possible Shift selection from getting cancelled. */
shift_held = TRUE;
/* If the switched-to buffer gave an error during opening, show the message
* once; otherwise, indicate on the status bar which file we switched to. */
if (openfile->errormessage) {
statusline(ALERT, openfile->errormessage);
free(openfile->errormessage);
openfile->errormessage = NULL;
} else
/* Indicate on the status bar where we switched to. */
mention_name_and_linecount();
mention_name_and_linecount();
}
/* Switch to the previous entry in the circular list of buffers. */

Просмотреть файл

@ -317,10 +317,10 @@ void help_init(void)
/* Hard-wrap the concatenated help text, and write it into a new buffer. */
void wrap_help_text_into_buffer(void)
{
size_t sum = 0;
/* Avoid overtight and overwide paragraphs in the introductory text. */
size_t wrapping_point = ((COLS < 40) ? 40 : (COLS > 74) ? 74 : COLS) - thebar;
const char *ptr = start_of_body;
size_t sum = 0;
make_new_buffer();

Просмотреть файл

@ -98,8 +98,8 @@ size_t proper_x(linestruct *line, size_t *leftedge, bool forward,
* the middle of a tab that crosses a row boundary. */
void set_proper_index_and_pww(size_t *leftedge, size_t target, bool forward)
{
bool shifted = FALSE;
size_t was_edge = *leftedge;
bool shifted = FALSE;
openfile->current_x = proper_x(openfile->current, leftedge, forward,
actual_last_column(*leftedge, target), &shifted);

Просмотреть файл

@ -358,9 +358,9 @@ void emergency_save(const char *filename)
* that were modified. */
void die(const char *msg, ...)
{
va_list ap;
openfilestruct *firstone = openfile;
static int stabs = 0;
va_list ap;
/* When dying for a second time, just give up. */
if (++stabs > 1)

Просмотреть файл

@ -41,6 +41,33 @@ void do_statusbar_end(void)
}
#ifndef NANO_TINY
/* Move to the previous word in the answer. */
void do_statusbar_prev_word(void)
{
bool seen_a_word = FALSE, step_forward = FALSE;
/* Move backward until we pass over the start of a word. */
while (typing_x != 0) {
typing_x = step_left(answer, typing_x);
if (is_word_char(answer + typing_x, FALSE))
seen_a_word = TRUE;
#ifdef ENABLE_UTF8
else if (is_zerowidth(answer + typing_x))
; /* skip */
#endif
else if (seen_a_word) {
/* This is space now: we've overshot the start of the word. */
step_forward = TRUE;
break;
}
}
if (step_forward)
/* Move one character forward again to sit on the start of the word. */
typing_x = step_right(answer, typing_x);
}
/* Move to the next word in the answer. */
void do_statusbar_next_word(void)
{
@ -78,33 +105,6 @@ void do_statusbar_next_word(void)
}
}
}
/* Move to the previous word in the answer. */
void do_statusbar_prev_word(void)
{
bool seen_a_word = FALSE, step_forward = FALSE;
/* Move backward until we pass over the start of a word. */
while (typing_x != 0) {
typing_x = step_left(answer, typing_x);
if (is_word_char(answer + typing_x, FALSE))
seen_a_word = TRUE;
#ifdef ENABLE_UTF8
else if (is_zerowidth(answer + typing_x))
; /* skip */
#endif
else if (seen_a_word) {
/* This is space now: we've overshot the start of the word. */
step_forward = TRUE;
break;
}
}
if (step_forward)
/* Move one character forward again to sit on the start of the word. */
typing_x = step_right(answer, typing_x);
}
#endif /* !NANO_TINY */
/* Move left one character in the answer. */
@ -131,6 +131,17 @@ void do_statusbar_right(void)
}
}
/* Backspace over one character in the answer. */
void do_statusbar_backspace(void)
{
if (typing_x > 0) {
size_t was_x = typing_x;
typing_x = step_left(answer, typing_x);
memmove(answer + typing_x, answer + was_x, strlen(answer) - was_x + 1);
}
}
/* Delete one character in the answer. */
void do_statusbar_delete(void)
{
@ -146,17 +157,6 @@ void do_statusbar_delete(void)
}
}
/* Backspace over one character in the answer. */
void do_statusbar_backspace(void)
{
if (typing_x > 0) {
size_t was_x = typing_x;
typing_x = step_left(answer, typing_x);
memmove(answer + typing_x, answer + was_x, strlen(answer) - was_x + 1);
}
}
/* Zap the part of the answer after the cursor, or the whole answer. */
void lop_the_answer(void)
{
@ -595,10 +595,10 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
int do_prompt(int menu, const char *provided, linestruct **history_list,
void (*refresh_func)(void), const char *msg, ...)
{
va_list ap;
int retval;
functionptrtype func = NULL;
bool listed = FALSE;
va_list ap;
int retval;
/* Save a possible current status-bar x position and prompt. */
size_t was_typing_x = typing_x;
char *saved_prompt = prompt;

Просмотреть файл

@ -897,7 +897,7 @@ bool is_good_file(char *file)
#ifdef ENABLE_COLOR
/* Partially parse the syntaxes in the given file, or (when syntax
* is not NULL) fully parse one specific syntax from the file . */
* is not NULL) fully parse one specific syntax from the file. */
void parse_one_include(char *file, syntaxtype *syntax)
{
char *was_nanorc = nanorc;

Просмотреть файл

@ -446,8 +446,8 @@ void go_looking(void)
* text in the passed string only when create is TRUE. */
int replace_regexp(char *string, bool create)
{
const char *c = answer;
size_t replacement_size = 0;
const char *c = answer;
/* Iterate through the replacement text to handle subexpression
* replacement using \1, \2, \3, etc. */
@ -525,11 +525,11 @@ char *replace_line(const char *needle)
ssize_t do_replace_loop(const char *needle, bool whole_word_only,
const linestruct *real_current, size_t *real_current_x)
{
bool skipone = ISSET(BACKWARDS_SEARCH);
bool replaceall = FALSE;
int modus = REPLACING;
ssize_t numreplaced = -1;
size_t match_len;
bool replaceall = FALSE;
bool skipone = ISSET(BACKWARDS_SEARCH);
int modus = REPLACING;
#ifndef NANO_TINY
linestruct *was_mark = openfile->mark;
linestruct *top, *bot;

Просмотреть файл

@ -117,8 +117,8 @@ void indent_a_line(linestruct *line, char *indentation)
* depending on whether --tabstospaces is in effect. */
void do_indent(void)
{
char *indentation;
linestruct *top, *bot, *line;
char *indentation;
/* Use either all the marked lines or just the current line. */
get_range(&top, &bot);
@ -502,10 +502,11 @@ void redo_cut(undostruct *u)
void do_undo(void)
{
undostruct *u = openfile->current_undo;
linestruct *line = NULL, *intruder;
linestruct *oldcutbuffer;
char *data, *undidmsg = NULL;
linestruct *oldcutbuffer, *intruder;
linestruct *line = NULL;
size_t original_x, regain_from_x;
char *undidmsg = NULL;
char *data;
if (u == NULL) {
statusline(AHEM, _("Nothing to undo"));
@ -684,10 +685,12 @@ void do_undo(void)
/* Redo the last thing(s) we undid. */
void do_redo(void)
{
linestruct *line = NULL, *intruder;
char *data, *redidmsg = NULL;
bool suppress_modification = FALSE;
undostruct *u = openfile->undotop;
bool suppress_modification = FALSE;
linestruct *line = NULL;
linestruct *intruder;
char *redidmsg = NULL;
char *data;
if (u == NULL || u == openfile->current_undo) {
statusline(AHEM, _("Nothing to redo"));

Просмотреть файл

@ -130,9 +130,9 @@ bool parse_num(const char *string, ssize_t *result)
* *line and *column. Return FALSE on error, and TRUE otherwise. */
bool parse_line_column(const char *str, ssize_t *line, ssize_t *column)
{
bool retval;
char *firstpart;
const char *comma;
char *firstpart;
bool retval;
while (*str == ' ')
str++;

Просмотреть файл

@ -1620,7 +1620,7 @@ int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts)
}
#if NCURSES_MOUSE_VERSION >= 2
/* Handle "presses" of the fourth and fifth mouse buttons
* (upward and downward rolls of the mouse wheel) . */
* (upward and downward rolls of the mouse wheel). */
else if (event.bstate & (BUTTON4_PRESSED | BUTTON5_PRESSED)) {
if (in_footer)
/* Shift the coordinates to be relative to the bottom window. */
@ -2985,8 +2985,8 @@ bool less_than_a_screenful(size_t was_lineno, size_t was_leftedge)
/* Draw a scroll bar on the righthand side of the screen. */
void draw_scrollbar(void)
{
int totallines = openfile->filebot->lineno;
int fromline = openfile->edittop->lineno - 1;
int totallines = openfile->filebot->lineno;
int coveredlines = editwinrows;
if (ISSET(SOFTWRAP)) {