summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoshe Piekarski <mendelmunkis@protonmail.com>2018-04-03 12:45:22 -0500
committerWilliam Wilgus <me.theuser@yahoo.com>2018-07-04 06:25:45 +0200
commitab1b67f37b4d415ba096aed3bc5d9700e0a7923f (patch)
tree952e58823e37c7ea99a4f24b0de29bb2105bea6c
parent8742f6f0e2cf7c03716d4486f4fad3b57b98d8d3 (diff)
Textviewer night mode
Add a night mode to textviewer. Change-Id: I6ddcd9c3c87473cbbffaeacf63a21ef11c0e5f44
-rw-r--r--apps/plugins/text_viewer/tv_display.c19
-rw-r--r--apps/plugins/text_viewer/tv_display.h3
-rw-r--r--apps/plugins/text_viewer/tv_menu.c17
-rw-r--r--apps/plugins/text_viewer/tv_preferences.c4
-rw-r--r--apps/plugins/text_viewer/tv_preferences.h2
-rw-r--r--apps/plugins/text_viewer/tv_settings.c13
6 files changed, 52 insertions, 6 deletions
diff --git a/apps/plugins/text_viewer/tv_display.c b/apps/plugins/text_viewer/tv_display.c
index 3376ccc548..1f8499bed2 100644
--- a/apps/plugins/text_viewer/tv_display.c
+++ b/apps/plugins/text_viewer/tv_display.c
@@ -69,6 +69,7 @@
#define TV_SCROLLBAR_WIDTH rb->global_settings->scrollbar_width
#define TV_SCROLLBAR_HEIGHT 4
+
#ifndef HAVE_LCD_BITMAP
#define TV_BOOKMARK_ICON 0xe101
#endif
@@ -220,6 +221,7 @@ void tv_draw_text(int row, const unsigned char *text, int offset)
}
display->set_viewport(&vp_text);
+ tv_night_mode();
#ifdef HAVE_LCD_BITMAP
display->putsxy(xpos, row * row_height, text);
#else
@@ -231,6 +233,7 @@ void tv_draw_text(int row, const unsigned char *text, int offset)
void tv_start_display(void)
{
display->set_viewport(&vp_info);
+ tv_night_mode();
#ifdef HAVE_LCD_BITMAP
display->set_drawmode(DRMODE_SOLID);
#endif
@@ -239,6 +242,7 @@ void tv_start_display(void)
rb->lcd_set_backdrop(NULL);
#endif
display->clear_viewport();
+
}
void tv_end_display(void)
@@ -403,6 +407,21 @@ bool tv_init_display(unsigned char **buf, size_t *size)
return true;
}
+void tv_night_mode(void)
+{
+#ifdef HAVE_LCD_COLOR
+ if(preferences->night_mode)
+ {
+ rb->lcd_set_foreground(LCD_RGBPACK(0xBF,0xBF,0x00));
+ rb->lcd_set_background(LCD_RGBPACK(0x96,0x0D,0x00));
+ }else
+ {
+ rb->lcd_set_foreground(LCD_WHITE);
+ rb->lcd_set_background(LCD_BLACK);
+ }
+#endif
+}
+
void tv_finalize_display(void)
{
#ifdef HAVE_LCD_BITMAP
diff --git a/apps/plugins/text_viewer/tv_display.h b/apps/plugins/text_viewer/tv_display.h
index f6a3d19b78..9dfe17d900 100644
--- a/apps/plugins/text_viewer/tv_display.h
+++ b/apps/plugins/text_viewer/tv_display.h
@@ -103,6 +103,9 @@ void tv_start_display(void);
/* end the display processing */
void tv_end_display(void);
+/*change color scheme*/
+void tv_night_mode(void);
+
/* layout functions */
diff --git a/apps/plugins/text_viewer/tv_menu.c b/apps/plugins/text_viewer/tv_menu.c
index 9e796982d3..01fb052151 100644
--- a/apps/plugins/text_viewer/tv_menu.c
+++ b/apps/plugins/text_viewer/tv_menu.c
@@ -247,6 +247,13 @@ static bool tv_indent_spaces_setting(void)
&new_prefs.indent_spaces, NULL, 1, 0, 5, NULL);
}
+#ifdef HAVE_LCD_COLOR
+static bool tv_night_mode_setting(void)
+{
+ return rb->set_bool("Night Mode", &new_prefs.night_mode);
+}
+#endif
+
MENUITEM_FUNCTION(encoding_item, 0, "Encoding", tv_encoding_setting,
NULL, NULL, Icon_NOICON);
MENUITEM_FUNCTION(word_wrap_item, 0, "Word Wrap", tv_word_wrap_setting,
@@ -269,6 +276,10 @@ MENUITEM_FUNCTION(font_item, 0, "Font", tv_font_setting,
#endif
MENUITEM_FUNCTION(indent_spaces_item, 0, "Indent Spaces", tv_indent_spaces_setting,
NULL, NULL, Icon_NOICON);
+#ifdef HAVE_LCD_COLOR
+MENUITEM_FUNCTION(night_mode_item, 0, "Night Mode", tv_night_mode_setting,
+ NULL, NULL, Icon_NOICON);
+#endif
MAKE_MENU(option_menu, "Viewer Options", NULL, Icon_NOICON,
&encoding_item, &word_wrap_item, &line_mode_item, &windows_item,
@@ -276,7 +287,11 @@ MAKE_MENU(option_menu, "Viewer Options", NULL, Icon_NOICON,
#ifdef HAVE_LCD_BITMAP
&header_item, &footer_item, &font_item, &statusbar_item,
#endif
- &scroll_menu, &indent_spaces_item);
+ &scroll_menu, &indent_spaces_item
+#ifdef HAVE_LCD_COLOR
+ , &night_mode_item
+#endif
+ );
static unsigned tv_options_menu(void)
{
diff --git a/apps/plugins/text_viewer/tv_preferences.c b/apps/plugins/text_viewer/tv_preferences.c
index 86719ae16b..54c21ba04d 100644
--- a/apps/plugins/text_viewer/tv_preferences.c
+++ b/apps/plugins/text_viewer/tv_preferences.c
@@ -49,6 +49,7 @@ static bool tv_notify_change_preferences(const struct tv_preferences *oldp)
* - font
* - autoscroll_speed
* - narrow_mode
+ * - night_mode
*/
if ((oldp == NULL) ||
(oldp->word_mode != preferences->word_mode) ||
@@ -120,7 +121,8 @@ void tv_set_default_preferences(struct tv_preferences *p)
p->footer_mode = false;
p->statusbar = false;
#endif
- p->autoscroll_speed = 1;
+ p->autoscroll_speed = 10;
+ p->night_mode = false;
p->narrow_mode = NM_PAGE;
p->indent_spaces = 2;
/* Set codepage to system default */
diff --git a/apps/plugins/text_viewer/tv_preferences.h b/apps/plugins/text_viewer/tv_preferences.h
index f3b2aebfa6..65d9521e15 100644
--- a/apps/plugins/text_viewer/tv_preferences.h
+++ b/apps/plugins/text_viewer/tv_preferences.h
@@ -93,6 +93,8 @@ struct tv_preferences {
bool statusbar;
+ bool night_mode;
+
#ifdef HAVE_LCD_BITMAP
unsigned char font_name[MAX_PATH];
int font_id;
diff --git a/apps/plugins/text_viewer/tv_settings.c b/apps/plugins/text_viewer/tv_settings.c
index 895f162ebb..dfd47ec7a3 100644
--- a/apps/plugins/text_viewer/tv_settings.c
+++ b/apps/plugins/text_viewer/tv_settings.c
@@ -50,7 +50,8 @@
* narrow_mode 1
* indent_spaces 1
* statusbar 1
- * (reserved) 11
+ * night_mode 1
+ * (reserved) 10
* font name MAX_PATH
*/
@@ -58,7 +59,7 @@
#define TV_GLOBAL_SETTINGS_FILE VIEWERS_DATA_DIR "/tv_global.dat"
#define TV_GLOBAL_SETTINGS_HEADER "\x54\x56\x47\x53" /* "TVGS" */
-#define TV_GLOBAL_SETTINGS_VERSION 0x38
+#define TV_GLOBAL_SETTINGS_VERSION 0x39
#define TV_GLOBAL_SETTINGS_HEADER_SIZE 5
#define TV_GLOBAL_SETTINGS_FIRST_VERSION 0x31
@@ -93,7 +94,8 @@
* narrow_mode 1
* indent_spaces 1
* statusbar 1
- * (reserved) 11
+ * night_mode 1
+ * (reserved) 10
* font name MAX_PATH
* bookmark count 1
* [1st bookmark]
@@ -115,7 +117,7 @@
#define TV_SETTINGS_TMP_FILE VIEWERS_DATA_DIR "/tv_file.tmp"
#define TV_SETTINGS_HEADER "\x54\x56\x53" /* "TVS" */
-#define TV_SETTINGS_VERSION 0x39
+#define TV_SETTINGS_VERSION 0x3A
#define TV_SETTINGS_HEADER_SIZE 4
#define TV_SETTINGS_FIRST_VERSION 0x32
@@ -214,6 +216,8 @@ static bool tv_read_preferences(int pfd, int version, struct tv_preferences *pre
if (version > 6)
prefs->statusbar = (*p++ != 0);
+ if (version > 6)
+ prefs->night_mode = (*p++ != 0);
#ifdef HAVE_LCD_BITMAP
rb->strlcpy(prefs->font_name, buf + read_size - MAX_PATH, MAX_PATH);
@@ -247,6 +251,7 @@ static void tv_serialize_preferences(unsigned char *buf, const struct tv_prefere
*p++ = prefs->narrow_mode;
*p++ = prefs->indent_spaces;
*p++ = prefs->statusbar;
+ *p++ = prefs->night_mode;
#ifdef HAVE_LCD_BITMAP
rb->strlcpy(buf + 28, prefs->font_name, MAX_PATH);