.ig \"-*- nroff -*-
     Copyright (C) 1998 Jaap Korthals Altes <jkaltes@hetnet.nl>       
                                                                           
     This program is free software; you can redistribute it and/or modify  
     it under the terms of the GNU General Public License as published by  
     the Free Software Foundation; either version 2 of the License, or     
     (at your option) any later version.                                   
                                                                           
     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 for more details.                          
                                                                           
     You should have received a copy of the GNU General Public License     
     along with this program; if not, write to the Free Software           
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.             
..
.de TQ
.br
.ns
.TP \\$1
..
.TH bed 1 "Apr 25 2002" "Bed Version 0.2.16"
..
.SH NAME
..
bed \- Variable dataformat binary editor
..
.SH SYNOPSIS
..
.B bed
[
.IR Options
]
[
.IR Files
]
.br
.B xbed
[
.IR Options
]
[
.IR Files
]
.br
..
.SH DESCRIPTION
..
Menu driven binary editor. Dataformats are
ascii, unsigned and signed integers, float, bitflags,
bitfields, labels, ebcdic and time_t. Different sizes
and byte ordenings are possible. Datatypes can
be used in structures. Other dataformats, filters and
procedures can be defined in plugins. Contains copy,
past, undo, redo, search, replace, marks, record/play and
context sensitive help. Linux & FreeBSD & Win95: 
edit block devices (linux limit 1023 gigabyte).
.SS Interface
Some general remarks about working with bed.
In bed you can do everything with the menu. You open a menu by pressing Alt in combination
with the highlighted key. A menuitem is selected by pressing only the highlighted key or
using movement keys followed by Enter. You can get help about a menuitem by pressing F1.
You escape from menu by pressing Esc.
In dialog boxes you can jump to the highlighted character by pressing Alt-char or
by using Tab and Alt-tab or shift-tab. Options are switched on by pressing space or *.
Buttons like Ok and Cancel are operated by moving to the button and pressing Enter.
.PP
While editing the usual movement keys should work, if they don't run bed -k.
.PP
Select works wp5.1 (and vi) like: You specify a starting point (prockey setselect)
and with whatever moving function exist you go to an other
point and you then press copy (prockey copyselect) or save selection (prockey saveselect).
.PP
bed has only a typeover mode, so your data doesn't move to another offset without
explicitly saying so. To extend a file you should explicitly call prockey extend. If you like to left something out you should copy everything after it past it
over what you like to remove and truncate the file with prockey truncate.
.PP
To be able to handle large files (e.g. whole harddrives) bed only holds in memory what 
is  changed and reads the other parts from disk at the moments they are needed. 
.PP
If bed seems to get in some end less operation, you can try Ctrl-C (Ctrl-Break when using win95 with pdcurses). It should bring bed back to it's main loop, but  sometimes problems arise.
.SS Data types
In bed you can display the filecontent in different dataformats for example: ASCII, signed and unsigned integers of variable base and size, and Floating point number of size 4 (float),8(double) and 12 (long double). 
Beside this standard types there are lots of other datatypes like:  bitflags, bitfields, translate (enum), ebcdic etc. You can also also add new datatypes in plugins.
.PP
\fBcomposed datatype\fP
.br
It is also possible to form composed datatypes (structures, records).
At different offset within a unit the filecontent is displays in a different
datatype. 
.nf
struct nameincome {
	char name[20];
	unsigned long income;
	};
.fi
For example if the file contains a database of strings of size 20 followed by a digit of 4 bytes, you can make a composed datatype of Ascii/20 and Dec/4. You do this simple by first making a ascii of size 20 by pressing prockey naarASCII and filling in 20 for Nr Bytes and setting Separate and then adding a unsigned integer by pressing prockey makemode setting for Nr bytes 4 and check Dec and Add field.
.PP
All kind of operations which can be applied to basic (single) datatypes can also be applied on composed datatypes: search, replace and the addition of a filter (e.g reorder). To do this you need to make the composed datatype the active datatype. You can do this by setting the cursor between two of its elements or by using prockey uplevel.
.PP
\fBSwitching datatype\fP
.br
Moving between parts of the screen with different datatypes
you can do with Prev (prockey prevmode) and Next (prockey nextmode). 
.br
Zooming a datatype you do with Full (prockey zoommode), removing a
datatype with Remove (prockey removemode).
.br
Save selection saves the selected part of the file in the
format of the active datatype. 
.br
\fBAdding datatypes\fP
.br
You can add a datatype with Ascii, Integer, Signed, Float, Clone.
Clone gives an identical copy of the currently active
datatype.
.br
Integer (alt-d,i) gives the following window:
.nf
                                          
   (*) Hex   ( ) Dec   ( ) Custom:        
   ( ) Oct   ( ) Bin   Base nr:           
                                          
   Nr bytes:   1                          
                          (*) Add field   
     Ok        Cancel     ( ) Separate    
                                          
.fi
.br
You can specify the base of the integer in the field Base nr
or you can use one of the options Hex,Oct,Dec or Bin. Hex
stands for hexidecimal, Oct for octal, Dec for decimal and bin
for binary. You can also check Custom and specify a base number.
.br
You can specify the number of bytes and the order in which the
bytes are interpreted.
.br
You can set Add field or Separate.
Separate makes a separate datatype. Add field means that this datatype is added to the currently active datatype, making a composed datatype (struct, record).  In the last case where in the existing datatype the new field is placed depends on the cursor position:
.br
- At the end of the existing datatype if the cursor is at the end of the screen
.br
- At the beginning of the existing datatype if the cursor is at the beginning of the screen
.br
- Otherwise at the place closest to the cursor.
.br
- After the cursor position if the distances are equal
.br
\fBModifying datatypes\fP: 
.br
Basic datatypes you can change by pressing prockey datatypeconfig (Config).
This are operation you can apply on some datatypes which
changes certain aspects while leaving other aspects the same. 
It are usually the same options you had when creating a datatype.
.br
\fBFilters\fP: 
.br
It is possible to place filters between the file and a datatype. Such a filter can transform the filecontent before interpretating it as a certain kind of datatype.
Currently there are the following filters:
.br
.br
Reorder (prockey reorderunit)
.br
Duplicate (prockey duplicate)
.br
Skip (prockey addskip)
.br
Backward (prockey backward)
.br
Index2table (prockey index2table)
.br
Translate (prockey translate)
.br
You can find a description by pressing F1 in the menu with the appropriate menu item
selected. The same description you can find somewhat further in this file in the list of all procedures. You can remove the last added filter by pressing prockey rmlastfilter (Rm filter).
.br
When using some filters, filters, like Skip, Index2table and and possibly Backward, differences in
file content are not always shown on the screen. Skip for example skips some bytes. Normal search translates the search string in a string of bytes and then
searches for this string in the raw content of the file. This is obviously
not possible if skipped bytes can contain different data within the file.
Regex search uses a different method. It first transformes the file content
to the search datatype and then searches in this datatype for the search string.
So if you use this kind if filters you should check regex search. The same applies for other datatype were what is displayed can corresponced to different bytes
like Float and Empty.
.PP
\fBSaving datatypes\fP: 
.br
Press prockey savedatatype (Write Type) to save a datatype. You can read it again with prockey readcontain (Read Type). CONFDIRLINK/misc contains some example
saved datatypes. Read CONFDIRLINK/misc/README.txt for a description.
.SS Search
When you press on search of the Move menu (prockey search), you come in the
search window. Standard you search in the currently active
datatype. To select a different data type you press on space
when the appropriate data type is selected (like Ascii). 
.br
When you instead presses on Return the search string is also
converted from the old data type to the new data type. 
.br
Beside this there are also the usual features like starting
from the top or the bottum of the file instead of the cursor
position, searching backwards, searching case insensitive and
using regular expressions. 
.br

