diff options
author | Marcoen Hirschberg <marcoen@gmail.com> | 2007-11-23 09:11:09 +0000 |
---|---|---|
committer | Marcoen Hirschberg <marcoen@gmail.com> | 2007-11-23 09:11:09 +0000 |
commit | 3f6461acfc7545cb12c500fd774be8199d126539 (patch) | |
tree | 7b010c4cc777eebf37dbaa9f97fa65d7abd7e3a5 | |
parent | 8a64cdd5e8e2e37d5949cd4811d53fc3fd88f189 (diff) |
rearrange the initialization a bit. also fixes the disappearing scrollbar.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15769 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/plugins/viewer.c | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/apps/plugins/viewer.c b/apps/plugins/viewer.c index d81cc094e5..882cf10a06 100644 --- a/apps/plugins/viewer.c +++ b/apps/plugins/viewer.c @@ -1052,20 +1052,10 @@ static bool viewer_init(void) /* Init mac_text value used in processing buffer */ mac_text = false; - /* Set codepage to system default */ - prefs.encoding = rb->global_settings->default_codepage; - - /* Read top of file into buffer; - init file_pos, buffer_end, screen_top_ptr */ - viewer_top(); - - /* Init prefs.need_scrollbar value */ - init_need_scrollbar(); - return true; } -static void viewer_reset_settings(void) +static void viewer_default_settings(void) { prefs.word_mode = WRAP; prefs.line_mode = NORMAL; @@ -1076,6 +1066,8 @@ static void viewer_reset_settings(void) prefs.scrollbar_mode = SB_OFF; #endif prefs.autoscroll_speed = 1; + /* Set codepage to system default */ + prefs.encoding = rb->global_settings->default_codepage; } static void viewer_load_settings(void) /* same name as global, but not the same file.. */ @@ -1090,8 +1082,14 @@ static void viewer_load_settings(void) /* same name as global, but not the same { rb->read(settings_fd, &prefs, sizeof(struct preferences)); rb->close(settings_fd); - rb->memcpy(&old_prefs, &prefs, sizeof(struct preferences)); - } + } + else + { + /* load default settings if there is no settings file */ + viewer_default_settings(); + } + + rb->memcpy(&old_prefs, &prefs, sizeof(struct preferences)); data = (struct bookmark_file_data*)buffer; /* grab the text buffer */ data->bookmarked_files_count = 0; @@ -1155,8 +1153,6 @@ static void viewer_load_settings(void) /* same name as global, but not the same rb->close(settings_fd); } - init_need_scrollbar(); - buffer_end = BUFFER_END(); /* Update whenever file_pos changes */ if (BUFFER_OOB(screen_top_ptr)) @@ -1168,6 +1164,8 @@ static void viewer_load_settings(void) /* same name as global, but not the same /* remember the current position */ start_position = file_pos + screen_top_ptr - buffer; + + init_need_scrollbar(); } static void viewer_save_settings(void)/* same name as global, but not the same file.. */ @@ -1419,8 +1417,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* file) return PLUGIN_ERROR; } - viewer_reset_settings(); /* load defaults first */ - viewer_load_settings(); /* .. then try to load from disk */ + viewer_load_settings(); /* load the preferences and bookmark */ #if LCD_DEPTH > 1 rb->lcd_set_backdrop(NULL); |