Category : Word Processors
Archive   : MEDIT.ZIP
Filename : TECH.DOC

 
Output of file : TECH.DOC contained in archive : MEDIT.ZIP




















Technical Reference Manual

Medit

Program overview:

This program will allow the user to edit any normal DOS text file

using all available memory for text storage. The program is very small and

will take up about 35k of conventional ram, leaving usually about 520k for

editing text files. It also allows the user to shell to DOS, without

saving the current file, and run any other programs or DOS commands.


C Techniques used:

The program uses several specialized techniques to perform the

functions necessary to give the user the best environment for editing his

or her text files. Some of these techniques are:


Direct Video Displays - the program send all output directly to the

video memory of your machine resulting in

almost instantaneous screen updates.

Dynamic Memory Allocation - all memory is allocated at run time so that

when shelling to DOS the user will have as

much memory as is available for running

other DOS programs while Medit is still run-

ning and your text is still in memory.

DOS File Manipulation - ability load and save files any where on any

disk drive.

Use of the FAR Heap - all memory allocation is done in the far heap

and when the source is compiled in the compact

memory model this gives the user the use of

all available conventional RAM.


Programmers Maintenance Information

The following is a list of all nonstandard include files, defined

values, structures, global variables, and functions, and descriptions of

what they are used for. The functions are more heavily documented in the

actual source code.


Nonstandard include files:

biosarea.h - this file sets up a typedef named BIOSDATA that describes the

bios information area in ROM


Defines:

#define READWRITE 2 - file has read write capability

#define READONLY 1 - file is read only


Structures:

typedef struct line { - typedef for line structure which contains

char *dataptr; a pointer to the actual text and a

struct line *prev_line; pointer to previous line and a

struct line *next_line; pointer to next line

} LINE;

This structure is used to hold all text information that the user

enters into the editor while editing the file.


Global Variables;

start - pointer to start of list in the far heap
new - used for allocation of new nodes and locating specific nodes
tptr - pointer to node currently displayed at top of screen
prev - use in load process to link to previously loaded line
pathname -
drive - strings used to hold filename
dir -
filename - information
ext -
buffer - all actual input goes here first before being added

row - current row number the cursor is on
column - current column number the cursor is on also index to buffer[]
lpos - column number displayed at left of screen \ used for l/r
rpos - column number displayed at right of screen / scrolling
tpos - row number displayed at top of screen \ used for u/d
bpos - row number displayed at bottom of screen/ scrolling
last - highest numbered row
insert_flag- insert mode flag (0=off, 1=on)
load - load flag (0=not loading,1=loading current file)
attr - current files attribute (readwrite,readonly)
changed - file changed flag (0=nochange,1 file changed)

fn - file stream pointer
bios - pointer to bios data area
bios=MK_FP(0x40,0x0); // point bios to actual bios data area

origscrn - hold area for screen contents before execution
savearea - general screen text hold area


Functions:


void main(int argc,char *argv[])

Description: Loads the current file into memory, initializes the screen,
and begins the main loop to process text
Arguments: argc - number of command line arguments passed
argv - actual command line arguments
Return: Nothing

void clear_text(void)

Description: Starting at the beginning of the list the function traverses
the list freeing the text string that dataptr points to
and then freeing the structure that is being pointed to.
This erases the list from memory to free the memory for use
by further mallocs.
Arguments: NONE
Return: Nothing













char pop_input(int x, int y, char *str,int len,char *msg)

Description: Used to allow the input of a charater array of up to 78
characters into the str field. Displays a boxed area at
x,y that is 80 columns long and 4 row wide and prints
the string in msg on the first line of the box and
waits for user input on the second line, exits when enter
or ESC is pressed.
Arguments: x - zero based x position on screen
y - zero based y position on screen
str - the character array the user input will be placed in, it
will be NULL terminated unless the use inputs len number
of characters.
len - maximum length of array
msg - message to display at top of message box
Returns: 0 if user pressed enter 27 if user pressed esc
str - receives user inputed character array


void box(int x,int y,int len,int width)

Description: Draws a box around and fills a specified region of
the screen.
Arguments: x - zero based x position of screen
y - zero based y position of screen
len - maximun length of interior region; cannot exceed 78
width - number of rows for box include top and bottom of box
Return: nothing


int menu(void)

Description: When the user presses ESC while inputing text this menu is
displayed with a list of functions that the user can select
by moving the cursor up or down and pressing enter on the
desired option or pressing ESC to go back to inputing text.
Arguments: NONE
Return: if enter is pressed then the option number selected or if
ESC is pressed then 27 is returned


