text viewer: can select "move to prev/next page" or "move to top page/bottom page" when LEFT/RIGHT key is pressed (narrow mode).

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26719 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Yoshihisa Uchida 2010-06-09 11:28:43 +00:00
parent c92b2cc16a
commit 8bdb1c04d3
6 changed files with 54 additions and 19 deletions

View file

@ -52,5 +52,3 @@ TODO list
- more treatments of line breaking, word wrappings. - more treatments of line breaking, word wrappings.
(for example, period does not appear the top of line.) (for example, period does not appear the top of line.)
- whether scroll to prev/next page or scroll to top page/bottom page can be select the settings menu.

View file

@ -114,12 +114,16 @@ enum plugin_status plugin_start(const void* file)
tv_scroll_left(TV_HORIZONTAL_SCROLL_PREFS); tv_scroll_left(TV_HORIZONTAL_SCROLL_PREFS);
} }
else { /* prefs->windows == 1 */ else { /* prefs->windows == 1 */
/* scroll to previous page */ if (prefs->narrow_mode == NM_PAGE)
tv_scroll_up(TV_VERTICAL_SCROLL_PAGE); {
#if 0 /* scroll to previous page */
/* Top of file */ tv_scroll_up(TV_VERTICAL_SCROLL_PAGE);
tv_top(); }
#endif else
{
/* Top of file */
tv_top();
}
} }
break; break;
@ -131,12 +135,16 @@ enum plugin_status plugin_start(const void* file)
tv_scroll_right(TV_HORIZONTAL_SCROLL_PREFS); tv_scroll_right(TV_HORIZONTAL_SCROLL_PREFS);
} }
else { /* prefs->windows == 1 */ else { /* prefs->windows == 1 */
/* scroll to next page */ if (prefs->narrow_mode == NM_PAGE)
tv_scroll_down(TV_VERTICAL_SCROLL_PAGE); {
#if 0 /* scroll to next page */
/* Bottom of file */ tv_scroll_down(TV_VERTICAL_SCROLL_PAGE);
tv_bottom(); }
#endif else
{
/* Bottom of file */
tv_bottom();
}
} }
break; break;

View file

