deadpixi / sam

An updated version of the sam text editor.
Other
430 stars 46 forks source link

Introduction

sam is a text editor originally written for the Blit graphical terminal connected to a machine running 9th Edition Research Unix. It contained many useful innovations, the most famous of which was its use of structural regular expressions_.

sam was the standard text editor for Plan 9 from Bell Labs_, and the Plan 9 version was backported to Unix and the X Window Sytem in the 1990s.

.. Blit: https://en.wikipedia.org/wiki/Blit(computer_terminal)

.. _9th Edition Research Unix: https://en.wikipedia.org/wiki/Research_Unix

.. _structural regular expressions: http://doc.cat-v.org/bell_labs/structural_regexps/se.pdf

.. _Plan 9 from Bell Labs: http://plan9.bell-labs.com/plan9/

This version of sam is based on that 1990s Unix port, with many useful additions and modifications (see New Features_).

Note that this is not stable software. This version of sam is under heavy development; the goal being to get it working before making it beautiful. That being said, it's my primary editor, so any major bugs tend to get fixed pretty quickly. Still, be careful with it.

The Obiligatory Screenshot

.. image:: sam.png

Community

Rob posts updates about sam on Twitter at http://twitter.com/TheKingAdRob.

Installation

Basic Installation

Installation and configuration is fairly simple:

Note that running make install will install a desktop entry file_, in either "system" or "user" mode. This can be specified via the MODE make variable (the default is "user"). To isntall the desktop entry for the all users, use:

make MODE=system install

The sam command runs sam. The B command adds a new file to a running instance of sam, or starts sam if it's not already running. To configure sam, create a .samrc file in your home directory. The file doc/samrc <doc/samrc>_ file serves as a useful example of such a file.

.. XQuartz: https://www.xquartz.org/ .. desktop entry file: https://specifications.freedesktop.org/desktop-entry-spec/latest/

Running Remotely

