* keys.c (History_Init): Make it static. Tidy-up its formatting.

(History_Shutdown): Likewise.


git-svn-id: http://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@229 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
sezero 2010-06-25 23:55:41 +00:00
parent 819208b38c
commit 9154ed3539

View file

@ -682,64 +682,67 @@ void Key_WriteBindings (FILE *f)
fprintf (f, "bind \"%s\" \"%s\"\n", Key_KeynumToString(i), keybindings[i]); fprintf (f, "bind \"%s\" \"%s\"\n", Key_KeynumToString(i), keybindings[i]);
} }
void History_Init (void)
static void History_Init (void)
{ {
int i, c; int i, c;
FILE *hf; FILE *hf;
for (i = 0; i < CMDLINES; i++) { for (i = 0; i < CMDLINES; i++)
key_lines[i][0] = ']'; {
key_lines[i][1] = 0; key_lines[i][0] = ']';
} key_lines[i][1] = 0;
key_linepos = 1; }
key_linepos = 1;
// if (cl_savehistory.value) // if (cl_savehistory.value)
if ((hf = fopen(HISTORY_FILE_NAME, "rt"))) if ((hf = fopen(HISTORY_FILE_NAME, "rt")) != NULL)
{ {
do do
{ {
i = 1; i = 1;
do do
{ {
c = fgetc(hf); c = fgetc(hf);
key_lines[edit_line][i++] = c; key_lines[edit_line][i++] = c;
} while (c != '\n' && c != EOF && i < MAXCMDLINE); } while (c != '\n' && c != EOF && i < MAXCMDLINE);
key_lines[edit_line][i - 1] = 0; key_lines[edit_line][i - 1] = 0;
edit_line = (edit_line + 1) & (CMDLINES - 1); edit_line = (edit_line + 1) & (CMDLINES - 1);
} while (c != EOF && edit_line < CMDLINES); } while (c != EOF && edit_line < CMDLINES);
fclose(hf); fclose(hf);
history_line = edit_line = (edit_line - 1) & (CMDLINES - 1); history_line = edit_line = (edit_line - 1) & (CMDLINES - 1);
key_lines[edit_line][0] = ']'; key_lines[edit_line][0] = ']';
key_lines[edit_line][1] = 0; key_lines[edit_line][1] = 0;
} }
} }
void History_Shutdown (void) static void History_Shutdown (void)
{ {
int i; int i;
FILE *hf; FILE *hf;
// if (cl_savehistory.value) // if (cl_savehistory.value)
if ((hf = fopen(HISTORY_FILE_NAME, "wt"))) if ((hf = fopen(HISTORY_FILE_NAME, "wt")) != NULL)
{ {
i = edit_line; i = edit_line;
do do
{ {
i = (i + 1) & (CMDLINES - 1); i = (i + 1) & (CMDLINES - 1);
} while (i != edit_line && !key_lines[i][1]); } while (i != edit_line && !key_lines[i][1]);
do do
{ {
// fprintf(hf, "%s\n", wcs2str(key_lines[i] + 1)); // Baker: I commented this line out because byte colored text isn't a feature in most ordinary engines // Baker: I commented this line out because byte colored
fprintf(hf, "%s\n", key_lines[i] + 1); // text isn't a feature in most ordinary engines.
i = (i + 1) & (CMDLINES - 1); // fprintf(hf, "%s\n", wcs2str(key_lines[i] + 1));
} while (i != edit_line && key_lines[i][1]); fprintf(hf, "%s\n", key_lines[i] + 1);
fclose(hf); i = (i + 1) & (CMDLINES - 1);
} } while (i != edit_line && key_lines[i][1]);
fclose(hf);
}
} }
/* /*
=================== ===================
Key_Init Key_Init
@ -751,10 +754,9 @@ void Key_Init (void)
BuildKeyMaps(); BuildKeyMaps();
History_Init (); History_Init ();
#if 0 // This section of code is now done in History_Init
#if 0 /* This section of code is now done in History_Init */
for (i=0 ; i<32 ; i++) for (i=0 ; i<32 ; i++)
{ {
key_lines[i][0] = ']'; key_lines[i][0] = ']';