.br
\fBRegular expression\fP:  Use the GNU regular expression library to
match a pattern against the text (See 
.BR regex(7)
). When using regular expression you can search forward and backward in
ascii text. In any other data type you can only search
forward. When "Regular expression" is not checked everything
is first converted to a general byte string and then for this
byte string is searched in the file. When searching  with
regular expressions enabled the file is block for block
converted to the currently active datatype and this printable
representation is searched for regular expressions in exactly
the same way as when the file was originally in this form.
This means for example that when searching case sensitively
the hex datatype ff is different from FF.
.br
When using  a floating point plugin different byte
strings can give the same superficial appearance. When you
convert the search pattern first into bytes and then search
for the bytes, you will only find one of this underlying byte
strings. When searching in regex mode you will find all of
them. The char2 plugin contains a data type which leaves out
every other byte. And when converting to bytes you have to
fill them in with something and when in the file they are
filled different you will not find the byte string. But when
searching only in the superficial appearance you can find
them.
.br
I haven't tried any attempt to optimize regular
expressions so regular expression search in ascii is very
slow, and this conversion to other datatypes before searching
makes it even slower. So only small distances can be searched
this way.
.br
Further shortcoming of regular expressions search:
.br
- Only one hit in a single datatype is returned. When
searching for 1 in a hex datatype it stops only once in 11.
.br
- The same byte can generate a hit in different alignments.
Only one is shown. To see them all you should change the
alignment around every hit.
.PP
\fBCase sensitive\fP: When checked upper and lower case are
treated distinctively
.br
\fBBoundaries\fP: Multibyte datatypes can be aligned differently a 4
byte digit can start at offset 0,1,2 or 3 and give then
different 4 byte digits. Without checking Boundaries all will
be returned. With Boundaries checked only bytes aligned in the
same way as is now shown on the screen are returned.
.br
\fBForward\fP: When checked the file is searched in the forward
direction going from lower to higher offsets.  When not checked the file is searched backward.
.br
\fBEdge file\fP: When checked the file is searched from the edge of
the file. From offset 0 when searching forward, from end of
file when searching backward.
.br
\fBFind\fP: Here you type the search pattern
.br
\fBList\fP: Generated a list of all hits. When compiled with
CONFIG_THREADS=y you can go on editing whilehits are marked
so you can view them in marklist (prockey showmarks).
.br
\fBAscii\fP, \fBDec\fP etc give when checked the current active datatype.
The last datatype is the currently active. In this case that it char2. Which is a plugin datatype.
.br
\fBNr bytes\fP: give the number of bytes each data item occupies. By
some datatype you can change this for example by unsigned integers. 
.SS Replace
Everything has the same meaning as in search, with a replace
string added.
.br
At the place where the search string is found the replacestring is placed. The replace string
.br
overwrites the data. When Regular expression is checked you
can insert the whole search string by & or
.br
supexpressions by \e1 \e2 to \e9. In the searchstring
subexpressions are demarcated by \e(pattern\e).
.SS Tools
A few options not handles by other menus.
.br
\fBNumbertype\fP: changing the number type in which the offset in
the file is shown (or removing offset numbers).
.br
\fBMessageline\fP: switching the messageline on and off, 
.br
\fBMenu\fP: switching the menu bar on and off
.br
\fBCommandmode\fP:  setting commandmode on and off. Inside command
mode the normal keys are not automatically put into the
document. This makes it possible to bound commands to normal
keys, like is done inside vi. By default there are no
keysbindings of this kind, but you can put it into the
configuration file if you want. 
.br
\fBProcedures\fP: View list off all procedures which can be bounded
to keys or are part of the menu. Press return on a procedure
to execute the procedure.
.br
\fBDynamic\fP: view procedures defined in plugins
.br
\fBLoad plugin\fP: filemanager to select a plugin
.br
\fBKey binding\fP: shows the procedure bounded to a particular key
.SH OPTIONS
.TP
.B -f bedrc
 Use configuration file bedrc, instead of env BEDRC 
.TP
.B or c
/.bedrc  or c:/Program Files/bed/bedrc 
.TP
.B -w
 Always test filesize
.TP
.B -d SIZE
 Set filesize to SIZE (dangerous!!)
.TP
.B -v
 Version information
.TP
.B -c
 Source and compile info
.TP
.B -h
 This screen
.TP
.B -s FILE
 play recorded keystrokes file FILE
.TP
.B -e procedure
 execute procedure at startup
.TP
.B -p plugin
 load plugin at startup
.TP
.B -k
 Configure key bindings for current terminal
.TP
.B -B
 black-white
.TP
.B The commandline you can specify files

.TP
.B doslike
 separated with \ caseinsenstive no wildcard 
.TP
.B unixlike
 separated with / casesensitive wildcards (*,?,[..],etc)
.TP
.B extentions

.TP
.B can use disk letters (e.g. c
/)
.TP
.B /cygdrive/c is c
/
.TP
.B inside bed
 separeted with  \ caseinsensitive wildcards
.SH CONFIGURATION 
In the configuration file you can change colors, assign keys, change
the menulayout, loud plugins. and configure to call procedure's at certain moments.
As configuration file is used the first file found of following:
the argument to -f at the commandline ,
the environmental variable BEDRC, PERSCONFIG or GLOBALCONFIG.
.SS Path
\fBplugindir\fP path
.br
Set directory were is looked for plugins to path.  Also effects prockey opendynlib.
.br
.br
\fBdatatypedir\fP path
.br
Set directory were is looked for saved datatypes  to path. Effects prockey savedatatype and prockey readcontain.
.SS Keys
When the keys don't work or you want to make different key bindings, you can assign 
 new key bindings in the configuration file. 
.br
In bedrc the keys are defined by lines of the following format:
.br
.br
\fB\fPkeys key1 key2 ...keyn = procedure
.br

.br
for example:
.br

.br
keys 27 115 = search
.br

.br
In which case Alt-s is bound to 'search' which is the search function.
.br

.br
The numbers are a decimal representation of the escape sequences generated by a
key or a key combination. Within bed you can press prockey showprocedure to press
a key and see the keycodes and keybinding.

Bed version 0.2.7 added the possibility to make keys statements of the
following format:
.br
.br
\fB\fPkeys capname  = procedure
.br
.br
capname is a terminfo name for a key sequence. For example
.br
.br
\fB\fPkeys kf1  = selectprocedure 
.br
.br
binds selectprocedure to function key F1. See man terminfo for details.
There seems to be as much variation in keylabels as keycodes, 
so don't expect to much.
.br

.br
\fBbed -k
.br
\fPIf you only want to assign the right meaning to the keys used
by the program
(instead of making new keybinding), you can press bed -k. You are
asked to press function
keys and it will append the corresponding key assignments to
PERSCONFIG.
.br
\fBPersonal keybindings
.br
\fPIf you want to make personal keybindings you should come to
know the
procedure argument to keys. To come to know the name of a
procedure mentioned
in the menu or bounded to an other key you press prockey showprocedure followed
by the
key or menukey combination.
.br
If you want for example to know what the name is of the
procedure behind
Alt-f,o you press prockey showprocedure followed by Alt-f,o and on the
commandline
you see something like "menu item Alt-f,o = addfile".
To bind this to insert you press prockey showprocedure ,INS and get as answer
something like:
No keybinding for 27 91 50 126
You add now at the bottum of PERSCONFIG 
.br
keys 27 91 50 126 = addfile
.br
An other way to learn the names of the procedures is the read the
Procedures section later in this manual, but the program itself is
always  
more up to date then the manual.
.SS Menu
New in bed-0.2.12 is the possibility to change the menu layout. 
You can add new items to the menu, add new menus and delete
menuitems and menu's. A 'menu' corresponds to the list of names you get 
when you press for example Alt-f, (the menu with menulabel "~File"). 
A 'menuitem' corresponds on name in this list for example "~Open     C-o".
.br
The menu's are numbered. The first menu on the left usually
"~File" has number 0, the following menu "~Edit" number 1 etc.
This number I will call 'menunum' in this manual.
.PP
\fBmenu\fP [menunum] menulabel [+]
.br
This command is used to give a menu a certain label and
keybinding. 
One character in label should be prefixed by ~ meaning that is the
highlighted letter what should be pressed in combination with Alt
to open the menu. The menu label should be surrounded by  "'-s.
e.g.
.br
     menu 0 "My F~ile"
.br
Changes the label of the "~File" menu to "My ~File".
To insert a new empty menu at position 0 shifting the other menu's to the right, you
should add a + after the previous command, getting:
.br
     menu 0 "My F~ile" +
.br
To create an empty menu at the very right you can use:
.br
     menu 8 "~Hallo"
.br
In this case you can also leave out 8, 
.br
     menu "~Hallo"
.br
In the menu command menunum defaults to the highest used menu number+1.
.PP
\fBmenuitem\fP [menunum] menuitemlabel [keylabel] [menitemnum] [+]= procedure
.br
This command is used to add menuitems to menu's.
For example:
.br
	menuitem 0 "~Quit" 1 = quit
.PP
	menuitem menunum menuitemlabel menuitemnum
.br
Replaces the existing menuitem at position 1 in menu 0 with the label "~Quit" and the
procedure quit.
Menuitem's are numbered from 0 starting from above.
If you like to insert the menuitem, while shifting the existing menuitems downwards,
you can add a +, which gives:
.br
	menuitem 0 "~Quit" 1 + = quit
.br
If you like to add a keylabel (e.g. M-q) you can change it to
.br 
	menuitem 0 "~Quit" "M-q" 1 + = quit
.br
this will be displaced as something like " \fBQ\fPuit     M-q "
to make M-q work you should also add something like:
.br
	keys 27 113 =quit
.br
In menuitem menunum defaults to the last mentioned menu. menuitemnum defaults
to the highest menuitem number + 1 (in this menu).
You can write:
.nf
     menu "S~imple"
     menuitem "~New" = emptyfile
     menuitem "~Open" = addfile
     menuitem "~Save" = dosave
     menuitem "~Quit" = quit
.fi
.PP
\fBmenuitem\fP [menunum] LINE [menitemnum] [+]
.br
This command is used to create a blank like in a menu (leaving a menuitem empty).
.br
To insert a line after "~Open" in the previous menu you can write:
.br
     menuitem LINE 2 +
.PP
\fBdeletemenu\fP [menunum]
.br
This command is used to delete a menu and all it's menuitems. If you dislikes the first
menu ("~File") you simply writes:
.br
     deletemenu 0
.br
In deletemenu menunum defaults to the highest numbered menu.
.PP
\fBdeletemenuitem\fP [menunum] [menitemnum]
.br
Deletes menuitem menuitemnum from menu menunum. menunum defaults to the last
mentioned menu, menuitemnum to the highest numbered menuitem.
When only one number is given it is interpret as meaning menuitemnum (for
menunum the default is used).
To delete the fourth menuitem out of the first menu, you write:
.br
	deletemenuitem 0 3
