From 4c62c00f99001c592a17178815edb3a72c4a9d0a Mon Sep 17 00:00:00 2001 From: Marcoen Hirschberg Date: Mon, 19 Nov 2007 16:02:45 +0000 Subject: [PATCH] don't save the viewer position if it hasn't changed git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15689 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/viewer.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/plugins/viewer.c b/apps/plugins/viewer.c index f0b8e3ff36..0628e7ab3c 100644 --- a/apps/plugins/viewer.c +++ b/apps/plugins/viewer.c @@ -296,6 +296,7 @@ static int par_indent_spaces; /* number of spaces to indent first paragraph */ static int fd; static char *file_name; static long file_size; +static long start_position; /* position in the file after the viewer is started */ static bool mac_text; static long file_pos; /* Position of the top of the buffer in the file */ static unsigned char *buffer_end; /*Set to BUFFER_END() when file_pos changes*/ @@ -1142,12 +1143,19 @@ static void viewer_load_settings(void) /* same name as global, but not the same } fill_buffer(file_pos, buffer, BUFFER_SIZE); + + /* remember the current position */ + start_position = file_pos + screen_top_ptr - buffer; } static void viewer_save_settings(void)/* same name as global, but not the same file.. */ { int settings_fd; + /* don't save if the position didn't change */ + if (file_pos + screen_top_ptr - buffer == start_position) + return; + settings_fd = rb->creat(SETTINGS_FILE); /* create the settings file */ rb->write (settings_fd, &prefs, sizeof(struct preferences));