summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/plugins/text_viewer/readme.txt4
-rw-r--r--apps/plugins/text_viewer/tv_menu.c10
-rw-r--r--apps/plugins/text_viewer/tv_preferences.c2
-rw-r--r--apps/plugins/text_viewer/tv_preferences.h2
-rw-r--r--apps/plugins/text_viewer/tv_settings.c16
-rw-r--r--apps/plugins/text_viewer/tv_text_processor.c18
6 files changed, 34 insertions, 18 deletions
diff --git a/apps/plugins/text_viewer/readme.txt b/apps/plugins/text_viewer/readme.txt
index ebde6d7f75..a7e6e790ba 100644
--- a/apps/plugins/text_viewer/readme.txt
+++ b/apps/plugins/text_viewer/readme.txt
@@ -28,7 +28,7 @@ Difference between viewer.rock
28 - If the next line is a blank line or spaces only line, this line breaks. 28 - If the next line is a blank line or spaces only line, this line breaks.
29 29
30 [reflow] 30 [reflow]
31 - indent changes two spaces. 31 - indent changes is two spaces (changable in the settings).
32 - supports the player which does not define HAVE_LCD_BITMAP. 32 - supports the player which does not define HAVE_LCD_BITMAP.
33 33
34 [alignment] 34 [alignment]
@@ -44,8 +44,6 @@ TODO list
44 44
45 - add History feature. 45 - add History feature.
46 46
47 - when the line_mode is reflow, allow to specify indent spaces.
48
49 - draw images that are linked to the text. (<img src="...">) 47 - draw images that are linked to the text. (<img src="...">)
50 48
51 - play audios that are linked to the text. (<audio src="...">) 49 - play audios that are linked to the text. (<audio src="...">)
diff --git a/apps/plugins/text_viewer/tv_menu.c b/apps/plugins/text_viewer/tv_menu.c
index 7c27a3d8c1..ce85dc9325 100644
--- a/apps/plugins/text_viewer/tv_menu.c
+++ b/apps/plugins/text_viewer/tv_menu.c
@@ -315,6 +315,12 @@ static bool tv_font_setting(void)
315} 315}
316#endif 316#endif
317 317
318static bool tv_indent_spaces_setting(void)
319{
320 return rb->set_int("Indent Spaces", "", UNIT_INT,
321 &new_prefs.indent_spaces, NULL, 1, 0, 5, NULL);
322}
323
318MENUITEM_FUNCTION(encoding_item, 0, "Encoding", tv_encoding_setting, 324MENUITEM_FUNCTION(encoding_item, 0, "Encoding", tv_encoding_setting,
319 NULL, NULL, Icon_NOICON); 325 NULL, NULL, Icon_NOICON);
320MENUITEM_FUNCTION(word_wrap_item, 0, "Word Wrap", tv_word_wrap_setting, 326MENUITEM_FUNCTION(word_wrap_item, 0, "Word Wrap", tv_word_wrap_setting,
@@ -333,6 +339,8 @@ MENUITEM_FUNCTION(footer_item, 0, "Show Footer", tv_footer_setting,
333MENUITEM_FUNCTION(font_item, 0, "Font", tv_font_setting, 339MENUITEM_FUNCTION(font_item, 0, "Font", tv_font_setting,
334 NULL, NULL, Icon_NOICON); 340 NULL, NULL, Icon_NOICON);
335#endif 341#endif
342MENUITEM_FUNCTION(indent_spaces_item, 0, "Indent Spaces", tv_indent_spaces_setting,
343 NULL, NULL, Icon_NOICON);
336 344
337MAKE_MENU(option_menu, "Viewer Options", NULL, Icon_NOICON, 345MAKE_MENU(option_menu, "Viewer Options", NULL, Icon_NOICON,
338 &encoding_item, &word_wrap_item, &line_mode_item, &windows_item, 346 &encoding_item, &word_wrap_item, &line_mode_item, &windows_item,
@@ -340,7 +348,7 @@ MAKE_MENU(option_menu, "Viewer Options", NULL, Icon_NOICON,
340#ifdef HAVE_LCD_BITMAP 348#ifdef HAVE_LCD_BITMAP
341 &header_item, &footer_item, &font_item, 349 &header_item, &footer_item, &font_item,
342#endif 350#endif
343 &scroll_menu); 351 &scroll_menu, &indent_spaces_item);
344 352
345static enum tv_menu_result tv_options_menu(void) 353static enum tv_menu_result tv_options_menu(void)
346{ 354{
diff --git a/apps/plugins/text_viewer/tv_preferences.c b/apps/plugins/text_viewer/tv_preferences.c
index 8b4c91a1cb..d317508936 100644
--- a/apps/plugins/text_viewer/tv_preferences.c
+++ b/apps/plugins/text_viewer/tv_preferences.c
@@ -52,6 +52,7 @@ static void tv_notify_change_preferences(const struct tv_preferences *oldp,
52 (oldp->horizontal_scrollbar != newp->horizontal_scrollbar) || 52 (oldp->horizontal_scrollbar != newp->horizontal_scrollbar) ||
53 (oldp->vertical_scrollbar != newp->vertical_scrollbar) || 53 (oldp->vertical_scrollbar != newp->vertical_scrollbar) ||
54 (oldp->encoding != newp->encoding) || 54 (oldp->encoding != newp->encoding) ||
55 (oldp->indent_spaces != newp->indent_spaces) ||
55#ifdef HAVE_LCD_BITMAP 56#ifdef HAVE_LCD_BITMAP
56 (oldp->header_mode != newp->header_mode) || 57 (oldp->header_mode != newp->header_mode) ||
57 (oldp->footer_mode != newp->footer_mode) || 58 (oldp->footer_mode != newp->footer_mode) ||
@@ -113,6 +114,7 @@ void tv_set_default_preferences(struct tv_preferences *p)
113#endif 114#endif
114 p->autoscroll_speed = 1; 115 p->autoscroll_speed = 1;
115 p->narrow_mode = NM_PAGE; 116 p->narrow_mode = NM_PAGE;
117 p->indent_spaces = 2;
116 /* Set codepage to system default */ 118 /* Set codepage to system default */
117 p->encoding = rb->global_settings->default_codepage; 119 p->encoding = rb->global_settings->default_codepage;
118 p->file_name[0] = '\0'; 120 p->file_name[0] = '\0';
diff --git a/apps/plugins/text_viewer/tv_preferences.h b/apps/plugins/text_viewer/tv_preferences.h
index 645258c8a6..1e5c45309a 100644
--- a/apps/plugins/text_viewer/tv_preferences.h
+++ b/apps/plugins/text_viewer/tv_preferences.h
@@ -89,6 +89,8 @@ struct tv_preferences {
89 NM_TOP_BOTTOM, 89 NM_TOP_BOTTOM,
90 } narrow_mode; 90 } narrow_mode;
91 91
92 int indent_spaces;
93
92 unsigned char font_name[MAX_PATH]; 94 unsigned char font_name[MAX_PATH];
93#ifdef HAVE_LCD_BITMAP 95#ifdef HAVE_LCD_BITMAP
94 struct font *font; 96 struct font *font;
diff --git a/apps/plugins/text_viewer/tv_settings.c b/apps/plugins/text_viewer/tv_settings.c
index db27e8928a..6b16218523 100644
--- a/apps/plugins/text_viewer/tv_settings.c
+++ b/apps/plugins/text_viewer/tv_settings.c
@@ -49,7 +49,8 @@
49 * horizontal_scrollbar 1 49 * horizontal_scrollbar 1
50 * horizontal_scroll_mode 1 50 * horizontal_scroll_mode 1
51 * narrow_mode 1 51 * narrow_mode 1
52 * (reserved) 13 52 * indent_spaces 1
53 * (reserved) 12
53 * font name MAX_PATH 54 * font name MAX_PATH
54 */ 55 */
55 56
@@ -57,7 +58,7 @@
57#define TV_GLOBAL_SETTINGS_FILE VIEWERS_DIR "/tv_global.dat" 58#define TV_GLOBAL_SETTINGS_FILE VIEWERS_DIR "/tv_global.dat"
58 59
59#define TV_GLOBAL_SETTINGS_HEADER "\x54\x56\x47\x53" /* "TVGS" */ 60#define TV_GLOBAL_SETTINGS_HEADER "\x54\x56\x47\x53" /* "TVGS" */
60#define TV_GLOBAL_SETTINGS_VERSION 0x36 61#define TV_GLOBAL_SETTINGS_VERSION 0x37
61#define TV_GLOBAL_SETTINGS_HEADER_SIZE 5 62#define TV_GLOBAL_SETTINGS_HEADER_SIZE 5
62#define TV_GLOBAL_SETTINGS_FIRST_VERSION 0x31 63#define TV_GLOBAL_SETTINGS_FIRST_VERSION 0x31
63 64
@@ -90,7 +91,8 @@
90 * horizontal_scrollbar 1 91 * horizontal_scrollbar 1
91 * horizontal_scroll_mode 1 92 * horizontal_scroll_mode 1
92 * narrow_mode 1 93 * narrow_mode 1
93 * (reserved) 13 94 * indent_spaces 1
95 * (reserved) 12
94 * font name MAX_PATH 96 * font name MAX_PATH
95 * bookmark count 1 97 * bookmark count 1
96 * [1st bookmark] 98 * [1st bookmark]
@@ -112,7 +114,7 @@
112#define TV_SETTINGS_TMP_FILE VIEWERS_DIR "/tv_file.tmp" 114#define TV_SETTINGS_TMP_FILE VIEWERS_DIR "/tv_file.tmp"
113 115
114#define TV_SETTINGS_HEADER "\x54\x56\x53" /* "TVS" */ 116#define TV_SETTINGS_HEADER "\x54\x56\x53" /* "TVS" */
115#define TV_SETTINGS_VERSION 0x37 117#define TV_SETTINGS_VERSION 0x38
116#define TV_SETTINGS_HEADER_SIZE 4 118#define TV_SETTINGS_HEADER_SIZE 4
117#define TV_SETTINGS_FIRST_VERSION 0x32 119#define TV_SETTINGS_FIRST_VERSION 0x32
118 120
@@ -174,6 +176,11 @@ static bool tv_read_preferences(int pfd, int version, struct tv_preferences *pre
174 else 176 else
175 prefs->narrow_mode = NM_PAGE; 177 prefs->narrow_mode = NM_PAGE;
176 178
179 if (version > 5)
180 prefs->indent_spaces = *p++;
181 else
182 prefs->indent_spaces = 2;
183
177 rb->memcpy(prefs->font_name, buf + read_size - MAX_PATH, MAX_PATH); 184 rb->memcpy(prefs->font_name, buf + read_size - MAX_PATH, MAX_PATH);
178 185
179#ifdef HAVE_LCD_BITMAP 186#ifdef HAVE_LCD_BITMAP
@@ -204,6 +211,7 @@ static bool tv_write_preferences(int pfd, const struct tv_preferences *prefs)
204 *p++ = prefs->horizontal_scrollbar; 211 *p++ = prefs->horizontal_scrollbar;
205 *p++ = prefs->horizontal_scroll_mode; 212 *p++ = prefs->horizontal_scroll_mode;
206 *p++ = prefs->narrow_mode; 213 *p++ = prefs->narrow_mode;
214 *p++ = prefs->indent_spaces;
207 215
208 rb->memcpy(buf + 28, prefs->font_name, MAX_PATH); 216 rb->memcpy(buf + 28, prefs->font_name, MAX_PATH);
209 217
diff --git a/apps/plugins/text_viewer/tv_text_processor.c b/apps/plugins/text_viewer/tv_text_processor.c
index f99bfdfd4e..5e30f0b078 100644
--- a/apps/plugins/text_viewer/tv_text_processor.c
+++ b/apps/plugins/text_viewer/tv_text_processor.c
@@ -41,12 +41,6 @@ enum tv_text_type {
41 41
42#define TV_MAX_BLOCKS 5 42#define TV_MAX_BLOCKS 5
43 43
44/*
45 * number of spaces to indent first paragraph
46 * (this value uses the line mode is REFLOW only)
47 */
48#define TV_INDENT_SPACES 2
49
50static const struct tv_preferences *prefs; 44static const struct tv_preferences *prefs;
51static enum tv_text_type text_type = TV_TEXT_UNKNOWN; 45static enum tv_text_type text_type = TV_TEXT_UNKNOWN;
52 46
@@ -434,7 +428,7 @@ static int tv_parse_text(const unsigned char *src, unsigned short *ucs,
434 is_indent = false; 428 is_indent = false;
435 429
436 if (prefs->line_mode == REFLOW && is_indent) 430 if (prefs->line_mode == REFLOW && is_indent)
437 gw = tv_glyph_width(ch) * TV_INDENT_SPACES; 431 gw = tv_glyph_width(ch) * prefs->indent_spaces;
438 else 432 else
439 gw = tv_glyph_width(ch); 433 gw = tv_glyph_width(ch);
440 434
@@ -451,12 +445,13 @@ static int tv_parse_text(const unsigned char *src, unsigned short *ucs,
451 break; 445 break;
452 } 446 }
453 447
454 if (prefs->line_mode == REFLOW && is_indent) 448 if (prefs->line_mode != REFLOW || !is_indent)
449 ucs[chars++] = ch;
450 else
455 { 451 {
456 for (i = 1; i < TV_INDENT_SPACES; i++) 452 for (i = 0; i < prefs->indent_spaces; i++)
457 ucs[chars++] = ch; 453 ucs[chars++] = ch;
458 } 454 }
459 ucs[chars++] = ch;
460 455
461 if (tv_is_line_break_char(ch)) 456 if (tv_is_line_break_char(ch))
462 { 457 {
@@ -518,6 +513,9 @@ int tv_create_formed_text(const unsigned char *src, ssize_t bufsize,
518 tv_get_ucs(src, &ch); 513 tv_get_ucs(src, &ch);
519 is_indent = (tv_isspace(ch) && !is_break_line); 514 is_indent = (tv_isspace(ch) && !is_break_line);
520 515
516 if (is_indent && prefs->indent_spaces == 0 && (expand_extra_line = !expand_extra_line) == true)
517 return 0;
518
521 for (i = 0; i < block_count; i++) 519 for (i = 0; i < block_count; i++)
522 { 520 {
523 size += tv_parse_text(src + size, ucsbuf[i], &chars[i], is_indent); 521 size += tv_parse_text(src + size, ucsbuf[i], &chars[i], is_indent);