HackerTrans
TopNewTrendsCommentsPastAskShowJobs

chrisecker

no profile record

Submissions

Show HN: A WYSIWYG word processor in Python

codeberg.org
91 points·by chrisecker·3 месяца назад·38 comments

TexelTree – A data model for word processors

codeberg.org
3 points·by chrisecker·4 месяца назад·2 comments

Ask HN: Is there prior art for this rich text data model?

6 points·by chrisecker·4 месяца назад·2 comments

comments

chrisecker
·3 месяца назад·discuss
Fixed it. Thanks for reporting.
chrisecker
·3 месяца назад·discuss
I have been able to install MiniWord under Windows. It is a bit more challenging.

You should use cairocffi instead of pycairo:

  pip install cairocffi
You also need to install the Cairo DLL. The easiest way is to install the full GTK3 runtime from: https://github.com/tschoonj/gtk-for-windows-runtime-environm...

You must add the directory containing libcairo-2.dll to your PATH environment variable. In my case, this is:

  C:\Program Files\GTK3-Runtime Win64\bin
Note that MiniWord is not yet optimised for Windows. While it mostly works, the rendering quality is lower and startup is slow.
chrisecker
·3 месяца назад·discuss
I came from the TeX-Approach where all layout elements are boxes which contain other boxes. This box-tree is a kind of DOM if you want. But the box-tree only represents the layout, not the data itself. For the data you usually have a separate object. In Word this used to be the piece table structure, now it is probably something else. I described my approach here, if you want to know how and why: https://codeberg.org/chrisecker/texeltree/src/branch/main/do...
chrisecker
·3 месяца назад·discuss
When you want to develop cross platform apps which use the native widgets, there are not so many options. The two big players are qt and wx.
chrisecker
·3 месяца назад·discuss
Yes, I can see what you mean: There are hand coded colors together with system colors. With the dark mode this gives white text on white background for the side panel. Thanks for mentioning.
chrisecker
·3 месяца назад·discuss
Cursor positioning is simple. The layout is a tree of nested box. Each box knows the x,y-position of its children. There is also an index dimension which numbers possible cursor positions. A box lies from i1 to i2 in index space. You just iterate over all boxes holding cursor position i to find the cursor coordinate x,y. Selection is simple as well. It is defined by a start index s1 and end index s2. Some objects have a special selection, e.g. tables where you select a rectangular range of table cells.
chrisecker
·3 месяца назад·discuss
Ropes are for strings. In a word processor you need text with formatting, and structures as tables, images and math.
chrisecker
·3 месяца назад·discuss
My mistake. Now it works (on linux).
chrisecker
·3 месяца назад·discuss
My apologies. I added the missing file.
chrisecker
·4 месяца назад·discuss
Finding a good data structure for a word processor is a difficult problem. My notebook diaries on the problem go back to 2001 when I was frustrated with using Word, which was at that time slow and unstable.

While ropes and piece tables are standard data structures, I found that an immutable n-ary tree of 'Texels' (B-Tree) works surprisingly well even in high-level languages like Python.

I’m currently taking a professional career break and decided to finally use this time to push my research further, document the results, and build MiniWord—a WYSIWYG word processor in Python.

I'd love to get your thoughts on the TexelTree. Repo/Essay: https://codeberg.org/chrisecker/texeltree
chrisecker
·4 месяца назад·discuss
You're right that hidden structure is often the cause of strange effects — but Group is not a document element in that sense. It's invisible at the index level too: when you iterate over the document by index, you pass through Groups transparently. A Group is purely a tree node for balancing purposes — it has no position in the document model that a cursor could land on, no semantic meaning, and no user-visible boundary. It has no effect the user can see or feel. Think of it like the internal nodes of a B-Tree: they exist to keep the structure efficient, but you never 'see' them when you traverse the data."