mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
convert the last of the menus in text_editor to the new api
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13901 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
b43bf7e639
commit
9dca6aafb3
1 changed files with 18 additions and 51 deletions
|
@ -18,7 +18,6 @@
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include "plugin.h"
|
#include "plugin.h"
|
||||||
#include "action.h"
|
#include "action.h"
|
||||||
#include "oldmenuapi.h"
|
|
||||||
|
|
||||||
#if PLUGIN_BUFFER_SIZE > 0x45000
|
#if PLUGIN_BUFFER_SIZE > 0x45000
|
||||||
#define MAX_CHARS 0x40000 /* 128 kiB */
|
#define MAX_CHARS 0x40000 /* 128 kiB */
|
||||||
|
@ -218,21 +217,12 @@ enum {
|
||||||
int do_item_menu(int cur_sel, char* copy_buffer)
|
int do_item_menu(int cur_sel, char* copy_buffer)
|
||||||
{
|
{
|
||||||
int m, ret = 0;
|
int m, ret = 0;
|
||||||
static const struct menu_item items[] = {
|
MENUITEM_STRINGLIST(menu, "Line Options", NULL,
|
||||||
{ "Cut", NULL },
|
"Cut/Delete", "Copy",
|
||||||
{ "Copy", NULL },
|
"Insert Above", "Insert Below",
|
||||||
{ "", NULL },
|
"Concat To Above", "Save");
|
||||||
{ "Insert Above", NULL },
|
|
||||||
{ "Insert Below", NULL },
|
|
||||||
{ "", NULL },
|
|
||||||
{ "Cat To Above",NULL },
|
|
||||||
{ "", NULL },
|
|
||||||
{ "Save", NULL },
|
|
||||||
};
|
|
||||||
m = menu_init(rb, items, sizeof(items) / sizeof(*items),
|
|
||||||
NULL, NULL, NULL, NULL);
|
|
||||||
|
|
||||||
switch (menu_show(m))
|
switch (rb->do_menu(&menu, NULL))
|
||||||
{
|
{
|
||||||
case 0: /* cut */
|
case 0: /* cut */
|
||||||
rb->strcpy(copy_buffer,&buffer[do_action(ACTION_GET,0,cur_sel)]);
|
rb->strcpy(copy_buffer,&buffer[do_action(ACTION_GET,0,cur_sel)]);
|
||||||
|
@ -243,11 +233,7 @@ int do_item_menu(int cur_sel, char* copy_buffer)
|
||||||
rb->strcpy(copy_buffer,&buffer[do_action(ACTION_GET,0,cur_sel)]);
|
rb->strcpy(copy_buffer,&buffer[do_action(ACTION_GET,0,cur_sel)]);
|
||||||
ret = MENU_RET_NO_UPDATE;
|
ret = MENU_RET_NO_UPDATE;
|
||||||
break;
|
break;
|
||||||
case 2: /* blank */
|
case 2: /* insert above */
|
||||||
ret = MENU_RET_NO_UPDATE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3: /* insert above */
|
|
||||||
if (!rb->kbd_input(copy_buffer,MAX_LINE_LEN))
|
if (!rb->kbd_input(copy_buffer,MAX_LINE_LEN))
|
||||||
{
|
{
|
||||||
do_action(ACTION_INSERT,copy_buffer,cur_sel);
|
do_action(ACTION_INSERT,copy_buffer,cur_sel);
|
||||||
|
@ -255,7 +241,7 @@ int do_item_menu(int cur_sel, char* copy_buffer)
|
||||||
ret = MENU_RET_UPDATE;
|
ret = MENU_RET_UPDATE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 4: /* insert below */
|
case 3: /* insert below */
|
||||||
if (!rb->kbd_input(copy_buffer,MAX_LINE_LEN))
|
if (!rb->kbd_input(copy_buffer,MAX_LINE_LEN))
|
||||||
{
|
{
|
||||||
do_action(ACTION_INSERT,copy_buffer,cur_sel+1);
|
do_action(ACTION_INSERT,copy_buffer,cur_sel+1);
|
||||||
|
@ -263,24 +249,20 @@ int do_item_menu(int cur_sel, char* copy_buffer)
|
||||||
ret = MENU_RET_UPDATE;
|
ret = MENU_RET_UPDATE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 5: /* blank */
|
case 4: /* cat to above */
|
||||||
ret = MENU_RET_NO_UPDATE;
|
|
||||||
break;
|
|
||||||
case 6: /* cat to above */
|
|
||||||
if (cur_sel>0)
|
if (cur_sel>0)
|
||||||
{
|
{
|
||||||
do_action(ACTION_CONCAT,0,cur_sel);
|
do_action(ACTION_CONCAT,0,cur_sel);
|
||||||
ret = MENU_RET_UPDATE;
|
ret = MENU_RET_UPDATE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 7: /* save */
|
case 5: /* save */
|
||||||
ret = MENU_RET_SAVE;
|
ret = MENU_RET_SAVE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = MENU_RET_NO_UPDATE;
|
ret = MENU_RET_NO_UPDATE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
menu_exit(m);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -482,46 +464,31 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
||||||
case ACTION_STD_CANCEL:
|
case ACTION_STD_CANCEL:
|
||||||
if (changed)
|
if (changed)
|
||||||
{
|
{
|
||||||
int m;
|
MENUITEM_STRINGLIST(menu, "Do What?", NULL,
|
||||||
int result;
|
"Return", "Save Changes",
|
||||||
|
"Save As...", "Save and Exit",
|
||||||
static const struct menu_item items[] = {
|
"Ignore Changes and Exit");
|
||||||
{ "Return", NULL },
|
switch (rb->do_menu(&menu, NULL))
|
||||||
{ " ", NULL },
|
|
||||||
{ "Save Changes", NULL },
|
|
||||||
{ "Save As...", NULL },
|
|
||||||
{ " ", NULL },
|
|
||||||
{ "Save and Exit", NULL },
|
|
||||||
{ "Ignore Changes and Exit", NULL },
|
|
||||||
};
|
|
||||||
|
|
||||||
m = menu_init(rb, items, sizeof(items) / sizeof(*items),
|
|
||||||
NULL, NULL, NULL, NULL);
|
|
||||||
|
|
||||||
result=menu_show(m);
|
|
||||||
|
|
||||||
switch (result)
|
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case 2: //save to disk
|
case 1: //save to disk
|
||||||
save_changes(1);
|
save_changes(1);
|
||||||
changed = 0;
|
changed = 0;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 2:
|
||||||
save_changes(0);
|
save_changes(0);
|
||||||
changed = 0;
|
changed = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5:
|
case 3:
|
||||||
save_changes(1);
|
save_changes(1);
|
||||||
exit=1;
|
exit=1;
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 4:
|
||||||
exit=1;
|
exit=1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
menu_exit(m);
|
|
||||||
}
|
}
|
||||||
else exit=1;
|
else exit=1;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue