DIRECTOR: LINGO: Implement b_delete/cb_delete

This commit is contained in:
djsrv 2021-06-10 11:51:50 -04:00
parent b5767a793c
commit e3f75a9bc4
2 changed files with 47 additions and 7 deletions

View File

@ -502,13 +502,50 @@ void LB::b_charToNum(int nargs) {
}
void LB::b_delete(int nargs) {
Datum d = g_lingo->pop();
Datum d = g_lingo->pop(false);
Datum res(d.asInt());
Datum field;
int start, end;
if (d.type == FIELDREF || d.type == VAR) {
field = d;
start = 0;
end = -1;
} else if (d.type == CHUNKREF) {
TYPECHECK2(d.u.cref->source, FIELDREF, VAR);
field = d.u.cref->source;
start = d.u.cref->start;
end = d.u.cref->end;
} else {
warning("b_delete: bad field type: %s", d.type2str());
return;
}
warning("STUB: b_delete");
if (start < 0)
return;
g_lingo->push(res);
Common::String text = g_lingo->varFetch(field).asString();
if (d.type == CHUNKREF) {
switch (d.u.cref->type) {
case kChunkChar:
break;
case kChunkWord:
while (end < (int)text.size() && Common::isSpace(text[end]))
end++;
break;
case kChunkItem:
case kChunkLine:
// last char of the first portion is the delimiter. skip it.
if (start > 0)
start--;
break;
}
}
Common::String res = text.substr(0, start) + text.substr(end);
Datum s;
s.u.s = new Common::String(res);
s.type = STRING;
g_lingo->varAssign(field, s);
}
void LB::b_hilite(int nargs) {

View File

@ -372,9 +372,12 @@ void LC::cb_unk2() {
}
void LC::cb_delete() {
g_lingo->readInt();
g_lingo->printSTUBWithArglist("cb_delete", 9);
g_lingo->dropStack(9);
int varType = g_lingo->readInt();
Datum varID = g_lingo->pop();
Datum var = g_lingo->findVarV4(varType, varID);
Datum chunkRef = readChunkRef(var);
g_lingo->push(chunkRef);
LB::b_delete(1);
}
void LC::cb_field() {