Main Page | Data Structures | File List | Data Fields | Globals

SDL_console.h File Reference

#include "SDL_events.h"
#include "SDL_video.h"
#include "begin_code.h"
#include "close_code.h"

Include dependency graph for SDL_console.h:

Include dependency graph

Go to the source code of this file.

Data Structures

struct  console_information_td

Defines

#define CON_CHARS_PER_LINE   127
#define CON_BLINK_RATE   500
#define CON_CHAR_BORDER   4
#define CON_DEFAULT_PROMPT   "]"
#define CON_LINE_SCROLL   2
#define CON_SCROLL_INDICATOR   "^"
#define CON_INS_CURSOR   "_"
#define CON_OVR_CURSOR   "|"
#define CON_DEFAULT_HIDEKEY   SDLK_ESCAPE
#define CON_OPENCLOSE_SPEED   25

Typedefs

typedef console_information_td ConsoleInformation

Enumerations

enum  { CON_CLOSED, CON_CLOSING, CON_OPENING, CON_OPEN }

Functions

DECLSPEC SDL_Event *SDLCALL CON_Events (SDL_Event *event)
DECLSPEC void SDLCALL CON_Show (ConsoleInformation *console)
DECLSPEC void SDLCALL CON_Hide (ConsoleInformation *console)
DECLSPEC int SDLCALL CON_isVisible (ConsoleInformation *console)
DECLSPEC void SDLCALL CON_UpdateOffset (ConsoleInformation *console)
DECLSPEC void SDLCALL CON_DrawConsole (ConsoleInformation *console)
DECLSPEC ConsoleInformation
*SDLCALL 
CON_Init (const char *FontName, SDL_Surface *DisplayScreen, int lines, SDL_Rect rect)
DECLSPEC void SDLCALL CON_Destroy (ConsoleInformation *console)
DECLSPEC void SDLCALL CON_Free (ConsoleInformation *console)
DECLSPEC void SDLCALL CON_Out (ConsoleInformation *console, const char *str,...)
DECLSPEC void SDLCALL CON_Alpha (ConsoleInformation *console, unsigned char alpha)
DECLSPEC void SDLCALL CON_AlphaGL (SDL_Surface *s, int alpha)
DECLSPEC int SDLCALL CON_Background (ConsoleInformation *console, const char *image, int x, int y)
DECLSPEC void SDLCALL CON_Position (ConsoleInformation *console, int x, int y)
DECLSPEC int SDLCALL CON_Resize (ConsoleInformation *console, SDL_Rect rect)
DECLSPEC int SDLCALL CON_Transfer (ConsoleInformation *console, SDL_Surface *new_outputscreen, SDL_Rect rect)
DECLSPEC void SDLCALL CON_Topmost (ConsoleInformation *console)
DECLSPEC void SDLCALL CON_SetPrompt (ConsoleInformation *console, char *newprompt)
DECLSPEC void SDLCALL CON_SetHideKey (ConsoleInformation *console, int key)
DECLSPEC void SDLCALL CON_Execute (ConsoleInformation *console, char *command)
DECLSPEC void SDLCALL CON_SetExecuteFunction (ConsoleInformation *console, void(*CmdFunction)(ConsoleInformation *console2, char *command))
DECLSPEC void SDLCALL CON_SetTabCompletion (ConsoleInformation *console, char *(*TabFunction)(char *command))
DECLSPEC void SDLCALL CON_TabCompletion (ConsoleInformation *console)
DECLSPEC void SDLCALL CON_NewLineConsole (ConsoleInformation *console)
DECLSPEC void SDLCALL CON_NewLineCommand (ConsoleInformation *console)
DECLSPEC void SDLCALL CON_UpdateConsole (ConsoleInformation *console)
DECLSPEC void SDLCALL Default_CmdFunction (ConsoleInformation *console, char *command)
DECLSPEC char *SDLCALL Default_TabFunction (char *command)
DECLSPEC void SDLCALL DrawCommandLine ()
DECLSPEC void SDLCALL Cursor_Left (ConsoleInformation *console)
DECLSPEC void SDLCALL Cursor_Right (ConsoleInformation *console)
DECLSPEC void SDLCALL Cursor_Home (ConsoleInformation *console)
DECLSPEC void SDLCALL Cursor_End (ConsoleInformation *console)
DECLSPEC void SDLCALL Cursor_Del (ConsoleInformation *console)
DECLSPEC void SDLCALL Cursor_BSpace (ConsoleInformation *console)
DECLSPEC void SDLCALL Cursor_Add (ConsoleInformation *console, SDL_Event *event)
DECLSPEC void SDLCALL Clear_Command (ConsoleInformation *console)
DECLSPEC void SDLCALL Assemble_Command (ConsoleInformation *console)
DECLSPEC void SDLCALL Clear_History (ConsoleInformation *console)
DECLSPEC void SDLCALL Command_Up (ConsoleInformation *console)
DECLSPEC void SDLCALL Command_Down (ConsoleInformation *console)


Define Documentation

#define CON_CHARS_PER_LINE   127
 

