annotate src/console_gui.cpp @ 13792:a998faa00d15 draft

(svn r18318) -Codechange: add an enum value for manual window placement
author rubidium <rubidium@openttd.org>
date Sat, 28 Nov 2009 13:54:28 +0000 (2009-11-28)
parents 2123810ad874
children 3e68f07eb821
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
1 /* $Id$ */
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
2
12778
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12582
diff changeset
3 /*
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12582
diff changeset
4 * This file is part of OpenTTD.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12582
diff changeset
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12582
diff changeset
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12582
diff changeset
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12582
diff changeset
8 */
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12582
diff changeset
9
10238
12805d675e85 (svn r14466) -Doc: remove some obsolete parameters, fix a few parameter names in comments and add a little more doxygen documentation.
rubidium <rubidium@openttd.org>
parents: 10207
diff changeset
10 /** @file console_gui.cpp Handling the GUI of the in-game console. */
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
11
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
12 #include "stdafx.h"
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
13 #include "textbuf_gui.h"
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
14 #include "window_gui.h"
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
15 #include "console_gui.h"
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
16 #include "console_internal.h"
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
17 #include "window_func.h"
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
18 #include "string_func.h"
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
19 #include "gfx_func.h"
9906
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
20 #include "settings_type.h"
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
21 #include "rev.h"
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
22
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
23
9906
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
24 enum {
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
25 ICON_HISTORY_SIZE = 20,
11640
46a1311409f3 (svn r16020) -Codechange: Use actual font height for console output instead of fixed value.
peter1138 <peter1138@openttd.org>
parents: 11533
diff changeset
26 ICON_LINE_SPACING = 2,
9906
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
27 ICON_RIGHT_BORDERWIDTH = 10,
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
28 ICON_BOTTOM_BORDERWIDTH = 12,
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
29 };
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
30
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
31 /**
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
32 * Container for a single line of console output
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
33 */
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
34 struct IConsoleLine {
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
35 static IConsoleLine *front; ///< The front of the console backlog buffer
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
36 static int size; ///< The amount of items in the backlog
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
37
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
38 IConsoleLine *previous; ///< The previous console message.
11082
9ec1f7eac0a0 (svn r15425) -Codechange: some color->colour changes and type safety.
rubidium <rubidium@openttd.org>
parents: 11081
diff changeset
39 char *buffer; ///< The data to store.
9ec1f7eac0a0 (svn r15425) -Codechange: some color->colour changes and type safety.
rubidium <rubidium@openttd.org>
parents: 11081
diff changeset
40 TextColour colour; ///< The colour of the line.
9ec1f7eac0a0 (svn r15425) -Codechange: some color->colour changes and type safety.
rubidium <rubidium@openttd.org>
parents: 11081
diff changeset
41 uint16 time; ///< The amount of time the line is in the backlog.
9906
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
42
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
43 /**
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
44 * Initialize the console line.
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
45 * @param buffer the data to print.
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
46 * @param colour the colour of the line.
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
47 */
11082
9ec1f7eac0a0 (svn r15425) -Codechange: some color->colour changes and type safety.
rubidium <rubidium@openttd.org>
parents: 11081
diff changeset
48 IConsoleLine(char *buffer, TextColour colour) :
9906
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
49 previous(IConsoleLine::front),
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
50 buffer(buffer),
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
51 colour(colour),
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
52 time(0)
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
53 {
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
54 IConsoleLine::front = this;
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
55 IConsoleLine::size++;
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
56 }
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
57
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
58 /**
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
59 * Clear this console line and any further ones.
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
60 */
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
61 ~IConsoleLine()
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
62 {
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
63 IConsoleLine::size--;
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
64 free(buffer);
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
65
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
66 delete previous;
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
67 }
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
68
9906
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
69 /**
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
70 * Get the index-ed item in the list.
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
71 */
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
72 static const IConsoleLine *Get(uint index)
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
73 {
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
74 const IConsoleLine *item = IConsoleLine::front;
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
75 while (index != 0 && item != NULL) {
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
76 index--;
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
77 item = item->previous;
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
78 }
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
79
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
80 return item;
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
81 }
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
82
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
83 /**
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
84 * Truncate the list removing everything older than/more than the amount
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
85 * as specified in the config file.
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
86 * As a side effect also increase the time the other lines have been in
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
87 * the list.
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
88 * @return true if and only if items got removed.
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
89 */
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
90 static bool Truncate()
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
91 {
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
92 IConsoleLine *cur = IConsoleLine::front;
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
93 if (cur == NULL) return false;
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
94
9906
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
95 int count = 1;
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
96 for (IConsoleLine *item = cur->previous; item != NULL; count++, cur = item, item = item->previous) {
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
97 if (item->time > _settings_client.gui.console_backlog_timeout &&
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
98 count > _settings_client.gui.console_backlog_length) {
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
99 delete item;
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
100 cur->previous = NULL;
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
101 return true;
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
102 }
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
103
9915
f0cea4aa2bf6 (svn r14068) -Fix (r14056): MSVC doesn't support typeof.
rubidium <rubidium@openttd.org>
parents: 9906
diff changeset
104 if (item->time != MAX_UVALUE(uint16)) item->time++;
9906
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
105 }
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
106
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
107 return false;
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
108 }
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
109
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
110 /**
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
111 * Reset the complete console line backlog.
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
112 */
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
113 static void Reset()
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
114 {
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
115 delete IConsoleLine::front;
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
116 IConsoleLine::front = NULL;
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
117 IConsoleLine::size = 0;
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
118 }
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
119 };
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
120
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
121 /* static */ IConsoleLine *IConsoleLine::front = NULL;
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
122 /* static */ int IConsoleLine::size = 0;
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
123
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
124
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
125 /* ** main console cmd buffer ** */
9906
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
126 static Textbuf _iconsole_cmdline;
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
127 static char *_iconsole_history[ICON_HISTORY_SIZE];
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
128 static byte _iconsole_historypos;
9906
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
129 IConsoleModes _iconsole_mode;
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
130
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
131 /* *************** *
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
132 * end of header *
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
133 * *************** */
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
134
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
135 static void IConsoleClearCommand()
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
136 {
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
137 memset(_iconsole_cmdline.buf, 0, ICON_CMDLN_SIZE);
10276
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10238
diff changeset
138 _iconsole_cmdline.size = 1; // only terminating zero
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
139 _iconsole_cmdline.width = 0;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
140 _iconsole_cmdline.caretpos = 0;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
141 _iconsole_cmdline.caretxoffs = 0;
13034
6eb3f749890a (svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents: 13027
diff changeset
142 SetWindowDirty(WC_CONSOLE, 0);
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
143 }
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
144
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
145 static inline void IConsoleResetHistoryPos() {_iconsole_historypos = ICON_HISTORY_SIZE - 1;}
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
146
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
147
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
148 static void IConsoleHistoryAdd(const char *cmd);
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
149 static void IConsoleHistoryNavigate(int direction);
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
150
12582
e4e3a1de73b5 (svn r17022) -Codechange: Use nested widgets for the console window.
alberth <alberth@openttd.org>
parents: 12003
diff changeset
151 /** Widgets of the console window. */
e4e3a1de73b5 (svn r17022) -Codechange: Use nested widgets for the console window.
alberth <alberth@openttd.org>
parents: 12003
diff changeset
152 enum ConsoleWidgets {
e4e3a1de73b5 (svn r17022) -Codechange: Use nested widgets for the console window.
alberth <alberth@openttd.org>
parents: 12003
diff changeset
153 CW_BACKGROUND, ///< Background of the console
e4e3a1de73b5 (svn r17022) -Codechange: Use nested widgets for the console window.
alberth <alberth@openttd.org>
parents: 12003
diff changeset
154 };
e4e3a1de73b5 (svn r17022) -Codechange: Use nested widgets for the console window.
alberth <alberth@openttd.org>
parents: 12003
diff changeset
155
e4e3a1de73b5 (svn r17022) -Codechange: Use nested widgets for the console window.
alberth <alberth@openttd.org>
parents: 12003
diff changeset
156 static const struct NWidgetPart _nested_console_window_widgets[] = {
e4e3a1de73b5 (svn r17022) -Codechange: Use nested widgets for the console window.
alberth <alberth@openttd.org>
parents: 12003
diff changeset
157 NWidget(WWT_EMPTY, INVALID_COLOUR, CW_BACKGROUND), SetResize(1, 1),
e4e3a1de73b5 (svn r17022) -Codechange: Use nested widgets for the console window.
alberth <alberth@openttd.org>
parents: 12003
diff changeset
158 };
e4e3a1de73b5 (svn r17022) -Codechange: Use nested widgets for the console window.
alberth <alberth@openttd.org>
parents: 12003
diff changeset
159
e4e3a1de73b5 (svn r17022) -Codechange: Use nested widgets for the console window.
alberth <alberth@openttd.org>
parents: 12003
diff changeset
160 static const WindowDesc _console_window_desc(
13792
a998faa00d15 (svn r18318) -Codechange: add an enum value for manual window placement
rubidium <rubidium@openttd.org>
parents: 13628
diff changeset
161 WDP_MANUAL, WDP_MANUAL, 0, 0,
12582
e4e3a1de73b5 (svn r17022) -Codechange: Use nested widgets for the console window.
alberth <alberth@openttd.org>
parents: 12003
diff changeset
162 WC_CONSOLE, WC_NONE,
e4e3a1de73b5 (svn r17022) -Codechange: Use nested widgets for the console window.
alberth <alberth@openttd.org>
parents: 12003
diff changeset
163 0,
13564
bae287664b02 (svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents: 13509
diff changeset
164 _nested_console_window_widgets, lengthof(_nested_console_window_widgets)
12582
e4e3a1de73b5 (svn r17022) -Codechange: Use nested widgets for the console window.
alberth <alberth@openttd.org>
parents: 12003
diff changeset
165 );
e4e3a1de73b5 (svn r17022) -Codechange: Use nested widgets for the console window.
alberth <alberth@openttd.org>
parents: 12003
diff changeset
166
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
167 struct IConsoleWindow : Window
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
168 {
9906
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
169 static int scroll;
11640
46a1311409f3 (svn r16020) -Codechange: Use actual font height for console output instead of fixed value.
peter1138 <peter1138@openttd.org>
parents: 11533
diff changeset
170 int line_height;
11641
f4e14efa6fdf (svn r16021) -Codechange: Offset current console output by (width of "] ")+5 pixels instead of 5+5 pixels.
peter1138 <peter1138@openttd.org>
parents: 11640
diff changeset
171 int line_offset;
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
172
12582
e4e3a1de73b5 (svn r17022) -Codechange: Use nested widgets for the console window.
alberth <alberth@openttd.org>
parents: 12003
diff changeset
173 IConsoleWindow() : Window()
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
174 {
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
175 _iconsole_mode = ICONSOLE_OPENED;
11640
46a1311409f3 (svn r16020) -Codechange: Use actual font height for console output instead of fixed value.
peter1138 <peter1138@openttd.org>
parents: 11533
diff changeset
176 this->line_height = FONT_HEIGHT_NORMAL + ICON_LINE_SPACING;
11641
f4e14efa6fdf (svn r16021) -Codechange: Offset current console output by (width of "] ")+5 pixels instead of 5+5 pixels.
peter1138 <peter1138@openttd.org>
parents: 11640
diff changeset
177 this->line_offset = GetStringBoundingBox("] ").width + 5;
12582
e4e3a1de73b5 (svn r17022) -Codechange: Use nested widgets for the console window.
alberth <alberth@openttd.org>
parents: 12003
diff changeset
178
e4e3a1de73b5 (svn r17022) -Codechange: Use nested widgets for the console window.
alberth <alberth@openttd.org>
parents: 12003
diff changeset
179 this->InitNested(&_console_window_desc, 0);
e4e3a1de73b5 (svn r17022) -Codechange: Use nested widgets for the console window.
alberth <alberth@openttd.org>
parents: 12003
diff changeset
180 ResizeWindow(this, _screen.width, _screen.height / 3);
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
181 }
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
182
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
183 ~IConsoleWindow()
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
184 {
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
185 _iconsole_mode = ICONSOLE_CLOSED;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
186 }
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
187
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
188 virtual void OnPaint()
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
189 {
11640
46a1311409f3 (svn r16020) -Codechange: Use actual font height for console output instead of fixed value.
peter1138 <peter1138@openttd.org>
parents: 11533
diff changeset
190 const int max = (this->height / this->line_height) - 1;
11483
f45b22901ffa (svn r15844) -Codechange: allow text alignment to be forced so the console and ai debug output don't get swapped (those are untranslateable anyways)
rubidium <rubidium@openttd.org>
parents: 11436
diff changeset
191 const int right = this->width - 5;
11436
caf4456fbbf3 (svn r15794) -Codechange: remove the DoDrawString part of the old text drawing API
rubidium <rubidium@openttd.org>
parents: 11373
diff changeset
192
9906
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
193 const IConsoleLine *print = IConsoleLine::Get(IConsoleWindow::scroll);
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
194 GfxFillRect(this->left, this->top, this->width, this->height - 1, 0);
9906
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
195 for (int i = 0; i < max && print != NULL; i++, print = print->previous) {
11640
46a1311409f3 (svn r16020) -Codechange: Use actual font height for console output instead of fixed value.
peter1138 <peter1138@openttd.org>
parents: 11533
diff changeset
196 DrawString(5, right, this->height - (2 + i) * this->line_height, print->buffer, print->colour, SA_LEFT | SA_FORCE);
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
197 }
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
198 /* If the text is longer than the window, don't show the starting ']' */
11641
f4e14efa6fdf (svn r16021) -Codechange: Offset current console output by (width of "] ")+5 pixels instead of 5+5 pixels.
peter1138 <peter1138@openttd.org>
parents: 11640
diff changeset
199 int delta = this->width - this->line_offset - _iconsole_cmdline.width - ICON_RIGHT_BORDERWIDTH;
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
200 if (delta > 0) {
11640
46a1311409f3 (svn r16020) -Codechange: Use actual font height for console output instead of fixed value.
peter1138 <peter1138@openttd.org>
parents: 11533
diff changeset
201 DrawString(5, right, this->height - this->line_height, "]", (TextColour)CC_COMMAND, SA_LEFT | SA_FORCE);
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
202 delta = 0;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
203 }
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
204
11641
f4e14efa6fdf (svn r16021) -Codechange: Offset current console output by (width of "] ")+5 pixels instead of 5+5 pixels.
peter1138 <peter1138@openttd.org>
parents: 11640
diff changeset
205 DrawString(this->line_offset + delta, right, this->height - this->line_height, _iconsole_cmdline.buf, (TextColour)CC_COMMAND, SA_LEFT | SA_FORCE);
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
206
11081
0a26df8849a2 (svn r15424) -Codechange: make it possible to have multiple windows with edit box open simultaniously (Zuu).
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
207 if (_focused_window == this && _iconsole_cmdline.caret) {
11641
f4e14efa6fdf (svn r16021) -Codechange: Offset current console output by (width of "] ")+5 pixels instead of 5+5 pixels.
peter1138 <peter1138@openttd.org>
parents: 11640
diff changeset
208 DrawString(this->line_offset + delta + _iconsole_cmdline.caretxoffs, right, this->height - this->line_height, "_", TC_WHITE, SA_LEFT | SA_FORCE);
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
209 }
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
210 }
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
211
9906
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
212 virtual void OnHundredthTick()
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
213 {
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
214 if (IConsoleLine::Truncate() &&
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
215 (IConsoleWindow::scroll > IConsoleLine::size)) {
11640
46a1311409f3 (svn r16020) -Codechange: Use actual font height for console output instead of fixed value.
peter1138 <peter1138@openttd.org>
parents: 11533
diff changeset
216 IConsoleWindow::scroll = max(0, IConsoleLine::size - (this->height / this->line_height) + 1);
9906
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
217 this->SetDirty();
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
218 }
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
219 }
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
220
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
221 virtual void OnMouseLoop()
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
222 {
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
223 if (HandleCaret(&_iconsole_cmdline)) this->SetDirty();
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
224 }
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
225
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
226 virtual EventState OnKeyPress(uint16 key, uint16 keycode)
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
227 {
11081
0a26df8849a2 (svn r15424) -Codechange: make it possible to have multiple windows with edit box open simultaniously (Zuu).
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
228 if (_focused_window != this) return ES_NOT_HANDLED;
0a26df8849a2 (svn r15424) -Codechange: make it possible to have multiple windows with edit box open simultaniously (Zuu).
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
229
11640
46a1311409f3 (svn r16020) -Codechange: Use actual font height for console output instead of fixed value.
peter1138 <peter1138@openttd.org>
parents: 11533
diff changeset
230 const int scroll_height = (this->height / this->line_height) - 1;
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
231 switch (keycode) {
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
232 case WKC_UP:
11361
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11085
diff changeset
233 IConsoleHistoryNavigate(1);
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
234 this->SetDirty();
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
235 break;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
236
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
237 case WKC_DOWN:
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
238 IConsoleHistoryNavigate(-1);
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
239 this->SetDirty();
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
240 break;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
241
9906
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
242 case WKC_SHIFT | WKC_PAGEDOWN:
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
243 if (IConsoleWindow::scroll - scroll_height < 0) {
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
244 IConsoleWindow::scroll = 0;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
245 } else {
9906
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
246 IConsoleWindow::scroll -= scroll_height;
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
247 }
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
248 this->SetDirty();
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
249 break;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
250
9906
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
251 case WKC_SHIFT | WKC_PAGEUP:
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
252 if (IConsoleWindow::scroll + scroll_height > IConsoleLine::size - scroll_height) {
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
253 IConsoleWindow::scroll = IConsoleLine::size - scroll_height;
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
254 } else {
9906
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
255 IConsoleWindow::scroll += scroll_height;
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
256 }
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
257 this->SetDirty();
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
258 break;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
259
9906
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
260 case WKC_SHIFT | WKC_DOWN:
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
261 if (IConsoleWindow::scroll <= 0) {
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
262 IConsoleWindow::scroll = 0;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
263 } else {
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
264 --IConsoleWindow::scroll;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
265 }
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
266 this->SetDirty();
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
267 break;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
268
9906
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
269 case WKC_SHIFT | WKC_UP:
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
270 if (IConsoleWindow::scroll >= IConsoleLine::size) {
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
271 IConsoleWindow::scroll = IConsoleLine::size;
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
272 } else {
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
273 ++IConsoleWindow::scroll;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
274 }
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
275 this->SetDirty();
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
276 break;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
277
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
278 case WKC_BACKQUOTE:
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
279 IConsoleSwitch();
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
280 break;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
281
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
282 case WKC_RETURN: case WKC_NUM_ENTER:
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
283 IConsolePrintF(CC_COMMAND, "] %s", _iconsole_cmdline.buf);
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
284 IConsoleHistoryAdd(_iconsole_cmdline.buf);
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
285
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
286 IConsoleCmdExec(_iconsole_cmdline.buf);
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
287 IConsoleClearCommand();
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
288 break;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
289
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
290 case WKC_CTRL | WKC_RETURN:
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
291 _iconsole_mode = (_iconsole_mode == ICONSOLE_FULL) ? ICONSOLE_OPENED : ICONSOLE_FULL;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
292 IConsoleResize(this);
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
293 MarkWholeScreenDirty();
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
294 break;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
295
13201
4ebcd304709f (svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents: 13186
diff changeset
296 #ifdef WITH_COCOA
4ebcd304709f (svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents: 13186
diff changeset
297 case (WKC_META | 'V'):
4ebcd304709f (svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents: 13186
diff changeset
298 #endif
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
299 case (WKC_CTRL | 'V'):
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
300 if (InsertTextBufferClipboard(&_iconsole_cmdline)) {
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
301 IConsoleResetHistoryPos();
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
302 this->SetDirty();
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
303 }
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
304 break;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
305
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
306 case (WKC_CTRL | 'L'):
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
307 IConsoleCmdExec("clear");
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
308 break;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
309
13201
4ebcd304709f (svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents: 13186
diff changeset
310 #ifdef WITH_COCOA
4ebcd304709f (svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents: 13186
diff changeset
311 case (WKC_META | 'U'):
4ebcd304709f (svn r17708) -Feature [FS#2053]: [OSX] Implement clipboard support for OS X.
michi_cc <michi_cc@openttd.org>
parents: 13186
diff changeset
312 #endif
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
313 case (WKC_CTRL | 'U'):
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
314 DeleteTextBufferAll(&_iconsole_cmdline);
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
315 this->SetDirty();
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
316 break;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
317
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
318 case WKC_BACKSPACE: case WKC_DELETE:
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
319 if (DeleteTextBufferChar(&_iconsole_cmdline, keycode)) {
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
320 IConsoleResetHistoryPos();
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
321 this->SetDirty();
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
322 }
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
323 break;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
324
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
325 case WKC_LEFT: case WKC_RIGHT: case WKC_END: case WKC_HOME:
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
326 if (MoveTextBufferPos(&_iconsole_cmdline, keycode)) {
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
327 IConsoleResetHistoryPos();
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
328 this->SetDirty();
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
329 }
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
330 break;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
331
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
332 default:
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
333 if (IsValidChar(key, CS_ALPHANUMERAL)) {
9906
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
334 IConsoleWindow::scroll = 0;
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
335 InsertTextBufferChar(&_iconsole_cmdline, key);
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
336 IConsoleResetHistoryPos();
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
337 this->SetDirty();
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
338 } else {
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
339 return ES_NOT_HANDLED;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
340 }
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
341 }
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
342 return ES_HANDLED;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
343 }
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
344 };
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
345
9906
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
346 int IConsoleWindow::scroll = 0;
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
347
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
348 void IConsoleGUIInit()
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
349 {
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
350 _iconsole_historypos = ICON_HISTORY_SIZE - 1;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
351 _iconsole_mode = ICONSOLE_CLOSED;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
352
9906
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
353 IConsoleLine::Reset();
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
354 memset(_iconsole_history, 0, sizeof(_iconsole_history));
9906
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
355
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
356 _iconsole_cmdline.buf = CallocT<char>(ICON_CMDLN_SIZE); // create buffer and zero it
10276
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10238
diff changeset
357 _iconsole_cmdline.maxsize = ICON_CMDLN_SIZE;
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
358
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
359 IConsolePrintF(CC_WARNING, "OpenTTD Game Console Revision 7 - %s", _openttd_revision);
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
360 IConsolePrint(CC_WHITE, "------------------------------------");
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
361 IConsolePrint(CC_WHITE, "use \"help\" for more information");
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
362 IConsolePrint(CC_WHITE, "");
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
363 IConsoleClearCommand();
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
364 }
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
365
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
366 void IConsoleClearBuffer()
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
367 {
9906
b5cdbf8eadf3 (svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents: 9339
diff changeset
368 IConsoleLine::Reset();
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
369 }
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
370
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
371 void IConsoleGUIFree()
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
372 {
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
373 free(_iconsole_cmdline.buf);
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
374 IConsoleClearBuffer();
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
375 }
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
376
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
377 void IConsoleResize(Window *w)
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
378 {
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
379 switch (_iconsole_mode) {
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
380 case ICONSOLE_OPENED:
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
381 w->height = _screen.height / 3;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
382 w->width = _screen.width;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
383 break;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
384 case ICONSOLE_FULL:
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
385 w->height = _screen.height - ICON_BOTTOM_BORDERWIDTH;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
386 w->width = _screen.width;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
387 break;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
388 default: return;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
389 }
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
390
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
391 MarkWholeScreenDirty();
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
392 }
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
393
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
394 void IConsoleSwitch()
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
395 {
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
396 switch (_iconsole_mode) {
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
397 case ICONSOLE_CLOSED:
11533
80379bc12cb3 (svn r15894) -Codechange: remove console widget array (it was empty anyway) and window desc
glx <glx@openttd.org>
parents: 11483
diff changeset
398 new IConsoleWindow();
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
399 break;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
400
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
401 case ICONSOLE_OPENED: case ICONSOLE_FULL:
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
402 DeleteWindowById(WC_CONSOLE, 0);
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
403 break;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
404 }
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
405
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
406 MarkWholeScreenDirty();
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
407 }
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
408
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
409 void IConsoleClose() {if (_iconsole_mode == ICONSOLE_OPENED) IConsoleSwitch();}
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
410
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
411 /**
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
412 * Add the entered line into the history so you can look it back
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
413 * scroll, etc. Put it to the beginning as it is the latest text
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
414 * @param cmd Text to be entered into the 'history'
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
415 */
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
416 static void IConsoleHistoryAdd(const char *cmd)
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
417 {
12003
dae3a822e71b (svn r16409) -Change: don't add empty lines/duplicates of the previous command to the console's history
rubidium <rubidium@openttd.org>
parents: 11641
diff changeset
418 /* Strip all spaces at the begin */
dae3a822e71b (svn r16409) -Change: don't add empty lines/duplicates of the previous command to the console's history
rubidium <rubidium@openttd.org>
parents: 11641
diff changeset
419 while (IsWhitespace(*cmd)) cmd++;
dae3a822e71b (svn r16409) -Change: don't add empty lines/duplicates of the previous command to the console's history
rubidium <rubidium@openttd.org>
parents: 11641
diff changeset
420
dae3a822e71b (svn r16409) -Change: don't add empty lines/duplicates of the previous command to the console's history
rubidium <rubidium@openttd.org>
parents: 11641
diff changeset
421 /* Do not put empty command in history */
dae3a822e71b (svn r16409) -Change: don't add empty lines/duplicates of the previous command to the console's history
rubidium <rubidium@openttd.org>
parents: 11641
diff changeset
422 if (StrEmpty(cmd)) return;
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
423
12003
dae3a822e71b (svn r16409) -Change: don't add empty lines/duplicates of the previous command to the console's history
rubidium <rubidium@openttd.org>
parents: 11641
diff changeset
424 /* Do not put in history if command is same as previous */
dae3a822e71b (svn r16409) -Change: don't add empty lines/duplicates of the previous command to the console's history
rubidium <rubidium@openttd.org>
parents: 11641
diff changeset
425 if (_iconsole_history[0] == NULL || strcmp(_iconsole_history[0], cmd) != 0) {
dae3a822e71b (svn r16409) -Change: don't add empty lines/duplicates of the previous command to the console's history
rubidium <rubidium@openttd.org>
parents: 11641
diff changeset
426 free(_iconsole_history[ICON_HISTORY_SIZE - 1]);
dae3a822e71b (svn r16409) -Change: don't add empty lines/duplicates of the previous command to the console's history
rubidium <rubidium@openttd.org>
parents: 11641
diff changeset
427 memmove(&_iconsole_history[1], &_iconsole_history[0], sizeof(_iconsole_history[0]) * (ICON_HISTORY_SIZE - 1));
dae3a822e71b (svn r16409) -Change: don't add empty lines/duplicates of the previous command to the console's history
rubidium <rubidium@openttd.org>
parents: 11641
diff changeset
428 _iconsole_history[0] = strdup(cmd);
dae3a822e71b (svn r16409) -Change: don't add empty lines/duplicates of the previous command to the console's history
rubidium <rubidium@openttd.org>
parents: 11641
diff changeset
429 }
dae3a822e71b (svn r16409) -Change: don't add empty lines/duplicates of the previous command to the console's history
rubidium <rubidium@openttd.org>
parents: 11641
diff changeset
430
dae3a822e71b (svn r16409) -Change: don't add empty lines/duplicates of the previous command to the console's history
rubidium <rubidium@openttd.org>
parents: 11641
diff changeset
431 /* Reset the history position */
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
432 IConsoleResetHistoryPos();
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
433 }
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
434
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
435 /**
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
436 * Navigate Up/Down in the history of typed commands
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
437 * @param direction Go further back in history (+1), go to recently typed commands (-1)
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
438 */
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
439 static void IConsoleHistoryNavigate(int direction)
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
440 {
12003
dae3a822e71b (svn r16409) -Change: don't add empty lines/duplicates of the previous command to the console's history
rubidium <rubidium@openttd.org>
parents: 11641
diff changeset
441 if (_iconsole_history[0] == NULL) return; // Empty history
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
442 int i = _iconsole_historypos + direction;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
443
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
444 /* watch out for overflows, just wrap around */
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
445 if (i < 0) i = ICON_HISTORY_SIZE - 1;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
446 if (i >= ICON_HISTORY_SIZE) i = 0;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
447
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
448 if (direction > 0) {
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
449 if (_iconsole_history[i] == NULL) i = 0;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
450 }
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
451
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
452 if (direction < 0) {
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
453 while (i > 0 && _iconsole_history[i] == NULL) i--;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
454 }
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
455
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
456 _iconsole_historypos = i;
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
457 IConsoleClearCommand();
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
458 /* copy history to 'command prompt / bash' */
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
459 assert(_iconsole_history[i] != NULL && IsInsideMM(i, 0, ICON_HISTORY_SIZE));
10276
a5286e772120 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents: 10238
diff changeset
460 ttd_strlcpy(_iconsole_cmdline.buf, _iconsole_history[i], _iconsole_cmdline.maxsize);
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
461 UpdateTextBufferSize(&_iconsole_cmdline);
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
462 }
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
463
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
464 /**
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
465 * Handle the printing of text entered into the console or redirected there
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 9915
diff changeset
466 * by any other means. Text can be redirected to other clients in a network game
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
467 * as well as to a logfile. If the network server is a dedicated server, all activities
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
468 * are also logged. All lines to print are added to a temporary buffer which can be
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
469 * used as a history to print them onscreen
11085
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11082
diff changeset
470 * @param colour_code the colour of the command. Red in case of errors, etc.
13070
1c4c4ae8d716 (svn r17570) -Fix: a number of Doxygen warnings about missing parameters, which were sometimes missing and sometimes just typos
rubidium <rubidium@openttd.org>
parents: 13034
diff changeset
471 * @param str the message entered or output on the console (notice, error, etc.)
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
472 */
11085
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11082
diff changeset
473 void IConsoleGUIPrint(ConsoleColour colour_code, char *str)
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
474 {
11085
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11082
diff changeset
475 new IConsoleLine(str, (TextColour)colour_code);
13034
6eb3f749890a (svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents: 13027
diff changeset
476 SetWindowDirty(WC_CONSOLE, 0);
9339
030274da8619 (svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff changeset
477 }