lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I've just written a word processor. From scratch. In 5500 lines of code. I do
like this language.

http://wordgrinder.sourceforge.net/

It's a text-mode word processor, which runs in a Unix terminal. It supports
basic markup, a nice menu-based interface, decent Unicode support (no rtl or
combined characters, but single and double width glyphs work fine), and a
bunch of the standard features you'd expect from a word processor.

It consists of 1200 lines of C, mostly to do with ncursesw interfacing and
UTF-8 handling, and 4200 lines of Lua, which contains everything else
(including UI and redraw code). The C is all very low level and is mostly just
to do things that can't be conveniently done in Lua, like byte-by-byte string
manipulation. The stripped binary is slightly under 16kB (using a shared
library for Lua).

Lua Unicode hackers might be interested to know that UTF-8 is used throughout
the entire program. *All* strings are stored in UTF-8, and they're never
broken down into UCS-4 codepoint arrays at any point. While I did do this
slightly to prove a point, once I got my head around the different way of
working, it actually went rather smoothly.

It's not as fast as it could be; when I run WordGrinder on my 266MHz ARM box
it can't quite keep up with the screen scrolling. However, on my desktop the
only time it ever stops to think is when loading and saving [*]. One day I
should try running it with the JIT and see if that makes a difference.

Interested parties may wish to rip out the UI forms code and use it elsewhere.
It was written to be modular.



[*] Anyone know where I can get a faster object serialisation/deserialisation
routine?

- --
┌── dg@cowlark.com ─── http://www.cowlark.com ───────────────────
│
│ "There does not now, nor will there ever, exist a programming language in
│ which it is the least bit hard to write bad programs." --- Flon's Axiom
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHEo91f9E0noFvlzgRAmWJAKCqpwZrbrIWTMBeZ3MSHa5UlD/OdACgt5bq
+JN7oeW+kbOVvmLNycfzFiE=
=EGJs
-----END PGP SIGNATURE-----