summaryrefslogtreecommitdiff
path: root/apps/plugins/text_editor.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/text_editor.c')
-rw-r--r--apps/plugins/text_editor.c69
1 files changed, 18 insertions, 51 deletions
diff --git a/apps/plugins/text_editor.c b/apps/plugins/text_editor.c
index bb6fdbf..ee8e994 100644
--- a/apps/plugins/text_editor.c
+++ b/apps/plugins/text_editor.c
@@ -18,7 +18,6 @@
****************************************************************************/
#include "plugin.h"
#include "action.h"
-#include "oldmenuapi.h"
#if PLUGIN_BUFFER_SIZE > 0x45000
#define MAX_CHARS 0x40000 /* 128 kiB */
@@ -218,21 +217,12 @@ enum {
int do_item_menu(int cur_sel, char* copy_buffer)
{
int m, ret = 0;
- static const struct menu_item items[] = {
- { "Cut", NULL },
- { "Copy", NULL },
- { "", NULL },
- { "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);
+ MENUITEM_STRINGLIST(menu, "Line Options", NULL,
+ "Cut/Delete", "Copy",
+ "Insert Above", "Insert Below",
+ "Concat To Above", "Save");
- switch (menu_show(m))
+ switch (rb->do_menu(&menu, NULL))
{
case 0: /* cut */
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)]);
ret = MENU_RET_NO_UPDATE;
break;
- case 2: /* blank */
- ret = MENU_RET_NO_UPDATE;
- break;
-
- case 3: /* insert above */
+ case 2: /* insert above */
if (!rb->kbd_input(copy_buffer,MAX_LINE_LEN))
{
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;
}
break;
- case 4: /* insert below */
+ case 3: /* insert below */
if (!rb->kbd_input(copy_buffer,MAX_LINE_LEN))
{
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;
}
break;
- case 5: /* blank */
- ret = MENU_RET_NO_UPDATE;
- break;
- case 6: /* cat to above */
+ case 4: /* cat to above */
if (cur_sel>0)
{
do_action(ACTION_CONCAT,0,cur_sel);
ret = MENU_RET_UPDATE;
}
break;
- case 7: /* save */
+ case 5: /* save */
ret = MENU_RET_SAVE;
break;
default:
ret = MENU_RET_NO_UPDATE;
break;
}
- menu_exit(m);
return ret;
}
@@ -482,46 +464,31 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
case ACTION_STD_CANCEL:
if (changed)
{
- int m;
- int result;
-
- static const struct menu_item items[] = {
- { "Return", 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)
+ MENUITEM_STRINGLIST(menu, "Do What?", NULL,
+ "Return", "Save Changes",
+ "Save As...", "Save and Exit",
+ "Ignore Changes and Exit");
+ switch (rb->do_menu(&menu, NULL))
{
case 0:
break;
- case 2: //save to disk
+ case 1: //save to disk
save_changes(1);
changed = 0;
break;
- case 3:
+ case 2:
save_changes(0);
changed = 0;
break;
- case 5:
+ case 3:
save_changes(1);
exit=1;
break;
- case 6:
+ case 4:
exit=1;
break;
}
- menu_exit(m);
}
else exit=1;
break;