mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-04 05:15:21 +00:00
(svn r18631) -Fix [FS#3419]: when making a screenshot from the console the currently executed command would be shown twice
This commit is contained in:
parent
21a3f97a0b
commit
7ed2e65b77
@ -145,7 +145,7 @@ static void IConsoleClearCommand()
|
|||||||
static inline void IConsoleResetHistoryPos() {_iconsole_historypos = ICON_HISTORY_SIZE - 1;}
|
static inline void IConsoleResetHistoryPos() {_iconsole_historypos = ICON_HISTORY_SIZE - 1;}
|
||||||
|
|
||||||
|
|
||||||
static void IConsoleHistoryAdd(const char *cmd);
|
static const char *IConsoleHistoryAdd(const char *cmd);
|
||||||
static void IConsoleHistoryNavigate(int direction);
|
static void IConsoleHistoryNavigate(int direction);
|
||||||
|
|
||||||
/** Widgets of the console window. */
|
/** Widgets of the console window. */
|
||||||
@ -279,13 +279,13 @@ struct IConsoleWindow : Window
|
|||||||
IConsoleSwitch();
|
IConsoleSwitch();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WKC_RETURN: case WKC_NUM_ENTER:
|
case WKC_RETURN: case WKC_NUM_ENTER: {
|
||||||
IConsolePrintF(CC_COMMAND, "] %s", _iconsole_cmdline.buf);
|
IConsolePrintF(CC_COMMAND, "] %s", _iconsole_cmdline.buf);
|
||||||
IConsoleHistoryAdd(_iconsole_cmdline.buf);
|
const char *cmd = IConsoleHistoryAdd(_iconsole_cmdline.buf);
|
||||||
|
|
||||||
IConsoleCmdExec(_iconsole_cmdline.buf);
|
|
||||||
IConsoleClearCommand();
|
IConsoleClearCommand();
|
||||||
break;
|
|
||||||
|
if (cmd != NULL) IConsoleCmdExec(cmd);
|
||||||
|
} break;
|
||||||
|
|
||||||
case WKC_CTRL | WKC_RETURN:
|
case WKC_CTRL | WKC_RETURN:
|
||||||
_iconsole_mode = (_iconsole_mode == ICONSOLE_FULL) ? ICONSOLE_OPENED : ICONSOLE_FULL;
|
_iconsole_mode = (_iconsole_mode == ICONSOLE_FULL) ? ICONSOLE_OPENED : ICONSOLE_FULL;
|
||||||
@ -412,14 +412,15 @@ void IConsoleClose() {if (_iconsole_mode == ICONSOLE_OPENED) IConsoleSwitch();}
|
|||||||
* Add the entered line into the history so you can look it back
|
* Add the entered line into the history so you can look it back
|
||||||
* scroll, etc. Put it to the beginning as it is the latest text
|
* scroll, etc. Put it to the beginning as it is the latest text
|
||||||
* @param cmd Text to be entered into the 'history'
|
* @param cmd Text to be entered into the 'history'
|
||||||
|
* @return the command to execute
|
||||||
*/
|
*/
|
||||||
static void IConsoleHistoryAdd(const char *cmd)
|
static const char *IConsoleHistoryAdd(const char *cmd)
|
||||||
{
|
{
|
||||||
/* Strip all spaces at the begin */
|
/* Strip all spaces at the begin */
|
||||||
while (IsWhitespace(*cmd)) cmd++;
|
while (IsWhitespace(*cmd)) cmd++;
|
||||||
|
|
||||||
/* Do not put empty command in history */
|
/* Do not put empty command in history */
|
||||||
if (StrEmpty(cmd)) return;
|
if (StrEmpty(cmd)) return NULL;
|
||||||
|
|
||||||
/* Do not put in history if command is same as previous */
|
/* Do not put in history if command is same as previous */
|
||||||
if (_iconsole_history[0] == NULL || strcmp(_iconsole_history[0], cmd) != 0) {
|
if (_iconsole_history[0] == NULL || strcmp(_iconsole_history[0], cmd) != 0) {
|
||||||
@ -430,6 +431,7 @@ static void IConsoleHistoryAdd(const char *cmd)
|
|||||||
|
|
||||||
/* Reset the history position */
|
/* Reset the history position */
|
||||||
IConsoleResetHistoryPos();
|
IConsoleResetHistoryPos();
|
||||||
|
return _iconsole_history[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user