text viewer: can be selected the number of screens per page.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26613 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
e1a0e2cd7a
commit
1445c3b8c5
8 changed files with 84 additions and 87 deletions
|
@ -44,8 +44,6 @@ TODO list
|
|||
|
||||
- add History feature.
|
||||
|
||||
- when the WIDE screen, allow to specify the number of screens.
|
||||
|
||||
- when the line_mode is reflow, allow to specify indent spaces.
|
||||
|
||||
- for the horizontal scroll, allow the select scroll by screen/scroll by column for the settings menu.
|
||||
|
|
|
@ -108,12 +108,12 @@ enum plugin_status plugin_start(const void* file)
|
|||
|
||||
case TV_SCREEN_LEFT:
|
||||
case TV_SCREEN_LEFT | BUTTON_REPEAT:
|
||||
if (prefs->view_mode == WIDE)
|
||||
if (prefs->windows > 1)
|
||||
{
|
||||
/* Screen left */
|
||||
tv_scroll_left(TV_HORIZONTAL_SCROLL_WINDOW);
|
||||
}
|
||||
else { /* prefs->view_mode == NARROW */
|
||||
else { /* prefs->windows == 1 */
|
||||
/* scroll to previous page */
|
||||
tv_scroll_up(TV_VERTICAL_SCROLL_PAGE);
|
||||
#if 0
|
||||
|
@ -125,12 +125,12 @@ enum plugin_status plugin_start(const void* file)
|
|||
|
||||
case TV_SCREEN_RIGHT:
|
||||
case TV_SCREEN_RIGHT | BUTTON_REPEAT:
|
||||
if (prefs->view_mode == WIDE)
|
||||
if (prefs->windows > 1)
|
||||
{
|
||||
/* Screen right */
|
||||
tv_scroll_right(TV_HORIZONTAL_SCROLL_WINDOW);
|
||||
}
|
||||
else { /* prefs->view_mode == NARROW */
|
||||
else { /* prefs->windows == 1 */
|
||||
/* scroll to next page */
|
||||
tv_scroll_down(TV_VERTICAL_SCROLL_PAGE);
|
||||
#if 0
|
||||
|
|
|
@ -69,15 +69,10 @@ static bool tv_line_mode_setting(void)
|
|||
sizeof(names) / sizeof(names[0]), NULL);
|
||||
}
|
||||
|
||||
static bool tv_view_mode_setting(void)
|
||||
static bool tv_windows_setting(void)
|
||||
{
|
||||
static const struct opt_items names[] = {
|
||||
{"No (Narrow)", -1},
|
||||
{"Yes", -1},
|
||||
};
|
||||
|
||||
return rb->set_option("Wide View", &new_prefs.view_mode, INT,
|
||||
names , 2, NULL);
|
||||
return rb->set_int("Screens Per Page", "", UNIT_INT,
|
||||
&new_prefs.windows, NULL, 1, 1, 5, NULL);
|
||||
}
|
||||
|
||||
static bool tv_scroll_mode_setting(void)
|
||||
|
@ -272,7 +267,7 @@ MENUITEM_FUNCTION(word_wrap_item, 0, "Word Wrap", tv_word_wrap_setting,
|
|||
NULL, NULL, Icon_NOICON);
|
||||
MENUITEM_FUNCTION(line_mode_item, 0, "Line Mode", tv_line_mode_setting,
|
||||
NULL, NULL, Icon_NOICON);
|
||||
MENUITEM_FUNCTION(view_mode_item, 0, "Wide View", tv_view_mode_setting,
|
||||
MENUITEM_FUNCTION(windows_item, 0, "Screens Per Page", tv_windows_setting,
|
||||
NULL, NULL, Icon_NOICON);
|
||||
MENUITEM_FUNCTION(alignment_item, 0, "Alignment", tv_alignment_setting,
|
||||
NULL, NULL, Icon_NOICON);
|
||||
|
@ -293,7 +288,7 @@ MENUITEM_FUNCTION(scroll_mode_item, 0, "Scroll Mode", tv_scroll_mode_setting,
|
|||
MENUITEM_FUNCTION(autoscroll_speed_item, 0, "Auto-Scroll Speed",
|
||||
tv_autoscroll_speed_setting, NULL, NULL, Icon_NOICON);
|
||||
MAKE_MENU(option_menu, "Viewer Options", NULL, Icon_NOICON,
|
||||
&encoding_item, &word_wrap_item, &line_mode_item, &view_mode_item,
|
||||
&encoding_item, &word_wrap_item, &line_mode_item, &windows_item,
|
||||
&alignment_item,
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
&scrollbar_item, &page_mode_item, &header_item, &footer_item, &font_item,
|
||||
|
|
|
@ -46,7 +46,7 @@ static void tv_notify_change_preferences(const struct tv_preferences *oldp,
|
|||
if ((oldp == NULL) ||
|
||||
(oldp->word_mode != newp->word_mode) ||
|
||||
(oldp->line_mode != newp->line_mode) ||
|
||||
(oldp->view_mode != newp->view_mode) ||
|
||||
(oldp->windows != newp->windows) ||
|
||||
(oldp->scrollbar_mode != newp->scrollbar_mode) ||
|
||||
(oldp->encoding != newp->encoding) ||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
|
@ -91,7 +91,7 @@ void tv_set_default_preferences(struct tv_preferences *p)
|
|||
{
|
||||
p->word_mode = WRAP;
|
||||
p->line_mode = NORMAL;
|
||||
p->view_mode = NARROW;
|
||||
p->windows = 1;
|
||||
p->alignment = LEFT;
|
||||
p->scroll_mode = PAGE;
|
||||
p->page_mode = NO_OVERLAP;
|
||||
|
|
|
@ -36,11 +36,6 @@ struct tv_preferences {
|
|||
REFLOW,
|
||||
} line_mode;
|
||||
|
||||
enum {
|
||||
NARROW = 0,
|
||||
WIDE,
|
||||
} view_mode;
|
||||
|
||||
enum {
|
||||
LEFT = 0,
|
||||
RIGHT,
|
||||
|
@ -79,6 +74,8 @@ struct tv_preferences {
|
|||
|
||||
int autoscroll_speed;
|
||||
|
||||
int windows;
|
||||
|
||||
unsigned char font_name[MAX_PATH];
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
struct font *font;
|
||||
|
|
|
@ -30,30 +30,31 @@
|
|||
*
|
||||
* setting file format
|
||||
*
|
||||
* part byte count
|
||||
* --------------------------------
|
||||
* 'TVGS' 4
|
||||
* version 1
|
||||
* word_mode 1
|
||||
* line_mode 1
|
||||
* view_mode 1
|
||||
* alignment 1
|
||||
* encoding 1
|
||||
* scrollbar_mode 1
|
||||
* (unused) 1 (for compatibility)
|
||||
* page_mode 1
|
||||
* page_number_mode 1
|
||||
* title_mode 1
|
||||
* scroll_mode 1
|
||||
* autoscroll_speed 1
|
||||
* font name MAX_PATH
|
||||
* part byte count
|
||||
* -------------------------------
|
||||
* 'TVGS' 4
|
||||
* version 1
|
||||
* word_mode 1
|
||||
* line_mode 1
|
||||
* windows 1 (when version <= 0x32, this value is view_mode)
|
||||
* alignment 1
|
||||
* encoding 1
|
||||
* scrollbar_mode 1
|
||||
* (unused) 1 (for compatibility)
|
||||
* page_mode 1
|
||||
* page_number_mode 1
|
||||
* title_mode 1
|
||||
* scroll_mode 1
|
||||
* autoscroll_speed 1
|
||||
* (reserved) 16
|
||||
* font name MAX_PATH
|
||||
*/
|
||||
|
||||
#define VIEWER_GLOBAL_SETTINGS_FILE VIEWERS_DIR "/viewer.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_VERSION 0x32
|
||||
#define TV_GLOBAL_SETTINGS_VERSION 0x33
|
||||
#define TV_GLOBAL_SETTINGS_HEADER_SIZE 5
|
||||
#define TV_GLOBAL_SETTINGS_FIRST_VERSION 0x31
|
||||
|
||||
|
@ -62,34 +63,35 @@
|
|||
*
|
||||
* setting file format
|
||||
*
|
||||
* part byte count
|
||||
* --------------------------------
|
||||
* 'TVS' 3
|
||||
* version 1
|
||||
* file count 2
|
||||
* part byte count
|
||||
* -----------------------------------
|
||||
* 'TVS' 3
|
||||
* version 1
|
||||
* file count 2
|
||||
* [1st file]
|
||||
* file path MAX_PATH
|
||||
* next file pos 2 (prefences size + bookmark count * bookmark size + 1)
|
||||
* file path MAX_PATH
|
||||
* next file pos 2 (prefences size + bookmark count * bookmark size + 1)
|
||||
* [preferences]
|
||||
* word_mode 1
|
||||
* line_mode 1
|
||||
* view_mode 1
|
||||
* alignment 1
|
||||
* encoding 1
|
||||
* scrollbar_mode 1
|
||||
* (unused) 1 (for compatibility)
|
||||
* page_mode 1
|
||||
* header_mode 1
|
||||
* footer_mode 1
|
||||
* scroll_mode 1
|
||||
* autoscroll_speed 1
|
||||
* font name MAX_PATH
|
||||
* bookmark count 1
|
||||
* word_mode 1
|
||||
* line_mode 1
|
||||
* windows 1 (when version <= 0x33, this value is view_mode)
|
||||
* alignment 1
|
||||
* encoding 1
|
||||
* scrollbar_mode 1
|
||||
* (unused) 1 (for compatibility)
|
||||
* page_mode 1
|
||||
* header_mode 1
|
||||
* footer_mode 1
|
||||
* scroll_mode 1
|
||||
* autoscroll_speed 1
|
||||
* (reserved) 16
|
||||
* font name MAX_PATH
|
||||
* bookmark count 1
|
||||
* [1st bookmark]
|
||||
* file_position 4
|
||||
* page 2
|
||||
* line 1
|
||||
* flag 1
|
||||
* file_position 4
|
||||
* page 2
|
||||
* line 1
|
||||
* flag 1
|
||||
* [2nd bookmark]
|
||||
* ...
|
||||
* [last bookmark]
|
||||
|
@ -104,11 +106,11 @@
|
|||
#define TV_SETTINGS_TMP_FILE VIEWERS_DIR "/tv_file.tmp"
|
||||
|
||||
#define TV_SETTINGS_HEADER "\x54\x56\x53" /* "TVS" */
|
||||
#define TV_SETTINGS_VERSION 0x33
|
||||
#define TV_SETTINGS_VERSION 0x34
|
||||
#define TV_SETTINGS_HEADER_SIZE 4
|
||||
#define TV_SETTINGS_FIRST_VERSION 0x32
|
||||
|
||||
#define TV_PREFERENCES_SIZE (12 + MAX_PATH)
|
||||
#define TV_PREFERENCES_SIZE (28 + MAX_PATH)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* read/write the preferences
|
||||
|
@ -122,18 +124,25 @@ static bool tv_read_preferences(int pfd, int version, struct tv_preferences *pre
|
|||
int read_size = TV_PREFERENCES_SIZE;
|
||||
|
||||
if (version == 0)
|
||||
read_size--;
|
||||
read_size -= 17;
|
||||
else if (version == 1)
|
||||
read_size -= 16;
|
||||
|
||||
if (rb->read(pfd, buf, read_size) < 0)
|
||||
return false;
|
||||
|
||||
prefs->word_mode = *p++;
|
||||
prefs->line_mode = *p++;
|
||||
prefs->view_mode = *p++;
|
||||
|
||||
prefs->windows = *p++;
|
||||
if (version <= 1)
|
||||
prefs->windows++;
|
||||
|
||||
if (version > 0)
|
||||
prefs->alignment = *p++;
|
||||
else
|
||||
prefs->alignment = LEFT;
|
||||
|
||||
prefs->encoding = *p++;
|
||||
prefs->scrollbar_mode = *p++;
|
||||
/* skip need_scrollbar */
|
||||
|
@ -143,7 +152,9 @@ static bool tv_read_preferences(int pfd, int version, struct tv_preferences *pre
|
|||
prefs->footer_mode = *p++;
|
||||
prefs->scroll_mode = *p++;
|
||||
prefs->autoscroll_speed = *p++;
|
||||
rb->memcpy(prefs->font_name, p, MAX_PATH);
|
||||
|
||||
rb->memcpy(prefs->font_name, buf + read_size - MAX_PATH, MAX_PATH);
|
||||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
prefs->font = rb->font_get(FONT_UI);
|
||||
#endif
|
||||
|
@ -158,7 +169,7 @@ static bool tv_write_preferences(int pfd, const struct tv_preferences *prefs)
|
|||
|
||||
*p++ = prefs->word_mode;
|
||||
*p++ = prefs->line_mode;
|
||||
*p++ = prefs->view_mode;
|
||||
*p++ = prefs->windows;
|
||||
*p++ = prefs->alignment;
|
||||
*p++ = prefs->encoding;
|
||||
*p++ = prefs->scrollbar_mode;
|
||||
|
@ -169,7 +180,8 @@ static bool tv_write_preferences(int pfd, const struct tv_preferences *prefs)
|
|||
*p++ = prefs->footer_mode;
|
||||
*p++ = prefs->scroll_mode;
|
||||
*p++ = prefs->autoscroll_speed;
|
||||
rb->memcpy(p, prefs->font_name, MAX_PATH);
|
||||
|
||||
rb->memcpy(buf + 28, prefs->font_name, MAX_PATH);
|
||||
|
||||
return (rb->write(pfd, buf, TV_PREFERENCES_SIZE) >= 0);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ enum tv_text_type {
|
|||
#define TV_MAX_CHARS_PER_BLOCK (LCD_WIDTH + 1)
|
||||
#endif
|
||||
|
||||
#define TV_MAX_BLOCKS 2
|
||||
#define TV_MAX_BLOCKS 5
|
||||
|
||||
/*
|
||||
* number of spaces to indent first paragraph
|
||||
|
|
|
@ -27,8 +27,6 @@
|
|||
#include "tv_text_reader.h"
|
||||
#include "tv_window.h"
|
||||
|
||||
#define TV_WINDOWS_PER_SCREEN 2
|
||||
|
||||
#define TV_SCROLLBAR_WIDTH rb->global_settings->scrollbar_width
|
||||
|
||||
#ifndef HAVE_LCD_BITMAP
|
||||
|
@ -48,8 +46,6 @@ static int window_width;
|
|||
static int window_columns;
|
||||
static int col_width;
|
||||
|
||||
static int max_windows;
|
||||
|
||||
static int cur_window;
|
||||
static int cur_column;
|
||||
|
||||
|
@ -204,7 +200,7 @@ void tv_draw_window(void)
|
|||
int offset = cur_column * col_width;
|
||||
int size = 0;
|
||||
int line_width;
|
||||
int draw_width = (max_windows - cur_window) * LCD_WIDTH - offset;
|
||||
int draw_width = (prefs->windows - cur_window) * LCD_WIDTH - offset;
|
||||
int dx = start_width - offset;
|
||||
|
||||
tv_copy_screen_pos(&pos);
|
||||
|
@ -213,7 +209,7 @@ void tv_draw_window(void)
|
|||
if (prefs->alignment == LEFT)
|
||||
tv_read_start(cur_window, (cur_column > 0));
|
||||
else
|
||||
tv_read_start(0, prefs->view_mode == WIDE);
|
||||
tv_read_start(0, prefs->windows > 1);
|
||||
|
||||
for (line = 0; line < display_lines; line++)
|
||||
{
|
||||
|
@ -313,8 +309,7 @@ static void tv_change_preferences(const struct tv_preferences *oldp)
|
|||
col_width = 1;
|
||||
#endif
|
||||
|
||||
max_windows = (prefs->view_mode == NARROW)? 1: TV_WINDOWS_PER_SCREEN;
|
||||
if (cur_window >= max_windows)
|
||||
if (cur_window >= prefs->windows)
|
||||
cur_window = 0;
|
||||
|
||||
window_width = LCD_WIDTH;
|
||||
|
@ -322,7 +317,7 @@ static void tv_change_preferences(const struct tv_preferences *oldp)
|
|||
need_scrollbar = false;
|
||||
start_width = 0;
|
||||
tv_seek_top();
|
||||
tv_set_read_conditions(max_windows, window_width);
|
||||
tv_set_read_conditions(prefs->windows, window_width);
|
||||
if (tv_traverse_lines() && prefs->scrollbar_mode)
|
||||
{
|
||||
need_scrollbar = true;
|
||||
|
@ -337,7 +332,7 @@ static void tv_change_preferences(const struct tv_preferences *oldp)
|
|||
|
||||
cur_column = 0;
|
||||
|
||||
tv_set_read_conditions(max_windows, window_width);
|
||||
tv_set_read_conditions(prefs->windows, window_width);
|
||||
}
|
||||
|
||||
bool tv_init_window(unsigned char *buf, size_t bufsize, size_t *used_size)
|
||||
|
@ -365,9 +360,9 @@ void tv_move_window(int window_delta, int column_delta)
|
|||
cur_window = 0;
|
||||
cur_column = 0;
|
||||
}
|
||||
else if (cur_window >= max_windows)
|
||||
else if (cur_window >= prefs->windows)
|
||||
{
|
||||
cur_window = max_windows - 1;
|
||||
cur_window = prefs->windows - 1;
|
||||
cur_column = 0;
|
||||
}
|
||||
|
||||
|
@ -383,7 +378,7 @@ void tv_move_window(int window_delta, int column_delta)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (cur_window == max_windows - 1)
|
||||
if (cur_window == prefs->windows - 1)
|
||||
cur_column = 0;
|
||||
else if (cur_column >= window_columns)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue