[Taranis] Copy/Paste/Delete contextual menu in Custom Switches screen
This commit is contained in:
@@ -3990,6 +3990,39 @@ void menuModelCustomSwitches(uint8_t event)
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
#if defined(PCBTARANIS)
|
||||||
|
enum ClipboardType {
|
||||||
|
CLIPBOARD_TYPE_NONE,
|
||||||
|
CLIPBOARD_TYPE_CUSTOM_SWITCH,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Clipboard {
|
||||||
|
ClipboardType type;
|
||||||
|
union {
|
||||||
|
CustomSwData csw;
|
||||||
|
} data;
|
||||||
|
};
|
||||||
|
|
||||||
|
Clipboard clipboard;
|
||||||
|
|
||||||
|
void onCustomSwitchesMenu(const char *result)
|
||||||
|
{
|
||||||
|
int8_t sub = m_posVert-1;
|
||||||
|
CustomSwData * cs = cswAddress(sub);
|
||||||
|
|
||||||
|
if (result == STR_COPY) {
|
||||||
|
clipboard.type = CLIPBOARD_TYPE_CUSTOM_SWITCH;
|
||||||
|
clipboard.data.csw = *cs;
|
||||||
|
}
|
||||||
|
else if (result == STR_PASTE) {
|
||||||
|
*cs = clipboard.data.csw;
|
||||||
|
}
|
||||||
|
else if (result == STR_DELETE) {
|
||||||
|
memset(cs, 0, sizeof(CustomSwData));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void menuModelCustomSwitches(uint8_t event)
|
void menuModelCustomSwitches(uint8_t event)
|
||||||
{
|
{
|
||||||
INCDEC_DECLARE_VARS();
|
INCDEC_DECLARE_VARS();
|
||||||
@@ -4007,6 +4040,17 @@ void menuModelCustomSwitches(uint8_t event)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(PCBTARANIS)
|
||||||
|
if (sub >= 0 && event == EVT_KEY_LONG(KEY_ENTER)) {
|
||||||
|
killEvents(event);
|
||||||
|
MENU_ADD_ITEM(STR_COPY);
|
||||||
|
if (clipboard.type == CLIPBOARD_TYPE_CUSTOM_SWITCH)
|
||||||
|
MENU_ADD_ITEM(STR_PASTE);
|
||||||
|
MENU_ADD_ITEM(STR_DELETE);
|
||||||
|
menuHandler = onCustomSwitchesMenu;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
for (uint8_t i=0; i<LCD_LINES-1; i++) {
|
for (uint8_t i=0; i<LCD_LINES-1; i++) {
|
||||||
y = 1 + (i+1)*FH;
|
y = 1 + (i+1)*FH;
|
||||||
k = i+s_pgOfs;
|
k = i+s_pgOfs;
|
||||||
|
|||||||
@@ -360,6 +360,7 @@ const pm_char STR_INSERT_BEFORE[] PROGMEM = TR_INSERT_BEFORE;
|
|||||||
const pm_char STR_INSERT_AFTER[] PROGMEM = TR_INSERT_AFTER;
|
const pm_char STR_INSERT_AFTER[] PROGMEM = TR_INSERT_AFTER;
|
||||||
const pm_char STR_COPY[] PROGMEM = TR_COPY;
|
const pm_char STR_COPY[] PROGMEM = TR_COPY;
|
||||||
const pm_char STR_MOVE[] PROGMEM = TR_MOVE;
|
const pm_char STR_MOVE[] PROGMEM = TR_MOVE;
|
||||||
|
const pm_char STR_PASTE[] PROGMEM = "Paste";
|
||||||
const pm_char STR_DELETE[] PROGMEM = TR_DELETE;
|
const pm_char STR_DELETE[] PROGMEM = TR_DELETE;
|
||||||
const pm_char STR_RESET_FLIGHT[] PROGMEM = TR_RESET_FLIGHT;
|
const pm_char STR_RESET_FLIGHT[] PROGMEM = TR_RESET_FLIGHT;
|
||||||
const pm_char STR_RESET_TIMER1[] PROGMEM = TR_RESET_TIMER1;
|
const pm_char STR_RESET_TIMER1[] PROGMEM = TR_RESET_TIMER1;
|
||||||
|
|||||||
@@ -492,6 +492,7 @@ extern const pm_char STR_CURRENT[];
|
|||||||
extern const pm_char STR_INSERT_AFTER[];
|
extern const pm_char STR_INSERT_AFTER[];
|
||||||
extern const pm_char STR_COPY[];
|
extern const pm_char STR_COPY[];
|
||||||
extern const pm_char STR_MOVE[];
|
extern const pm_char STR_MOVE[];
|
||||||
|
extern const pm_char STR_PASTE[];
|
||||||
extern const pm_char STR_DELETE[];
|
extern const pm_char STR_DELETE[];
|
||||||
extern const pm_char STR_RESET_FLIGHT[];
|
extern const pm_char STR_RESET_FLIGHT[];
|
||||||
extern const pm_char STR_RESET_TIMER1[];
|
extern const pm_char STR_RESET_TIMER1[];
|
||||||
|
|||||||
Reference in New Issue
Block a user