A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

Patch #4864 by Jonathan Gordon: text editor plugin, with some changes by me. Also correct a var clash between the rockbox's gui api and doom plugin


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9451 a1c6a512-1295-4272-9138-f99709370657

+549 -42
+8
apps/gui/list.c
··· 491 491 #endif 492 492 } 493 493 } 494 + int gui_synclist_get_nb_items(struct gui_synclist * lists) 495 + { 496 + return gui_list_get_nb_items(&((lists)->gui_list[0])); 497 + } 498 + int gui_synclist_get_sel_pos(struct gui_synclist * lists) 499 + { 500 + return gui_list_get_sel_pos(&((lists)->gui_list[0])); 501 + } 494 502 void gui_synclist_set_icon_callback(struct gui_synclist * lists, list_get_icon icon_callback) 495 503 { 496 504 int i;
+1 -5
apps/gui/list.h
··· 337 337 ); 338 338 extern void gui_synclist_set_nb_items(struct gui_synclist * lists, int nb_items); 339 339 extern void gui_synclist_set_icon_callback(struct gui_synclist * lists, list_get_icon icon_callback); 340 - #define gui_synclist_get_nb_items(lists) \ 341 - gui_list_get_nb_items(&((lists)->gui_list[0])) 340 + extern int gui_synclist_get_nb_items(struct gui_synclist * lists); 342 341 343 342 extern int gui_synclist_get_sel_pos(struct gui_synclist * lists); 344 - 345 - #define gui_synclist_get_sel_pos(lists) \ 346 - gui_list_get_sel_pos(&((lists)->gui_list[0])) 347 343 348 344 extern void gui_synclist_draw(struct gui_synclist * lists); 349 345 extern void gui_synclist_select_item(struct gui_synclist * lists,
+22
apps/plugin.c
··· 52 52 #include "sound.h" 53 53 #include "database.h" 54 54 #include "splash.h" 55 + #include "list.h" 55 56 #if (CONFIG_CODEC == SWCODEC) 56 57 #include "pcm_playback.h" 57 58 #include "dsp.h" ··· 412 413 413 414 vsnprintf, 414 415 memchr, 416 + /* list */ 417 + gui_synclist_init, 418 + gui_synclist_set_nb_items, 419 + gui_synclist_set_icon_callback, 420 + gui_synclist_get_nb_items, 421 + gui_synclist_get_sel_pos, 422 + gui_synclist_draw, 423 + gui_synclist_select_item, 424 + gui_synclist_select_next, 425 + gui_synclist_select_previous, 426 + gui_synclist_select_next_page, 427 + gui_synclist_select_previous_page, 428 + gui_synclist_add_item, 429 + gui_synclist_del_item, 430 + gui_synclist_limit_scroll, 431 + gui_synclist_flash, 432 + #ifdef HAVE_LCD_BITMAP 433 + gui_synclist_scroll_right, 434 + gui_synclist_scroll_left, 435 + #endif 436 + gui_synclist_do_button, 415 437 }; 416 438 417 439 int plugin_load(const char* plugin, void* parameter)
+28 -1
apps/plugin.h
··· 67 67 #include "sound.h" 68 68 #include "menu.h" 69 69 #include "rbunicode.h" 70 + #include "list.h" 70 71 71 72 #ifdef HAVE_REMOTE_LCD 72 73 #include "lcd-remote.h" ··· 102 103 #define PLUGIN_MAGIC 0x526F634B /* RocK */ 103 104 104 105 /* increase this every time the api struct changes */ 105 - #define PLUGIN_API_VERSION 17 106 + #define PLUGIN_API_VERSION 18 106 107 107 108 /* update this to latest version if a change to the api struct breaks 108 109 backwards compatibility (and please take the opportunity to sort in any ··· 483 484 484 485 int (*vsnprintf)(char *buf, int size, const char *fmt, va_list ap); 485 486 void *(*memchr)(const void *s1, int c, size_t n); 487 + 488 + /* list */ 489 + void (*gui_synclist_init)(struct gui_synclist * lists, 490 + list_get_name callback_get_item_name,void * data); 491 + void (*gui_synclist_set_nb_items)(struct gui_synclist * lists, int nb_items); 492 + void (*gui_synclist_set_icon_callback)(struct gui_synclist * lists, list_get_icon icon_callback); 493 + int (*gui_synclist_get_nb_items)(struct gui_synclist * lists); 494 + int (*gui_synclist_get_sel_pos)(struct gui_synclist * lists); 495 + void (*gui_synclist_draw)(struct gui_synclist * lists); 496 + void (*gui_synclist_select_item)(struct gui_synclist * lists, 497 + int item_number); 498 + void (*gui_synclist_select_next)(struct gui_synclist * lists); 499 + void (*gui_synclist_select_previous)(struct gui_synclist * lists); 500 + void (*gui_synclist_select_next_page)(struct gui_synclist * lists, 501 + enum screen_type screen); 502 + void (*gui_synclist_select_previous_page)(struct gui_synclist * lists, 503 + enum screen_type screen); 504 + void (*gui_synclist_add_item)(struct gui_synclist * lists); 505 + void (*gui_synclist_del_item)(struct gui_synclist * lists); 506 + void (*gui_synclist_limit_scroll)(struct gui_synclist * lists, bool scroll); 507 + void (*gui_synclist_flash)(struct gui_synclist * lists); 508 + #ifdef HAVE_LCD_BITMAP 509 + void (*gui_synclist_scroll_right)(struct gui_synclist * lists); 510 + void (*gui_synclist_scroll_left)(struct gui_synclist * lists); 511 + #endif 512 + unsigned (*gui_synclist_do_button)(struct gui_synclist * lists, unsigned button); 486 513 }; 487 514 488 515 /* plugin header */
+1
apps/plugins/SOURCES
··· 26 26 #ifndef IRIVER_IFP7XX_SERIES /* Temporarily disable plugins for iFP7xx */ 27 27 dice.c 28 28 #ifdef HAVE_LCD_BITMAP /* Not for the Player */ 29 + text_editor.c 29 30 30 31 #if CONFIG_LCD != LCD_IPOD2BPP /* Plugins needing the grayscale lib */ 31 32 fire.c
+5 -5
apps/plugins/doom/f_wipe.c
··· 140 140 return done; 141 141 } 142 142 143 - // CPhipps - modified to allocate and deallocate screens[2 to 3] as needed, saving memory 143 + // CPhipps - modified to allocate and deallocate d_screens[2 to 3] as needed, saving memory 144 144 145 145 static int wipe_exitMelt(int width, int height, int ticks) 146 146 { ··· 152 152 free(wipe_scr_end); 153 153 // Paranoia 154 154 y = NULL; 155 - wipe_scr_start = wipe_scr_end = screens[SRC_SCR] = screens[DEST_SCR] = NULL; 155 + wipe_scr_start = wipe_scr_end = d_screens[SRC_SCR] = d_screens[DEST_SCR] = NULL; 156 156 return 0; 157 157 } 158 158 159 159 int wipe_StartScreen(int x, int y, int width, int height) 160 160 { 161 - wipe_scr_start = screens[SRC_SCR] = malloc(SCREENWIDTH * SCREENHEIGHT); 161 + wipe_scr_start = d_screens[SRC_SCR] = malloc(SCREENWIDTH * SCREENHEIGHT); 162 162 V_CopyRect(x, y, 0, width, height, x, y, SRC_SCR, VPT_NONE ); // Copy start screen to buffer 163 163 return 0; 164 164 } 165 165 166 166 int wipe_EndScreen(int x, int y, int width, int height) 167 167 { 168 - wipe_scr_end = screens[DEST_SCR] = malloc(SCREENWIDTH * SCREENHEIGHT); 168 + wipe_scr_end = d_screens[DEST_SCR] = malloc(SCREENWIDTH * SCREENHEIGHT); 169 169 V_CopyRect(x, y, 0, width, height, x, y, DEST_SCR, VPT_NONE); // Copy end screen to buffer 170 170 V_CopyRect(x, y, SRC_SCR, width, height, x, y, 0 , VPT_NONE); // restore start screen 171 171 return 0; ··· 180 180 if (!go) // initial stuff 181 181 { 182 182 go = 1; 183 - wipe_scr = screens[0]; 183 + wipe_scr = d_screens[0]; 184 184 wipe_initMelt(width, height, ticks); 185 185 } 186 186 V_MarkRect(0, 0, width, height); // do a piece of wipe-in
+10 -6
apps/plugins/doom/i_video.c
··· 16 16 * GNU General Public License for more details. 17 17 * 18 18 * $Log$ 19 - * Revision 1.4 2006/04/02 20:45:24 kkurbjun 19 + * Revision 1.5 2006/04/03 08:51:08 bger 20 + * Patch #4864 by Jonathan Gordon: text editor plugin, with some changes by me. 21 + * Also correct a var clash between the rockbox's gui api and doom plugin 22 + * 23 + * Revision 1.4 2006-04-02 20:45:24 kkurbjun 20 24 * Properly ifdef H300 video code, fix commented line handling rockbox volume 21 25 * 22 26 * Revision 1.3 2006-04-02 01:52:44 kkurbjun ··· 336 340 *(volatile unsigned short *) 0xf0000002 = 0; // value 337 341 *(volatile unsigned short *) 0xf0000000 = 0x22; // GRAM 338 342 339 - unsigned char *screenptr=screens[0]; 343 + unsigned char *screenptr=d_screens[0]; 340 344 int wcnt=0, hcnt=0; 341 345 342 346 while(hcnt<LCD_HEIGHT) ··· 358 362 { 359 363 for (x = 0; x < LCD_WIDTH; x++) 360 364 { 361 - paletteIndex = screens[0][y*SCREENWIDTH + x]; 365 + paletteIndex = d_screens[0][y*SCREENWIDTH + x]; 362 366 rb->lcd_framebuffer[y * LCD_WIDTH + x] = palette[paletteIndex]; 363 367 } 364 368 } ··· 371 375 // 372 376 void I_ReadScreen (byte* scr) 373 377 { 374 - memcpy (scr, screens[0], SCREENWIDTH*SCREENHEIGHT); 378 + memcpy (scr, d_screens[0], SCREENWIDTH*SCREENHEIGHT); 375 379 } 376 380 377 381 // ··· 399 403 400 404 #if defined(CPU_COLDFIRE) && !defined(SIMULATOR) 401 405 coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE); 402 - screens[0] = fastscreen; 406 + d_screens[0] = fastscreen; 403 407 #else 404 408 // Don't know if this will fit in other IRAMs 405 - screens[0] = malloc (SCREENWIDTH * SCREENHEIGHT * sizeof(unsigned char)); 409 + d_screens[0] = malloc (SCREENWIDTH * SCREENHEIGHT * sizeof(unsigned char)); 406 410 #endif 407 411 }
+2 -2
apps/plugins/doom/r_draw.c
··· 573 573 574 574 viewwindowy = width==SCREENWIDTH ? 0 : (SCREENHEIGHT-(ST_SCALED_HEIGHT-1)-height)>>1; 575 575 576 - topleft = screens[0] + viewwindowy*SCREENWIDTH + viewwindowx; 576 + topleft = d_screens[0] + viewwindowy*SCREENWIDTH + viewwindowx; 577 577 578 578 // Preclaculate all row offsets. 579 579 // CPhipps - merge viewwindowx into here ··· 627 627 628 628 void R_VideoErase(unsigned ofs, int count) 629 629 { 630 - memcpy(screens[0]+ofs, screens[1]+ofs, count); // LFB copy. 630 + memcpy(d_screens[0]+ofs, d_screens[1]+ofs, count); // LFB copy. 631 631 } 632 632 633 633 //
+2 -2
apps/plugins/doom/st_stuff.c
··· 1148 1148 veryfirsttime = 0; 1149 1149 ST_loadData(); 1150 1150 // proff 08/18/98: Changed for high-res 1151 - screens[4] = Z_Malloc(SCREENWIDTH*(ST_SCALED_HEIGHT+1), PU_STATIC, 0); 1152 - // screens[4] = Z_Malloc(ST_WIDTH*ST_HEIGHT, PU_STATIC, 0); 1151 + d_screens[4] = Z_Malloc(SCREENWIDTH*(ST_SCALED_HEIGHT+1), PU_STATIC, 0); 1152 + // d_screens[4] = Z_Malloc(ST_WIDTH*ST_HEIGHT, PU_STATIC, 0); 1153 1153 }
+16 -16
apps/plugins/doom/v_video.c
··· 44 44 #include "m_swap.h" 45 45 #include "rockmacros.h" 46 46 // Each screen is [SCREENWIDTH*SCREENHEIGHT]; 47 - byte *screens[6] IBSS_ATTR; 47 + byte *d_screens[6] IBSS_ATTR; 48 48 int dirtybox[4]; 49 49 50 50 /* jff 4/24/98 initialize this at runtime */ ··· 239 239 240 240 V_MarkRect (destx, desty, width, height); 241 241 242 - src = screens[srcscrn]+SCREENWIDTH*srcy+srcx; 243 - dest = screens[destscrn]+SCREENWIDTH*desty+destx; 242 + src = d_screens[srcscrn]+SCREENWIDTH*srcy+srcx; 243 + dest = d_screens[destscrn]+SCREENWIDTH*desty+destx; 244 244 245 245 for ( ; height>0 ; height--) 246 246 { ··· 294 294 if (!scrn) 295 295 V_MarkRect (x, y, width, height); 296 296 297 - dest = screens[scrn] + y*SCREENWIDTH+x; 297 + dest = d_screens[scrn] + y*SCREENWIDTH+x; 298 298 // x & y no longer needed 299 299 300 300 while (height--) { ··· 308 308 } else { 309 309 V_MarkRect (x, y, width, height); 310 310 311 - dest = screens[scrn] + y*SCREENWIDTH+x; 311 + dest = d_screens[scrn] + y*SCREENWIDTH+x; 312 312 313 313 while (height--) { 314 314 memcpy (dest, src, width); ··· 369 369 I_Error ("V_GetBlock: Bad arguments"); 370 370 #endif 371 371 372 - src = screens[scrn] + y*SCREENWIDTH+x; 372 + src = d_screens[scrn] + y*SCREENWIDTH+x; 373 373 374 374 while (height--) 375 375 { ··· 394 394 #define PREALLOCED_SCREENS 2 395 395 396 396 // CPhipps - no point in "stick these in low dos memory on PCs" anymore 397 - // Allocate the screens individually, so I_InitGraphics can release screens[0] 397 + // Allocate the screens individually, so I_InitGraphics can release d_screens[0] 398 398 // if e.g. it wants a MitSHM buffer instead 399 399 400 400 for (i=0 ; i<PREALLOCED_SCREENS ; i++) 401 - screens[i] = calloc(SCREENWIDTH*SCREENHEIGHT, 1); 401 + d_screens[i] = calloc(SCREENWIDTH*SCREENHEIGHT, 1); 402 402 for (; i<4; i++) // Clear the rest (paranoia) 403 - screens[i] = NULL; 403 + d_screens[i] = NULL; 404 404 } 405 405 406 406 // ··· 448 448 if (!(flags & VPT_STRETCH)) { 449 449 unsigned int col; 450 450 const column_t *column; 451 - byte *desttop = screens[scrn]+y*SCREENWIDTH+x; 451 + byte *desttop = d_screens[scrn]+y*SCREENWIDTH+x; 452 452 unsigned int w = SHORT(patch->width); 453 453 454 454 if (!scrn) ··· 544 544 V_MarkRect ( stretchx, stretchy, (SHORT( patch->width ) * DX ) >> 16, 545 545 (SHORT( patch->height) * DY ) >> 16 ); 546 546 547 - desttop = screens[scrn] + stretchy * SCREENWIDTH + stretchx; 547 + desttop = d_screens[scrn] + stretchy * SCREENWIDTH + stretchx; 548 548 549 549 for ( col = 0; col <= w; x++, col+=DXI, desttop++ ) { 550 550 const column_t *column; ··· 640 640 enum patch_translation_e flags, 641 641 unsigned short* width, unsigned short* height) 642 642 { 643 - byte *oldscr = screens[1]; 643 + byte *oldscr = d_screens[1]; 644 644 byte *block; 645 645 const patch_t *patch; 646 646 647 - screens[1] = calloc(SCREENWIDTH*SCREENHEIGHT, 1); 647 + d_screens[1] = calloc(SCREENWIDTH*SCREENHEIGHT, 1); 648 648 649 649 patch = W_CacheLumpName(name); 650 650 V_DrawMemPatch(SHORT(patch->leftoffset), SHORT(patch->topoffset), ··· 662 662 V_GetBlock(0, 0, 1, *width, *height, 663 663 block = malloc((long)(*width) * (*height))); 664 664 665 - free(screens[1]); 666 - screens[1] = oldscr; 665 + free(d_screens[1]); 666 + d_screens[1] = oldscr; 667 667 return block; 668 668 } 669 669 #endif /* GL_DOOM */ ··· 691 691 #ifndef GL_DOOM 692 692 void V_FillRect(int scrn, int x, int y, int width, int height, byte colour) 693 693 { 694 - byte* dest = screens[scrn] + x + y*SCREENWIDTH; 694 + byte* dest = d_screens[scrn] + x + y*SCREENWIDTH; 695 695 while (height--) { 696 696 memset(dest, colour, width); 697 697 dest += SCREENWIDTH;
+4 -4
apps/plugins/doom/v_video.h
··· 72 72 73 73 #define CR_DEFAULT CR_RED /* default value for out of range colors */ 74 74 75 - extern byte *screens[6]; 75 + extern byte *d_screens[6]; 76 76 extern int dirtybox[4]; 77 77 extern const byte gammatable[5][256]; 78 78 extern int usegamma; ··· 173 173 // CPhipps - function to plot a pixel 174 174 175 175 #ifndef GL_DOOM 176 - #define V_PlotPixel(s,x,y,c) screens[s][x+SCREENWIDTH*y]=c 176 + #define V_PlotPixel(s,x,y,c) d_screens[s][x+SCREENWIDTH*y]=c 177 177 #endif 178 178 179 - #define V_AllocScreen(scrn) screens[scrn] = malloc(SCREENWIDTH*SCREENHEIGHT) 180 - #define V_FreeScreen(scrn) free(screens[scrn]); screens[scrn] = NULL 179 + #define V_AllocScreen(scrn) d_screens[scrn] = malloc(SCREENWIDTH*SCREENHEIGHT) 180 + #define V_FreeScreen(scrn) free(d_screens[scrn]); d_screens[scrn] = NULL 181 181 182 182 #ifdef GL_DOOM 183 183 #include "gl_struct.h"
+447
apps/plugins/text_editor.c
··· 1 + /*************************************************************************** 2 + * __________ __ ___. 3 + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 + * \/ \/ \/ \/ \/ 8 + * $Id$ 9 + * 10 + * Copyright (C) 2006 Jonathan Gordon 11 + * 12 + * All files in this archive are subject to the GNU General Public License. 13 + * See the file COPYING in the source tree root for full license agreement. 14 + * 15 + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 16 + * KIND, either express or implied. 17 + * 18 + ****************************************************************************/ 19 + #include "plugin.h" 20 + /* button definitions, every keypad must only have select,menu and cancel */ 21 + #if CONFIG_KEYPAD == RECORDER_PAD 22 + #define TEXT_EDITOR_SELECT BUTTON_PLAY 23 + #define TEXT_EDITOR_CANCEL BUTTON_OFF 24 + #define TEXT_EDITOR_ITEM_MENU BUTTON_F1 25 + 26 + #elif CONFIG_KEYPAD == ONDIO_PAD 27 + #define TEXT_EDITOR_SELECT_PRE BUTTON_MENU 28 + #define TEXT_EDITOR_SELECT (BUTTON_MENU|BUTTON_REL) 29 + #define TEXT_EDITOR_CANCEL BUTTON_OFF 30 + #define TEXT_EDITOR_ITEM_MENU BUTTON_MENU|BUTTON_REPEAT 31 + 32 + #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD) 33 + #define TEXT_EDITOR_SELECT BUTTON_SELECT 34 + #define TEXT_EDITOR_CANCEL BUTTON_OFF 35 + #define TEXT_EDITOR_DELETE BUTTON_REC 36 + #define TEXT_EDITOR_ITEM_MENU BUTTON_MODE 37 + 38 + #elif (CONFIG_KEYPAD == IPOD_3G_PAD) || (CONFIG_KEYPAD == IPOD_4G_PAD) 39 + #define TEXT_EDITOR_SELECT_PRE BUTTON_SELECT 40 + #define TEXT_EDITOR_SELECT ( BUTTON_SELECT | BUTTON_REL) 41 + #define TEXT_EDITOR_CANCEL_PRE BUTTON_SELECT 42 + #define TEXT_EDITOR_CANCEL (BUTTON_SELECT | BUTTON_MENU) 43 + #define TEXT_EDITOR_DELETE (BUTTON_LEFT) 44 + #define TEXT_EDITOR_ITEM_MENU (BUTTON_MENU) 45 + 46 + #elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD 47 + 48 + #elif CONFIG_KEYPAD == IAUDIO_X5_PAD 49 + #define TEXT_EDITOR_SELECT BUTTON_SELECT 50 + #define TEXT_EDITOR_CANCEL BUTTON_POWER 51 + #define TEXT_EDITOR_ITEM_MENU BUTTON_PLAY 52 + 53 + #elif CONFIG_KEYPAD == GIGABEAT_PAD 54 + 55 + #else 56 + #error TEXT_EDITOR: Unsupported keypad 57 + #endif 58 + 59 + #define MAX_LINE_LEN 128 60 + 61 + #if PLUGIN_BUFFER_SIZE > 0x45000 62 + #define MAX_LINES 2048 63 + #else 64 + #define MAX_LINES 128 65 + #endif 66 + 67 + PLUGIN_HEADER 68 + static struct plugin_api* rb; 69 + 70 + struct LineStruct { 71 + char line[MAX_LINE_LEN]; 72 + int prev; /* index to prev item, or -1 */ 73 + int next; /* index to next item, or -1 */ 74 + }; 75 + 76 + struct LineStruct lines[MAX_LINES]; 77 + int line_count = 0; 78 + int first = -1, last = -1; 79 + int indicies[MAX_LINES]; 80 + /**************************** stuff for the linked lists ***************/ 81 + int build_indicies(void) 82 + { 83 + int i=0, index = first; 84 + struct LineStruct *line; 85 + if (first==-1) 86 + return 0; 87 + while (i<line_count) 88 + { 89 + indicies[i++] = index; 90 + DEBUGF("%d,",index); 91 + line = &lines[index]; 92 + index = line->next; 93 + 94 + } 95 + DEBUGF("\n"); 96 + return 1; 97 + } 98 + 99 + int find_first_free(int start) 100 + { 101 + int i; 102 + if ((start <0) || (start >=MAX_LINES)) 103 + start = 0; 104 + i = start; 105 + do 106 + { 107 + if (lines[i].line[0] == '\0') 108 + return i; 109 + i = (i+1)%MAX_LINES; 110 + } while (i!=start); 111 + return -1; 112 + } 113 + 114 + int add_line(char *line, int idx_after_me) 115 + { 116 + struct LineStruct *temp; 117 + int next; 118 + int this_idx = find_first_free(idx_after_me); 119 + if ((line_count >= MAX_LINES) || (this_idx == -1)) 120 + return -1; 121 + DEBUGF("line:%s ,idx_after_me=%d\n",line,idx_after_me); 122 + if (idx_after_me == -1) /* add as the first item */ 123 + { 124 + rb->strcpy(lines[this_idx].line,line); 125 + lines[this_idx].prev = -1; 126 + if (first != -1) 127 + lines[first].prev = this_idx; 128 + lines[this_idx].next = first; 129 + first = this_idx; 130 + if (last == idx_after_me) 131 + last = this_idx; 132 + line_count++; 133 + return 1; 134 + } 135 + 136 + temp = &lines[idx_after_me]; 137 + next = lines[idx_after_me].next; 138 + temp->next = this_idx; 139 + rb->strcpy(lines[this_idx].line,line); 140 + temp = &lines[this_idx]; 141 + temp->next = next; 142 + temp->prev = idx_after_me; 143 + if (last == idx_after_me) 144 + last = this_idx; 145 + if (first == -1) 146 + first = this_idx; 147 + line_count ++; 148 + return this_idx; 149 + } 150 + 151 + void del_line(int line) 152 + { 153 + int idx_prev, idx_next; 154 + idx_prev = (&lines[line])->prev; 155 + idx_next = (&lines[line])->next; 156 + lines[line].line[0] = '\0'; 157 + lines[idx_prev].next = idx_next; 158 + lines[idx_next].prev = idx_prev; 159 + line_count --; 160 + } 161 + char *list_get_name_cb(int selected_item,void* data,char* buf) 162 + { 163 + (void)data; 164 + rb->strcpy(buf,lines[indicies[selected_item]].line); 165 + return buf; 166 + } 167 + char filename[1024]; 168 + void save_changes(int overwrite) 169 + { 170 + int fd; 171 + int i; 172 + 173 + if (!filename[0] || overwrite) 174 + { 175 + rb->strcpy(filename,"/"); 176 + rb->kbd_input(filename,1024); 177 + } 178 + 179 + fd = rb->open(filename,O_WRONLY|O_CREAT); 180 + if (!fd) 181 + { 182 + rb->splash(HZ*2,1,"Changes NOT saved"); 183 + return; 184 + } 185 + 186 + rb->lcd_clear_display(); 187 + build_indicies(); 188 + for (i=0;i<line_count;i++) 189 + { 190 + rb->fdprintf(fd,"%s\n",lines[indicies[i]].line); 191 + } 192 + 193 + rb->close(fd); 194 + } 195 + 196 + void setup_lists(struct gui_synclist *lists) 197 + { 198 + build_indicies(); 199 + rb->gui_synclist_init(lists,list_get_name_cb,0); 200 + rb->gui_synclist_set_icon_callback(lists,NULL); 201 + rb->gui_synclist_set_nb_items(lists,line_count); 202 + rb->gui_synclist_limit_scroll(lists,true); 203 + rb->gui_synclist_select_item(lists, 0); 204 + rb->gui_synclist_draw(lists); 205 + } 206 + enum { 207 + MENU_RET_SAVE = -1, 208 + MENU_RET_NO_UPDATE, 209 + MENU_RET_UPDATE, 210 + }; 211 + int do_item_menu(int cur_sel, char* copy_buffer) 212 + { 213 + int m, ret = 0; 214 + static const struct menu_item items[] = { 215 + { "Cut", NULL }, 216 + { "Copy", NULL }, 217 + { "", NULL }, 218 + { "Insert Above", NULL }, 219 + { "Insert Below", NULL }, 220 + { "", NULL }, 221 + { "Cat To Above",NULL }, 222 + /* { "Split Line",NULL }, */ 223 + { "", NULL }, 224 + { "Save", NULL }, 225 + }; 226 + m = rb->menu_init(items, sizeof(items) / sizeof(*items), 227 + NULL, NULL, NULL, NULL); 228 + 229 + switch (rb->menu_show(m)) 230 + { 231 + case 0: /* cut */ 232 + rb->strcpy(copy_buffer,lines[indicies[cur_sel]].line); 233 + del_line(indicies[cur_sel]); 234 + ret = MENU_RET_UPDATE; 235 + break; 236 + case 1: /* copy */ 237 + rb->strcpy(copy_buffer,lines[indicies[cur_sel]].line); 238 + ret = MENU_RET_NO_UPDATE; 239 + break; 240 + case 2: /* blank */ 241 + ret = MENU_RET_NO_UPDATE; 242 + break; 243 + 244 + case 3: /* insert above */ 245 + if (!rb->kbd_input(copy_buffer,MAX_LINE_LEN)) 246 + { 247 + add_line(copy_buffer,lines[indicies[cur_sel]].prev); 248 + copy_buffer[0]='\0'; 249 + ret = MENU_RET_UPDATE; 250 + } 251 + break; 252 + case 4: /* insert below */ 253 + if (!rb->kbd_input(copy_buffer,MAX_LINE_LEN)) 254 + { 255 + add_line(copy_buffer,indicies[cur_sel]); 256 + copy_buffer[0]='\0'; 257 + ret = MENU_RET_UPDATE; 258 + } 259 + break; 260 + case 5: /* blank */ 261 + ret = MENU_RET_NO_UPDATE; 262 + break; 263 + case 6: /* cat to above */ 264 + if (cur_sel>0) 265 + { 266 + rb->strcat(lines[indicies[cur_sel-1]].line,lines[indicies[cur_sel]].line); 267 + del_line(indicies[cur_sel]); 268 + ret = MENU_RET_UPDATE; 269 + } 270 + break; 271 + /* case 7: // split line */ 272 + 273 + case 7: /* save */ 274 + ret = MENU_RET_SAVE; 275 + break; 276 + default: 277 + ret = MENU_RET_NO_UPDATE; 278 + break; 279 + } 280 + rb->menu_exit(m); 281 + return ret; 282 + } 283 + /* this is the plugin entry point */ 284 + enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 285 + { 286 + int fd; 287 + char temp_line[MAX_LINE_LEN]; 288 + 289 + struct gui_synclist lists; 290 + bool exit = false; 291 + int button, last_button = BUTTON_NONE; 292 + bool changed = false; 293 + int cur_sel; 294 + char copy_buffer[MAX_LINE_LEN]; copy_buffer[0]='\0'; 295 + 296 + rb = api; 297 + if (parameter) 298 + { 299 + rb->strcpy(filename,(char*)parameter); 300 + fd = rb->open(filename,O_RDONLY); 301 + if (fd<0) 302 + { 303 + rb->splash(HZ*2,true,"Couldnt open file: %s",(char*)parameter); 304 + return PLUGIN_ERROR; 305 + } 306 + /* read in the file */ 307 + while (rb->read_line(fd,temp_line,MAX_LINE_LEN)) 308 + { 309 + if (add_line(temp_line,last) < 0) 310 + { 311 + rb->splash(HZ*2,true,"Error reading file: %s",(char*)parameter); 312 + rb->close(fd); 313 + return PLUGIN_ERROR; 314 + } 315 + } 316 + rb->close(fd); 317 + } 318 + else filename[0] = '\0'; 319 + /* now dump it in the list */ 320 + setup_lists(&lists); 321 + while (!exit) 322 + { 323 + rb->gui_synclist_draw(&lists); 324 + cur_sel = rb->gui_synclist_get_sel_pos(&lists); 325 + button = rb->button_get(true); 326 + if (rb->gui_synclist_do_button(&lists,button)) 327 + continue; 328 + switch (button) 329 + { 330 + case TEXT_EDITOR_SELECT: 331 + { 332 + #ifdef TEXT_EDITOR_SELECT_PRE 333 + if (last_button != TEXT_EDITOR_SELECT_PRE) 334 + break; 335 + #endif 336 + char buf[MAX_LINE_LEN];buf[0]='\0'; 337 + 338 + if (line_count) 339 + rb->strcpy(buf,lines[indicies[cur_sel]].line); 340 + if (!rb->kbd_input(buf,MAX_LINE_LEN)) 341 + { 342 + if (line_count) 343 + rb->strcpy(lines[indicies[cur_sel]].line,buf); 344 + else { add_line(buf, first); setup_lists(&lists); } 345 + changed = true; 346 + } 347 + } 348 + break; 349 + #ifdef TEXT_EDITOR_DELETE 350 + case TEXT_EDITOR_DELETE: 351 + #ifdef TEXT_EDITOR_DELETE_PRE 352 + if (last_button != TEXT_EDITOR_DELETE_PRE) 353 + break; 354 + #endif 355 + if (!line_count) break; 356 + rb->strcpy(copy_buffer,lines[indicies[cur_sel]].line); 357 + del_line(indicies[cur_sel]); 358 + changed = true; 359 + setup_lists(&lists); 360 + break; 361 + #endif 362 + #ifdef TEXT_EDITOR_ITEM_MENU 363 + case TEXT_EDITOR_ITEM_MENU: 364 + #ifdef TEXT_EDITOR_RC_ITEM_MENU 365 + case TEXT_EDITOR_RC_ITEM_MENU: 366 + #endif 367 + #ifdef TEXT_EDITOR_ITEM_MENU_PRE 368 + if (lastbutton != TEXT_EDITOR_ITEM_MENU_PRE 369 + #ifdef TEXT_EDITOR_RC_ITEM_MENU_PRE 370 + && lastbutton != TEXT_EDITOR_RC_ITEM_MENU_PRE 371 + #endif 372 + ) 373 + break; 374 + #endif 375 + { /* do the item menu */ 376 + switch (do_item_menu(cur_sel, copy_buffer)) 377 + { 378 + case MENU_RET_SAVE: 379 + save_changes(1); 380 + changed = false; 381 + break; 382 + case MENU_RET_UPDATE: 383 + changed = true; 384 + setup_lists(&lists); 385 + break; 386 + case MENU_RET_NO_UPDATE: 387 + break; 388 + } 389 + } 390 + break; 391 + #endif /* TEXT_EDITOR_ITEM_MENU */ 392 + case TEXT_EDITOR_CANCEL: 393 + #ifdef TEXT_EDITOR_CANCEL_PRE 394 + if (last_button != TEXT_EDITOR_CANCEL_PRE) 395 + break; 396 + #endif 397 + if (changed) 398 + { 399 + int m; 400 + int result; 401 + 402 + static const struct menu_item items[] = { 403 + { "Return", NULL }, 404 + { " ", NULL }, 405 + { "Save Changes", NULL }, 406 + { "Save As...", NULL }, 407 + { " ", NULL }, 408 + { "Save and Exit", NULL }, 409 + { "Ignore Changes and Exit", NULL }, 410 + }; 411 + 412 + m = rb->menu_init(items, sizeof(items) / sizeof(*items), 413 + NULL, NULL, NULL, NULL); 414 + 415 + result=rb->menu_show(m); 416 + 417 + switch (result) 418 + { 419 + case 0: 420 + break; 421 + case 2: //save to disk 422 + save_changes(1); 423 + changed = 0; 424 + break; 425 + case 3: 426 + save_changes(0); 427 + changed = 0; 428 + break; 429 + 430 + case 5: 431 + save_changes(1); 432 + exit=1; 433 + break; 434 + case 6: 435 + exit=1; 436 + break; 437 + } 438 + rb->menu_exit(m); 439 + } 440 + else exit=1; 441 + break; 442 + } 443 + last_button = button; 444 + } 445 + 446 + return PLUGIN_OK; 447 + }
+3 -1
apps/plugins/viewers.config
··· 1 1 ch8,viewers/chip8,70 70 7f 7f 70 70 2 2 txt,viewers/viewer,55 55 55 55 55 55 3 3 nfo,viewers/viewer,55 55 55 55 55 55 4 + txt,rocks/text_editor, 55 55 55 55 55 55 4 5 jpg,viewers/jpeg,18 24 3C 3C 24 18 5 6 ucl,viewers/rockbox_flash,2A 7F 41 41 7F 2A 6 7 rvf,viewers/video,5D 7F 5D 7F 5D 7F ··· 15 16 ss,rocks/sudoku, 55 55 55 55 55 55 16 17 wav,viewers/wav2wv, 00 00 00 00 00 00 17 18 wav,viewers/mp3_encoder, 00 00 00 00 00 00 18 - wav,viewers/wavplay,60 7F 05 35 3F 00 19 + wav,viewers/wavplay,60 7F 05 35 3F 00 20 +