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
This commit is contained in:
Paul Gilbert 2019-03-02 18:09:34 -08:00
parent 6be0dbe016
commit 3b8d006c8b
4 changed files with 20 additions and 6 deletions

View File

@ -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;

View File

@ -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) {

View File

@ -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

View File

@ -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));