Skip to content

Commit 2dd3110

Browse files
committed
GUI: keyboard shortcuts SHIFT+HOME/END.
1 parent 7ac6cfe commit 2dd3110

File tree

3 files changed

+45
-2
lines changed

3 files changed

+45
-2
lines changed

plugins/gui/lvgl_static/src/core/lv_group.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ typedef enum {
4444
LV_KEY_COPY = 25, /*0x19, EOM*/
4545
LV_KEY_PASTE = 26, /*0x1A, SUB*/
4646
LV_KEY_CUT = 28, /*0x1C, FS*/
47-
47+
LV_KEY_SELECT_FROM_SOL = 29, /*0x1D, GS*/
48+
LV_KEY_SELECT_TILL_EOL = 30, /*0x1E, RS*/
4849
} lv_key_t;
4950

5051
/**********************

plugins/gui/lvgl_static/src/drivers/sdl/lv_sdl_keyboard.c

+4
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,10 @@ static uint32_t keycode_to_ctrl_key(SDL_Keycode sdl_key)
214214
return LV_KEY_SELECT_UP;
215215
case SDLK_DOWN:
216216
return LV_KEY_SELECT_DOWN;
217+
case SDLK_HOME:
218+
return LV_KEY_SELECT_FROM_SOL;
219+
case SDLK_END:
220+
return LV_KEY_SELECT_TILL_EOL;
217221
}
218222
}
219223

plugins/gui/lvgl_static/src/widgets/textarea/lv_textarea.c

+39-1
Original file line numberDiff line numberDiff line change
@@ -1107,7 +1107,9 @@ static void lv_textarea_event(const lv_obj_class_t * class_p, lv_event_t * e)
11071107
c != LV_KEY_SELECT_RIGHT &&
11081108
c != LV_KEY_SELECT_LEFT &&
11091109
c != LV_KEY_SELECT_UP &&
1110-
c != LV_KEY_SELECT_DOWN
1110+
c != LV_KEY_SELECT_DOWN &&
1111+
c != LV_KEY_SELECT_TILL_EOL &&
1112+
c != LV_KEY_SELECT_FROM_SOL
11111113
) {
11121114
lv_textarea_selection_stop(obj);
11131115
}
@@ -1146,6 +1148,12 @@ static void lv_textarea_event(const lv_obj_class_t * class_p, lv_event_t * e)
11461148
lv_textarea_cursor_down(obj);
11471149
lv_textarea_selection_continue(obj);
11481150
}
1151+
else if (c == LV_KEY_SELECT_FROM_SOL) {
1152+
update_selection_expand(obj, 0);
1153+
}
1154+
else if (c == LV_KEY_SELECT_TILL_EOL) {
1155+
update_selection_expand(obj, 1);
1156+
}
11491157
else if(c == LV_KEY_RIGHT)
11501158
lv_textarea_cursor_right(obj);
11511159
else if(c == LV_KEY_LEFT)
@@ -1454,6 +1462,36 @@ void update_selection_word(lv_event_t* e) {
14541462
#endif
14551463
}
14561464

1465+
void update_selection_expand(lv_obj_t* obj, int direction) {
1466+
LV_ASSERT_OBJ(obj, MY_CLASS);
1467+
#if LV_LABEL_TEXT_SELECTION
1468+
lv_textarea_t* ta = (lv_textarea_t *)obj;
1469+
uint32_t c;
1470+
uint32_t pos;
1471+
uint32_t oldpos;
1472+
pos = lv_textarea_get_cursor_pos(ta);
1473+
oldpos = -1;
1474+
lv_textarea_selection_start(ta);
1475+
while (oldpos != pos) {
1476+
if (direction == 0) {
1477+
lv_textarea_cursor_left(ta);
1478+
} else {
1479+
lv_textarea_cursor_right(ta);
1480+
}
1481+
oldpos = pos;
1482+
pos = lv_textarea_get_cursor_pos(ta);
1483+
lv_textarea_selection_continue(ta);
1484+
c = lv_textarea_get_current_char(ta);
1485+
if (c == '\n' || c == '\r') {
1486+
break;
1487+
}
1488+
}
1489+
lv_textarea_selection_stop(ta);
1490+
#else
1491+
#endif
1492+
}
1493+
1494+
14571495
static void update_cursor_position_on_click(lv_event_t * e)
14581496
{
14591497
lv_indev_t * click_source = lv_indev_active();

0 commit comments

Comments
 (0)