00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _CONSOLE_H_
00024 #define _CONSOLE_H_
00025
00026 #ifdef HAVE_CONFIG_H
00027 #include <config.h>
00028 #endif
00029
00030
00031 #include "SDL_events.h"
00032 #include "SDL_video.h"
00033 #include "begin_code.h"
00034
00039 #define CON_CHARS_PER_LINE 127
00040
00041 #define CON_BLINK_RATE 500
00042
00043 #define CON_CHAR_BORDER 4
00044
00045 #define CON_DEFAULT_PROMPT "]"
00046
00047 #define CON_LINE_SCROLL 2
00048
00049 #define CON_SCROLL_INDICATOR "^"
00050
00051 #define CON_INS_CURSOR "_"
00052
00053 #define CON_OVR_CURSOR "|"
00054
00055 #define CON_DEFAULT_HIDEKEY SDLK_ESCAPE
00056
00057 #define CON_OPENCLOSE_SPEED 25
00058
00059
00060 #ifdef __cplusplus
00061 extern "C" {
00062 #endif
00063
00064 enum {
00065 CON_CLOSED,
00066 CON_CLOSING,
00067 CON_OPENING,
00068 CON_OPEN
00069 };
00070
00072 typedef struct console_information_td {
00073 int Visible;
00074 int WasUnicode;
00075 int RaiseOffset;
00076 int HideKey;
00077 char **ConsoleLines;
00078 char **CommandLines;
00079 int TotalConsoleLines;
00080 int ConsoleScrollBack;
00081 int TotalCommands;
00082 int FontNumber;
00083 int LineBuffer;
00084 int VChars;
00085 int BackX, BackY;
00086 char* Prompt;
00087 char Command[CON_CHARS_PER_LINE+1];
00088 char RCommand[CON_CHARS_PER_LINE+1];
00089 char LCommand[CON_CHARS_PER_LINE+1];
00090 char VCommand[CON_CHARS_PER_LINE+1];
00091 int CursorPos;
00092 int Offset;
00093 int InsMode;
00094 SDL_Surface *ConsoleSurface;
00095 SDL_Surface *OutputScreen;
00096 SDL_Surface *BackgroundImage;
00097 SDL_Surface *InputBackground;
00098 int DispX, DispY;
00099 unsigned char ConsoleAlpha;
00100 int CommandScrollBack;
00101 void(*CmdFunction)(struct console_information_td *console, char* command);
00102 char*(*TabFunction)(char* command);
00104 int FontHeight;
00105 int FontWidth;
00106 } ConsoleInformation;
00107
00112 extern DECLSPEC SDL_Event* SDLCALL CON_Events(SDL_Event *event);
00114 extern DECLSPEC void SDLCALL CON_Show(ConsoleInformation *console);
00116 extern DECLSPEC void SDLCALL CON_Hide(ConsoleInformation *console);
00118 extern DECLSPEC int SDLCALL CON_isVisible(ConsoleInformation *console);
00120 extern DECLSPEC void SDLCALL CON_UpdateOffset(ConsoleInformation* console);
00122 extern DECLSPEC void SDLCALL CON_DrawConsole(ConsoleInformation *console);
00129 extern DECLSPEC ConsoleInformation* SDLCALL CON_Init(const char *FontName, SDL_Surface *DisplayScreen, int lines, SDL_Rect rect);
00131 extern DECLSPEC void SDLCALL CON_Destroy(ConsoleInformation *console);
00133 extern DECLSPEC void SDLCALL CON_Free(ConsoleInformation *console);
00135 extern DECLSPEC void SDLCALL CON_Out(ConsoleInformation *console, const char *str, ...);
00138 extern DECLSPEC void SDLCALL CON_Alpha(ConsoleInformation *console, unsigned char alpha);
00141 extern DECLSPEC void SDLCALL CON_AlphaGL(SDL_Surface *s, int alpha);
00143 extern DECLSPEC int SDLCALL CON_Background(ConsoleInformation *console, const char *image, int x, int y);
00145 extern DECLSPEC void SDLCALL CON_Position(ConsoleInformation *console, int x, int y);
00147 extern DECLSPEC int SDLCALL CON_Resize(ConsoleInformation *console, SDL_Rect rect);
00151 extern DECLSPEC int SDLCALL CON_Transfer(ConsoleInformation* console, SDL_Surface* new_outputscreen, SDL_Rect rect);
00154 extern DECLSPEC void SDLCALL CON_Topmost(ConsoleInformation *console);
00156 extern DECLSPEC void SDLCALL CON_SetPrompt(ConsoleInformation *console, char* newprompt);
00159 extern DECLSPEC void SDLCALL CON_SetHideKey(ConsoleInformation *console, int key);
00161 extern DECLSPEC void SDLCALL CON_Execute(ConsoleInformation *console, char* command);
00168 extern DECLSPEC void SDLCALL CON_SetExecuteFunction(ConsoleInformation *console, void(*CmdFunction)(ConsoleInformation *console2, char* command));
00174 extern DECLSPEC void SDLCALL CON_SetTabCompletion(ConsoleInformation *console, char*(*TabFunction)(char* command));
00176 extern DECLSPEC void SDLCALL CON_TabCompletion(ConsoleInformation *console);
00178 extern DECLSPEC void SDLCALL CON_NewLineConsole(ConsoleInformation *console);
00180 extern DECLSPEC void SDLCALL CON_NewLineCommand(ConsoleInformation *console);
00182 extern DECLSPEC void SDLCALL CON_UpdateConsole(ConsoleInformation *console);
00183
00184
00186 extern DECLSPEC void SDLCALL Default_CmdFunction(ConsoleInformation *console, char* command);
00188 extern DECLSPEC char* SDLCALL Default_TabFunction(char* command);
00189
00192 extern DECLSPEC void SDLCALL DrawCommandLine();
00193
00195 extern DECLSPEC void SDLCALL Cursor_Left(ConsoleInformation *console);
00197 extern DECLSPEC void SDLCALL Cursor_Right(ConsoleInformation *console);
00200 extern DECLSPEC void SDLCALL Cursor_Home(ConsoleInformation *console);
00202 extern DECLSPEC void SDLCALL Cursor_End(ConsoleInformation *console);
00204 extern DECLSPEC void SDLCALL Cursor_Del(ConsoleInformation *console);
00206 extern DECLSPEC void SDLCALL Cursor_BSpace(ConsoleInformation *console);
00208 extern DECLSPEC void SDLCALL Cursor_Add(ConsoleInformation *console, SDL_Event *event);
00209
00211 extern DECLSPEC void SDLCALL Clear_Command(ConsoleInformation *console);
00213 extern DECLSPEC void SDLCALL Assemble_Command(ConsoleInformation *console);
00215 extern DECLSPEC void SDLCALL Clear_History(ConsoleInformation *console);
00216
00218 extern DECLSPEC void SDLCALL Command_Up(ConsoleInformation *console);
00220 extern DECLSPEC void SDLCALL Command_Down(ConsoleInformation *console);
00221
00222
00223 #ifdef __cplusplus
00224 };
00225 #endif
00226 #include "close_code.h"
00227
00228 #endif
00229
00230
00231