aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/gargoyle/glk.cpp117
-rw-r--r--engines/gargoyle/window_text_buffer.h3
-rw-r--r--engines/gargoyle/window_text_grid.h2
-rw-r--r--engines/gargoyle/windows.h38
4 files changed, 155 insertions, 5 deletions
diff --git a/engines/gargoyle/glk.cpp b/engines/gargoyle/glk.cpp
index 3148fa1544..a50c7a6211 100644
--- a/engines/gargoyle/glk.cpp
+++ b/engines/gargoyle/glk.cpp
@@ -440,12 +440,123 @@ glui32 Glk::glk_get_buffer_stream(strid_t str, char *buf, glui32 len) {
return 0;
}
-void Glk::glk_stylehint_set(glui32 wintype, glui32 styl, glui32 hint, glsi32 val) {
- // TODO
+void Glk::glk_stylehint_set(glui32 wintype, glui32 style, glui32 hint, glsi32 val) {
+ WindowStyle *styles;
+ bool p, b, i;
+
+ if (wintype == wintype_AllTypes) {
+ glk_stylehint_set(wintype_TextGrid, style, hint, val);
+ glk_stylehint_set(wintype_TextBuffer, style, hint, val);
+ return;
+ }
+
+ if (wintype == wintype_TextGrid)
+ styles = g_conf->_gStyles;
+ else if (wintype == wintype_TextBuffer)
+ styles = g_conf->_tStyles;
+ else
+ return;
+
+ if (!g_conf->_styleHint)
+ return;
+
+ switch (hint) {
+ case stylehint_TextColor:
+ styles[style].fg[0] = (val >> 16) & 0xff;
+ styles[style].fg[1] = (val >> 8) & 0xff;
+ styles[style].fg[2] = (val) & 0xff;
+ break;
+
+ case stylehint_BackColor:
+ styles[style].bg[0] = (val >> 16) & 0xff;
+ styles[style].bg[1] = (val >> 8) & 0xff;
+ styles[style].bg[2] = (val) & 0xff;
+ break;
+
+ case stylehint_ReverseColor:
+ styles[style].reverse = (val != 0);
+ break;
+
+ case stylehint_Proportional:
+ if (wintype == wintype_TextBuffer) {
+ p = val > 0;
+ b = styles[style].isBold();
+ i = styles[style].isItalic();
+ styles[style].font = WindowStyle::makeFont(p, b, i);
+ }
+ break;
+
+ case stylehint_Weight:
+ p = styles[style].isProp();
+ b = val > 0;
+ i = styles[style].isItalic();
+ styles[style].font = WindowStyle::makeFont(p, b, i);
+ break;
+
+ case stylehint_Oblique:
+ p = styles[style].isProp();
+ b = styles[style].isBold();
+ i = val > 0;
+ styles[style].font = WindowStyle::makeFont(p, b, i);
+ break;
+ }
+
+ if (wintype == wintype_TextBuffer && style == style_Normal && hint == stylehint_BackColor) {
+ memcpy(g_conf->_windowColor, styles[style].bg, 3);
+ }
+
+ if (wintype == wintype_TextBuffer && style == style_Normal && hint == stylehint_TextColor) {
+ memcpy(g_conf->_moreColor, styles[style].fg, 3);
+ memcpy(g_conf->_caretColor, styles[style].fg, 3);
+ }
}
void Glk::glk_stylehint_clear(glui32 wintype, glui32 style, glui32 hint) {
- // TODO
+ WindowStyle *styles;
+ const WindowStyle *defaults;
+
+ if (wintype == wintype_AllTypes) {
+ glk_stylehint_clear(wintype_TextGrid, style, hint);
+ glk_stylehint_clear(wintype_TextBuffer, style, hint);
+ return;
+ }
+
+ if (wintype == wintype_TextGrid) {
+ styles = g_conf->_gStyles;
+ defaults = g_conf->_gStylesDefault;
+ } else if (wintype == wintype_TextBuffer) {
+ styles = g_conf->_tStyles;
+ defaults = g_conf->_tStylesDefault;
+ } else {
+ return;
+ }
+
+ if (!g_conf->_styleHint)
+ return;
+
+ switch (hint) {
+ case stylehint_TextColor:
+ styles[style].fg[0] = defaults[style].fg[0];
+ styles[style].fg[1] = defaults[style].fg[1];
+ styles[style].fg[2] = defaults[style].fg[2];
+ break;
+
+ case stylehint_BackColor:
+ styles[style].bg[0] = defaults[style].bg[0];
+ styles[style].bg[1] = defaults[style].bg[1];
+ styles[style].bg[2] = defaults[style].bg[2];
+ break;
+
+ case stylehint_ReverseColor:
+ styles[style].reverse = defaults[style].reverse;
+ break;
+
+ case stylehint_Proportional:
+ case stylehint_Weight:
+ case stylehint_Oblique:
+ styles[style].font = defaults[style].font;
+ break;
+ }
}
glui32 Glk::glk_style_distinguish(winid_t win, glui32 style1, glui32 style2) {
diff --git a/engines/gargoyle/window_text_buffer.h b/engines/gargoyle/window_text_buffer.h
index 5359d4e60e..9f0e20c0c1 100644
--- a/engines/gargoyle/window_text_buffer.h
+++ b/engines/gargoyle/window_text_buffer.h
@@ -126,6 +126,9 @@ public:
glui32 _echoLineInput;
glui32 *_lineTerminators;
+ /* style hints and settings */
+ WindowStyle _styles[style_NUMSTYLES];
+
/* for copy selection */
glui32 *_copyBuf;
int _copyPos;
diff --git a/engines/gargoyle/window_text_grid.h b/engines/gargoyle/window_text_grid.h
index 0040b195ba..8470c36fd2 100644
--- a/engines/gargoyle/window_text_grid.h
+++ b/engines/gargoyle/window_text_grid.h
@@ -74,6 +74,8 @@ public:
Attributes _origAttr;
gidispatch_rock_t _inArrayRock;
glui32 *_lineTerminators;
+
+ WindowStyle _styles[style_NUMSTYLES]; ///< style hints and settings
public:
/**
* Constructor
diff --git a/engines/gargoyle/windows.h b/engines/gargoyle/windows.h
index bd24892939..5830c7c85e 100644
--- a/engines/gargoyle/windows.h
+++ b/engines/gargoyle/windows.h
@@ -230,6 +230,42 @@ struct WindowStyle {
bool operator==(const WindowStyle &src) const {
return !memcmp(this, &src, sizeof(WindowStyle));
}
+
+ /**
+ * Returns true if the font is proportinate
+ */
+ bool isProp() const {
+ return font == PROPR || font == PROPI || font == PROPB || font == PROPZ;
+ }
+
+ /**
+ * Returns true ifont the font is bold
+ */
+ bool isBold() const {
+ return font == PROPB || font == PROPZ || font == MONOB || font == MONOZ;
+ }
+
+ /**
+ * Returns true ifont the font is italic
+ */
+ bool isItalic() const {
+ return font == PROPI || font == PROPZ || font == MONOI || font == MONOZ;
+ }
+
+ /**
+ * Returns a font that has the following combination of proportinate, bold, and italic
+ */
+ static FACES makeFont(bool p, bool b, bool i) {
+ if (p && !b && !i) return PROPR;
+ if (p && !b && i) return PROPI;
+ if (p && b && !i) return PROPB;
+ if (p && b && i) return PROPZ;
+ if (!p && !b && !i) return MONOR;
+ if (!p && !b && i) return MONOI;
+ if (!p && b && !i) return MONOB;
+ if (!p && b && i) return MONOZ;
+ return PROPR;
+ }
};
/**
@@ -302,8 +338,6 @@ struct Attributes {
* Window definition
*/
class Window {
-protected:
- WindowStyle _styles[style_NUMSTYLES]; ///< style hints and settings for grid and buffer windows
public:
Windows *_windows;
glui32 _rock;