mirror of
https://github.com/scummvm/scummvm.git
synced 2026-06-20 05:45:29 +00:00
GLK: Skeleton implementation of window text stream
This commit is contained in:
committed by
Paul Gilbert
parent
3c9987c0a7
commit
256f7ff312
+12
-11
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "gargoyle/glk.h"
|
||||
#include "gargoyle/events.h"
|
||||
#include "gargoyle/stream.h"
|
||||
#include "gargoyle/windows.h"
|
||||
|
||||
namespace Gargoyle {
|
||||
@@ -122,8 +123,7 @@ void Glk::glk_window_move_cursor(winid_t win, glui32 xpos, glui32 ypos) {
|
||||
}
|
||||
|
||||
strid_t Glk::glk_window_get_stream(winid_t win) {
|
||||
// TODO
|
||||
return nullptr;
|
||||
return win->_stream;
|
||||
}
|
||||
|
||||
void Glk::glk_window_set_echo_stream(winid_t win, strid_t str) {
|
||||
@@ -136,7 +136,7 @@ strid_t Glk::glk_window_get_echo_stream(winid_t win) {
|
||||
}
|
||||
|
||||
void Glk::glk_set_window(winid_t win) {
|
||||
_windows->setCurrent(win ? win->str : nullptr);
|
||||
_windows->setCurrent(win ? win->_stream : nullptr);
|
||||
}
|
||||
|
||||
strid_t Glk::glk_stream_open_file(frefid_t fileref, glui32 fmode,
|
||||
@@ -371,27 +371,28 @@ glui32 Glk::glk_buffer_to_title_case_uni(glui32 *buf, glui32 len,
|
||||
}
|
||||
|
||||
void Glk::glk_put_char_uni(glui32 ch) {
|
||||
// TODO
|
||||
glk_put_char_stream_uni(_windows->getCurrent(), ch);
|
||||
}
|
||||
|
||||
void Glk::glk_put_string_uni(glui32 *s) {
|
||||
// TODO
|
||||
glk_put_buffer_stream_uni(_windows->getCurrent(), s, strlen_uni(s));
|
||||
}
|
||||
|
||||
void Glk::glk_put_buffer_uni(glui32 *buf, glui32 len) {
|
||||
// TODO
|
||||
glk_put_buffer_stream_uni(_windows->getCurrent(), buf, len);
|
||||
}
|
||||
|
||||
void Glk::glk_put_char_stream_uni(strid_t str, glui32 ch) {
|
||||
// TODO
|
||||
str->writeUint32LE(ch);
|
||||
}
|
||||
|
||||
void Glk::glk_put_string_stream_uni(strid_t str, glui32 *s) {
|
||||
// TODO
|
||||
void Glk::glk_put_string_stream_uni(strid_t str, const glui32 *s) {
|
||||
glk_put_buffer_stream_uni(str, s, strlen_uni(s));
|
||||
}
|
||||
|
||||
void Glk::glk_put_buffer_stream_uni(strid_t str, glui32 *buf, glui32 len) {
|
||||
// TODO
|
||||
void Glk::glk_put_buffer_stream_uni(strid_t str, const glui32 *buf, glui32 len) {
|
||||
while (len-- > 0)
|
||||
str->writeUint32LE(*buf++);
|
||||
}
|
||||
|
||||
glsi32 Glk::glk_get_char_stream_uni(strid_t str) {
|
||||
|
||||
@@ -171,8 +171,8 @@ public:
|
||||
void glk_put_string_uni(glui32 *s);
|
||||
void glk_put_buffer_uni(glui32 *buf, glui32 len);
|
||||
void glk_put_char_stream_uni(strid_t str, glui32 ch);
|
||||
void glk_put_string_stream_uni(strid_t str, glui32 *s);
|
||||
void glk_put_buffer_stream_uni(strid_t str, glui32 *buf, glui32 len);
|
||||
void glk_put_string_stream_uni(strid_t str, const glui32 *s);
|
||||
void glk_put_buffer_stream_uni(strid_t str, const glui32 *buf, glui32 len);
|
||||
|
||||
glsi32 glk_get_char_stream_uni(strid_t str);
|
||||
glui32 glk_get_buffer_stream_uni(strid_t str, glui32 *buf, glui32 len);
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#define GARGOYLE_GLK_TYPES_H
|
||||
|
||||
#include "common/scummsys.h"
|
||||
#include "common/stream.h"
|
||||
|
||||
namespace Gargoyle {
|
||||
|
||||
@@ -49,7 +50,7 @@ class Window;
|
||||
* These types are opaque object identifiers. They're pointers to opaque
|
||||
* C structures, which are defined differently by each library.
|
||||
*/
|
||||
typedef struct glk_stream_struct *strid_t;
|
||||
typedef Common::WriteStream *strid_t;
|
||||
typedef struct glk_fileref_struct *frefid_t;
|
||||
typedef struct glk_schannel_struct *schanid_t;
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ MODULE_OBJS := \
|
||||
gargoyle.o \
|
||||
glk.o \
|
||||
picture.o \
|
||||
stream.o \
|
||||
windows.o \
|
||||
scott/detection.o \
|
||||
scott/scott.o
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software{} you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation{} either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY{} without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program{} if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "gargoyle/stream.h"
|
||||
|
||||
namespace Gargoyle {
|
||||
|
||||
uint32 WindowStream::write(const void *dataPtr, uint32 dataSize) {
|
||||
// TODO
|
||||
return dataSize;
|
||||
}
|
||||
|
||||
bool WindowStream::flush() {
|
||||
// TODO
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t strlen_uni(const uint32 *s) {
|
||||
size_t len = 0;
|
||||
while (*s++)
|
||||
++len;
|
||||
return len;
|
||||
}
|
||||
|
||||
} // End of namespace Gargoyle
|
||||
@@ -0,0 +1,74 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef GARGOYLE_STREAM_H
|
||||
#define GARGOYLE_STREAM_H
|
||||
|
||||
#include "common/stream.h"
|
||||
|
||||
namespace Gargoyle {
|
||||
|
||||
class Window;
|
||||
|
||||
/**
|
||||
* Implements the stream for writing text to a window
|
||||
*/
|
||||
class WindowStream : public Common::WriteStream {
|
||||
private:
|
||||
uint32 _rock;
|
||||
Window *_window;
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
WindowStream(Window *window, uint32 rock = 0) : Common::WriteStream(),
|
||||
_window(window), _rock(rock) {}
|
||||
|
||||
/**
|
||||
* Write to the stream
|
||||
*/
|
||||
virtual uint32 write(const void *dataPtr, uint32 dataSize);
|
||||
|
||||
/**
|
||||
* Flush the stream
|
||||
*/
|
||||
virtual bool flush();
|
||||
|
||||
/**
|
||||
* Finalize and close this stream
|
||||
*/
|
||||
virtual void finalize() { flush(); }
|
||||
|
||||
/**
|
||||
* Returns the stream position
|
||||
*/
|
||||
virtual int32 pos() const { return 0; }
|
||||
};
|
||||
|
||||
/*
|
||||
* Get the length of a unicode string
|
||||
*/
|
||||
size_t strlen_uni(const uint32 *s);
|
||||
|
||||
} // End of namespace Gargoyle
|
||||
|
||||
#endif
|
||||
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
|
||||
#include "gargoyle/windows.h"
|
||||
#include "gargoyle/stream.h"
|
||||
#include "common/algorithm.h"
|
||||
#include "common/textconsole.h"
|
||||
|
||||
@@ -281,10 +282,6 @@ void Windows::clearSelection() {
|
||||
_claimSelect = false;
|
||||
}
|
||||
|
||||
void Windows::setCurrent(Common::WriteStream *stream) {
|
||||
_currentStr = stream;
|
||||
}
|
||||
|
||||
void Windows::repaint(const Common::Rect &box) {
|
||||
// TODO
|
||||
}
|
||||
@@ -295,7 +292,7 @@ Window::Window(Windows *windows, glui32 rock) : _magicnum(MAGIC_WINDOW_NUM),
|
||||
_windows(windows), _rock(rock), _type(0), parent(nullptr), next(nullptr), prev(nullptr),
|
||||
yadj(0), line_request(0), line_request_uni(0), char_request(0), char_request_uni(0),
|
||||
mouse_request(0), hyper_request(0), more_request(0), scroll_request(0), image_loaded(0),
|
||||
echo_line_input(true), line_terminators(nullptr), termct(0), str(nullptr), echostr(nullptr) {
|
||||
echo_line_input(true), line_terminators(nullptr), termct(0), _echoStream(nullptr) {
|
||||
attr.fgset = 0;
|
||||
attr.bgset = 0;
|
||||
attr.reverse = 0;
|
||||
@@ -307,6 +304,8 @@ Window::Window(Windows *windows, glui32 rock) : _magicnum(MAGIC_WINDOW_NUM),
|
||||
Common::fill(&bgcolor[0], &bgcolor[3], 3);
|
||||
Common::fill(&fgcolor[0], &fgcolor[3], 3);
|
||||
disprock.num = 0;
|
||||
|
||||
_stream = new WindowStream(this, rock);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
@@ -116,7 +116,12 @@ public:
|
||||
/**
|
||||
* Set the current output stream
|
||||
*/
|
||||
void setCurrent(Common::WriteStream *stream);
|
||||
void setCurrent(Common::WriteStream *stream) { _currentStr = stream; }
|
||||
|
||||
/**
|
||||
* Gets the current output stream
|
||||
*/
|
||||
Common::WriteStream *getCurrent() const { return _currentStr; }
|
||||
|
||||
/**
|
||||
* Repaint an area of the windows
|
||||
@@ -179,12 +184,12 @@ public:
|
||||
glui32 _rock;
|
||||
glui32 _type;
|
||||
|
||||
Window *parent; ///< pair window which contains this one
|
||||
Window *parent; ///< pair window which contains this one
|
||||
Common::Rect bbox;
|
||||
int yadj;
|
||||
|
||||
Common::WriteStream *str; ///< the window stream.
|
||||
Common::WriteStream *echostr; ///< the window's echo stream, if any.
|
||||
Common::WriteStream *_stream; ///< the window stream.
|
||||
Common::WriteStream *_echoStream; ///< the window's echo stream, if any.
|
||||
|
||||
int line_request;
|
||||
int line_request_uni;
|
||||
|
||||
Reference in New Issue
Block a user