Review global literals for mode names and color names.

This commit is contained in:
Renaud 2013-09-30 23:05:29 +08:00
parent 63e2f82211
commit 526c1e3baa
7 changed files with 28 additions and 56 deletions

View File

@ -23,6 +23,20 @@
#include "window.h"
const char *modename[] = { /* name of modes */
"Wrap", "Cmode", "Spell", "Exact", "View", "Over",
"Magic",
#if CRYPT
"Crypt",
#else
"",
#endif
"Asave", "Utf-8", "Dos"
} ;
static const char modecode[] = "WCSEVOMYAUD" ; /* letters to represent modes */
static int makelist( int iflag) ;
static int addline( char *text) ;
static void ltoa( char *buf, int width, long num) ;
@ -296,9 +310,8 @@ static int makelist( int iflag)
if ((s = bclear(blistp)) != TRUE) /* Blow old text away */
return s;
strcpy(blistp->b_fname, "");
if (addline("ACT MODES Size Buffer File") == FALSE
|| addline("--- ----- ---- ------ ----") ==
FALSE)
if( addline("ACT MODES Size Buffer File") == FALSE
|| addline("--- ----- ---- ------ ----") == FALSE)
return FALSE;
bp = bheadp; /* For all buffers */

View File

@ -59,6 +59,9 @@ struct buffer {
#define MDDOS 0x0400 /* CRLF eol mode */
extern const char *modename[] ; /* text names of modes */
int usebuffer( int f, int n) ;
int nextbuffer( int f, int n) ;
int swbuffer( struct buffer *bp) ;

View File

@ -1165,7 +1165,7 @@ static void modeline(struct window *wp)
if (firstm != TRUE)
strcat(tline, " ");
firstm = FALSE;
strcat(tline, mode2name[i]);
strcat( tline, modename[ i]) ;
}
strcat(tline, ") ");

3
edef.h
View File

@ -28,9 +28,6 @@ extern char *execstr; /* pointer to string to execute */
extern int eolexist; /* does clear to EOL exist? */
extern int revexist; /* does reverse video exist? */
extern int flickcode; /* do flicker supression? */
extern const char *modename[]; /* text names of modes */
extern const char *mode2name[]; /* text names of modes */
extern const char modecode[]; /* letters to represent modes */
extern int gmode; /* global editor mode */
extern int gflags; /* global control flag */
extern int gfcolor; /* global forgrnd color (white) */

View File

@ -239,7 +239,6 @@
#define NPAT 128 /* # of bytes, pattern */
#define HUGE 1000 /* Huge number */
#define NLOCKS 100 /* max # of file locks active */
#define NCOLORS 8 /* number of supported colors */
#define CONTROL 0x10000000 /* Control flag, or'ed in */
#define META 0x20000000 /* Meta flag, or'ed in */

View File

@ -13,30 +13,6 @@ char *execstr = NULL; /* pointer to string to execute */
int eolexist = TRUE; /* does clear to EOL exist */
int revexist = FALSE; /* does reverse video exist? */
int flickcode = FALSE; /* do flicker supression? */
const char *modename[] = { /* name of modes */
"WRAP", "CMODE", "SPELL", "EXACT", "VIEW", "OVER",
"MAGIC",
#if CRYPT
"CRYPT",
#else
"",
#endif
"ASAVE", "UTF-8", "DOS"
};
const char *mode2name[] = { /* name of modes */
"Wrap", "Cmode", "Spell", "Exact", "View", "Over",
"Magic",
#if CRYPT
"Crypt",
#else
"",
#endif
"Asave", "utf-8", "Dos"
};
const char modecode[] = "WCSEVOMYAUD"; /* letters to represent modes */
int gmode = 0; /* global editor mode */
int gflags = GFREAD; /* global control flag */
#if PKCODE & IBMPC

View File

@ -24,7 +24,8 @@
#include "terminal.h"
#include "window.h"
static const char *cname[] = { /* names of colors */
static const char *cname[] = { /* names of colors */
"BLACK", "RED", "GREEN", "YELLOW", "BLUE",
"MAGENTA", "CYAN", "WHITE"
#if PKCODE & IBMPC
@ -32,6 +33,9 @@ static const char *cname[] = { /* names of colors */
#endif
} ;
#define NCOLORS (sizeof cname / sizeof( *cname)) /* # of supported colors */
int tabsize; /* Tab size (0: use real tabs) */
/*
@ -917,12 +921,8 @@ int delgmode(int f, int n)
*/
int adjustmode(int kind, int global)
{
char *scan; /* scanning pointer to convert prompt */
int i; /* loop index */
int status; /* error return on input */
#if COLOR
int uflag; /* was modename uppercase? */
#endif
char prompt[50]; /* string to prompt user with */
char cbuf[NPAT]; /* buffer to recieve mode name into */
@ -943,28 +943,12 @@ int adjustmode(int kind, int global)
if (status != TRUE)
return status;
/* make it uppercase */
scan = cbuf;
#if COLOR
uflag = (*scan >= 'A' && *scan <= 'Z');
#endif
while (*scan != 0) {
if (*scan >= 'a' && *scan <= 'z')
*scan = *scan - 32;
scan++;
}
/* test it first against the colors we know */
#if PKCODE & IBMPC
for (i = 0; i <= NCOLORS; i++) {
#else
for (i = 0; i < NCOLORS; i++) {
#endif
if (strcmp(cbuf, cname[i]) == 0) {
if( stricmp( cbuf, cname[ i]) == 0) {
/* finding the match, we set the color */
#if COLOR
if (uflag) {
if( *cbuf >= 'A' && *cbuf <= 'Z') {
if (global)
gfcolor = i;
#if PKCODE == 0
@ -990,7 +974,7 @@ int adjustmode(int kind, int global)
/* test it against the modes we know */
for (i = 0; i < NUMMODES; i++) {
if (strcmp(cbuf, modename[i]) == 0) {
if( stricmp( cbuf, modename[ i]) == 0) {
/* finding a match, we process it */
if (kind == TRUE)
if (global)