src/console_gui.cpp
author Tero Marttila <terom@fixme.fi>
Tue, 22 Jul 2008 23:20:33 +0300
changeset 11184 88c967f1422b
parent 10687 7a2d9450e0e7
permissions -rw-r--r--
add an empty bin/cache dir
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
10429
1b99254f9607 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents: 10418
diff changeset
     3
/** @file console.cpp Handling of the in-game console. */
6449
e520244dc71e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6144
diff changeset
     4
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
     5
#include "stdafx.h"
1891
92a3b0aa0946 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1889
diff changeset
     6
#include "openttd.h"
8603
88c5ce6a5215 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8602
diff changeset
     7
#include "textbuf_gui.h"
88c5ce6a5215 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8602
diff changeset
     8
#include "window_gui.h"
10684
7cc2278c2ac0 (svn r13228) -Codechange: split console.h.
rubidium
parents: 10641
diff changeset
     9
#include "console_gui.h"
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    10
#include <stdarg.h>
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
    11
#include <string.h>
10684
7cc2278c2ac0 (svn r13228) -Codechange: split console.h.
rubidium
parents: 10641
diff changeset
    12
#include "console_internal.h"
8627
448ebf3a8291 (svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents: 8626
diff changeset
    13
#include "window_func.h"
8710
52015340050c (svn r11777) -Codechange: split the string header and make do not include it when it's not necessary.
rubidium
parents: 8627
diff changeset
    14
#include "string_func.h"
8720
4e60c30e2006 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8710
diff changeset
    15
#include "gfx_func.h"
10687
7a2d9450e0e7 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium
parents: 10685
diff changeset
    16
#include "core/math_func.hpp"
10402
b168fbb99f7c (svn r12944) -Codechange: use rev.h instead of externs at many places
smatz
parents: 8764
diff changeset
    17
#include "rev.h"
274
a56c9fe2832c (svn r280) -Fix: ^M removement in console.c
signde
parents: 273
diff changeset
    18
8760
ce0891c412ce (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8750
diff changeset
    19
#include "table/strings.h"
ce0891c412ce (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8750
diff changeset
    20
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
    21
#define ICON_BUFFER 79
1739
4f3082735fbc (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
    22
#define ICON_HISTORY_SIZE 20
301
f30c8c628dc6 (svn r307) -Fix: Several potential buffer-overflow fixes, and removal of 'magic-numbers' in favour of constants. (Tron)
darkvater
parents: 289
diff changeset
    23
#define ICON_LINE_HEIGHT 12
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
    24
#define ICON_RIGHT_BORDERWIDTH 10
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
    25
#define ICON_BOTTOM_BORDERWIDTH 12
634
88d9420048db (svn r1065) -Add: [Console] Alias support. Type 'list_aliases' to show them all (sign_de)
truelight
parents: 618
diff changeset
    26
#define ICON_MAX_ALIAS_LINES 40
1739
4f3082735fbc (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
    27
#define ICON_TOKEN_COUNT 20
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
    28
10685
955ddec7961e (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium
parents: 10684
diff changeset
    29
/* console modes */
8764
65746a5248ec (svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium
parents: 8760
diff changeset
    30
IConsoleModes _iconsole_mode;
65746a5248ec (svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium
parents: 8760
diff changeset
    31
6449
e520244dc71e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6144
diff changeset
    32
/* ** main console ** */
1739
4f3082735fbc (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
    33
static char *_iconsole_buffer[ICON_BUFFER + 1];
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
    34
static uint16 _iconsole_cbuffer[ICON_BUFFER + 1];
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1379
diff changeset
    35
static Textbuf _iconsole_cmdline;
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    36
6449
e520244dc71e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6144
diff changeset
    37
/* ** main console cmd buffer ** */
1739
4f3082735fbc (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
    38
static char *_iconsole_history[ICON_HISTORY_SIZE];
4f3082735fbc (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
    39
static byte _iconsole_historypos;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
    40
6449
e520244dc71e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6144
diff changeset
    41
/* *************** *
e520244dc71e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6144
diff changeset
    42
 *  end of header  *
e520244dc71e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6144
diff changeset
    43
 * *************** */
274
a56c9fe2832c (svn r280) -Fix: ^M removement in console.c
signde
parents: 273
diff changeset
    44
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6449
diff changeset
    45
static void IConsoleClearCommand()
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    46
{
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1379
diff changeset
    47
	memset(_iconsole_cmdline.buf, 0, ICON_CMDLN_SIZE);
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1379
diff changeset
    48
	_iconsole_cmdline.length = 0;
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1379
diff changeset
    49
	_iconsole_cmdline.width = 0;
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1379
diff changeset
    50
	_iconsole_cmdline.caretpos = 0;
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1379
diff changeset
    51
	_iconsole_cmdline.caretxoffs = 0;
5143
a78072872bff (svn r7233) -Codechange: get rid of three console.c globals
Darkvater
parents: 5137
diff changeset
    52
	SetWindowDirty(FindWindowById(WC_CONSOLE, 0));
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    53
}
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    54
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6449
diff changeset
    55
static inline void IConsoleResetHistoryPos() {_iconsole_historypos = ICON_HISTORY_SIZE - 1;}
1739
4f3082735fbc (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
    56
2817
58dcead3f545 (svn r3365) Staticise 36 functions
tron
parents: 2791
diff changeset
    57
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
    58
static void IConsoleHistoryAdd(const char *cmd);
2817
58dcead3f545 (svn r3365) Staticise 36 functions
tron
parents: 2791
diff changeset
    59
static void IConsoleHistoryNavigate(int direction);
58dcead3f545 (svn r3365) Staticise 36 functions
tron
parents: 2791
diff changeset
    60
10592
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
    61
struct IConsoleWindow : Window
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    62
{
10592
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
    63
	static byte scroll;
5143
a78072872bff (svn r7233) -Codechange: get rid of three console.c globals
Darkvater
parents: 5137
diff changeset
    64
10592
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
    65
	IConsoleWindow(const WindowDesc *desc) : Window(desc)
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
    66
	{
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
    67
		_iconsole_mode = ICONSOLE_OPENED;
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
    68
		SetBit(_no_scroll, SCROLL_CON); // override cursor arrows; the gamefield will not scroll
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
    69
10592
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
    70
		this->height = _screen.height / 3;
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
    71
		this->width  = _screen.width;
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
    72
	}
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1379
diff changeset
    73
10592
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
    74
	~IConsoleWindow()
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
    75
	{
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
    76
		_iconsole_mode = ICONSOLE_CLOSED;
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
    77
		ClrBit(_no_scroll, SCROLL_CON);
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
    78
	}
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
    79
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
    80
	virtual void OnPaint()
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
    81
	{
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
    82
		int i = IConsoleWindow::scroll;
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
    83
		int max = (this->height / ICON_LINE_HEIGHT) - 1;
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
    84
		int delta = 0;
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
    85
		GfxFillRect(this->left, this->top, this->width, this->height - 1, 0);
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
    86
		while ((i > 0) && (i > IConsoleWindow::scroll - max) && (_iconsole_buffer[i] != NULL)) {
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
    87
			DoDrawString(_iconsole_buffer[i], 5,
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
    88
				this->height - (IConsoleWindow::scroll + 2 - i) * ICON_LINE_HEIGHT, _iconsole_cbuffer[i]);
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
    89
			i--;
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
    90
		}
10592
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
    91
		/* If the text is longer than the window, don't show the starting ']' */
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
    92
		delta = this->width - 10 - _iconsole_cmdline.width - ICON_RIGHT_BORDERWIDTH;
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
    93
		if (delta > 0) {
10685
955ddec7961e (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium
parents: 10684
diff changeset
    94
			DoDrawString("]", 5, this->height - ICON_LINE_HEIGHT, CC_COMMAND);
10592
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
    95
			delta = 0;
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
    96
		}
672
d06d46264039 (svn r1110) -Fix: Empty console commands were executed and returned error message (sign_de for GeniusDex)
darkvater
parents: 659
diff changeset
    97
10685
955ddec7961e (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium
parents: 10684
diff changeset
    98
		DoDrawString(_iconsole_cmdline.buf, 10 + delta, this->height - ICON_LINE_HEIGHT, CC_COMMAND);
10592
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
    99
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   100
		if (_iconsole_cmdline.caret) {
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   101
			DoDrawString("_", 10 + delta + _iconsole_cmdline.caretxoffs, this->height - ICON_LINE_HEIGHT, TC_WHITE);
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   102
		}
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   103
	}
10592
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   104
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   105
	virtual void OnMouseLoop()
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   106
	{
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   107
		if (HandleCaret(&_iconsole_cmdline)) this->SetDirty();
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   108
	}
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   109
10607
1ab30cead125 (svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
rubidium
parents: 10592
diff changeset
   110
	virtual EventState OnKeyPress(uint16 key, uint16 keycode)
10592
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   111
	{
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   112
		switch (keycode) {
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   113
			case WKC_UP:
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   114
				IConsoleHistoryNavigate(+1);
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   115
				this->SetDirty();
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   116
				break;
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   117
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   118
			case WKC_DOWN:
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   119
				IConsoleHistoryNavigate(-1);
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   120
				this->SetDirty();
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   121
				break;
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   122
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   123
			case WKC_SHIFT | WKC_PAGEUP:
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   124
				if (IConsoleWindow::scroll - (this->height / ICON_LINE_HEIGHT) - 1 < 0) {
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   125
					IConsoleWindow::scroll = 0;
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   126
				} else {
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   127
					IConsoleWindow::scroll -= (this->height / ICON_LINE_HEIGHT) - 1;
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   128
				}
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   129
				this->SetDirty();
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   130
				break;
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   131
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   132
			case WKC_SHIFT | WKC_PAGEDOWN:
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   133
				if (IConsoleWindow::scroll + (this->height / ICON_LINE_HEIGHT) - 1 > ICON_BUFFER) {
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   134
					IConsoleWindow::scroll = ICON_BUFFER;
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   135
				} else {
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   136
					IConsoleWindow::scroll += (this->height / ICON_LINE_HEIGHT) - 1;
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   137
				}
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   138
				this->SetDirty();
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   139
				break;
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   140
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   141
			case WKC_SHIFT | WKC_UP:
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   142
				if (IConsoleWindow::scroll <= 0) {
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   143
					IConsoleWindow::scroll = 0;
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   144
				} else {
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   145
					--IConsoleWindow::scroll;
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   146
				}
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   147
				this->SetDirty();
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   148
				break;
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   149
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   150
			case WKC_SHIFT | WKC_DOWN:
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   151
				if (IConsoleWindow::scroll >= ICON_BUFFER) {
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   152
					IConsoleWindow::scroll = ICON_BUFFER;
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   153
				} else {
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   154
					++IConsoleWindow::scroll;
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   155
				}
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   156
				this->SetDirty();
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   157
				break;
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   158
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   159
			case WKC_BACKQUOTE:
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   160
				IConsoleSwitch();
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   161
				break;
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   162
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   163
			case WKC_RETURN: case WKC_NUM_ENTER:
10685
955ddec7961e (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium
parents: 10684
diff changeset
   164
				IConsolePrintF(CC_COMMAND, "] %s", _iconsole_cmdline.buf);
10592
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   165
				IConsoleHistoryAdd(_iconsole_cmdline.buf);
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   166
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   167
				IConsoleCmdExec(_iconsole_cmdline.buf);
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   168
				IConsoleClearCommand();
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   169
				break;
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   170
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   171
			case WKC_CTRL | WKC_RETURN:
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   172
				_iconsole_mode = (_iconsole_mode == ICONSOLE_FULL) ? ICONSOLE_OPENED : ICONSOLE_FULL;
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   173
				IConsoleResize(this);
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   174
				MarkWholeScreenDirty();
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   175
				break;
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   176
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   177
			case (WKC_CTRL | 'V'):
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   178
				if (InsertTextBufferClipboard(&_iconsole_cmdline)) {
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   179
					IConsoleResetHistoryPos();
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   180
					this->SetDirty();
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   181
				}
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   182
				break;
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   183
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   184
			case (WKC_CTRL | 'L'):
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   185
				IConsoleCmdExec("clear");
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   186
				break;
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   187
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   188
			case (WKC_CTRL | 'U'):
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   189
				DeleteTextBufferAll(&_iconsole_cmdline);
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   190
				this->SetDirty();
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   191
				break;
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   192
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   193
			case WKC_BACKSPACE: case WKC_DELETE:
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   194
				if (DeleteTextBufferChar(&_iconsole_cmdline, keycode)) {
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   195
					IConsoleResetHistoryPos();
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   196
					this->SetDirty();
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   197
				}
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   198
				break;
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   199
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   200
			case WKC_LEFT: case WKC_RIGHT: case WKC_END: case WKC_HOME:
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   201
				if (MoveTextBufferPos(&_iconsole_cmdline, keycode)) {
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   202
					IConsoleResetHistoryPos();
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   203
					this->SetDirty();
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   204
				}
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   205
				break;
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   206
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   207
			default:
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   208
				if (IsValidChar(key, CS_ALPHANUMERAL)) {
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   209
					IConsoleWindow::scroll = ICON_BUFFER;
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   210
					InsertTextBufferChar(&_iconsole_cmdline, key);
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   211
					IConsoleResetHistoryPos();
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   212
					this->SetDirty();
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   213
				} else {
10607
1ab30cead125 (svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
rubidium
parents: 10592
diff changeset
   214
					return ES_NOT_HANDLED;
10592
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   215
				}
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   216
		}
10607
1ab30cead125 (svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
rubidium
parents: 10592
diff changeset
   217
		return ES_HANDLED;
10592
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   218
	}
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   219
};
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   220
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   221
byte IConsoleWindow::scroll = ICON_BUFFER;
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   222
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1379
diff changeset
   223
static const Widget _iconsole_window_widgets[] = {
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1379
diff changeset
   224
	{WIDGETS_END}
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1379
diff changeset
   225
};
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1379
diff changeset
   226
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1379
diff changeset
   227
static const WindowDesc _iconsole_window_desc = {
7837
65d7362153a6 (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7527
diff changeset
   228
	0, 0, 2, 2, 2, 2,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5860
diff changeset
   229
	WC_CONSOLE, WC_NONE,
8515
d0401d967e99 (svn r11579) -Revert(r11578): some cases of key propagation are not handled correctly.
belugas
parents: 8514
diff changeset
   230
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1379
diff changeset
   231
	_iconsole_window_widgets,
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1379
diff changeset
   232
};
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1379
diff changeset
   233
10687
7a2d9450e0e7 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium
parents: 10685
diff changeset
   234
void IConsoleGUIInit()
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   235
{
1739
4f3082735fbc (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   236
	_iconsole_historypos = ICON_HISTORY_SIZE - 1;
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   237
	_iconsole_mode = ICONSOLE_CLOSED;
1243
dda9f676e081 (svn r1747) - Fix: [network] ottd should compile when networking is disabled.
darkvater
parents: 1230
diff changeset
   238
1739
4f3082735fbc (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   239
	memset(_iconsole_history, 0, sizeof(_iconsole_history));
1243
dda9f676e081 (svn r1747) - Fix: [network] ottd should compile when networking is disabled.
darkvater
parents: 1230
diff changeset
   240
	memset(_iconsole_buffer, 0, sizeof(_iconsole_buffer));
dda9f676e081 (svn r1747) - Fix: [network] ottd should compile when networking is disabled.
darkvater
parents: 1230
diff changeset
   241
	memset(_iconsole_cbuffer, 0, sizeof(_iconsole_cbuffer));
5860
7fdc9b423ba1 (svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents: 5838
diff changeset
   242
	_iconsole_cmdline.buf = CallocT<char>(ICON_CMDLN_SIZE); // create buffer and zero it
3458
d3a6ddfa6784 (svn r4301) - Fix: the maxlength parameter of Textbuf is supposed to be the size of the buffer (so length of string + '\0'), but in the code it was a mix of both. It didn't cause any problems though, only an occasionaly one-less character than allowed. (thanks Tron for noticing)
Darkvater
parents: 3017
diff changeset
   243
	_iconsole_cmdline.maxlength = ICON_CMDLN_SIZE;
1243
dda9f676e081 (svn r1747) - Fix: [network] ottd should compile when networking is disabled.
darkvater
parents: 1230
diff changeset
   244
10685
955ddec7961e (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium
parents: 10684
diff changeset
   245
	IConsolePrintF(CC_WARNING, "OpenTTD Game Console Revision 7 - %s", _openttd_revision);
955ddec7961e (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium
parents: 10684
diff changeset
   246
	IConsolePrint(CC_WHITE,  "------------------------------------");
955ddec7961e (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium
parents: 10684
diff changeset
   247
	IConsolePrint(CC_WHITE,  "use \"help\" for more information");
955ddec7961e (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium
parents: 10684
diff changeset
   248
	IConsolePrint(CC_WHITE,  "");
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   249
	IConsoleClearCommand();
1739
4f3082735fbc (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   250
	IConsoleHistoryAdd("");
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   251
}
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   252
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6449
diff changeset
   253
void IConsoleClearBuffer()
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   254
{
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   255
	uint i;
1827
b8a0edd6eb89 (svn r2332) - Feature: Add 'clear' command and CTRL+L to empty the console window
Darkvater
parents: 1819
diff changeset
   256
	for (i = 0; i <= ICON_BUFFER; i++) {
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   257
		free(_iconsole_buffer[i]);
1827
b8a0edd6eb89 (svn r2332) - Feature: Add 'clear' command and CTRL+L to empty the console window
Darkvater
parents: 1819
diff changeset
   258
		_iconsole_buffer[i] = NULL;
b8a0edd6eb89 (svn r2332) - Feature: Add 'clear' command and CTRL+L to empty the console window
Darkvater
parents: 1819
diff changeset
   259
	}
b8a0edd6eb89 (svn r2332) - Feature: Add 'clear' command and CTRL+L to empty the console window
Darkvater
parents: 1819
diff changeset
   260
}
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1379
diff changeset
   261
10687
7a2d9450e0e7 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium
parents: 10685
diff changeset
   262
void IConsoleGUIFree()
1827
b8a0edd6eb89 (svn r2332) - Feature: Add 'clear' command and CTRL+L to empty the console window
Darkvater
parents: 1819
diff changeset
   263
{
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1379
diff changeset
   264
	free(_iconsole_cmdline.buf);
1827
b8a0edd6eb89 (svn r2332) - Feature: Add 'clear' command and CTRL+L to empty the console window
Darkvater
parents: 1819
diff changeset
   265
	IConsoleClearBuffer();
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   266
}
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   267
5143
a78072872bff (svn r7233) -Codechange: get rid of three console.c globals
Darkvater
parents: 5137
diff changeset
   268
void IConsoleResize(Window *w)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   269
{
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   270
	switch (_iconsole_mode) {
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   271
		case ICONSOLE_OPENED:
5143
a78072872bff (svn r7233) -Codechange: get rid of three console.c globals
Darkvater
parents: 5137
diff changeset
   272
			w->height = _screen.height / 3;
a78072872bff (svn r7233) -Codechange: get rid of three console.c globals
Darkvater
parents: 5137
diff changeset
   273
			w->width = _screen.width;
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   274
			break;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   275
		case ICONSOLE_FULL:
5143
a78072872bff (svn r7233) -Codechange: get rid of three console.c globals
Darkvater
parents: 5137
diff changeset
   276
			w->height = _screen.height - ICON_BOTTOM_BORDERWIDTH;
a78072872bff (svn r7233) -Codechange: get rid of three console.c globals
Darkvater
parents: 5137
diff changeset
   277
			w->width = _screen.width;
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   278
			break;
5120
e12dfc67761f (svn r7200) -Codechange: remove unneeded redraw (console.c), coding style, use FindWindowById
Darkvater
parents: 5108
diff changeset
   279
		default: return;
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   280
	}
986
239603c9dd34 (svn r1484) -Fix: [1099197] scrolling through console sometimes crashed the whole game. Also added MarkWholeScreenDirty() to have redrawing of console resize instant (sign_de)
darkvater
parents: 959
diff changeset
   281
239603c9dd34 (svn r1484) -Fix: [1099197] scrolling through console sometimes crashed the whole game. Also added MarkWholeScreenDirty() to have redrawing of console resize instant (sign_de)
darkvater
parents: 959
diff changeset
   282
	MarkWholeScreenDirty();
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   283
}
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   284
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6449
diff changeset
   285
void IConsoleSwitch()
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   286
{
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   287
	switch (_iconsole_mode) {
10592
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   288
		case ICONSOLE_CLOSED:
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   289
			new IConsoleWindow(&_iconsole_window_desc);
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   290
			break;
ee1b9e621589 (svn r13136) -Codechange: make a window class of the console window.
rubidium
parents: 10461
diff changeset
   291
1397
b04402b901cd (svn r1901) - Fix: unwanted behaviour of the savegame dialog, as well as a bug with a sloppy termination of a string. When any editbox is open, scrolling is disabled. If any new types of editboxes come up, please use SET/CLRBIT of _no_scroll with its unique identifier (ttd.h)
Darkvater
parents: 1390
diff changeset
   292
		case ICONSOLE_OPENED: case ICONSOLE_FULL:
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   293
			DeleteWindowById(WC_CONSOLE, 0);
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 518
diff changeset
   294
			break;
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   295
	}
986
239603c9dd34 (svn r1484) -Fix: [1099197] scrolling through console sometimes crashed the whole game. Also added MarkWholeScreenDirty() to have redrawing of console resize instant (sign_de)
darkvater
parents: 959
diff changeset
   296
239603c9dd34 (svn r1484) -Fix: [1099197] scrolling through console sometimes crashed the whole game. Also added MarkWholeScreenDirty() to have redrawing of console resize instant (sign_de)
darkvater
parents: 959
diff changeset
   297
	MarkWholeScreenDirty();
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   298
}
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   299
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6449
diff changeset
   300
void IConsoleClose() {if (_iconsole_mode == ICONSOLE_OPENED) IConsoleSwitch();}
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6449
diff changeset
   301
void IConsoleOpen()  {if (_iconsole_mode == ICONSOLE_CLOSED) IConsoleSwitch();}
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   302
1739
4f3082735fbc (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   303
/**
4f3082735fbc (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   304
 * Add the entered line into the history so you can look it back
4f3082735fbc (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   305
 * scroll, etc. Put it to the beginning as it is the latest text
4f3082735fbc (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   306
 * @param cmd Text to be entered into the 'history'
4f3082735fbc (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   307
 */
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   308
static void IConsoleHistoryAdd(const char *cmd)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   309
{
1739
4f3082735fbc (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   310
	free(_iconsole_history[ICON_HISTORY_SIZE - 1]);
141
29cc31c87ede (svn r142) -Feature development: [1016299] Console Rev #3 allowes variable references and has a new commandline buffer (sign_de)
darkvater
parents: 136
diff changeset
   311
1739
4f3082735fbc (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   312
	memmove(&_iconsole_history[1], &_iconsole_history[0], sizeof(_iconsole_history[0]) * (ICON_HISTORY_SIZE - 1));
4f3082735fbc (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   313
	_iconsole_history[0] = strdup(cmd);
4f3082735fbc (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   314
	IConsoleResetHistoryPos();
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   315
}
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   316
1739
4f3082735fbc (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   317
/**
4f3082735fbc (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   318
 * Navigate Up/Down in the history of typed commands
4f3082735fbc (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   319
 * @param direction Go further back in history (+1), go to recently typed commands (-1)
4f3082735fbc (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   320
 */
2817
58dcead3f545 (svn r3365) Staticise 36 functions
tron
parents: 2791
diff changeset
   321
static void IConsoleHistoryNavigate(int direction)
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   322
{
1739
4f3082735fbc (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   323
	int i = _iconsole_historypos + direction;
4f3082735fbc (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   324
6449
e520244dc71e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6144
diff changeset
   325
	/* watch out for overflows, just wrap around */
1739
4f3082735fbc (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   326
	if (i < 0) i = ICON_HISTORY_SIZE - 1;
4f3082735fbc (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   327
	if (i >= ICON_HISTORY_SIZE) i = 0;
4f3082735fbc (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   328
10687
7a2d9450e0e7 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium
parents: 10685
diff changeset
   329
	if (direction > 0) {
1739
4f3082735fbc (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   330
		if (_iconsole_history[i] == NULL) i = 0;
10687
7a2d9450e0e7 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium
parents: 10685
diff changeset
   331
	}
1739
4f3082735fbc (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   332
4f3082735fbc (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   333
	if (direction < 0) {
4f3082735fbc (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   334
		while (i > 0 && _iconsole_history[i] == NULL) i--;
4f3082735fbc (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   335
	}
4f3082735fbc (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   336
4f3082735fbc (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   337
	_iconsole_historypos = i;
220
dc1710f96b39 (svn r221) -Feature: console command and variable hooking
signde
parents: 209
diff changeset
   338
	IConsoleClearCommand();
6449
e520244dc71e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6144
diff changeset
   339
	/* copy history to 'command prompt / bash' */
8450
dce58137301f (svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents: 8427
diff changeset
   340
	assert(_iconsole_history[i] != NULL && IsInsideMM(i, 0, ICON_HISTORY_SIZE));
1739
4f3082735fbc (svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents: 1726
diff changeset
   341
	ttd_strlcpy(_iconsole_cmdline.buf, _iconsole_history[i], _iconsole_cmdline.maxlength);
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1379
diff changeset
   342
	UpdateTextBufferSize(&_iconsole_cmdline);
141
29cc31c87ede (svn r142) -Feature development: [1016299] Console Rev #3 allowes variable references and has a new commandline buffer (sign_de)
darkvater
parents: 136
diff changeset
   343
}
29cc31c87ede (svn r142) -Feature development: [1016299] Console Rev #3 allowes variable references and has a new commandline buffer (sign_de)
darkvater
parents: 136
diff changeset
   344
1588
5cb399cb05e5 (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like ??, etc. Diff approved by the code-police.
Darkvater
parents: 1483
diff changeset
   345
/**
5cb399cb05e5 (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like ??, etc. Diff approved by the code-police.
Darkvater
parents: 1483
diff changeset
   346
 * Handle the printing of text entered into the console or redirected there
5cb399cb05e5 (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like ??, etc. Diff approved by the code-police.
Darkvater
parents: 1483
diff changeset
   347
 * by any other means. Text can be redirected to other players in a network game
5cb399cb05e5 (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like ??, etc. Diff approved by the code-police.
Darkvater
parents: 1483
diff changeset
   348
 * as well as to a logfile. If the network server is a dedicated server, all activities
5cb399cb05e5 (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like ??, etc. Diff approved by the code-police.
Darkvater
parents: 1483
diff changeset
   349
 * are also logged. All lines to print are added to a temporary buffer which can be
5cb399cb05e5 (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like ??, etc. Diff approved by the code-police.
Darkvater
parents: 1483
diff changeset
   350
 * used as a history to print them onscreen
5cb399cb05e5 (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like ??, etc. Diff approved by the code-police.
Darkvater
parents: 1483
diff changeset
   351
 * @param color_code the colour of the command. Red in case of errors, etc.
5cb399cb05e5 (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like ??, etc. Diff approved by the code-police.
Darkvater
parents: 1483
diff changeset
   352
 * @param string the message entered or output on the console (notice, error, etc.)
5cb399cb05e5 (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like ??, etc. Diff approved by the code-police.
Darkvater
parents: 1483
diff changeset
   353
 */
10687
7a2d9450e0e7 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium
parents: 10685
diff changeset
   354
void IConsoleGUIPrint(ConsoleColour color_code, char *str)
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   355
{
1588
5cb399cb05e5 (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like ??, etc. Diff approved by the code-police.
Darkvater
parents: 1483
diff changeset
   356
	/* move up all the strings in the buffer one place and do the same for colour
5cb399cb05e5 (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like ??, etc. Diff approved by the code-police.
Darkvater
parents: 1483
diff changeset
   357
	 * to accomodate for the new command/message */
5cb399cb05e5 (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like ??, etc. Diff approved by the code-police.
Darkvater
parents: 1483
diff changeset
   358
	free(_iconsole_buffer[0]);
5cb399cb05e5 (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like ??, etc. Diff approved by the code-police.
Darkvater
parents: 1483
diff changeset
   359
	memmove(&_iconsole_buffer[0], &_iconsole_buffer[1], sizeof(_iconsole_buffer[0]) * ICON_BUFFER);
5182
bd91899f118e (svn r7292) -Codechange: Also validate an strip of colours the console string passed to the dedicated
Darkvater
parents: 5143
diff changeset
   360
	_iconsole_buffer[ICON_BUFFER] = str;
1588
5cb399cb05e5 (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like ??, etc. Diff approved by the code-police.
Darkvater
parents: 1483
diff changeset
   361
5cb399cb05e5 (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like ??, etc. Diff approved by the code-police.
Darkvater
parents: 1483
diff changeset
   362
	memmove(&_iconsole_cbuffer[0], &_iconsole_cbuffer[1], sizeof(_iconsole_cbuffer[0]) * ICON_BUFFER);
5cb399cb05e5 (svn r2092) - Fix: old commands/lines in the console (history) did not show when they used 'special' characters like ??, etc. Diff approved by the code-police.
Darkvater
parents: 1483
diff changeset
   363
	_iconsole_cbuffer[ICON_BUFFER] = color_code;
289
1e1102dd2a62 (svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
darkvater
parents: 274
diff changeset
   364
5143
a78072872bff (svn r7233) -Codechange: get rid of three console.c globals
Darkvater
parents: 5137
diff changeset
   365
	SetWindowDirty(FindWindowById(WC_CONSOLE, 0));
135
638fb31434eb (svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents: 129
diff changeset
   366
}