21#include "../../common/CommonHeaders.h"
22#include "../../kernel/core/ui/language.hpp"
23#include "../../kernel/core/utils/tools.hpp"
25#include <wx/datetime.h>
26#include <wx/stdpaths.h>
31#define HISTORYHEADERSTART "## --- "
65 NumeReTerminal* __terminal, const wxPoint& pos, const wxSize& size,
long style, const wxString&
name) :
66 NumeReEditor(mframe, options, parent,
id, __syntax, __terminal, pos, size, style,
name)
70 m_terminal = __terminal;
75 this->SetUseTabs(
true);
76 this->SetReadOnly(
true);
79 this->SetMarginWidth(0, 0);
80 this->SetMarginType(0, wxSTC_MARGIN_NUMBER);
81 this->SetMarginWidth(1,0);
84 this->StyleSetFont(wxSTC_STYLE_DEFAULT, font);
86 this->StyleClearAll();
88 this->SetMouseDwellTime(250);
90 UpdateSyntaxHighlighting();
93 SetEdgeMode(wxSTC_EDGE_NONE);
94 this->SetCaretLineVisible(
false);
96 this->SetWrapMode(wxSTC_WRAP_WORD);
97 this->SetWrapIndentMode(wxSTC_WRAPINDENT_INDENT);
98 this->SetWrapStartIndent(1);
99 this->SetWrapVisualFlags(wxSTC_WRAPVISUALFLAG_END);
100 this->SetWrapVisualFlagsLocation(wxSTC_WRAPVISUALFLAGLOC_END_BY_TEXT);
102 this->GotoPos(this->GetLastPosition());
125 this->StyleSetFont(wxSTC_STYLE_DEFAULT, font);
126 this->StyleClearAll();
130 this->SetLexer(wxSTC_LEX_NSCR);
132 this->SetProperty(
"fold",
"0");
133 this->SetFoldFlags(wxSTC_FOLDFLAG_LINEAFTER_CONTRACTED | wxSTC_FOLDFLAG_LINEAFTER_EXPANDED);
135 this->SetMarginType(
MARGIN_FOLD, wxSTC_MARGIN_SYMBOL);
137 this->SetMarginMask(
MARGIN_FOLD, wxSTC_MASK_FOLDERS);
139 this->StyleSetBackground(
MARGIN_FOLD, wxColor(200, 200, 200) );
142 wxColor grey( 100, 100, 100 );
143 this->MarkerDefine (wxSTC_MARKNUM_FOLDER, wxSTC_MARK_BOXPLUS);
144 this->MarkerSetForeground (wxSTC_MARKNUM_FOLDER,
"WHITE");
145 this->MarkerSetBackground (wxSTC_MARKNUM_FOLDER, grey);
147 this->MarkerDefine (wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_BOXMINUS);
148 this->MarkerSetForeground (wxSTC_MARKNUM_FOLDEROPEN,
"WHITE");
149 this->MarkerSetBackground (wxSTC_MARKNUM_FOLDEROPEN, grey);
151 this->MarkerDefine (wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_VLINE);
152 this->MarkerSetForeground (wxSTC_MARKNUM_FOLDERSUB, grey);
153 this->MarkerSetBackground (wxSTC_MARKNUM_FOLDERSUB, grey);
155 this->MarkerDefine (wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_BOXPLUSCONNECTED);
156 this->MarkerSetForeground (wxSTC_MARKNUM_FOLDEREND,
"WHITE");
157 this->MarkerSetBackground (wxSTC_MARKNUM_FOLDEREND, grey);
159 this->MarkerDefine (wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_BOXMINUSCONNECTED);
160 this->MarkerSetForeground (wxSTC_MARKNUM_FOLDEROPENMID,
"WHITE");
161 this->MarkerSetBackground (wxSTC_MARKNUM_FOLDEROPENMID, grey);
163 this->MarkerDefine (wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_TCORNER);
164 this->MarkerSetForeground (wxSTC_MARKNUM_FOLDERMIDTAIL, grey);
165 this->MarkerSetBackground (wxSTC_MARKNUM_FOLDERMIDTAIL, grey);
167 this->MarkerDefine (wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_LCORNER);
168 this->MarkerSetForeground (wxSTC_MARKNUM_FOLDERTAIL, grey);
169 this->MarkerSetBackground (wxSTC_MARKNUM_FOLDERTAIL, grey);
177 this->SetKeyWords(4,
"x y z t");
184 for (
int i = 0; i <= wxSTC_NSCR_PROCEDURE_COMMANDS; i++)
189 case wxSTC_NSCR_DEFAULT:
190 case wxSTC_NSCR_IDENTIFIER:
193 case wxSTC_NSCR_NUMBERS:
196 case wxSTC_NSCR_COMMENT_BLOCK:
197 case wxSTC_NSCR_COMMENT_LINE:
200 case wxSTC_NSCR_COMMAND:
203 case wxSTC_NSCR_OPTION:
206 case wxSTC_NSCR_CONSTANTS:
209 case wxSTC_NSCR_FUNCTION:
212 case wxSTC_NSCR_METHOD:
215 case wxSTC_NSCR_PREDEFS:
218 case wxSTC_NSCR_STRING:
221 case wxSTC_NSCR_STRING_PARSER:
224 case wxSTC_NSCR_INCLUDES:
227 case wxSTC_NSCR_PROCEDURES:
230 case wxSTC_NSCR_PROCEDURE_COMMANDS:
233 case wxSTC_NSCR_INSTALL:
236 case wxSTC_NSCR_DEFAULT_VARS:
239 case wxSTC_NSCR_CUSTOM_FUNCTION:
242 case wxSTC_NSCR_CLUSTER:
245 case wxSTC_NSCR_OPERATORS:
246 case wxSTC_NSCR_OPERATOR_KEYWORDS:
251 this->StyleSetForeground(i, _style.
foreground);
253 this->StyleSetBackground(i, _style.
background);
255 this->StyleSetBackground(i, this->StyleGetBackground(wxSTC_STYLE_DEFAULT));
256 this->StyleSetBold(i, _style.
bold);
257 this->StyleSetItalic(i, _style.
italics);
258 this->StyleSetUnderline(i, _style.
underline);
261 this->Colourise(0,-1);
274 switch (event.GetId())
296 if (GetCapture() ==
this)
312 this->SetReadOnly(
false);
316 this->SetReadOnly(
true);
329 this->SetReadOnly(
false);
333 this->SetReadOnly(
true);
356 for (
int i = 1; i < GetLineCount(); i++)
360 DeleteRange(PositionFromLine(i-1), PositionFromLine(i)-PositionFromLine(i-1));
364 if (GetStyleAt(GetLineEndPosition(i)) == wxSTC_NSCR_STRING)
366 InsertText(GetLineEndPosition(i),
"\"");
367 Colourise(PositionFromLine(i), -1);
371 if (GetLineCount() > 10000)
372 DeleteRange(0, PositionFromLine(GetLineCount()-99999));
374 GotoPos(GetLastPosition());
424 int zerolevel = wxSTC_FOLDLEVELBASE;
425 for (
int i = 0; i < this->GetLineCount(); i++)
431 this->SetFoldLevel(i, zerolevel | wxSTC_FOLDLEVELHEADERFLAG);
436 this->SetFoldLevel(i, zerolevel | wxSTC_FOLDLEVELHEADERFLAG);
440 this->SetFoldLevel(i, zerolevel+1);
455 if (!commandstring.length())
458 this->SetReadOnly(
false);
459 this->GotoPos(this->GetLastPosition());
461 wxString cleaned = commandstring.substr(0, commandstring.find_last_not_of(
' ')+1);
467 if (lastline == cleaned)
469 this->SetReadOnly(
true);
474 this->AddText(cleaned);
476 if (commandstring[commandstring.find_last_not_of(
' ')] !=
'\n')
479 Colourise(PositionFromLine(GetCurrentLine()-2), -1);
481 if (GetStyleAt(GetLastPosition()-1) == wxSTC_NSCR_STRING)
482 this->InsertText(GetLastPosition()-1,
"\"");
485 this->SetReadOnly(
true);
498 wxString lastline = GetLine(LineFromPosition(GetLastPosition()-1));
499 lastline.erase(lastline.find_first_of(
"\n\r"));
514 int position =
event.GetPosition();
516 int linenum = this->LineFromPosition(position);
520 int levelClick = this->GetFoldLevel(linenum);
521 if ((levelClick & wxSTC_FOLDLEVELHEADERFLAG) > 0)
522 this->ToggleFold(linenum);
538 int clickedLine = LineFromPosition(PositionFromPoint(event.GetPosition()));
539 wxString line = this->GetLine(clickedLine);
540 if (line.substr(0,6) ==
"## ---")
542 int levelClick = this->GetFoldLevel(clickedLine);
543 if ((levelClick & wxSTC_FOLDLEVELHEADERFLAG) > 0)
544 this->ToggleFold(clickedLine);
547 while (line[line.length()-1] ==
'\r' || line[line.length()-1] ==
'\n')
548 line.erase(line.length()-1);
564 int clickedLine = LineFromPosition(PositionFromPoint(event.GetPosition()));
565 if (this->GetLine(clickedLine).substr(0,6) ==
"## ---")
567 this->SetSelection(PositionFromLine(clickedLine), GetLineEndPosition(clickedLine));
582 int clickedLine = LineFromPosition(PositionFromPoint(event.GetPosition()));
583 if (this->GetLine(clickedLine).substr(0,6) ==
"## ---")
589 wxPoint p =
event.GetPosition();
590 this->PopupMenu(&popupMenu, p);
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 ...
The class of the editor window.
bool SaveFile(const wxString &filename)
NumeReTerminal * m_terminal
NumeReWindow * m_mainframe
void OnMenuEvent(wxCommandEvent &event)
Event handler for the context menu.
void OnMouseDblClk(wxMouseEvent &event)
Double clicking event handler. Will re-execute the selected line or fold the session,...
wxString getLastLine()
Return the last line of the input history.
void applyFoldPoints()
Add fold points to hide previous sessions.
~NumeReHistory()
Empty destructor.
void UpdateSyntaxHighlighting(bool forceUpdate=false)
Update the syntax highlighting to represent the selected syntax colors.
void OnMouseDn(wxMouseEvent &event)
Select the whole line, if the user clicks on a line.
void AddToHistory(const wxString &commandstring)
Add the passed string at the end of the input history.
void saveHistory()
Save the history to the corresponding file.
void addHeader()
Add the history header presenting the current date and time.
void OnMarginClick(wxStyledTextEvent &event)
Event handler for folding.
void copyLine()
Copy the selected line to the clipboard.
void OnRightClick(wxMouseEvent &event)
Event handler to display the context menu, if the user clicks right on a line.
void loadHistory()
Load the history from the corresponding file.
void OnMouseCaptureLost(wxMouseCaptureLostEvent &event)
Ensure that the drag'n drop is handled consistently.
void deleteLine()
Delete the previously selected line.
This class contains all needed keywords to highlight their occurences correspondingly....
std::string getNPRCCommands() const
std::string getConstants() const
std::string getOperators() const
std::string getMethods() const
std::string getCommands() const
std::string getSpecial() const
std::string getFunctions() const
std::string getOptions() const
The terminal class for the GUI. It's a specialisation of the GenericTerminal.
void pass_command(const std::string &command, bool isEvent)
Pass the external command to the kernel without printing it to the console.
This class is the actual NumeRe main frame. The application's logic is implemented here.
wxString getProgramFolder()
This member function returns the application's root path.
This class implements an interface of the internal Settings object adapted to be usable from the GUI.
static wxFont toFont(const std::string &sFontDescr)
SyntaxStyles GetSyntaxStyle(size_t i) const
Return the selected syntax style by constructing it from the style string.
SettingsValue & getSetting(const std::string &value)
Returns a reference to the setting value, which corresponds to the passed string. Throws an exception...
std::string & stringval()
Returns a reference to a std::string value type setting.
#define HISTORYHEADERSTART
bool fileExists(const string &)
This function checks, whether the file with the passed file name exists.
#define SETTING_S_HISTORYFONT
This structure contains the necessary data to completely define a style for a distinctive syntax elem...