sled

sled is a simple text editor with a terminal UI.

Q&A

Q: Why?

A:

  • Because newcomers don't find vi(m) comfortable. Something akin to EDIT.COM is usually perceived as more familiar: type text straight away, C-S to save, then C-Q. (Sled still has vim‑like behavior, but it is “reverse” - default is insert mode, from which you can enter command mode.)

  • Because nano/joe are still relatively complicated.

  • As an exercise in programming in C, and to create an editor to my own liking, closer to suckless principles.

Q: Why can't sled open the file “read only” even if modification is disallowed?

A: A text editor's purpose should be to edit text files. For just viewing text files, there's less(1). This avoids the situation when opening a file one is not allowed to write to with an editor like vi(1), only to have write operation denied after making numerous edits.

Of course, one could argue that screen editors like vi already double as text file viewers, but I think of displaying the contents of a writable file as being separate from displaying the contents of a non-writable file.

If this bothers you, you can use something like the included shell script sledv.

Q: Is editing multiple files planned?

A: No, and this is by design. You can edit multiple files at the same time by running multiple instances of sled. You can arrange them on screen through a terminal multiplexer like GNU screen(1) or tmux(1), or just open several terminal emulators like st(1) and have your window manager arrange their windows. Inter-process “clipboard” can be managed by a terminal multiplexer or X.Org itself.

Q: Is there a ~/.config/sled/config or ~/.sledrc?

A: No, and never will be. sled is intended to be configured through editing config.h and recompilation, like suckless software.

Q: Are plugins planned?

A: No. Like suckless software, sled is meant to be extended through patches.

Q: Why doesn't sled have feature X from text editor Y?

A: Most likely because it is not essential to editing text files. However, you are free to offer a patch supporting the feature, which will be included in the repository, with credits to the author.

Q: How can I configure sled if I installed it (from AUR|through my distro's package manager)?

A: You don't. If you want customization/configuration, clone the git repo, customize and compile it from source, just like with suckless software.

Q: Why am I getting a “Permission denied” when trying to edit a file?

A: You either can't access the directory for writing and search (execute bit) and haven't disabled the creation of backups nor set BACKUP_FAIL_OK, or can't access the file itself for writing.

Q: How to get crontab -e to work?

A: Uncomment the BACKUP_FAIL_OK define in config.h. If that fails, comment out the CREATE_BACKUPS define in that file.

Prerequisites

Testing

Install

$ git clone https://git.sr.ht/~strahinja/sled
$ cd sled
$ su
# make install

Persistent build configuration file

The file config.mk will be sourced when building targets which also accept configuration through environment variables. For example, CC and PREFIX are specified in config.mk.

OpenBSD

Before running make(1), comment the CPPFLAGS definition in config.mk above the line with the “OpenBSD” comment and uncomment the one below it:

#CPPFLAGS	= -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L \
#		  -D_XOPEN_SOURCE=700
# OpenBSD
CPPFLAGS	= -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L \
		  -D_XOPEN_SOURCE=700 -D_BSD_SOURCE

Also, do the same for MANPREFIX:

#MANPREFIX	= $(PREFIX)/share/man
# OpenBSD
MANPREFIX	= $(PREFIX)/man

Install (Arch)

$ <aur_helper> -S sled

Applying patches

To apply any patches, change the current directory to the one holding the sled repository, then:

$ git am path_to_patch/filename-of-patch.patch

and then call make as above. Included patches are located inside the patch/ subdirectory.

Contributing patches

See the file HACKING in the sled repository for details.

Bugs and limitations

Bugs can be reported using the ticket tracker. See the manpage (man sled) after installing sled for more information.

License

sled - Simple text editor
Copyright (C) 2022-2024 Страхиња Радић

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

File termbox.h is based on termbox2 TUI library, (c) 2021 termbox developers, which is released under the terms of Expat license, see the file LICENSE.termbox.

Generated by slweb © 2020-2024 Strahinya Radich.