Merge pull request #4 from haganbmj/clear-console

feat: add ability to clear the console messages
This commit is contained in:
Brendan Hagan
2022-07-01 21:02:10 -04:00
committed by GitHub
7 changed files with 58 additions and 13 deletions
+1
View File
@@ -11,6 +11,7 @@ Features:
* Add "Created At", "Last Modified At" columns to card list.
* Add filter box to Game and Stylesheet selection.
* Add extra_card("field name") script function for accessing Extra Card Fields.
* Add Clear button to console panel.
------------------------------------------------------------------------------
HEAD: new items added as changes are made
+16 -5
View File
@@ -80,7 +80,10 @@ menu:
stack: &Stacked Bars 3
scatter: S&catter Plot 4
scatter pie: Sc&atter-Pie 5
console: Console
clear console: &Clear Console Ctrl+L
window: &Window
new window: &New Window
cards tab: &Cards Alt+1
@@ -196,7 +199,10 @@ help:
stack: A bar graph with stacked bars
scatter: A scatter plot, the size indicates the number of cards
scatter pie: A scatter plot where each item is a small pie graph
#console:
clear console: Clear the console
#window:
new window: Creates another window to edit the same set
cards tab: Edit the cards in the set
@@ -351,7 +357,9 @@ tool:
curve segment: Curve
free point: Free
smooth point: Smooth
symmetric point: Symmetric
symmetric point: Symmetric
clear console: Clear Console
############################################################## Toolbar help text
tooltip:
@@ -426,7 +434,9 @@ tooltip:
curve segment: To curve
free point: Unlock point
smooth point: Make point smooth
symmetric point: Make point symmetric
symmetric point: Make point symmetric
clear console: Clear Console
############################################################## Labels in the GUI
label:
@@ -582,7 +592,8 @@ button:
add custom pack: Add &Custom Pack...
# Console panel
evaluate: &Evaluate
evaluate: &Evaluate
clear: &Clear
# Welcome
new set: New set
Binary file not shown.

After

Width:  |  Height:  |  Size: 384 B

+2
View File
@@ -61,6 +61,8 @@ tool/graph_stack IMAGE "tool/graph_stack.png"
tool/graph_scatter IMAGE "tool/graph_scatter.png"
tool/graph_scatter_pie IMAGE "tool/graph_scatter_pie.png"
tool/clear_console IMAGE "tool/clear_console.png"
tool/window_cards IMAGE "tool/window_cards.png"
tool/window_set_info IMAGE "tool/window_set_info.png"
tool/window_style IMAGE "tool/window_style.png"
+32 -5
View File
@@ -79,6 +79,14 @@ public:
}
void add_message(MessageType type, String const& text, bool joined_to_previous = false) {
add_message(make_intrusive<ConsoleMessage>(type,text,joined_to_previous));
}
void clear_console() {
messages.clear();
layout_all();
selection = messages.size();
update_scrollbar();
Refresh(false);
}
bool have_selection() const {
@@ -455,6 +463,7 @@ END_EVENT_TABLE()
ConsolePanel::ConsolePanel(Window* parent, int id)
: SetWindowPanel(parent, id)
, menuConsole(nullptr)
, messages(nullptr)
, entry(nullptr)
, is_active_window(false)
@@ -480,7 +489,15 @@ ConsolePanel::ConsolePanel(Window* parent, int id)
wxSizer* s = new wxBoxSizer(wxVERTICAL);
s->Add(splitter, 1, wxEXPAND);
s->SetSizeHints(this);
SetSizer(s);
SetSizer(s);
// init menus
menuConsole = new wxMenu();
add_menu_item_tr(menuConsole, ID_CLEAR_CONSOLE, "clear_console", "clear console");
}
ConsolePanel::~ConsolePanel() {
delete menuConsole;
}
void ConsolePanel::onChangeSet() {
@@ -500,13 +517,20 @@ void ConsolePanel::initUI(wxToolBar* tb, wxMenuBar* mb) {
// stop blinker
is_active_window = true;
stop_blinker();
stop_blinker();
add_tool_tr(tb, ID_CLEAR_CONSOLE, "clear_console", "clear console");
tb->Realize();
mb->Insert(2, menuConsole, _MENU_("console"));
}
void ConsolePanel::destroyUI(wxToolBar* tb, wxMenuBar* mb) {
// Toolbar
// Menus
// Toolbar
tb->DeleteTool(ID_CLEAR_CONSOLE);
// Menus
mb->Remove(2);
// we are no longer active, allow blinker
is_active_window = false;
}
@@ -524,6 +548,9 @@ void ConsolePanel::onCommand(int id) {
if (id == ID_EVALUATE) {
exec(entry->get_command_and_clear());
}
else if (id == ID_CLEAR_CONSOLE) {
messages->clear_console();
}
}
void ConsolePanel::onIdle(wxIdleEvent&) {
+5 -2
View File
@@ -19,7 +19,8 @@ class HistoryTextCtrl;
class ConsolePanel : public SetWindowPanel {
public:
ConsolePanel(Window* parent, int id);
ConsolePanel(Window* parent, int id);
~ConsolePanel();
// --------------------------------------------------- : UI
@@ -48,7 +49,9 @@ private:
wxSplitterWindow* splitter;
MessageCtrl* messages;
wxPanel* entry_panel;
HistoryTextCtrl* entry;
HistoryTextCtrl* entry;
wxMenu* menuConsole;
void get_pending_errors();
void exec(String const& code);
+2 -1
View File
@@ -208,7 +208,8 @@ enum ChildMenuID {
ID_CUSTOM_PACK,
// Console panel
ID_EVALUATE,
ID_EVALUATE,
ID_CLEAR_CONSOLE,
// SymbolFont (Format menu)
ID_INSERT_SYMBOL_MENU_MIN = 9001,