home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
High Voltage Shareware
/
high1.zip
/
high1
/
DIR8
/
FRUGALED.ZIP
/
FE.H
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-13
|
15KB
|
355 lines
// FE.H
//----------------------------------------------------------------------//
// [FE] FrugalEdit v1.0 (c) 1993 by S.C.Park, Esq. [shareware] //
// Full Function Built-In Text Editor Library for Programmers //
// Free personal use as stand-alone text editor / FE.EXE for DOS //
// Based on ee.c (c) 1991 Yijun Ding (PD) / Written in Turbo C++ //
//----------------------------------------------------------------------//
// This should be included to call Fedit().
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#define LF '\n'
#define EOL '\0'
////////// VARIABLE DECLARATIONS //////////
int FeUserRoutine[4] = { // Turn these on (1) to use
// your own implementation
0, //1, // user's printing routine
0, //1, // user's shell routine
0, //1, // user's function selection (menu) routine
0 //1, // user's file selection routine
};
char *FeErr[20] = {
"None",
"Printer!",
"Not Enough Memory!",
"Window Too Small!",
"Disk Drive!",
"Cannot Open File!",
"User Abort!",
"Illegal Drive/Path!",
"Unknown Error!"
};
char friar[] = "<<FE>>";// Do NOT REMOVE THIS LINE!
// It is used to find the location of the following defaults
// by config.exe: [FE] configuration program.
// USING CONFIG.EXE INSTEAD OF CHANGING THE FOLLOWING IS RECOMMENDED.
// Do NOT change the order of the comment line.
// Order of functions are fixed.
// Special keys:
// ^=Ctrl, @=Alt, &=Meta: one of two user selected keys
// For Example, "^p" means Ctrl-p key.
// For Meta key "^p" and "^q" are recommended.
// Only LOWER CASE ALPHABET should be used with special keys.
// Do not use number keys (except for Function keys).
// Function keys: #=Shifted
// F11 and F12 keys are not supported.
// Function keys should be in the form "F1", "#1", "@1", or "^1".
// Upper class letter 'F' or shifting symbol plus number between 0-9.
// Note F10 is symbolized by "F0".
char FeKey [60][2] = {
"^c", // function 0: show copyright notice
// TO CHANGE THE ABOVE KEY, YOU SHOULD REGISTER FIRST.
"@h", // function 1: show internal help
"^h", // function 2: view help documentation
"^p", // function 3: meta key
"^q", // function 4: meta key
"^a", // function 5: block begin marking
"^k", // function 6: block store (copy)
"&k", // function 7: block cut
"^u", // function 8: block paste
"^n", // function 9: block print
"&n", // function 10: block write (to file)
"^f", // function 11: search forward
"&f", // function 12: search backward
"^l", // function 13: search again
"^r", // function 14: replace all asking confirmation
"&r", // function 15: replace without asking
"^m", // function 16: get more file (if any)
"&m", // function 17: load new file (in another window)
"^z", // function 18: save file and quit editing
"&z", // function 19: save file in new name
"^y", // function 20: delete one line (store in block buffer)
"^t", // function 21: delete one word
"&t", // function 22: delete from cursor to end of line
"^g", // function 23: go to row
"&g", // function 24: go to column
"^i", // function 25: go to top of file
"&i", // function 26: go to bottom of file
"^d", // function 27: stamp date
"&d", // function 28: stamp time
"^e", // function 29: insert user's stamp
"&e", // function 30: make user's stamp
"^j", // function 31: insert formfeed (also Ctrl-Enter)
"^b", // function 32: format paragraph (to fit in window)
"^x", // function 33: execute a DOS command
"&x", // function 34: go to DOS shell
"F8", // Function 35: show file size
"#8", // Function 36: show memory size
"@8", // function 37: show date/time
// User Programmer Hooks Functions
"F9", // Function 38: User implemented SHELL
"F0", // Function 39: User implemented MENU
// Grouped functions - Two keys for each
"F2", // Function 40: SEARCH and REPLACE
"@s", // Function 41: Forward/Backward/Again/Replace/alL
"F3", // Function 42: FILE
"@f", // Function 43: Helpfile/Load/Quit
"F4", // Function 44: BLOCK
"@k", // Function 45: Mar/Paste or Copy/cuT/priNt/Write
"F5", // Function 46: MODE toggle
"^o", // Function 47: Wrap/Overwrite/Case/Tab/View
"F6", // Function 48: STAMP
"@p", // Function 49: Both/Date/Time/User/Make
// Duplicate keys and reserved
"F1", // function 50: show internal help
"F7", // function 51: save file and quit editing
" "
};
// COLORS
int FeC1 = 7; // Edit window foreground
int FeC2 = 0; // background
int FeC3 = 0; // Status line foreground
int FeC4 = 7; // background
int FeC5 = 7; // Border foreground
int FeC6 = 0; // background
int FeC7 = 0; // Blocked text && Help window
int FeC8 = 7; // Reverse of Edit window is recommended
int FeLeft = 0; // if 0, use whole screen.
int FeTop = 1; // otherwise, window coordinates
int FeRight = 80; // including statuse line at bottom
int FeBottom = 25; // and borders, if any.
int FeTabsize = 4;
int FeBorder = 0; // 0=none, 1=horizontal, 2=vertical, 3=both
int FeBorderStr = 1; // 1=single line┌─┐, 2=double╔═╗, 3=block▄▄▄
int FeSaveScr = 1; // 0=no, 1=yes
int FeNoShell = 0; // do not allow shelling out to DOS
int FeView = 0; // start with view mode (1= no editing allowed)
int FeSensitive = 0; // default 0 = no; 1 = yes; for search/replace
int FeWrap = 1; // start in word wrap mode
int FePrint = 0; // use default printer initialization
int FeNoNewFile = 0; // edit given existing file only
// should be 1 for built-in editor
int FeNoOther = 0; // do not allow multiple files
int FeNoHelpline = 0;// do not show help message on status line
int FeSilence = 0; // do not buz (ring bell) on error
int FeBackup = 1; // leave back up when saving
int FePrintBuf [40] = { // initial printer control codes
// for EPSON LQ-2500
27, 120, 0, // letter quality = draft
27, 77, // pitch = elite = 96 cpi
27, 108, 10, // left margin = 10
27, 81, 96, // right margin = 96
10, 10, 10, 10, 10, // top margin = 5 lines
27, 67, 66, // page length = 66 lines
27, 78, 10, // skip at bottom = 10 lines
// bottom margin = 5 lines
999 }; // Required to end initializing
char FeHelpLine [50] = // Do NOT change this line
// change the next line to show correct keys
// or to show whatever you want on the status line
" [FE] F1=Help F2=Search F3=File F4=Block ";
char FeHelpText [4096] = "\
EDITING KEY HELP [FE] Frugal Edit v1.0 (c) \n\
============================================ \n\
GROUPED FUNCTIONS - main key - another below \n\
-------------------------------------------- \n\
F1 HELP Show this help \n\
F2 SEARCH Forward/Back/Again/Replace/All \n\
F3 FILE More/Helpfile/Save/Load/Quit \n\
F4 BLOCK Mark/Copy/cuT/Paste/priNt/Write \n\
F5 MODE Wrap/Overwrite/Case/Tab/View \n\
F6 STAMP Both/Date/Time/User/Make \n\
F7 EXIT Quit editing after saving \n\
============================================ \n\
FIXED BINDING KEYS - movement/block_marking \n\
-------------------------------------------- \n\
ESC Abort user_input/blocking/help \n\
TAB Insert/advance depending on mode \n\
INSERT Toggle insert/overwrite mode \n\
^PgUp Go to top of file \n\
^PgDown Go to bottom of file \n\
Other movement keys behave as expected \n\
SHIFTED cursors/home/end begins BLOCKING \n\
============================================ \n\
No Function Key Action \n\
-------------------------------------------- \n\
00 Copyright ^c Show copyright notice \n\
01 HELP Short @h Show this help \n\
02 HELP Doc ^h Show help document \n\
03 META key ^p Meta key prefix \n\
04 META key ^q Meta key prefix \n\
05 BLOCK Mark ^a Start marking block \n\
06 BLOCK Store ^k Store marked block \n\
07 BLOCK Cut &k Cut (delete and store) \n\
08 BLOCK Paste ^u Paste stored block/line\n\
09 BLOCK Print ^n Print marked block \n\
10 BLOCK Write &n Write to disk file \n\
11 SEARCH For ^f Search string forward \n\
12 SEARCH Back &f Search string backward \n\
13 SEARCH Again ^l Search again for/back \n\
14 REPLACE Ask ^r Replace after asking \n\
15 REPLACE alL &r Replace without asking \n\
16 FILE More ^m Load more into buffer \n\
17 FILE Load &m Load another file \n\
18 FILE Quit ^z Save file and Quit \n\
19 FILE SaveAs &z Save file in new name \n\
20 DELETE Line ^y Delete one line/marked \n\
21 DELETE Word ^t Delete one word \n\
22 DELETE to End &t Delete to end of line \n\
23 GOTO Row ^g Go to specified row \n\
24 GOTO Column &g Go to specified column \n\
25 GOTO Top ^i Go to top of file \n\
26 GOTO Bottom &i Go to bottom of file \n\
27 STAMP Date ^d Insert today's date \n\
28 STAMP Time &d Insert current time \n\
29 STAMP User ^e Insert user made string\n\
30 STAMP Make &e Make user's stamp \n\
31 FORMFEED ^j Insert formfeed/enter \n\
32 FORMAT ^b Format paragraph \n\
33 SHELL Line ^x Execute a DOS command \n\
34 SHELL Goto &x Go to DOS shell \n\
35 INFO file F8 Show file size \n\
36 INFO mem #8 Show memory size \n\
37 INFO now @8 Show date/time \n\
38 HOOK Shell F9 [if implemented] \n\
39 HOOK Menu F0 [if implemented] \n\
-------------------------------------------- \n\
No.s GROUPED FUNCTIONS KEYS \n\
-------------------------------------------- \n\
40/41 SEARCH F2 @s \n\
42/43 FILE F3 @f \n\
44/45 BLOCK F4 @k \n\
46/47 MODE F5 ^o \n\
48/49 STAMP F6 @p \n\
-------------------------------------------- \n\
Duplicate Keys \n\
-------------------------------------------- \n\
50 HELP Short F1 Show this help \n\
51 FILE Quit F7 Save file and Quit \n\
52-59 RESERVED \n\
============================================ \n\
Press ESC to exit \n";
////////// FUNCTION DECLARATIONS //////////
int Fedit (char *filename, char *helpfilename,
int border, int border_str, int save_scr,
int left, int top, int right, int bottom,
int c1, int c2, int c3, int c4, int c5, int c6, int c7, int c8,
int tab_size, int line_no, int col_no, int no_shell,
int view, int sensitive, int wrap, int print,
int no_new_file, int no_other, int no_helpline, int silence, int backup,
char *string_input, unsigned text_buf_size);
void FeHelp(); // command line options
char *FeDate(); // returns pointer to current date in 01-01-93 format
char *FeTime(); // current time in 12:59am format
void FeBlockPrint( char *start, char *end );
char *FeShell();
int FeMenu();
char *FeGetName( char *prp );
////////// H O O K S F O R U S E R S
////////// MAY BE MODIFIED BUT SHOULD NEVER BE DELETED
///// user hook for block print
// Turn FeUserRoutine[0] to use.
// Note: text is stored as multiple strings
// replace '\0' with '\n' to print
// End of file marker is another '\0'.
void FeBlockPrint( char *start, char *end )
{
char *s;
s = start;
do {
if (*s && fputs (s, stdprn) <= 0) break;
fputc (LF, stdprn);
while (*s++ != EOL);
} while ((s < end));
fputc (LF, stdprn);
fflush (stdprn);
return;
}
///// For the following three routines,
///// whole screen will be saved before calling them and
///// it will be restored on returning.
///// user hook for shell
// Using this as a shell to DOS, as in [FE],
// is Not recommended for a built-in editor.
// Proper use: to show another help file or
// to provide a pick list.
// Turn FeUserRoutine[1] on (=1) AND
// turn on the NO_SHELL command line parameter.
// If any string (pointer to allocated character array)
// is returned, it will be inserted into text.
// The string will be stored in user's stamp buffer.
// Not bound in (stand-alone) FE.EXE.
char *FeShell()
{
static char string[80]; // MAXIMUM = 80 character
puts( " DESIRED TEXT: (up to 80 characters) ");
return( gets( string ) );
}
///// user hook for menu
// I don't think any menu system is necessary
// because of the intuitive command structure of [FE].
// However if you want, feel free to implement one
// so long as it returns an integal value of
// the selected function's number. (See, internal help - F1)
// Turn FeUserRoutine[2] on (=1) to use.
// Not bound in (stand-alone) FE.EXE.
int FeMenu()
{
char buf[80];
char *function;
int number;
cputs( " DESIRED FUNCTION'S NUMBER: \b\b\b\b" );
function = gets( buf );
number = atoi( function ); // if fails, function0: show copyright notice
// if (!number) number = 1; // show help instead
return( number );
}
///// user hook for file selection system
// Usually not required for built-in editor.
// Used only if you allow the end-user
// access other files than the given one.
// User implementation is Not recommeded,
// unless you are intending to use [FE] as a stand alone editor.
// In such a case, the program should be free.
// Turn FeUserRoutine[3] on (=1) to use.
char *FeGetName( char *prp )
{
static char name[40];
clrscr();
system( "dir /p" );
cputs( prp );
return( gets( name ) );
}
// END OF FE.H