Here's a little snippet of code that interfaces with Scintilla (it works btw.):
File file = File("test.txt", "r");
foreach (ubyte[] buf; file.byChunk(4096))
{
sendEditor(SCI_ADDTEXT, buf.length, (cast(char[])buf).idup);
}
The cast looks ugly, but I *have* to send a copy. Am I doing it right, or can I
make this a bit simpler? Otherwise I can use file.byLine, but I think this
would be much slower (unless D reads the entire contents at once into memory,
but I think it does not).
Actually, I shouldn't even complain. I can't believe how easy it is to open a
file, use buffers and send it all to a C interface. This is a 4-liner, the C
equivalent spans 20+ lines. Ha!