FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
livecode/engine/src/cardlst.cpp at develop · livecodeali/livecode · GitHub
livecodeali
/
livecode
Public
forked from
livecode/livecode
Notifications
You must be signed in to change notification settings
Fork
1
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
livecode
/
engine
/
src
/
cardlst.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
277 lines (243 loc) · 5.5 KB
Breadcrumbs
livecode
/
engine
/
src
/
cardlst.cpp
Copy path
File metadata and controls
277 lines (243 loc) · 5.5 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
/*
Copyright (C) 2003-2015 LiveCode Ltd.
This file is part of LiveCode.
LiveCode is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License v3 as published by the Free
Software Foundation.
LiveCode 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 LiveCode. If not see <http://www.gnu.org/licenses/>.
*/
#
include
"
prefix.h
"
#
include
"
globdefs.h
"
#
include
"
filedefs.h
"
#
include
"
parsedef.h
"
#
include
"
objdefs.h
"
#
include
"
dispatch.h
"
#
include
"
stack.h
"
#
include
"
card.h
"
#
include
"
cardlst.h
"
#
include
"
util.h
"
#
include
"
exec.h
"
#
include
"
globals.h
"
MCCardnode::~MCCardnode
()
{ }
MCCardlist::MCCardlist
()
: first(
nullptr
)
{
cards =
NULL
;
interval =
0
;
}
MCCardlist::~MCCardlist
()
{
while
(cards !=
NULL
)
{
MCCardnode *cptr = cards->
remove
(cards);
delete
cptr;
}
}
void
MCCardlist::trim
()
{
//
Check for and remove any dead cards from the list
deletecard
(nil);
while
(interval >
MIN_FILL
)
{
cards = cards->
prev
();
MCCardnode *cptr = cards->
remove
(cards);
if
(first == cptr)
first = cards;
delete
cptr;
interval--;
}
}
bool
MCCardlist::GetRecent
(MCExecContext& ctxt, MCStack *stack, Properties which, MCStringRef& r_props)
{
//
Get list of recent card short names or long ids
trim
();
MCCardnode *tmp = cards;
MCAutoListRef t_prop_list;
bool
t_success;
t_success =
true
;
if
(t_success)
t_success =
MCListCreateMutable
(
'
\n
'
, &t_prop_list);
if
(t_success && tmp !=
NULL
)
{
do
{
if
(stack ==
NULL
|| tmp->
card
->
getstack
() == stack)
{
MCAutoStringRef t_property;
if
(which ==
P_SHORT_NAME
)
tmp -> card ->
GetShortName
(ctxt, &t_property);
else
tmp -> card ->
GetLongId
(ctxt,
0
, &t_property);
t_success = !ctxt .
HasError
();
if
(t_success)
t_success =
MCListAppend
(*t_prop_list, *t_property);
}
tmp = tmp->
next
();
}
while
(tmp != cards && t_success);
}
if
(t_success)
t_success =
MCListCopyAsString
(*t_prop_list, r_props);
return
t_success;
}
void
MCCardlist::addcard
(MCCard *card)
{
//
Prune all dead cards from the recent list
trim
();
//
If the recent list is not to be updated or this card is already at the
//
head of the list, do nothing.
if
((cards !=
NULL
&& cards->
card
== card) || MClockrecent)
return
;
MCCardnode *nptr =
new
(nothrow) MCCardnode;
nptr->
card
= card;
if
(cards ==
NULL
)
first = nptr;
nptr->
insertto
(cards);
if
(interval++ >
MAX_FILL
)
trim
();
}
void
MCCardlist::deletecard
(MCCard *card)
{
MCCardnode *tmp = cards;
Boolean restart;
if
(tmp !=
NULL
)
do
{
restart = False;
if
(!tmp->
card
.
IsValid
() || tmp->
card
== card)
{
if
(tmp == first)
first = tmp->
next
();
if
(tmp == cards)
{
MCCardnode *tptr = cards->
remove
(cards);
delete
tptr;
interval--;
tmp = cards;
if
(cards ==
NULL
)
break
;
else
restart = True;
}
else
{
MCCardnode *tptr = tmp->
remove
(tmp);
delete
tptr;
interval--;
}
}
else
tmp = tmp->
next
();
}
while
(restart || tmp != cards);
}
void
MCCardlist::deletestack
(MCStack *stack)
{
MCCardnode *tmp = cards;
Boolean restart;
if
(tmp !=
NULL
)
do
{
restart = False;
if
(!tmp->
card
.
IsValid
() || tmp->
card
->
getstack
() == stack)
{
if
(tmp == first)
first = tmp->
next
();
if
(tmp == cards)
{
MCCardnode *tptr = cards->
remove
(cards);
delete
tptr;
interval--;
tmp = cards;
if
(cards ==
NULL
)
break
;
else
restart = True;
}
else
{
MCCardnode *tptr = tmp->
remove
(tmp);
delete
tptr;
interval--;
}
}
else
tmp = tmp->
next
();
}
while
(restart || tmp != cards);
}
void
MCCardlist::gorel
(int2 offset)
{
if
(cards ==
NULL
)
return
;
if
(offset >
0
)
while
(offset--)
cards = cards->
prev
();
else
while
(offset++)
cards = cards->
next
();
MCStack *sptr = cards->
card
->
getstack
();
if
(sptr != MCdefaultstackptr && MCdefaultstackptr->
hcstack
())
MCdefaultstackptr->
close
();
sptr->
setcard
(cards->
card
, False, False);
sptr->
openrect
(sptr->
getrect
(),
WM_LAST
,
NULL
,
WP_DEFAULT
,
OP_NONE
);
MCdefaultstackptr = sptr;
}
MCCard *
MCCardlist::getrel
(int2 offset)
{
if
(cards ==
NULL
)
return
NULL
;
MCCardnode *tptr = cards;
if
(offset >
0
)
while
(offset--)
tptr = tptr->
prev
();
else
while
(offset++)
tptr = tptr->
next
();
return
tptr->
card
;
}
void
MCCardlist::godirect
(Boolean start)
{
if
(cards ==
NULL
)
return
;
if
(start)
cards = first;
else
cards = first->
next
();
MCStack *sptr = cards->
card
->
getstack
();
if
(sptr != MCdefaultstackptr && MCdefaultstackptr->
hcstack
())
MCdefaultstackptr->
close
();
sptr->
setcard
(cards->
card
, False, False);
sptr->
openrect
(sptr->
getrect
(),
WM_LAST
,
NULL
,
WP_DEFAULT
,
OP_NONE
);
MCdefaultstackptr = sptr;
}
void
MCCardlist::pushcard
(MCCard *card)
{
if
(card ==
NULL
)
return
;
MCCardnode *nptr =
new
(nothrow) MCCardnode;
nptr->
card
= card;
nptr->
insertto
(cards);
}
MCCard *
MCCardlist::popcard
()
{
if
(cards !=
NULL
)
{
MCCardnode *tptr = cards->
remove
(cards);
MCCard *card = tptr->
card
;
delete
tptr;
return
card;
}
return
MCdispatcher->
gethome
()->
getcurcard
();
}
Back
|
FazBrowse Home
|
New Git URL