Writing text editor from scratch in D & Raylib
madwebness
qount25 at protonmail.com
Sat Apr 4 09:37:25 UTC 2026
Hi everyone. Decided to share my work after almost a year of slow
grind.
"ick" is a text editor I am writing in D. One of my main goals is
to keep the codebase small, readable, and easy to understand --
so it's not just features, but about making an editor that stays
hackable and maintainable over time and avoid turning into a
mess.
Here's a short [video
demonstration](https://qount25.dev/video/ick_syntax_highlihght_2.mp4)
If you're still here and interested, here's an overview of what
ick can currently do and how it's designed:
* Internally, it's a pretty simple model: there's document,
lines, cursor, viewport, grid, syntax spans...
* A lot of behavior is config-driven. Key bindings, syntax
schemes, syntax themes, GUI theme, fonts are all loaded from
files.
* Syntax highlight doesn't use tree-sitter (too complex) or LSPs
(complex & slow). Instead I picked an unusual approach wherein I
use "steps" of small regexes and custom D functions which pick
spans on each line, which are then highlighted. There are
"schemes", "themes" (applies to schemes) and also "editor
themes", which are planned to basically modify themes on the fly
so colors match better. This makes it extremely flexible and
fast. Also, because I don't care about LSPs or tree-sitter,
syntax highlight doesn't actually have to follow language syntax
- this enabled a lot of interesting things.
* Rendering is based on a grid/cell model, which keeps the GUI
side conceptually simple. It's not the bestest, as they say, but
I think simplicity is more important. Also yes, it only works
well with mono fonts.
* Commands... Firstly, you get the usual kind of editor behavior
you'd expect from Vim or Kakoune or Helix: different modes,
movement, editing, numeric prefixes, leader-style sequences,
staged commands (they work a bit differently than Vim, better I'd
say) that wait for a motion or selection etc. All bindings are
loaded from a config file. Every binding executes one or more
commands, and while commands themselves are D functions --
because you can stack one on top of another, it's very
composable. For example, this would be the equivalent of Vim's
"o" (adding new line) taken from ick's bindings config file: `o
move_right(-1);insert_newline;move_down;move_line_start;switch_to_insert`
So, folks, while I can't say it's very useful as of the moment
(I'm still writing my code in Vim), it's getting there. I can at
least say I outlined some major design, architecture and features
so that the development direction is more or less clear.
Would appreciate your thoughts about the code and editor itself.
I don't expect anyone to be so interested as to help out with the
development - and, besides, like many other programmers, it's
pretty hard for me to let go of control. But I think it might be
worth it to start building a small community around it, so that
people at least discuss it and contribute ideas. I have a
personal Element/Matrix server, where I can invite anyone who
wants to contribute one way or another, even if with just the
occasional conversations - so ping here or in DM if you'd like to
be added.
Tank you for your attention to this matter :)
More information about the Digitalmars-d
mailing list