aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/interface-curses/interface.c
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2025-03-13 02:28:23 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2025-03-13 02:28:23 +0300
commit8d8d62a108d6329049dac63f25c6119db6c44d12 (patch)
tree683b9f7675f0a0b2891de1e4524e4eb85ac2db17 /src/interface-curses/interface.c
parent541bee1c6d56ce81a0302263af006b53dc1aea64 (diff)
downloadsciteco-8d8d62a108d6329049dac63f25c6119db6c44d12.tar.gz
updated Scinterm: my monochrome patch was merged only with some modifications
* SCI_COLOR_PAIR() is now a function teco_color_pair() since it also became an inline function in Scinterm.
Diffstat (limited to 'src/interface-curses/interface.c')
-rw-r--r--src/interface-curses/interface.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/interface-curses/interface.c b/src/interface-curses/interface.c
index 206ff30..2e87601 100644
--- a/src/interface-curses/interface.c
+++ b/src/interface-curses/interface.c
@@ -167,12 +167,16 @@ static gint teco_xterm_version(void) G_GNUC_UNUSED;
* Returns the curses `COLOR_PAIR` for the given curses foreground and background `COLOR`s.
* This is used simply to enumerate every possible color combination.
* Note: only 256 combinations are possible due to curses portability.
- * Note: This references the global curses variable `COLORS` and is not a constant expression.
- * @param f The curses foreground `COLOR`.
- * @param b The curses background `COLOR`.
- * @return int number for defining a curses `COLOR_PAIR`.
+ *
+ * @param fg The curses foreground `COLOR`.
+ * @param bg The curses background `COLOR`.
+ * @return number for defining a curses `COLOR_PAIR`.
*/
-#define SCI_COLOR_PAIR(f, b) ((b) * ((COLORS < 16) ? 8 : 16) + (f) + 1)
+static inline gshort
+teco_color_pair(gshort fg, gshort bg)
+{
+ return bg * (COLORS < 16 ? 8 : 16) + fg + 1;
+}
/**
* Curses attribute for the color combination
@@ -188,7 +192,7 @@ static inline attr_t
teco_color_attr(gshort fg, gshort bg)
{
if (has_colors())
- return COLOR_PAIR(SCI_COLOR_PAIR(fg, bg));
+ return COLOR_PAIR(teco_color_pair(fg, bg));
/*
* Basic support for monochrome terminals:
@@ -1121,7 +1125,7 @@ teco_interface_cmdline_update(const teco_cmdline_t *cmdline)
short fg = teco_rgb2curses(teco_interface_ssm(SCI_STYLEGETFORE, STYLE_DEFAULT, 0));
short bg = teco_rgb2curses(teco_interface_ssm(SCI_STYLEGETBACK, STYLE_DEFAULT, 0));
- wcolor_set(teco_interface.cmdline_pad, SCI_COLOR_PAIR(fg, bg), NULL);
+ wcolor_set(teco_interface.cmdline_pad, teco_color_pair(fg, bg), NULL);
/* format effective command line */
teco_interface.cmdline_len =