Changeset a106037 in mainline for uspace/lib/ui/src/entry.c


Ignore:
Timestamp:
2021-07-21T18:04:12Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
21b0013, 5de71df
Parents:
282c86d
Message:

Selecting entry text by shift-click

You can never have enough ways of selecting text. Besides, mouse drag
does not work in console, because console does not deliver position
update events (we might have to rethink that).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ui/src/entry.c

    r282c86d ra106037  
    733733        }
    734734
     735        /*
     736         * Need to keep track if any shift is held for the case
     737         * of selecting by shift-click. This could be simplified
     738         * if position events were decorated with modifier
     739         * state.
     740         */
     741
     742        if (event->type == KEY_PRESS && event->key == KC_LSHIFT)
     743                entry->lshift_held = true;
     744        if (event->type == KEY_RELEASE && event->key == KC_LSHIFT)
     745                entry->lshift_held = false;
     746        if (event->type == KEY_PRESS && event->key == KC_RSHIFT)
     747                entry->rshift_held = true;
     748        if (event->type == KEY_RELEASE && event->key == KC_RSHIFT)
     749                entry->rshift_held = false;
     750
    735751        if (event->type == KEY_PRESS &&
    736752            (event->mods & (KM_CTRL | KM_ALT | KM_SHIFT)) == 0)
     
    800816                        entry->held = true;
    801817                        entry->pos = ui_entry_find_pos(entry, &pos);
    802                         entry->sel_start = entry->pos;
     818
     819                        /* Clear selection if no shift key is held */
     820                        if (!entry->lshift_held && !entry->rshift_held)
     821                                entry->sel_start = entry->pos;
     822
    803823                        if (entry->active)
    804824                                ui_entry_paint(entry);
Note: See TracChangeset for help on using the changeset viewer.