Skip to content

Commit 8e82a10

Browse files
committed
GUI: Add select all to context menu.
1 parent 871792a commit 8e82a10

File tree

7 files changed

+20
-6
lines changed

7 files changed

+20
-6
lines changed

plugins/gui/gui.c

+10-3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ lv_obj_t* CtrGUIContextMenuItemPaste;
4343
lv_obj_t* CtrGUIContextMenuLabelPaste;
4444
lv_obj_t* CtrGUIContextMenuItemCut;
4545
lv_obj_t* CtrGUIContextMenuLabelCut;
46+
lv_obj_t* CtrGUIContextMenuItemSelAll;
47+
lv_obj_t* CtrGUIContextMenuLabelSelAll;
4648
lv_obj_t* CtrGUIContextFocus;
4749

4850
struct GUIIMG {
@@ -358,8 +360,12 @@ void ctr_internal_gui_context_actions(lv_event_t * e) {
358360
char* oldbuf = lv_textarea_get_text(CtrGUIContextFocus);
359361
uint32_t sellen = selend - selstart;
360362
char* selbuf;
363+
int close = 1;
361364
uint32_t pos = lv_textarea_get_cursor_pos(CtrGUIContextFocus);
362-
if (issel && (obj == CtrGUIContextMenuItemCopy || obj == CtrGUIContextMenuLabelCopy)) {
365+
if ((obj == CtrGUIContextMenuItemSelAll || obj == CtrGUIContextMenuLabelSelAll)) {
366+
lv_textarea_selection_all(CtrGUIContextFocus);
367+
close = 0;
368+
} else if (issel && (obj == CtrGUIContextMenuItemCopy || obj == CtrGUIContextMenuLabelCopy)) {
363369
selbuf = ctr_internal_gui_copytext(oldbuf, selstart, sellen);
364370
SDL_SetClipboardText(selbuf);
365371
ctr_heap_free(selbuf);
@@ -382,7 +388,7 @@ void ctr_internal_gui_context_actions(lv_event_t * e) {
382388
SDL_free(selbuf);
383389
}
384390
}
385-
ctr_internal_gui_context_menu_close();
391+
if (close) ctr_internal_gui_context_menu_close();
386392
}
387393

388394
void ctr_internal_gui_context_menu_add(lv_obj_t** ret_item, lv_obj_t** ret_label, char* text) {
@@ -402,12 +408,13 @@ void ctr_internal_gui_context_menu_open(lv_point_t point) {
402408
ctr_internal_gui_context_menu_close();
403409
CtrGUIContextMenu = lv_menu_create(lv_scr_act());
404410
lv_obj_add_event_cb(CtrGUIContextMenu, ctr_internal_gui_context_actions, LV_EVENT_CLICKED, CtrGUIContextMenu);
405-
lv_obj_set_size(CtrGUIContextMenu, 200, 120);
411+
lv_obj_set_size(CtrGUIContextMenu, 230, 150);
406412
lv_obj_align(CtrGUIContextMenu, LV_ALIGN_TOP_LEFT, point.x, point.y );
407413
CtrGUIContextMenuMainPage = lv_menu_page_create(CtrGUIContextMenu, NULL);
408414
ctr_internal_gui_context_menu_add(&CtrGUIContextMenuItemCopy, &CtrGUIContextMenuLabelCopy, LV_SYMBOL_COPY " " CTR_MSG_GUI_CONTEXTMENU_COPY);
409415
ctr_internal_gui_context_menu_add(&CtrGUIContextMenuItemPaste, &CtrGUIContextMenuLabelPaste, LV_SYMBOL_PASTE " " CTR_MSG_GUI_CONTEXTMENU_PASTE);
410416
ctr_internal_gui_context_menu_add(&CtrGUIContextMenuItemCut, &CtrGUIContextMenuLabelCut, LV_SYMBOL_CUT " " CTR_MSG_GUI_CONTEXTMENU_CUT);
417+
ctr_internal_gui_context_menu_add(&CtrGUIContextMenuItemSelAll, &CtrGUIContextMenuLabelSelAll, CTR_MSG_GUI_CONTEXTMENU_SELALL);
411418
lv_menu_set_page(CtrGUIContextMenu, CtrGUIContextMenuMainPage);
412419
}
413420

plugins/gui/i18n/de/guimsg.h

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
#define CTR_MSG_GUI_CONTEXTMENU_COPY "kopieren"
22
#define CTR_MSG_GUI_CONTEXTMENU_CUT "ausschneiden"
33
#define CTR_MSG_GUI_CONTEXTMENU_PASTE "einfügen"
4+
#define CTR_MSG_GUI_CONTEXTMENU_SELALL "alle auswählen"
5+

plugins/gui/i18n/en/guimsg.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#define CTR_MSG_GUI_CONTEXTMENU_COPY "copy"
22
#define CTR_MSG_GUI_CONTEXTMENU_CUT "cut"
3-
#define CTR_MSG_GUI_CONTEXTMENU_PASTE "paste"
3+
#define CTR_MSG_GUI_CONTEXTMENU_PASTE "paste"
4+
#define CTR_MSG_GUI_CONTEXTMENU_SELALL "select all"

plugins/gui/i18n/es/guimsg.h

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#define CTR_MSG_GUI_CONTEXTMENU_COPY "copiar"
22
#define CTR_MSG_GUI_CONTEXTMENU_CUT "cortar"
33
#define CTR_MSG_GUI_CONTEXTMENU_PASTE "pegar"
4+
#define CTR_MSG_GUI_CONTEXTMENU_SELALL "seleccionar todo"

plugins/gui/i18n/fr/guimsg.h

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#define CTR_MSG_GUI_CONTEXTMENU_COPY "copier"
22
#define CTR_MSG_GUI_CONTEXTMENU_CUT "couper"
33
#define CTR_MSG_GUI_CONTEXTMENU_PASTE "coller"
4+
#define CTR_MSG_GUI_CONTEXTMENU_SELALL "sélectionner tout"

plugins/gui/i18n/nl/guimsg.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#define CTR_MSG_GUI_CONTEXTMENU_COPY "kopieer"
22
#define CTR_MSG_GUI_CONTEXTMENU_CUT "knip"
3-
#define CTR_MSG_GUI_CONTEXTMENU_PASTE "plak"
3+
#define CTR_MSG_GUI_CONTEXTMENU_PASTE "plak"
4+
#define CTR_MSG_GUI_CONTEXTMENU_SELALL "selecteer alles"

plugins/gui/i18n/ru/guimsg.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#define CTR_MSG_GUI_CONTEXTMENU_COPY "копировать"
22
#define CTR_MSG_GUI_CONTEXTMENU_CUT "вырезать"
3-
#define CTR_MSG_GUI_CONTEXTMENU_PASTE "вставить"
3+
#define CTR_MSG_GUI_CONTEXTMENU_PASTE "вставить"
4+
#define CTR_MSG_GUI_CONTEXTMENU_SELALL "выбрать все"

0 commit comments

Comments
 (0)