Windows Text Viewer in D

c-smile andrew.fedoniouk at gmail.com
Wed May 20 01:15:05 UTC 2026


On Thursday, 9 April 2026 at 01:27:47 UTC, Paul wrote:

> Some goals are:
> -as little dependency on specific IDE's or compilers, if 
> possible.  Just include all the dependencies on the command 
> line, if possible.
>
> -long term I plan on loading 100s of text files and having 
> millions of lines of text to highlight and filter. I feel if 
> I'm depending on big complex libraries, that optimizing the 
> viewer will be much more difficult.

Here is 2 hours project - TextViewer using Sciter. Self-portrait 
of TextViewer:

![TextViewer 
v.0.1](https://sciter.com/wp-content/uploads/2026/05/textviewer.jpg)

[TextViewer 
sample](https://gitlab.com/sciter-engine/sciter-js-sdk/-/tree/main/sciter%2B/D/demos/textviewer?ref_type=heads) is part of [Sciter SDK](https://gitlab.com/sciter-engine/sciter-js-sdk/) now. Grab it and run sdk/sciter+/D/demos/textviewer/build-win.bat

While the task sounds simple it has technical challenges:

Loading whole file in memory is no-go. This implementation uses 
so called virtual-list - sliding window that loads just portion 
of file lines in a view.

Opening and access to a text file is made in D using MmFile class.

### How to do colorization / syntax highlighting

Sciter renders its stuff as HTML and D side, instead of plain 
text, may supply to the viewer html fragments. So not plain text 
as `"import std.mmfile;"` line but supply html fragment 
`"<span.keyword>import</span> std.mmfile;".

Adding then CSS declaration like
```
span.keyword { color:blue; }
```
will make output colorful. If you will decided to go that way 
uncomment 
[this](https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/sciter%2B/D/demos/textviewer/res/TextTape.js?ref_type=heads#L65-L74).



More information about the Digitalmars-d-learn mailing list