.br
In all menu commands you can explicitly use the default value by using a negative
number.
.SS Call_on
Instead of calling a procedure after pressing a key or using a menu, you can also
specify in the configuration file that procedure will be called at certain moment (on
startup,open,switch).
.br
\fBcall_on_start\fP procedure
.br
Calls procedure at startup, which means after the program is has started, and a file is opened. Operated is on this file. 
.br
\fBcall_on_open\fP procedure
.br
Procedure is called every time a file is opened.
.br
\fBcall_on_switch\fP procedure
.br
Procedure is called every time you switch to a file.
.SS Context
When you use more than one terminal (for example linux console and rxvt), you can set a environmental variable to differentiate between the type of terminal
and use the context key word in ~/.bedrc.
.br
Everything started with the context keyword until the following context keyword or
end of file is only used when the right environmental variable set.
.br
The format of context is the following.
.br
.br
context [!] variablename [variablevalue]
.br
.br
For example:
.br
.br
context term xterm
.br
.br
You can also say
.br
.br
context variablename
.br
.br
when it should apply for all cases in which the variablename has a definition.
.br
For example
.br
.br
context termcap
.br
.br
applies in all cases in which termcap is defined.
.br
If you like to apply the next configuration only when an enviromental variable
is not set or has a different value, you have to write ! before the
enviromental variable.
.br
context ! DISPLAY
.br 
means to apply the statements following this context statement and before
the next context statement only when DISPLAY is not set.
.br
If there is no environmental variable shared by the context you like to give
the same configuration you can set a environmental variable and use this at a context argument. It is possible to set enviromental variables within the configuration file with:
.br
\fBsetenv\fP name val
.br
To do the same by TERM=cons25 as with TERM=cons50 you can write:
.nf
	context TERM cons25
	setenv consoleterm yes
	context TERM cons50
	setenv consoleterm yes
	context TERM cons43
	setenv consoleterm yes
	context consoleterm
	keys  27 91 97 = beginfile #S-F3
	keys  27 91 98 = endfile #S-F4
	keys  27 91 101 = middlepage #S-F7	
.fi
In combination with '!' you can this way create every possible boolean logic
formula (using the statement that every propositional logical formula can
be written with only not and or).
With setenv you have an or and '!' adds the not.
To apply statementZ only if X and Y you use "X and Y"<=>"not (not X or not Y)"
transforming this to bedrc you get
.nf
context !X
setenv dont 1
context !Y
setenv dont 1
context !dont 1
statementZ
.fi
.SS Color
Colors can also be changed in the configuration file. There are around 17 screen
elements which you can give a foreground and background color and a list of
attributes (standout, underline, etc).
.br
The format is:
.br

.br
color screen-element [foreground background] [attr,attr...]
.br

.br
You can give only attributes or both the foreground and the background color and
any number of attributes.
.br

.br
The screen parts are the following:
.br
TEXT: The color the text is showed in. It is better not to give this a color because this
makes the screen updating much slower (some feature of ncurses)
.br
COMMAND: the commandline
.br
SELECTION: selection
.br
CURSOR: cursor in active datatype
.br
CURSORPAS: cursor in passive datatype
.br
SELCURSOR: cursor during selection
.br
BAR: the menubar
.br
BARKEY: Key highlighting in the menubar
.br
MENU: Opened menu's
.br
MENUKEY: key highlighting in menu
.br
MENUSEL: color of menu element which is selected
.br
OPENTITLE: title of file manager
.br
OPENKEY: key highlighting of key manager
.br
OPENNORMAL: background key manager
.br
OPENLIST: color of non active items of list
.br
OPENLISTSEL: color of active item
.br
OPENLISTACT: color of active item when this piece is used
.br
SHOWBACK: Search/replace window
.br 
SPACEAFTER: color of space before and between datatypes
.br

.br
The colors and attributes are just the colors and attributes of ncurses. When they
don't look the way the name suggests you should send your complains to the makers
of ncurses.
.br

.br
Colors: BLACK RED GREEN YELLOW BLUE MAGENTA CYAN WHITE
.br
Attributes: NORMAL STANDOUT UNDERLINE REVERSE BLINK DIM BOLD
PROTECT INVIS ALTCHARSET CHARTEXT

.br
For me only STANDOUT UNDERLINE REVERSE BLINK BOLD have a useful
meaning.
.br
On example:

.br
color BAR WHITE RED blink
.br

.br
Which makes a blinking white on red menu bar (on my computer it blinks only
under linux console and not in xterm or rxvt).
.br

.br
To make the cursor bold and underlined you can do
.br

.br
color cursor bold underline
.br

.br
The color lines can be intermixed with the keys lines and can also be specific to a
context.
.br

.br
.SS Procedures
When you want to make you own key bindings you need to know the names of
the procedures you can bind to keys. A selected subset of the procedures can also be assigned by using the name of the key they are normally bound to. There are the following key labels: 
.I home
, end, f1, up, down, left, right, pgup, pgdn, stab, delete, backspace and esc. When you assign a key sequence to a key label the meaning in the filemanager, search window  and menu is also changed.
so 
.br
	keys 1 = home
.br
gives Contr-A the home functionality in all this application parts.

For the filemanager and search window this is the only way the change keybindings. Inside the menu you can also change keybindings by putting 
.I 253
in front of the key numbers. See  procedure firstmenuitem.
.br
What follows are all procedures mentioned in the menu with a description and their
place in the menu. It is exactly the same information as you get when you press F1
within the menu.
.br
#addfile
Filemanager:
Name:
Alt-n: switch to line were you can write a filename.
Del,Backspace,C-h,C-u,left,right,home,end,C-a and C-e should work 
if bed is well configured (see man bed for key definitions)
Files:
Alt-f: switch to list of files. You can open one file by pressing 
Enter. Use up and down to move between files.
Directories:
Alt-d: switch to list of directories. Change to directory by 
pressing Enter.

Tab,Alt-Tab and/or Shift-Tab can be used to jump between File,Directories and
Name.
#dosave
Save current file. 
#saveas
Save currently active file to a file with another name. 
#rewrite
Rewrites screen. 
#selectprocedure
Listing of available procedures to bind to keys or use in plugins. 
You can press return on the name to run the procedure. 
Press F1 to get help about the procedure.
#selectdynprocedure
Listing of available dynamic procedures (procedures defined in plugins) to 
bind to keys, place in menu or use in plugins. You can press return on 
the name to let it work. Press F1 to get help about a procedure.
#closethis
Close the current file. 
#quit
Quit application. For all changed files you are asked to save it. 
#undo
Undo last change. 
#redo
After you have undone something with undo, you can redo it with redo.
#setselect
Turns selection on or of. 
#copyselect
Copies selected part of the file to copy buffer. 
#pastselect
Past selection. 
#saveselect
Save selection or copy buffer. 
#replace
Regular expression: 
Use the GNU regular expression library to match a pattern 
against the text (See man regex(7)). 
In normal search the search string is first converted to bytes
and then matched with the raw file content. With regex search the
file content is first converted to the datatype before regex search.
Sometimes different bytes have the same appearance in a datatype.
In that case you should always search with regex checked,
examples: Float, char2 and when filters like duplicate or skip 
are applied.
Case sensitive: 
When checked upper and lower case are treated distinctively.
Boundaries: 
Multibyte datatypes can be aligned differently. For example a 4
byte digit can start at offset 0,1,2 or 3 and that will give
different 4 byte digits. Without checking Boundaries all will
be returned. With Boundaries checked only bytes aligned in the
same way as is now shown on the screen are returned.
Forward: 
When checked the file is searched in the forward
direction going from lower to higher offsets. When not checked 
the file is searched backward.
Edge file: 
When checked the file is searched from the edge of
the file. From offset 0 when searching forward, from end of
file when searching backward.
Find: Here you type the search pattern
Replace:
At the place where the search string is found the 
replacestring is placed. The replace string overwrites the data. 
When Regular expression is checked you can insert the whole search 
string by & or supexpressions by \e1 \e2 to \e9. In the searchstring
subexpressions are demarcated by \e(pattern\e).
List: 
Generates a list of all hits. When compiled with
CONFIG_THREADS=y you can go on editing while hits are marked
so you can view them in marklist (prockey showmarks).
Ascii, Digit etc are when checked the current active datatype.
Base:
Base of digit. E.g 16 for heximal. 
Nr bytes: 
Gives the number of bytes each data item occupies. By
some datatypes you can change this for example by unsigned integers. 
Reverse:
Reverse bytes while transforming from datatype to bytes.
Set: 
After changing datatype info (base,bytes,type) you press Return
on Set to make this the search datatype.
Convert: 
the same as Set in addition the current search string is converted.
Ok: search
Cancel: Cancel
#extend
Make the file larger, adding zeros to the end of file. 
#truncate
Truncates file on the right of cursor. 
#repeat
Repeats command a certain number of times. 
#search
You can move through the dialog by pressing Alt in combination with a 
highlighted character, or by pressing Tab,Shift-Tab or Alt-Tab.
Press Shift to check options.
Standard you search within the currently active datatype, but
you can also use Ascii or Digit (unsigned integers) by selecting them,
specifying base and bytes and pressing Set.
Regular expression: 
Use the GNU regular expression library to match a pattern 
against the text (See man regex(7)). 
In normal search the search string is first converted to bytes
and then matched with the raw file content. With regex search the
file content is first converted to the datatype before regex search.
Sometimes different bytes have the same appearance in a datatype.
In that case you should always search with regex checked,
examples: Float, char2 and when filters like duplicate or skip are
applied.
Case sensitive: 
When checked upper and lower case are treated distinctively.
Boundaries: 
Multibyte datatypes can be aligned differently. For example a 4
byte digit can start at offset 0,1,2 or 3 and that will give
different 4 byte digits. Without checking Boundaries all will
be returned. With Boundaries checked only bytes aligned in the
same way as is now shown on the screen are returned.
Forward: 
When checked the file is searched in the forward
direction going from lower to higher offsets. When not checked 
the file is searched backward.
Edge file: 
When checked the file is searched from the edge of
the file. From offset 0 when searching forward, from end of
file when searching backward. If not checked searching starts
at the current position.
Find: Here you type the search pattern
List: 
Generates a list of all hits. When compiled with
CONFIG_THREADS=y you can go on editing while hits are marked.
You can view the hits in marklist (prockey showmarks).
Ascii, Digit etc are when checked the current active datatype.
Base:
Base of digit. E.g 16 for heximal. 
Nr bytes: 
Gives the number of bytes each data item occupies. By
some datatypes you can change this for example by unsigned integers. 
Reverse:
Reverse bytes while transforming from datatype to bytes.
Set: 
After changing datatype info (base,bytes,type) you press Return
on Set to make this the search datatype.
Convert: 
the same as Set in addition the current search string is converted.
Ok: search
Cancel: Cancel
#nextsearch
Search again for the same search string. 
#gettopos
Ask for a file offset and jumps to this offset. 
Forward: 
count up
Edge File: 
If checked: count from begin (forward) or end (backward) file. 
If not checked you count from the cursor position.
Boundaries: 
If checked: In multibyte units the screen is aligned at the current 
alignment (boundary) after changing position.
Position:
Offset to jump to.
You can specify in what format to specify the offset. 
All: specify offset with 0x for hex and 0 for oct. Numbers not starting with 0
are decimal numbers.
Hex,Dec,Oct: type of number without need to use 0x or 0 

