mirror of git://git.sv.gnu.org/nano.git
tweaks: rename a function, to be distinct and fitting
It was hard to remember that the "pt" stood for "plus tabs", and the "len" seemed to say it was about number of bytes instead of columns.
This commit is contained in:
parent
fcad442d80
commit
00410d83fc
|
@ -400,7 +400,7 @@ void read_the_list(const char *path, DIR *dir)
|
|||
|
||||
/* Find the length of the longest filename in the current folder. */
|
||||
while ((nextdir = readdir(dir)) != NULL) {
|
||||
size_t name_len = strlenpt(nextdir->d_name);
|
||||
size_t name_len = breadth(nextdir->d_name);
|
||||
|
||||
if (name_len > longest)
|
||||
longest = name_len;
|
||||
|
@ -518,7 +518,7 @@ void browser_refresh(void)
|
|||
struct stat st;
|
||||
const char *thename = tail(filelist[i]);
|
||||
/* The filename we display, minus the path. */
|
||||
size_t namelen = strlenpt(thename);
|
||||
size_t namelen = breadth(thename);
|
||||
/* The length of the filename in columns. */
|
||||
size_t infolen;
|
||||
/* The length of the file information in columns. */
|
||||
|
@ -598,7 +598,7 @@ void browser_refresh(void)
|
|||
}
|
||||
|
||||
/* Make sure info takes up no more than infomaxlen columns. */
|
||||
infolen = strlenpt(info);
|
||||
infolen = breadth(info);
|
||||
if (infolen > infomaxlen) {
|
||||
info[actual_x(info, infomaxlen)] = '\0';
|
||||
infolen = infomaxlen;
|
||||
|
@ -672,7 +672,7 @@ int filesearch_init(bool forwards)
|
|||
thedefault = charalloc(strlen(disp) + 7);
|
||||
/* We use (COLS / 3) here because we need to see more on the line. */
|
||||
sprintf(thedefault, " [%s%s]", disp,
|
||||
(strlenpt(last_search) > COLS / 3) ? "..." : "");
|
||||
(breadth(last_search) > COLS / 3) ? "..." : "");
|
||||
free(disp);
|
||||
} else
|
||||
thedefault = mallocstrcpy(NULL, "");
|
||||
|
|
12
src/files.c
12
src/files.c
|
@ -355,13 +355,13 @@ int do_lockfile(const char *filename)
|
|||
|
||||
/* TRANSLATORS: The second %s is the name of the user, the third that of the editor. */
|
||||
question = _("File %s is being edited (by %s with %s, PID %s); continue?");
|
||||
room = COLS - strlenpt(question) + 7 - strlenpt(lockuser) -
|
||||
strlenpt(lockprog) - strlenpt(pidstring);
|
||||
room = COLS - breadth(question) + 7 - breadth(lockuser) -
|
||||
breadth(lockprog) - breadth(pidstring);
|
||||
if (room < 4)
|
||||
postedname = mallocstrcpy(NULL, "_");
|
||||
else if (room < strlenpt(filename)) {
|
||||
else if (room < breadth(filename)) {
|
||||
char *fragment = display_string(filename,
|
||||
strlenpt(filename) - room + 3, room, FALSE, FALSE);
|
||||
breadth(filename) - room + 3, room, FALSE, FALSE);
|
||||
postedname = charalloc(strlen(fragment) + 4);
|
||||
strcpy(postedname, "...");
|
||||
strcat(postedname, fragment);
|
||||
|
@ -2266,7 +2266,7 @@ int do_writeout(bool exiting, bool withprompt)
|
|||
if (name_exists) {
|
||||
char *question = _("File \"%s\" exists; OVERWRITE? ");
|
||||
char *name = display_string(answer, 0,
|
||||
COLS - strlenpt(question) + 1, FALSE, FALSE);
|
||||
COLS - breadth(question) + 1, FALSE, FALSE);
|
||||
char *message = charalloc(strlen(question) +
|
||||
strlen(name) + 1);
|
||||
|
||||
|
@ -2683,7 +2683,7 @@ char *input_tab(char *buf, bool allow_files, size_t *place,
|
|||
|
||||
/* Find the length of the longest among the choices. */
|
||||
for (match = 0; match < num_matches; match++) {
|
||||
size_t namelen = strlenpt(matches[match]);
|
||||
size_t namelen = breadth(matches[match]);
|
||||
|
||||
if (namelen > longest_name)
|
||||
longest_name = namelen;
|
||||
|
|
|
@ -741,13 +741,13 @@ void mouse_init(void)
|
|||
void print_opt(const char *shortflag, const char *longflag, const char *desc)
|
||||
{
|
||||
printf(" %s\t", shortflag);
|
||||
if (strlenpt(shortflag) < 8)
|
||||
if (breadth(shortflag) < 8)
|
||||
printf("\t");
|
||||
|
||||
printf("%s\t", longflag);
|
||||
if (strlenpt(longflag) < 8)
|
||||
if (breadth(longflag) < 8)
|
||||
printf("\t\t");
|
||||
else if (strlenpt(longflag) < 16)
|
||||
else if (breadth(longflag) < 16)
|
||||
printf("\t");
|
||||
|
||||
printf("%s\n", _(desc));
|
||||
|
|
|
@ -37,7 +37,7 @@ int do_statusbar_mouse(void)
|
|||
|
||||
/* We can click on the statusbar window text to move the cursor. */
|
||||
if (retval == 0 && wmouse_trafo(bottomwin, &click_row, &click_col, FALSE)) {
|
||||
size_t start_col = strlenpt(prompt) + 2;
|
||||
size_t start_col = breadth(prompt) + 2;
|
||||
|
||||
/* Move to where the click occurred. */
|
||||
if (click_row == 0 && click_col >= start_col)
|
||||
|
@ -385,12 +385,12 @@ void put_cursor_at_end_of_answer(void)
|
|||
/* Redraw the promptbar and place the cursor at the right spot. */
|
||||
void draw_the_promptbar(void)
|
||||
{
|
||||
size_t base = strlenpt(prompt) + 2;
|
||||
size_t base = breadth(prompt) + 2;
|
||||
size_t the_page, end_page, column;
|
||||
char *expanded;
|
||||
|
||||
the_page = get_statusbar_page_start(base, base + strnlenpt(answer, typing_x));
|
||||
end_page = get_statusbar_page_start(base, base + strlenpt(answer) - 1);
|
||||
end_page = get_statusbar_page_start(base, base + breadth(answer) - 1);
|
||||
|
||||
/* Color the promptbar over its full width. */
|
||||
wattron(bottomwin, interface_color_pair[TITLE_BAR]);
|
||||
|
@ -404,7 +404,7 @@ void draw_the_promptbar(void)
|
|||
waddstr(bottomwin, expanded);
|
||||
free(expanded);
|
||||
|
||||
if (base + strlenpt(answer) != COLS && the_page < end_page)
|
||||
if (base + breadth(answer) != COLS && the_page < end_page)
|
||||
mvwaddch(bottomwin, 0, COLS - 1, '>');
|
||||
|
||||
wattroff(bottomwin, interface_color_pair[TITLE_BAR]);
|
||||
|
|
|
@ -581,7 +581,7 @@ 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 strlenpt(const char *text);
|
||||
size_t breadth(const char *text);
|
||||
void new_magicline(void);
|
||||
#if !defined(NANO_TINY) || defined(ENABLE_HELP)
|
||||
void remove_magicline(void);
|
||||
|
|
|
@ -1135,7 +1135,7 @@ void parse_rcfile(FILE *rcstream, bool syntax_only)
|
|||
} else
|
||||
matchbrackets = option;
|
||||
} else if (strcasecmp(rcopts[i].name, "whitespace") == 0) {
|
||||
if (mbstrlen(option) != 2 || strlenpt(option) != 2) {
|
||||
if (mbstrlen(option) != 2 || breadth(option) != 2) {
|
||||
rcfile_error(N_("Two single-column characters required"));
|
||||
free(option);
|
||||
} else {
|
||||
|
|
|
@ -88,7 +88,7 @@ void search_init(bool replacing, bool keep_the_answer)
|
|||
thedefault = charalloc(strlen(disp) + 7);
|
||||
/* We use (COLS / 3) here because we need to see more on the line. */
|
||||
sprintf(thedefault, " [%s%s]", disp,
|
||||
(strlenpt(last_search) > COLS / 3) ? "..." : "");
|
||||
(breadth(last_search) > COLS / 3) ? "..." : "");
|
||||
free(disp);
|
||||
} else
|
||||
thedefault = mallocstrcpy(NULL, "");
|
||||
|
@ -810,7 +810,7 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
|
|||
|
||||
/* Take a negative column number to mean: from the end of the line. */
|
||||
if (column < 0)
|
||||
column = strlenpt(openfile->current->data) + column + 2;
|
||||
column = breadth(openfile->current->data) + column + 2;
|
||||
if (column < 1)
|
||||
column = 1;
|
||||
|
||||
|
@ -820,8 +820,8 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
|
|||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(SOFTWRAP) && openfile->placewewant / editwincols >
|
||||
strlenpt(openfile->current->data) / editwincols)
|
||||
openfile->placewewant = strlenpt(openfile->current->data);
|
||||
breadth(openfile->current->data) / editwincols)
|
||||
openfile->placewewant = breadth(openfile->current->data);
|
||||
#endif
|
||||
|
||||
/* When the position was manually given, center the target line. */
|
||||
|
|
|
@ -1456,7 +1456,7 @@ bool do_wrap(void)
|
|||
* line too long, then join the two lines, so that, after the line wrap,
|
||||
* the remainder will effectively have been prefixed to the next line. */
|
||||
if (openfile->spillage_line && openfile->spillage_line == line->next &&
|
||||
rest_length + strlenpt(line->next->data) <= wrap_at) {
|
||||
rest_length + breadth(line->next->data) <= wrap_at) {
|
||||
/* Go to the end of this line. */
|
||||
openfile->current_x = line_len;
|
||||
|
||||
|
@ -1836,7 +1836,7 @@ void rewrap_paragraph(linestruct **line, char *lead_string, size_t lead_len)
|
|||
ssize_t break_pos;
|
||||
/* The x-coordinate where the current line is to be broken. */
|
||||
|
||||
while (strlenpt((*line)->data) > wrap_at) {
|
||||
while (breadth((*line)->data) > wrap_at) {
|
||||
size_t line_len = strlen((*line)->data);
|
||||
|
||||
/* Find a point in the line where it can be broken. */
|
||||
|
@ -2296,7 +2296,7 @@ bool fix_spello(const char *word)
|
|||
} else if (result == 1) {
|
||||
spotlighted = TRUE;
|
||||
light_from_col = xplustabs();
|
||||
light_to_col = light_from_col + strlenpt(word);
|
||||
light_to_col = light_from_col + breadth(word);
|
||||
#ifndef NANO_TINY
|
||||
linestruct *saved_mark = openfile->mark;
|
||||
openfile->mark = NULL;
|
||||
|
|
|
@ -416,7 +416,7 @@ size_t strnlenpt(const char *text, size_t maxlen)
|
|||
}
|
||||
|
||||
/* Return the number of columns that the given text occupies. */
|
||||
size_t strlenpt(const char *text)
|
||||
size_t breadth(const char *text)
|
||||
{
|
||||
size_t span = 0;
|
||||
|
||||
|
|
20
src/winio.c
20
src/winio.c
|
@ -2106,16 +2106,16 @@ void titlebar(const char *path)
|
|||
else if (ISSET(RESTRICTED))
|
||||
state = _("Restricted");
|
||||
|
||||
pluglen = strlenpt(_("Modified")) + 1;
|
||||
pluglen = breadth(_("Modified")) + 1;
|
||||
}
|
||||
|
||||
/* Determine the widths of the four elements, including their padding. */
|
||||
verlen = strlenpt(upperleft) + 3;
|
||||
prefixlen = strlenpt(prefix);
|
||||
verlen = breadth(upperleft) + 3;
|
||||
prefixlen = breadth(prefix);
|
||||
if (prefixlen > 0)
|
||||
prefixlen++;
|
||||
pathlen = strlenpt(path);
|
||||
statelen = strlenpt(state) + 2;
|
||||
pathlen = breadth(path);
|
||||
statelen = breadth(state) + 2;
|
||||
if (statelen > 2) {
|
||||
pathlen++;
|
||||
pluglen = 0;
|
||||
|
@ -2253,7 +2253,7 @@ void statusline(message_type importance, const char *msg, ...)
|
|||
message = display_string(compound, 0, COLS, FALSE, FALSE);
|
||||
free(compound);
|
||||
|
||||
start_col = (COLS - strlenpt(message)) / 2;
|
||||
start_col = (COLS - breadth(message)) / 2;
|
||||
bracketed = (start_col > 1);
|
||||
|
||||
wmove(bottomwin, 0, (bracketed ? start_col - 2 : start_col));
|
||||
|
@ -2348,7 +2348,7 @@ void post_one_key(const char *keystroke, const char *tag, int width)
|
|||
wattroff(bottomwin, interface_color_pair[KEY_COMBO]);
|
||||
|
||||
/* If the remaning space is too small, skip the description. */
|
||||
width -= strlenpt(keystroke);
|
||||
width -= breadth(keystroke);
|
||||
if (width < 2)
|
||||
return;
|
||||
|
||||
|
@ -2812,7 +2812,7 @@ int update_line(linestruct *fileptr, size_t index)
|
|||
mvwaddch(edit, row, margin, '<');
|
||||
wattroff(edit, hilite_attribute);
|
||||
}
|
||||
if (strlenpt(fileptr->data) > from_col + editwincols) {
|
||||
if (breadth(fileptr->data) > from_col + editwincols) {
|
||||
wattron(edit, hilite_attribute);
|
||||
mvwaddch(edit, row, COLS - 1, '>');
|
||||
wattroff(edit, hilite_attribute);
|
||||
|
@ -3392,7 +3392,7 @@ void do_cursorpos(bool force)
|
|||
{
|
||||
char saved_byte;
|
||||
size_t sum, cur_xpt = xplustabs() + 1;
|
||||
size_t cur_lenpt = strlenpt(openfile->current->data) + 1;
|
||||
size_t cur_lenpt = breadth(openfile->current->data) + 1;
|
||||
int linepct, colpct, charpct;
|
||||
|
||||
/* If the showing needs to be suppressed, don't suppress it next time. */
|
||||
|
@ -3652,7 +3652,7 @@ void do_credits(void)
|
|||
else
|
||||
what = credits[crpos];
|
||||
|
||||
start_col = COLS / 2 - strlenpt(what) / 2 - 1;
|
||||
start_col = COLS / 2 - breadth(what) / 2 - 1;
|
||||
mvwaddstr(edit, editwinrows - 1 - (editwinrows % 2),
|
||||
start_col, what);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue