20#include "../../kernel/core/ui/language.hpp"
21#include "../../kernel/core/utils/stringtools.hpp"
22#include "../../common/datastructures.h"
23#include "../../common/Options.h"
24#include "../NumeReWindow.h"
27#include <wx/clipbrd.h>
35using namespace wxcode;
63VariableViewer::
VariableViewer(wxWindow* parent,
NumeReWindow* mainWin,
int fieldsize,
bool debugMode) : wxTreeListCtrl(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTR_TWIST_BUTTONS | wxTR_FULL_ROW_HIGHLIGHT | wxTR_ROW_LINES | wxTR_NO_LINES | wxTR_HIDE_ROOT)
65 selectedID = wxTreeItemId();
67 nDataFieldSize = fieldsize;
72 AddColumn(
_guilang.
get(
"GUI_VARVIEWER_DIM"), 80, wxALIGN_RIGHT);
74 AddColumn(
_guilang.
get(
"GUI_VARVIEWER_VALUE"), fieldsize - (!debugMode)*50);
83 numRoot = AppendItem(GetRootItem(),
_guilang.
get(
"GUI_VARVIEWER_VARS"));
84 stringRoot = AppendItem(GetRootItem(),
_guilang.
get(
"GUI_VARVIEWER_STRINGS"));
85 clusterRoot = AppendItem(GetRootItem(),
_guilang.
get(
"GUI_VARVIEWER_CLUSTERS"));
86 tableRoot = AppendItem(GetRootItem(),
_guilang.
get(
"GUI_VARVIEWER_TABLES"));
87 SetItemText(tableRoot,
VALUECOLUMN,
" {min, ..., max}");
88 SetItemText(clusterRoot,
VALUECOLUMN,
" {first, ..., last}");
91 SetItemBold(numRoot,
true);
92 SetItemBold(stringRoot,
true);
93 SetItemBold(tableRoot,
true);
94 SetItemBold(clusterRoot,
true);
96 for (
size_t i = 0; i < 6; i++)
98 bExpandedState[i] =
true;
101 setDebuggerMode(debugMode);
137 if (sVar.substr(0, sVar.find(
'\t')) ==
"data()")
139 else if (sVar.substr(0, sVar.find(
'\t')) ==
"table()")
141 else if (sVar.substr(0, sVar.find(
'\t')) ==
"string()")
143 else if (sVar.substr(0, sVar.find(
'\t')) ==
"x")
145 else if (sVar.substr(0, sVar.find(
'\t')) ==
"y")
147 else if (sVar.substr(0, sVar.find(
'\t')) ==
"z")
149 else if (sVar.substr(0, sVar.find(
'\t')) ==
"t")
151 else if (sVar.substr(0, sVar.find(
'\t')) ==
"nrows" || sVar.substr(0, sVar.find(
'\t')) ==
"nlines")
153 else if (sVar.substr(0, sVar.find(
'\t')) ==
"ncols")
155 else if (sVar.substr(0, sVar.find(
'\t')) ==
"nlen")
157 else if (sVar.substr(0, sVar.find(
'\t')) ==
"ans" || sVar.substr(0, sVar.find(
'\t')) ==
"ans{}")
179 wxTreeItemId currentItem = AppendItem(rootNode, sVar.substr(0, sVar.find(
'\t')));
180 tooltip = sVar.substr(0, sVar.find(
'\t'));
181 sVar.erase(0, sVar.find(
'\t')+1);
183 SetItemText(currentItem,
DIMCOLUMN, sVar.substr(0, sVar.find(
'\t')) +
" ");
184 sVar.erase(0, sVar.find(
'\t')+1);
186 SetItemText(currentItem,
CLASSCOLUMN,
" " + sVar.substr(0, sVar.find(
'\t')));
187 sVar.erase(0, sVar.find(
'\t')+1);
189 SetItemText(currentItem,
VALUECOLUMN,
" " + sVar.substr(0, sVar.find(
'\t')));
192 size_t pos = sVar.find(
'\t');
195 tooltip +=
" = " + sVar.substr(0, pos);
197 tooltip +=
" = " + sVar.substr(0, 1000) +
"[...]" + sVar.substr(pos-1000, pos);
199 SetItemToolTip(currentItem, tooltip);
204 SetItemText(currentItem,
SIZECOLUMN,
" " + sVar.substr(sVar.rfind(
'\t')+1));
205 sVar.erase(sVar.rfind(
'\t'));
212 SetItemData(currentItem,
new VarData(sVar.substr(sVar.rfind(
'\t')+1)));
290 return static_cast<VarData*
>(GetItemData(
id))->sInternalName;
306 switch (event.GetId())
345 wxTextEntryDialog textEntry(
this,
_guilang.
get(
"GUI_VARVIEWER_NEWTABLE_QUESTION"),
_guilang.
get(
"GUI_VARVIEWER_NEWTABLE"),
"table()");
347 if (textEntry.ShowModal() != wxID_OK)
350 wxString tables = textEntry.GetValue();
353 if (tables.find(
',') != std::string::npos)
358 while (tables.length())
360 if (tablesTemp.length())
364 tablesTemp += tables.substr(0, tables.find(
','));
368 if (tablesTemp.substr(tablesTemp.find_last_not_of(
' ')-1, 2) !=
"()")
369 tablesTemp.insert(tablesTemp.find_last_not_of(
' ')+1,
"()");
372 if (tables.find(
',') != std::string::npos)
373 tables.erase(0, tables.find(
',')+1);
380 else if (tables.find(
"()") == std::string::npos)
384 tables.insert(tables.find_last_not_of(
' ')+1,
"()");
431 wxTextEntryDialog textEntry(
this,
_guilang.
get(
"GUI_VARVIEWER_NEWNAME_QUESTION"),
_guilang.
get(
"GUI_VARVIEWER_NEWNAME"), table);
433 if (textEntry.ShowModal() != wxID_OK)
480 wxTextEntryDialog textEntry(
this,
_guilang.
get(
"GUI_VARVIEWER_SAVENAME_QUESTION"),
_guilang.
get(
"GUI_VARVIEWER_SAVENAME"), table.substr(0, table.find(
'(')));
482 if (textEntry.ShowModal() != wxID_OK)
499 if (wxTheClipboard->Open())
501 wxTheClipboard->SetData(
new wxTextDataObject(value));
502 wxTheClipboard->Close();
548 if (!event.GetItem().IsOk() || GetItemParent(event.GetItem()) == GetRootItem())
553 bool isTable = GetItemParent(event.GetItem()) ==
tableRoot || GetItemText(event.GetItem()).find(
"()") != std::string::npos;
554 wxString itemLabel = GetItemText(event.GetItem());
555 bool bMayBeModified = itemLabel !=
"string()" && itemLabel !=
"table()";
564 popUpmenu.AppendSeparator();
571 if (itemLabel !=
"string()")
573 popUpmenu.AppendSeparator();
595 PopupMenu(&popUpmenu, event.GetPoint());
609 if (GetItemParent(event.GetItem()) !=
tableRoot && GetItemParent(event.GetItem()) !=
clusterRoot)
616 if (GetItemText(event.GetItem()).find(
"()") != std::string::npos || GetItemText(event.GetItem()).find(
"{}") != std::string::npos)
618 else if (
GetInternalName(event.GetItem()).find(
"{}") != std::string::npos)
620 else if (
GetInternalName(event.GetItem()).find(
"()") != std::string::npos)
692void VariableViewer::UpdateVariables(
const std::vector<std::string>& vVarList,
size_t nNumerics,
size_t nStrings,
size_t nTables,
size_t nClusters,
size_t nArguments,
size_t nGlobals)
713 wxTreeItemId currentItem;
716 for (
size_t i = 0; i < vVarList.size(); i++)
723 else if (i < nStrings+nNumerics)
728 else if (i < nStrings+nNumerics+nTables)
733 else if (i < nStrings+nNumerics+nTables+nClusters)
738 else if (
argumentRoot.IsOk() && i < nStrings+nNumerics+nTables+nClusters+nArguments)
743 else if (
globalRoot.IsOk() && i < nStrings+nNumerics+nTables+nClusters+nArguments+nGlobals)
751 SetItemTextColour(currentItem, *wxRED);
754 SetItemTextColour(currentItem, wxColour(0, 0, 192));
This class handles the internal language system and returns the language strings of the selected lang...
std::string get(const std::string &sMessage, const std::vector< std::string > &vTokens) const
This member function returns the language string for the passed language identifier and replaces all ...
This class is the actual NumeRe main frame. The application's logic is implemented here.
void showTable(const wxString &tableName, const wxString &tableDisplayName)
This member function is a wrapper for an event handler of the variable viewer to display the contents...
void pass_command(const wxString &command, bool isEvent=false)
This member function is a wrapper for the corresponding terminal function to pass a command to the ke...
bool GetShowGlobalVariables() const
bool GetShowProcedureArguments() const
void OnSaveTable(const wxString &table)
This member function saves the selected table.
void setDebuggerMode(bool mode=true)
This member function creates or removes unneeded tree root items and handles the debugger mode.
void OnEditTable(const wxString &table)
This member function displays the selected table for editing.
void OnRightClick(wxTreeEvent &event)
This member function creates the pop-up menu in the var viewer case (it does nothing in debugger mode...
void UpdateVariables(const std::vector< std::string > &vVarList, size_t nNumerics, size_t nStrings, size_t nTables, size_t nClusters, size_t nArguments=0, size_t nGlobals=0)
This member function is used to update the variable list, which is displayed by this control.
void OnRemoveTable(const wxString &table)
This member function removes the selected table.
NumeReWindow * mainWindow
void OnRenameTable(const wxString &table)
This member function displays a text entry dialog to choose a new name for the selected table.
void ExpandAll()
This member function expands all nodes, which contain child nodes.
wxString GetInternalName(wxTreeItemId id)
Returns the internal variable name of the selected variable.
void ClearTree()
A simple helper function to clean the tree.
void OnSaveasTable(const wxString &table)
This member function displays a text entry dialog to choose the file name for the selected table,...
bool checkSpecialVals(const std::string &sVar)
This member functions checks for special variable names, to highlight them (not used in debug mode).
bool checkPresence(const std::string &sVar)
This member function checks, whether a variable was already part of the previous variable set (only u...
void OnCopyValue(const wxString &value)
Copies the selected text to the clip board.
wxTreeItemId AppendVariable(wxTreeItemId rootNode, std::string sVar)
This member function splits the passed variable at tabulator characters and adds its contents to the ...
wxTreeItemId argumentRoot
void OnNewTable()
This member function displays a text entry dialog to enter the new table names and sends the correspo...
void OnDoubleClick(wxTreeEvent &event)
This event handler displays the selected table.
std::vector< std::string > vLastVarSet
void HandleDebugActions(const std::vector< std::string > &vVarList)
This member function handles every task, which is specific to the debug mode after a variable update.
void OnMenuEvent(wxCommandEvent &event)
This member function handles the menu events created from the popup menu and redirects the control to...
void OnShowTable(const wxString &table, const wxString &tableDisplayName)
This member function displays the selected table.
std::string sInternalName
VarData(const std::string name)
std::string toString(int)
Converts an integer to a string without the Settings bloat.