Number of visible characters in a line. Lines in the history, the commandline, or CON_Out strings cannot be longer than this. Remark that this number does NOT include the '/0' character at the end of a string. So if we create a string we do this char* mystring[CON_CHARS_PER_LINE + 1];

#define CON_BLINK_RATE   500
 

Cursor blink frequency in ms

#define CON_CHAR_BORDER   4
 

Border in pixels from the left margin to the first letter

#define CON_DEFAULT_PROMPT   "]"
 

Default prompt used at the commandline

#define CON_LINE_SCROLL   2
 

Scroll this many lines at a time (when pressing PGUP or PGDOWN)

#define CON_SCROLL_INDICATOR   "^"
 

Indicator showing that you scrolled up the history

#define CON_INS_CURSOR   "_"
 

Cursor shown if we are in insert mode

#define CON_OVR_CURSOR   "|"
 

Cursor shown if we are in overwrite mode

#define CON_DEFAULT_HIDEKEY   SDLK_ESCAPE
 

Defines the default hide key (that Hide()'s the console if pressed)

#define CON_OPENCLOSE_SPEED   25
 

Defines the opening/closing speed when the console switches from CON_CLOSED to CON_OPEN


Typedef Documentation

typedef struct console_information_td ConsoleInformation
 

This is a struct for each consoles data


Enumeration Type Documentation

anonymous enum
 

Enumeration values:
CON_CLOSED 
CON_CLOSING  The console is closed (and not shown)
CON_OPENING  The console is still open and visible but closing. After it has completely disappeared it changes to CON_CLOSED
CON_OPEN  The console is open and visible


Function Documentation

DECLSPEC SDL_Event* SDLCALL CON_Events SDL_Event *  event  ) 
 

Takes keys from the keyboard and inputs them to the console if the console isVisible(). If the event was not handled (i.e. WM events or unknown ctrl- or alt-sequences) the function returns the event for further processing. ***The prototype of this function will change in the next major release to int CON_Events(ConsoleInformation* console, SDL_Event *event) **

DECLSPEC void SDLCALL CON_Show ConsoleInformation console  ) 
 

Makes the console visible

DECLSPEC void SDLCALL CON_Hide ConsoleInformation console  ) 
 

Hides the console

DECLSPEC int SDLCALL CON_isVisible ConsoleInformation console  ) 
 

Returns 1 if the console is opening or open, 0 else

DECLSPEC void SDLCALL CON_UpdateOffset ConsoleInformation console  ) 
 

Internal: Updates visible state. This function is responsible for the opening/closing animation. Only used in CON_DrawConsole()

DECLSPEC void SDLCALL CON_DrawConsole ConsoleInformation console  ) 
 

Draws the console to the screen if it is visible (NOT if it isVisible()). It get's drawn if it is REALLY visible ;-)

DECLSPEC ConsoleInformation* SDLCALL CON_Init const char *  FontName,
SDL_Surface *  DisplayScreen,
int  lines,
SDL_Rect  rect
 

Initializes a new console.

Parameters:
FontName A filename of an image containing the font. Look at the example code for the image contents
DisplayScreen The VideoSurface we are blitting to. ***This was not a very intelligent move. I will change this in the next major release. CON_DrawConsole will then no more blit the console to this surface but give you a pointer to ConsoleSurface when all updates are done***
lines The total number of lines in the history
rect Position and size of the new console

DECLSPEC void SDLCALL CON_Destroy ConsoleInformation console  ) 
 

Frees DT_DrawText and calls CON_Free

DECLSPEC void SDLCALL CON_Free ConsoleInformation console  ) 
 

Frees all the memory loaded by the console

DECLSPEC void SDLCALL CON_Out ConsoleInformation console,
const char *  str,
... 
 

Function to send text to the console. Works exactly like printf and supports the same format

DECLSPEC void SDLCALL CON_Alpha ConsoleInformation console,
unsigned char  alpha
 

Sets the alpha level of the console to the specified value (0 - transparent, 255 - opaque). Use this function also for OpenGL.

DECLSPEC void SDLCALL CON_AlphaGL SDL_Surface *  s,
int  alpha
 

Internal: Sets the alpha channel of an SDL_Surface to the specified value. Preconditions: the surface in question is RGBA. 0 <= a <= 255, where 0 is transparent and 255 opaque

DECLSPEC int SDLCALL CON_Background ConsoleInformation console,
const char *  image,
int  x,
int  y
 

Sets a background image for the console

DECLSPEC void SDLCALL CON_Position ConsoleInformation console,
int  x,
int  y
 

Changes current position of the console to the new given coordinates

DECLSPEC int SDLCALL CON_Resize ConsoleInformation console,
SDL_Rect  rect
 

Changes the size of the console

DECLSPEC int SDLCALL CON_Transfer ConsoleInformation console,
SDL_Surface *  new_outputscreen,
SDL_Rect  rect
 

Beams a console to another screen surface. Needed if you want to make a Video restart in your program. This function first changes the OutputScreen Pointer then calls CON_Resize to adjust the new size. ***Will disappear in the next major release. Instead i will introduce a new function called CON_ReInit or something that adjusts the internal parameters etc ***