#keymark
Set mark 
#tomark
Goto mark. You are asked to type the corresponding key. 
#nextmark
Goto next mark 
#prevmark
Goto previous mark. 
#showmarks
Shows list of all marks. Press Return to jump to the file offset of the 
selected mark.
#deletemark
Delete mark. You get an overview of current marks. Press return to delete
the currently selected mark.
#clearmarks
Delete all marks.
#savemarks
Save marks to file.
#readmarks
Read saved marks.
#postotop
Moves file display so that the file offset at the cursor position 
is shifted to the upper left corner of the file display.
#beginfile
Goto the beginning of file. 
#endfile
Goto end of file.
#beginpage
To the top of page.
#endpage
Goto end of page 
#middlepage
Goto the middle of the page. 
#nextmode
Goto the data type on the right of this data type. 
#prevmode
Goto the data type shown on the left of current active data screen.
#removemode
Closes data type screen part. 
#zoommode
Zooms current data type (For example ASCII). 
#addprev
Adds previous file to the screen 
#addnext
Adds the next file to the screen. 
#prevfile
Goto previous file. Zooming the file. 
#nextfile
Goto next file. 
#firstfile
Goto the first opened buffer. 
#lastfile
Goto last opened file. 
#zoomwindow
Zooms current window 
#hidewindow
Get opened file from the screen without closing it 
#listfiles
List opened files. Press Enter to edit selected file.
#askbase
Changes the file offset number type. Offsets can be shown as decimal,
hexadecimal or octal numbers. You can also turn of the display of
offsets.
#switchmessage
Hides or shows message line.
#switchmenu
Hides or shows menu bar.
#switchcommand
Switches command mode on or off. In command mode procedures are bound
to normal characters as in pagers like 'less' and 'more' and in vi's 
command mode.
Some of less's and vi's keys are already bound in the configuration file.
If you like some more you should add them to the configuration file.
You can mail them to me if you like to help others.
#backchar
Left

Go back one character.
#beginline
Go to begin line (Home).
#endline
Goto end line (End).
#fileinfo
Show the name and size of file in the message line. (No key binding).
#firstmenuitem
Goto the first menu element. (Home).

Only applies within an opened menu. You have to put 253 immediately after
the keys keyword. So for example:

keys 253 1 = firstmenuitem

makes that within an opened menu contr-a jumps to the first menu item.
#lastmenuitem
Goto last menu element. See firstmenuitem for more information. (End).
#fromcommand
Turns command mode off.
#linedown
Down one line (Down).
#lineup
Up one line (Up).
#nextchar
Next character. (Right).
#nextmenu
Goto next opened menu. (Right). Only applies in the context of the menu.
See firstmenuitem for more information,
#nextmenuitem
Goto next menu item. (Down). See firstmenuitem for more information.
#nop
Does nothing.
#pagedown
Page down. (Pgdn).
#pageup
Page up. (Pgup).
#prevmenu
Goto previous menu. (Left). See firstmenuitem for more information.
#prevmenuitem
Goto previous menuitem (Up). See firstmenuitem for more information.
#tocommand
Turns command mode on.
#tosubscreen
Goto the data screen corresponding to the number you type after this command. 
0 is the first from the left, 1 the second etc. (No key binding).
#emptyfile
Opens new document of size 1. 
You can enlarge the document with prockey extend.
#filedata
Displays information about current file.
#checkchanged
Checks if current file is modified by comparing changed parts with the
original file. 
#suspend
Go to shell. Starts a new shell or uses suspend.

If a new shell is evoked, it uses the SHELL environmental variable 
to decide which shell to use. You can also set environmental
variables in beds configuration file (see manual).
#input
Modifies current data item. 
With this procedure you edit the current item and only after 
pressing Enter the modifications are inserted.
Certain datatypes you can't edit without this procedure (e.g.
Float and Time_t).
If you don't use this procedure, then the data item is converted to
and from binary format after every key you press.
#editdata
Evokes text editor to edit selected data in active datatype.

If the environmental variable EDITOR is set to the full path 
of an editor that editor is used.
You can set environmental variables in beds configuration file 
with the following command:

setenv name [val]

Leaving out val means unsetenv.

See bed's manual page or bed -h for more information.
#select
Turn on or off selection. Selections can be copied and pasted, saved,
edited etc.
#saveshown
Save selection in the active datatype as shown on the screen.
So the selected data is first converted to the active datatype and
then saved to a file.
#readshown
Insert file content within active datatype. The content of the
file is interpreted as consisting of data in the active datatype.
#gotolastsearchpos
Jumps to file offset not yet searched. Useful if you interrupted
searching or are searching on the background and want to know
where search was left.
#nextitem
Moves one item forwards. Item is the active datatype unit.
#backitem
Moves one item backwards. Item is the active datatype unit.
#prevpos
Go to previous file offset.
#nextpos
Go again to file offset before undo move.
#scrollup
Scrolls file up. The second line is scrolled up to the first line position.
#edscholldown
Scrolls file down. The first line is scrolled down to the second line position.
#scrollitem
Shift left one item. The second item is shifted leftwards to the first item position.
#scrollbackitem
Shift right one item. The first item is shifted rightwards to the second item position.
#scrollbyte
Shift left one byte. The second byte is shifted leftwards to the second byte position.
#scrollbackbyte
Shift right one byte. The first byte is shifted rightwards to the first byte position.
#makemode
Create unsigned integer datatype. You can select bases from 2 to 36. 
The number of bytes per unit range from 1 to some unknown limit 
depending on hardware speed.
You can start a separate datatype or add a field to an existing
datatype.
In the last case where in the existing datatype the new field is 
placed depends on the cursor position:
- At the end of the existing datatype if the cursor is at the end of
the screen
- At the beginning of the existing datatype if the cursor is at the
beginning of the screen
- Otherwise at the place closest to the cursor.
- After the cursor position if the distances are equal
#naarASCII
Create ascii datatype.
No print: 
character to show if byte is not printable. 
You can also decide which byte values are interpreted as printable
characters. Strict is ascii only, +161-255 adds byte value 161-255 
etc. 
It is possible to make units of more then one character.
The meaning of separete/add field is explained under Integer help.
#emptycontain
Skip empty parts within a composed datatype.
Useful if a file contains records with parts you are not interested in.
#copymode
Create a datatype that is identical to the active (sub) datatype.
#addSigned
Create signed integer datatype. See Integer help for more information.
#addFloat
Create float datatype:
4 bytes: float
8 bytes: double
12 bytes: long double

