Coder Social home page Coder Social logo

howerj / edlin Goto Github PK

View Code? Open in Web Editor NEW
7.0 3.0 1.0 27 KB

Line Editor Library for constrained systems (that also have a command line and file system...)

License: The Unlicense

C 89.18% Makefile 5.33% Shell 5.49%
line-editor text c command-line ms-dos

edlin's Introduction

% edlin(1) | Line Editor / EDLIN clone

NAME

EDLIN - A line editor

SYNOPSYS

edlin files...

edlin < script.txt

DESCRIPTION

A Line Editor inspired by edlin, which is like a simplified version of ed.

The idea of this text editor is to use it on systems that behave a little like MS-DOS did, so a microcontroller with a command line and a file system. It is very niche and I do not expect it to be useful to anyone bar myself. The only dependencies should be on the standard C library, it should be fairly easy to port.

EXAMPLE

An example creating a new file called 'hello.c' containing the standard C program:

$ ./edlin # or 'edlin.exe' for Windows users
i
#include <stdio.h>

int main(void) {
	printf("Hello, World\n");
	return 0;
}
.
whello.c
q

Have fun.

COMMANDS

The editor starts up in command mode, commands 'i' and 'a' switch the interpreter into insert mode where text can be entered, a single '.' on a new line can exit insert mode back into command mode.

The commands are, where '#' is a number, <> is a file name, $ is a string, [] is an optional argument. If a file name is not provided the file opened up for editing is used. Ranges behave differently depending on the command and which optional numbers are provided. A file pointer exists which is used and updated depending on the command and optional numbers provided.

For numbers, the character '.' can be used for the current line number and '$' can be used to mean the end of the file. For example '.,$d' would delete everything from the current line up until the end of the file.

  • q

Quit the editor without saving.

  • [#][,#]w<>

Write a range to a file.

  • [#][,#]e<>

Save a range to a file then exit.

  • [#][,#]l

List a range, without updating the file pointer. A '*' marks the current position of the file pointer.

  • [#][,#]p

List a range, updating the file pointer to the end of the range. A '*' marks the current position of the file pointer.

  • [#][,#]d

Delete a range of lines. If no range is provided the current line the file pointer points to is deleted.

  • [#]i

Enter insert mode at a line if provided, at the file position if one is not. This command updates the file position to end of the last inserted line. To exit insert mode type a single '.' character on an empty line.

  • a

Enter insert at the end of the file. This command updates the file position to end of the last inserted line. To exit insert mode type a single '.' character on an empty line.

  • h OR ?

Print out the help message. This is all.

  • @

Print information about the currently opened file and editor state.

  • [#][,#]s$

Search a range for a string.

  • [#]t<>

Transfer a file into the currently opened file at the line specified, if no line is specified transfer to the file pointer.

  • [#]v

Set the editor verbosity to the number provided, higher numbers mean more messages and noise.

  • #,[#],#m

Move a range of lines from one position to another.

  • #,#,#,#c

Copy a range of lines.

  • [#][,#]r$

Replace a range of lines.

Edit a single line, updating the file position to the line after the one edited once editing is done. This does use '.' as an escape character, so if you need to insert a single '.' on a line then this is one way to do it.

KNOWN LIMITATIONS

  • The file that is being edited is loaded into RAM so files cannot be bigger than your memory.
  • 'unsigned long' is used to keep track of line numbers, and 'int' for line line lengths. The minimum values for these are 2^32 - 1 and 65535 respectively, so that limits the maximum line count and maximum line length to those values.

BUGS

Yes.

COPYRIGHT

The project is released under the 'Unlicense', which puts the project into the public domain. Do what thou wilt!

edlin's People

Contributors

howerj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

skywind3000

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.