1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 Gilles Roux
12 * 2010 Yoshihisa Uchida
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
22 ****************************************************************************/
24 #include "tv_action.h"
25 #include "tv_bookmark.h"
27 #include "tv_screen_pos.h"
28 #include "tv_settings.h"
29 #include "tv_window.h"
31 bool tv_init(const unsigned char *file
)
35 /* get the plugin buffer */
36 unsigned char *buf
= rb
->plugin_get_buffer(&size
);
40 /* initialize modules */
41 if (!tv_init_window(&buf
, &size
))
44 /* load the preferences and bookmark */
45 tv_load_settings(file
);
47 /* select to read the page */
52 void tv_exit(void *parameter
)
56 /* save preference and bookmarks */
57 if (!tv_save_settings())
58 rb
->splash(HZ
, "Can't save preferences and bookmarks");
60 /* finalize modules */
66 struct tv_screen_pos pos
;
68 tv_copy_screen_pos(&pos
);
73 tv_move_screen(pos
.page
, pos
.line
, SEEK_SET
);
76 void tv_scroll_up(unsigned mode
)
81 if ((mode
== TV_VERTICAL_SCROLL_PAGE
) ||
82 (mode
== TV_VERTICAL_SCROLL_PREFS
&& preferences
->vertical_scroll_mode
== PAGE
))
85 #ifdef HAVE_LCD_BITMAP
86 offset_line
= (preferences
->page_mode
== OVERLAP
)? 1:0;
89 tv_move_screen(offset_page
, offset_line
, SEEK_CUR
);
92 void tv_scroll_down(unsigned mode
)
97 if ((mode
== TV_VERTICAL_SCROLL_PAGE
) ||
98 (mode
== TV_VERTICAL_SCROLL_PREFS
&& preferences
->vertical_scroll_mode
== PAGE
))
101 #ifdef HAVE_LCD_BITMAP
102 offset_line
= (preferences
->page_mode
== OVERLAP
)? -1:0;
105 tv_move_screen(offset_page
, offset_line
, SEEK_CUR
);
108 void tv_scroll_left(unsigned mode
)
110 int offset_window
= 0;
111 int offset_column
= 0;
113 if ((mode
== TV_HORIZONTAL_SCROLL_COLUMN
) ||
114 (mode
== TV_HORIZONTAL_SCROLL_PREFS
&& preferences
->horizontal_scroll_mode
== COLUMN
))
116 /* Scroll left one column */
121 /* Scroll left one window */
124 tv_move_window(offset_window
, offset_column
);
127 void tv_scroll_right(unsigned mode
)
129 int offset_window
= 0;
130 int offset_column
= 0;
132 if ((mode
== TV_HORIZONTAL_SCROLL_COLUMN
) ||
133 (mode
== TV_HORIZONTAL_SCROLL_PREFS
&& preferences
->horizontal_scroll_mode
== COLUMN
))
135 /* Scroll right one column */
140 /* Scroll right one window */
143 tv_move_window(offset_window
, offset_column
);
148 tv_move_screen(0, 0, SEEK_SET
);
153 tv_move_screen(0, 0, SEEK_END
);
154 if (preferences
->vertical_scroll_mode
== PAGE
)
155 tv_move_screen(0, -tv_get_screen_pos()->line
, SEEK_CUR
);
158 unsigned tv_menu(void)
161 struct tv_screen_pos cur_pos
;
162 off_t cur_file_pos
= tv_get_screen_pos()->file_pos
;
164 res
= tv_display_menu();
166 if (res
== TV_MENU_RESULT_EXIT_MENU
)
168 tv_convert_fpos(cur_file_pos
, &cur_pos
);
169 if (preferences
->vertical_scroll_mode
== PAGE
)
172 tv_move_screen(cur_pos
.page
, cur_pos
.line
, SEEK_SET
);
174 else if (res
== TV_MENU_RESULT_MOVE_PAGE
)
175 res
= TV_MENU_RESULT_EXIT_MENU
;
180 void tv_add_or_remove_bookmark(void)
182 tv_toggle_bookmark();