It is not possible to use normal search in the float datatype,
you need to use regex search. Normal search translates
the search string from the datatype format back to raw bytes and
searches for these raw bytes. This is not possible because float as
displayed has not a perfect precision so that that the float
that is displayed can correspondent to more then one raw byte array.
#addBitFlags
Create bitflags. Give every bit a label which is shown if that bit
has value 1. 
Not char:
If that bit is zero, the value of Not char is shown.
Add:
Bit-label correspondences are assigned by typing a bit number after 
Bit and the corresponding label after Label and pressing return on 
Add. Bits are numbered from 0 to (8*bytenr-1). With the lowest bit 
having number 0.
This creates a list of bit-label correspondences under Flags.
Flags:
You can edit one such correspondence by pressing Alt-f followed by
selecting the correspondence and pressing return. You change the
Bit and label values and again press Return at Add.
Del:
If you press on delete the selected correspondence is deleted.
Between:
What to write between bytes. Default: nothing.
Order:
When editing a file in bitflags every item is shown as some flags.
If you want to set a certain flag you write the label. If order is
set this is only possible if you are above the position of this
label. If order is not set you can set the label at every position.
Example:
If the flags are zyx and order is set you can change --- in --x only
by pressing x at position 0, without order you can press x
also at position 1 or 2.
#bitfielder
This is a record/struct in which you specify the number of bits
for every field. After making a bitfield around a datatype it works like
a normal composed datatype. You just add the other fields. 
You change the number of bits of a certain field by setting the cursor 
on that field and selecting again prockey bitfielder but now you press 'Change Bits'.
Another way is to make the bitfield the active datatype by pressing prockey uplevel
(Parent) and then selecting Config (prockey datatypeconfig).
#translate
Translate assigns labels to values of another datatype. You can use it when numbers
have a certain meaning.
After selecting 'New' or 'Change':
Type:
The To datatype is what is shown on the screen (usually Ascii).
For certain values of the 'From' datatype you specify what should be 
shown in the To datatype.
Add:
After specifiying the To and From datatypes, you specify the From 
and To values and press Add. 
Default:
If there is no assignment Default is shown.
Assignments:
After pressing Alt-g you can select a certain existing assignment.
Pressing Return makes it editable, pressing Del deletes it.

After selecting 'Use;
Select label and press return to insert this value.
#listtypes
List of all datatypes. Use movement keys to select one of them and press 
Return to create it.
#reorderunit
One of the filters that is transforms the data when read from the file and
before interpreted by the datatype.
Reorders bytes within item. Unit gives the number of bytes to keep together.
If the bytes are 'abcdef', reorder with unit=1 gives 'fedcba', with unit=2 
gives 'efcdab', with unit=3 gives 'defabc'.
#duplicate
Useful if you like to use the same data more than once in a composed
datatype. It acts like an union in c. 
Filter that duplicates bytes before being interpret by the active (sub-)
datatype. You have to specify how many times it is duplicated (dubnr).
The active (sub) datatype consists of a certain number of bytes (size).
usenr=(size/dubnr) gives the number of bytes used for every item.
dubnr times the same usenr bytes are appended and given to the datatype.
Example:
You use ascii/4 (ascii consisting of 4 bytes). You say duplicate 2 
and the file consists of abcdefghijkl.
Before applying the filter this was displayed as abcd efgh ijkl.
After applying the duplicate filter it becomes abab cdcd efef ghghe ijij klkl.
#addskip
Filter to skips a certain number of bytes.
You have to specify after how many bytes and how many bytes are to be
skipped. This is then repeatedly applied to every unit of the active (sub-)
datatype.
Example:
The active datatype is ascii/4. The file contains 'abcdefghijkl'. 
abcd efgh ijkl is displayed. 
Applying Skip with After=2 and Skip=1 gives: abde ghjk.
After ab c is skipped after de f is skipped and after jk l is skipped.
It is not possible to use normal search in a datatype were Skip is
applied. You need to use regex search. Normal search translates
the search string from the datatype format back to raw bytes and
searches for that string. This is not possible when Skip is applied
because one search string can correspondent to more then one
raw content bytes string.
#rmlastfilter
Removes last filter (Reorder, Duplicate, Skip or some other filter
defined in a plugin).
#repeatcontain
Repeats active (sub-)datatype a certain number of times. It behaves the same
as a composed datatype with multiple version of the current active (sub-)
datatype.
#datatypeconfig
Modify parameters of active (sub-) datatype. Things like number of bytes
and the base of Integers.
#dataconfig
Modify some general display parameters of datatype. 
Label: 
Name for datatype shown on the message line
Apart: 
number of spaces between items of this datatype
Spaceafter: 
number of spaces between this datatype and an other datatype 
or the offset numbers.
Conf:
Configuration string every datatype has. Usually you don't need
to change this.
#savedatatype
Save datatype to file so you don't have to recreate complex datatype 
everytime you need them.
#readcontain
Read saved datatype. So that the current file is displayed in that format.
#record
Start recording. Keystrokes are recorded until you press C-t. You
can save recorded keystrokes to replay them at some other moment.

Take notice of the fact that RAW keystrokes are saved. This means that
the recorded keystrokes are very unportable. They are not portable between
operating systems but also not portable between terminals and configurations.
What's is recorded within xterm does not nessesarily work with rxvt or
with linux console. You can use more portable keystrokes by using
only Alt-char and Control-char keys. The movement and function keys are
very unportable and also combinations of Alt or Control that make use of
non alphabetic characters.
#saverecord
Save recorded keystrokes to file.
#playkeysfile
Play saved keystrokes (recorded with Record). 
The program runs like the keystrokes are pressed by the user, except when 
other programs are evoked from bed.
#playrecord
If you have recorded keystrokes after program startup you can play them
off with this procedure.
#opendynlib
Load plugin in program. The plugin can contain datatypes or procedures.
Procedures you can view under Dynamic (prockey selectdynprocedure), datatypes under prockey listtypes.
#showprocedure
Shows procedure in menu or binded to key sequence. 
You are asked to press the keys you want to know the procedure off.
Within menus you can only use a key and not movement keys to go to the
procedure you are interested in.

Beside the procedure it is shown what you need to write in the
configuration file to declare this key/menu-procedure binding.

Examples 
After prockey showprocedure, you press F12 and get
keys 27 91 50 52 126 = makeselection

The procedure is makeselection which is bounded to escape 
sequence: 27 91 50 52 126
If you like to bind makeselection to an other key sequence you
press after prockey showprocedure, the keys you want to bind it to, 
for example C-a and replace '27 91 50 52 126' with what you found there
for example 1. So add keys 1 = makeselection to the end of ~/.bedrc

After prockey showprocedure you press prockey quit and get

menuitem 0 "E~xit" "M-x" 12 = quit

Procedure quit is bounded to a menuitem. The menu item is in menu 0
(the first menu) has label 'E~xit' and had keylabel 'M-x' and is the
twelves menuitem in the menu (starting with 0 and counting empty places).

If you like to change to name from 'E~xit' to '~Quit' you can add
menuitem 0 "~Quit" "M-x" 12 = quit 
to the end of ~/.bedrc

See the bed manual page for more details about assigning procedures
to menu items and keys.
#newcontain
With this function you can create a composed datatype within another
composed datatype. First make a element of a composed datatype
the active datatype and then use this function (prockey newcontain).
To make a sub composed datatype around the active datatype.
After this you can add more datatypes, to this sub composed datatype, 
by using the "Add field" option while starting a new datatype or 
by using prockey stretchcontain. New datatype created with add field
are always added to the lowest composed datatype in which the active
datatype is contained. The message line shows what datatype is active.
Use prockey uplevel and prockey downlevel to change to the datatype
this datatype is contained in and back again. You can also make the
composed datatype the active datatype by placing the cursor between
two of it's member (child) datatypes.
Subcomposed datatypes can be useful if you want to use a filter for only
a subset of the members of a composed datatype.
For example a file consists of records of three ascii strings and you
like to exchange the position of the first two strings.
After creating three ascii strings of 10 in one record (composed datatype),
you set the cursor on the first field and press prockey newcontain. This
makes a subcomposed datatype around this field. To add the second field
to this composed datatype you set the cursor at the second field and
press prockey stretchcontain. Now you set the cursor between the first two 
fields (or you press prockey uplevel) and you reorder with unit 10 using 
prockey reorderunit.
#stretchcontain
Used to handle nested composed datatypes (made with prockey newcontain).
If you have made a composed (struct/record) datatype for 
example: {{a,b,c},d,g}
Here the letters are datatypes and {..} is one composed datatype.
{a,b,c} is a nested (or sub) composed datatype.
If you put the cursor on d and apply this function, you can add d to
this sub composed datatype. So you get then {{a,b,c,d},g}.
#levelout
Applies if active datatype is a composed/record datatype.
With this function the composed datatype is removed so that the item(s)
endup at a higher level.
It can be used in two cases:
1. a nested composed;
2. a composed containing only one datatype.
#uplevel
Parent datatype. Make active datatype the datatype in which the current
datatype is contained. 
#downlevel
If applied to a composed datatype, this makes the current active datatype
the member of the composed datatype the cursor is on.
#goto1
Goto the first open file.
#toclipboard
Puts selection in active datatype in MS Windows clipboard.
#pastclipboard
Insert MS Windows clipboard in active datatype.
#selectdisk
Edit raw data of floppies and hard disks.
This way you can handle the whole disk like a large file.

If you save something to a hard disk you should keep in mind that
bed saves by blocks (probably 4096 bytes). This can lead to problems
when some other process changes the hard disk close to the change you
made. In this case by saving what you changed, you will also 
save some old data at the place the other program had changed something.
So make absolutely certain that no other process could possibly have 
changed something around the place you change during the editing.

Under Linux, FreeBSD and Windows NT bed makes use of some standard
interface for raw disk access. Under windows 95 you need to use 
some undocumented thunk to a win16 dll to use the DOS Protected Mode 
Interface to execute a BIOS interrupt. So if you use Windows 95 backup
all your hard disks before opening a disk.

