Bed: Overview
=============
This is the binary editor, or bed.   It can be used to look at ascii of text
files, the binary of executables and data files or the raw data off of a
hard drive.


Usage
=====
To edit a file, simply type:
	pedit <filename>
where <filename> is either a text file, a binary file, a directory or a
disk location of the form C:H:S.

If you don't give a <filename>, it'll prompt you for one.





Files
=====
I wrote this program so that someone in the future can write a drop in
replacement for curses, like, gtk.  I've been kind of successful in this
regard.  Files are divided by functionality:
	curses.c       curses interface
	functions.c    functions which are user interface independent
	main.c         main driver program
	pfunctions.c   my own personal library of cool stuff



Structure Of The Screen
=======================
There are two main boxes - dbox and hbox.  Hbox (header box) contains
various information like cursor position and filename.  Dbox (data box)
contains the actual contents of the file in a numeric and alpha format on
the right and the offset address, given on the left.


          @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
          @+----------------------------+@
          @|            hbox            |@
          @+----------------------------+@
          @ offset:   numeric   alpha    @
          @            data      data    @
          @                              @
          @ 00000:  99 89 10   F  ^T  a  @      @ = monitor boundary
          @ 00009:  60 DD A5   2   l  0  @
          @                              @
          @ dbox (doesn't include the    @      - and +: drawn boundary
          @    drawn border around hbox) @
          @                              @
          @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@


dbox lines and tp
-----------------
A page is defined as the entire contents of what you see on the screen.

The dbox lines are numbered starting with 1 (00012 in figure above) and
ending with 7 (00030 in figure above).   The tp (top pointer) cell is the
upper left hand corner cell.  The tp_addr = 00012 and tp_line is 5.



	defines
	-------
	LINES, COLS: Provided by curses.  The number of lines and columns of the
			display.  Above example would be 10, 29.
	PER_LINE: Number of addresses displayed in one line.  The example above
			would be 3, corresponding to 5010, 5011 and 5012.  Default: 10.
	ADDRFIELD_LNG: The length of the offset column.  The example above would
			be 8 (5 address, 1 colon, 2 spaces).  Default: 7
	HBOX_LINES: The number of lines of the hbox.  Above example would be 3
			(top and bottom border, 1 text line).  Default: 4.
	IBOXSZ: The length of the inputbox string.  Default: 33.



	globals
	-------
	I've always avoided global and static variables like the plague.
	However, in my attempt to keep UI separate from functionality, I've found
	it very difficult to avoid using globals, so I chickened out.  :)

	char filename[15]        Filename of file we're editing.
	off_t filesize           Filesize of file we're editing.

struct ctl:
	/* Program characteristics */
	int filesize       Filesize of file we're editing.
	int d_format       Show databox as 0=decimal or 1=hex.
	int a_format       Show offsetbox as 0=decimal or 1=hex.

	/* Cursor characteristics */
   int x, y           Cursor position.
   int cur_addr       Offset of current cursor position.
	int cur_addr_line  Line number of cur_addr: cur_addr/PER_LINE + 1

	/* Dbox characteristics */
   int tp_addr        Offset of top left corner of the dbox.
	int tp_line        Line of the top left corner of dbox.  tp_addr/PER_LINE + 1
	int last_tp_addr   Offset of last top_ptr
	int max_dlines     How many lines needed to display whole file assuming we
								put PER_LINE elements per line.
	dbox_lines: The number of lines of the dbox.  Above example would be 7.
											Default: LINES - HBOX_LINES
	char inputbox:           The contents of the inputbox.



                +-----------------------------------+
                |0                                  |
                |9        FILE                      |
                |18                                 |
                |27                                 |
                !===================================!
36 is the   --> !36               ^                 !   ^
tp_addr         !45               |y (from 0)       !   |
                !54               |                 !   |
                !63  x (from 0)   V                 !   |  dbox_lines is 8
72 is the   --> !<--------------->*                 !   |
cur_addr_line   !81                                 !   |
inconsistant    !90                                 !   |
starts with 1   !99                                 !   |
                !===================================!   V
                |108                                |
                |117                                |
126 is the   -->|126                      +---------+
last_tp_addr    +-------------------------+          

main                  main.c
	loads file into memory

user_interface        curses.c
	creates windows and turns them into panels
	main event loop
