rnoth / edna

ed-like text editor
MIT License
16 stars 0 forks source link

Man page form the README #3

Closed ghost closed 7 years ago

ghost commented 7 years ago

Here is a prorpsition of man page in the mdoc format.

mandoc -Thtml -Ofragment edna.1


EDNA(1) General Commands Manual EDNA(1)

NAME

ednatext editor inspired by the UNIX standard, ed

SYNOPSYS

edna file

DESCRIPTION

At the moment edna has some features, but not quite at odds with ed(1) itself. There are two modes: ‘command’, and ‘insert’. While starting edna, the ‘command’ mode is active. To insert text, an insersion command have to be entered.

Insertion commands

a
Enter insert mode, appending lines after the current
i
Enter insert mode, inserting lines before the current
c
Delete the current line, and insert lines in place of the deleted
To exit insert mode, enter a “.” alone at the beginning of the line.

Edition commands

d
Delete the current line.

Printing commands

p
Print the current line.
h
Explain the last error.

Buffer management commands

o
Opens a delimitted list of files in new buffers.
b
Lists the all the opened buffers.
next
Focus the next buffer.
prev
Focus the previous buffer.
f
Print or change the default filename.
w
Write the contents of the buffer.
e
Re-open the current file, or edit a new file.
q
Free the buffer and exit successfully.
wq
Write and quit.
Q
Quit unconditionally.
If edna is given a list of files as it's arguments, they are read into memory as buffers, and written back out on w and wq commands.

FILES

edna has a config.h header file included at compilation time, which allows configuring a few options:
PROMPT
Macro expanded and printed before a command is read from stdin. It defaults to ‘:’, but it is fed into printf(3), allowing some flexibility. the ‘%ld:, bufgetpos(buf)’ prompt is quite handy, for instance
INS_PROMPT
Macro expand and printed before a line is read from stdin when in insert mode.
ERROR
Macro expanded and printed when a command fails in some way. Following ed(1), edna defaults to “?\n”, but you may find “%s\n” error more helpful.
The prompt have to contain the newline.
config.c Primarily contains the arrays for commands and modes, to prevent them from being re-defined everytime.
commands
Array indexed when a command is read from stdin It has a four fields:
name
A string handle to identify the command both to the user and edna.
func
A pointer to function to be executed.
mode
A string which allows extra context to be given to the function.
defaddr
the default line address of the command
modes
Array indexed when a command tries the change the mode, it has six fields:
name
the name of the mode
init
currently unused
prompt
executed first
input
executed second
parse
Executed last.
If any of these commands return failure, the sixth member is called:
error
The error handler

EXAMPLE

Example of edna interactive editing session:
% edna 
:i 
int main() { 
    return 0; 
} 
:
A configuration example can be found in the source directory at examples/config.h.
March 9, 2017 Linux 4.9.11-1-ARCH
ghost commented 7 years ago

PS: I did it with ex, to try line editing. This actually works!

rnoth commented 7 years ago

this is wonderful, thanks!