home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Black Box 4
/
BlackBox.cdr
/
editors
/
tde150.arj
/
CFGMODES.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-04-01
|
11KB
|
475 lines
/*
* Author: Frank Davis
* Date: January 20, 1992
* Compiler: MSC 6.0a and QuickC 2.5
*
* This program is released into the public domain. You may distribute
* it freely, Frank Davis
*/
/******** EXTREMELY IMPORTANT ************/
/*
* If you modify tde, it is your responsibility to find the offset of
* "mode_infos mode", a global structure declared in ed.c.
*
* If you don't change the default modes, search for the following string,
* a hexadecimal integer array, in your new executable file:
*
* 0000 0000 0100 0100 0100 0800 0000 0000
*
* Then, replace MODE_OFFSET with your new one and recompile tdecfg
* with the new offset.
*/
#define MODE_OFFSET 67914l
/******* EXTREMELY IMPORTANT ************/
#include <bios.h>
#include <dos.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "tdecfg.h"
#include "cfgmodes.h"
extern struct vcfg cfg; /* video stuff */
extern FILE *tde_exe; /* FILE pointer to tde.exe */
MODE_INFO in_modes; /* play around with modes in this struct */
int color;
/*
* Name: tdemodes
* Date: July 21, 1991
* Notes: Strategy is fairly straight forward - 1) initialize all the
* variables 2) show the user a color sample 3) make the changes
* permanent if desired.
*/
void tdemodes( void )
{
color = 7;
initialize_modes( );
show_init_mode( );
change_modes( );
}
/*
* Name: initialize_modes
* Date: July 21, 1991
* Notes: Set up the global mode variables.
*/
void initialize_modes( void )
{
int i, j;
fseek( tde_exe, MODE_OFFSET, SEEK_SET );
fread( (void *)&in_modes, sizeof( MODE_INFO ), 1, tde_exe );
mode[Ins].mode = in_modes.insert;
mode[Ind].mode = in_modes.indent;
mode[Tab].mode = in_modes.tab_size;
mode[Write_Z].mode = in_modes.control_z;
mode[Crlf].mode = in_modes.crlf;
mode[Trim].mode = in_modes.trailing;
mode[Eol].mode = in_modes.show_eol;
mode[WW].mode = in_modes.word_wrap;
mode[Left].mode = in_modes.left_margin;
mode[Para].mode = in_modes.parg_margin;
mode[Right].mode = in_modes.right_margin;
mode[Size].mode = in_modes.cursor_size;
mode[Backup].mode = in_modes.do_backups;
mode[Ruler].mode = in_modes.ruler;
}
/*
* Name: show_init_mode
* Date: July 21, 1991
* Notes: Draw the sample screen.
*/
void show_init_mode( void )
{
char *sample;
int line, i;
cls( );
xygoto( -1, -1 );
for (i=0,line=3; sample != NULL; line++, i++) {
sample = mode_screen[i];
s_output( (char far *)sample, line, 0, 7 );
}
for (i=0; i<14; i++)
(*mode[i].show_me)();
}
/*
* Name: show_insert_mode
* Date: January 20, 1992
*/
void show_insert_mode( void )
{
char *p[] = {
"Overwrite",
"Insert "
};
s_output( p[mode[Ins].mode], mode[Ins].line, mode[Ins].col, color );
}
/*
* Name: show_indent_mode
* Date: January 20, 1992
*/
void show_indent_mode( void )
{
char *p[] = {
"Indent off",
"Indent on "
};
s_output( p[mode[Ind].mode], mode[Ind].line, mode[Ind].col, color );
}
/*
* Name: show_tabsize
* Date: January 20, 1992
*/
void show_tabsize( void )
{
char temp[10];
s_output( " ", mode[Tab].line, mode[Tab].col, color );
s_output( itoa(mode[Tab].mode,temp,10), mode[Tab].line, mode[Tab].col,color);
}
/*
* Name: show_controlz
* Date: January 20, 1992
*/
void show_controlz( void )
{
char *p[] = {
"Write ^Z",
"No ^Z ",
};
s_output( p[mode[Write_Z].mode], mode[Write_Z].line,mode[Write_Z].col,color);
}
/*
* Name: show_eol_out
* Date: January 20, 1992
*/
void show_eol_out( void )
{
char *p[] = {
"",
"CRLF",
"LF ",
};
s_output( p[mode[Crlf].mode], mode[Crlf].line, mode[Crlf].col, color );
}
/*
* Name: show_trail
* Date: January 20, 1992
*/
void show_trail( void )
{
char *p[] = {
"No Trim",
"Trim ",
};
s_output( p[mode[Trim].mode], mode[Trim].line, mode[Trim].col, color );
}
/*
* Name: show_eol_display
* Date: January 20, 1992
*/
void show_eol_display( void )
{
char *p[] = {
"Off",
"On ",
};
s_output( p[mode[Eol].mode], mode[Eol].line, mode[Eol].col, color );
}
/*
* Name: show_ww
* Date: January 20, 1992
*/
void show_ww( void )
{
char *p[] = {
"Off",
"On ",
};
s_output( p[mode[WW].mode], mode[WW].line, mode[WW].col, color );
}
/*
* Name: show_left
* Date: January 20, 1992
*/
void show_left( void )
{
char temp[10];
s_output( " ", mode[Left].line, mode[Left].col, color );
s_output( itoa( mode[Left].mode+1, temp, 10 ), mode[Left].line, mode[Left].col,
color);
}
/*
* Name: show_para
* Date: January 20, 1992
*/
void show_para( void )
{
char temp[10];
s_output( " ", mode[Para].line, mode[Para].col, color );
s_output( itoa( mode[Para].mode+1, temp, 10 ), mode[Para].line, mode[Para].col,
color);
}
/*
* Name: show_right
* Date: January 20, 1992
*/
void show_right( void )
{
char temp[10];
s_output( " ", mode[Right].line, mode[Right].col, color );
s_output( itoa(mode[Right].mode+1,temp,10), mode[Right].line, mode[Right].col,
color);
}
/*
* Name: show_cursor_size
* Date: January 20, 1992
*/
void show_cursor_size( void )
{
char *p[] = {
"Small Insert Cursor",
"Big Insert Cursor ",
};
s_output( p[mode[Size].mode], mode[Size].line, mode[Size].col, color );
}
/*
* Name: show_backup_mode
* Date: January 20, 1992
*/
void show_backup_mode( void )
{
char *p[] = {
"No .bak files ",
"Create .bak files"
};
s_output( p[mode[Backup].mode], mode[Backup].line, mode[Backup].col, color );
}
/*
* Name: show_backup_mode
* Date: January 20, 1992
*/
void show_ruler_mode( void )
{
char *p[] = {
"No ruler ",
"Show ruler"
};
s_output( p[mode[Ruler].mode], mode[Ruler].line, mode[Ruler].col, color );
}
/*
* Name: change_modes
* Date: July 21, 1991
* Notes: Real workhorse function of the utility. Get a key and then
* figure out what to do with it.
*/
void change_modes( void )
{
int c;
int m;
int new_field;
m = 0;
xygoto( mode[m].col, mode[m].line );
color = 112;
(*mode[m].show_me)();
for (c=0; c != F3 && c != F10 && c != ESC;) {
c = getkey( );
new_field = FALSE;
color = 112;
switch (c) {
case RTURN :
case DOWN :
color = 7;
(*mode[m].show_me)();
++m;
if (m > 13)
m = 0;
new_field = TRUE;
break;
case UP :
color = 7;
(*mode[m].show_me)();
--m;
if (m < 0)
m = 13;
new_field = TRUE;
break;
case LEFT :
switch (m) {
case Ins :
case Ind :
case Write_Z :
case Trim :
case Eol :
case WW :
case Size :
case Backup :
case Ruler :
mode[m].mode = !mode[m].mode;
break;
case Tab :
if (mode[m].mode > 1)
--mode[m].mode;
else
mode[m].mode = 255 / 2;
break;
case Crlf :
if (mode[m].mode == CRLF)
mode[m].mode = LF;
else
mode[m].mode = CRLF;
break;
case Left :
case Para :
if (mode[m].mode > 0)
--mode[m].mode;
else
mode[m].mode = mode[Right].mode - 1;
break;
case Right :
if (mode[m].mode > mode[Left].mode + 1 &&
mode[m].mode > mode[Para].mode + 1)
--mode[m].mode;
else
mode[m].mode = 254;
break;
}
(*mode[m].show_me)();
break;
case RIGHT :
switch (m) {
case Ins :
case Ind :
case Write_Z :
case Trim :
case Eol :
case WW :
case Size :
case Backup :
case Ruler :
mode[m].mode = !mode[m].mode;
break;
case Tab :
if (mode[m].mode < 255 / 2)
++mode[m].mode;
else
mode[m].mode = 1;
break;
case Crlf :
if (mode[m].mode == CRLF)
mode[m].mode = LF;
else
mode[m].mode = CRLF;
break;
case Left :
case Para :
if (mode[m].mode < mode[Right].mode)
++mode[m].mode;
else
mode[m].mode = 0;
break;
case Right :
if (mode[m].mode < 254)
++mode[m].mode;
else {
if (mode[Left].mode < mode[Para].mode)
mode[m].mode = mode[Para].mode + 1;
else
mode[m].mode = mode[Left].mode + 1;
}
break;
}
(*mode[m].show_me)();
break;
}
if (new_field) {
color = 112;
(*mode[m].show_me)();
xygoto( mode[m].col, mode[m].line );
}
}
/*
* write changes to "tde.exe" if user presses F10.
*/
if (c == F10) {
in_modes.insert = mode[Ins].mode;
in_modes.indent = mode[Ind].mode;
in_modes.tab_size = mode[Tab].mode;
in_modes.control_z = mode[Write_Z].mode;
in_modes.crlf = mode[Crlf].mode;
in_modes.trailing = mode[Trim].mode;
in_modes.show_eol = mode[Eol].mode;
in_modes.word_wrap = mode[WW].mode;
in_modes.left_margin = mode[Left].mode;
in_modes.parg_margin = mode[Para].mode;
in_modes.right_margin = mode[Right].mode;
in_modes.cursor_size = mode[Size].mode;
in_modes.do_backups = mode[Backup].mode;
in_modes.ruler = mode[Ruler].mode;
fseek( tde_exe, MODE_OFFSET, SEEK_SET );
fwrite( (void *)&in_modes, sizeof( MODE_INFO ), 1, tde_exe );
}
cls( );
}