On Tuesday, 18 October 2022 at 05:48:27 UTC, Ali Çehreli wrote:
On 10/17/22 22:40, Joel wrote:
> I have two text fields. The one on the left has the whole
text, new
> stuff being added to the bottom. The one on the right has
text I've been
> wiping as I'm reading.
I think this can be modelled as a string array and an index
showing where the active part starts:
import std;
struct Notes {
string[] whole;
size_t activeIndex;
void add(string line) {
whole ~= line;
}
string[] activeText() {
return whole[activeIndex..$];
}
void wipeText() {
++activeIndex;
}
}
void main() {
auto input = [ "I went for a walk and fell down a hole.",
"There was a D guy on the roof.",
"That was a tricky problem!", ];
Notes notes;
// add() to add()
input.each!(line => notes.add(line));
// activeText() will show the active part
// wipeText() will move forward
}
Ali
I want to have two text files, for each notes I'm reading and
wiping. Keep adding to one and reading wiping and updating the
other one. I want my program to process them by updating the
temporary notes.