mirror of git://git.sv.gnu.org/nano.git
tweaks: rename another function, to be distinct and fitting
This commit is contained in:
parent
00410d83fc
commit
0b6889cbd8
|
@ -610,7 +610,7 @@ size_t help_line_len(const char *ptr)
|
|||
length = move_mbright(ptr, length);
|
||||
|
||||
/* If the entire line will just fit the screen, don't wrap it. */
|
||||
if (strnlenpt(ptr, length) <= wrapping_point + 1)
|
||||
if (wideness(ptr, length) <= wrapping_point + 1)
|
||||
return length;
|
||||
else if (wrap_location > 0)
|
||||
return wrap_location;
|
||||
|
|
|
@ -75,7 +75,7 @@ size_t proper_x(linestruct *line, size_t *leftedge, bool forward,
|
|||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(SOFTWRAP) && line->data[index] == '\t' &&
|
||||
((forward && strnlenpt(line->data, index) < *leftedge) ||
|
||||
((forward && wideness(line->data, index) < *leftedge) ||
|
||||
(!forward && column / tabsize == (*leftedge - 1) / tabsize &&
|
||||
column / tabsize < (*leftedge + editwincols - 1) / tabsize))) {
|
||||
index++;
|
||||
|
@ -85,7 +85,7 @@ size_t proper_x(linestruct *line, size_t *leftedge, bool forward,
|
|||
}
|
||||
|
||||
if (ISSET(SOFTWRAP))
|
||||
*leftedge = leftedge_for(strnlenpt(line->data, index), line);
|
||||
*leftedge = leftedge_for(wideness(line->data, index), line);
|
||||
#endif
|
||||
|
||||
return index;
|
||||
|
|
|
@ -43,7 +43,7 @@ int do_statusbar_mouse(void)
|
|||
if (click_row == 0 && click_col >= start_col)
|
||||
typing_x = actual_x(answer,
|
||||
get_statusbar_page_start(start_col, start_col +
|
||||
strnlenpt(answer, typing_x)) + click_col - start_col);
|
||||
wideness(answer, typing_x)) + click_col - start_col);
|
||||
}
|
||||
|
||||
return retval;
|
||||
|
@ -389,7 +389,7 @@ void draw_the_promptbar(void)
|
|||
size_t the_page, end_page, column;
|
||||
char *expanded;
|
||||
|
||||
the_page = get_statusbar_page_start(base, base + strnlenpt(answer, typing_x));
|
||||
the_page = get_statusbar_page_start(base, base + wideness(answer, typing_x));
|
||||
end_page = get_statusbar_page_start(base, base + breadth(answer) - 1);
|
||||
|
||||
/* Color the promptbar over its full width. */
|
||||
|
@ -414,7 +414,7 @@ void draw_the_promptbar(void)
|
|||
wrefresh(bottomwin);
|
||||
|
||||
/* Place the cursor at the right spot. */
|
||||
column = base + strnlenpt(answer, typing_x);
|
||||
column = base + wideness(answer, typing_x);
|
||||
wmove(bottomwin, 0, column - get_statusbar_page_start(base, column));
|
||||
wnoutrefresh(bottomwin);
|
||||
}
|
||||
|
|
|
@ -580,7 +580,7 @@ char *free_and_assign(char *dest, char *src);
|
|||
size_t get_page_start(size_t column);
|
||||
size_t xplustabs(void);
|
||||
size_t actual_x(const char *text, size_t column);
|
||||
size_t strnlenpt(const char *text, size_t maxlen);
|
||||
size_t wideness(const char *text, size_t maxlen);
|
||||
size_t breadth(const char *text);
|
||||
void new_magicline(void);
|
||||
#if !defined(NANO_TINY) || defined(ENABLE_HELP)
|
||||
|
|
|
@ -389,7 +389,7 @@ void do_findnext(void)
|
|||
void not_found_msg(const char *str)
|
||||
{
|
||||
char *disp = display_string(str, 0, (COLS / 2) + 1, FALSE, FALSE);
|
||||
size_t numchars = actual_x(disp, strnlenpt(disp, COLS / 2));
|
||||
size_t numchars = actual_x(disp, wideness(disp, COLS / 2));
|
||||
|
||||
statusline(HUSH, _("\"%.*s%s\" not found"), numchars, disp,
|
||||
(disp[numchars] == '\0') ? "" : "...");
|
||||
|
@ -577,7 +577,7 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
|||
if (!replaceall) {
|
||||
spotlighted = TRUE;
|
||||
light_from_col = xplustabs();
|
||||
light_to_col = strnlenpt(openfile->current->data,
|
||||
light_to_col = wideness(openfile->current->data,
|
||||
openfile->current_x + match_len);
|
||||
|
||||
/* Refresh the edit window, scrolling it if necessary. */
|
||||
|
|
|
@ -1841,7 +1841,7 @@ void rewrap_paragraph(linestruct **line, char *lead_string, size_t lead_len)
|
|||
|
||||
/* Find a point in the line where it can be broken. */
|
||||
break_pos = break_line((*line)->data + lead_len,
|
||||
wrap_at - strnlenpt((*line)->data, lead_len), FALSE);
|
||||
wrap_at - wideness((*line)->data, lead_len), FALSE);
|
||||
|
||||
/* If we can't break the line, or don't need to, we're done. */
|
||||
if (break_pos == -1 || break_pos + lead_len == line_len)
|
||||
|
|
|
@ -368,7 +368,7 @@ size_t get_page_start(size_t column)
|
|||
* column position of the cursor. */
|
||||
size_t xplustabs(void)
|
||||
{
|
||||
return strnlenpt(openfile->current->data, openfile->current_x);
|
||||
return wideness(openfile->current->data, openfile->current_x);
|
||||
}
|
||||
|
||||
/* Return the index in text of the character that (when displayed) will
|
||||
|
@ -394,10 +394,9 @@ size_t actual_x(const char *text, size_t column)
|
|||
|
||||
/* A strnlen() with tabs and multicolumn characters factored in:
|
||||
* how many columns wide are the first maxlen bytes of text? */
|
||||
size_t strnlenpt(const char *text, size_t maxlen)
|
||||
size_t wideness(const char *text, size_t maxlen)
|
||||
{
|
||||
size_t width = 0;
|
||||
/* The screen display width to text[maxlen]. */
|
||||
|
||||
if (maxlen == 0)
|
||||
return 0;
|
||||
|
|
20
src/winio.c
20
src/winio.c
|
@ -1871,7 +1871,7 @@ char *display_string(const char *buf, size_t column, size_t span,
|
|||
{
|
||||
size_t start_index = actual_x(buf, column);
|
||||
/* The index of the first character that the caller wishes to show. */
|
||||
size_t start_col = strnlenpt(buf, start_index);
|
||||
size_t start_col = wideness(buf, start_index);
|
||||
/* The actual column where that first character starts. */
|
||||
char *converted;
|
||||
/* The expanded string we will return. */
|
||||
|
@ -2509,12 +2509,12 @@ void edit_draw(linestruct *fileptr, const char *converted,
|
|||
continue;
|
||||
|
||||
start_col = (match.rm_so <= from_x) ?
|
||||
0 : strnlenpt(fileptr->data,
|
||||
0 : wideness(fileptr->data,
|
||||
match.rm_so) - from_col;
|
||||
|
||||
thetext = converted + actual_x(converted, start_col);
|
||||
|
||||
paintlen = actual_x(thetext, strnlenpt(fileptr->data,
|
||||
paintlen = actual_x(thetext, wideness(fileptr->data,
|
||||
match.rm_eo) - from_col - start_col);
|
||||
|
||||
mvwaddnstr(edit, row, margin + start_col,
|
||||
|
@ -2613,7 +2613,7 @@ void edit_draw(linestruct *fileptr, const char *converted,
|
|||
|
||||
/* Only if it is visible, paint the part to be coloured. */
|
||||
if (endmatch.rm_eo > from_x) {
|
||||
paintlen = actual_x(converted, strnlenpt(fileptr->data,
|
||||
paintlen = actual_x(converted, wideness(fileptr->data,
|
||||
endmatch.rm_eo) - from_col);
|
||||
mvwaddnstr(edit, row, margin, converted, paintlen);
|
||||
}
|
||||
|
@ -2633,7 +2633,7 @@ void edit_draw(linestruct *fileptr, const char *converted,
|
|||
startmatch.rm_eo += index;
|
||||
|
||||
start_col = (startmatch.rm_so <= from_x) ?
|
||||
0 : strnlenpt(fileptr->data,
|
||||
0 : wideness(fileptr->data,
|
||||
startmatch.rm_so) - from_col;
|
||||
|
||||
thetext = converted + actual_x(converted, start_col);
|
||||
|
@ -2649,7 +2649,7 @@ void edit_draw(linestruct *fileptr, const char *converted,
|
|||
* it is more than zero characters long. */
|
||||
if (endmatch.rm_eo > from_x &&
|
||||
endmatch.rm_eo > startmatch.rm_so) {
|
||||
paintlen = actual_x(thetext, strnlenpt(fileptr->data,
|
||||
paintlen = actual_x(thetext, wideness(fileptr->data,
|
||||
endmatch.rm_eo) - from_col - start_col);
|
||||
|
||||
mvwaddnstr(edit, row, margin + start_col,
|
||||
|
@ -2702,7 +2702,7 @@ void edit_draw(linestruct *fileptr, const char *converted,
|
|||
|
||||
if (*(converted + target_x) != '\0') {
|
||||
charlen = parse_mbchar(converted + target_x, striped_char, NULL);
|
||||
target_column = strnlenpt(converted, target_x);
|
||||
target_column = wideness(converted, target_x);
|
||||
} else if (target_column + 1 == editwincols) {
|
||||
/* Defeat a VTE bug -- see https://sv.gnu.org/bugs/?55896. */
|
||||
#ifdef ENABLE_UTF8
|
||||
|
@ -2749,7 +2749,7 @@ void edit_draw(linestruct *fileptr, const char *converted,
|
|||
/* Only paint if the marked part of the line is on this page. */
|
||||
if (top_x < till_x && bot_x > from_x) {
|
||||
/* Compute on which screen column to start painting. */
|
||||
start_col = strnlenpt(fileptr->data, top_x) - from_col;
|
||||
start_col = wideness(fileptr->data, top_x) - from_col;
|
||||
|
||||
if (start_col < 0)
|
||||
start_col = 0;
|
||||
|
@ -2759,7 +2759,7 @@ void edit_draw(linestruct *fileptr, const char *converted,
|
|||
/* If the end of the mark is onscreen, compute how many
|
||||
* characters to paint. Otherwise, just paint all. */
|
||||
if (bot_x < till_x) {
|
||||
size_t end_col = strnlenpt(fileptr->data, bot_x) - from_col;
|
||||
size_t end_col = wideness(fileptr->data, bot_x) - from_col;
|
||||
paintlen = actual_x(thetext, end_col - start_col);
|
||||
}
|
||||
|
||||
|
@ -2797,7 +2797,7 @@ int update_line(linestruct *fileptr, size_t index)
|
|||
blank_row(edit, row, 0, COLS);
|
||||
|
||||
/* Next, find out from which column to start displaying the line. */
|
||||
from_col = get_page_start(strnlenpt(fileptr->data, index));
|
||||
from_col = get_page_start(wideness(fileptr->data, index));
|
||||
|
||||
/* Expand the line, replacing tabs with spaces, and control
|
||||
* characters with their displayed forms. */
|
||||
|
|
Loading…
Reference in New Issue