Under win95 you shouldn't give too much trust to the specified 
disk size. What the bios says is not exactly right and sometimes 
totally wrong (when using a large harddrive with an old bios).
Returned floppy sizes are mostly right so bed takes over the bios value
if -w is not specified at startup.
To determine the real harddisk size bed uses some ad hoc heuristic
while trying how far it can can read. The problem is that at very
large offsets the bios disk read interrupt returns SUCCESS again, 
so you have to try larger, but not too large offsets. 
At my computer reading a HD floppy at offset 2948608 fails, but reading 
at offset 5120000 succeeds. A DD floppy fails at 1474048 but succeeds at 
2948608. If the size seems to be wrong try to determine it and specify it
with the -d option at startup. Bed saves the disksize so you have
to specify it only once (within regedit at HKEY_LOCAL_MACHINE
SOFTWARE\eBed\ehardisks).
#filetype
Uses the unix program file to guess the filetype of the data starting at
the current cursor position. It can be used when the cursor is on the
first byte of a file or when searching for files inside a harddrive device.
plugin file.cpp
#filter
Gives the content of the selection as input to a user specified command
(e.g. grep '^X'|sort|uniq) and places the output of that command in the
copy buffer.
plugin filter.cpp
#disassembler
File content at cursor position is translated to assembler code.
Makes use of gdb. Use nextdisassem to jump to the next machine code.
Use gotosymol (elftables.plug) to jump to procedure using its
procedure name
plugin disass.cc
#nextdisassem
Jumps to next machine code instruction and disassemble it:
Cursor position is moved the length of the current machine code
statement further and disassembler is called.
plugin disass.cc
#backward
Adds the backward filter.
This filter tries to reverse the direction of the last applied filter.
plugin backward.cc
#compare
Compares last made selection with current file at current cursor
position for the length of that selection.
If some variant of klipper isn't running, there is no limit on selection
size (As long as they say to be of class klipper they form no problem,
because I don't give the content of the whole selection to programs of
class klipper).
plugin searchclip.cc
#searchclip
Searches in current file for the content the bed's copy buffer.
It takes over the search settings (direction, case sensitivity, regex or not,
on boundaries or not, from current position or from edge of file) of Alt-m,s.
Currently it repeatedly searches for the first block of the copy buffer
and then compares it with the whole copy buffer.
plugin searchclip.cc
#tryinstall1
Installs Float with installpart/1 and getFLoat
plugin install.cc
#tryinstall2
Installs Digit with installpart(part,0) and getDigit
plugin install.cc
#cutselect
Standard cut: selection is put in copy buffer, file after selection
is moved to begin selection and rest file is truncated
plugin cut.cc
#insertpast
Standard past: file is extended and content after current file
position moved so that copy buffer content can be inserted
plugin cut.cc
#index2table
index2table

index2table interprets the file content as long's (4 bytes)
which are indexes in a table at some offset in the current file.
Instead of the index number it displays the content of that table
at that position. index2table is a filter that should be applied
to a datatype appropriate for the data in the table. For this
purpose this procedure asks to specify at what offset in the file
the labels start, with what index the table starts and table length.
Index2table is for example
used to show the names of procedures in a symbol table.
index2table is then applied to multibyte ascii that shows
this label instead of the index.
dynsym and symtab are sub classes of index2table.
They are used by misc/dynsym.bedda and misc/symtab.bedda.
Because of this use index2table was previously called symtable.
plugin index2table.cc
#section
Used by composed datatype file sectionheader.bedda to show
labels of names in section header
plugin elftables.cc
#dynsym
Used by composed datatype file dynsym.bedda to show the procedure
names in dynsym (dynamische) symbol table.
plugin elftables.cc
#symtab
Used by composed datatype file symtab.bedda to show the procedure
names in symtab (statische) symbol table.
plugin elftables.cc
#gotosymbol
Procedure searches in symbol tables symtab and dynsym for a given
symbol. It sets the cursor to its fileoffset and starts a better fitting
datatype. It shows the offset and its size in the message line.
plugin elftables.cc
#rxvtmenu
Add rxvt menu.
You can remove the scrollbar, reverse video and if you don't have
a buggy rxvt you can change fonts.
plugin rxvt.cc
#switchsize
Switches xterm size to a large size if small or to a small size if large
plugin switchsize.cc
#pastclipboard
Past clipboard. This is data copied by bed or a Xwindows program.
plugin putselect.cc
#makeselection
Turn on or off selection. Selections can be copied and pasted, saved,
edited etc. Within a xterm the selection is usually shared with other
X window Programs.
plugin putselect.cc
#pastselection
Past Xwindows selection.
plugin putselect.cc
#copyclipboard
Copies selection.
plugin putselect.cc
#pastspecial
Only available if a bed owns the clipboard.
Shown:
With this function you can past data formatted as shown on
the screen. So you can for example insert in ascii the data as
shown in heximals
Datatype:
Past datatype of copied data.
plugin putselect.cc
#exportselection
Make selection the xwindows selection.
plugin putselect.cc
.SH PLUGINS
.SS Introduction
Bed has the possibility to call c functions from within bed and to access some of the
data of bed.
.br
Here is an example:
.nf
/*Begin example1.cpp */
#ifdef GLOBAL
#endif
#ifdef EDITOR
int  example1(void) {
	message("Hello world!!!");
	}
#endif
call(example1)
/* End example1 */
.fi
Everything in the area in which GLOBAL is defined is code outside of the EDITOR
class. Everything inside the area in which EDITOR is defined is inside the Editor
class and at the end of the files are the names of the procedures which should be
bounded to a key in bed.
.br
In this example the procedure example1 uses an function of bed which writes a
message to the messageline and call(example1) says that the function example1
should be accessible by bed.
.br
This function example1 you can bound to a key the same way as bed's own procedures . For example
.br
keys 1 = example1
.br
to bind contr-A to example1.
.br
To compile the example you need just to do 
.br
	make example1.plug 
.br
in the plugings/examples directory. Which assumes that there is the original Makefile
and the make variable PLUGINDIR is assigned to the directory in which plugin.cpp,
faked.h and mainprocedures.h reside.
.br
Ones compiled you have to put the line
.br
plugin ABSOLUTEFILENAME
.br
in ~/.bedrc before you bind a key to the corresponding functions.
.br
So in for this example you can add
.br
plugin CONFDIRLINK/plugins/example1.plug
.br
keys 1 = example1
.br
in ~/.bedrc to enjoy the pleasure of getting "Hello world!!" when you press Contr-A.
.br
In the procedures you write you can use all the procedures which can bounded to
keys (which have the format int name(void)), plus some extra procedures I am going to describe now.
.br
.SS Editor
The following functions are inside class Editor:
.PP
\fBint topos(OFFTYPE pos)
.br
\fP
.br
Go to offset pos in the current file. pos is rounded down to
boundaries of active datatype.
.PP
\fBint toborderpos(OFFTYPE pos)
.br
\fP
.br
Go to offset pos in the current file.
.PP
\fBOFFTYPE dosearch(char *str, int len)
.br
\fP
.br
Search for str with length len in the current document
.br

.br
\fBOFFTYPE getfilepos()
.br
\fP
.br
Get the offset of the first byte on the screen.
.br

.br
\fBint geteditpos()
.br
\fP
.br
Get the offset of the cursor in the current screen.
The offset of the cursor in the file is getfilepos()+geteditpos()
.br

.br
\fBOFFTYPE getmem(OFFTYPE pos,char *buf,OFFTYPE len)

.br
\fP
.br
Get from position pos a piece of the current file with length len.
Returns OFFTYPEINVALID
on error, otherwise len;
.br

.br
\fBOFFTYPE putmem(OFFTYPE pos,char *buf,OFFTYPE len)
.br
\fP
.br
Put at position pos the array buf of length len. Returns OFFTYPEINVALID
on error, otherwise len;
.br
.br
\fBint getselbuf(char **buf) 
\fP
.br
Put a pointer to the cutbuffer in *buf and returns the length of the cutbuffer. Returns negative on error;
.br
.PP
\fBint putselbuf(char *buf,int len)
.br
\fP
Puts buf with length len in the cutbuffer. 
.PP
\fBOFFTYPE getselect(void) 
.br
\fP
\fBOFFTYPE setselect(OFFTYPE pos)
.br
\fP
.br
getselect returns the starting position of the current selection or OFFTYPEINVALID if there is no
selection. Putselect put's the starting position of the selection or with OFFTYPEINVALID unselects.
.br
(The end position is the cursor position).
.PP
\fBOFFTYPE Editor::getselregion(OFFTYPE *start)\fP 
.br
Returns length of selection and puts start position in start. 
start has to point to an OFFTYPE.
.PP
\fBint screensize()
.br
\fP
.br
Get the number of bytes currently on the screen.
.br

.br
\fBchar *getfilename(char *buf)
.br
\fP
.br
The current filename is copied to buf.
.br

.br
\fBint message(char *format ...) 
.br
\fP
.br
Write to messageline. Same format as printf.
.br

.br
\fBint getkeyinput(char *format ...)
.br
\fP
.br
Ask in the same format as printf. And get an key as answer.
.br

.br
\fBint inputget(char *answer,const char *format,...)
.br
\fP
.br
Ask in the same format as printf and get an answer in answer (should hold enough
memory).
.br

.br
\fBOFFTYPE filesize(void) 
.br
\fP
.br
Get filesize.
.br

