diff options
Diffstat (limited to 'apps/plugins/text_viewer')
-rw-r--r-- | apps/plugins/text_viewer/readme.txt | 4 | ||||
-rw-r--r-- | apps/plugins/text_viewer/tv_menu.c | 10 | ||||
-rw-r--r-- | apps/plugins/text_viewer/tv_preferences.c | 2 | ||||
-rw-r--r-- | apps/plugins/text_viewer/tv_preferences.h | 2 | ||||
-rw-r--r-- | apps/plugins/text_viewer/tv_settings.c | 16 | ||||
-rw-r--r-- | apps/plugins/text_viewer/tv_text_processor.c | 18 |
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 - If the next line is a blank line or spaces only line, this line breaks. [reflow] - - indent changes two spaces. + - indent changes is two spaces (changable in the settings). - supports the player which does not define HAVE_LCD_BITMAP. [alignment] @@ -44,8 +44,6 @@ TODO list - add History feature. - - when the line_mode is reflow, allow to specify indent spaces. - - draw images that are linked to the text. (<img src="...">) - 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) } #endif +static bool tv_indent_spaces_setting(void) +{ + return rb->set_int("Indent Spaces", "", UNIT_INT, + &new_prefs.indent_spaces, NULL, 1, 0, 5, NULL); +} + MENUITEM_FUNCTION(encoding_item, 0, "Encoding", tv_encoding_setting, NULL, NULL, Icon_NOICON); MENUITEM_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, MENUITEM_FUNCTION(font_item, 0, "Font", tv_font_setting, NULL, NULL, Icon_NOICON); #endif +MENUITEM_FUNCTION(indent_spaces_item, 0, "Indent Spaces", tv_indent_spaces_setting, + NULL, NULL, Icon_NOICON); MAKE_MENU(option_menu, "Viewer Options", NULL, Icon_NOICON, &encoding_item, &word_wrap_item, &line_mode_item, &windows_item, @@ -340,7 +348,7 @@ MAKE_MENU(option_menu, "Viewer Options", NULL, Icon_NOICON, #ifdef HAVE_LCD_BITMAP &header_item, &footer_item, &font_item, #endif - &scroll_menu); + &scroll_menu, &indent_spaces_item); static enum tv_menu_result tv_options_menu(void) { 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, (oldp->horizontal_scrollbar != newp->horizontal_scrollbar) || (oldp->vertical_scrollbar != newp->vertical_scrollbar) || (oldp->encoding != newp->encoding) || + (oldp->indent_spaces != newp->indent_spaces) || #ifdef HAVE_LCD_BITMAP (oldp->header_mode != newp->header_mode) || (oldp->footer_mode != newp->footer_mode) || @@ -113,6 +114,7 @@ void tv_set_default_preferences(struct tv_preferences *p) #endif p->autoscroll_speed = 1; p->narrow_mode = NM_PAGE; + p->indent_spaces = 2; /* Set codepage to system default */ p->encoding = rb->global_settings->default_codepage; 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 { NM_TOP_BOTTOM, } narrow_mode; + int indent_spaces; + unsigned char font_name[MAX_PATH]; #ifdef HAVE_LCD_BITMAP 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 @@ * horizontal_scrollbar 1 * horizontal_scroll_mode 1 * narrow_mode 1 - * (reserved) 13 + * indent_spaces 1 + * (reserved) 12 * font name MAX_PATH */ @@ -57,7 +58,7 @@ #define TV_GLOBAL_SETTINGS_FILE VIEWERS_DIR "/tv_global.dat" #define TV_GLOBAL_SETTINGS_HEADER "\x54\x56\x47\x53" /* "TVGS" */ -#define TV_GLOBAL_SETTINGS_VERSION 0x36 +#define TV_GLOBAL_SETTINGS_VERSION 0x37 #define TV_GLOBAL_SETTINGS_HEADER_SIZE 5 #define TV_GLOBAL_SETTINGS_FIRST_VERSION 0x31 @@ -90,7 +91,8 @@ * horizontal_scrollbar 1 * horizontal_scroll_mode 1 * narrow_mode 1 - * (reserved) 13 + * indent_spaces 1 + * (reserved) 12 * font name MAX_PATH * bookmark count 1 * [1st bookmark] @@ -112,7 +114,7 @@ #define TV_SETTINGS_TMP_FILE VIEWERS_DIR "/tv_file.tmp" #define TV_SETTINGS_HEADER "\x54\x56\x53" /* "TVS" */ -#define TV_SETTINGS_VERSION 0x37 +#define TV_SETTINGS_VERSION 0x38 #define TV_SETTINGS_HEADER_SIZE 4 #define TV_SETTINGS_FIRST_VERSION 0x32 @@ -174,6 +176,11 @@ static bool tv_read_preferences(int pfd, int version, struct tv_preferences *pre else prefs->narrow_mode = NM_PAGE; + if (version > 5) + prefs->indent_spaces = *p++; + else + prefs->indent_spaces = 2; + rb->memcpy(prefs->font_name, buf + read_size - MAX_PATH, MAX_PATH); #ifdef HAVE_LCD_BITMAP @@ -204,6 +211,7 @@ static bool tv_write_preferences(int pfd, const struct tv_preferences *prefs) *p++ = prefs->horizontal_scrollbar; *p++ = prefs->horizontal_scroll_mode; *p++ = prefs->narrow_mode; + *p++ = prefs->indent_spaces; rb->memcpy(buf + 28, prefs->font_name, MAX_PATH); 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 { #define TV_MAX_BLOCKS 5 -/* - * number of spaces to indent first paragraph - * (this value uses the line mode is REFLOW only) - */ -#define TV_INDENT_SPACES 2 - static const struct tv_preferences *prefs; static enum tv_text_type text_type = TV_TEXT_UNKNOWN; @@ -434,7 +428,7 @@ static int tv_parse_text(const unsigned char *src, unsigned short *ucs, is_indent = false; if (prefs->line_mode == REFLOW && is_indent) - gw = tv_glyph_width(ch) * TV_INDENT_SPACES; + gw = tv_glyph_width(ch) * prefs->indent_spaces; else gw = tv_glyph_width(ch); @@ -451,12 +445,13 @@ static int tv_parse_text(const unsigned char *src, unsigned short *ucs, break; } - if (prefs->line_mode == REFLOW && is_indent) + if (prefs->line_mode != REFLOW || !is_indent) + ucs[chars++] = ch; + else { - for (i = 1; i < TV_INDENT_SPACES; i++) + for (i = 0; i < prefs->indent_spaces; i++) ucs[chars++] = ch; } - ucs[chars++] = ch; if (tv_is_line_break_char(ch)) { @@ -518,6 +513,9 @@ int tv_create_formed_text(const unsigned char *src, ssize_t bufsize, tv_get_ucs(src, &ch); is_indent = (tv_isspace(ch) && !is_break_line); + if (is_indent && prefs->indent_spaces == 0 && (expand_extra_line = !expand_extra_line) == true) + return 0; + for (i = 0; i < block_count; i++) { size += tv_parse_text(src + size, ucsbuf[i], &chars[i], is_indent); |