Git Product home page Git Product logo

edj's Introduction

edj, sedj, and vedj

Edj (pronounced like the English word "edge") is the skeleton of a simple line editor patterned after Unix ed(1). sedj is the stream editor - a tiny subset of Unix sed(1). vedj is - wait for it - the visual edj. The names all rhyme.

It was not created to be a useful editor - you cannot yet save your work! - but to provide a platform for some demonstrations of Design Patterns and related issues, particularly in the Java language, including the "undo" command. If someone (or even me) tries to turn it into a useful line editor, you’ll know that CLI fans have regained the upper hand in geekdom. Or not.

It was also written to show that you can, in fact, do something small and (possibly) useful in Java without dragging in 47 different add-on JAR files. This project has zero external run-time dependencies and only one test-time dependency (JUnit).

Note that the BufferPrims code has changed slightly from the version shown in Part 1 of the article, appearing in the July/August issue of Java Magazine, due to the need to support a screen editor as well. If you want that exact version, use git checkout edj_article.

Usage

  • Compile and package:

	mvn package
  • Copy the edj and vedj scripts to a directory on your path (for MS-DOS-derived systems, somebody needs to write DOS bat files to do the same thing).

  • Copy the JAR file from target/ to someplace like $HOME/lib/

  • Hack the scripts script to find the jar file there.

Invoke with a filename argument, or, start with an 'r' (read file) command.

Commands are single lower-case letters (or '.' or '=') Command lines are of the form start,endCOMMANDoperands

The line range start,end is optional; if omitted altogether the current line (most recently added or modified, or clicked on in vedj) is meant. If only one line is intended, omit the comma and the second number. A command line that consists only of a line number will move the current line to that number.

The original ed's special line number '$' (dollar sign) meaning 'last line' is not yet implemented. Line numbers beginning with '+' or '-' are not implemented. The special filename syntax beginning with '!' ('bang' or exclamation mark) will not be implemented.

The following commands are implemented so far:

Table 1. Implemented Commands
Name Stands for Notes

.

Current

Print the current line

=

Line numbers

What are current and dollar(last-line) equal to?

a

append

Type lines, end with "." on line by itself

d

delete

e

edit

load a new file and make it the current file

f

filename

Print or set the current filename

p

print

Print the line or lines

q

quit

Does not currently prompt for unsaved changes

r

read

read named file into buffer

s

substitute

[linerange]s/old/new/[g][p] - replace old (regex) with new (text), once per line unless g

u

undo

Undoes last modify command

The following are not implemented:

Table 2. Unimplemented Commands
Name Stands for Notes

b

-

c

change

combines delete with append

g

global

Not implemented, but g/RE/p is the origin of the grep command’s name.

h

-

i

insert

Like 'a' but inserts before current line

j

join

merge current line and next line into one line

k

marK

l

list

Like p but expands unprintable characters

m

move

n

-

o

-

t

transfer

Copy lines

v

inVert

like g but does non-matching lines

w

write

write to current file if any, or named file

x

?

encrypt file

y

-

z

-

:

extension

That would start down the path from ed to ex, and then vi. Not on my watch.

History

When computers were very young, there were no graphics systems for them, no touchscreens, no mice, only "terminals" that read from a keyboard and printed on paper. It was in this era that line editors were the dominant way of editing text for program source code, emails, instant messages, and so on.

An ed command that is recognizably the origin of this family of tools appeared in Version 1 of AT&T Bell Labs Research UNIX around 1970.

Versions of ed have been in every flavor of Unix (including *BSD and Mac OS X), and in every Unix-like system (Linux etc.), since then. Berkeley Unix mutated ed into ex, and then added visual editing mode, which became the vi editor, in the late 1970’s. Vi still has ex (and hence ed) line mode editing built in.

So this project is a months-young implementation of a fifty-year-old specification.

edj's People

Contributors

dependabot[bot] avatar iandarwin avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

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.