FS2_Open
Open source remastering of the Freespace 2 engine
|
#include "debugconsole/console.h"
#include "globalincs/alphacolors.h"
#include "globalincs/version.h"
#include "graphics/2d.h"
#include "graphics/font.h"
#include "io/key.h"
#include "io/timer.h"
#include "osapi/osapi.h"
#include <algorithm>
#include <cmath>
Go to the source code of this file.
Macros | |
#define | SCROLL_X_MAX (DBCOLS - DCOLS) |
#define | SCROLL_Y_MAX (DBROWS - DROWS) |
Functions | |
void | dc_init (void) |
Initializes the debug console. More... | |
void | dc_do_command (SCP_string *cmd_str) |
Process the entered command string. More... | |
void | dc_draw (bool show_prompt) |
Draws the in-game console. More... | |
void | dc_draw_cursor (SCP_string &cmd_string, int x, int y) |
void | dc_draw_window (bool show_prompt) |
void | dc_putc (char c) |
Stuffs the given character into the output buffer. More... | |
bool | dcmd_less (debug_command *first, debug_command *second) |
Predicate function used to sort debug_commands. More... | |
bool | dc_pause_output (void) |
Pauses the output of a command and allows user to scroll through the output history. More... | |
void | dc_printf (const char *format,...) |
Prints the given char string to the debug console. More... | |
void | debug_console (void(*_func)(void)) |
Opens and processes the debug console. (Blocking call) More... | |
Variables | |
bool | Dc_debug_on |
Flag used to print console and command debugging strings. More... | |
SCP_string | dc_command_str |
Is progressively culled from the left as commands, arguments are parsed in DCF's. More... | |
bool | debug_inited = FALSE |
uint | lastline = 0 |
uint | DBROWS = 80 |
uint | DBCOLS = 80 |
uint | lastwhite = 0 |
ubyte | DTABS = 4 |
Tab size in spaces. More... | |
SCP_deque< SCP_string > | dc_buffer |
uint | DROWS = 25 |
uint | DCOLS = 80 |
const uint | DROWS_MIN = 25 |
const uint | DCOLS_MIN = 80 |
uint | dc_scroll_x |
uint | dc_scroll_y |
int | row_height |
int | col_width |
int | dc_font = FONT1 |
SCP_string | dc_title |
uint | DCMDS = 40 |
SCP_deque< SCP_string > | dc_history |
SCP_deque< SCP_string >::iterator | last_oldcommand |
const char | dc_prompt [] = "> " |
SCP_string | dc_command_buf |
Definition at line 73 of file console.cpp.
Definition at line 74 of file console.cpp.
void dc_do_command | ( | SCP_string * | cmd_str | ) |
Process the entered command string.
Grab the first word from the cmd_str If it is not a literal, ignore it "Invalid keyword: %s" Search for the command... Compare the word against valid commands If command not found, ignore it "Invalid or unknown command: %s"\ Process the command... Call the function to process the command (the rest of the command line is in the parser) Function takes care of long_help and status depending on the mode.
Definition at line 126 of file console.cpp.
Draws the in-game console.
Definition at line 185 of file console.cpp.
void dc_draw_cursor | ( | SCP_string & | cmd_string, |
int | x, | ||
int | y | ||
) |
Draws the cursor
[in] | cmd_string | The formatted command string displayed by dc_draw_window |
[in] | x | The x screen position of the command string |
[in] | y | The y screen position of the command string |
Definition at line 199 of file console.cpp.
void dc_draw_window | ( | bool | show_prompt | ) |
Draws the window text
Definition at line 214 of file console.cpp.
Initializes the debug console.
Definition at line 271 of file console.cpp.
bool dc_pause_output | ( | void | ) |
Pauses the output of a command and allows user to scroll through the output history.
Returns true if user has pressed Esc, returns false otherwise. Use this in your function to (safely?) break out of the loop it's presumably in.
Definition at line 306 of file console.cpp.
void dc_printf | ( | const char * | format, |
... | |||
) |
Prints the given char string to the debug console.
See the doc for std::printf() for formating and more details
Definition at line 358 of file console.cpp.
void dc_putc | ( | char | c | ) |
Stuffs the given character into the output buffer.
Also handles tab alignment, newlines, and maintains the target.
Push c onto the temp_str and get its gr_string width
If we run out of room on the line, or If we run out of room on the screen, change c to a '
' and let subsequent block handle it, Else, push the space onto the line and bail
Calculate how many spaces to put in to align tabs, Append temp_str with the spaces and get its gr_string width
If we run out of room on the line, or If we run out of room on the screen, change c to a '
' and let subsequent block handle it, Else, copy temp_str onto the line, update the lastwhite index, and bail
Trash whatever char happens to be past (DBCOLS - 1), Push a blank line onto the dc_buffer from the bottom, Increment the scroller, if needed, Trash the topmost line(s) in the buffer, Reset the lastwhite index, Increment the lastline counter, and finally bail
Word wrapping Save the word, clear the line of the word, push new line with the word on it Update scroll_y, if needed, Pop off old lines, and finally Push new character onto the new line
Definition at line 373 of file console.cpp.
bool dcmd_less | ( | debug_command * | first, |
debug_command * | second | ||
) |
Predicate function used to sort debug_commands.
Definition at line 490 of file console.cpp.
Opens and processes the debug console. (Blocking call)
TODO: Make this a non-blocking call so that the game can still run while the debug console is open.
Definition at line 495 of file console.cpp.
int col_width |
Definition at line 68 of file console.cpp.
uint DBCOLS = 80 |
Definition at line 38 of file console.cpp.
uint DBROWS = 80 |
Definition at line 37 of file console.cpp.
SCP_deque<SCP_string> dc_buffer |
Definition at line 58 of file console.cpp.
SCP_string dc_command_buf |
Definition at line 83 of file console.cpp.
SCP_string dc_command_str |
Is progressively culled from the left as commands, arguments are parsed in DCF's.
The entered command line, arguments and all.
Definition at line 27 of file console.cpp.
bool Dc_debug_on |
Flag used to print console and command debugging strings.
Definition at line 24 of file console.cpp.
Definition at line 69 of file console.cpp.
SCP_deque<SCP_string> dc_history |
Definition at line 79 of file console.cpp.
const char dc_prompt[] = "> " |
Definition at line 82 of file console.cpp.
uint dc_scroll_x |
Definition at line 65 of file console.cpp.
uint dc_scroll_y |
Definition at line 66 of file console.cpp.
SCP_string dc_title |
Definition at line 71 of file console.cpp.
uint DCMDS = 40 |
Definition at line 77 of file console.cpp.
uint DCOLS = 80 |
Definition at line 62 of file console.cpp.
const uint DCOLS_MIN = 80 |
Definition at line 64 of file console.cpp.
bool debug_inited = FALSE |
Definition at line 31 of file console.cpp.
uint DROWS = 25 |
Definition at line 61 of file console.cpp.
const uint DROWS_MIN = 25 |
Definition at line 63 of file console.cpp.
ubyte DTABS = 4 |
Tab size in spaces.
Definition at line 40 of file console.cpp.
SCP_deque<SCP_string>::iterator last_oldcommand |
Definition at line 80 of file console.cpp.
uint lastline = 0 |
Definition at line 32 of file console.cpp.
uint lastwhite = 0 |
Definition at line 39 of file console.cpp.
int row_height |
Definition at line 67 of file console.cpp.