Index: apps/plugins/viewer.c =================================================================== --- apps/plugins/viewer.c (revision 21809) +++ apps/plugins/viewer.c (working copy) @@ -432,6 +432,7 @@ static unsigned char *next_screen_ptr; static unsigned char *next_screen_to_draw_ptr; static unsigned char *next_line_ptr; +static bool view_wide; /* false if line mode is reflow or join, or view mode is narrow */ #ifdef HAVE_LCD_BITMAP static struct font *pf; #endif @@ -550,7 +550,7 @@ if BUFFER_OOB(cur_line) return NULL; - if (prefs.view_mode == WIDE) { + if (view_wide) { search_len = MAX_WIDTH; } else { /* prefs.view_mode == NARROW */ @@ -780,7 +780,7 @@ rb->memcpy(MID_SECTOR, TOP_SECTOR, SMALL_BLOCK_SIZE); } else /* down */ { - if (prefs.view_mode == WIDE) { + if (view_wide) { /* WIDE mode needs more buffer so we have to read smaller blocks */ move_size = SMALL_BLOCK_SIZE; offset = LARGE_BLOCK_SIZE; @@ -950,8 +950,8 @@ } if (col != -1) { scratch_buffer[k] = 0; - endptr = rb->iso_decode(scratch_buffer + col, utf8_buffer, - prefs.encoding, draw_columns/glyph_width('i')); + endptr = rb->iso_decode(scratch_buffer, utf8_buffer, + prefs.encoding, k); *endptr = 0; } } @@ -1039,8 +1039,8 @@ if (col != -1) { scratch_buffer[k] = 0; - endptr = rb->iso_decode(scratch_buffer + col, utf8_buffer, - prefs.encoding, k-col); + endptr = rb->iso_decode(scratch_buffer, utf8_buffer, + prefs.encoding, k); *endptr = 0; } } @@ -1061,7 +1061,7 @@ } } - if(prefs.view_mode==WIDE) + if(view_wide) endptr = rb->iso_decode(line_begin, utf8_buffer, prefs.encoding, oldstr-line_begin); else @@ -1214,6 +1214,12 @@ /* load default settings if there is no settings file */ viewer_default_settings(); } + /* it doesn't make sence to enable wide view while join or reflow. */ + if(prefs.view_mode == WIDE + && prefs.line_mode != JOIN && prefs.line_mode != REFLOW) + view_wide = true; + else + view_wide = false; rb->memcpy(&old_prefs, &prefs, sizeof(struct preferences)); @@ -1402,8 +1408,6 @@ bool ret; ret = rb->set_option("Wide View", &prefs.view_mode, INT, names , 2, NULL); - if (prefs.view_mode == NARROW) - col = 0; return ret; } @@ -1478,6 +1482,13 @@ bool result; result = (rb->do_menu(&option_menu, NULL, NULL, false) == MENU_ATTACHED_USB); + if(prefs.view_mode == WIDE + && prefs.line_mode != JOIN && prefs.line_mode != REFLOW) + view_wide = true; + else { + col = 0; + view_wide = false; + } #ifdef HAVE_LCD_BITMAP /* Show-scrollbar mode for current view-width mode */ init_need_scrollbar(); @@ -1601,7 +1612,7 @@ case VIEWER_SCREEN_LEFT: case VIEWER_SCREEN_LEFT | BUTTON_REPEAT: - if (prefs.view_mode == WIDE) { + if (view_wide) { /* Screen left */ col -= draw_columns; col = col_limit(col); @@ -1616,7 +1627,7 @@ case VIEWER_SCREEN_RIGHT: case VIEWER_SCREEN_RIGHT | BUTTON_REPEAT: - if (prefs.view_mode == WIDE) { + if (view_wide) { /* Screen right */ col += draw_columns; col = col_limit(col); @@ -1650,7 +1661,7 @@ #ifdef VIEWER_COLUMN_LEFT case VIEWER_COLUMN_LEFT: case VIEWER_COLUMN_LEFT | BUTTON_REPEAT: - if (prefs.view_mode == WIDE) { + if (view_wide) { /* Scroll left one column */ col -= glyph_width('o'); col = col_limit(col); @@ -1660,7 +1671,7 @@ case VIEWER_COLUMN_RIGHT: case VIEWER_COLUMN_RIGHT | BUTTON_REPEAT: - if (prefs.view_mode == WIDE) { + if (view_wide) { /* Scroll right one column */ col += glyph_width('o'); col = col_limit(col);