From 0bd18421f143f9e0eda6d32182dab1e6f240ba78 Mon Sep 17 00:00:00 2001 From: ac-stef Date: Wed, 31 May 2017 15:37:08 +0200 Subject: [PATCH] optionally not store inputcommand into command history inputcommand Opens a custom console buffer with custom prompt, initial buffer text and execution script (which gets the input buffer content in alias cmdbuf). If nopersist is not zero, the command will not be stored in console history. DOCREF inputcommand --- source/src/console.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/source/src/console.cpp b/source/src/console.cpp index a82813e2..897e6b02 100644 --- a/source/src/console.cpp +++ b/source/src/console.cpp @@ -82,7 +82,7 @@ struct console : consolebuffer console con; textinputbuffer cmdline; char *cmdaction = NULL, *cmdprompt = NULL; -bool saycommandon = false; +bool saycommandon = false, storeinputcommand = false; VARFP(maxcon, 10, 200, 1000, con.setmaxlines(maxcon)); @@ -313,13 +313,14 @@ void saycommand(char *init) // turns input to the comman } COMMAND(saycommand, "c"); -void inputcommand(char *init, char *action, char *prompt) +void inputcommand(char *init, char *action, char *prompt, int *nopersist) { saycommand(init); if(action[0]) cmdaction = newstring(action); if(prompt[0]) cmdprompt = newstring(prompt); + storeinputcommand = cmdaction && !*nopersist; } -COMMAND(inputcommand, "sss"); +COMMAND(inputcommand, "sssi"); SVARFF(mapmsg, { // read mapmsg @@ -395,6 +396,7 @@ struct hline DELETEA(cmdprompt); if(action) cmdaction = newstring(action); if(prompt) cmdprompt = newstring(prompt); + storeinputcommand = false; } bool shouldsave() @@ -578,7 +580,11 @@ void consolekey(int code, bool isdown, int cooked, SDLMod mod) } histpos = history.length(); saycommand(NULL); - if(h) h->run(); + if(h) + { + h->run(); + if(h->action && !storeinputcommand) history.drop(); + } } else if((code==SDLK_ESCAPE && !ignoreescup) || code== SDL_AC_BUTTON_RIGHT) {