@ -117,6 +117,17 @@ static bool tv_autoscroll_speed_setting(void)
&new_prefs.autoscroll_speed, NULL, 1, 1, 10, NULL); &new_prefs.autoscroll_speed, NULL, 1, 1, 10, NULL);
} }
static bool tv_narrow_mode_setting(void)
{
static const struct opt_items names[] = {
{"Previous/Next Page", -1},
{"Top/Bottom Page", -1},
};
return rb->set_option("Left/Right Key", &new_prefs.narrow_mode, INT,
names, 2, NULL);
}
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
MENUITEM_FUNCTION(vertical_scrollbar_item, 0, "Scrollbar", MENUITEM_FUNCTION(vertical_scrollbar_item, 0, "Scrollbar",
tv_vertical_scrollbar_setting, tv_vertical_scrollbar_setting,
@ -128,12 +139,15 @@ MENUITEM_FUNCTION(page_mode_item, 0, "Overlap Pages", tv_page_mode_setting,
NULL, NULL, Icon_NOICON); NULL, NULL, Icon_NOICON);
MENUITEM_FUNCTION(autoscroll_speed_item, 0, "Auto-Scroll Speed", MENUITEM_FUNCTION(autoscroll_speed_item, 0, "Auto-Scroll Speed",
tv_autoscroll_speed_setting, NULL, NULL, Icon_NOICON); tv_autoscroll_speed_setting, NULL, NULL, Icon_NOICON);
MENUITEM_FUNCTION(narrow_mode_item, 0, "Left/Right Key (Narrow mode)",
tv_narrow_mode_setting, NULL, NULL, Icon_NOICON);
MAKE_MENU(vertical_scroll_menu, "Vertical", NULL, Icon_NOICON, MAKE_MENU(vertical_scroll_menu, "Vertical", NULL, Icon_NOICON,
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
&vertical_scrollbar_item, &vertical_scrollbar_item,
#endif #endif
&vertical_scroll_mode_item, &page_mode_item, &autoscroll_speed_item); &vertical_scroll_mode_item, &page_mode_item, &autoscroll_speed_item,
&narrow_mode_item);
/* */ /* */
/* scroll settings menu */ /* scroll settings menu */

View file

@ -43,6 +43,7 @@ static void tv_notify_change_preferences(const struct tv_preferences *oldp,
* - page_mode * - page_mode
* - font * - font
* - autoscroll_speed * - autoscroll_speed
* - narrow_mode
*/ */
if ((oldp == NULL) || if ((oldp == NULL) ||
(oldp->word_mode != newp->word_mode) || (oldp->word_mode != newp->word_mode) ||
@ -111,6 +112,7 @@ void tv_set_default_preferences(struct tv_preferences *p)
p->footer_mode = FT_NONE; p->footer_mode = FT_NONE;
#endif #endif
p->autoscroll_speed = 1; p->autoscroll_speed = 1;
p->narrow_mode = NM_PAGE;
/* Set codepage to system default */ /* Set codepage to system default */
p->encoding = rb->global_settings->default_codepage; p->encoding = rb->global_settings->default_codepage;
p->file_name[0] = '\0'; p->file_name[0] = '\0';

View file

@ -84,6 +84,11 @@ struct tv_preferences {
int windows; int windows;
enum {
NM_PAGE = 0,
NM_TOP_BOTTOM,
} narrow_mode;
unsigned char font_name[MAX_PATH]; unsigned char font_name[MAX_PATH];
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
struct font *font; struct font *font;

View file

@ -48,7 +48,8 @@
* autoscroll_speed 1 * autoscroll_speed 1
* horizontal_scrollbar 1 * horizontal_scrollbar 1
* horizontal_scroll_mode 1 * horizontal_scroll_mode 1
* (reserved) 14 * narrow_mode 1
* (reserved) 13
* font name MAX_PATH * font name MAX_PATH
*/ */
@ -56,7 +57,7 @@
#define TV_GLOBAL_SETTINGS_FILE VIEWERS_DIR "/tv_global.dat" #define TV_GLOBAL_SETTINGS_FILE VIEWERS_DIR "/tv_global.dat"
#define TV_GLOBAL_SETTINGS_HEADER "\x54\x56\x47\x53" /* "TVGS" */ #define TV_GLOBAL_SETTINGS_HEADER "\x54\x56\x47\x53" /* "TVGS" */
#define TV_GLOBAL_SETTINGS_VERSION 0x35 #define TV_GLOBAL_SETTINGS_VERSION 0x36
#define TV_GLOBAL_SETTINGS_HEADER_SIZE 5 #define TV_GLOBAL_SETTINGS_HEADER_SIZE 5
#define TV_GLOBAL_SETTINGS_FIRST_VERSION 0x31 #define TV_GLOBAL_SETTINGS_FIRST_VERSION 0x31
@ -88,7 +89,8 @@
* autoscroll_speed 1 * autoscroll_speed 1
* horizontal_scrollbar 1 * horizontal_scrollbar 1
* horizontal_scroll_mode 1 * horizontal_scroll_mode 1
* (reserved) 14 * narrow_mode 1
* (reserved) 13
* font name MAX_PATH * font name MAX_PATH
* bookmark count 1 * bookmark count 1
* [1st bookmark] * [1st bookmark]
@ -110,7 +112,7 @@
#define TV_SETTINGS_TMP_FILE VIEWERS_DIR "/tv_file.tmp" #define TV_SETTINGS_TMP_FILE VIEWERS_DIR "/tv_file.tmp"
#define TV_SETTINGS_HEADER "\x54\x56\x53" /* "TVS" */ #define TV_SETTINGS_HEADER "\x54\x56\x53" /* "TVS" */
#define TV_SETTINGS_VERSION 0x36 #define TV_SETTINGS_VERSION 0x37
#define TV_SETTINGS_HEADER_SIZE 4 #define TV_SETTINGS_HEADER_SIZE 4
#define TV_SETTINGS_FIRST_VERSION 0x32 #define TV_SETTINGS_FIRST_VERSION 0x32
@ -167,6 +169,11 @@ static bool tv_read_preferences(int pfd, int version, struct tv_preferences *pre
else else
prefs->horizontal_scroll_mode = SCREEN; prefs->horizontal_scroll_mode = SCREEN;
if (version > 4)
prefs->narrow_mode = *p++;
else
prefs->narrow_mode = NM_PAGE;
rb->memcpy(prefs->font_name, buf + read_size - MAX_PATH, MAX_PATH); rb->memcpy(prefs->font_name, buf + read_size - MAX_PATH, MAX_PATH);
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
@ -196,6 +203,7 @@ static bool tv_write_preferences(int pfd, const struct tv_preferences *prefs)
*p++ = prefs->autoscroll_speed; *p++ = prefs->autoscroll_speed;
*p++ = prefs->horizontal_scrollbar; *p++ = prefs->horizontal_scrollbar;
*p++ = prefs->horizontal_scroll_mode; *p++ = prefs->horizontal_scroll_mode;
*p++ = prefs->narrow_mode;
rb->memcpy(buf + 28, prefs->font_name, MAX_PATH); rb->memcpy(buf + 28, prefs->font_name, MAX_PATH);