Implement PRGSET
This commit is contained in:
@@ -3174,6 +3174,10 @@ class BuiltinFunction
|
|||||||
{
|
{
|
||||||
return p.program.get();
|
return p.program.get();
|
||||||
}
|
}
|
||||||
|
static void PRGSET(PetitComputer p, wstring x)
|
||||||
|
{
|
||||||
|
p.program.set(x.dup);
|
||||||
|
}
|
||||||
//alias void function(PetitComputer, Value[], Value[]) BuiltinFunc;
|
//alias void function(PetitComputer, Value[], Value[]) BuiltinFunc;
|
||||||
static BuiltinFunctions[wstring] builtinFunctions;
|
static BuiltinFunctions[wstring] builtinFunctions;
|
||||||
static wstring getBasicName(BFD)(const wstring def)
|
static wstring getBasicName(BFD)(const wstring def)
|
||||||
|
|||||||
@@ -1,14 +1,20 @@
|
|||||||
module otya.smilebasic.program;
|
module otya.smilebasic.program;
|
||||||
import std.range;
|
import std.range;
|
||||||
import std.container;
|
import std.container;
|
||||||
|
import std.algorithm;
|
||||||
|
|
||||||
struct Slot
|
struct Slot
|
||||||
{
|
{
|
||||||
DList!wstring program;
|
DList!wstring program;
|
||||||
DList!wstring.Range range;
|
DList!wstring.Range range;
|
||||||
|
this(T)(T)
|
||||||
|
{
|
||||||
|
program = make!(DList!wstring);
|
||||||
|
range = program[];
|
||||||
|
}
|
||||||
|
|
||||||
void load(wstring data)
|
void load(wstring data)
|
||||||
{
|
{
|
||||||
import std.algorithm;
|
|
||||||
program.clear();
|
program.clear();
|
||||||
foreach(l; splitter(data, "\n"))
|
foreach(l; splitter(data, "\n"))
|
||||||
{
|
{
|
||||||
@@ -78,6 +84,29 @@ struct Slot
|
|||||||
range.popFront();
|
range.popFront();
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
void set(wstring v)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
foreach(l; splitter(v, "\n"))
|
||||||
|
{
|
||||||
|
if (!range.empty && i == 0)
|
||||||
|
{
|
||||||
|
range.put(l ~ "\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (range.empty)
|
||||||
|
{
|
||||||
|
program.insertAfter(range, l ~ "\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
program.insertBefore(range, l ~ "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Program
|
class Program
|
||||||
@@ -88,6 +117,10 @@ class Program
|
|||||||
this()
|
this()
|
||||||
{
|
{
|
||||||
slot = new Slot[5];
|
slot = new Slot[5];
|
||||||
|
foreach(ref s; slot)
|
||||||
|
{
|
||||||
|
s = Slot(slot);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void edit(int slot, int line)
|
void edit(int slot, int line)
|
||||||
{
|
{
|
||||||
@@ -98,4 +131,8 @@ class Program
|
|||||||
{
|
{
|
||||||
return this.slot[currentSlot].get;
|
return this.slot[currentSlot].get;
|
||||||
}
|
}
|
||||||
|
void set(wstring v)
|
||||||
|
{
|
||||||
|
this.slot[currentSlot].set = v;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user