diff options
author | Yoshihisa Uchida <uchida@rockbox.org> | 2010-06-09 11:28:43 +0000 |
---|---|---|
committer | Yoshihisa Uchida <uchida@rockbox.org> | 2010-06-09 11:28:43 +0000 |
commit | 8bdb1c04d3ea9fd6460506ca05de506416e1d750 (patch) | |
tree | d5031f2c14d0d7d5866c2a3c9c3b5717b612a8bc | |
parent | c92b2cc16a8324b71e874e96cc828589b9f586fd (diff) | |
download | rockbox-8bdb1c04d3ea9fd6460506ca05de506416e1d750.tar.gz rockbox-8bdb1c04d3ea9fd6460506ca05de506416e1d750.zip |
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
-rw-r--r-- | apps/plugins/text_viewer/readme.txt | 2 | ||||
-rw-r--r-- | apps/plugins/text_viewer/text_viewer.c | 32 | ||||
-rw-r--r-- | apps/plugins/text_viewer/tv_menu.c | 16 | ||||
-rw-r--r-- | apps/plugins/text_viewer/tv_preferences.c | 2 | ||||
-rw-r--r-- | apps/plugins/text_viewer/tv_preferences.h | 5 | ||||
-rw-r--r-- | apps/plugins/text_viewer/tv_settings.c | 16 |
6 files changed, 54 insertions, 19 deletions
diff --git a/apps/plugins/text_viewer/readme.txt b/apps/plugins/text_viewer/readme.txt index 1180965fe4..ebde6d7f75 100644 --- a/apps/plugins/text_viewer/readme.txt +++ b/apps/plugins/text_viewer/readme.txt | |||
@@ -52,5 +52,3 @@ TODO list | |||
52 | 52 | ||
53 | - more treatments of line breaking, word wrappings. | 53 | - more treatments of line breaking, word wrappings. |
54 | (for example, period does not appear the top of line.) | 54 | (for example, period does not appear the top of line.) |
55 | |||
56 | - whether scroll to prev/next page or scroll to top page/bottom page can be select the settings menu. | ||
diff --git a/apps/plugins/text_viewer/text_viewer.c b/apps/plugins/text_viewer/text_viewer.c index ea8972491b..fae2f071aa 100644 --- a/apps/plugins/text_viewer/text_viewer.c +++ b/apps/plugins/text_viewer/text_viewer.c | |||
@@ -114,12 +114,16 @@ enum plugin_status plugin_start(const void* file) | |||
114 | tv_scroll_left(TV_HORIZONTAL_SCROLL_PREFS); | 114 | tv_scroll_left(TV_HORIZONTAL_SCROLL_PREFS); |
115 | } | 115 | } |
116 | else { /* prefs->windows == 1 */ | 116 | else { /* prefs->windows == 1 */ |
117 | /* scroll to previous page */ | 117 | if (prefs->narrow_mode == NM_PAGE) |
118 | tv_scroll_up(TV_VERTICAL_SCROLL_PAGE); | 118 | { |
119 | #if 0 | 119 | /* scroll to previous page */ |
120 | /* Top of file */ | 120 | tv_scroll_up(TV_VERTICAL_SCROLL_PAGE); |
121 | tv_top(); | 121 | } |
122 | #endif | 122 | else |
123 | { | ||
124 | /* Top of file */ | ||
125 | tv_top(); | ||
126 | } | ||
123 | } | 127 | } |
124 | break; | 128 | break; |
125 | 129 | ||
@@ -131,12 +135,16 @@ enum plugin_status plugin_start(const void* file) | |||
131 | tv_scroll_right(TV_HORIZONTAL_SCROLL_PREFS); | 135 | tv_scroll_right(TV_HORIZONTAL_SCROLL_PREFS); |
132 | } | 136 | } |
133 | else { /* prefs->windows == 1 */ | 137 | else { /* prefs->windows == 1 */ |
134 | /* scroll to next page */ | 138 | if (prefs->narrow_mode == NM_PAGE) |
135 | tv_scroll_down(TV_VERTICAL_SCROLL_PAGE); | 139 | { |
136 | #if 0 | 140 | /* scroll to next page */ |
137 | /* Bottom of file */ | 141 | tv_scroll_down(TV_VERTICAL_SCROLL_PAGE); |
138 | tv_bottom(); | 142 | } |
139 | #endif | 143 | else |
144 | { | ||
145 | /* Bottom of file */ | ||
146 | tv_bottom(); | ||
147 | } | ||
140 | } | 148 | } |
141 | break; | 149 | break; |
142 | 150 | ||
diff --git a/apps/plugins/text_viewer/tv_menu.c b/apps/plugins/text_viewer/tv_menu.c index eb92782385..c40d6e67a6 100644 --- a/apps/plugins/text_viewer/tv_menu.c +++ b/apps/plugins/text_viewer/tv_menu.c | |||
@@ -117,6 +117,17 @@ static bool tv_autoscroll_speed_setting(void) | |||
117 | &new_prefs.autoscroll_speed, NULL, 1, 1, 10, NULL); | 117 | &new_prefs.autoscroll_speed, NULL, 1, 1, 10, NULL); |
118 | } | 118 | } |
119 | 119 | ||
120 | static bool tv_narrow_mode_setting(void) | ||
121 | { | ||
122 | static const struct opt_items names[] = { | ||
123 | {"Previous/Next Page", -1}, | ||
124 | {"Top/Bottom Page", -1}, | ||
125 | }; | ||
126 | |||
127 | return rb->set_option("Left/Right Key", &new_prefs.narrow_mode, INT, | ||
128 | names, 2, NULL); | ||
129 | } | ||
130 | |||
120 | #ifdef HAVE_LCD_BITMAP | 131 | #ifdef HAVE_LCD_BITMAP |
121 | MENUITEM_FUNCTION(vertical_scrollbar_item, 0, "Scrollbar", | 132 | MENUITEM_FUNCTION(vertical_scrollbar_item, 0, "Scrollbar", |
122 | tv_vertical_scrollbar_setting, | 133 | tv_vertical_scrollbar_setting, |
@@ -128,12 +139,15 @@ MENUITEM_FUNCTION(page_mode_item, 0, "Overlap Pages", tv_page_mode_setting, | |||
128 | NULL, NULL, Icon_NOICON); | 139 | NULL, NULL, Icon_NOICON); |
129 | MENUITEM_FUNCTION(autoscroll_speed_item, 0, "Auto-Scroll Speed", | 140 | MENUITEM_FUNCTION(autoscroll_speed_item, 0, "Auto-Scroll Speed", |
130 | tv_autoscroll_speed_setting, NULL, NULL, Icon_NOICON); | 141 | tv_autoscroll_speed_setting, NULL, NULL, Icon_NOICON); |
142 | MENUITEM_FUNCTION(narrow_mode_item, 0, "Left/Right Key (Narrow mode)", | ||
143 | tv_narrow_mode_setting, NULL, NULL, Icon_NOICON); | ||
131 | 144 | ||
132 | MAKE_MENU(vertical_scroll_menu, "Vertical", NULL, Icon_NOICON, | 145 | MAKE_MENU(vertical_scroll_menu, "Vertical", NULL, Icon_NOICON, |
133 | #ifdef HAVE_LCD_BITMAP | 146 | #ifdef HAVE_LCD_BITMAP |
134 | &vertical_scrollbar_item, | 147 | &vertical_scrollbar_item, |
135 | #endif | 148 | #endif |
136 | &vertical_scroll_mode_item, &page_mode_item, &autoscroll_speed_item); | 149 | &vertical_scroll_mode_item, &page_mode_item, &autoscroll_speed_item, |
150 | &narrow_mode_item); | ||
137 | 151 | ||
138 | /* */ | 152 | /* */ |
139 | /* scroll settings menu */ | 153 | /* scroll settings menu */ |
diff --git a/apps/plugins/text_viewer/tv_preferences.c b/apps/plugins/text_viewer/tv_preferences.c index 62a700b85d..8b4c91a1cb 100644 --- a/apps/plugins/text_viewer/tv_preferences.c +++ b/apps/plugins/text_viewer/tv_preferences.c | |||
@@ -43,6 +43,7 @@ static void tv_notify_change_preferences(const struct tv_preferences *oldp, | |||
43 | * - page_mode | 43 | * - page_mode |
44 | * - font | 44 | * - font |
45 | * - autoscroll_speed | 45 | * - autoscroll_speed |
46 | * - narrow_mode | ||
46 | */ | 47 | */ |
47 | if ((oldp == NULL) || | 48 | if ((oldp == NULL) || |
48 | (oldp->word_mode != newp->word_mode) || | 49 | (oldp->word_mode != newp->word_mode) || |
@@ -111,6 +112,7 @@ void tv_set_default_preferences(struct tv_preferences *p) | |||
111 | p->footer_mode = FT_NONE; | 112 | p->footer_mode = FT_NONE; |
112 | #endif | 113 | #endif |
113 | p->autoscroll_speed = 1; | 114 | p->autoscroll_speed = 1; |
115 | p->narrow_mode = NM_PAGE; | ||
114 | /* Set codepage to system default */ | 116 | /* Set codepage to system default */ |
115 | p->encoding = rb->global_settings->default_codepage; | 117 | p->encoding = rb->global_settings->default_codepage; |
116 | p->file_name[0] = '\0'; | 118 | p->file_name[0] = '\0'; |
diff --git a/apps/plugins/text_viewer/tv_preferences.h b/apps/plugins/text_viewer/tv_preferences.h index dc29dcae26..645258c8a6 100644 --- a/apps/plugins/text_viewer/tv_preferences.h +++ b/apps/plugins/text_viewer/tv_preferences.h | |||
@@ -84,6 +84,11 @@ struct tv_preferences { | |||
84 | 84 | ||
85 | int windows; | 85 | int windows; |
86 | 86 | ||
87 | enum { | ||
88 | NM_PAGE = 0, | ||
89 | NM_TOP_BOTTOM, | ||
90 | } narrow_mode; | ||
91 | |||
87 | unsigned char font_name[MAX_PATH]; | 92 | unsigned char font_name[MAX_PATH]; |
88 | #ifdef HAVE_LCD_BITMAP | 93 | #ifdef HAVE_LCD_BITMAP |
89 | struct font *font; | 94 | struct font *font; |
diff --git a/apps/plugins/text_viewer/tv_settings.c b/apps/plugins/text_viewer/tv_settings.c index b537b3fb40..db27e8928a 100644 --- a/apps/plugins/text_viewer/tv_settings.c +++ b/apps/plugins/text_viewer/tv_settings.c | |||
@@ -48,7 +48,8 @@ | |||
48 | * autoscroll_speed 1 | 48 | * autoscroll_speed 1 |
49 | * horizontal_scrollbar 1 | 49 | * horizontal_scrollbar 1 |
50 | * horizontal_scroll_mode 1 | 50 | * horizontal_scroll_mode 1 |
51 | * (reserved) 14 | 51 | * narrow_mode 1 |
52 | * (reserved) 13 | ||
52 | * font name MAX_PATH | 53 | * font name MAX_PATH |
53 | */ | 54 | */ |
54 | 55 | ||
@@ -56,7 +57,7 @@ | |||
56 | #define TV_GLOBAL_SETTINGS_FILE VIEWERS_DIR "/tv_global.dat" | 57 | #define TV_GLOBAL_SETTINGS_FILE VIEWERS_DIR "/tv_global.dat" |
57 | 58 | ||
58 | #define TV_GLOBAL_SETTINGS_HEADER "\x54\x56\x47\x53" /* "TVGS" */ | 59 | #define TV_GLOBAL_SETTINGS_HEADER "\x54\x56\x47\x53" /* "TVGS" */ |
59 | #define TV_GLOBAL_SETTINGS_VERSION 0x35 | 60 | #define TV_GLOBAL_SETTINGS_VERSION 0x36 |
60 | #define TV_GLOBAL_SETTINGS_HEADER_SIZE 5 | 61 | #define TV_GLOBAL_SETTINGS_HEADER_SIZE 5 |
61 | #define TV_GLOBAL_SETTINGS_FIRST_VERSION 0x31 | 62 | #define TV_GLOBAL_SETTINGS_FIRST_VERSION 0x31 |
62 | 63 | ||
@@ -88,7 +89,8 @@ | |||
88 | * autoscroll_speed 1 | 89 | * autoscroll_speed 1 |
89 | * horizontal_scrollbar 1 | 90 | * horizontal_scrollbar 1 |
90 | * horizontal_scroll_mode 1 | 91 | * horizontal_scroll_mode 1 |
91 | * (reserved) 14 | 92 | * narrow_mode 1 |
93 | * (reserved) 13 | ||
92 | * font name MAX_PATH | 94 | * font name MAX_PATH |
93 | * bookmark count 1 | 95 | * bookmark count 1 |
94 | * [1st bookmark] | 96 | * [1st bookmark] |
@@ -110,7 +112,7 @@ | |||
110 | #define TV_SETTINGS_TMP_FILE VIEWERS_DIR "/tv_file.tmp" | 112 | #define TV_SETTINGS_TMP_FILE VIEWERS_DIR "/tv_file.tmp" |
111 | 113 | ||
112 | #define TV_SETTINGS_HEADER "\x54\x56\x53" /* "TVS" */ | 114 | #define TV_SETTINGS_HEADER "\x54\x56\x53" /* "TVS" */ |
113 | #define TV_SETTINGS_VERSION 0x36 | 115 | #define TV_SETTINGS_VERSION 0x37 |
114 | #define TV_SETTINGS_HEADER_SIZE 4 | 116 | #define TV_SETTINGS_HEADER_SIZE 4 |
115 | #define TV_SETTINGS_FIRST_VERSION 0x32 | 117 | #define TV_SETTINGS_FIRST_VERSION 0x32 |
116 | 118 | ||
@@ -167,6 +169,11 @@ static bool tv_read_preferences(int pfd, int version, struct tv_preferences *pre | |||
167 | else | 169 | else |
168 | prefs->horizontal_scroll_mode = SCREEN; | 170 | prefs->horizontal_scroll_mode = SCREEN; |
169 | 171 | ||
172 | if (version > 4) | ||
173 | prefs->narrow_mode = *p++; | ||
174 | else | ||
175 | prefs->narrow_mode = NM_PAGE; | ||
176 | |||
170 | rb->memcpy(prefs->font_name, buf + read_size - MAX_PATH, MAX_PATH); | 177 | rb->memcpy(prefs->font_name, buf + read_size - MAX_PATH, MAX_PATH); |
171 | 178 | ||
172 | #ifdef HAVE_LCD_BITMAP | 179 | #ifdef HAVE_LCD_BITMAP |
@@ -196,6 +203,7 @@ static bool tv_write_preferences(int pfd, const struct tv_preferences *prefs) | |||
196 | *p++ = prefs->autoscroll_speed; | 203 | *p++ = prefs->autoscroll_speed; |
197 | *p++ = prefs->horizontal_scrollbar; | 204 | *p++ = prefs->horizontal_scrollbar; |
198 | *p++ = prefs->horizontal_scroll_mode; | 205 | *p++ = prefs->horizontal_scroll_mode; |
206 | *p++ = prefs->narrow_mode; | ||
199 | 207 | ||
200 | rb->memcpy(buf + 28, prefs->font_name, MAX_PATH); | 208 | rb->memcpy(buf + 28, prefs->font_name, MAX_PATH); |
201 | 209 | ||