Both the sam and B commands accept an '-r' argument, naming a remote machine or (assuming you're using ssh(1), an SSH host entry). The remote machine only needs to have the sam binary.

The remote machine may also have the B command installed (as a symbolic/hard link to sam). If it is installed, the B command can be executed both locally (on the machine running samterm) using the '-r' option, and remotely (on the machine running sam) without the '-r' option. The B command requires a remote shell client that supports UNIX domain socket forwarding; such support has been present in OpenSSH since at least version 6.7 (released in 2014). See the sam(1) manual page for information on how the remote shell client is invoked.

Note that sam relies on the contents of the LANG, LC_CTYPE, and/or LC_ALL environment variables to determine the character encoding to use. If you're using ssh(1) to run sam remotely, be sure to pass those variables along or have them set remotely.

Installation Paths

By default, sam, samterm, and B all end up in '$(BINDIR)' as defined in config.mk.

Compatibility

Note that Deadpixi sam has extended the binary protocol spoken between sam and samterm. That means that a Deadpixi samterm won't work with a non-Deadpixi sam, nor will a Deadpixi sam work with a non-Deadpixi samterm.

New Features

Modern OS Support This version of sam compiles and runs on modern Linux/Unix/BSD/macOS systems under X11.

Improved 64-bit Support The original sam had support for 32-bit architectures and big-endian 64-bit architectures. This version supports 64-bit architectures of any endianess (including, most importantly, x86_64).

Scalable Font Support This version of sam is not limited to classic X fonts, but can use modern scalable fonts. Inconsolata is this author's favorite, though Courier Prime Code and Go Mono_ are giving Inconsolata a run for its money.

X Input Method and Composition Support This version of sam supports the X Input Method extension for input processing. This allows users to input text via the methods with which they are most comfortable. Additionally, the XCompose(5) file can be used to bind arbitrary sequences of keystrokes to different input character sequences. This mechanism is both more portable and more extensible than the old composed text input mechanism.

Multicolor Support This version of sam supports configurable text, selection, border, and background colors. It also allows different files to have different background colors, allowing different files to be easily distinguished. The default is still the classic two-color appearance, of course. These colors can be configured at runtime. (Note that this does not mean that sam has syntax highlighting. That will almost certainly never happen.)

Simplified and Dynamic Configuration The graphical elements (colors and fonts) of this version of sam are controlled via environment variables, not X Resources. Keybindings and mouse chords are configurable at runtime via a configuration file.

Far Better Keyboard Support The selection ("cursor") can be moved using keyboard commands. Additional keyboard-accessible commands allow jumping between file windows and the command window, scrolling the display, snarfing, pasting, etc. The binding of these commands to keyboard sequences is configurable at run-time (via the ~/.samrc file).

Support for Two-Button Mice and Wheel Mice The original sam required a three-button mouse. This version is still easier to use with such a mouse, but can be used with a two-button mouse by simulating a button-3 press using shift-button-2. This version also supports scrolling with mouse wheels.

Support for Mouse Chords The commands available for keyboard binding are also accessible via mouse-button combinations ("chords"). By default, the snarf, cut, and paste commands are mapped to chords. The binding of these chords is configurable at run-time.

Better Remote Editing Support This version of sam can use ssh(1) as its remote shell. Additionally, the B command works on both the local and the remote system during remote editing sessions.

Command Language Extensions Various minor and mostly-compatible changes have been made to the sam command language. Most notable is the b command, which now performs a fuzzy match on filenames, making switching between files much faster and easier.

Improved Manual Page The manual page has been rewritten to use the modern mdoc(7) manual page macros. It has been additionally cleaned up, clarified, and extended.

Support for Tab Expansion When enabled, tabs will be expanded into spaces.

Arbitrary Encoding Support This version of sam now uses the operating system's multibyte encoding functions. That means that it is not limited to UTF-8, but can edit files in any encoding supported by the operating system. This also means that on modern systems, files containing codepoints outside of the Basic Multilingual Plane can be edited (as opposed to classic sam, which supported only the BMP).

Numerous Bug Fixes This version of sam fixes some crashes and memory leaks that were in the original version. It feels nice fixing a thirty year old memory leak. ☺

Code Cleanup and Modernization This version of sam uses C99 standard integer types everywhere, and uses a much simpler buffer implementation. This makes the code more portable and easier to understand.

.. _Inconsolata: http://www.levien.com/type/myfonts/inconsolata.html

.. _Courier Prime Code: http://quoteunquoteapps.com/courierprime/

.. _Go Mono: https://blog.golang.org/go-fonts

.. _WordStar Diamond: http://texteditors.org/cgi-bin/wiki.pl?WordStarDiamond

The Future

This project has an end goal: once the issues listed here are complete, this edition of sam will enter maintenance mode.

Primary Goals

Stretch Goals

Very Unlikely Goals

Permissible Changes in Maintenance Mode

Once the above goals are met, the only changes that will be made to sam are:

Things That Won't Ever Happen (Sorry)

How You Can Help

Credits

These credits are in rough chronological order:

Rob Pike, Howard Trickey, Matty Farrow, Boyd Roberts, Doug Gwyn, James Clark, Mark H. Wilkinson, et al. Authors and/or contributors to the original X version of sam, upon which this version is based.

Rob King Added most of the things mentioned in New Features_ above. Rob is the author and maintainer of this version of sam.

Chris Siebenmann Many many many suggestions, fixes, and improvements.

Aram Havarneanu Improved the handling of Makefile variables.

Ishpeck Improved C89 support.

Tommy Pettersson Numerous bugfixes and suggestions.

Christian Neukirchen Found and fixed numerous bugs.

Benjamin Scher Purcell Added the Cbol and Ceol commands.

Mike Rosenberg Helped get sam running on Mac OS X. Extensive testing help.

RamKromberg Offered numerous suggestions.

Erez Schatz Extensive testing help and evangelism.

ckeen Added Alt modifier support.

David Tolpin Added support for optional automatic indentation.

Andrew Higham Added support for focus-follows-mouse, based on a couple of patches posted to the sam-fans mailing list in the ‘90s.

If I've forgotten you in this list of credits, please accept my apologies and email me (Rob King) at jking@deadpixi.com to be added.

Copyright and License

The authors of this software are Rob Pike and Howard Trickey. Copyright (c) 1998 by Lucent Technologies.

Rob King made some changes. Those changes, Copyright (c) 2014-2016 by Rob King.

Permission to use, copy, modify, and distribute this software for any purpose without fee is hereby granted, provided that this entire notice is included in all copies of any software which is or includes a copy or modification of this software and in all copies of the supporting documentation for such software.

THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.