Changeset f7a8052 in mainline


Ignore:
Timestamp:
2022-02-08T12:22:28Z (2 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0436aec
Parents:
7eec25fc
git-author:
Jiri Svoboda <jiri@…> (2022-02-07 18:22:17)
git-committer:
Jiri Svoboda <jiri@…> (2022-02-08 12:22:28)
Message:

Account for scrolling while initially printing prompt and text

File:
1 edited

Legend:

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

    r7eec25fc rf7a8052  
    172172}
    173173
    174 /** Update text_coord, prompt_coord in case the screen could have scrolled. */
    175 static void tinput_update_origin(tinput_t *ti)
    176 {
    177         unsigned end_coord = ti->text_coord + ti->nc;
     174/** Update text_coord, prompt_coord in case the screen would scroll
     175 * due to @a end_coord being beyond the end of the screen
     176 *
     177 * @param ti Text input
     178 * @param end_coord Linear screen coordinate to which the cursor would
     179 *                  be moved if the screen would not have scrolled
     180 */
     181static void tinput_update_origin_coord(tinput_t *ti, unsigned end_coord)
     182{
    178183        unsigned end_row = LIN_TO_ROW(ti, end_coord);
    179184
     
    188193}
    189194
     195/** Update text_coord, prompt_coord in case the screen could have scrolled. */
     196static void tinput_update_origin(tinput_t *ti)
     197{
     198        /* Account for scrolling until the end of the input text */
     199        tinput_update_origin_coord(ti, ti->text_coord + ti->nc);
     200}
     201
    190202static void tinput_jump_after(tinput_t *ti)
    191203{
     
    203215
    204216        ti->prompt_coord = row0 * ti->con_cols + col0;
     217        ti->text_coord = ti->prompt_coord;
     218        tinput_display_prompt(ti);
     219
     220        /* The screen might have scrolled after priting the prompt */
     221        tinput_update_origin_coord(ti, ti->prompt_coord + str_width(ti->prompt));
     222
    205223        ti->text_coord = ti->prompt_coord + str_length(ti->prompt);
    206 
    207         tinput_display_prompt(ti);
    208224        tinput_display_tail(ti, 0, 0);
     225
     226        /* The screen might have scrolled after priting the text */
     227        tinput_update_origin(ti);
     228
    209229        tinput_position_caret(ti);
    210230
Note: See TracChangeset for help on using the changeset viewer.