![]() |
|
I've written pad mainly for personal use. There are enough ideas for enhancements, but on one hand I'm too lazy to add them and on the other hand I don't want pad to grow fat. If you're happy with your editor there is no need to use pad.
YES: large files, long lines, binary clean, multiple files, mouse support, cut/paste, search/replace, undo, autoindent, key macro, bracket matching, ...
No: scripting language, regular expression searching, overtype mode, syntax highlighting, text formatting ...
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of merchantability or fitness for a particular purpose. See the GNU General Public License published by the Free Software Foundation for more details.
The name "pad" has nothing to do with pcb or chip design. There is no relation to the famous notepad editor, the palm address dumper or any other product with the same or a similar name. Pad does not use ncurses pads. The name was choosen to be short for typing and easy to remember; it's the first three letters of my calling name (I have a bad memory for names but usually remember this).
On DOS my favorite editor was Point supplied with the Logitech Modula compiler. Point allowed quick working with a few mouse clicks. It was even ported for TCL/TK, but this does not run on a console. Pad looks similar to Point but I'm not an experienced programmer nor do I like late-night hacking so it lacks some nice features.
Jul-1999: Planned to write the editor, read a lot about console programming, first steps with ncurses, initial version for editing multiple files given at the command line, saving files at exit, scrolling, selecting text, cut/copy/paste.
Aug-1999: Fixed some problems with recognition of function keys, search, search/replace, enhanced file access, open/save/close from within the editor.
Sep-1999: Autoindent, indent/outdent of selection, key macro, interface to gpm mouse driver, commandline options, run shell commands, html page.
Oct-1999: (0.54) Changed edit buffers for multiple undo, delete without overwriting clipboard.
Nov-1999: (0.69) Change case, tab handling, ascii table, fixed backwards selection with mouse, dos/mac modes.
Jan-2000: (0.72) Bug fixes (scrolling, backspace, dos mode) and cosmetic changes.
Feb-2000: (0.74) Window resizing, toolbar, fixed some bugs (and introduced some new ones).
May-2000: (0.77) Simple file browser to open files, resolving symbolic links for backup files, execute selection.
Jul-2000: (0.78) Scroll bar added to file browser. Cut/copy/paste now end keyboard selection mode.
Sep-2000: (0.79) Bug fixes (backspace after paste, function keys with caps locked).
- | no recognition of already opened files. |
- | handling of xterm resizing not stable. |
- | changes are lost after a crash (no error recovery). |
- | no check for file size limits (approx 2GB). |
- | no check of available memory or disk space. |
- | no configure script and no makefile available. |
Thanks to Anton, Peter and Urs for proof reading, discussion of problems and for testing.
Thanks to all folks working on Linux and contributing free software to the public.
email: paddy.strebel@tiscali.ch, please write in easy english or german.
Pad was compiled with gcc on different Pentium PC's (Linux 2.2.x) and on some Suns (Solaris 2.6). Other compilers or other hardware may work. Pad needs the ncurses library (4.2, 5.0) and for console mouse support the gpm library. Verify that ncurses.h and gpm.h are in the include path. Compile with:
gcc -g -Wall -o pad pad.c -lncurses -lgpm
Or if gpm mouse support is not needed:
gcc -g -Wall -o pad pad.c -lncurses -DNO_GPM
The -g option is for support with the gnu debugger. When pad recognizes an error it dies with an error message and then forces a core dump for locating the problem with gdb.
After successfully building the program try it out with some filenames as arguments. Get help with "ESC h". Quit with "ESC q".
The environment variable TERM must be set appropriately
for proper function of display and keyboard (see termcap resp. terminfo).
Try TERM=linux on a text console or TERM=xterm in an X-Terminal.
Correct TERM setting is essential: e.g. a gnome terminal was not
cleanly updated after scrolling (blank regions still contained old text).
The problem was solved with "export TERM=color_xterm".
pad myfile
Writing will insert text just before the cursor. Use the BackSpace key to correct typos.
Move around with cursor keys or place the write cursor with the mouse.
To scroll full pages use the PageUp/PageDown keys.
Or click on the scrollbar at the left boarder.
Select Text with the mouse, cut the selection with DEL and paste it with INS.
When you're finished press F10. Confirm you want to save the file with Enter.
When pad is started with no arguments a help screen is displayed. Files may then be opened with ALT-o.
Normally pad will be started with a filename. If an existing file can't be opened for reading or a new file cannot be created pad will terminate with an error message.
Commandline options start with a minus "-".
Filenames and options may appear in any order.
Options are globally and not related to a file.
All options may also be changed on the fly
with the editor command ALT-o.
-a, -A | Autoindent off, on. With default setting (-A), when inserting a newline, leading spaces and tabs from the previous line are duplicated. |
-b, -B | Backup file off, on. Per default (-B) whenever a file is saved to an existing file (usually to itself) a backup of the old file is created with '~' appended to the filename. With the -b option that backup file will be removed. |
-c, -C | Case sensitive searching off, on. Default setting (-c) ignores upper/lower case for all searches (also for search/replace). |
-k, -K | Black screen off, on. Text display is white on a black background (-K) if the terminal allows. Option -k turns the display to black on white. |
-p, -P | Mouse off, on. With the default (-P) pad tries to get mouse events. Unfortunately pad does not interface with default select/paste mechanism of external text: To get this partly working, the mouse may be turned off with -p. |
-x, -X | Open files full size off, on. By default (-X) the window of a newly opened file expands over the full screen. When -x is specified new file windows do not cover the top line (toolbar). |
-i string | Pad allows quick indenting of a selected text area with ALT-i. The reverse may be done by ALT-j. The default indent string is two spaces. Any other string may be defined: For example a string "> " may be used for quotations in a email reply. |
-m command | Default command is "padmak". The command may be run from within pad and gets the name of the current file as parameter. First the current file is saved, then the command is run and it's screen output is logged to a temporary file: This allows for compilation while working on a source file without leaving the editor and location of numbered errors with ALT-n (next error). |
-r command | Default command is "padrun". Similar to the -m option this command may be run from within pad and gets the name of the currently edited file. But the current file is not saved and output is not logged. |
-t n | Tab width. n is 8 by default and must be in range 0..100. When set to 0, tabs are shown as a "right tee" symbol instead of blank space. |
-U, -D, -M | End of line code Unix (LF), Dos (CR+LF) or Mac (CR). Default (-U) is Unix file format. If setting is wrong, line ends are visible and sometimes the whole file is on a single line. |
toolbar: commands
|
options: autoindent, case sense, background
|
help wtop undo open save quit cut paste copy fwd bwd rpl A c K + file3 (read only) ------------- L:1 C:1 0:101=65=41 + | .................. | | ....... | | ............. + file2 (new) ------------------ L:1 C:1 0:040=32=20 + | ..... | ...... | | ....... | ....................... | | .. | | | ... + file1 -------------------------- L:3 C:7 0:141=97=61 + | | .. | ............... | | | ... | .................... | | | ... | ........ | | +-----| ............ | | | .................. | | | .......... | | | ..... |---------+ | ............. | | ... | | | +------------------------------------------------------+ not found: quite an ugly search string ... |
|
message and command line
|
filename
|
line, column, offset : oct=hex=dec
|
||
scrollbar
up/down |
+ foobar (new) --------------------- L:1 C:1 0:040=32=20 + | .................. | | ............. | | ................ | | .......... | | ............ | | .......... | | .................... | | .............. | | ............ | | ... | | ............... | | ........ | +--------------------------------------------------------+ |
searchbar
bwd/fwd |
|
scrollbar (left/right)
|
Every byte takes exactly one character cell on the display. This is even true for tabs when the tab width is set to 0 with the -t option: then tabs are displayed as a "right tee". Carriage returns are displayed as a "lower right corner" and linefeeds as a "lower left corner" but when acting as newline code these are shown as a space at the end of the line. Nulls are displayed as "degree" signs and other codes below 32 (space) as a "tee" sign.
A bytecode of 127 is displayed as an "upside-down tee" and all codes from 128 to 255 are shown as a "large plus" sign.
If unsure move the cursor to a character position and read the code from the upper right corner of the file window.
Commands are inwoked by the ALT- (or META-) key combined with a
single letter a-z. If this does not work ESC followed by the letter
can be used.
For conveniance some commands are additionally available on
function keys F1 to F12. The DEL and INS keys serve also for
cut and paste.
Example: switch to next file window with ALT-w or ESC w or F8
ESC will also cancel any command that is waiting for input.
(a command may also be cancelled with the right mouse button or entered
with the left one!)
^c | terminate (this is ignored) |
^h | backspace |
^i | tabulator |
^j | newline |
^m | return (will insert a newline, not a carriage return) |
^q | xon (start transmission) |
^s | xof (stop transmission, resume with ^q) |
^z | stop (resume with shell command fg) |
The null character CTRL-` (CTRL-backtick; CTRL-Space on some keyboards) changes the case of all alphabetic characters within the selection.
CTRL-a shows an ascii code table (see also: man ascii).
CTLR-y is reserved for debugging.
CTRL-e, CTRL-g, CTRL-k, CTRL-o, CTRL-t, CTRL-v, CTRL-w and CTRL-x are currently not used.
When you expand a selection with the mouse and you entered word or line selection mode by double or tripple clicking, the selection is expanded to full words or lines: ALT-y or F6 cancels this mode.
The selected area may be cut or copied to the clipboard and inserted anywhere within the text even in another file window. You may also search for another occurence of the selected text. The search/replace command can do replacements limited to the selected area if you wish. And finally the indent and outdent commands work within selected text.
There is a scrollbar at the left margin to scroll up and down, and a scrollbar at the bottom to scroll left and right. Scrolling is disabled if the file has less lines or columns than half the display height or width. It is useful to have a three button mouse for scrolling.
If the right mouse button is clicked at top of the scrollbar the file window scrolls down one line. To scroll more lines click the right button on the scrollbar beneath the line you want to move to the top. The left button works likewise but in the other direction.
Click the middle mouse button at top of the scrollbar to display the top of file or at the other end to see the end of file. To move somewhere in between click the middle mouse button on the scrollbar between top and bottom. Warning: if the file is large scrolling may take a long time.
The bottom line acts as a scrollbar for horizontal scrolling. The three mouse buttons may be used to scroll left or right or to move quickly to some column within a long line.
If the right mouse button is clicked on the right margin the selected text is copied to the search buffer (or part of it if the selection is too large) and this pattern is searched forwards. The left button does the same but searching is done backwards.
To resize a file window click with the right mouse button on a corner an drag it to a new location. To move the window drag its title bar with the right mouse button. There is a toolbar with frequently used commands on the topmost line in background. File windows may overlap the toolbar to get a larger area for viewing edited data.
If pad runs with user id root, owner and group of the modified file are not changed but the backup file gets owner root.
Pad works on the original file but does not change it. When saving the original file is renamed and becomes the backup file. The changed file is newly written. When the original file has been changed from somewhere else since start of editing, pad will complain. (this may happen when an editor that saves to the original file, like vi, changed the file; but when the file is renamed or deleted it stays available as long as pad has it opened)
Saving a file does not replace the original file atomically. This is critical for files that should always be available like /etc/passwd.
CTRL-d is used by Point to enter a string to search for. When you do this in pad CTRL-d moves the cursor down a line and then the entered string is inserted into text. But that's not what you aimed for. If you want to search for a string you must move your left hand a bit more to the right and type ALT-f. Think of FIND! or FORWARDS!
Save & exit with F9 and close a file with F3: these keys are exchanged.
Bracket matching is done with ALT-m (not ALT-b).
Locating a line is ALT-l (not ALT-n).
When the editor is left with F10 (ALT-q) it is asked whether to save and not wheter to discard changes.
F5 starts keyboard selection mode. Even though the F6 key displays the file status it may still be used to end keyboard selection mode.
ALT-y displays the current size (number of bytes) and lines count (number of newlines).
Internal status (shown in parantheses): bufcnt is total number of edit buffers. These buffers are kept in memory and point to a chunk of file data on disk. Data is either in the original file or in the temporary edit file (inserts and clipboard). While editing bufcnt grows and editing speed will decrease. When saving a file its data chunks are gathered and edit buffers are freed. ncol is number of columns from the longest line on the screen. tln is the topmost line on display (first line is 0). sft (shift) is the leftmost column on display (starting at 0). chg is increased by each edit step and decreased with undo.
The open command allows also for changing options the same way options are given at the commandline. It is allowed to enter more than one filename but no wildcard expansion is done.
With ALT-z the current file is closed. When the file was changed you will be asked whether to save it or not.
Save the file with ALT-s. You are asked for a filename. If saved to another file the original file will be closed and the file with the new name is kept open.
Alt-q leaves the editor asking for each changed file whether to save it or not.
If a read-only file was changed you are always asked whether to save it and to what file. It is possible to ignore the write protection if access rights are sufficient.
ALT-c copies the selected text to the clipboard.
ALT-v inserts the clipboard contents from the last cut or copy right before the text cursor.
Alt-d deletes selected text without saving it to the clipboard. To delete some text without loosing the clipboard contents you may also use the BackSpace key.
ALT-b let you define a string to search backwards.
CTRL-b repeats the last search backwards.
When entering the search pattern ALT-a may be used to define any byte code.
If the -c option is set (default) upper case text is changed to
lower case and searching is not case sensitive.
For case sensitive searching type ALT-o and enter -C
(if not already done on the commandline).
Example: delete carriage-returns from a DOS text file
1. | Go to top of file e.g. with ALT-l, ENTER |
2. | Call search/replace with ALT-r |
3. | replace what? : ALT-a, 13, ENTER, ENTER |
4. | replace with? : empty string (hit DEL if there is a string), ENTER |
5. | to end of file [e] or within selection [s]? : ENTER (defaults to [e]) |
6. | Verify each change? [y/n] : n |
ALT-g goes to the byte with a specified offset from filestart. When no number is entered the first byte is located. A number larger than the file size goes to the file end.
Insertion of text at a new location is treated as a single editor step including corrections with backspace. A newline introduces another editor step.
When search/replace is done without confirmation all replacements are undone at once. When replacements have been confirmed, the most recent change is restored with every undo, so it is possible to restore only part of the replacements.
ALT-j deletes n characters (n is the length of the indent string) at the current position or at every line within the selection. The starting column of the selection determines at what column on each line characters are removed. When a line end is reached no more characters are deleted.
With the option -i <string> the default indent string may be redefined.
Alt-p starts playback of the previously recorded key sequence.
m: save & make
The current file is saved. Then the command "padmak" is run with
current filename as argument.
Screen output is logged to a temporary file. This allows for
compilation of a source file without leaving the editor
and locating numbered errors with ALT-n (next error).
The default command "padmak" may be a script that starts a compiler.
With the option -m <command> any command that takes a filename
as argument may be specified.
Example 1: simple "padmak" script that was used to compile pad.c:
#!/bin/sh gcc -g -Wall -lncurses -lgpm $1An option -m "gcc -g -Wall -lncurses -lgpm" would have done the same, without an external script.
Example 2: "padmak" script to compile a sourcefile with extension .c or .java:
#!/bin/sh srcname=$1 basname=`echo $srcname|sed -e 's|\..*$||'` extensn=`echo $srcname|sed -e "s|$basname||"` if [ $extensn = ".c" ] then gcc -g -Wall $srcname -o $basname -lncurses -lgpm fi if [ $extensn = ".java" ] then javac $srcname fi
r: run
By default "padrun" is run with current filename as argument.
The file is not saved and output is not logged.
The option -r <command> allows to specify any command that takes
a filename as argument.
Example: simple "padrun" script that runs a previously compiled program:
#!/bin/sh a.out
x: exec sel
Takes the selected text from the current editor window as a command
to execute in a subshell.
s: shell
Starts a subshell by executing /bin/sh. Return to the editor with
with the command exit or with CTRL-d.