[command-prompt] cosmetics: whitespace, sort headers

develop
Tim Siegel 2022-04-20 11:59:44 -04:00
parent 55e4008925
commit c3347d465f
No known key found for this signature in database
GPG Key ID: 856AC2B87AB8474E
1 changed files with 54 additions and 48 deletions

@ -1,23 +1,23 @@
//command-prompt a one line command entry at the top of the screen for quick commands // command-prompt: A one-line command entry at the top of the screen for quick commands
#include "Core.h" #include "Core.h"
#include <ColorText.h>
#include <Console.h> #include <Console.h>
#include <Export.h> #include <Export.h>
#include <PluginManager.h> #include <PluginManager.h>
#include <ColorText.h>
#include <modules/Screen.h>
#include <modules/Gui.h> #include <modules/Gui.h>
#include <modules/Screen.h>
#include <set>
#include <list> #include <list>
#include <set>
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "df/enabler.h"
#include "df/graphic.h"
#include "df/interface_key.h" #include "df/interface_key.h"
#include "df/ui.h" #include "df/ui.h"
#include "df/graphic.h"
#include "df/enabler.h"
using namespace DFHack; using namespace DFHack;
using namespace df::enums; using namespace df::enums;
@ -36,7 +36,9 @@ class prompt_ostream:public buffered_color_ostream
protected: protected:
void flush_proxy(); void flush_proxy();
public: public:
prompt_ostream(viewscreen_commandpromptst* parent):parent_(parent){} prompt_ostream(viewscreen_commandpromptst* parent)
: parent_(parent)
{}
bool empty() { return buffer.empty(); } bool empty() { return buffer.empty(); }
}; };
class viewscreen_commandpromptst : public dfhack_viewscreen { class viewscreen_commandpromptst : public dfhack_viewscreen {
@ -57,7 +59,8 @@ public:
df::plant* getSelectedPlant() { return Gui::getAnyPlant(parent); } df::plant* getSelectedPlant() { return Gui::getAnyPlant(parent); }
std::string getFocusString() { return "commandprompt"; } std::string getFocusString() { return "commandprompt"; }
viewscreen_commandpromptst(std::string entry):submitted(false), is_response(false) viewscreen_commandpromptst(std::string entry)
: submitted(false), is_response(false)
{ {
show_fps = gps->display_frames; show_fps = gps->display_frames;
gps->display_frames = 0; gps->display_frames = 0;
@ -161,7 +164,8 @@ void viewscreen_commandpromptst::render()
{ {
Screen::fillRect(Screen::Pen(' ', 7, 0), 0, i, dim.x, i); Screen::fillRect(Screen::Pen(' ', 7, 0), 0, i, dim.x, i);
std::string cur_line = it->second; std::string cur_line = it->second;
Screen::paintString(Screen::Pen(' ',it->first,0),0,i,cur_line.substr(0,cur_line.size()-1)); Screen::paintString(Screen::Pen(' ', it->first, 0), 0, i,
cur_line.substr(0, cur_line.size() - 1));
} }
} }
else else
@ -170,7 +174,7 @@ void viewscreen_commandpromptst::render()
Screen::fillRect(Screen::Pen(' ', 7, 0), 0, 0, dim.x, 0); Screen::fillRect(Screen::Pen(' ', 7, 0), 0, 0, dim.x, 0);
Screen::paintString(Screen::Pen(' ', 7, 0), 0, 0, "[DFHack]#"); Screen::paintString(Screen::Pen(' ', 7, 0), 0, 0, "[DFHack]#");
std::string cursor = (frame < enabler->gfps / 2) ? "_" : " "; std::string cursor = (frame < enabler->gfps / 2) ? "_" : " ";
if(cursor_pos < (dim.x - 10)) if (cursor_pos < dim.x - 10)
{ {
Screen::paintString(Screen::Pen(' ', 7, 0), 10, 0, entry); Screen::paintString(Screen::Pen(' ', 7, 0), 10, 0, entry);
if (int16_t(entry.size()) > dim.x - 10) if (int16_t(entry.size()) > dim.x - 10)
@ -333,8 +337,10 @@ bool hotkey_allow_all(df::viewscreen *top)
DFhackCExport command_result plugin_init(color_ostream &out, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init(color_ostream &out, std::vector <PluginCommand> &commands)
{ {
commands.push_back(PluginCommand( commands.push_back(PluginCommand(
"command-prompt","Shows a command prompt on window.",show_prompt,hotkey_allow_all, "command-prompt", "Shows a command prompt on window.",
"command-prompt [entry] - shows a cmd prompt in df window. Entry is used for default prefix (e.g. ':lua')" show_prompt, hotkey_allow_all,
"command-prompt [entry] - shows a cmd prompt in df window."
" Entry is used for default prefix (e.g. ':lua')"
)); ));
return CR_OK; return CR_OK;
} }