GithubHelp home page GithubHelp logo

sam's Introduction

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.

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

sam.png

Community

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

Installation

Basic Installation

Installation and configuration is fairly simple:

  • You need to be running X11 of some sort. On the Mac, XQuartz seems to work well. On Linux and BSD systems, the operating system's installation of X should be fine.
  • If you need to modify the default compile-time configuration (which is unlikely) copy config.mk.def to config.mk and modify as needed
  • Run make clean
  • Run make
  • Run make install or, if needed, sudo make install

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 file serves as a useful example of such a file.

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.

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

  • Scalable font support (DONE)
  • Support big- and little-endian 64-bit systems (DONE)
  • Support compilation and use on modern *nix systems (DONE)
  • Support two-button mice (DONE)
  • Support tab expansion (DONE)
  • Support runtime configuration of tab sizes (DONE)
  • Support scroll wheels on mice (DONE)
  • Support fuzzy matching in the b command (DONE)
  • Raise the window when opening a new file (DONE)
  • Support a configurable set of keybindings (i.e. rework the keyboard layer) (DONE)
  • Support multiple background colors at once (DONE)
  • Support the following commands for keybindings
    • escape (DONE)
    • scrollup / scrolldown (DONE)
    • charright / charleft (DONE)
    • lineup / linedown (DONE)
    • jump to/from command window (DONE)
    • delword / delbol / del / delbs (DONE)
    • snarf / cut / paste / exchange (DONE)
    • write (DONE)
    • nextlayer / prevlayer (TODO)
    • maximize / tile left / tile right (TODO, also looking into acme-like tiling)
    • look (DONE)
    • /regex (DONE)
    • send (DONE)
    • eol / bol (DONE)
  • Support a configurable scroll factor; scrolling is a bit drastic now (DONE)
  • Support Unicode beyond the Basic Multilingual Plane (TODO, possibly making sam agnostic about encoding)
  • Support font fallback (TODO)
  • Allow runtime configuration of key bindings (DONE)
  • Support a configurable set of mouse chords (DONE)
  • Support runtime configuration of mouse chords (DONE)
  • Support mouse button reassignment (TODO)
  • Support runtime mouse button reassignment (TODO)
  • Remove external command FIFO, switch to UNIX domain sockets for IPC (email me if you want to know why I think this is a good idea) (DONE)
  • Support the CDPATH environment variable for the cd command (TODO)
  • Split the man page into documentation for samterm, sam, keyboard, and samrc (DONE)
  • Add localization support (TODO)
  • Add a Desktop Entry file, icon, etc (TODO)
  • Create RPMs, DEBs, etc (TODO)
  • Refactor all code to be as clean and standards-compliant as possible; remove all legacy code (TODO)
  • Compile with no warnings, with all and extra warnings and -pedantic enabled on GCC in C99 mode (TODO)
  • Run with no Valgrind-detected leaks or errors (DONE)

Stretch Goals

  • Remove Xt dependency (TODO)
  • Switch to a more X11-y model (e.g. one child window per layer) (TODO)
  • Shell windows (TODO)

Very Unlikely Goals

  • Windows port (no, seriously, stop laughing)
  • Non-X11 Mac OS X port
  • Console port

Permissible Changes in Maintenance Mode

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

  • Bugfixes
  • Translation updates
  • Binary package updates
  • Updates necessary to keep sam compiling on whatever systems its users are using

Things That Won't Ever Happen (Sorry)

  • Syntax highlighting
  • Multiple cursors
  • Complex text rendering (I really am sorry about this one; I want speakers of languages with more complex writing systems to use sam, but getting it to work would be nigh impossible)

How You Can Help

  • Use sam! Open up issues on GitHub if you see any problems or have any ideas.
  • Spread sam! Tell your friends and colleagues. Anyone know Rob Pike, Brian Kernighan, Ken Thompson, or Bjarne Stroustrup? They are known sam-users, see if they like this version. :)
  • Package sam! Create packages or ports of sam for your operating system of choice.
  • Document sam! I'm not particularly good at readable, accessible documentation. If you are, I'd love help!
  • Translate sam! Currently, sam only speaks English. I'd like to see sam speak all of the languages that its users speak.
  • Draw sam! I can't draw. At all. Sam needs a decent icon for use with various desktops. If you can draw a nice scalable icon for sam, I would be very happy to see it.
  • Write sam! Write code and send patches.

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 [email protected] 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.