void save_file(void)

Description: opens the file currently in the pathname string as write only
and uses the global variable new to traverse the list saving
each dataptrs contents to disk with a '\n' at the end. When
done the file is closed.
Arguments: NONE
Return: nothing





char get_charray(char *array,int size, int x, int y)

Description: Processes user input and places it into array if array is
less that size characters long it is NULL terminated otherwise
it is not

Arguments: array - character array that will receive all input
size - maximum number of character to input into array
x - x position of pop_input box
y - y position of pop_input box +2
Return: if user presses ESC then 27 else 0


int check_file(char *name)

Description: Check a filename and path to see if it is valid and to
determine its read write access and whether it exists or not.
Arguments: name - filename and path if any to be checked
Return: -1 then invalid directory
0 newfile
1 readonly
2 readwrite


char error_msg(int x,int y,int len,char *msg,byte attrib)

Description: Display a boxed error message at a specified location and
wait for a one key user input which is returned to the
calling function
Arguments: x - zero based x position of upper left corner of box
y - zero based y position of upper left corner of box
len - display width, if msg is longer than len it is wrapped
to a second line in box. It has a variable width based
on the length of msg
msg - text to be displayed in error msg box
attrib - color to display message in
Return: char containing the key the user entered


void load_file()

Description: Loads file in pathname and creates places it into the list
Arguments: NONE
Return: nothing


unsigned cursor_change(unsigned value)

Description: changes the cursor size, the value should be passed in hex
so that it is easier to see exactly what is going on. A value
of 0x0e0f starts the cursor on line 14->0x0e and ends the
cursor on line 15->0x0f. 0xffff displays no cursor.
Arguments: value - cursor size
Return: current cursor size void screen_writea(int xs,int xe,int ys,int ye,byte *screen,byte attrib)

Description: Direct Screen Write with color attribute. Can be used to write
on single line or multiple lines in any area of the screen
the screen argument should contain the same number of bytes of
information as calculated by ((xe-xs+1)*(ye-ys+1))
Arguments: xs - zero based x starting position for write
xe - ending x position of write
ys - zero based y starting position for write
ye - ending y position of write
screen - character array of text to be displayed
attrib - color of text to be printed
Return: nothing


void screen_write(int xs,int xe,int ys,int ye,byte *screen)

Description: Direct Screen Write of character using whatever attribute that
currently displayed on the screen. Can be used to write
on single line or multiple lines in any area of the screen
the screen argument should contain the same number of bytes of
information as calculated by ((xe-xs+1)*(ye-ys+1))
Arguments: xs - zero based x starting position for write
xe - ending x position of write
ys - zero based y starting position for write
ye - ending y position of write
screen - character array of text to be displayed
Return: nothing


void attrib_fill(int xs,int xe,int ys,int ye,byte attrib)

Description: Direct Screen Write of color changing the color of text that
is already on the screen without rewriting it. Can be used to
write on single line or multiple lines in any area of the
screen
Arguments: xs - zero based x starting position for write
xe - ending x position of write
ys - zero based y starting position for write
ye - ending y position of write
attrib - color to write to video memory
Return: nothing


void init_screen(void)

Description: used to setup main editor screen
Arguments: NONE
Return: nothing





void uplc(void)

Description: displays the current line and column of the cursor. the values
come from the global variables row and column.
Arguments: NONE
Return: nothing


void mem(void)

Description: displays the current memory available
Arguments: NONE
Return: nothing


int get_text(void)

Description: gets all user input while editing the file and processes it
accordingly
Arguments: NONE
Return: value to option in main() if special keys are pressed


int insert_line(LINE far *ptr)

Description: inserts a newly allocated structure after the structure passed
to it
Arguments: ptr - far pointer of type LINE insert is done after this line
Return: -1 if memory allocation error occured
0 if ok


void fill_buffer(void)

Description: fills the global string buffer with the text of the current
row
Arguments: NONE
Return: nothing


void delete_line(LINE far *ptr)

Description: deletes the structure passed in ptr
Arguments: ptr - far pointer to the structure to be deleted
Return: nothing


void update_screen(void)

Description: redisplay the screen printing out the text stored in the
part of the list currently associated with the screen with
the global variables row and tptr
Arguments: NONE
Return: nothing

int add_line(int flag)

Description: adds new structures to the end of the list and updates the
text of existing structures
Arguments: flag - a '2' indicates that buffer should be filled with the
next lines text
Return: nothing



  3 Responses to “Category : Word Processors
Archive   : MEDIT.ZIP
Filename : TECH.DOC

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/