2001-07-16 20:41:10 +00:00
|
|
|
/*
|
|
|
|
console.c
|
|
|
|
|
|
|
|
console api
|
|
|
|
|
|
|
|
Copyright (C) 2001 Bill Currie <bill@taniwha.org>
|
|
|
|
|
|
|
|
Author: Bill Currie <bill@taniwha.org>
|
|
|
|
Date: 2001/7/16
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
2001-09-10 12:56:23 +00:00
|
|
|
|
2005-08-04 15:27:09 +00:00
|
|
|
static __attribute__ ((used)) const char rcsid[] =
|
2003-01-15 15:31:36 +00:00
|
|
|
"$Id$";
|
|
|
|
|
2001-07-16 20:41:10 +00:00
|
|
|
#include <stdarg.h>
|
2001-08-09 12:19:15 +00:00
|
|
|
#include <stdio.h>
|
2001-07-16 20:41:10 +00:00
|
|
|
|
2001-10-02 03:24:36 +00:00
|
|
|
#include "QF/cmd.h"
|
2001-07-16 20:41:10 +00:00
|
|
|
#include "QF/console.h"
|
|
|
|
#include "QF/cvar.h"
|
|
|
|
#include "QF/plugin.h"
|
2001-09-21 04:22:46 +00:00
|
|
|
#include "QF/sys.h"
|
2001-07-16 20:41:10 +00:00
|
|
|
|
2001-09-16 05:41:28 +00:00
|
|
|
int con_linewidth; // characters across screen
|
2001-07-16 20:41:10 +00:00
|
|
|
|
2002-01-16 21:53:42 +00:00
|
|
|
plugin_t *con_module;
|
2001-09-10 12:56:23 +00:00
|
|
|
|
2005-08-04 15:27:09 +00:00
|
|
|
#define U __attribute__ ((used))
|
2003-04-17 00:01:48 +00:00
|
|
|
static U con_buffer_t *(*const buffer) (size_t, int) = Con_CreateBuffer;
|
|
|
|
static U void (*const complete)(inputline_t *) = Con_BasicCompleteCommandLine;
|
|
|
|
static U inputline_t *(*const create)(int, int, char) = Con_CreateInputLine;
|
|
|
|
static U void (*const display)(const char **, int) = Con_DisplayList;
|
|
|
|
#undef U
|
2001-09-25 20:16:24 +00:00
|
|
|
|
2001-07-16 20:41:10 +00:00
|
|
|
void
|
|
|
|
Con_Init (const char *plugin_name)
|
|
|
|
{
|
|
|
|
con_module = PI_LoadPlugin ("console", plugin_name);
|
2001-09-21 04:22:46 +00:00
|
|
|
if (con_module) {
|
2001-07-17 00:21:56 +00:00
|
|
|
con_module->functions->general->p_Init ();
|
2002-02-20 19:22:52 +00:00
|
|
|
Sys_SetStdPrintf (con_module->functions->console->pC_Print);
|
2001-09-21 04:22:46 +00:00
|
|
|
} else {
|
2001-08-09 12:19:15 +00:00
|
|
|
setvbuf (stdout, 0, _IOLBF, BUFSIZ);
|
2001-09-21 04:22:46 +00:00
|
|
|
}
|
2001-07-16 20:41:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Con_Init_Cvars (void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Con_Shutdown (void)
|
|
|
|
{
|
|
|
|
if (con_module) {
|
2001-07-17 00:21:56 +00:00
|
|
|
con_module->functions->general->p_Shutdown ();
|
2001-07-16 20:41:10 +00:00
|
|
|
PI_UnloadPlugin (con_module);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Con_Printf (const char *fmt, ...)
|
|
|
|
{
|
2001-09-10 12:56:23 +00:00
|
|
|
va_list args;
|
|
|
|
|
2001-07-16 20:41:10 +00:00
|
|
|
va_start (args, fmt);
|
|
|
|
if (con_module)
|
|
|
|
con_module->functions->console->pC_Print (fmt, args);
|
|
|
|
else
|
|
|
|
vfprintf (stdout, fmt, args);
|
|
|
|
va_end (args);
|
|
|
|
}
|
|
|
|
|
2002-01-17 02:47:22 +00:00
|
|
|
void
|
|
|
|
Con_Print (const char *fmt, va_list args)
|
|
|
|
{
|
|
|
|
if (con_module)
|
|
|
|
con_module->functions->console->pC_Print (fmt, args);
|
|
|
|
else
|
|
|
|
vfprintf (stdout, fmt, args);
|
|
|
|
}
|
|
|
|
|
2001-07-16 20:41:10 +00:00
|
|
|
void
|
|
|
|
Con_DPrintf (const char *fmt, ...)
|
|
|
|
{
|
|
|
|
if (developer && developer->int_val) {
|
|
|
|
va_list args;
|
|
|
|
va_start (args, fmt);
|
|
|
|
if (con_module)
|
|
|
|
con_module->functions->console->pC_Print (fmt, args);
|
|
|
|
else
|
|
|
|
vfprintf (stdout, fmt, args);
|
|
|
|
va_end (args);
|
|
|
|
}
|
|
|
|
}
|
2001-09-16 05:41:28 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
Con_ProcessInput (void)
|
|
|
|
{
|
2001-12-02 20:11:21 +00:00
|
|
|
if (con_module) {
|
2001-09-16 05:41:28 +00:00
|
|
|
con_module->functions->console->pC_ProcessInput ();
|
2001-12-02 20:11:21 +00:00
|
|
|
} else {
|
|
|
|
static int been_there_done_that = 0;
|
|
|
|
|
|
|
|
if (!been_there_done_that) {
|
|
|
|
been_there_done_that = 1;
|
|
|
|
Con_Printf ("no input for you\n");
|
|
|
|
}
|
|
|
|
}
|
2001-09-16 05:41:28 +00:00
|
|
|
}
|
2002-01-16 21:53:42 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
Con_KeyEvent (knum_t key, short unicode, qboolean down)
|
|
|
|
{
|
|
|
|
if (con_module)
|
|
|
|
con_module->functions->console->pC_KeyEvent (key, unicode, down);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Con_SetOrMask (int mask)
|
|
|
|
{
|
|
|
|
if (con_module)
|
|
|
|
con_module->data->console->ormask = mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-07-25 22:21:47 +00:00
|
|
|
Con_DrawConsole (void)
|
2002-01-16 21:53:42 +00:00
|
|
|
{
|
|
|
|
if (con_module)
|
2003-07-25 22:21:47 +00:00
|
|
|
con_module->functions->console->pC_DrawConsole ();
|
2002-01-16 21:53:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Con_CheckResize (void)
|
|
|
|
{
|
|
|
|
if (con_module)
|
|
|
|
con_module->functions->console->pC_CheckResize ();
|
|
|
|
}
|
2002-01-18 19:19:33 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
Con_NewMap (void)
|
|
|
|
{
|
|
|
|
if (con_module)
|
|
|
|
con_module->functions->console->pC_NewMap ();
|
|
|
|
}
|