diff options
Diffstat (limited to 'apps/plugins/text_editor.c')
-rw-r--r-- | apps/plugins/text_editor.c | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/apps/plugins/text_editor.c b/apps/plugins/text_editor.c index f18e7134e3..acd82b8794 100644 --- a/apps/plugins/text_editor.c +++ b/apps/plugins/text_editor.c | |||
@@ -32,17 +32,23 @@ static int last_action_line = 0; | |||
32 | static int last_char_index = 0; | 32 | static int last_char_index = 0; |
33 | static bool audio_buf = false; | 33 | static bool audio_buf = false; |
34 | 34 | ||
35 | static char temp_line[MAX_LINE_LEN]; | ||
36 | static char copy_buffer[MAX_LINE_LEN]; | ||
37 | static char filename[MAX_PATH]; | ||
38 | static char eol[3]; | ||
39 | static bool newfile; | ||
40 | |||
35 | #define ACTION_INSERT 0 | 41 | #define ACTION_INSERT 0 |
36 | #define ACTION_GET 1 | 42 | #define ACTION_GET 1 |
37 | #define ACTION_REMOVE 2 | 43 | #define ACTION_REMOVE 2 |
38 | #define ACTION_UPDATE 3 | 44 | #define ACTION_UPDATE 3 |
39 | #define ACTION_CONCAT 4 | 45 | #define ACTION_CONCAT 4 |
40 | 46 | ||
41 | char* _do_action(int action, char* str, int line); | 47 | static char* _do_action(int action, char* str, int line); |
42 | #ifndef HAVE_ADJUSTABLE_CPU_FREQ | 48 | #ifndef HAVE_ADJUSTABLE_CPU_FREQ |
43 | #define do_action _do_action | 49 | #define do_action _do_action |
44 | #else | 50 | #else |
45 | char* do_action(int action, char* str, int line) | 51 | static char* do_action(int action, char* str, int line) |
46 | { | 52 | { |
47 | char *r; | 53 | char *r; |
48 | rb->cpu_boost(1); | 54 | rb->cpu_boost(1); |
@@ -52,7 +58,7 @@ char* do_action(int action, char* str, int line) | |||
52 | } | 58 | } |
53 | #endif | 59 | #endif |
54 | 60 | ||
55 | char* _do_action(int action, char* str, int line) | 61 | static char* _do_action(int action, char* str, int line) |
56 | { | 62 | { |
57 | int len, lennew; | 63 | int len, lennew; |
58 | int i=0,c=0; | 64 | int i=0,c=0; |
@@ -127,10 +133,7 @@ static const char* list_get_name_cb(int selected_item, void* data, | |||
127 | return buf; | 133 | return buf; |
128 | } | 134 | } |
129 | 135 | ||
130 | char filename[MAX_PATH]; | 136 | static void get_eol_string(char* fn) |
131 | char eol[3]; | ||
132 | bool newfile; | ||
133 | void get_eol_string(char* fn) | ||
134 | { | 137 | { |
135 | int fd; | 138 | int fd; |
136 | char t; | 139 | char t; |
@@ -163,7 +166,7 @@ void get_eol_string(char* fn) | |||
163 | return; | 166 | return; |
164 | } | 167 | } |
165 | 168 | ||
166 | bool save_changes(int overwrite) | 169 | static bool save_changes(int overwrite) |
167 | { | 170 | { |
168 | int fd; | 171 | int fd; |
169 | int i; | 172 | int i; |
@@ -185,10 +188,6 @@ bool save_changes(int overwrite) | |||
185 | return false; | 188 | return false; |
186 | } | 189 | } |
187 | 190 | ||
188 | if (!overwrite) | ||
189 | /* current directory may have changed */ | ||
190 | rb->reload_directory(); | ||
191 | |||
192 | rb->lcd_clear_display(); | 191 | rb->lcd_clear_display(); |
193 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | 192 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
194 | rb->cpu_boost(1); | 193 | rb->cpu_boost(1); |
@@ -201,11 +200,16 @@ bool save_changes(int overwrite) | |||
201 | rb->cpu_boost(0); | 200 | rb->cpu_boost(0); |
202 | #endif | 201 | #endif |
203 | rb->close(fd); | 202 | rb->close(fd); |
203 | |||
204 | if (newfile || !overwrite) | ||
205 | /* current directory may have changed */ | ||
206 | rb->reload_directory(); | ||
207 | |||
204 | newfile = false; | 208 | newfile = false; |
205 | return true; | 209 | return true; |
206 | } | 210 | } |
207 | 211 | ||
208 | void setup_lists(struct gui_synclist *lists, int sel) | 212 | static void setup_lists(struct gui_synclist *lists, int sel) |
209 | { | 213 | { |
210 | rb->gui_synclist_init(lists,list_get_name_cb,0, false, 1, NULL); | 214 | rb->gui_synclist_init(lists,list_get_name_cb,0, false, 1, NULL); |
211 | rb->gui_synclist_set_icon_callback(lists,NULL); | 215 | rb->gui_synclist_set_icon_callback(lists,NULL); |
@@ -220,7 +224,7 @@ enum { | |||
220 | MENU_RET_NO_UPDATE, | 224 | MENU_RET_NO_UPDATE, |
221 | MENU_RET_UPDATE, | 225 | MENU_RET_UPDATE, |
222 | }; | 226 | }; |
223 | int do_item_menu(int cur_sel, char* copy_buffer) | 227 | static int do_item_menu(int cur_sel) |
224 | { | 228 | { |
225 | int ret = MENU_RET_NO_UPDATE; | 229 | int ret = MENU_RET_NO_UPDATE; |
226 | MENUITEM_STRINGLIST(menu, "Line Options", NULL, | 230 | MENUITEM_STRINGLIST(menu, "Line Options", NULL, |
@@ -289,7 +293,7 @@ int do_item_menu(int cur_sel, char* copy_buffer) | |||
289 | || (c>='0' && c<= '9')) | 293 | || (c>='0' && c<= '9')) |
290 | #define hex2dec(c) (((c) >= '0' && ((c) <= '9')) ? (toupper(c)) - '0' : \ | 294 | #define hex2dec(c) (((c) >= '0' && ((c) <= '9')) ? (toupper(c)) - '0' : \ |
291 | (toupper(c)) - 'A' + 10) | 295 | (toupper(c)) - 'A' + 10) |
292 | int hex_to_rgb(const char* hex, int* color) | 296 | static int my_hex_to_rgb(const char* hex, int* color) |
293 | { int ok = 1; | 297 | { int ok = 1; |
294 | int i; | 298 | int i; |
295 | int red, green, blue; | 299 | int red, green, blue; |
@@ -319,14 +323,12 @@ int hex_to_rgb(const char* hex, int* color) | |||
319 | enum plugin_status plugin_start(const void* parameter) | 323 | enum plugin_status plugin_start(const void* parameter) |
320 | { | 324 | { |
321 | int fd; | 325 | int fd; |
322 | static char temp_line[MAX_LINE_LEN]; | ||
323 | 326 | ||
324 | struct gui_synclist lists; | 327 | struct gui_synclist lists; |
325 | bool exit = false; | 328 | bool exit = false; |
326 | int button; | 329 | int button; |
327 | bool changed = false; | 330 | bool changed = false; |
328 | int cur_sel=0; | 331 | int cur_sel=0; |
329 | static char copy_buffer[MAX_LINE_LEN]; | ||
330 | #ifdef HAVE_LCD_COLOR | 332 | #ifdef HAVE_LCD_COLOR |
331 | bool edit_colors_file = false; | 333 | bool edit_colors_file = false; |
332 | #endif | 334 | #endif |
@@ -418,7 +420,7 @@ enum plugin_status plugin_start(const void* parameter) | |||
418 | "Extension", "Colour"); | 420 | "Extension", "Colour"); |
419 | rb->strcpy(extension, name); | 421 | rb->strcpy(extension, name); |
420 | if (value) | 422 | if (value) |
421 | hex_to_rgb(value, &color); | 423 | my_hex_to_rgb(value, &color); |
422 | else | 424 | else |
423 | color = 0; | 425 | color = 0; |
424 | 426 | ||
@@ -465,8 +467,9 @@ enum plugin_status plugin_start(const void* parameter) | |||
465 | changed = true; | 467 | changed = true; |
466 | break; | 468 | break; |
467 | case ACTION_STD_MENU: | 469 | case ACTION_STD_MENU: |
468 | { /* do the item menu */ | 470 | { |
469 | switch (do_item_menu(cur_sel, copy_buffer)) | 471 | /* do the item menu */ |
472 | switch (do_item_menu(cur_sel)) | ||
470 | { | 473 | { |
471 | case MENU_RET_SAVE: | 474 | case MENU_RET_SAVE: |
472 | if(save_changes(1)) | 475 | if(save_changes(1)) |