summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2007-07-15 06:45:12 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2007-07-15 06:45:12 +0000
commit9dca6aafb3b12e55e2b8fa956287e160bce2a17c (patch)
tree68f6045bb4fdde1fe43a20f0703fca6a72d2dc78 /apps/plugins
parentb43bf7e6397fe79ce99530fd10c0eb34b192c253 (diff)
downloadrockbox-9dca6aafb3b12e55e2b8fa956287e160bce2a17c.tar.gz
rockbox-9dca6aafb3b12e55e2b8fa956287e160bce2a17c.zip
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
Diffstat (limited to 'apps/plugins')
-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 bb6fdbf755..ee8e994ab8 100644
--- a/apps/plugins/text_editor.c
+++ b/apps/plugins/text_editor.c
@@ -18,7 +18,6 @@
18 ****************************************************************************/ 18 ****************************************************************************/
19#include "plugin.h" 19#include "plugin.h"
20#include "action.h" 20#include "action.h"
21#include "oldmenuapi.h"
22 21
23#if PLUGIN_BUFFER_SIZE > 0x45000 22#if PLUGIN_BUFFER_SIZE > 0x45000
24#define MAX_CHARS 0x40000 /* 128 kiB */ 23#define MAX_CHARS 0x40000 /* 128 kiB */
@@ -218,21 +217,12 @@ enum {
218int do_item_menu(int cur_sel, char* copy_buffer) 217int do_item_menu(int cur_sel, char* copy_buffer)
219{ 218{
220 int m, ret = 0; 219 int m, ret = 0;
221 static const struct menu_item items[] = { 220 MENUITEM_STRINGLIST(menu, "Line Options", NULL,
222 { "Cut", NULL }, 221 "Cut/Delete", "Copy",
223 { "Copy", NULL }, 222 "Insert Above", "Insert Below",
224 { "", NULL }, 223 "Concat To Above", "Save");
225 { "Insert Above", NULL },
226 { "Insert Below", NULL },
227 { "", NULL },
228 { "Cat To Above",NULL },
229 { "", NULL },
230 { "Save", NULL },
231 };
232 m = menu_init(rb, items, sizeof(items) / sizeof(*items),
233 NULL, NULL, NULL, NULL);
234 224
235 switch (menu_show(m)) 225 switch (rb->do_menu(&menu, NULL))
236 { 226 {
237 case 0: /* cut */ 227 case 0: /* cut */
238 rb->strcpy(copy_buffer,&buffer[do_action(ACTION_GET,0,cur_sel)]); 228 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)
243 rb->strcpy(copy_buffer,&buffer[do_action(ACTION_GET,0,cur_sel)]); 233 rb->strcpy(copy_buffer,&buffer[do_action(ACTION_GET,0,cur_sel)]);
244 ret = MENU_RET_NO_UPDATE; 234 ret = MENU_RET_NO_UPDATE;
245 break; 235 break;
246 case 2: /* blank */ 236 case 2: /* insert above */
247 ret = MENU_RET_NO_UPDATE;
248 break;
249
250 case 3: /* insert above */
251 if (!rb->kbd_input(copy_buffer,MAX_LINE_LEN)) 237 if (!rb->kbd_input(copy_buffer,MAX_LINE_LEN))
252 { 238 {
253 do_action(ACTION_INSERT,copy_buffer,cur_sel); 239 do_action(ACTION_INSERT,copy_buffer,cur_sel);
@@ -255,7 +241,7 @@ int do_item_menu(int cur_sel, char* copy_buffer)
255 ret = MENU_RET_UPDATE; 241 ret = MENU_RET_UPDATE;
256 } 242 }
257 break; 243 break;
258 case 4: /* insert below */ 244 case 3: /* insert below */
259 if (!rb->kbd_input(copy_buffer,MAX_LINE_LEN)) 245 if (!rb->kbd_input(copy_buffer,MAX_LINE_LEN))
260 { 246 {
261 do_action(ACTION_INSERT,copy_buffer,cur_sel+1); 247 do_action(ACTION_INSERT,copy_buffer,cur_sel+1);
@@ -263,24 +249,20 @@ int do_item_menu(int cur_sel, char* copy_buffer)
263 ret = MENU_RET_UPDATE; 249 ret = MENU_RET_UPDATE;
264 } 250 }
265 break; 251 break;
266 case 5: /* blank */ 252 case 4: /* cat to above */
267 ret = MENU_RET_NO_UPDATE;
268 break;
269 case 6: /* cat to above */
270 if (cur_sel>0) 253 if (cur_sel>0)
271 { 254 {
272 do_action(ACTION_CONCAT,0,cur_sel); 255 do_action(ACTION_CONCAT,0,cur_sel);
273 ret = MENU_RET_UPDATE; 256 ret = MENU_RET_UPDATE;
274 } 257 }
275 break; 258 break;
276 case 7: /* save */ 259 case 5: /* save */
277 ret = MENU_RET_SAVE; 260 ret = MENU_RET_SAVE;
278 break; 261 break;
279 default: 262 default:
280 ret = MENU_RET_NO_UPDATE; 263 ret = MENU_RET_NO_UPDATE;
281 break; 264 break;
282 } 265 }
283 menu_exit(m);
284 return ret; 266 return ret;
285} 267}
286 268
@@ -482,46 +464,31 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
482 case ACTION_STD_CANCEL: 464 case ACTION_STD_CANCEL:
483 if (changed) 465 if (changed)
484 { 466 {
485 int m; 467 MENUITEM_STRINGLIST(menu, "Do What?", NULL,
486 int result; 468 "Return", "Save Changes",
487 469 "Save As...", "Save and Exit",
488 static const struct menu_item items[] = { 470 "Ignore Changes and Exit");
489 { "Return", NULL }, 471 switch (rb->do_menu(&menu, NULL))
490 { " ", NULL },
491 { "Save Changes", NULL },
492 { "Save As...", NULL },
493 { " ", NULL },
494 { "Save and Exit", NULL },
495 { "Ignore Changes and Exit", NULL },
496 };
497
498 m = menu_init(rb, items, sizeof(items) / sizeof(*items),
499 NULL, NULL, NULL, NULL);
500
501 result=menu_show(m);
502
503 switch (result)
504 { 472 {
505 case 0: 473 case 0:
506 break; 474 break;
507 case 2: //save to disk 475 case 1: //save to disk
508 save_changes(1); 476 save_changes(1);
509 changed = 0; 477 changed = 0;
510 break; 478 break;
511 case 3: 479 case 2:
512 save_changes(0); 480 save_changes(0);
513 changed = 0; 481 changed = 0;
514 break; 482 break;
515 483
516 case 5: 484 case 3:
517 save_changes(1); 485 save_changes(1);
518 exit=1; 486 exit=1;
519 break; 487 break;
520 case 6: 488 case 4:
521 exit=1; 489 exit=1;
522 break; 490 break;
523 } 491 }
524 menu_exit(m);
525 } 492 }
526 else exit=1; 493 else exit=1;
527 break; 494 break;