.br
\fBint toscreen(void) 
.br
\fP
.br
Makes that the effect of previous operations is shown on the screen.
.br
.br
\fBvoid filesup(void) 
.br
\fP
When a newwin (of ncurses) is used you can with filesup get the file windows of bed
again on top.
.SS Global
\fBextern Editor *editfile(const char *file)
.br
\fP
.br
Open a new file. When you want to do operations on this file you should hold in
mind that the previous functions are part of the class Editor. So when you can do
for example:
.nf
/*start stupid.cpp
#compile with make stupid.plug
#put in ~/.bedrc
plugin CONFDIRLINK/plugins/stupid.plug
keys 1 stupid
# and call contr-A in bed
*/
#ifdef EDITOR
int another(void) {
	topos(400);
	toscreen();
	getkeyinput("I am going to delete everyting O.K. ");
	putmem(0,"Hello",5);
	}

int stupid(void) {
	Editor *ed=editfile("/boot/zimage");
	return ed->another();
	}
#endif
call(stupid)
/*end stupid.c */
.fi
.PP
\fBcall(proc)
.br
\fP
Determines that proc can by used to bind keys to, add to menu and is seen
in prockey selectdynprocedure (Dynamic).
proc is a procedure of the form int Editor::proc(void). A call(proc) should not ended with ';'.
.PP
\fB call_on_start(proc)
\fP
\fB call_on_open(proc)
\fP
\fB call_on_switch(proc)
\fP
call proc once after program start, everytime a file is opened or everytime the program switches to a file.
.PP
\fBsethelp(proc,text)
.br
\fP
Adds helptext text to procedure. Shown on pressing F1 in Dynamic procedure listing (prockey selectdynprocedure) and in menu if procedure is added to menu with menuitem statement.
.PP
\fBextern Editor *newfile(void);
.br
\fP
Opens empty file.
.PP
\fBextern editor *getactive(void)
.br
\fP
Get the currently active Editor.

.br
\fBextern void rewriteall(void) 
.br
\fP
Rewrites everything on the screen.
.br

.br
Some examples of plugins are put in plugins/examples: one shows the assembler labels of the bytes starting with the cursor
(gdb.plug), one shows the file type (when the cursor is on the first byte of a file)
(file.plug) and and one filters what's selected through an other program (filter.plug).
.br
A new syntax uses class Editor {} instead of the defines. If you use the old syntax the file name should end at .cpp, when using the new syntax at .cc.
In the new syntax you should put the following statements above any code:
.nf
#include "global.h" 
BEDPLUGIN
.fi
Instead of #ifdef EDITOR ... #endif you write
.nf
class Editor {
public:
#include "faked.h"
int proc(void) {
	}
};
call(proc)
.fi
and put you procedures under #include "faked.h"
the call statements you place under the '}'.

