include themes as files from the README and make it easier to configure at compile-time - sfeed_curses - sfeed curses UI (now part of sfeed, development is in sfeed)
HTML git clone git://git.codemadness.org/sfeed_curses
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
DIR commit 1cd5d0bd8f917614c65e1a7c9b03ba92eac94d0a
DIR parent 57932cc12daff30b45e81b19bed2a0e3a27eac9f
HTML Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Sat, 19 Dec 2020 16:20:27 +0100
include themes as files from the README and make it easier to configure at compile-time
make (defaults to mono)
or
make SFEED_THEME=newsboat
or
make SFEED_THEME=templeos
Diffstat:
M Makefile | 9 +++++++--
M README | 36 +++----------------------------
M sfeed_curses.c | 17 +++++------------
A themes/mono.h | 12 ++++++++++++
A themes/newsboat.h | 12 ++++++++++++
A themes/templeos.h | 19 +++++++++++++++++++
6 files changed, 58 insertions(+), 47 deletions(-)
---
DIR diff --git a/Makefile b/Makefile
@@ -3,6 +3,9 @@
NAME = sfeed_curses
VERSION = 0.9.6
+# theme, see themes/ directory.
+#SFEED_THEME = mono
+
# paths
PREFIX = /usr/local
MANPREFIX = ${PREFIX}/man
@@ -11,7 +14,8 @@ DOCPREFIX = ${PREFIX}/share/doc/${NAME}
# use system flags.
SFEED_CFLAGS = ${CFLAGS}
SFEED_LDFLAGS = ${LDFLAGS} -lcurses
-SFEED_CPPFLAGS = -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -D_BSD_SOURCE
+SFEED_CPPFLAGS = -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -D_BSD_SOURCE \
+ -DSFEED_THEME=\"themes/${SFEED_THEME}.h\"
# Linux: some distros use ncurses and require -lncurses.
#SFEED_LDFLAGS = ${LDFLAGS} -lncurses
@@ -19,7 +23,8 @@ SFEED_CPPFLAGS = -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -D_BSD_SOURCE
# Gentoo Linux: some distros might also require -ltinfo and -D_DEFAULT_SOURCE
# to prevent warnings about feature macros.
#SFEED_LDFLAGS = ${LDFLAGS} -lcurses -ltinfo
-#SFEED_CPPFLAGS = -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -D_BSD_SOURCE
+#SFEED_CPPFLAGS = -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L \
+# -D_XOPEN_SOURCE=700 -D_BSD_SOURCE -DSFEED_THEME=\"themes/${SFEED_THEME}.h\"
BIN = sfeed_curses
SCRIPTS = sfeed_content sfeed_markread
DIR diff --git a/README b/README
@@ -102,39 +102,9 @@ testing. Some of them might be fixed already upstream:
Color themes
------------
-/* newsboat-like (blue, yellow) */
-#define THEME_ITEM_NORMAL() do { } while(0)
-#define THEME_ITEM_FOCUS() do { } while(0)
-#define THEME_ITEM_BOLD() do { attrmode(ATTR_BOLD_ON); } while(0)
-#define THEME_ITEM_SELECTED() do { if (p->focused) ttywrite("\x1b[93;44m"); } while(0) /* bright yellow fg, blue bg */
-#define THEME_SCROLLBAR_FOCUS() do { ttywrite("\x1b[34m"); } while(0) /* blue fg */
-#define THEME_SCROLLBAR_NORMAL() do { ttywrite("\x1b[34m"); } while(0)
-#define THEME_SCROLLBAR_TICK_FOCUS() do { ttywrite("\x1b[44m"); } while(0) /* blue bg */
-#define THEME_SCROLLBAR_TICK_NORMAL() do { ttywrite("\x1b[44m"); } while(0)
-#define THEME_STATUSBAR() do { attrmode(ATTR_BOLD_ON); ttywrite("\x1b[93;44m"); } while(0)
-#define THEME_INPUT_LABEL() do { } while(0)
-#define THEME_INPUT_NORMAL() do { } while(0)
-
-
-/* TempleOS-like (for fun and god) */
-/* set true-color foreground / background, Terry would've preferred ANSI */
-#define SETFGCOLOR(r,g,b) ttywritef("\x1b[38;2;%d;%d;%dm", r, g, b)
-#define SETBGCOLOR(r,g,b) ttywritef("\x1b[48;2;%d;%d;%dm", r, g, b)
-
-#define THEME_ITEM_NORMAL() do { SETFGCOLOR(0x00, 0x00, 0xaa); SETBGCOLOR(0xff, 0xff, 0xff); } while(0)
-#define THEME_ITEM_FOCUS() do { SETFGCOLOR(0x00, 0x00, 0xaa); SETBGCOLOR(0xff, 0xff, 0xff); } while(0)
-#define THEME_ITEM_BOLD() do { attrmode(ATTR_BOLD_ON); SETFGCOLOR(0xaa, 0x00, 0x00); SETBGCOLOR(0xff, 0xff, 0xff); } while(0)
-#define THEME_ITEM_SELECTED() do { if (p->focused) attrmode(ATTR_REVERSE_ON); } while(0)
-#define THEME_SCROLLBAR_FOCUS() do { SETFGCOLOR(0x00, 0x00, 0xaa); SETBGCOLOR(0xff, 0xff, 0xff); } while(0)
-#define THEME_SCROLLBAR_NORMAL() do { SETFGCOLOR(0x00, 0x00, 0xaa); SETBGCOLOR(0xff, 0xff, 0xff); } while(0)
-#define THEME_SCROLLBAR_TICK_FOCUS() do { SETBGCOLOR(0x00, 0x00, 0xaa); SETFGCOLOR(0xff, 0xff, 0xff); } while(0)
-#define THEME_SCROLLBAR_TICK_NORMAL() do { SETBGCOLOR(0x00, 0x00, 0xaa); SETFGCOLOR(0xff, 0xff, 0xff); } while(0)
-#define THEME_STATUSBAR() do { ttywrite("\x1b[6m"); SETBGCOLOR(0x00, 0x00, 0xaa); SETFGCOLOR(0xff, 0xff, 0xff); } while(0) /* blink statusbar */
-#define THEME_INPUT_LABEL() do { SETFGCOLOR(0x00, 0x00, 0xaa); SETBGCOLOR(0xff, 0xff, 0xff); } while(0)
-#define THEME_INPUT_NORMAL() do { SETFGCOLOR(0x00, 0x00, 0xaa); SETBGCOLOR(0xff, 0xff, 0xff); } while(0)
-
-#undef SCROLLBAR_SYMBOL_BAR
-#define SCROLLBAR_SYMBOL_BAR "\xe2\x95\x91" /* symbol: "double vertical" */
+To change the default theme you can set SFEED_THEME using make or in the
+Makefile or include the a header file in sfeed_curses.c. See also the themes/
+directory.
Running custom commands inside the program
DIR diff --git a/sfeed_curses.c b/sfeed_curses.c
@@ -27,18 +27,11 @@
#define SCROLLBAR_SYMBOL_BAR "\xe2\x94\x82" /* symbol: "light vertical" */
#define SCROLLBAR_SYMBOL_TICK " "
-/* See the README for some color theme examples. */
-#define THEME_ITEM_NORMAL() do { } while(0)
-#define THEME_ITEM_FOCUS() do { } while(0)
-#define THEME_ITEM_BOLD() do { attrmode(ATTR_BOLD_ON); } while(0)
-#define THEME_ITEM_SELECTED() do { if (p->focused) attrmode(ATTR_REVERSE_ON); } while(0)
-#define THEME_SCROLLBAR_FOCUS() do { } while(0)
-#define THEME_SCROLLBAR_NORMAL() do { attrmode(ATTR_FAINT_ON); } while(0)
-#define THEME_SCROLLBAR_TICK_FOCUS() do { attrmode(ATTR_REVERSE_ON); } while(0)
-#define THEME_SCROLLBAR_TICK_NORMAL() do { attrmode(ATTR_REVERSE_ON); } while(0)
-#define THEME_STATUSBAR() do { attrmode(ATTR_REVERSE_ON); } while(0)
-#define THEME_INPUT_LABEL() do { attrmode(ATTR_REVERSE_ON); } while(0)
-#define THEME_INPUT_NORMAL() do { } while(0)
+/* color-scheme */
+#ifndef SFEED_THEME
+#define SFEED_THEME "themes/mono.h"
+#endif
+#include SFEED_THEME
static char *plumbercmd = "xdg-open"; /* env variable: $SFEED_PLUMBER */
static char *pipercmd = "sfeed_content"; /* env variable: $SFEED_PIPER */
DIR diff --git a/themes/mono.h b/themes/mono.h
@@ -0,0 +1,12 @@
+/* default mono theme */
+#define THEME_ITEM_NORMAL() do { } while(0)
+#define THEME_ITEM_FOCUS() do { } while(0)
+#define THEME_ITEM_BOLD() do { attrmode(ATTR_BOLD_ON); } while(0)
+#define THEME_ITEM_SELECTED() do { if (p->focused) attrmode(ATTR_REVERSE_ON); } while(0)
+#define THEME_SCROLLBAR_FOCUS() do { } while(0)
+#define THEME_SCROLLBAR_NORMAL() do { attrmode(ATTR_FAINT_ON); } while(0)
+#define THEME_SCROLLBAR_TICK_FOCUS() do { attrmode(ATTR_REVERSE_ON); } while(0)
+#define THEME_SCROLLBAR_TICK_NORMAL() do { attrmode(ATTR_REVERSE_ON); } while(0)
+#define THEME_STATUSBAR() do { attrmode(ATTR_REVERSE_ON); } while(0)
+#define THEME_INPUT_LABEL() do { attrmode(ATTR_REVERSE_ON); } while(0)
+#define THEME_INPUT_NORMAL() do { } while(0)
DIR diff --git a/themes/newsboat.h b/themes/newsboat.h
@@ -0,0 +1,12 @@
+/* newsboat-like (blue, yellow) */
+#define THEME_ITEM_NORMAL() do { } while(0)
+#define THEME_ITEM_FOCUS() do { } while(0)
+#define THEME_ITEM_BOLD() do { attrmode(ATTR_BOLD_ON); } while(0)
+#define THEME_ITEM_SELECTED() do { if (p->focused) ttywrite("\x1b[93;44m"); } while(0) /* bright yellow fg, blue bg */
+#define THEME_SCROLLBAR_FOCUS() do { ttywrite("\x1b[34m"); } while(0) /* blue fg */
+#define THEME_SCROLLBAR_NORMAL() do { ttywrite("\x1b[34m"); } while(0)
+#define THEME_SCROLLBAR_TICK_FOCUS() do { ttywrite("\x1b[44m"); } while(0) /* blue bg */
+#define THEME_SCROLLBAR_TICK_NORMAL() do { ttywrite("\x1b[44m"); } while(0)
+#define THEME_STATUSBAR() do { attrmode(ATTR_BOLD_ON); ttywrite("\x1b[93;44m"); } while(0)
+#define THEME_INPUT_LABEL() do { } while(0)
+#define THEME_INPUT_NORMAL() do { } while(0)
DIR diff --git a/themes/templeos.h b/themes/templeos.h
@@ -0,0 +1,19 @@
+/* TempleOS-like (for fun and god) */
+/* set true-color foreground / background, Terry would've preferred ANSI */
+#define SETFGCOLOR(r,g,b) ttywritef("\x1b[38;2;%d;%d;%dm", r, g, b)
+#define SETBGCOLOR(r,g,b) ttywritef("\x1b[48;2;%d;%d;%dm", r, g, b)
+
+#define THEME_ITEM_NORMAL() do { SETFGCOLOR(0x00, 0x00, 0xaa); SETBGCOLOR(0xff, 0xff, 0xff); } while(0)
+#define THEME_ITEM_FOCUS() do { SETFGCOLOR(0x00, 0x00, 0xaa); SETBGCOLOR(0xff, 0xff, 0xff); } while(0)
+#define THEME_ITEM_BOLD() do { attrmode(ATTR_BOLD_ON); SETFGCOLOR(0xaa, 0x00, 0x00); SETBGCOLOR(0xff, 0xff, 0xff); } while(0)
+#define THEME_ITEM_SELECTED() do { if (p->focused) attrmode(ATTR_REVERSE_ON); } while(0)
+#define THEME_SCROLLBAR_FOCUS() do { SETFGCOLOR(0x00, 0x00, 0xaa); SETBGCOLOR(0xff, 0xff, 0xff); } while(0)
+#define THEME_SCROLLBAR_NORMAL() do { SETFGCOLOR(0x00, 0x00, 0xaa); SETBGCOLOR(0xff, 0xff, 0xff); } while(0)
+#define THEME_SCROLLBAR_TICK_FOCUS() do { SETBGCOLOR(0x00, 0x00, 0xaa); SETFGCOLOR(0xff, 0xff, 0xff); } while(0)
+#define THEME_SCROLLBAR_TICK_NORMAL() do { SETBGCOLOR(0x00, 0x00, 0xaa); SETFGCOLOR(0xff, 0xff, 0xff); } while(0)
+#define THEME_STATUSBAR() do { ttywrite("\x1b[6m"); SETBGCOLOR(0x00, 0x00, 0xaa); SETFGCOLOR(0xff, 0xff, 0xff); } while(0) /* blink statusbar */
+#define THEME_INPUT_LABEL() do { SETFGCOLOR(0x00, 0x00, 0xaa); SETBGCOLOR(0xff, 0xff, 0xff); } while(0)
+#define THEME_INPUT_NORMAL() do { SETFGCOLOR(0x00, 0x00, 0xaa); SETBGCOLOR(0xff, 0xff, 0xff); } while(0)
+
+#undef SCROLLBAR_SYMBOL_BAR
+#define SCROLLBAR_SYMBOL_BAR "\xe2\x95\x91" /* symbol: "double vertical" */