sam's People

Contributors

4ad avatar ahamidullah avatar andygoblins avatar arizvisa avatar ckeen avatar czarkoff avatar deadpixi avatar dtolpin avatar hubhamster avatar leahneukirchen avatar pilona avatar ramkromberg avatar sevan avatar siebenmann avatar spewspews avatar wime12 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sam's Issues

/ Address command should also update the selection for <look>

Currently when searching for a regexp with '/foo' in the command window and want to search for further occurances of 'foo' with the Mouse 'look' command it does not search for foo but the empty selection (if nothing else has been selected before).

I would expect that to work.

Pressing alt gr on azerty keyboard inserts unwanted character

Hello,
Whenever I press the right alt key on my azerty keyboard (the so-called alt greek key), a glyph is inserted, with hexadecimal value "ef b8 83".
When I hold the altgreek key and then type for example the 5 key, a [ is displayed like it should,
so apart from inserting this unwanted glyph, the alt gr is working.
In the attached file, I have pressed the following keys:

  • alt gr
  • 5, while holding the alt gr, and then releasing both keys
  • enter
    altgr.txt

Thanks,

'could not open command socket' error on startup

Hi. After compiling from latest source, I get this error on startup:

could not open command socket: Address already in use

samterm loads, command window seems to work.
But sam exits with Segmentation fault after I try to open a new window.

Thanks for any suggestions!

RFE: Better way to handle local changes to commands.h (and chords.h)

At the moment, it's relatively painful to maintain local changes to commands.h (and probably chords.h, since it uses the same mechanism). With commands.h.def changing and evolving relatively frequently, one keeps having to re-integrate your own changes into a newly changed upstream version. It would be nice if this was easier.

I have a three-part idea for how to improve this:

  • document what I currently believe is the case, which is that the table is searched in order and the first match wins.
  • add a new key binding kind, Knormal. Knormal simply does whatever sam would normally do if there was no matching entry in commands.h (and the action is ignored).
  • #include a 'local-commands.h' at the start of commands.h, and guarantee that local-commands.h ships empty of bindings (but ready for alterations) and will never be changed (except, at most, for changes to an explanatory comment at the start).

With these three changes, people can freely add bindings to their local-commands.h without colliding with upstream changes to commands.h(.def), and their bindings will always take priority over the standard ones. If they want to remove a standard binding, they redefine the key as Knormal and they're guaranteed it will always do the right thing (and their intentions are explicit, as opposed to having to be deduced from a Kcomposed or Kraw binding that inserts itself).

could not open command socket: Address already in use

I am just opening the sam from command line and I get this error. How do I fix this?

Also is there any documentation on how to issue B from outside sam command interface but in the same machine I will try to figure this out. I am suspecting it is becausing of the above error.

RFE: Better integration with X selections

Right now, one of the awkward bits about using sam as an editor in the broader X ecosystem is that it's kind of painful to move text between sam and other X programs. X has a selection system, and sam has a selection system, and you have to <exch> between the two. I think that there are good reasons to keep the two at least somewhat separate, but I also think that it could be easier. My current set of ideas:

  • Add a 'paste from X' operation along side the regular paste, both as a menu item and as, say, shift + chord-23. This would make it much easier to get text in to sam from eg xterm.
  • make sam assert the X selection any time that you cut or snarf something. sam should not discard its own internal buffer if it loses the X selection, but I think it's perfectly sensible to assert the selection when you snarf.

These two changes combined would mostly remove the need to use <exch>, while still keeping the separation between sam's own buffer and the X selection that insures you don't accidentally lose cut or snarf'd data that exists only in sam's buffer.

RFE: (chorded) cut followed by a paste in the same spot should leave the file unchanged

This is likely to be low priority.

I believe that one of the things Rob Pike has mentioned he did with chorded cut & paste in acme is make it so that if you cut and then immediately pasted the cut back in the same spot, the file was considered unchanged. The advantage of this is that you get a clean chorded 'snarf' operation, instead of marking the file as dirty (and making sam complain if you don't write it out sooner or later and so on).

Chorded mouse paste doesn't ignore mouse movement during the paste

If you paste something with chorded mouse buttons (B1+B3 usually), normally what you pasted stays selected afterwards. However, if you happen to move the mouse slightly while you're clicking B3 (or deliberately click-and-hold and then move the mouse), this movement causes the selection to reset itself after the paste. The traditional behavior of chorded paste is that this movement is ignored while the chord is in effect, and I think it's clearly the more useful behavior (especially since it's very easy to have the mouse shift slightly).

There are at least some anomalous things that may be happening with mouse movement during a cut chord (B1+B2), but it's less obviously flawed since the cut is made the moment the second button goes down.

This may also be a sign of a larger issue, which is that right now you can't cancel mouse chords, as they fire the moment the second mouse button goes down. I believe that this isn't acme behavior (although, to my surprise, it is the behavior of the original patches to sam).

RFE/bug: unbound Ctrl-<x> keys should do nothing

At the moment, sam interprets an unbound Ctrl- key as the same as . This is not traditional sam behavior (it inserts the Ctrl character) and is likely surprising. If one is going to change the traditional sam behavior, I think a better and less surprising default is to do nothing. People holding down Ctrl presumably expect it to do something different than the regular character, after all.

In a sam environment with an increasing number of Ctrl keys bound to do things, doing nothing by default also has the benefit that if you mis-type a Ctrl key (you aim for Ctrl-y, say, but get Ctrl-t by accident), you don't destroy the current selection by replacing it with whatever normal character you just typed.

RFE: option for the scroll wheel to scroll just one line at a time

Right now the mouse scroll wheel jumps significant amounts of distance. It would be nice if there was an option (either build-time or runtime) to scroll things only one line at a time, as xterm and other terminal emulators do. I personally prefer this sort of scrolling, because sam has no other good way to do it while it already has ways to do larger scroll movements (eg PgUp and PgDown, and the cursor keys with standard key bindings).

I have (hacky) code to do the actual line-forward and line-backwards scrolling in my sam repo at the top of samterm/main.c, although it may not be the ideal way to do either direction. Please feel free to adapt it if this feature seems good.

rsam Makefile misses a rule (at least on OpenBSD)

Hello,

when building on OpenBSD, rsam (as the only program
from the set) is not built. I had to add the line

$(CC) -o rsam rsam.o $(LDFLAGS)

to the Makefile's rule for rsam.

It might be just that the "make" on OpenBSD doesn't know
some implicit rule, but this is simply beyond my knowledge...
(Sorry, if that's the case; still I think the explicit rule does not hurt.)

Thanks,
Ruda

shortcut to switch back to command window (9front)?

Hi. Would you mind adding a keyboard shortcut for switching back to the command window?
9front has this (ctrl-b) and it's really handy.
I believe the implementation can be seen from here:
https://gist.github.com/tintohill/471ee1ddb50f6d5150cd

Being a computer hobbyist, I unfortunately can't get my own head around the code at this point. But I've been really enjoying your version of sam for several months, so thanks anyhow!

BTW, While searching for the ctrl-b implementation, I also found another interesting extended version of sam:
https://bitbucket.org/rennis250/sam

Problem compilation: error string.c

string.c:60:1: error: conflicting types for 'Straddc'Straddc(String p, wchar_t c)
^~~~~~~
In file included from string.c:2:0:
sam.h:254:9: note: previous declaration of 'Straddc' was here
void Straddc(String
, int);
^~~~~~~
make: *** [string.o] Error 1

If I change the type (in file: string.c) of wchar_t to int then compilation complite.
All function work except for viewing more than 2 dots.
example:
1p - work
1,2p - crashed :( Please help,
p.s. I use only "sam -d" (Compiled in cygwin)

build process faults on man directory

Building on Ubuntu, on a regular build, root privileges:

...
cp sam.1 "/usr/local/share/man/man1"
cp B "/usr/local/bin"
ln -sf "/usr/local/share/man/man1/sam.1" "/usr/local/share/man/man1/B.1"
ln: failed to access ‘/usr/local/share/man/man1/B.1’: Not a directory
make[1]: *** [install] Error 1
make[1]: Leaving directory `/home/ubuntu/sam/doc'
make: *** [install] Error 2

Then, if I do

rm /usr/local/share/man/man1
mkdir -p /usr/local/share/man/man1/B.1

And rerun make install, it finishes the process with no hitch

I've attempted the same on CentOS and there wasn't any issue

A couple of minor issues...

In no particular order of significance:
0. When writing samsave ( https://github.com/deadpixi/sam/blob/master/sam/sam.c#L160 ), sam tries being smart and uses the shebang line to circumvent calling sh. Unfortunately, with gnu bash this fails with the following error:

bash: ./sam.save: samsave: bad interpreter: No such file or directory

I tried using /usr/bin/env samsave which did help a little. Unfortunately, gnu bash doesn't pass more than a single argument so that failed as well.
A simple solution would be to write a more typical /bin/sh shebang. So, instead of:

#!samsave './test.txt' $* <<'---./test.txt'
testing123
---./test.txt

Sam should just do:

#!/bin/sh
samsave './test.txt' $* <<'---./test.txt'
testing 123
---./test.txt
  1. If you're doing c++ style comments, gcc -std=c89 won't work. Also, c99 isn't a standard c compiler name. (https://github.com/deadpixi/sam/blob/master/config.mk.def#L5-L6).
    I think your best bet is to go with cc -std c99 or whichever standard you're aiming at and make sure the flags are supported both in clang ( http://clang.llvm.org/docs/UsersManual.html#differences-between-various-standard-modes ) and gcc ( https://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html#C-Dialect-Options ).
  2. Does /bin/B really need a direct /bin/pwd invocation? Can't it just be pwd?
  3. Similarly, I don't think /bin/samsave needs to force it's own PATH.
  4. xdg-desktop-menu isn't part of the base system. Maybe cp deadpixi-sam.desktop $(DESTDIR)/share/applications as a fallback?
  5. The way numlock breaks Return and Backspace took me by surprise... Might want to look into that or at least document it somewhere... Since I actually knew both sam and ed beforehand, I started playing around with ctrl+enter and other combinations thinking it's some weird default I'm not familiar with :D Only when I finally tried hitting the numpad enter did I guess by chance numlock must be doing something weird :)

Anyhow, these are the immediate issues I noticed working on packaging deadpixi-sam for Nixpkgs (NixOS/nixpkgs#18305).

Thanks for the updated sam :)

linking fails on osx

hi, looks like osx has none of the *at flavor.

8 warnings generated.
c99 -L/usr/X11R6/lib  rsam.o   -o rsam
Undefined symbols for architecture x86_64:
  "_mkfifoat", referenced from:
      _main in rsam.o
  "_openat", referenced from:
      _main in rsam.o
  "_unlinkat", referenced from:
      _cleanup in rsam.o
      _main in rsam.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

RFE: Ctrl-I and Ctrl-J should behave as Tab and Return

Currently, doing an explicit Ctrl-I or Ctrl-J will insert 'i' and 'j' respectively instead of acting as Tab or Return. This is at least surprising; in most everything else the Ctrl- version is the same as the keyboard key. It's also not how the traditional/original version of sam behaves (in it Ctrl-I and Ctrl-J are equivalent to Tab/Return).

Scrolling with the scroll wheel moves lines off the top of the window

This happens with the experimental branch. If you open a file and use the mouse wheel to scroll down until the end, two lines will "move to the left" as if the characters get removed.

The buffer content is left intact, so this seems to be a fencing problem when handling scrolling

The built in composed text input key sequences don't include 'ta' for TAB

Commits 3ca56f0 and ecca4be updated doc/sam.1 and doc/keyboard to document and include the new 'ta' sequence to insert a hard tab even if -e is making the tab key insert spaces. However, libXg/latin1.c hasn't been updated to include this sequence, so it doesn't work without a $HOME/.keyboard file with the sequence in it (including a plain copy of the default one).

(As a larger issue, the same information is now in three places that must be manually kept in synchronization: in the manpage, in the example keyboard file, and in the source code itself. Would it make sense to ship auxiliary scripts to generate all of this from a master source, even if they're only run by hand instead of as part of the normal build process?)

socket closed after a period of time

Hi,

There is an issue where the localhost socket is being closed after a period of time. I haven't determined the reason yet.
I'm using the B command to open files. After a while I get an error:
"could not determine controlling socket name, starting new instance"
"could not open socket: No such file or directory"

Looking for the default socket ~/.sam.localhost and it seems it's closed/no where to be found.

What logs/debug would help you identify the issue? Should I run through gdb?

No O_DIRECTORY on osx

Just use O_RDONLY? (That's what libressl did: libressl/openbsd#23)

c99    -c -o rsam.o rsam.c
rsam.c:31:5: warning: implicit declaration of function 'unlinkat' is invalid in C99 [-Wimplicit-function-declaration]
    unlinkat(home, ".sam.fifo", 0);
    ^
rsam.c:49:32: error: use of undeclared identifier 'O_DIRECTORY'
    home = open(pwent->pw_dir, O_DIRECTORY | O_RDONLY);
~/src/sam$ uname -rsp
Darwin 13.4.0 i386

I can't mouse-wheel-scroll to the end of the document

Steps to reproduce:

  1. Create a new, empty buffer
  2. Fill it with many lines of content by executing something like < seq 1000
  3. Scroll downward with the mousewheel until the buffer will scroll no further

Expected results:

  • The last visible line is blank, representing the \n at the end of the file

Actual results:

  • The last visible line reads 1000

Notes:

In normal editing buffers, this is a minor annoyance and the worst outcome is that you might have some trailing blank lines at the end of the file.

In the command window, this is highly annoying, since the command-window ignores anything that happens before its "input point", which is at the very end of the buffer. Multiple times, when I felt sam was doing something weird, I tried to make sure I was typing at the end of the command-window buffer by scrolling as far down as I could, and clicking past the last character at the end of the line to make sure I was "at the end". Of course, that only broke things: I wound up typing commands just before the trailing newline that I couldn't see off the bottom of the window, instead of just after it.

As a workaround, one can scroll down with keyboard shortcuts (at least with the default bindings) or by clicking button 3 repeatedly at the bottom of the scroll-bar, until only the insertion point is visible on the top-line of the window. Dragging the scroll-thumb with button 2 works on smaller files (such as the 1000-line demonstration above), but in a sufficiently large file the thumb becomes so small that even when dragged to the bottom of the track, the window is still several pages above the bottom of the file.

select by double-click followed by a chord cut operation: selection not visible in between

Hello,

when one wants to cut a word, one can double-click on the word, not
release the (left) mouse button and press the middle button (chord operation).

However, the word gets (now) visibly selected on button release, thus
while the above operation does what one expects, the selection is
not visible before the (chord) cut operation. (C.f. acme.)

Thanks
Ruda

Backspace on highlighted text should delete text

This is part of the "make this like Plan9 sam" department.

In P9 Sam, highlight text via left click, then hit backspace deletes the text (And a character before the highlighted text), so it clears the text, then execute backspace (I'm assuming it sets dot before the highlighted text then executes backspace on dot).

In deadpixi Sam, hitting backspace after highlighting text simply performs the "set dot before highlighted text then execute backspace on dot".

As a workaround, chording a "cut" (left-click highlight, middle-click cut) does the same thing.

binding for undo?

bind C u command undo would be nice :)

btw, the PR got merged recently so sam in in Nix's master now: https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/editors/deadpixi-sam/default.nix

Unrelated, I've also updated vis which is using the sam command language with a vi like interface if you're unfamiliar & curious. A point of interest is how it solved the highlighter and extend-ability problem: It embedded lua 0_o Still, if you're going to rewrite samterm for real (which I think is crazy btw but I'm not complaining :D ), I figured you'd want to know about this...

As always, thanks for sam it's lovely :)

config.mk: can't disable multiple dot-moving keys following the documented procedure

config.mk currently says:

# If you want to have keyboard control of dot's position, set the following
# variables to the appropriate ASCII control codes. The default values
# emulate the WordStar diamond. Setting any command to zero disables it.
LINEUP=0x05
LINEDOWN=0x18
CHARLEFT=0x13
CHARRIGHT=0x04

If you try to do this to disable more than one of these characters, you'll discover that it doesn't work; the build will fail with an error about duplicate case labels, because these values are all used as case labels in type() in samterm/main.c, so they must have distinct values. This also means that #defineing them all to 0x00 if they're undefined at the top of samterm/main.c won't work; if more than one is undefined, you get the same problem.

I think the simplest solution is to change the documentation (and the default #defines) to say that to disable a key, set it to a unique negative number (eg -1, -2, -3, -4). This is a bit of a hack because it takes advantage of how the relevant variables are signed ints instead of unsigned ones, but it's easy.

(One can come up with large scale reconstructive fixes if desired. For instance, perhaps it would make sense to put all of the keyboard mapping handling into libXg instead of having some of it in samterm/main.c. For cursor movement, the various deletions, and so on, libXg would emit abstract keys for the various operations (in the same way it emits composed characters), and only libXg would care about how specific physical keys or key sequences are mapped to those operations. Then 'LINEUP' et al would always be defined in samterm/main.c, and it would be libXg's job to decide what, if anything, would generate LINEUP. This description may not make sense.)

Typo in man page?

https://github.com/deadpixi/sam/blob/master/doc/sam.1#L42

Is that or.Dq a typo?

I opened sam and then tried B filename in another terminal to see if I can load a file from outside. It executed without errors but I didn't see the file in the samterm. I couldn't understand what the man says clearly. Are there any pointers or examples?

I think create a FAQ will be a nice idea in future.

RFE: `$SAMRC` environment variable or something like it

Right now sam always loads .samrc from your $HOME. There are situations (such as being su'd or sudo'd to another login) where this is inconvenient and it would be nice to be able to load .samrc from another fixed location. This would also provide a convenient way of temporarily starting sam without a .samrc at all, so you're just using standard bindings and behavior; just run eg SAMRC=/dev/null sam .....

Tips for configuring sam

There doesn't appear to be any existing place in the docs for "hints and tips", but here's some things that I found out through trial and error:

  • sam lets you configure a font for drawing text, and a colour to draw it with. However, due to the way sam draws selected text, you should set the foreground colour to black OR use a font without anti-aliasing. If you don't do at least one of those, selected text will be rainbow gibberish.
  • If you're using a scalable font, you can force sam to draw it without anti-aliasing by adding :antialias=0 to the end of the font pattern: font Envy Code R:size=10:antialias=0
  • If the font you want to use looks terrible without anti-aliasing because it does not include rasterization hints, applying FreeType's autohinter by adding :autohint=1 may help.
  • If you're using a bitmap-based font, it may include a separate copy limited to Latin1 (ISO8859-1) encoding for legacy applications. Because sam doesn't do glyph scavenging, it's better to use a font with as many glyphs as possible. There's no FontConfig syntax for "give me a font in Unicode", but apparently "give me a font that supports Afrikaans" is enough to nudge it toward a Unicode font: :lang=af

If you can't find a suitable place for these tips, feel free to just close this issue.

can't enter capital accented characters

Some of the recent changes allowed me to enter (Czech) accented characters, however, I can't enter capital accented characters. E.g., using capslock + accented letters does not do what it does in other programs. Furthemore: I use the menu-key to switch keyboards. This works in sam, too, however, pressing the key also draws a 'rectangle' in the buffer (while nothing should, I believe, appear).

fatal error: X11/IntrinsicP.h

When I use make install

gwin.c:8:28: fatal error: X11/IntrinsicP.h: Aucun fichier ou dossier de ce type
compilation terminated.
<commande interne> : la recette pour la cible « gwin.o » a échouée

If you have an idea :)

unifying ˆ and ^

ˆ is a non-ascii character that's hard to type with a standard 104 us keyboard - it would be nice if ^ can be used in its place

NOT A BUG; ESC and arrows behaviour

Hello,

  1. Is there a reason why ESC does not do the cut operation
    in this version of sam? (As it does in its p9(p) incarnation.)

  2. Is there a reason for left/right arrow keys to not move
    the cursor left/right?

(Both, at least, by default.)

Thanks
Ruda

Black cursor on black selection

Since the pointer-cursor and the selection are both black, its impossible to see the cursor when mousing over selected text...

Files get permanently marked as "dirty"

Sam will occasionally decide a file is permanently "dirty" (has unsaved modifications) and saving the file no longer sets it to clean. This will happen to multiple files during extended use, though I haven't been able to figure out what triggers it.

New 'command send <keys>' feature doesn't work entirely reliably

The problem is that send literally inserts the keys into the command window, followed by a newline. If you already have a partially typed command that you haven't hit Return on, the sent keys are added on the end of it and may do something quite different than you expect. A multi-line sequence such as the sample binding for C-Enter is especially dangerous, because after the first line errors out the subsequent lines will be interpreted as sam commands instead of eg text to be inserted.

I can see two potential fixes. The simple fix is to refuse to do the send if there is pending text in the command window. The thorough fix would be to directly send the command to sam while inserting the command (and its output) immediately before the in-progress command, using something like the code path that executing menu items uses (since they have the same issue and have solved it).

As a side note, I got samterm and sam to crash and panic while fooling around with send'ing a command while I had bits of text selected in the command window. I can't reproduce it, but the crash messages from samterm are:

samterm: host mesg: count 8250 100x 58x 32x (new file) #0
...ignored
28 6e 65 77 20 66 69 6c 65 29 20 23 30 a 6 2 samterm:panic: host-terminal version mismatch: Resource temporarily unavailable

(Unfortunately systemd ate the core dumps. Thanks, systemd. That won't be happening again but it's too late now for this time around.)

could not initialize keyboard under Wayland

Hello.

Looks like sam cannot open under Wayland environment (GNOME 3.24). It complains: could not initialize keyboard. After changing to X11 based GNOME, it can work properly.

Not sure if it is a known issue. Suggestions are welcome. Thanks.

p.s., the sam from `plan9 from user space' works fine under the same environment.

Crash on start of samterm with hardening

I built sam/samterm with stack protector, PIE and fortify_source, and it segfaults at the Hbindname message now:

0x00005555555c1631 in inmesg (type=<optimized out>, count=<optimized out>)
    at mesg.c:127
127         text[i]->tag = m;
(gdb) bt
#0  0x00005555555c1631 in inmesg (type=<optimized out>, count=<optimized out>)
    at mesg.c:127
#1  0x00005555555c0c27 in rcv () at mesg.c:74
#2  0x00005555555b12ea in main (argc=<optimized out>, argv=<optimized out>)
    at main.c:83

(gdb) p i
$3 = 0
(gdb) p text[i]
$4 = (Text *) 0x5628dbd8
(gdb) p *text[i]
Cannot access memory at address 0x5628dbd8

It seems PIE is at fault here, which shuffles the addresses in the new samterm process(?)... is this code really passing pointers to global variables via a pipe? In a non-PIE build, text[i] is cmd, but not sure where that is defined really.

I-beam cursor for text selection?

I'm playing with Sam to learn more about minimalist text editing, but one thing that keeps tripping me up is that my text selections wind up off-by-one because I'm not used to selecting text with an arrow pointer.

Would it be possible to make sam switch to the I-beam cursor when it's over a text-window, or is the arrow-pointer supposed to be part of the charm, like the way the cursor keys don't actually move the insertion point by default?

RFE: Specific command binding for the menu 'write' operation

Given the potential issues with command send w interacting with incomplete lines in the command window, it would be nice to have a specific command binding for the menu 'write' operation. Possibly some other menu operations should have command bindings as well.

Cannot transfer text between two instances of sam

Suppose that you are running two copies of sam (perhaps on different machines) and you want to transfer some text from a file in one to a file in the other. In theory you should be able to snarf the text in the source sam, <exch> to make it the X selection, <exch> in the target sam to import the X selection, and then paste it. In practice this doesn't work; the target sam winds up with nothing from its <exch> operation. It does work if I use xterm running cat >/dev/null as an intermediate.

This may be related to #61, since both involve <exch>.

In attempting to look at the code with very little knowledge of how X selection things work, I noticed that libXg/gwin.c's SelectSwap() appears to set the selection as a UTF8_STRING, but SendSel() returns false unless it is being asked for an XA_STRING. Some instrumentation suggests that when another sam asks for the selection, SendSel() is usually called with a UTF8_STRING Atom as the *target value. In the current code, it will thus fail. Hacking it up to accept UTF8_STRING as well appears to make things work between two sam processes (although it doesn't fix #61).

Performing <exch> two times in succession doesn't return your snarf buffer to sam

Suppose that you snarf something that you plan to paste into another spot in sam, but then you absently or reflexively <exch> it. You would like to get your snarf buffer back, so you <exch> again. This doesn't work. Worse, it doesn't even keep the X selection you imported in the first place; you wind up with nothing in sam's snarf buffer.

As far as I can see, if you start with 'SAM' in sam's snarf buffer and 'X11' in the X selection, the results are:

  1. first <exch>: sam's snarf buffer becomes the X selection, the X selection becomes the snarf buffer. So sam's snarf buffer is 'X11' and the X selection is 'SAM'.
  2. second <exch>: sam's snarf buffer turns into the X selection (which means that the X selection returns to the original value of 'X11'), sam's snarf buffer is empty.

c99 required to build

gwin.c contains two C99-style loops, which is not the default for older versions of gcc.

Please add -std=c99 to CFLAGS where required.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.