From 3b8d006c8b7091f6e65a4c4865cc9aebb6452d38 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Mar 2019 18:09:34 -0800 Subject: GLK: Add support for input cursors in text grid windows This is initially primarily for Bureaucracy.. the starting form is drawn in the text grid window, and visible cursor is needed so you can tell which line you're filling in --- engines/glk/conf.cpp | 3 --- engines/glk/fonts.cpp | 10 +++++++++- engines/glk/fonts.h | 6 ++++-- engines/glk/window_text_grid.cpp | 7 +++++++ 4 files changed, 20 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/glk/conf.cpp b/engines/glk/conf.cpp index 4e7ed24b02..5c6bc761bc 100644 --- a/engines/glk/conf.cpp +++ b/engines/glk/conf.cpp @@ -124,9 +124,6 @@ Conf::Conf(InterpreterType interpType) { get("caretcolor", _propInfo._caretColor, nullptr); get("caretcolor", _propInfo._caretSave, nullptr); get("caretshape", _propInfo._caretShape, 2); - _monoInfo._caretColor = _propInfo._caretColor; - _monoInfo._caretSave = _propInfo._caretSave; - _monoInfo._caretShape = _propInfo._caretShape; _propInfo._linkStyle = _monoInfo._linkStyle = ConfMan.hasKey("linkstyle") && !strToInt(ConfMan.get("linkstyle").c_str()) ? 0 : 1; diff --git a/engines/glk/fonts.cpp b/engines/glk/fonts.cpp index 12ae7c6489..6ef500c581 100644 --- a/engines/glk/fonts.cpp +++ b/engines/glk/fonts.cpp @@ -27,9 +27,17 @@ namespace Glk { +uint FontInfo::_caretColor; +uint FontInfo::_caretSave; +int FontInfo::_caretShape; + + FontInfo::FontInfo() : _size(0), _aspect(0), _cellW(0), _cellH(0), _leading(0), _baseLine(0), _linkStyle(0), _moreFont(PROPB), _moreAlign(0), _caps(0), _linkColor(0), _linkSave(0), - _moreColor(0), _moreSave(0), _caretShape(0), _caretColor(0), _caretSave(0) { + _moreColor(0), _moreSave(0) { + _caretShape = 0; + _caretColor = 0; + _caretSave = 0; } void FontInfo::drawCaret(const Point &pos) { diff --git a/engines/glk/fonts.h b/engines/glk/fonts.h index 156f4d44f8..afe28252e6 100644 --- a/engines/glk/fonts.h +++ b/engines/glk/fonts.h @@ -36,6 +36,10 @@ enum STYLES { FONTR, FONTB, FONTI, FONTZ }; * Font configuration info */ struct FontInfo { +public: + static uint _caretColor, _caretSave; + static int _caretShape; +public: double _size; double _aspect; int _cellW, _cellH; @@ -48,8 +52,6 @@ struct FontInfo { int _moreAlign; Common::String _morePrompt; int _caps; - uint _caretColor, _caretSave; - int _caretShape; /** * Constructor diff --git a/engines/glk/window_text_grid.cpp b/engines/glk/window_text_grid.cpp index be097251fc..e0459e0b2e 100644 --- a/engines/glk/window_text_grid.cpp +++ b/engines/glk/window_text_grid.cpp @@ -624,6 +624,13 @@ void TextGridWindow::redraw() { w += _bbox.right - (x + w); screen.fillRect(Rect::fromXYWH(x, y, w, _font._leading), bgcolor); + // Draw the caret if necessary + if (_windows->getFocusWindow() == this && i == _curY && + (_lineRequest || _lineRequestUni || _charRequest || _charRequestUni)) { + _font.drawCaret(Point((x0 + _curX * _font._cellW) * GLI_SUBPIX, y + _font._baseLine)); + } + + // Write out the text for (k = a, o = x; k < b; k++, o += _font._cellW) { screen.drawStringUni(Point(o * GLI_SUBPIX, y + _font._baseLine), font, fgcolor, Common::U32String(&ln->_chars[k], 1)); -- cgit v1.2.3