DECLSPEC void SDLCALL CON_Topmost ConsoleInformation console  ) 
 

Give focus to a console. Make it the "topmost" console. This console will receive events sent with CON_Events() ***Will disappear in the next major release. There is no need for such a focus model ***

DECLSPEC void SDLCALL CON_SetPrompt ConsoleInformation console,
char *  newprompt
 

Modify the prompt of the console. If you want a backslash you will have to escape it.

DECLSPEC void SDLCALL CON_SetHideKey ConsoleInformation console,
int  key
 

Set the key, that invokes a CON_Hide() after press. default is ESCAPE and you can always hide using ESCAPE and the HideKey (2 keys for hiding). compared against event->key.keysym.sym !!

DECLSPEC void SDLCALL CON_Execute ConsoleInformation console,
char *  command
 

Internal: executes the command typed in at the console (called if you press 'Return')

DECLSPEC void SDLCALL CON_SetExecuteFunction ConsoleInformation console,
void(*  CmdFunction)(ConsoleInformation *console2, char *command)
 

Sets the callback function that is called if a command was typed in. The function you would like to use as the callback will have to look like this:
void my_command_handler(ConsoleInformation* console, char* command)

You will then call the function like this:
CON_SetExecuteFunction(console, my_command_handler)

If this is not clear look at the example program

DECLSPEC void SDLCALL CON_SetTabCompletion ConsoleInformation console,
char *(*  TabFunction)(char *command)
 

Sets the callback function that is called if you press the 'Tab' key. The function has to look like this:
char* my_tabcompletion(char* command)

The commandline on the left side of the cursor gets passed over to your function. You will then have to make your own tab-complete and return the completed string as return value. If you have nothing to complete you can return NULL or the string you got. ***Will change in the next major release to char* mytabfunction(ConsoleInformation* console, char* command) ***

DECLSPEC void SDLCALL CON_TabCompletion ConsoleInformation console  ) 
 

Internal: Gets called when TAB was pressed and executes the function you have earlier registered with CON_SetTabCompletion()

DECLSPEC void SDLCALL CON_NewLineConsole ConsoleInformation console  ) 
 

Internal: makes a newline (same as printf("\n") or CON_Out(console, "\n") )

DECLSPEC void SDLCALL CON_NewLineCommand ConsoleInformation console  ) 
 

Internal: shift command history (the one you can switch with the up/down keys)

DECLSPEC void SDLCALL CON_UpdateConsole ConsoleInformation console  ) 
 

Internal: updates console after resize, background image change, CON_Out() etc. This function draws the upper part of the console (that holds the history)

DECLSPEC void SDLCALL Default_CmdFunction ConsoleInformation console,
char *  command
 

Internal: Default Execute callback

DECLSPEC char* SDLCALL Default_TabFunction char *  command  ) 
 

Internal: Default TabCompletion callback

DECLSPEC void SDLCALL DrawCommandLine  ) 
 

Internal: draws the commandline the user is typing in to the screen. Called from within CON_DrawConsole() *** Will change in the next major release to void DrawCommandLine(ConsoleInformation* console) ***

DECLSPEC void SDLCALL Cursor_Left ConsoleInformation console  ) 
 

Internal: Gets called if you press the LEFT key (move cursor left)

DECLSPEC void SDLCALL Cursor_Right ConsoleInformation console  ) 
 

Internal: Gets called if you press the RIGHT key (move cursor right)

DECLSPEC void SDLCALL Cursor_Home ConsoleInformation console  ) 
 

Internal: Gets called if you press the HOME key (move cursor to the beginning of the line

DECLSPEC void SDLCALL Cursor_End ConsoleInformation console  ) 
 

Internal: Gets called if you press the END key (move cursor to the end of the line

DECLSPEC void SDLCALL Cursor_Del ConsoleInformation console  ) 
 

Internal: Called if you press DELETE (deletes character under the cursor)

DECLSPEC void SDLCALL Cursor_BSpace ConsoleInformation console  ) 
 

Internal: Called if you press BACKSPACE (deletes character left of cursor)

DECLSPEC void SDLCALL Cursor_Add ConsoleInformation console,
SDL_Event *  event
 

Internal: Called if you type in a character (add the char to the command)

DECLSPEC void SDLCALL Clear_Command ConsoleInformation console  ) 
 

Internal: Called if you press Ctrl-C (deletes the commandline)

DECLSPEC void SDLCALL Assemble_Command ConsoleInformation console  ) 
 

Internal: Called if the command line has changed (assemles console->Command from LCommand and RCommand

DECLSPEC void SDLCALL Clear_History ConsoleInformation console  ) 
 

Internal: Called if you press Ctrl-L (deletes the History)

DECLSPEC void SDLCALL Command_Up ConsoleInformation console  ) 
 

Internal: Called if you press UP key (switches through recent typed in commands

DECLSPEC void SDLCALL Command_Down ConsoleInformation console  ) 
 

Internal: Called if you press DOWN key (switches through recent typed in commands


Generated on Sun Aug 31 14:24:33 2003 for SDL Console by doxygen 1.3.2