Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.o
atto
debug.out

*~
.redo/*
4 changes: 4 additions & 0 deletions CHANGE.LOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Atto Emacs Change Log

# Atto v1.22f1 19 Jul 2022
* Add C-z command to suspend the editor.
* Load all files on command line and optionally jump to a specified line.

## Atto v1.22 06 Dec 2020
* fixed some color issues when running on Arch, needed to set color in modeline and msg line

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Atto Emacs

This is Atto v1.22f1 with a small set of additions be Georg Lehner <jorge@at.anteris.net>

The smallest functional Emacs in less than 2000 lines of C.

Atto Emacs is inspired by MicroEmacs, Nano, Pico and my earlier project known as Perfect Emacs [1].


![Atto screenshot](https://github.com/hughbarney/atto/blob/master/screenshots/atto.png)


Expand Down Expand Up @@ -71,6 +72,7 @@ Atto is based on the public domain code of Anthony Howe's editor (commonly known
C-W Kill Region (Cut)
C-X CTRL-X command prefix
C-Y Yank (Paste)
C-Y Suspend the Atto process (Run 'fg' at the shell to resume it)

M-< Start of file
M-> End of file
Expand Down
24 changes: 24 additions & 0 deletions atto.equivs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# leg20220722: atto Debian packaging
Package: atto
Version: 1.22f-1.0
Priority: optional
Section: editors
Maintainer: Georg Lehner <jorge@at.anteris.net>
Homepage: https://github.com/jorge-leon/atto
Tag: implemented-in::c, interface::text-mode, role::program,
scope::application, uitoolkit::ncurses, use::editing,
works-with::text, works-with::unicode
Description: The smallest functional Emacs in less than 2000 lines of C.
Atto is a small, multi buffer, multi window text editor for the console
with UTF-8 support and Emacs key bindings.

Architecture: any
Standards-Version: 3.9.2
Copyright: debian/public_domain
Readme: debian/README.Debian
Changelog: debian/changelog.Debian
Extra-Files: README.md
Files: atto /usr/bin/

Postinst: debian/postinst
Prerm: debian/prerm
6 changes: 6 additions & 0 deletions clean.do
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
exec >&2

make clean

rm -f atto_*.buildinfo atto_*.changes atto*.deb
2 changes: 2 additions & 0 deletions command.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,3 +354,5 @@ void showpos()
curbp->b_point, ((curbp->b_ebuf - curbp->b_buf) - (curbp->b_egap - curbp->b_gap)));
}
}

void suspend() { raise(SIGTSTP); }
5 changes: 5 additions & 0 deletions deb.do
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
exec >&2

make atto
equivs-build atto.equivs
13 changes: 13 additions & 0 deletions debian/README.Debian
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
atto for Debian is built with equivs.

Installation instructions:

sudo apt install libncurses-dev equivs build-essential
git clone https://github.com/jorge-leon/atto
cd atto
sh deb.do
sudo dpkg -i atto_*.deb

Set up atto as default editor:

sudo update-alternatives --set editor /usr/bin/atto
5 changes: 5 additions & 0 deletions debian/changelog.Debian
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
atto (1.22f-1.0) stable; urgency=low

* Initial Debian packaging

-- Georg Lehner <jorge@at.anteris.net> Sat, 23 Jul 2022 09:40:24 +0200
5 changes: 5 additions & 0 deletions debian/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

set -e

update-alternatives --install /usr/bin/editor editor /usr/bin/atto 30
10 changes: 10 additions & 0 deletions debian/prerm
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

set -e

if [ "$1" != "upgrade" ]
then
update-alternatives --remove editor /usr/bin/atto
fi


2 changes: 2 additions & 0 deletions debian/public_domain
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Atto code is released to the public domain.
hughbarney AT gmail.com 2017
2 changes: 1 addition & 1 deletion gap.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ point_t pos(buffer_t *bp, register char_t *cp)

int posix_file(char *fn)
{
if (fn[0] == '_')
if (fn[0] == '-')
return (FALSE);

for (; *fn != '\0'; ++fn) {
Expand Down
5 changes: 4 additions & 1 deletion header.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
#include <string.h>
#include <unistd.h>
#include <wchar.h>
#include <signal.h>
int mkstemp(char *);

#define VERSION "Atto 1.22, Public Domain, Dec 2020, by Hugh Barney, No warranty."
#define VERSION "Atto 1.22f1, Public Domain, Dec 2020, by Hugh Barney, No warranty."
#define PROG_NAME "atto"
#define B_MODIFIED 0x01 /* modified buffer */
#define B_OVERWRITE 0x02 /* overwite mode */
Expand Down Expand Up @@ -155,6 +156,7 @@ extern void left(void);
extern void lnbegin(void);
extern void lnend(void);
extern void paste(void);
extern void suspend(void);
extern void pgdown(void);
extern void pgup(void);
extern void quit(void);
Expand Down Expand Up @@ -206,3 +208,4 @@ extern void set_parse_state(buffer_t *, point_t);
extern void set_parse_state2(buffer_t *, point_t);
extern int parse_text(buffer_t *, point_t);
extern void resize_terminal();
extern void arguments(int argc, char **argv);
1 change: 1 addition & 0 deletions key.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ keymap_t keymap[] = {
{"C-v forward-page ", "\x16", pgdown },
{"C-w kill-region ", "\x17", cut},
{"C-y yank ", "\x19", paste},
{"C-z suspend ", "\x1A", suspend},
{"C-space set-mark ", "\x00", iblock }, /* ctrl-space */
{"C-x 1 delete-other-window", "\x18\x31", delete_other_windows },
{"C-x 2 split-window ", "\x18\x32", split_window },
Expand Down
47 changes: 35 additions & 12 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,11 @@ int main(int argc, char **argv)
init_pair(ID_LINE_COMMENT, COLOR_GREEN, COLOR_BLACK); /* line comments */
init_pair(ID_SINGLE_STRING, COLOR_YELLOW, COLOR_BLACK); /* single quoted strings */
init_pair(ID_DOUBLE_STRING, COLOR_YELLOW, COLOR_BLACK); /* double quoted strings */

if (1 < argc) {
curbp = find_buffer(argv[1], TRUE);
(void) insert_file(argv[1], FALSE);
/* Save filename irregardless of load() success. */
strncpy(curbp->b_fname, argv[1], NAME_MAX);
curbp->b_fname[NAME_MAX] = '\0'; /* force truncation */
} else {
curbp = find_buffer("*scratch*", TRUE);
strncpy(curbp->b_bname, "*scratch*", STRBUF_S);
}

curbp = find_buffer("*scratch*", TRUE);
strncpy(curbp->b_bname, "*scratch*", STRBUF_S);

arguments(argc, argv);

wheadp = curwp = new_window();
one_window(curwp);
Expand All @@ -66,7 +60,7 @@ int main(int argc, char **argv)
/* allow TAB and NEWLINE, otherwise any Control Char is 'Not bound' */
if (*input > 31 || *input == 10 || *input == 9)
insert();
else {
else {
flushinp(); /* discard without writing in buffer */
msg("Not bound");
}
Expand All @@ -81,6 +75,35 @@ int main(int argc, char **argv)
return 0;
}

void arguments(int argc, char **argv)
{
int i, ln = 0, opts = 1;
point_t p;

for (i=1; i < argc; i++) {
if (!strcmp(argv[i], "--")) {
opts = 0;
continue;
}
if (opts && argv[i][0] == '+') {
ln = atoi(argv[i]+1);
continue;
}

curbp = find_buffer(argv[i], TRUE);
(void) insert_file(argv[i], FALSE);
/* Save filename irregardless of load() success. */
strncpy(curbp->b_fname, argv[i], NAME_MAX);
curbp->b_fname[NAME_MAX] = '\0'; /* force truncation */

if (ln > 0) {
p = line_to_point(ln);
if (p != -1) curbp->b_point = p;
ln = 0;
}
}
}

void fatal(char *msg)
{
if (curscr != NULL) {
Expand Down
22 changes: 19 additions & 3 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
# Public Domain 1991, 1993 by Anthony Howe. No warranty.
#

BINDIR = /usr/local/bin
DOCDIR = /usr/local/share/doc/atto
DESTDIR =

CC = cc
CFLAGS = -O -Wall

Expand All @@ -16,6 +20,7 @@ LIBS = -lncursesw
CP = cp
MV = mv
RM = rm
MKDIR = mkdir

E =
O = .o
Expand Down Expand Up @@ -59,8 +64,19 @@ main$(O): main.c header.h
$(CC) $(CFLAGS) -c main.c

clean:
-$(RM) $(OBJ) atto$(E)
-$(RM) -f $(OBJ) atto$(E)

install: atto$(E)
$(MKDIR) -p $(DESTDIR)$(BINDIR)
$(CP) atto$(E) $(DESTDIR)$(BINDIR)

uninstall:
-$(RM) $(DESTDIR)$(BINDIR)/atto$(E)
@echo not removing $(DESTDIR)$(BINDIR)

install:
-$(MV) atto$(E) /usr/local/bin/
install-doc:
$(MKDIR) -p $(DESTDIR)$(DOCDIR)
$(CP) README.md $(DESTDIR)$(DOCDIR)/

uninstall-doc:
$(RM) -rf $(DESTDIR)$(DOCDIR)