Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset a106037 in mainline


Ignore:
Timestamp:
2021-07-21T18:04:12Z (3 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
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).

Location:
uspace/lib/ui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ui/private/entry.h

    r282c86d ra106037  
    6868        /** Button is held down */
    6969        bool held;
     70        /** Left shift is held down */
     71        bool lshift_held;
     72        /** Right shift is held down */
     73        bool rshift_held;
    7074};
    7175
  • 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.