diff options
author | Paul Gilbert | 2018-10-25 18:38:55 -0700 |
---|---|---|
committer | Paul Gilbert | 2018-12-08 19:05:59 -0800 |
commit | 4266f3af130ddeddbed5da9d6c7aa4826ad94d96 (patch) | |
tree | c9c39bea1a2b5a6aa38d29ce2fb293f633a1fedd | |
parent | 72022042ee303fde02eef2264d430d56526768ed (diff) | |
download | scummvm-rg350-4266f3af130ddeddbed5da9d6c7aa4826ad94d96.tar.gz scummvm-rg350-4266f3af130ddeddbed5da9d6c7aa4826ad94d96.tar.bz2 scummvm-rg350-4266f3af130ddeddbed5da9d6c7aa4826ad94d96.zip |
GLK: Adding more window glk methods
-rw-r--r-- | engines/gargoyle/glk.cpp | 51 | ||||
-rw-r--r-- | engines/gargoyle/window_text_buffer.h | 6 | ||||
-rw-r--r-- | engines/gargoyle/window_text_grid.h | 4 | ||||
-rw-r--r-- | engines/gargoyle/windows.cpp | 28 | ||||
-rw-r--r-- | engines/gargoyle/windows.h | 8 |
5 files changed, 89 insertions, 8 deletions
diff --git a/engines/gargoyle/glk.cpp b/engines/gargoyle/glk.cpp index 1e6dfa3d36..43ba646851 100644 --- a/engines/gargoyle/glk.cpp +++ b/engines/gargoyle/glk.cpp @@ -387,11 +387,25 @@ void Glk::glk_request_timer_events(glui32 millisecs) { } void Glk::glk_request_line_event(winid_t win, char *buf, glui32 maxlen, glui32 initlen) { - // TODO + if (!win) { + warning("request_line_event: invalid ref"); + } else if (win->_charRequest || win->_lineRequest || win->_charRequestUni + || win->_lineRequestUni) { + warning("request_line_event: window already has keyboard request"); + } else { + win->requestLineEvent(buf, maxlen, initlen); + } } void Glk::glk_request_char_event(winid_t win) { - // TODO + if (!win) { + warning("request_char_event: invalid ref"); + } else if (win->_charRequest || win->_lineRequest || win->_charRequestUni + || win->_lineRequestUni) { + warning("request_char_event: window already has keyboard request"); + } else { + win->requestCharEvent(); + } } void Glk::glk_request_mouse_event(winid_t win) { @@ -413,7 +427,11 @@ void Glk::glk_cancel_mouse_event(winid_t win) { #ifdef GLK_MODULE_LINE_ECHO void Glk::glk_set_echo_line_event(winid_t win, glui32 val) { - // TODO + if (!win) { + warning("set_echo_line_event: invalid ref"); + } else { + win->setEchoLineEvent(val); + } } #endif /* GLK_MODULE_LINE_ECHO */ @@ -421,7 +439,11 @@ void Glk::glk_set_echo_line_event(winid_t win, glui32 val) { #ifdef GLK_MODULE_LINE_TERMINATORS void Glk::glk_set_terminators_line_event(winid_t win, glui32 *keycodes, glui32 count) { - // TODO + if (!win) { + warning("set_terminators_line_event: invalid ref"); + } else { + win->setTerminatorsLineEvent(keycodes, count); + } } #endif /* GLK_MODULE_LINE_TERMINATORS */ @@ -505,12 +527,25 @@ strid_t Glk::glk_stream_open_memory_uni(glui32 *buf, glui32 buflen, FileMode fmo } void Glk::glk_request_char_event_uni(winid_t win) { - // TODO + if (!win) { + warning("request_char_event_uni: invalid ref"); + } else if (win->_charRequest || win->_lineRequest || win->_charRequestUni + || win->_lineRequestUni) { + warning("request_char_event_uni: window already has keyboard request"); + } else { + win->requestCharEvent(); + } } -void Glk::glk_request_line_event_uni(winid_t win, glui32 *buf, - glui32 maxlen, glui32 initlen) { - // TODO +void Glk::glk_request_line_event_uni(winid_t win, glui32 *buf, glui32 maxlen, glui32 initlen) { + if (!win) { + warning("request_line_event_uni: invalid ref"); + } else if (win->_charRequest || win->_lineRequest || win->_charRequestUni + || win->_lineRequestUni) { + warning("request_line_event_uni: window already has keyboard request"); + } else { + win->requestLineEventUni(buf, maxlen, initlen); + } } #endif /* GLK_MODULE_UNICODE */ diff --git a/engines/gargoyle/window_text_buffer.h b/engines/gargoyle/window_text_buffer.h index 0c59cd2fac..094d6d0eec 100644 --- a/engines/gargoyle/window_text_buffer.h +++ b/engines/gargoyle/window_text_buffer.h @@ -208,6 +208,12 @@ public: virtual void getSize(glui32 *width, glui32 *height) override; + virtual void requestCharEvent() override { _charRequest = true; } + + virtual void requestCharEventUni() override { _charRequestUni = true; } + + virtual void setEchoLineEvent(glui32 val) override { _echoLineInput = val != 0; } + int acceptScroll(glui32 arg); glui32 drawPicture(glui32 image, glui32 align, glui32 scaled, glui32 width, glui32 height); diff --git a/engines/gargoyle/window_text_grid.h b/engines/gargoyle/window_text_grid.h index 2b8448c799..17fa96f5cc 100644 --- a/engines/gargoyle/window_text_grid.h +++ b/engines/gargoyle/window_text_grid.h @@ -157,6 +157,10 @@ public: virtual void acceptReadChar(glui32 arg) override; virtual void getSize(glui32 *width, glui32 *height) override; + + virtual void requestCharEvent() override { _charRequest = true; } + + virtual void requestCharEventUni() override { _charRequestUni = true; } }; } // End of namespace Gargoyle diff --git a/engines/gargoyle/windows.cpp b/engines/gargoyle/windows.cpp index 400689c154..7c5b259aba 100644 --- a/engines/gargoyle/windows.cpp +++ b/engines/gargoyle/windows.cpp @@ -479,6 +479,34 @@ void Window::setArrangement(glui32 method, glui32 size, Window *keyWin) { warning("setArrangement: not a Pair window"); } +void Window::requestCharEvent() { + warning("requestCharEvent: window does not support keyboard input"); +} + +void Window::requestCharEventUni() { + warning("requestCharEventUni: window does not support keyboard input"); +} + +void Window::setTerminatorsLineEvent(glui32 *keycodes, glui32 count) { + if (dynamic_cast<TextBufferWindow *>(this) || dynamic_cast<TextGridWindow *>(this)) { + delete _lineTerminatorsBase; + _lineTerminatorsBase = nullptr; + + if (!keycodes || count == 0) { + _termCt = 0; + } else { + _lineTerminatorsBase = new glui32[count + 1]; + if (_lineTerminatorsBase) { + memcpy(_lineTerminatorsBase, keycodes, count * sizeof(glui32)); + _lineTerminatorsBase[count] = 0; + _termCt = count; + } + } + } else { + warning("setTerminatorsLineEvent: window does not support keyboard input"); + } +} + bool Window::checkTerminator(glui32 ch) { if (ch == keycode_Escape) return true; diff --git a/engines/gargoyle/windows.h b/engines/gargoyle/windows.h index 5a4c022151..3c419e5604 100644 --- a/engines/gargoyle/windows.h +++ b/engines/gargoyle/windows.h @@ -362,6 +362,8 @@ public: int acceptScroll(glui32 arg); + void setTerminatorsLineEvent(glui32 *keycodes, glui32 count); + virtual glui32 drawPicture(glui32 image, glui32 align, glui32 scaled, glui32 width, glui32 height) { return false; } virtual void acceptReadLine(glui32 arg); @@ -373,6 +375,12 @@ public: virtual void setArrangement(glui32 method, glui32 size, Window *keyWin); virtual void getSize(glui32 *width, glui32 *height); + + virtual void requestCharEvent(); + + virtual void requestCharEventUni(); + + virtual void setEchoLineEvent(glui32 val) {} }; typedef Window *winid_t; |