\fBWARNING!!\fP
.br
You should NEVER define any variables within class Editor (or between #ifdef EDITOR and its #endif. You should also never try access variables of the main program (relating to class Editor) directly. With this version of gcc it is possible to distribute the procedures of a class over different files, but not it's data.
.br
.SS Datatypes
.PP
\fBint Editor::installpart(ScreenPart *part,int field);\fP
.PP
Installs datatype part, which means that this datatype is used to display the curent file.
If field is zero this becomes a separate datatype, otherwise it is added to the active datatype. It uses the default settings and doesn't ask the user any questions.
.PP
\fBint Editor::installpart(ScreenPart *part);\fP
.PP
Installs datatype part, which means that this datatype is used to display the curent file.
The user is presented with an configuration screen to set some options.
.PP
\fBextern ScreenPart* getAscii(Editor *ed)
.br
extern ScreenPart* getDigit(Editor *ed)
.br
extern ScreenPart* getFloat(Editor *ed)\fP
.PP
For every datatype X there is a getX(Editor *ed) function that returns an instance of this datatype. You can use it by the command installpart(part).
In plugins you can define new datatypes.
.PP
\fBScreenPart *Editor:activemode(void);\fP
.PP
Returns curently active datatype.
.PP
\fBchar *ScreenPart::getname()\fP 
.PP
Returns name of the class of this datatype. It is a string shared by 
all instances of this class. 
.PP
\fBint ScreenPart::equal(ScreenPart *part)\fP
.PP
Test if part is equal to this datatype. Equal means a different instance, 
but no differences in behaviour. Not only the class is identical, but
also its parameters like bytes, filters and base.
.PP
\fBint ScreenPart::datbytes(int b=-1)\fP 
.PP
Returns the number of bytes of one item of this datatype.
If b different from -1 the number of bytes is changed to this number.
.PP
\fBint ScreenPart::getbytes()\fP 
.PP
Returns the number of bytes one item correspondence to on the file. This
can be different then what is returned by datbytes() when filters like
Skip (prockey addskip) or Duplicate (prockey duplicate) are applied.
.PP
\fBScreenPart *ScreenPart::getchild(int &forstart,int &binstart,int pos)\fP
.PP
If the datatype (ScreenPart) upon which is procedure is applied is a composed
or Repeat it returns the child datatype under the cursor, otherwise it returns the current datatype.
.PP
\fB ScreenPart *ScreenPart::getsubpart()\fP
.PP
Repeatedly applies getchild until is finds a datatype without children.
.PP
\fBScreenPart *ScreenPart::getparent() \fP
.PP
Returns contain current Screenpart is contained in, or NULL when there is not sucn thing.
.PP
\fBScreenPart *ScreenPart::getsuperpart(void)\fP
Repeatedly applies getpartent until is finds a datatype without parent.
.PP
\fBint ScreenPart::calcsizes(void)\fP
.PP
Calculate sizes of ScreenPart. Should sometimes be called after changing 
some parameter of a datatype or adding a filter.
.PP
\fBWrite you own datatypes:\fP
.br
You define a class as a subclass of ScreenPart or one existing datatype (Digit,Ascii, Signed, Float etc). Lets start with an example:
.nf
#include <stdio.h>
#include <limits.h>
#include <ctype.h>
#include "global.h"
BEDPLUGIN
#include "screenpart.h"
class char2 : public ScreenPart {
public: 
declareparent
char2 ( Editor *ed): ScreenPart( ed, 1 ,256, 2 )  {
apart=0;
};
int form2bin(char *formal, unsigned char *bin, int &len) {
bin[0]=formal[0];
return 2;
}
ScreenPart *newone(void) {return new char2(*this);}
int bin2formal(unsigned char *bin, char *formal, int len) {
	if(isprint(bin[0]))
		formal[0]=bin[0];
	else
		formal[0]='.';
	return 0;       }
  int isel(int ch) {return isprint(ch);}
        };
datatype(char2)
parentd(ScreenPart,char2)
.fi
.PP
After 
.nf
#include "global.h"
BEDPLUGIN
.fi
.PP
which is included in every plugin,
.nf
#include "screenpart.h"
.fi
is included because we need to become a sub class of ScreenPart.
.br

class char2 the new datatype.
.RS
.PP
declareparent
.RE
.PP
Is a statement what should be included in every datatype class. In combination with parentd it is used to determine the parent child relations between classes.
.RS
.PP
char2 ( Editor *ed): ScreenPart( ed, 1 ,256, 2 )  {
.RE
.PP
every datatype class should also contain a contructer with as first argument Editor *ed and it should call the parent constructor.
ScreenPart takes as first argument ed, as second the numbers of characters every item needs to be displayed on the screen. As third argument the base of the datatype (or something arbritary if this datatype has no base) and ad fourth argument the number of bytes of the screen this datatype uses.
.RS
.PP
apart=0
.RE
.PP
States that the items are zero space apart of each other on the screen. The default is 1 space between items.
int form2bin(char *formal, unsigned char *bin, int &len) {      
form2bin comes from format to bin. It transforms formatted input to binary form (the raw form in the file).
formal contains the formatted input, bin is filled with its binary form. len is a reference to the length of formal and should be set to the length of formal that is actually used. form2bin should return the number of bytes placed in bin.
.RS
.PP
int bin2formal(unsigned char *bin, char *formal, int len) {
.PP
.RE
bin2formal transforms binary input to formatted output.
bin contains the binary input, in formal the formatted output is placed.
len contains the length of bin. It should return 0 on success and -1 on error.
.RS
.PP
 int isel(int ch)
.RE
.PP
isel determines what character input (e.g. keyboard) input this datatype can handle. Unsigned decimal integers can handle for example 0-9 (isdigit(ch)).
It should return nonzero when it can handle the input and 0 when not.
.PP
.RS
datatype(char2)
.RE
.PP
The datatype statement makes the datatype known to bed, it adds this datatype to the datatype list so that it is seen with prockey listtypes and you can use it in saved datatypes. You can use ScreenPart *getchar2(Editor *ed) to get char2.
.PP
.RS
parentd(ScreenPart,char2)
.RE
.PP
Also a obligatory statement, stating that char2 is a child of ScreenPart.
.br
.PP
Other statements functions which can be defined in datatypes (ScreenPart's):
.PP
\fBint chbytes(int byt)\fP
.br
Changes the number of bytes the datatype uses (used by prockey datatypeconfig).
If byt=-1 is should return a number greeter then 0 if the number of bytes can be changed. If bytes>0 is should change its number of bytes to this value and return the number of bytes it occupies. On error is should return -1.
.PP
\fBint chbase(int base)\fP
.br
Returns the current base (ScreenPart::type) with b==-1, returns -type if b==0.
Returns -1 if base can't be set and changes to base base otherwise returning the base.
.PP
\fBchar *getconvstr(void)\fP
.PP
A procedure that can be defined to return a string describing some extra 
options set in the current instance of this datatype. When saving datatypes 
this string will also be saved and when the datatype is recreated from the
saved datatype it will be given to the curresponding procedure setconvstring 
to set these options.
The string can be a static string if you like; it will not be freed by the main program.
.PP
\fBint setconvstr(char *str)\fP
.PP
Procedure that can be defined to set the options of a string this datatype
returned with getconvstr. It should return -1 on error, otherwise it should
return 0.
.PP
\fBuserconfig(int modify)\fP
.PP
Procedure that can be defined to create your own dialog presented to the
user to configure the datatype
If modify=1 the datatype is already shown on the screen, as when it is called by prockey datatypeconfig.
If modify=0 useconfig is called on creation of the datatype. In the last case usrconfig should call installpart(sub,separ) to add this datatype to the screen.
.PP
Most datatype classes would also contain a copy constructor \fBDatatype(Datatype &fl)\fP
.PP
For additions and modifications you can look at the example plugins or in faked.h or the Tools menu inside bed (Key binding and Procedures).
.SS Filters

\fBint ScreenPart::addfilter(Filter *fil)\fP
.PP
Adds Filter fil to the filters of current datatype. Returns -1 on failure.
Otherwise it returns the number of filters.
.PP
\fBint ScreenPart::rmlastfilt(char *name=NULL)\fP
.PP
Removes last filter. If name!=NULL it only removes this filter if name is the name of the the last filter. Name is for example Duplicate, Reorder, Skip etc.
.PP
\fPFilter *ScreenPart::getlastfilter(void)\fP
.PP
Get the last applied filter if it exist, otherwise it returns NULL.
.PP
\fBCreating filters\fP
.PP
A filter sits between the datatype and the file and transforms the data.
It is a sub class of Filter (lets call it SubFilter).
.PP
Filter contains the following variables:
.br
char *name; /*All references to this name should contain the same pointer. set by name=filtername(SubFilter) (without "") extern char *filtername(SubFilter); should be defined above the class. */

.br
int bytesfile; /*Number of bytes of each unit at the file side of this filter */
.br
int bytesscreen; /*Number of bytes of each unit at the screen side */
.br
int err; /*set this if an error occured, that makes the filter unusable*/
.br
Screen side and file side doesn't mean that this is also the number of bytes per bytes on respectively the screen or the file. Other filters before or after can change this.
.PP
It contains the procedure fromfile which transfroms the data from the file to the datatype (ScreenPart):
.PP
\fBvirtual int fromfile(unsigned char *input,int &len,unsigned char *output)\fP 
.PP
Input: contains the input, len the length of the input. If less bytes are used len is set to the acually used length. output points to a array in which the output is written. The function returns the length of the output.
.PP
\fBvirtual int tofile(unsigned char *input,int &inplen,unsigned char *output)\fP
.PP
To file is identical except that now the direction is from the datatype to the file.
.PP
Beside these, it should contain the following procedures:
.PP
\fBSubFilter(int filebytes,int screenbytes,char *conf)\fP
.PP
Constructor with as arguments the number of bytes at the file side of the filter (filebytes), the number of bytes at the screen side of the filter (screenbytes) and a config string (conf). conf is a string returned by convstr of the same filter class and is used to save settings of the filter when saving datatypes.
.PP
\fBchar *convstr(void)\fP
.PP
Procedure that returns a configuration string used to set options while recreating this filter.
.PP
\fBSubFilter(Filter &rev)\fP
.PP
A copy contructor.
.PP
\fBFilter *newone(void)\fP
.PP
Returns a new copy of this filter
.PP
\fBint chbytes(int b)\fP
.PP
Changes the number of bytesfile to b. Returns -1 on failure, otherwise returns bytesscreen (after having recalculated it's value).
.PP
\fBint chbytesback(int b)\fP
.PP
Changes the number of bytesscreen to b. Returns -1 on failure, otherwise returns bytesfile (after having recalculated it's value).
.PP
\fBint  equal(Filter *fil)\fP
.PP
Returns 1 if fil is equal to this filter, 0 otherwise. 
.PP
\fBvirtual int screen2filepos(int pos)\fP
.PP
Can be defined to return the byte position on the fileside given a position on the screenside.
.PP
.B
virtual int file2screenpos(int pos) 
..
.PP
The same as screen2filepos in the opposide direction.
.PP
Outside of the class you should register the filter with \fBregisterfilterclass\fP(SubFilter). Needed for example to use this filter while reading saved datatypes.
.PP
Currently you should write your own procedure to add a filter to a datatype.
The most simple procedure is the following: 

.nf
#include "global.h"
#include "screenpart.h"
#include "reverse.h"
BEDPLUGIN
class Editor {
public:
#include "faked.h"
int addFilter(void) {
        ScreenPart *part=activemode();
        int byt=part->datbytes();
                Reverse *sub=new Reverse(byt,byt,"1");
                if(sub->error()) {
                        message("cant add filter");
			return -1;
		}
                   addfilter(sub);
        return 0;                                               
	}
};
call(addFilter)
.fi
You should Reverse change in the name of the Filter and "1" to the config string.
.SH ENVIRONMENT
.TP
.SM
.B BEDRC
Absolute filename of configuration file.
.TP
.SM
.B EDITOR
Preferred editor 
unix: export EDITOR=vi
windows: set EDITOR=notepad
.TP
.SM
.B SHELL
Preferred shell. Use unix like / to separate dirs
.TP
.SM
.B TMPDIR (unix) or TMP or TEMP (win95) 
Directory for temporary files
.br
.TP
It is possible to set environmental variables in the configuration file:
.TP
\fBsetenv\fP name [val]
.br
Leaving leaving out val means unsetenv.
.SH FILES
.TP
.BI PERSCONFIG
Individual configuration.
.TP
.BI GLOBALCONFIG
System wide configuration.
.TP
.BI CONFDIRLINK/plugins/*
Files needed to compile plugins: plugin.cpp faked.h mainprocedures.h Makefile
.SH PORTABILITY
Binaries available for:
.br
Linux RedHat 9
.br
FreeBSD 4.4
.br
Windows95+cygwin-1.3.10-1+pdcurses-2.5-win32+gnu/regex-0.12
.PP 
If bed doesn't run or compile with your linux, FreeBSD or cygwin distribution or you have a different widely used Unix
variant with a working gcc and ncurses installation and able to run on my computer (athlon 800mhz, 192 meg ram, 40 gig Harddrive),
send me a copy of the CDROMs containing the distribution and I will try to port bed to it.

.SH AUTHOR
Jaap Korthals Altes
.br
Onnemaheerd 62
.br
9736 AP Groningen
.br
The Netherlands
.PP
SMS: +31618329514
.PP
I don't read emails, only paper mail and SMS.
.SH LOCATION
http://bedlinux.tripod.com
.br
ftp://sunsite.unc.edu/pub/Linux/apps/editors/terminal/
.SH DOWNLOAD
\fBSource:\fP
.br
http://bedlinux.tripod.com/download/PROGRAM-VERSION.src.tar.gz 
.br
ftp://sunsite.unc.edu/pub/Linux/apps/editors/terminal/PROGRAM-VERSION.src.tar.gz 
.br
\fBRedhat 7.1 binary:\fP
.br
http://bedlinux.tripod.com/download/PROGRAM-VERSION.bin.ELF.tar.gz
.br
ftp://sunsite.unc.edu/pub/Linux/apps/editors/terminal/PROGRAM-VERSION.bin.ELF.tar.gz
.br
\fBStatic linux 2.2.x binary:\fP
.br
http://bedlinux.tripod.com/download/PROGRAM-VERSION.bin.ELF-static.tar.gz
.br
\fBFreeBSD 4.4 binary:\fP
.br
http://bedlinux.tripod.com/download/PROGRAM-VERSION.FreeBSD.tar.gz
.br
\fBWindows 95 Binary\fP (using pdcurses):
.br
http://bedlinux.tripod.com/download/PROGRAM-VERSION.win32.zip
.br
Needs cygwin1.dll out of the bootstrap package of cygwin. You can also take this one http://bedlinux.tripod.com/download/cygwin1.dll.zip
.br
It is compiled with the free CYGWIN version of gcc. See http://sources.redhat.com/cygwin/
.br
To compile bed for win32 you need:
.br
-gcc,binutils,gnu make,grep, sed,textutils,findutils,fileutils,diffutils, which and probably some other utilities from cygwin http://sources.redhat.com/cygwin/
.br
-GNU regex (different from libregex.a from cygwin): e.g
.br
http://ftp.kiarchive.ru/pub/gnu/gnu-mirror/regex/
.br
-pdcurses source (http://www.lightlink.com/hessling/downloads.html)
.SH "SEE ALSO"
.BR printf (3), 
.BR scanf (3),
.BR strings (1),
.BR grep (1),
.BR dd (1)
.BR head (1),
.BR tail (1),
.BR regex (7),
.BR ncurses (3),
.BR od (1),
.BR hexdump (1),
.BR hex (1),
.BR bpe (1),
.BR beav (1),
.BR hexed (1),
.BR hexedit (1),
.BR khexdit (1),
.BR khexedit (1),
.BR ghex (1),
.BR bvi (1)
.BR terminfo (5)
.BR readelf (1)
