Build Status:
wsedit
is a clean, intuitive terminal-based editor with CUA keybinds. It is
designed to get the job done in a simple, elegant and pragmatic manner. If
you've ever worked with a text editor and with a terminal, you already know
how wsedit
works, except some small quirks here and there maybe.
-
Dynamic dictionary-based autocompletion: Specify which files to index, and how (e.g. ignore comments, only global definitions, ...).
-
Pragmatic syntax highlighting: Highlights keywords, strings, matching brackets and comments declared in your config files. Default patterns for some languages are availabe for import in
lang/*.wsconf
, writing your own should take no longer than 30 minutes, including the submission of a pull request on GitHub =). -
Character class highlighting: This will colour your text by character class (e.g. operators -> yellow, brackets -> brown, numbers -> red, ...). This supplements the already mentioned syntax highlighting quite nicely and provides a base-line readability boost if no highlighting rules have been set.
-
Simple configuration interface via config files: Not really much to say here.
-
Reader mode: Want to glance over a file without accidentally editing it? Start the editor in read-only mode, or toggle it via keybind.
-
Protects you data: Special routines are in place to ensure your work doesn't just vanish, should the editor crash. I sure wish having this wasn't something to be proud of.
As vty
(wsedit
's terminal I/O library) depends on unix
which supports
neither Cygwin
nor MinGW
, there's currently no way to build wsedit
for
Windows
No packages available yet, contact me if you want to package wsedit
for your
distribution.
Thanks to Alex Arslan for providing a homebrew formula for wsedit:
brew tap ararslan/pints
brew install wsedit
IMPORTANT: I have no access to OSX systems myself, so the amount of support I can provide for platform-specific issues will be heavily limited and I might need your help to test some things for me.
- Install:
- stack,
ncurses
with unicode support,wl-clipboard
,xclip
orxsel
, optional, makeswsedit
use the system clipboard.
- Grab the latest
wsedit
release off GitHub. - Run
stack install
, the binary will be placed into$HOME/.local/bin/
. - Either add
$HOME/.local/bin/
to your$PATH
or copy/link/symlink the execuable where you actually want it. - Run
./install_lang.sh
, as root if you want the definitions to be installed system-wide. If your favourite language has no definitions available, you can easily create them yourself, take a look atlang/README.md
for instructions. - Done! I recommend opening two terminals next to each other, running
wsedit
in one of them and looking up keybinds in the other one withwsedit -hk
. Alternatively, you can view the keybinds withF1
.
First of all, welcome to Linux! If you encounter any problems, take a look at
the Troubleshooting
section further down below and see if it helps.
- Install the
Haskell Tool Stack.
(If you don't have root access to install stack, pick the
Linux (general) option and call the
stack
binary inside the archive directly.) - Make sure you have
ncurses
with unicode support installed. This should be default on most popular distributions. - Optional, Linux only: Install either
wl-clipboard
,xclip
orxsel
with your package manager. If this step is skipped,wsedit
will use a file buffer instead of the system facilities for copy/paste functionality. - Grab the latest stable release of
wsedit
from theReleases
tab on GitHub. - Extract the archive and point your shell towards its contents.
- Run
stack setup
to pull in the correct version ofghc
. - Run
stack install
to build the dependencies andwsedit
. - Check whether
$HOME/.local/bin
is already part of your$PATH
variable: if the commandecho "$HOME" | grep "$HOME/.local/bin"
has no output, add the linePATH="${PATH}:${HOME}/.local/bin"
to the file~/.bashrc
. This file will be executed every time you open a shell, so you either need to re-open the terminal or runsource ~/.bashrc
to re-run it manually. - To get syntax highlighting, run
./install_lang.sh
. If you want them to be installed for all users, runsudo ./install_lang.sh
instead. If your favourite language has no definitions available, you can easily create them yourself, take a look atlang/README.md
for instructions. - Done! I recommend opening two terminals next to each other, running
wsedit
in one of them and looking up keybinds in the other one withwsedit -hk
. Alternatively, you can view the keybinds withF1
.
Please submit every kind of weird behaviour you encounter as an issue on GitHub. If possible, obtain a state dump as described below.
When I started development on WSEdit back in 2016, it would frequently break things in a way that causes data loss. Since then, a lot of data protection safeguards have been implemented, and the codebase has matured quite a bit. Nowadays many things have to go wrong at once for data to be damaged, and as a result of this, I haven't had data loss in years.
I originally planned to write an extensive test suite for WSEdit, but have since stopped working on that for a number of reasons:
- Writing anything but simple unit tests for an interactive editor is very hard,
- Expected impact for bugs will be very low since the editor seems to work well and multiple safety nets are in place,
- The editors with comparable scope that I've checked don't seem to have test suites either.
Considering all that, the limited time I have for working on WSEdit is better spent developing new features.
The editor main loop runs inside an exception handler that will do the following:
- Dump the current state of your file to
${HOME}/CRASH-RESCUE
if it has been modified since the last save. As long as this location stays writeable, next to nothing can happen to your data. - Dump the editor's configuration, state and some additional info to
${HOME}/CRASH-DUMP
. This file can be used to restart the editor in the last coherent state before it crashed. - Safely shut down everything.
The state dump is of great importance to fixing the bug. However, it contains all active configuration as well as the entire file you edited when the crash happened. Make sure you are okay with that becoming public before uploading it. Also, please do not provide a modified dump file, as any changes made will throw off the caching system.
By default, the editor saves data in the following way:
- The contents are written to a new file.
- The written file is immediately read again, and the result is compared to
the current buffer. If these don't match, your current data is
emergency-saved to
${HOME}/CRASH-RESCUE
with conservative encoding settings, and the editor aborts. - The new file receives the same permissions as the old file.
- The new file is atomically renamed over the old file.
This behaviour can be disabled, but it is highly recommended not to do so.
Most non-fatal bugs will probably be rendering glitches. Reproduce the situation, point the cursor at it if possible, then press F9. This will simulate a crash and create the above-mentioned files.
Deactivate the -db
switch.
- Disable
-db
if it is active. - Performance is highly dependant on your terminal emulator. I can personally
recommend
termite
,sakura
,xterm
and to a lesser degree alsorxvt-unicode
if you really hate yourself.
- Make sure all non-haskell dependencies listed above are satisfied.
- Try
stack clean
or maybestack update
. - If that doesn't work, delete the
.stack-work
folder and try again.
Symptoms: After running wsedit
, any unicode output by other programs (e.g.
tree
) will be garbled.
This seems to be a problem wit vty
, the terminal library wsedit
uses, since
yi
, another terminal editor based on vty
, suffers from the same issue. For
now I can only recommend using another terminal emulator if you need the unicode
support.
Yeah, urxvt
is a mess. I recommend switching to another terminal, but adding
this to your .Xresources
file will soothe your pain:
! From http://thedarnedestthing.com/urxvt
urxvt*keysym.C-Up: \033[1;5A
urxvt*keysym.C-Down: \033[1;5B
urxvt*keysym.C-Right: \033[1;5C
urxvt*keysym.C-Left: \033[1;5D
urxvt*keysym.S-Up: \033[1;2A
urxvt*keysym.S-Down: \033[1;2B
urxvt*keysym.S-Right: \033[1;2C
urxvt*keysym.S-Left: \033[1;2D
urxvt*keysym.M-Up: \033[1;3A
urxvt*keysym.M-Down: \033[1;3B
urxvt*keysym.M-Right: \033[1;3C
urxvt*keysym.M-Left: \033[1;3D
urxvt*iso14755: False
urxvt*iso14755_52: False
The entire codebase, including the language definitions, is licensed under the
3-Clause BSD License, see LICENSE
.