Changeset 08e103d4 in mainline for uspace/lib/clui/tinput.c


Ignore:
Timestamp:
2019-02-05T18:26:05Z (5 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Children:
1d2f85e
Parents:
d066259
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2019-02-05 16:16:55)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2019-02-05 18:26:05)
Message:

Use clearer naming for string length functions

This and the following commit change the names of functions, as well as
their documentation, to use unambiguous terms "bytes" and "code points"
instead of ambiguous terms "size", "length", and "characters".

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/clui/tinput.c

    rd066259 r08e103d4  
    203203
    204204        ti->prompt_coord = row0 * ti->con_cols + col0;
    205         ti->text_coord = ti->prompt_coord + str_length(ti->prompt);
     205        ti->text_coord = ti->prompt_coord + str_code_points(ti->prompt);
    206206
    207207        tinput_display_prompt(ti);
     
    243243static void tinput_insert_string(tinput_t *ti, const char *str)
    244244{
    245         size_t ilen = min(str_length(str), INPUT_MAX_SIZE - ti->nc);
     245        size_t ilen = min(str_code_points(str), INPUT_MAX_SIZE - ti->nc);
    246246        if (ilen == 0)
    247247                return;
     
    467467{
    468468        str_to_wstr(ti->buffer, INPUT_MAX_SIZE, str);
    469         ti->nc = wstr_length(ti->buffer);
     469        ti->nc = wstr_code_points(ti->buffer);
    470470        ti->pos = ti->nc;
    471471        ti->sel_start = ti->pos;
     
    579579        ti->hpos += offs;
    580580
    581         int pad = (int) ti->nc - str_length(ti->history[ti->hpos]);
     581        int pad = (int) ti->nc - str_code_points(ti->history[ti->hpos]);
    582582        if (pad < 0)
    583583                pad = 0;
     
    727727                size_t cplen;
    728728
    729                 cplen = str_length(compl[0]);
     729                cplen = str_code_points(compl[0]);
    730730                for (i = 1; i < cnum; i++)
    731731                        cplen = min(cplen, common_pref_len(compl[0], compl[i]));
    732732
    733733                /* Compute how many bytes we should skip. */
    734                 size_t istart = str_lsize(compl[0], ti->pos - cstart);
     734                size_t istart = str_lbytes(compl[0], ti->pos - cstart);
    735735
    736736                if (cplen > istart) {
     
    739739                        /* Copy remainder of common prefix. */
    740740                        char *cpref = str_ndup(compl[0] + istart,
    741                             str_lsize(compl[0], cplen - istart));
     741                            str_lbytes(compl[0], cplen - istart));
    742742
    743743                        /* Insert it. */
     
    759759
    760760                /* Compute how many bytes of completion string we should skip. */
    761                 size_t istart = str_lsize(compl[0], ti->pos - cstart);
     761                size_t istart = str_lbytes(compl[0], ti->pos - cstart);
    762762
    763763                /* Insert remainder of completion string at current position. */
Note: See TracChangeset for help on using the changeset viewer.