-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathObSysInnerLib.h
155 lines (132 loc) · 4.3 KB
/
ObSysInnerLib.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#ifndef OBSYSINNERLIB_H
#define OBSYSINNERLIB_H
/*
* Copyright 2019 Rochus Keller <mailto:[email protected]>
*
* This file is part of the Oberon parser/compiler library.
*
* The following is the license that applies to this copy of the
* library. For a license to use the library under conditions
* other than those described here, please email to [email protected].
*
* GNU General Public License Usage
* This file may be used under the terms of the GNU General Public
* License (GPL) versions 2.0 or 3.0 as published by the Free Software
* Foundation and appearing in the file LICENSE.GPL included in
* the packaging of this file. Please review the following information
* to ensure GNU General Public Licensing requirements will be met:
* http://www.fsf.org/licensing/licenses/info/GPLv2.html and
* http://www.gnu.org/copyleft/gpl.html.
*/
#include <QBuffer>
#include <QWidget>
#include <Oberon/ObLjLib.h>
#include <QDateTime>
namespace Ob
{
class QtDisplay : public QWidget
{
Q_OBJECT
public:
enum { Width = 1024, Height = 768 };
// enum { Width = 1000, Height = 600 };
QImage d_img;
int d_xOb, d_yOb;
Ob::_Set d_keys;
int d_lock;
QByteArray arrow;
QByteArray star;
QByteArray hook;
QByteArray updown;
QByteArray block;
QDateTime start;
int clock;
int mouseHandler;
int charHandler;
int idleHandler;
static QtDisplay* inst();
static int mapToQt(int yOb);
static int mapToOb(int yQt);
typedef void (*IdleHandler)();
protected:
void paintEvent(QPaintEvent *);
void timerEvent(QTimerEvent *);
void mouseMoveEvent(QMouseEvent *);
void mousePressEvent(QMouseEvent *);
void mouseReleaseEvent(QMouseEvent *);
void keyPressEvent(QKeyEvent *);
void keyReleaseEvent(QKeyEvent *);
bool mapOb( QMouseEvent* );
void dispatchMouse(const Ob::_Set& keys, int x, int y);
private:
explicit QtDisplay();
~QtDisplay();
};
struct FileDesc;
typedef FileDesc* File;
struct Rider {
// public:
bool eof;
int res;
// c++ implementation:
int d_fileRef; // luaL_ref value
File d_file;
int d_pos;
Rider():d_file(0),d_pos(0){}
static void install(lua_State* L);
static int _new(lua_State* L);
static Rider* check(lua_State *L, int narg = 1 );
static int _gc(lua_State* L);
static int _index(lua_State* L);
static int Set(lua_State* L);
static int Pos(lua_State* L);
static int Base(lua_State* L);
static int ReadByte(lua_State* L);
void ReadByte(quint8& x);
static int Read(lua_State* L);
static int ReadInt(lua_State* L);
static int ReadNum(lua_State* L);
static int ReadString(lua_State* L);
void WriteByte(quint8 x);
static int WriteByte(lua_State* L);
static int Write(lua_State* L);
static int WriteInt(lua_State* L);
static int WriteNum(lua_State* L);
static int WriteString(lua_State* L);
static int RestoreList(lua_State* L);
};
struct FileDesc {
// c++ implementation:
QByteArray d_name;
QBuffer d_buf;
static void install(lua_State* L);
static FileDesc* create(lua_State* L);
static int _new(lua_State* L);
static FileDesc* check(lua_State *L, int narg = 1, bool nilAllowed = false );
static int _gc(lua_State* L);
static int Old(lua_State* L);
static int New(lua_State* L);
static int Register(lua_State* L);
static int Delete(lua_State* L);
static int Rename(lua_State* L);
static int Length(lua_State* L);
};
// Files module
// Attr fileSystemPath
class SysInnerLib
{
public:
static void install(lua_State *L);
static void quit();
protected:
static int installFiles(lua_State *L);
static int installFileDir(lua_State *L);
static int installKernel(lua_State *L);
static int installDisplay(lua_State *L);
static int installModules(lua_State *L);
static int installInput(lua_State *L);
private:
SysInnerLib();
};
}
#endif // OBSYSINNERLIB_H