-
Notifications
You must be signed in to change notification settings - Fork 1
/
movetext.h
executable file
·148 lines (106 loc) · 2.75 KB
/
movetext.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
#ifndef _MOVETEXT_
#define _MOVETEXT_
#include <unistd.h>
#include "movelib.h"
#include "anisysd.h"
#include "rtproc.h"
//#include "movecmd.h"
#include "globalsymbols.h"
//#include <stdlib.h>
/* Convert this to a proper class */
class MoveText {
friend class MoveTextCursor;
long active_count;
//int inactive;
long length;
char * text;
virtual ~MoveText();
public:
bool autoclean;
MoveText() {
active_count = 0;
autoclean=false;
//inactive=0;
length=0;
text=NULL;
}
/* Create new MoveText and duplicate buffer */
MoveText(const char * buf,int len);
void incRef();
void decRef();
//int getActiveCount(){return active_count;};
//bool isActive(){return (!inactive);};
MoveText * clean();
void copyAsBuffer(char * buf);
void setBuffer(char * buf,int len) { text=buf; length=len; };
};
class MoveTextCursor {
/* Handle cursor position and command level within a MoveText buffer */
MoveText * movetext;
char * buffer;
char * bpos ;
short level;
RTProcess * owner /* Usually a (rMoveProc *) */;
public:
MoveTextCursor(MoveText * text,RTProcess * _owner) {
movetext = NULL;
setText(text);
owner=_owner;
}
bool isLoaded() {
return (movetext != NULL) ;
}
void setText(MoveText * text) {
if (movetext) {
movetext->decRef(); }
movetext = text;
if (movetext) {
buffer = text->text;
text->incRef();
}
else {
buffer = NULL; }
reset();
}
void reset() {
bpos = buffer;
level=0;
}
~MoveTextCursor() {
if (movetext)
movetext->decRef();
}
RTProcess * getOwner(){return owner;};
int getLevel(){return level;};
void setLevel(int lvl){level=lvl;};
void incLevel(){level++;};
void decLevel(){level--;};
const char * getPosition(){return bpos;};
void setPosition(const char * pos){bpos=(char *)pos;}; /* CHECK THIS */
void setBufferStart(const char * pos) {buffer=bpos;}; /* CHECK THIS */
int ReadToNext(); TOKENELEMENT * nextToken();
};
/*
typedef struct {
long active_count;
int free_on_exit;
int inactive;
long textlength;
char text[1];
} MOVETEXT;
typedef struct {
char * buffer;
char * bpos ;
short level;
char * owner; // Usually a (rMoveProc *)
} MOVEREADPOS;
*/
// initfile.cpp
//extern MOVETEXT * InitFile(char * fname,VOLID_TYPE * fileSpec);
extern MoveText * InitFile(char * fname,VOLID_TYPE * fileSpec);
// moveparse.c
//int GetNextMove(MOVEREADPOS * aText,MOVEBLOCK aMove);
#endif