Re: [code] Customization questions and building curses version on Windows

From: Mitchell <>
Date: Tue, 7 May 2013 08:48:57 -0400 (Eastern Daylight Time)


On Tue, 7 May 2013, LM wrote:

> I've been looking for a console based editor that's customizable like
> SciTE. I ran across textadept in my search. It looks very promising,
> but I'm having trouble setting up the files to customize it.
> I downloaded the source code and built it on Windows using mingw and
> msys. I have libiconv, pdcurses, scintilla and lua (5.2) as system
> libraries. Noticed it only used libiconv and pdcurses, but used its own
> versions of scintilla and lua (5.1 for jit version). Hit a snag on the
> install. The makefile has a ln from the binaries at
> /usr/local/share/textadept to /usr/local/bin. This probably won't work
> right on Windows since the msys ln program copies the files (doesn't
> really create a true link) and textadept doesn't appear to work unless
> the support files it needs are directly below it. Am currently running
> textadept-curses from \mingw\msys\usr\local\share\textadept.

I'm impressed you were able to get it to build on Win32 since I only
support cross-compiling from Linux. Well done!

> Tried to set USERHOME environment variable both in msys and from a standard
> Windows command prompt. It doesn't seem to find the files in
> \mingw\msys\home\lm directory. I tried putting an init.lua file and a
> theme_term file at \mingw\msys\home\lm\.textadept. Doesn't seem to be
> reading these files.

Textadept uses C's `getenv()` function (via Lua's `os.getenv()`), so I'm
not sure what could be going wrong here. You can always pass the '-u
USERHOME_path' command line switch to manually set `_USERHOME`.

> What's the best way to add your own customizations for key mapping and
> screen colors? So far, the only thing I've been able to get working is
> editing keys.lua directly.

When you manage to get _USERHOME working, the place for key modifications
depends on your level of customization. Tweaks can go into
*_USERHOME/init.lua*, but full remaps are best suited in
*_USERHOME/modules/textadept/keys.lua* which would be loaded instead of
Textadept's *keys.lua*. Now, I don't know how to change the actual
terminal colors on Win32 -- you can only assign which colors to use for
which syntax bits. Those changes go in *_USERHOME/themes/term/lexer.lua*
unless you want to modify *_HOME/themes/term/lexer.lua*. (You can of
course use your own theme names.)

> Which key is the meta key on Windows/pdcurses or does that key not work
> on Windows?

Meta key is Alt, but I found that support for it and other modified keys
in pdcurses was poor at best, so I had to modify its key handling code
directly to support it better. Unfortunately I see that my patch for it is
not in the source release... I ended up editing pdckbd.c's `kptab` table.
I can send it later today in a separate e-mail if you are interested.

> Is there a way to toggle line numbering on and off?

In the command entry you can do:

   margin_width_n[0] = 0 -- toggle off
   margin_width_n[0] = 4 -- toggle on

Or assign a key command:

   keys['cmt'] = function()
     if buffer.margin_width_n[0] > 0 then
       buffer.margin_width_n[0] = 0
       buffer.margin_width_n[0] = 4

> Are there any additional examples of key customization or setting up a
> lighter color theme for textadept curses version? Any other good
> documents on how to customize textadept other than what's at the wiki?

The manual gives some examples on the preferences page. The wiki points to
users' *.textadept* directories that you can peruse. I myself completely
remapped my keys[1]. I cannot think of anywhere else.

> There is some functionality I use in SciTe and would be very curious if
> textadept can mimic it, even if it needs to be written in Lua. I run
> external programs (like gcc) on a file, view the stdout from it in SciTE
> and can click on the error messages to bring up and jump to the file and
> line where the errors occurred.

This is supported[2]. Note that in curses, where multiple views is not
supported, the screen is not split, but the error is still jumped to.

> I also run a diff tool on a file I'm viewing. SciTE lets me specify
> another filename to compare the current file to before it runs an
> external diff program. Would be curious if there are examples for
> either type of functionality with textadept or how doable this would be.

You could prompt the user with a `gui.dialog('fileselect', ...)` and then
run an external program.

> Textadept looks like a really nice editor. It's also one of the few
> I've run across that appears to have very good cross-platform support.
> Look forward to experimenting with it further and would appreciate any
> pointers to tips and tricks on customizing and working with it.

The code-base is small enough that you can actually read the Lua to get a
feel for how to customize things. Reading the Lua API[3] will also give
you a good feel for _what_ you can customize, but not necessarily _how_ :)



You are subscribed to
To change subscription settings, send an e-mail to
To unsubscribe, send an e-mail to
Received on Tue 07 May 2013 - 08:48:57 EDT

This archive was generated by hypermail 2.2.0 : Wed 08 May 2013 - 06:53:20 EDT