21#define CRTDBG_MAP_ALLOC
26#define _ASSERT(expr) ((void)0)
28#define _ASSERTE(expr) ((void)0)
31#include "../../common/CommonHeaders.h"
32#include "../../kernel/core/ui/language.hpp"
33#include "../../kernel/core/utils/tools.hpp"
35#include <wx/datetime.h>
36#include <wx/stdpaths.h>
37#include <wx/tokenzr.h>
38#include <wx/clipbrd.h>
45#include "../NumeReWindow.h"
46#include "../NumeReNotebook.h"
51#include "../../common/datastructures.h"
52#include "../../common/Options.h"
53#include "../../common/vcsmanager.hpp"
54#include "../../common/filerevisions.hpp"
55#include "../dialogs/renamesymbolsdialog.hpp"
56#include "../globals.hpp"
60#define HIGHLIGHT_DBLCLK 26
61#define HIGHLIGHT_MATCHING_BRACE 6
62#define HIGHLIGHT_STRIKETHROUGH 7
63#define HIGHLIGHT_MATCHING_BLOCK 8
64#define HIGHLIGHT_NOT_MATCHING_BLOCK 9
65#define HIGHLIGHT_DIFFERENCES 10
66#define HIGHLIGHT_DIFFERENCE_SOURCE 11
67#define HIGHLIGHT_ANNOTATION 12
68#define HIGHLIGHT_LOCALVARIABLES 13
69#define ANNOTATION_NOTE wxSTC_NSCR_PROCEDURE_COMMANDS+1
70#define ANNOTATION_WARN wxSTC_NSCR_PROCEDURE_COMMANDS+2
71#define ANNOTATION_ERROR wxSTC_NSCR_PROCEDURE_COMMANDS+3
73#define SEMANTICS_VAR 1
74#define SEMANTICS_STRING 2
75#define SEMANTICS_NUM 4
76#define SEMANTICS_FUNCTION 8
148 wxStyledTextCtrl(parent, id, pos, size, style,
name)
195 AutoCompSetIgnoreCase(
true);
196 AutoCompSetCaseInsensitiveBehaviour(wxSTC_CASEINSENSITIVEBEHAVIOUR_RESPECTCASE);
198 SetMultipleSelection(
true);
199 SetVirtualSpaceOptions(wxSTC_SCVS_RECTANGULARSELECTION);
200 SetAdditionalSelectionTyping(
true);
201 SetMultiPaste(wxSTC_MULTIPASTE_EACH);
203 SetMarginWidth(0, 40);
204 SetMarginType(0, wxSTC_MARGIN_NUMBER);
206 SetMarginWidth(1, 20);
207 SetMarginType(1, wxSTC_MARGIN_SYMBOL);
209 SetYCaretPolicy(wxSTC_CARET_SLOP | wxSTC_CARET_STRICT | wxSTC_CARET_EVEN, 1);
211 wxFileName f(wxStandardPaths::Get().GetExecutablePath());
214 wxBitmap(f.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) +
"icons\\cmd.png", wxBITMAP_TYPE_PNG));
216 wxBitmap(f.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) +
"icons\\fnc.png", wxBITMAP_TYPE_PNG));
218 wxBitmap(f.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) +
"icons\\opt.png", wxBITMAP_TYPE_PNG));
220 wxBitmap(f.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) +
"icons\\cnst.png", wxBITMAP_TYPE_PNG));
222 wxBitmap(f.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) +
"icons\\spv.png", wxBITMAP_TYPE_PNG));
224 wxBitmap(f.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) +
"icons\\opr.png", wxBITMAP_TYPE_PNG));
226 wxBitmap(f.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) +
"icons\\mthd.png", wxBITMAP_TYPE_PNG));
228 wxBitmap(f.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) +
"icons\\prc.png", wxBITMAP_TYPE_PNG));
230 wxBitmap(f.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) +
"icons\\var.png", wxBITMAP_TYPE_PNG));
232 wxBitmap(f.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) +
"icons\\cst.png", wxBITMAP_TYPE_PNG));
234 wxBitmap(f.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) +
"icons\\tab.png", wxBITMAP_TYPE_PNG));
237 StyleSetFont(wxSTC_STYLE_DEFAULT, font);
244 SetMouseDwellTime(500);
281 SetMarginSensitive(1,
true);
292 _guilang.
get(
"GUI_MENU_EDITOR_RENAME_SYMBOLS_TTP"));
297 _guilang.
get(
"GUI_MENU_EDITOR_ABSTRAHIZE_SECTION"),
298 _guilang.
get(
"GUI_MENU_EDITOR_ABSTRAHIZE_SECTION_TTP"));
331 int modmask = wxSTC_MOD_INSERTTEXT
332 | wxSTC_MOD_DELETETEXT
334 | wxSTC_PERFORMED_UNDO
335 | wxSTC_PERFORMED_REDO;
337 this->SetModEventMask(modmask);
338 SetScrollWidthTracking(
true);
399 if (!
Modified() && filename.IsEmpty())
404 wxFileName fn(filename);
407 if (!filename.IsEmpty())
413 std::unique_ptr<FileRevisions> revisions;
416 if (filename.find(
"numere.history") == string::npos)
421 if (!revisions->getRevisionCount() && wxFileExists(filename))
423 wxFile tempfile(filename);
425 tempfile.ReadAll(&contents);
426 revisions->addRevision(contents);
429 else if (wxFileExists(filename))
431 wxCopyFile(filename, filename +
".backup",
true);
434 bool bWriteSuccess =
false;
444 filecheck.Open(filename);
449 if (wxFileExists(filename +
".backup"))
450 wxCopyFile(filename +
".backup", filename,
true);
451 else if (revisions.get() && revisions->getRevisionCount())
452 revisions->restoreRevision(revisions->getRevisionCount()-1, filename);
459 if (wxFileExists(filename +
".backup"))
460 wxCopyFile(filename +
".backup", filename,
true);
461 else if (revisions.get() && revisions->getRevisionCount())
462 revisions->restoreRevision(revisions->getRevisionCount()-1, filename);
469 if (wxFileExists(filename +
".backup"))
470 wxCopyFile(filename +
".backup", filename,
true);
471 else if (revisions.get() && revisions->getRevisionCount())
472 revisions->restoreRevision(revisions->getRevisionCount()-1, filename);
480 revisions->addRevision(GetText());
485 wxRemoveFile(filename +
".backup");
513 file.open(filename.ToStdString().c_str(), std::ios_base::out |
std::ios_base::trunc | std::ios_base::binary);
519 for (
int i = 0; i < this->GetLineCount(); i++)
521 file << this->GetLine(i).ToStdString();
542 wxFile file (filename, wxFile::write);
544 if (!file.IsOpened())
550 wxString buf = GetText();
551 bool okay = file.Write(buf.ToStdString().c_str(), buf.ToStdString().length());
578 if (fileContents.length() > 0)
587 InsertText(0, fileContents);
599 if (fileContents.find(
"\r\n") != std::string::npos)
601 eolMode = wxSTC_EOL_CRLF;
604 else if (fileContents.find(
"\r") != std::string::npos)
606 eolMode = wxSTC_EOL_CR;
609 else if (fileContents.find(
"\n") != std::string::npos)
611 eolMode = wxSTC_EOL_LF;
637 bool modified = GetModify();
638 bool readonly = !GetReadOnly();
639 bool canundo = CanUndo();
643 bool isModified = (modified && readonly && canundo) ||
m_bSetUnsaved;
661 const wxChar chr =
event.GetKey();
662 const int currentLine = GetCurrentLine();
663 const int currentPos = GetCurrentPos();
664 const int wordstartpos = WordStartPosition(currentPos,
true);
672 int startLine = LineFromPosition(GetSelectionStart());
673 int endline = LineFromPosition(GetSelectionEnd());
674 int newStartPos = PositionFromLine(startLine);
675 int newEndPos = PositionFromLine(endline) + LineLength(endline);
676 bool doIndent =
event.GetShift();
677 int indentWidth = this->GetIndent();
679 this->SetSelection(newStartPos, newEndPos);
681 for (
int i = startLine; i <= endline; i++)
683 int lineIndent = this->GetLineIndentation(i);
686 this->SetLineIndentation(i, lineIndent + indentWidth);
688 this->SetLineIndentation(i, lineIndent - indentWidth);
695 int previousLineInd = 0;
700 previousLineInd = GetLineIndentation(currentLine - 1);
703 if (previousLineInd == 0)
706 SetLineIndentation(currentLine, previousLineInd);
710 previousLineInd /= GetTabWidth();
712 GotoPos(PositionFromLine(currentLine) + previousLineInd);
716 if ((isspace(chr) || (ispunct(chr) && chr !=
'_' && chr !=
'~')) && AutoCompActive())
721 if (GetStyleAt(currentPos) != wxSTC_NSCR_STRING && GetStyleAt(currentPos) != wxSTC_NPRC_STRING)
722 InsertText(currentPos,
"\"");
727 int nMatchingPos = currentPos;
729 if (this->HasSelection())
730 nMatchingPos = this->GetSelectionEnd();
732 if (this->BraceMatch(currentPos - 1) == wxSTC_INVALID_POSITION)
735 InsertText(nMatchingPos,
")");
737 InsertText(nMatchingPos,
"]");
739 InsertText(nMatchingPos,
"}");
743 int lenEntered = currentPos - wordstartpos;
745 wxString sAutoCompList;
753 int smartSenseWordStart = wordstartpos;
757 smartSenseWordStart--;
763 if (sAutoCompList.length())
764 AutoCompShow(lenEntered, sAutoCompList);
766 else if (lenEntered > 1
774 else if (lenEntered > 1
782 else if (lenEntered > 1
784 && GetStyleAt(wordstartpos) == wxSTC_NSCR_PROCEDURES)
787 wxString sSelectedNamespace;
788 int nNameSpacePosition = wordstartpos;
790 while (GetStyleAt(nNameSpacePosition - 1) == wxSTC_NSCR_PROCEDURES && GetCharAt(nNameSpacePosition - 1) !=
'$')
791 nNameSpacePosition--;
793 if (nNameSpacePosition == wordstartpos)
796 sSelectedNamespace = GetTextRange(nNameSpacePosition, wordstartpos);
799 if (sNamespace ==
"this~")
807 filename.erase(0, vPaths[
PROCPATH].length());
809 if (filename.find(
'/') != string::npos)
810 filename.erase(filename.rfind(
'/') + 1);
812 while (filename.front() ==
'/')
813 filename.erase(0, 1);
815 while (filename.find(
'/') != string::npos)
816 filename[filename.find(
'/')] =
'~';
818 sNamespace = filename;
823 else if (sSelectedNamespace ==
"this~")
831 filename.erase(0, vPaths[
PROCPATH].length());
833 if (filename.find(
'/') != string::npos)
834 filename.erase(filename.rfind(
'/') + 1);
836 while (filename.front() ==
'/')
837 filename.erase(0, 1);
839 while (filename.find(
'/') != string::npos)
840 filename[filename.find(
'/')] =
'~';
842 sSelectedNamespace = filename;
845 sSelectedNamespace =
"";
849 else if (sNamespace ==
"thisfile"
850 || sNamespace ==
"thisfile~"
851 || sSelectedNamespace ==
"thisfile"
852 || sSelectedNamespace ==
"thisfile~")
854 this->AutoCompSetIgnoreCase(
true);
855 this->AutoCompSetCaseInsensitiveBehaviour(wxSTC_CASEINSENSITIVEBEHAVIOUR_IGNORECASE);
857 this->Colourise(0, -1);
862 else if (sNamespace ==
"main" || sNamespace ==
"main~" || sNamespace ==
"~")
864 else if (sSelectedNamespace ==
"main" || sSelectedNamespace ==
"main~" || sSelectedNamespace ==
"~")
865 sSelectedNamespace =
"";
868 sNamespace.ToStdString(), sSelectedNamespace.ToStdString());
870 else if (lenEntered > 1
872 && GetStyleAt(wordstartpos) == wxSTC_TEX_COMMAND)
877 else if (lenEntered > 1)
880 if (sAutoCompList.length())
881 AutoCompShow(lenEntered, sAutoCompList);
899 int curPos = GetCurrentPos();
900 char CurrentChar = GetCharAt(curPos);
905 PrevChar = GetCharAt(curPos - 1);
908 if (CurrentChar ==
')' || CurrentChar ==
']' || CurrentChar ==
'}')
910 else if (PrevChar ==
'(' || PrevChar ==
'[' || PrevChar ==
'{')
912 else if (CurrentChar ==
'(' || CurrentChar ==
'[' || CurrentChar ==
'{')
914 else if (PrevChar ==
')' || PrevChar ==
']' || PrevChar ==
'}')
921 this->IndicatorClearRange(0, GetLastPosition());
922 this->BraceBadLight(wxSTC_INVALID_POSITION);
923 this->BraceHighlight(wxSTC_INVALID_POSITION, wxSTC_INVALID_POSITION);
951 IndicatorClearRange(0, GetLastPosition());
953 IndicatorClearRange(0, GetLastPosition());
963 wxString currentWord = this->GetTextRange(WordStartPosition(GetCurrentPos(),
true), WordEndPosition(GetCurrentPos(),
true));
988 if (this->AutoCompActive())
995 int nStartingBrace = 0;
996 int nArgStartPos = 0;
1001 if (!sFunctionContext.length())
1004 if (sFunctionContext.front() ==
'$')
1014 else if (sFunctionContext.front() ==
'.')
1016 _cTip = _provider.
getMethod(sFunctionContext.substr(1));
1019 if (_cTip.
sDefinition.find(
')', nDotPos) != string::npos)
1058 if (this->CallTipActive() && this->
CallTipStartPos() != nStartingBrace)
1063 else if (!this->CallTipActive())
1066 if (sArgument.length())
1067 this->CallTipSetHighlight(nArgStartPos, nArgStartPos + sArgument.length());
1098 int nCurrentLineStart = this->PositionFromLine(this->GetCurrentLine());
1099 int nCurrentPos = this->GetCurrentPos();
1102 for (
int i = nCurrentPos; i > nCurrentLineStart; i--)
1104 if (this->GetCharAt(i) ==
'('
1105 && (this->BraceMatch(i) >= nCurrentPos || this->BraceMatch(i) == -1)
1106 && (this->GetStyleAt(i - 1) == wxSTC_NSCR_FUNCTION
1107 || this->GetStyleAt(i - 1) == wxSTC_NSCR_PROCEDURES
1108 || this->GetStyleAt(i - 1) == wxSTC_NSCR_METHOD))
1113 if (this->GetStyleAt(i - 1) == wxSTC_NSCR_PROCEDURES)
1117 if (this->GetStyleAt(i - 1) == wxSTC_NSCR_METHOD)
1118 return "." + this->GetTextRange(this->WordStartPosition(i - 1,
true), this->WordEndPosition(i - 1,
true)).ToStdString();
1120 return this->GetTextRange(this->WordStartPosition(i - 1,
true), this->WordEndPosition(i - 1,
true)).ToStdString();
1143 int nCurrentPos = this->GetCurrentPos();
1144 int nCurrentArg = 0;
1145 size_t nParensPos = 0;
1149 if (sCallTip.find(
'(') == string::npos)
1152 nParensPos = sCallTip.find(
'(');
1157 if (sCallTip.find(
"().") != string::npos)
1159 if (sCallTip.find(
'(', sCallTip.find(
"().") + 3) == string::npos)
1162 nParensPos = sCallTip.find(
'(', sCallTip.find(
"().") + 3);
1166 string sArgList = sCallTip.substr(nParensPos);
1170 for (
int i = nStartingBrace + 1; i < nCurrentPos && i < this->GetLineEndPosition(this->GetCurrentLine()); i++)
1175 ||
isStyleType(StyleType::STYLE_COMMENT_BLOCK, i))
1178 currentChar = this->GetCharAt(i);
1182 if (currentChar ==
',')
1186 if ((currentChar ==
'(' || currentChar ==
'[' || currentChar ==
'{')
1187 && this->BraceMatch(i) != -1)
1188 i = this->BraceMatch(i);
1191 size_t nQuotationMarks = 0;
1194 for (
size_t i = 1; i < sArgList.length(); i++)
1198 if (!(nQuotationMarks % 2) && !nCurrentArg && (sArgList[i - 1] ==
'(' || sArgList[i - 1] ==
','))
1200 nArgStartPos = i + nParensPos;
1201 string sArgument = sArgList.substr(i);
1206 if (sArgument.find(
',') != string::npos)
1209 nArgStartPos = nParensPos + sArgList.find(sArgument, i);
1217 if (sArgList[i] ==
'"' && sArgList[i-1] !=
'\\')
1222 if (!(nQuotationMarks % 2) && (sArgList[i] ==
'(' || sArgList[i] ==
'{'))
1227 if (!(nQuotationMarks % 2) && sArgList[i] ==
',')
1265 if (CallTipActive())
1271 CallTipShow(pos, definition);
1309 if (event.GetKeyCode() != WXK_SHIFT
1310 && event.GetKeyCode() != WXK_CAPITAL
1311 && event.GetKeyCode() != WXK_END
1312 && event.GetKeyCode() != WXK_HOME
1313 && event.GetKeyCode() != WXK_LEFT
1314 && event.GetKeyCode() != WXK_RIGHT
1315 && event.GetKeyCode() != WXK_UP
1316 && event.GetKeyCode() != WXK_DOWN)
1318 if (this->HasSelection())
1323 char chr =
event.GetKeyCode();
1324 if (event.ShiftDown() && (chr ==
'8' || chr ==
'9'))
1326 this->BeginUndoAction();
1327 int selStart = this->GetSelectionStart();
1328 int selEnd = this->GetSelectionEnd() + 1;
1329 this->InsertText(selStart,
"(");
1330 this->InsertText(selEnd,
")");
1332 this->GotoPos(selStart);
1334 this->GotoPos(selEnd + 1);
1335 this->EndUndoAction();
1340 else if (event.ShiftDown() && chr ==
'2')
1342 this->BeginUndoAction();
1343 int selStart = this->GetSelectionStart();
1344 int selEnd = this->GetSelectionEnd() + 1;
1345 this->InsertText(selStart,
"\"");
1346 this->InsertText(selEnd,
"\"");
1347 this->GotoPos(selEnd + 1);
1348 this->EndUndoAction();
1353 else if (event.ControlDown() && event.AltDown() && (chr ==
'8' || chr ==
'9'))
1355 this->BeginUndoAction();
1356 int selStart = this->GetSelectionStart();
1357 int selEnd = this->GetSelectionEnd() + 1;
1358 this->InsertText(selStart,
"[");
1359 this->InsertText(selEnd,
"]");
1361 this->GotoPos(selStart);
1363 this->GotoPos(selEnd + 1);
1364 this->EndUndoAction();
1369 else if (event.ControlDown() && event.AltDown() && (chr ==
'7' || chr ==
'0'))
1371 this->BeginUndoAction();
1372 int selStart = this->GetSelectionStart();
1373 int selEnd = this->GetSelectionEnd() + 1;
1374 this->InsertText(selStart,
"{");
1375 this->InsertText(selEnd,
"}");
1377 this->GotoPos(selStart);
1379 this->GotoPos(selEnd + 1);
1380 this->EndUndoAction();
1393 char chr =
event.GetKeyCode();
1394 if (event.ShiftDown() && chr ==
'9')
1397 && GetCharAt(GetCurrentPos()) ==
')'
1398 && BraceMatch(GetCurrentPos()) != wxSTC_INVALID_POSITION)
1400 GotoPos(GetCurrentPos()+1);
1404 else if (event.ShiftDown() && chr ==
'2')
1407 && GetCharAt(GetCurrentPos()) ==
'"'
1408 && GetCharAt(GetCurrentPos()-1) !=
'\\')
1410 GotoPos(GetCurrentPos()+1);
1414 else if (event.ControlDown() && event.AltDown() && chr ==
'9')
1417 && GetCharAt(GetCurrentPos()) ==
']'
1418 && BraceMatch(GetCurrentPos()) != wxSTC_INVALID_POSITION)
1420 GotoPos(GetCurrentPos()+1);
1424 else if (event.ControlDown() && event.AltDown() && chr ==
'0')
1427 && GetCharAt(GetCurrentPos()) ==
'}'
1428 && BraceMatch(GetCurrentPos()) != wxSTC_INVALID_POSITION)
1430 GotoPos(GetCurrentPos()+1);
1440 if (AutoCompActive()
1442 && (event.GetKeyCode() == WXK_END || event.GetKeyCode() == WXK_HOME))
1451 if (this->GetSelections() <= 1)
1459 if (!event.ControlDown() && !event.ShiftDown())
1475 if (this->GetSelections() <= 1)
1517 if (!event.ControlDown())
1537 int charpos = PositionFromPoint(event.GetPosition());
1538 int startPosition = WordStartPosition(charpos,
true);
1539 int endPosition = WordEndPosition(charpos,
true);
1540 wxString
selection = this->GetTextRange(startPosition, endPosition);
1551 if (event.ControlDown() && this->HasSelection())
1552 this->AddSelection(endPosition, startPosition);
1554 this->SetSelection(startPosition, endPosition);
1557 long int maxpos = GetLastPosition();
1561 IndicatorClearRange(0, maxpos);
1565 int nLength = endPosition - startPosition;
1566 vector<int> vSelectionList;
1569 while ((nPos = FindText(nCurr, maxpos,
selection, wxSTC_FIND_MATCHCASE | wxSTC_FIND_WHOLEWORD)) != wxNOT_FOUND)
1571 vSelectionList.push_back(nPos);
1572 nCurr = nPos + nLength;
1576 for (
size_t i = 0; i < vSelectionList.size(); i++)
1577 this->IndicatorFillRange(vSelectionList[i], nLength);
1595 if (GetCapture() ==
this)
1652 if (this->CallTipActive())
1675 int charpos =
event.GetPosition();
1676 int startPosition = WordStartPosition(charpos,
true);
1677 int endPosition = WordEndPosition(charpos,
true);
1680 wxString
selection = this->GetTextRange(startPosition, endPosition);
1683 if (GetStyleAt(charpos) == wxSTC_NSCR_FUNCTION)
1685 else if (GetStyleAt(charpos) == wxSTC_NSCR_COMMAND
1686 || GetStyleAt(charpos) == wxSTC_NSCR_PROCEDURE_COMMANDS)
1691 if (
id != wxNOT_FOUND)
1700 size_t lastpos2 = 0;
1708 +
"_*"), lastpos)) +
"\n [...]\n";
1718 +
"_*"), lastpos2)) +
"\n [...]\n";
1742 CallTipSetHighlight(nLength,
selection.length() + nLength);
1748 else if (GetStyleAt(charpos) == wxSTC_NSCR_PROCEDURES)
1750 if (GetCharAt(charpos) !=
'$')
1764 wxString flags =
"";
1766 if (!procdef.length())
1769 size_t nSepPos = std::string::npos;
1771 if (procdef.find(
"::") != std::string::npos)
1772 nSepPos = procdef.find(
"::");
1773 else if (procdef.find(
" -> ") != std::string::npos)
1774 nSepPos = procdef.find(
" -> ");
1775 else if (procdef.find(
'\n') != std::string::npos)
1776 nSepPos = procdef.find(
'\n');
1778 if (nSepPos != std::string::npos)
1780 flags = procdef.substr(nSepPos);
1781 procdef.erase(nSepPos);
1784 if (flags.find(
'\n') != string::npos)
1789 CallTipSetHighlight(0, procdef.length());
1792 else if (GetStyleAt(charpos) == wxSTC_NSCR_OPTION)
1794 else if (GetStyleAt(charpos) == wxSTC_NSCR_METHOD)
1796 else if (GetStyleAt(charpos) == wxSTC_NSCR_PREDEFS)
1798 else if (GetStyleAt(charpos) == wxSTC_NSCR_CONSTANTS)
1809 CallTipSetHighlight(_cTip.
nStart, _cTip.
nEnd);
1900 if (event.GetText()[event.GetText().length()-1] ==
'(')
1905 && (GetCharAt(GetCurrentPos()) !=
'(' || BraceMatch(GetCurrentPos()) == wxSTC_INVALID_POSITION))
1906 InsertText(GetCurrentPos(),
"()");
1910 Replace(event.GetPosition(), GetCurrentPos(), event.GetText().substr(0, event.GetText().length()-1));
1916 else if (event.GetText()[event.GetText().length()-1] ==
'{')
1921 && (GetCharAt(GetCurrentPos()) !=
'{' || BraceMatch(GetCurrentPos()) == wxSTC_INVALID_POSITION))
1922 InsertText(GetCurrentPos(),
"{}");
1926 Replace(event.GetPosition(), GetCurrentPos(), event.GetText().substr(0, event.GetText().length()-1));
1937 size_t pos = sAutoComp.find(
'|');
1940 sAutoComp.erase(pos, 1);
1944 Replace(event.GetPosition(), GetCurrentPos(), sAutoComp);
1948 if (sAutoComp.find(
"\r\n") != std::string::npos)
1949 SetLineIndentation(LineFromPosition(event.GetPosition())+1, GetLineIndentation(LineFromPosition(event.GetPosition())));
1952 GotoPos(event.GetPosition() + pos);
1975 int nSelectionStart = -1;
1976 int nSelectionEnd = 0;
1977 int nCommentStyle = 0;
1978 int nCommentCharSequenceLen = 0;
1979 wxString sLineCommentCharSequence;
1984 sLineCommentCharSequence =
"## ";
1985 nCommentStyle = wxSTC_NSCR_COMMENT_LINE;
1989 sLineCommentCharSequence =
"% ";
1990 nCommentStyle = wxSTC_TEX_DEFAULT;
1994 sLineCommentCharSequence =
"# ";
1995 nCommentStyle = wxSTC_MATLAB_COMMENT;
1999 sLineCommentCharSequence =
"% ";
2000 nCommentStyle = wxSTC_MATLAB_COMMENT;
2004 sLineCommentCharSequence =
"// ";
2005 nCommentStyle = wxSTC_C_COMMENTLINE;
2008 nCommentCharSequenceLen = sLineCommentCharSequence.length();
2013 nSelectionStart = GetSelectionStart();
2014 nSelectionEnd = GetSelectionEnd();
2015 nFirstLine = LineFromPosition(nSelectionStart);
2016 nLastLine = LineFromPosition(nSelectionEnd);
2020 nFirstLine = GetCurrentLine();
2021 nLastLine = nFirstLine;
2027 for (
int i = nFirstLine; i <= nLastLine; i++)
2029 int position = PositionFromLine(i);
2031 while (GetCharAt(position) ==
' ' || GetCharAt(position) ==
'\t')
2034 int style = GetStyleAt(position);
2041 if (GetCharAt(position + nCommentCharSequenceLen-1) ==
' ')
2044 if (i == nFirstLine && nSelectionStart >= 0 && nSelectionStart >= position + nCommentCharSequenceLen)
2045 nSelectionStart -= nCommentCharSequenceLen;
2046 else if (i == nFirstLine && nSelectionStart >= 0)
2047 nSelectionStart = position;
2049 DeleteRange(position, nCommentCharSequenceLen);
2050 nSelectionEnd -= nCommentCharSequenceLen;
2055 if (i == nFirstLine && nSelectionStart >= 0 && nSelectionStart >= position + nCommentCharSequenceLen-1)
2056 nSelectionStart -= nCommentCharSequenceLen-1;
2057 else if (i == nFirstLine && nSelectionStart >= 0)
2058 nSelectionStart = position;
2060 DeleteRange(position, nCommentCharSequenceLen-1);
2061 nSelectionEnd -= nCommentCharSequenceLen-1;
2064 else if ((
m_fileType ==
FILE_TEXSOURCE && (GetStyleAt(position + 1) != wxSTC_TEX_DEFAULT || GetCharAt(position) !=
'%'))
2068 InsertText(PositionFromLine(i), sLineCommentCharSequence);
2070 if (nSelectionStart >= 0)
2072 nSelectionStart += nCommentCharSequenceLen;
2073 nSelectionEnd += nCommentCharSequenceLen;
2078 if (nSelectionStart >= 0)
2079 SetSelection(nSelectionStart, nSelectionEnd);
2102 if (!HasSelection())
2105 int nFirstPosition = GetSelectionStart();
2106 int nLastPosition = GetSelectionEnd();
2107 int nSelectionStart = nFirstPosition;
2108 int nSelectionEnd = nLastPosition;
2109 int style = GetStyleAt(nFirstPosition);
2110 int nCommentStyle = wxSTC_NSCR_COMMENT_BLOCK;
2111 wxString sBlockCommentStart =
"#* ";
2112 wxString sBlockCommentEnd =
" *#";
2127 sBlockCommentEnd =
" */";
2128 sBlockCommentStart =
"/* ";
2129 nCommentStyle = wxSTC_C_COMMENT;
2133 sBlockCommentEnd =
" -->";
2134 sBlockCommentStart =
"<!-- ";
2135 nCommentStyle = wxSTC_H_COMMENT;
2140 if (style == nCommentStyle)
2143 while (nFirstPosition && GetStyleAt(nFirstPosition - 1) == nCommentStyle)
2146 if (GetStyleAt(nLastPosition) != nCommentStyle)
2147 nLastPosition = nFirstPosition;
2150 while (nLastPosition < GetLastPosition() && GetStyleAt(nLastPosition) == nCommentStyle)
2154 if (GetTextRange(nLastPosition - sBlockCommentEnd.length(), nLastPosition) == sBlockCommentEnd)
2156 if (nSelectionEnd > nLastPosition - (
int)sBlockCommentEnd.length())
2157 nSelectionEnd -= sBlockCommentEnd.length();
2159 DeleteRange(nLastPosition - sBlockCommentEnd.length(), sBlockCommentEnd.length());
2163 if (nSelectionEnd > nLastPosition - (
int)sBlockCommentEnd.length() + 1)
2164 nSelectionEnd -= sBlockCommentEnd.length() - 1;
2166 DeleteRange(nFirstPosition - sBlockCommentEnd.length() + 1, sBlockCommentEnd.length() - 1);
2170 if (GetTextRange(nFirstPosition, nFirstPosition + sBlockCommentStart.length()) == sBlockCommentStart)
2172 if (nFirstPosition != nSelectionStart)
2173 nSelectionStart -= sBlockCommentStart.length();
2175 DeleteRange(nFirstPosition, sBlockCommentStart.length());
2176 nSelectionEnd -= sBlockCommentStart.length();
2180 if (nFirstPosition != nSelectionStart)
2181 nSelectionStart -= sBlockCommentStart.length() - 1;
2183 DeleteRange(nFirstPosition, sBlockCommentStart.length() - 1);
2184 nSelectionEnd -= sBlockCommentStart.length() - 1;
2190 InsertText(nFirstPosition, sBlockCommentStart);
2191 InsertText(nLastPosition + sBlockCommentStart.length(), sBlockCommentEnd);
2192 nSelectionEnd += sBlockCommentEnd.length();
2193 nSelectionStart += sBlockCommentStart.length();
2197 SetSelection(nSelectionStart, nSelectionEnd);
2209 for (
int i = GetLineCount() - 1; i >= 0; i--)
2211 if (GetFoldLevel(i) & wxSTC_FOLDLEVELHEADERFLAG && GetFoldExpanded(i))
2225 for (
int i = 0; i < GetLineCount(); i++)
2227 if (GetFoldLevel(i) & wxSTC_FOLDLEVELHEADERFLAG && !GetFoldExpanded(i))
2244 int nCurrentLine = GetCurrentLine();
2260 nMarker = MarkerNext(nCurrentLine, nMarkerMask);
2262 nMarker = MarkerPrevious(nCurrentLine, nMarkerMask);
2268 nMarker = MarkerNext(0, nMarkerMask);
2270 nMarker = MarkerPrevious(LineFromPosition(GetLastPosition()), nMarkerMask);
2289 vector<int> vBookmarks;
2292 for (
int i = 0; i < GetLineCount(); i++)
2295 vBookmarks.push_back(i);
2317 for (
size_t i = 0; i < vBookmarks.size(); i++)
2338 int nLastLine = GetLineCount() - 1;
2344 nFirstline = LineFromPosition(GetSelectionStart());
2345 nLastLine = LineFromPosition(GetSelectionEnd());
2352 for (
int i = nFirstline; i <= nLastLine; i++)
2355 SetLineIndentation(i, 0);
2358 wxString sLine = this->GetLine(i);
2360 if (sLine.find_first_of(
"\r\n") != string::npos)
2361 sLine.erase(sLine.find_first_of(
"\r\n"));
2363 int nLineEndPos = sLine.length();
2365 while (nLineEndPos && (sLine[nLineEndPos - 1] ==
' ' || sLine[nLineEndPos - 1] ==
'\t'))
2367 sLine.erase(nLineEndPos - 1);
2373 while (sLine[0] ==
' ' || sLine[0] ==
'\t')
2377 Replace(this->PositionFromLine(i), this->GetLineEndPosition(i), sLine);
2393 int nLine = GetCurrentLine();
2428 int nLastLine = GetLineCount() - 1;
2429 map<string, int> mSortMap;
2430 vector<wxString> vSortVector;
2431 string sCurrentLine;
2436 nFirstline = LineFromPosition(GetSelectionStart());
2437 nLastLine = LineFromPosition(GetSelectionEnd());
2446 for (
int i = nFirstline; i <= nLastLine; i++)
2449 vSortVector.push_back(this->GetLine(i));
2451 if (vSortVector[i - nFirstline].find_first_of(
"\r\n") != string::npos)
2452 vSortVector[i - nFirstline].erase(vSortVector[i - nFirstline].find_first_of(
"\r\n"));
2455 sCurrentLine =
toLowerCase(vSortVector[i - nFirstline].ToStdString());
2458 if (!sCurrentLine.length())
2459 sCurrentLine =
" " +
toString(i + 256);
2461 if (mSortMap.find(sCurrentLine) != mSortMap.end())
2462 sCurrentLine +=
"\n" +
toString(i + 256);
2465 mSortMap[sCurrentLine] = i - nFirstline;
2472 for (
auto iter = mSortMap.begin(); iter != mSortMap.end(); ++iter)
2474 this->Replace(this->PositionFromLine(nFirstline), this->GetLineEndPosition(nFirstline), vSortVector[iter->second]);
2480 for (
auto iter = mSortMap.rbegin(); iter != mSortMap.rend(); ++iter)
2482 this->Replace(this->PositionFromLine(nFirstline), this->GetLineEndPosition(nFirstline), vSortVector[iter->second]);
2502 if (
func ==
"time" ||
func ==
"clock" ||
func ==
"to_time")
2508 sRetVal.erase(0, sRetVal.find_first_not_of(
' ', sRetVal.find(
')')+1));
2509 sRetVal.erase(sRetVal.find_first_of(
" -"));
2513 if (sRetVal ==
"VAL" || sRetVal ==
"{VAL}" || sRetVal ==
"MAT" || sRetVal ==
"VEC")
2515 else if (sRetVal ==
"LOG" || sRetVal ==
"{LOG}")
2517 else if (sRetVal ==
"STR" || sRetVal ==
"{STR}")
2519 else if (sRetVal ==
"ARG" || sRetVal ==
"{ARG}")
2540 if (sRetVal.find(
"->") == std::string::npos)
2543 sRetVal.erase(0, sRetVal.find_first_not_of(
' ', sRetVal.find(
"->")+2));
2544 sRetVal.erase(sRetVal.find_first_of(
" -"));
2548 if (sRetVal ==
"VAL" || sRetVal ==
"{VAL}" || sRetVal ==
"MAT" || sRetVal ==
"VEC")
2550 else if (sRetVal ==
"LOG" || sRetVal ==
"{LOG}")
2552 else if (sRetVal ==
"STR" || sRetVal ==
"{STR}")
2554 else if (sRetVal ==
"ARG" || sRetVal ==
"{ARG}")
2573 if (val.find(
"##") != std::string::npos)
2574 val.erase(val.find(
"##"));
2580 for (
size_t i = 0; i < val.size(); i++)
2582 if (val[i] ==
'(' || val[i] ==
'[' || val[i] ==
'{')
2587 if (pos == std::string::npos)
2595 if (val[i] ==
')' || val[i] ==
']' || val[i] ==
'}')
2605 if (val.back() ==
';')
2608 if (val ==
"true" || val ==
"false")
2610 else if (val.find_first_not_of(
"0123456789^, ") == std::string::npos)
2617 else if (val.find_first_of(
"/^'") != std::string::npos)
2619 else if (val.length() > 2 && val[0] ==
'_' && std::islower(val[1]) && std::isupper(val[2]))
2621 else if (val.length() > 1 && std::islower(val[0]) && std::isupper(val[1]))
2649 std::string sSymbol = GetTextRange(WordStartPosition(pos,
true), WordEndPosition(pos,
true)).ToStdString();
2650 std::string sOldName = sSymbol;
2653 std::vector<int> vMatches =
m_search->
FindAll(sSymbol, GetStyleAt(pos),
2654 PositionFromLine(context.first), GetLineEndPosition(context.second),
false);
2657 wxString lineContent = GetLine(LineFromPosition(vMatches.front())).Strip(wxString::both);
2664 if (lineContent.StartsWith(
"str "))
2670 for (
int match : vMatches)
2672 match += sSymbol.length();
2673 int lineStartPosition = PositionFromLine(LineFromPosition(match));
2674 lineContent = GetLine(LineFromPosition(match)).Strip(wxString::both);
2677 if (lineContent.rfind(
'{', match-lineStartPosition) != std::string::npos
2678 && lineContent.find(
'}', match-lineStartPosition) != std::string::npos)
2682 while (GetCharAt(pos) !=
'{')
2685 pos = BraceMatch(pos);
2695 if (GetTextRange(match, match+2) ==
"++" || GetTextRange(match, match+2) ==
"--")
2703 while (GetCharAt(match) ==
' ' || GetCharAt(match) ==
'\t' || GetCharAt(match) ==
':')
2707 if (GetCharAt(match) ==
'=' && GetCharAt(match+1) !=
'=')
2713 while (GetCharAt(match) ==
' ' || GetCharAt(match) ==
'\t')
2720 else if (GetStyleAt(match) == wxSTC_NSCR_CONSTANTS)
2733 char commandType =
applyCommandHeuristics(GetTextRange(match, WordEndPosition(match,
true)).ToStdString());
2742 char valtype =
applyValueHeuristics(GetTextRange(match, GetLineEndPosition(LineFromPosition(match))).ToStdString());
2759 if (sSymbol != sOldName)
2761 int ret = wxMessageBox(
_guilang.
get(
"GUI_EDITOR_FIX_TYPE_MESSAGE", sOldName, sSymbol),
2763 wxCENTER | wxYES_NO,
2804 wxFont newFont = font;
2805 StyleSetFont(wxSTC_STYLE_DEFAULT, newFont);
2837 SetWhitespaceForeground(
true, wxColor(170, 190, 210));
2838 SetWhitespaceSize(2);
2850 SetWrapMode(wxSTC_WRAP_WORD);
2851 SetWrapIndentMode(wxSTC_WRAPINDENT_INDENT);
2852 SetWrapStartIndent(1);
2853 SetWrapVisualFlags(wxSTC_WRAPVISUALFLAG_END);
2854 SetWrapVisualFlagsLocation(wxSTC_WRAPVISUALFLAGLOC_END_BY_TEXT);
2859 SetViewWhiteSpace(wxSTC_WS_VISIBLEALWAYS);
2873 SetWrapMode(wxSTC_WRAP_NONE);
2877 SetViewWhiteSpace(wxSTC_WS_INVISIBLE);
2882 IndicatorClearRange(0, GetLastPosition());
2906 int nMatch = BraceMatch(nPos);
2909 if (nMatch == wxSTC_INVALID_POSITION)
2910 BraceBadLight(nPos);
2916 IndicatorClearRange(0, GetLastPosition());
2920 BraceHighlight(nMatch, nPos);
2921 IndicatorFillRange(nMatch + 1, nPos - nMatch - 1);
2925 BraceHighlight(nPos, nMatch);
2926 IndicatorFillRange(nPos + 1, nMatch - nPos - 1);
2953 if (vMatch.size() == 1 && vMatch[0] == wxSTC_INVALID_POSITION)
2958 if (vMatch.front() == wxSTC_INVALID_POSITION || vMatch.back() == wxSTC_INVALID_POSITION)
2964 IndicatorClearRange(0, GetLastPosition());
2967 for (
size_t i = 0; i < vMatch.size(); i++)
2969 if (vMatch[i] == wxSTC_INVALID_POSITION)
2972 IndicatorFillRange(vMatch[i], WordEndPosition(vMatch[i],
true) - vMatch[i]);
3004 vPos.push_back(wxSTC_INVALID_POSITION);
3021 for (
size_t i = 0; i < vBlocks.size(); i++)
3023 if ((
int)i == nBlockID && vBlocks[i] != 1)
3025 else if ((
int)i != nBlockID && vBlocks[i])
3046 int nStartPos = WordStartPosition(nPos,
true);
3048 wxString startblock;
3051 int searchForMiddleWords = wxNOT_FOUND;
3054 if (GetStyleAt(nPos) != wxSTC_NSCR_COMMAND && GetStyleAt(nPos) != wxSTC_NPRC_COMMAND)
3056 if (nPos && GetStyleAt(nPos - 1) == wxSTC_NSCR_COMMAND)
3060 vPos.push_back(wxSTC_INVALID_POSITION);
3065 startblock = GetTextRange(WordStartPosition(nPos,
true), WordEndPosition(nPos,
true));
3069 if (startblock.substr(0, 3) ==
"end")
3074 else if (blockMiddle != wxNOT_FOUND)
3078 vBlocks[blockMiddle]++;
3080 for (
int i = WordEndPosition(nPos,
true); i >= 0; i--)
3082 if (GetStyleAt(i) == wxSTC_NSCR_COMMAND)
3084 wxString currentWord = GetTextRange(WordStartPosition(i,
true), WordEndPosition(i,
true));
3089 if (block != wxNOT_FOUND)
3091 else if ((block =
isBlockEnd(currentWord)) != wxNOT_FOUND)
3094 if (block == blockMiddle
3095 && !(*std::min_element(vBlocks.begin(), vBlocks.end()))
3096 && !(*std::max_element(vBlocks.begin(), vBlocks.end())))
3098 nStartPos = WordStartPosition(i,
true);
3102 i -= currentWord.length();
3105 if (*std::min_element(vBlocks.begin(), vBlocks.end()) < 0)
3109 vPos.push_back(wxSTC_INVALID_POSITION);
3114 if (*std::max_element(vBlocks.begin(), vBlocks.end()) > 0)
3118 vPos.push_back(wxSTC_INVALID_POSITION);
3119 vBlocks.assign(vBlocks.size(), 0);
3120 vBlocks[blockMiddle] = 1;
3123 vBlocks.assign(vBlocks.size(), 0);
3125 searchForMiddleWords = blockMiddle;
3131 if (!endblock.length())
3133 vPos.push_back(wxSTC_INVALID_POSITION);
3140 vPos.push_back(nStartPos);
3142 if (nSearchDir == -1)
3143 nStartPos = WordEndPosition(nPos,
true);
3145 for (
int i = nStartPos; (i < GetLastPosition() && i >= 0); i += nSearchDir)
3147 if (GetStyleAt(i) == wxSTC_NSCR_COMMAND)
3149 wxString currentWord = GetTextRange(WordStartPosition(i,
true), WordEndPosition(i,
true));
3154 if (block != wxNOT_FOUND)
3155 vBlocks[block] += nSearchDir;
3156 else if ((block =
isBlockEnd(currentWord)) != wxNOT_FOUND)
3157 vBlocks[block] -= nSearchDir;
3160 if (searchForMiddleWords != wxNOT_FOUND
3163 vPos.push_back(WordStartPosition(i,
true));
3165 if (currentWord == endblock
3166 && !(*std::min_element(vBlocks.begin(), vBlocks.end()))
3167 && !(*std::max_element(vBlocks.begin(), vBlocks.end())))
3169 vPos.push_back(WordStartPosition(i,
true));
3173 i += nSearchDir * currentWord.length();
3176 if (*std::min_element(vBlocks.begin(), vBlocks.end()) < 0)
3179 vPos.push_back(wxSTC_INVALID_POSITION);
3184 if (!vPos.size() || (*std::max_element(vBlocks.begin(), vBlocks.end()) > 0))
3185 vPos.push_back(wxSTC_INVALID_POSITION);
3204 int nStartPos = WordStartPosition(nPos,
true);
3206 wxString startblock;
3208 bool bSearchForIf =
false;
3209 bool bSearchForSwitch =
false;
3210 bool bSearchForCatch =
false;
3213 if (GetStyleAt(nPos) != wxSTC_MATLAB_KEYWORD)
3215 if (nPos && GetStyleAt(nPos - 1) == wxSTC_MATLAB_KEYWORD)
3219 vPos.push_back(wxSTC_INVALID_POSITION);
3225 startblock = GetTextRange(WordStartPosition(nPos,
true), WordEndPosition(nPos,
true));
3227 if (startblock ==
"end")
3232 for (
int i = WordStartPosition(nPos,
true); i >= 0; i--)
3234 if (GetStyleAt(i) == wxSTC_MATLAB_KEYWORD)
3236 wxString currentWord = GetTextRange(WordStartPosition(i,
true), WordEndPosition(i,
true));
3238 if (currentWord ==
"for"
3239 || currentWord ==
"while"
3240 || currentWord ==
"function"
3241 || currentWord ==
"if"
3242 || currentWord ==
"switch"
3243 || currentWord ==
"try"
3244 || currentWord ==
"classdef"
3245 || currentWord ==
"properties"
3246 || currentWord ==
"methods")
3248 else if (currentWord ==
"end")
3253 nStartPos = WordStartPosition(i,
true);
3254 startblock = currentWord;
3255 if (currentWord ==
"if")
3256 bSearchForIf =
true;
3257 if (currentWord ==
"switch")
3258 bSearchForSwitch =
true;
3259 if (currentWord ==
"try")
3260 bSearchForCatch =
true;
3264 i -= currentWord.length();
3271 vPos.push_back(wxSTC_INVALID_POSITION);
3278 else if (startblock ==
"else" || startblock ==
"elseif")
3283 for (
int i = WordEndPosition(nPos,
true); i >= 0; i--)
3285 if (GetStyleAt(i) == wxSTC_MATLAB_KEYWORD)
3287 wxString currentWord = GetTextRange(WordStartPosition(i,
true), WordEndPosition(i,
true));
3289 if (currentWord ==
"for"
3290 || currentWord ==
"while"
3291 || currentWord ==
"function"
3292 || currentWord ==
"if"
3293 || currentWord ==
"switch"
3294 || currentWord ==
"try"
3295 || currentWord ==
"classdef"
3296 || currentWord ==
"properties"
3297 || currentWord ==
"methods")
3299 else if (currentWord ==
"end")
3302 if (currentWord ==
"if" && !nBlock)
3304 nStartPos = WordStartPosition(i,
true);
3309 i -= currentWord.length();
3316 vPos.push_back(wxSTC_INVALID_POSITION);
3325 vPos.push_back(wxSTC_INVALID_POSITION);
3331 bSearchForIf =
true;
3334 else if (startblock ==
"case" || startblock ==
"otherwise")
3340 for (
int i = WordEndPosition(nPos,
true); i >= 0; i--)
3342 if (GetStyleAt(i) == wxSTC_MATLAB_KEYWORD)
3344 wxString currentWord = GetTextRange(WordStartPosition(i,
true), WordEndPosition(i,
true));
3346 if (currentWord ==
"for"
3347 || currentWord ==
"while"
3348 || currentWord ==
"function"
3349 || currentWord ==
"if"
3350 || currentWord ==
"switch"
3351 || currentWord ==
"try"
3352 || currentWord ==
"classdef"
3353 || currentWord ==
"properties"
3354 || currentWord ==
"methods")
3356 else if (currentWord ==
"end")
3359 if (currentWord ==
"switch" && !nBlock)
3361 nStartPos = WordStartPosition(i,
true);
3362 startblock =
"switch";
3366 i -= currentWord.length();
3373 vPos.push_back(wxSTC_INVALID_POSITION);
3382 vPos.push_back(wxSTC_INVALID_POSITION);
3388 bSearchForSwitch =
true;
3391 else if (startblock ==
"catch")
3397 for (
int i = WordEndPosition(nPos,
true); i >= 0; i--)
3399 if (GetStyleAt(i) == wxSTC_MATLAB_KEYWORD)
3401 wxString currentWord = GetTextRange(WordStartPosition(i,
true), WordEndPosition(i,
true));
3403 if (currentWord ==
"for"
3404 || currentWord ==
"while"
3405 || currentWord ==
"function"
3406 || currentWord ==
"if"
3407 || currentWord ==
"switch"
3408 || currentWord ==
"try"
3409 || currentWord ==
"classdef"
3410 || currentWord ==
"properties"
3411 || currentWord ==
"methods")
3413 else if (currentWord ==
"end")
3416 if (currentWord ==
"try" && !nBlock)
3418 nStartPos = WordStartPosition(i,
true);
3423 i -= currentWord.length();
3430 vPos.push_back(wxSTC_INVALID_POSITION);
3439 vPos.push_back(wxSTC_INVALID_POSITION);
3445 bSearchForCatch =
true;
3449 if (startblock ==
"for"
3450 || startblock ==
"while"
3451 || startblock ==
"function"
3452 || startblock ==
"if"
3453 || startblock ==
"switch"
3454 || startblock ==
"try"
3455 || startblock ==
"classdef"
3456 || startblock ==
"properties"
3457 || startblock ==
"methods")
3461 vPos.push_back(wxSTC_INVALID_POSITION);
3465 if (startblock ==
"if" || endblock ==
"if")
3466 bSearchForIf =
true;
3468 if (startblock ==
"switch" || endblock ==
"switch")
3469 bSearchForSwitch =
true;
3471 if (startblock ==
"try" || endblock ==
"try")
3472 bSearchForCatch =
true;
3474 vPos.push_back(nStartPos);
3479 for (
int i = nStartPos; (i < GetLastPosition() && i >= 0); i += nSearchDir)
3481 if (GetStyleAt(i) == wxSTC_MATLAB_KEYWORD)
3483 wxString currentWord = GetTextRange(WordStartPosition(i,
true), WordEndPosition(i,
true));
3485 if (currentWord ==
"for"
3486 || currentWord ==
"while"
3487 || currentWord ==
"function"
3488 || currentWord ==
"if"
3489 || currentWord ==
"switch"
3490 || currentWord ==
"try"
3491 || currentWord ==
"classdef"
3492 || currentWord ==
"properties"
3493 || currentWord ==
"methods")
3494 nBlock += nSearchDir;
3495 else if (currentWord ==
"end")
3496 nBlock -= nSearchDir;
3498 if (bSearchForIf && nBlock == 1
3499 && (currentWord ==
"else" || currentWord ==
"elseif"))
3500 vPos.push_back(WordStartPosition(i,
true));
3502 if (bSearchForSwitch && nBlock == 1
3503 && (currentWord ==
"case" || currentWord ==
"otherwise"))
3504 vPos.push_back(WordStartPosition(i,
true));
3506 if (bSearchForCatch && nBlock == 1
3507 && currentWord ==
"catch")
3508 vPos.push_back(WordStartPosition(i,
true));
3510 if (currentWord == endblock && !nBlock)
3512 vPos.push_back(WordStartPosition(i,
true));
3516 i += nSearchDir * currentWord.length();
3522 vPos.push_back(wxSTC_INVALID_POSITION);
3529 vPos.push_back(wxSTC_INVALID_POSITION);
3595 SetFoldFlags(wxSTC_FOLDFLAG_LINEAFTER_CONTRACTED);
3601 StyleSetBackground(
MARGIN_FOLD, wxColor(200, 200, 200) );
3604 wxColor grey( 100, 100, 100 );
3605 MarkerDefine (wxSTC_MARKNUM_FOLDER, wxSTC_MARK_BOXPLUS);
3606 MarkerSetForeground (wxSTC_MARKNUM_FOLDER,
"WHITE");
3607 MarkerSetBackground (wxSTC_MARKNUM_FOLDER, grey);
3609 MarkerDefine (wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_BOXMINUS);
3610 MarkerSetForeground (wxSTC_MARKNUM_FOLDEROPEN,
"WHITE");
3611 MarkerSetBackground (wxSTC_MARKNUM_FOLDEROPEN, grey);
3613 MarkerDefine (wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_VLINE);
3614 MarkerSetForeground (wxSTC_MARKNUM_FOLDERSUB, grey);
3615 MarkerSetBackground (wxSTC_MARKNUM_FOLDERSUB, grey);
3617 MarkerDefine (wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_BOXPLUSCONNECTED);
3618 MarkerSetForeground (wxSTC_MARKNUM_FOLDEREND,
"WHITE");
3619 MarkerSetBackground (wxSTC_MARKNUM_FOLDEREND, grey);
3621 MarkerDefine (wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_BOXMINUSCONNECTED);
3622 MarkerSetForeground (wxSTC_MARKNUM_FOLDEROPENMID,
"WHITE");
3623 MarkerSetBackground (wxSTC_MARKNUM_FOLDEROPENMID, grey);
3625 MarkerDefine (wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_TCORNER);
3626 MarkerSetForeground (wxSTC_MARKNUM_FOLDERMIDTAIL, grey);
3627 MarkerSetBackground (wxSTC_MARKNUM_FOLDERMIDTAIL, grey);
3629 MarkerDefine (wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_LCORNER);
3630 MarkerSetForeground (wxSTC_MARKNUM_FOLDERTAIL, grey);
3631 MarkerSetBackground (wxSTC_MARKNUM_FOLDERTAIL, grey);
3633 MarkerEnableHighlight(
true);
3639 this->SetLexer(wxSTC_LEX_NSCR);
3640 this->SetProperty(
"fold",
"1");
3655 for (
int i = 0; i <= wxSTC_NSCR_PROCEDURE_COMMANDS; i++)
3660 case wxSTC_NSCR_DEFAULT:
3661 case wxSTC_NSCR_IDENTIFIER:
3664 case wxSTC_NSCR_NUMBERS:
3667 case wxSTC_NSCR_COMMENT_BLOCK:
3668 case wxSTC_NSCR_COMMENT_LINE:
3671 case wxSTC_NSCR_DOCCOMMENT_BLOCK:
3672 case wxSTC_NSCR_DOCCOMMENT_LINE:
3675 case wxSTC_NSCR_DOCKEYWORD:
3678 case wxSTC_NSCR_COMMAND:
3681 case wxSTC_NSCR_OPTION:
3684 case wxSTC_NSCR_CONSTANTS:
3687 case wxSTC_NSCR_FUNCTION:
3690 case wxSTC_NSCR_METHOD:
3693 case wxSTC_NSCR_PREDEFS:
3696 case wxSTC_NSCR_STRING:
3699 case wxSTC_NSCR_STRING_PARSER:
3702 case wxSTC_NSCR_INCLUDES:
3705 case wxSTC_NSCR_PROCEDURES:
3708 case wxSTC_NSCR_PROCEDURE_COMMANDS:
3711 case wxSTC_NSCR_INSTALL:
3714 case wxSTC_NSCR_DEFAULT_VARS:
3717 case wxSTC_NSCR_CUSTOM_FUNCTION:
3720 case wxSTC_NSCR_CLUSTER:
3723 case wxSTC_NSCR_OPERATORS:
3724 case wxSTC_NSCR_OPERATOR_KEYWORDS:
3729 this->StyleSetForeground(i, _style.
foreground);
3731 this->StyleSetBackground(i, _style.
background);
3733 this->StyleSetBackground(i, this->StyleGetBackground(wxSTC_STYLE_DEFAULT));
3734 this->StyleSetBold(i, _style.
bold);
3735 this->StyleSetItalic(i, _style.
italics);
3736 this->StyleSetUnderline(i, _style.
underline);
3742 this->SetLexer(wxSTC_LEX_NPRC);
3743 this->SetProperty(
"fold",
"1");
3758 for (
int i = 0; i <= wxSTC_NPRC_FLAGS; i++)
3763 case wxSTC_NPRC_DEFAULT:
3764 case wxSTC_NPRC_IDENTIFIER:
3767 case wxSTC_NPRC_NUMBERS:
3770 case wxSTC_NPRC_COMMENT_BLOCK:
3771 case wxSTC_NPRC_COMMENT_LINE:
3774 case wxSTC_NPRC_DOCCOMMENT_BLOCK:
3775 case wxSTC_NPRC_DOCCOMMENT_LINE:
3778 case wxSTC_NPRC_DOCKEYWORD:
3781 case wxSTC_NPRC_COMMAND:
3784 case wxSTC_NPRC_OPTION:
3787 case wxSTC_NPRC_CONSTANTS:
3790 case wxSTC_NPRC_FUNCTION:
3793 case wxSTC_NPRC_METHOD:
3796 case wxSTC_NPRC_PREDEFS:
3799 case wxSTC_NPRC_STRING:
3802 case wxSTC_NPRC_STRING_PARSER:
3805 case wxSTC_NPRC_INCLUDES:
3808 case wxSTC_NPRC_PROCEDURES:
3809 case wxSTC_NPRC_FLAGS:
3812 case wxSTC_NPRC_DEFAULT_VARS:
3815 case wxSTC_NPRC_CUSTOM_FUNCTION:
3818 case wxSTC_NPRC_CLUSTER:
3821 case wxSTC_NPRC_OPERATORS:
3822 case wxSTC_NPRC_OPERATOR_KEYWORDS:
3827 this->StyleSetForeground(i, _style.
foreground);
3829 this->StyleSetBackground(i, _style.
background);
3831 this->StyleSetBackground(i, this->StyleGetBackground(wxSTC_STYLE_DEFAULT));
3832 this->StyleSetBold(i, _style.
bold);
3833 this->StyleSetItalic(i, _style.
italics);
3834 this->StyleSetUnderline(i, _style.
underline);
3839 SetLexer(wxSTC_LEX_TEX);
3840 StyleSetForeground(wxSTC_TEX_DEFAULT, wxColor(0, 128, 0));
3841 StyleSetForeground(wxSTC_TEX_COMMAND, wxColor(0, 0, 255));
3842 StyleSetBold(wxSTC_TEX_COMMAND,
true);
3843 StyleSetUnderline(wxSTC_TEX_COMMAND,
false);
3844 StyleSetForeground(wxSTC_TEX_TEXT, wxColor(0, 0, 0));
3845 StyleSetForeground(wxSTC_TEX_GROUP, wxColor(0, 128, 0));
3846 StyleSetBackground(wxSTC_TEX_GROUP, wxColor(255, 255, 183));
3847 StyleSetBold(wxSTC_TEX_GROUP,
true);
3848 StyleSetForeground(wxSTC_TEX_SPECIAL, wxColor(255, 0, 196));
3849 StyleSetItalic(wxSTC_TEX_SPECIAL,
false);
3850 StyleSetBold(wxSTC_TEX_SPECIAL,
true);
3851 StyleSetForeground(wxSTC_TEX_SYMBOL, wxColor(255, 0, 0));
3852 StyleSetBackground(wxSTC_TEX_SYMBOL, wxColor(255, 255, 255));
3853 StyleSetBold(wxSTC_TEX_SYMBOL,
false);
3857 this->SetLexer(wxSTC_LEX_OCTAVE);
3858 this->StyleSetForeground(wxSTC_MATLAB_COMMENT, wxColor(0, 128, 0));
3859 this->StyleSetItalic(wxSTC_MATLAB_COMMENT,
false);
3860 this->StyleSetForeground(wxSTC_MATLAB_OPERATOR, wxColor(255, 0, 0));
3861 this->StyleSetBold(wxSTC_MATLAB_OPERATOR,
false);
3862 this->StyleSetForeground(wxSTC_MATLAB_NUMBER, wxColor(0, 0, 128));
3863 this->StyleSetBackground(wxSTC_MATLAB_NUMBER, wxColor(255, 255, 255));
3864 this->StyleSetForeground(wxSTC_MATLAB_IDENTIFIER, wxColor(0, 0, 0));
3865 this->StyleSetBold(wxSTC_MATLAB_IDENTIFIER,
false);
3869 this->SetLexer(wxSTC_LEX_MATLAB);
3870 this->SetProperty(
"fold",
"1");
3877 for (
int i = 0; i <= wxSTC_MATLAB_FUNCTIONS; i++)
3882 case wxSTC_MATLAB_DEFAULT:
3883 case wxSTC_MATLAB_IDENTIFIER:
3886 case wxSTC_MATLAB_NUMBER:
3889 case wxSTC_MATLAB_COMMENT:
3892 case wxSTC_MATLAB_COMMAND:
3893 case wxSTC_MATLAB_KEYWORD:
3896 case wxSTC_MATLAB_FUNCTIONS:
3899 case wxSTC_MATLAB_STRING:
3900 case wxSTC_MATLAB_DOUBLEQUOTESTRING:
3903 case wxSTC_MATLAB_OPERATOR:
3908 this->StyleSetForeground(i, _style.
foreground);
3910 this->StyleSetBackground(i, _style.
background);
3912 this->StyleSetBackground(i, this->StyleGetBackground(wxSTC_STYLE_DEFAULT));
3913 this->StyleSetBold(i, _style.
bold);
3914 this->StyleSetItalic(i, _style.
italics);
3915 this->StyleSetUnderline(i, _style.
underline);
3921 this->SetLexer(wxSTC_LEX_CPP);
3922 this->SetProperty(
"fold",
"1");
3929 for (
int i = 0; i <= wxSTC_C_PREPROCESSORCOMMENT; i++)
3934 case wxSTC_C_DEFAULT :
3935 case wxSTC_C_IDENTIFIER:
3938 case wxSTC_C_NUMBER:
3941 case wxSTC_C_COMMENT:
3942 case wxSTC_C_COMMENTLINE:
3945 case wxSTC_C_COMMENTDOC:
3946 case wxSTC_C_COMMENTLINEDOC:
3949 case wxSTC_C_COMMENTDOCKEYWORD:
3950 case wxSTC_C_COMMENTDOCKEYWORDERROR:
3959 case wxSTC_C_STRING:
3962 case wxSTC_C_CHARACTER:
3965 case wxSTC_C_PREPROCESSOR:
3968 case wxSTC_C_OPERATOR:
3973 this->StyleSetForeground(i, _style.
foreground);
3975 this->StyleSetBackground(i, _style.
background);
3977 this->StyleSetBackground(i, this->StyleGetBackground(wxSTC_STYLE_DEFAULT));
3978 this->StyleSetBold(i, _style.
bold);
3979 this->StyleSetItalic(i, _style.
italics);
3980 this->StyleSetUnderline(i, _style.
underline);
3985 SetLexer(wxSTC_LEX_DIFF);
3986 SetProperty(
"fold",
"1");
3987 StyleSetForeground(wxSTC_DIFF_ADDED, wxColour(0, 128, 0));
3988 StyleSetBackground(wxSTC_DIFF_ADDED, wxColour(210, 255, 210));
3989 StyleSetForeground(wxSTC_DIFF_CHANGED, wxColour(128, 0, 0));
3990 StyleSetBackground(wxSTC_DIFF_CHANGED, wxColour(255, 210, 210));
3991 StyleSetForeground(wxSTC_DIFF_DELETED, wxColour(128, 0, 0));
3992 StyleSetBackground(wxSTC_DIFF_DELETED, wxColour(255, 210, 210));
3993 StyleSetForeground(wxSTC_DIFF_DEFAULT, *wxBLACK);
3994 StyleSetBackground(wxSTC_DIFF_DEFAULT, *wxWHITE);
3995 StyleSetForeground(wxSTC_DIFF_HEADER, *wxBLUE);
3996 StyleSetBackground(wxSTC_DIFF_HEADER, *wxWHITE);
3997 StyleSetForeground(wxSTC_DIFF_POSITION, wxColour(255, 128, 0));
3998 StyleSetBackground(wxSTC_DIFF_POSITION, *wxWHITE);
3999 StyleSetBold(wxSTC_DIFF_POSITION,
true);
4003 SetLexer(wxSTC_LEX_XML);
4004 SetProperty(
"fold",
"1");
4005 StyleSetForeground(wxSTC_H_DEFAULT, wxColour(0,0,0));
4006 StyleSetForeground(wxSTC_H_TAG, wxColour(0,0,255));
4007 StyleSetBold(wxSTC_H_TAG,
true);
4008 StyleSetForeground(wxSTC_H_TAGEND, wxColour(0,0,255));
4009 StyleSetBold(wxSTC_H_TAGEND,
true);
4010 StyleSetForeground(wxSTC_H_ATTRIBUTE, wxColour(255,0,0));
4011 StyleSetForeground(wxSTC_H_DOUBLESTRING, wxColour(128,0,255));
4012 StyleSetBold(wxSTC_H_DOUBLESTRING,
true);
4013 StyleSetForeground(wxSTC_H_SINGLESTRING, wxColour(128,0,255));
4014 StyleSetBold(wxSTC_H_SINGLESTRING,
true);
4015 StyleSetForeground(wxSTC_H_COMMENT, wxColour(0,128,0));
4016 StyleSetItalic(wxSTC_H_COMMENT,
true);
4017 StyleSetForeground(wxSTC_H_ENTITY, wxColour(64,0,0));
4018 StyleSetBackground(wxSTC_H_ENTITY, wxColour(255,255,220));
4019 StyleSetBold(wxSTC_H_ENTITY,
true);
4025 this->SetLexer(wxSTC_LEX_NULL);
4026 this->ClearDocumentStyle();
4030 this->SetLexer(wxSTC_LEX_TXTADV);
4031 this->StyleSetItalic(wxSTC_TXTADV_DEFAULT,
false);
4032 this->StyleSetItalic(wxSTC_TXTADV_MODIFIER,
true);
4033 this->StyleSetForeground(wxSTC_TXTADV_MODIFIER, wxColor(255, 180, 180));
4034 this->StyleSetItalic(wxSTC_TXTADV_ITALIC,
true);
4035 this->StyleSetItalic(wxSTC_TXTADV_BOLD,
false);
4036 this->StyleSetBold(wxSTC_TXTADV_BOLD,
true);
4037 this->StyleSetItalic(wxSTC_TXTADV_BOLD_ITALIC,
true);
4038 this->StyleSetBold(wxSTC_TXTADV_BOLD_ITALIC,
true);
4039 this->StyleSetUnderline(wxSTC_TXTADV_UNDERLINE,
true);
4040 this->StyleSetForeground(wxSTC_TXTADV_STRIKETHROUGH, wxColor(140, 140, 140));
4041 this->StyleSetItalic(wxSTC_TXTADV_STRIKETHROUGH,
true);
4042 this->StyleSetUnderline(wxSTC_TXTADV_URL,
true);
4043 this->StyleSetForeground(wxSTC_TXTADV_URL, wxColor(0, 0, 255));
4044 this->StyleSetUnderline(wxSTC_TXTADV_HEAD,
true);
4045 this->StyleSetBold(wxSTC_TXTADV_HEAD,
true);
4046 this->StyleSetUnderline(wxSTC_TXTADV_BIGHEAD,
true);
4047 this->StyleSetBold(wxSTC_TXTADV_BIGHEAD,
true);
4048 this->StyleSetSize(wxSTC_TXTADV_BIGHEAD, this->StyleGetSize(0) + 1);
4049 this->StyleSetCase(wxSTC_TXTADV_BIGHEAD, wxSTC_CASE_UPPER);
4094 IndicatorSetStyle(
HIGHLIGHT, wxSTC_INDIC_ROUNDBOX);
4096 IndicatorSetForeground(
HIGHLIGHT, wxColor(255, 0, 0));
4129 this->CallTipSetForegroundHighlight(*wxBLUE);
4130 this->SetCaretLineVisible(
true);
4131 this->SetIndentationGuides(wxSTC_IV_LOOKBOTH);
4148 this->SetCaretLineVisible(
false);
4152 SetEdgeColour(wxColour(210, 210, 255));
4153 SetEdgeMode(wxSTC_EDGE_LINE);
4157 SetEdgeMode(wxSTC_EDGE_NONE);
4160 this->StyleSetForeground(wxSTC_STYLE_BRACELIGHT, wxColour(0, 150, 0));
4161 this->StyleSetBackground(wxSTC_STYLE_BRACELIGHT, wxColour(0, 220, 0));
4162 this->StyleSetBold(wxSTC_STYLE_BRACELIGHT,
true);
4163 this->StyleSetSize(wxSTC_STYLE_BRACELIGHT, this->StyleGetSize(0) + 1);
4164 this->StyleSetForeground(wxSTC_STYLE_BRACEBAD, wxColour(150, 0, 0));
4165 this->StyleSetBackground(wxSTC_STYLE_BRACEBAD, wxColour(220, 0, 0));
4166 this->StyleSetBold(wxSTC_STYLE_BRACEBAD,
true);
4167 this->StyleSetSize(wxSTC_STYLE_BRACEBAD, this->StyleGetSize(0) + 1);
4170 int nAnnotationFontSize = this->StyleGetSize(wxSTC_STYLE_DEFAULT);
4172 if (nAnnotationFontSize >= 10)
4173 nAnnotationFontSize -= 2;
4174 else if (nAnnotationFontSize >= 8)
4175 nAnnotationFontSize -= 1;
4215 IndicatorClearRange(0, GetLastPosition());
4217 for (
int i = 0; i < GetLastPosition(); i++)
4219 if (GetStyleAt(i) == wxSTC_TXTADV_STRIKETHROUGH)
4221 for (
int j = i; j < GetLastPosition(); j++)
4223 if (GetStyleAt(j) == wxSTC_TXTADV_MODIFIER || j == GetLastPosition() - 1)
4225 IndicatorFillRange(i, j - i);
4263 wxFileName file(filename);
4265 wxString extension = file.GetExt().Lower();
4269 if (extension ==
"nprc")
4271 else if (extension ==
"nscr" || extension ==
"nlyt")
4273 else if (extension ==
"ndat" || extension ==
"dat" || extension ==
"csv" || extension ==
"jdx" || extension ==
"dx" || extension ==
"jcm")
4275 else if (extension ==
"tex")
4277 else if (extension ==
"m")
4279 else if (extension ==
"cxx" || extension ==
"hxx" || extension ==
"c" || extension ==
"h" || extension ==
"cpp" || extension ==
"hpp")
4281 else if (extension ==
"diff" || extension ==
"patch")
4283 else if (extension ==
"nhlp" || extension ==
"xml" || extension ==
"npkp")
4370 SetText(wxEmptyString);
4396 int linenum = LineFromPosition(charpos);
4397 const int nINSERTIONPOINT = 16;
4409 bool canClearBreakpoints = currentBreakpoints.GetCount() > 0;
4464 if (clickedWord.length() > 0 || HasSelection())
4466 if (this->GetStyleAt(charpos) == wxSTC_NSCR_PROCEDURES)
4471 if (clickedProc.length())
4477 else if (this->GetStyleAt(charpos) == wxSTC_NSCR_COMMAND
4478 || this->GetStyleAt(charpos) == wxSTC_NSCR_PROCEDURE_COMMANDS
4479 || this->GetStyleAt(charpos) == wxSTC_NSCR_OPTION)
4485 else if (this->GetStyleAt(charpos) == wxSTC_NSCR_INCLUDES
4486 || this->GetStyleAt(charpos) == wxSTC_NPRC_INCLUDES)
4491 if (clickedInclude.length())
4529 if (this->CallTipActive())
4551 while (this->MarkerGet(nLine) & nMarkSaved)
4554 if (!(this->MarkerGet(nLine) & nMarkModified))
4574 while ((nNextLine = this->MarkerNext(0, nMarkModified)) != -1)
4578 if (!(this->MarkerGet(nNextLine) & nMarkSaved))
4598 if (!
m_bLoadingFile && (event.GetModificationType() & wxSTC_MOD_INSERTTEXT || event.GetModificationType() & wxSTC_MOD_DELETETEXT))
4601 int nLine = this->LineFromPosition(event.GetPosition());
4602 int nLinesAdded =
event.GetLinesAdded();
4604 if (nLinesAdded > 0)
4606 for (
int i = 0; i < nLinesAdded; i++)
4609 else if (nLinesAdded < 0)
4630 int nParentline = this->GetFoldParent(nLine);
4633 if (this->GetFoldLevel(nLine) & wxSTC_FOLDLEVELHEADERFLAG)
4634 nParentline = nLine;
4637 if (nParentline == -1)
4641 if (!this->GetFoldExpanded(nLine))
4645 this->ToggleFold(nParentline);
4673 int endline = this->GetLineCount();
4681 if ((startline = this->MarkerPrevious(this->GetCurrentLine() - 1, markermask)) == -1)
4684 if ((endline = this->MarkerNext(this->GetCurrentLine() + 1, markermask)) == -1)
4685 endline = this->GetLineCount();
4693 for (
int i = startline; i < endline; i++)
4722 for (
int i = startline; i < endline; i++)
4724 for (
int j = PositionFromLine(i); j < GetLineEndPosition(i) + 1; j++)
4726 if (GetCharAt(j) ==
' ' || GetCharAt(j) ==
'\t')
4729 if (GetStyleAt(j) == wxSTC_TEX_COMMAND)
4731 int wordstart = WordStartPosition(j,
false);
4732 int wordend = WordEndPosition(j,
false);
4734 wxString word = GetTextRange(wordstart, wordend);
4736 if (word ==
"maketitle"
4738 || word ==
"chapter"
4739 || word ==
"section"
4740 || word ==
"subsection"
4741 || word ==
"subsubsection"
4742 || word ==
"subsubsubsection"
4743 || word ==
"paragraph"
4744 || word ==
"subparagraph"
4745 || word ==
"addchap"
4746 || word ==
"addsec")
4763 for (
int i = startline; i < endline; i++)
4765 for (
int j = this->PositionFromLine(i); j < this->GetLineEndPosition(i) + 1; j++)
4767 if (this->GetCharAt(j) ==
' ' || this->GetCharAt(j) ==
'\t')
4770 if (this->GetStyleAt(j) == wxSTC_TXTADV_BIGHEAD || this->GetStyleAt(j) == wxSTC_TXTADV_HEAD)
4779 if (this->GetLine(i).find(
'#') == string::npos)
4803 IndicatorClearRange(0, GetLastPosition());
4809 IndicatorClearRange(PositionFromLine(context.first),
4810 GetLineEndPosition(context.second) - PositionFromLine(context.first));
4835 std::vector<int> matches;
4836 std::pair<int, int> context = std::make_pair(0, GetLineCount());
4845 PositionFromLine(context.first),
4846 GetLineEndPosition(context.second),
4858 for (
size_t i = 0; i < matches.size(); i++)
4861 wxString line = GetTextRange(matches[i]+command.length(), GetLineEndPosition(LineFromPosition(matches[i])));
4862 int nPos = line.find_first_not_of(
' ') + matches[i] + command.length();
4864 for (
int j = nPos; j < GetLineEndPosition(LineFromPosition(matches[i])) + 1; j++)
4866 char currentChar = GetCharAt(j);
4870 if (currentChar ==
' '
4871 || currentChar ==
'='
4872 || currentChar ==
','
4873 || currentChar ==
'('
4874 || currentChar ==
'{'
4875 || currentChar ==
';'
4876 || currentChar ==
'\r'
4877 || currentChar ==
'\n')
4882 GetLineEndPosition(context.second),
4885 for (
int n : localVars)
4887 IndicatorFillRange(n, j - nPos);
4890 if (currentChar ==
',')
4893 while (GetCharAt(j) ==
',' || GetCharAt(j) ==
' ')
4896 else if (currentChar ==
';')
4903 for (
int l = j; l < GetLineEndPosition(LineFromPosition(matches[i])); l++)
4905 if (GetCharAt(l) ==
',' && GetStyleAt(l) == wxSTC_NPRC_OPERATORS)
4907 while (GetCharAt(l) ==
',' || GetCharAt(l) ==
' ')
4913 else if (GetStyleAt(l) == wxSTC_NPRC_OPERATORS && (GetCharAt(l) ==
'(' || GetCharAt(l) ==
'{'))
4921 else if (l+1 == GetLineEndPosition(LineFromPosition(matches[i])))
4931 else if (GetStyleAt(j) == wxSTC_NPRC_OPERATORS && (currentChar ==
'(' || currentChar ==
'{'))
4954 return keycode == WXK_BACK
4955 || keycode == WXK_DELETE
4956 || keycode == WXK_TAB
4957 || keycode == WXK_SHIFT
4958 || keycode == WXK_CAPITAL
4959 || keycode == WXK_ALT
4960 || keycode == WXK_CONTROL
4961 || keycode == WXK_ESCAPE
4962 || keycode == WXK_LEFT
4963 || keycode == WXK_RIGHT
4964 || keycode == WXK_UP
4965 || keycode == WXK_DOWN
4966 || keycode == WXK_HOME
4967 || keycode == WXK_END;
4984 wxString lastLine = GetLine(line-1);
4985 lastLine.erase(lastLine.find_last_not_of(
"\r\n\t ")+1);
4988 return lastLine.EndsWith(
"...");
4990 return lastLine.EndsWith(
"\\\\");
5009 if (!this->AutoCompActive()
5015 int nLine = GetCurrentLine();
5019 if (GetFoldLevel(nLine) & wxSTC_FOLDLEVELHEADERFLAG)
5023 int nParentline = GetFoldParent(nLine+offset);
5026 if (nParentline == wxNOT_FOUND)
5028 nParentline =
std::max(nLine-10, 0);
5030 if (GetFoldParent(nParentline) != wxNOT_FOUND)
5031 nParentline = GetFoldParent(nParentline);
5084 wxString gtxt =
event.GetDragText();
5097 event.SetDragResult(wxDragMove);
5127 DoDragOver(event.GetX(), event.GetY(), wxDragMove);
5150 vPos =
m_search->
FindAll(
"|", wxSTC_NSCR_OPERATORS, nStartPos, GetLastPosition(),
false);
5155 vPos =
m_search->
FindAll(
"|", wxSTC_NSCR_INSTALL, nStartPos, GetLastPosition(),
false);
5161 GotoPos(vPos.front());
5162 DeleteRange(vPos.front(), 1);
5165 GotoLine(nStartPos);
5225 for (
int i = 0; i < numBreakpoints; i++)
5228 this->MarkerDeleteHandle(markerHandle);
5289 wxArrayInt linenumbers;
5290 wxArrayInt invalidBreakpoints;
5293 for (
int i = 0; i < numStoredBreakpoints; i++)
5297 int linenum = this->MarkerLineFromHandle(markerHandle);
5301 linenumbers.Add(linenum + 1);
5305 invalidBreakpoints.Add(markerHandle);
5309 for (
int i = 0; i < (int)invalidBreakpoints.GetCount(); i++)
5314 linenumbers.Sort((CMPFUNC_wxArraywxArrayInt)
CompareInts);
5345 GotoLine(linenumber);
5369 EnsureVisible(line);
5373 if (!GetLineVisible(line))
5375 int nFirstLine = line-1;
5376 int nLastLine = line+1;
5379 while (!GetLineVisible(nFirstLine))
5383 while (!GetLineVisible(nLastLine))
5387 ShowLines(nFirstLine, nLastLine);
5390 for (
int i = nFirstLine; i < nLastLine; i++)
5412 lineNum = GetCurrentLine();
5416 lineNum = LineFromPosition(charpos);
5463 if (!procedurename.length())
5467 wxString pathname = procedurename;
5470 for (
size_t i = 0; i < pathname.length(); i++)
5472 if (!isalnum(pathname[i])
5473 && pathname[i] !=
'$'
5474 && pathname[i] !=
'/'
5475 && pathname[i] !=
':'
5476 && pathname[i] !=
'_'
5477 && pathname[i] !=
'\''
5478 && pathname[i] !=
'~')
5480 wxMessageBox(
_guilang.
get(
"GUI_DLG_PROC_INVALIDCHARS", procedurename.ToStdString()),
_guilang.
get(
"GUI_DLG_PROC_INVALIDCHARS_HEADLINE"), wxCENTER | wxICON_ERROR | wxOK,
this);
5486 if (pathname.find(
"$this~") != string::npos)
5490 pathname.replace(pathname.find(
"$this~"), 6, thispath.substr(0, thispath.rfind(
'\\') + 1));
5492 while (pathname.find(
'~') != string::npos)
5493 pathname[pathname.find(
'~')] =
'\\';
5495 else if (pathname.find(
"$thisfile~") != string::npos)
5498 wxString
name = pathname.substr(pathname.rfind(
'~') + 1);
5499 wxString procedureline;
5501 int nmaxpos = GetLastPosition();
5504 while (nminpos < nmaxpos && FindText(nminpos, nmaxpos,
"procedure", wxSTC_FIND_MATCHCASE | wxSTC_FIND_WHOLEWORD) != -1)
5506 nminpos = FindText(nminpos, nmaxpos,
"procedure", wxSTC_FIND_MATCHCASE | wxSTC_FIND_WHOLEWORD) + 1;
5512 procedureline = GetLine(LineFromPosition(nminpos));
5516 if (procedureline.find(
"$" +
name) != string::npos && procedureline[procedureline.find_first_not_of(
' ', procedureline.find(
"$" +
name) +
name.length() + 1)] ==
'(')
5519 this->GotoLine(LineFromPosition(nminpos));
5520 this->SetFirstVisibleLine(VisibleFromDocLine(LineFromPosition(nminpos))-2);
5521 this->EnsureVisible(LineFromPosition(nminpos));
5527 int ret = wxMessageBox(
_guilang.
get(
"GUI_DLG_PROC_NEXISTS_CREATE", procedurename.ToStdString()),
_guilang.
get(
"GUI_DLG_PROC_NEXISTS_CREATE_HEADLINE"), wxCENTER | wxICON_WARNING | wxYES_NO,
this);
5536 int nLastLine = this->GetLineCount();
5537 this->GotoLine(nLastLine);
5538 this->AddText(
"\n");
5539 this->AddText(proctemplate);
5543 nLastLine = FindText(this->PositionFromLine(nLastLine), this->GetLastPosition(),
"procedure $" +
name, wxSTC_FIND_MATCHCASE);
5556 if (pathname.find(
"$main~") != string::npos)
5557 pathname.erase(pathname.find(
"$main~") + 1, 5);
5559 while (pathname.find(
'~') != string::npos)
5560 pathname[pathname.find(
'~')] =
'/';
5562 if (pathname[0] ==
'$' && pathname.find(
':') == string::npos)
5563 pathname.replace(0, 1, vPaths[5] +
"/");
5564 else if (pathname.find(
':') == string::npos)
5565 pathname.insert(0, vPaths[5]);
5566 else if (pathname.find(
'\'') != string::npos)
5567 pathname = pathname.substr(pathname.find(
'\'') + 1, pathname.rfind(
'\'') - pathname.find(
'\'') - 1);
5568 else if (pathname[0] ==
'$')
5569 pathname.erase(0, 1);
5572 wxArrayString pathnames;
5573 pathnames.Add(pathname +
".nprc");
5577 if (!
fileExists((pathname +
".nprc").ToStdString()))
5579 int ret = wxMessageBox(
_guilang.
get(
"GUI_DLG_PROC_NEXISTS_CREATE", procedurename.ToStdString()),
_guilang.
get(
"GUI_DLG_PROC_NEXISTS_CREATE_HEADLINE"), wxCENTER | wxICON_WARNING | wxYES_NO,
this);
5603 if (!includename.length())
5606 wxArrayString pathnames;
5607 pathnames.Add(includename);
5611 if (!
fileExists((includename).ToStdString()))
5613 int ret = wxMessageBox(
_guilang.
get(
"GUI_DLG_SCRIPT_NEXISTS_CREATE", includename.ToStdString()),
_guilang.
get(
"GUI_DLG_SCRIPT_NEXISTS_CREATE_HEADLINE"), wxCENTER | wxICON_WARNING | wxYES_NO,
this);
5652 int nInc = sNewSymbol.length() - sSymbol.length();
5655 if (!vMatches.size())
5659 for (
size_t i = 0; i < vMatches.size(); i++)
5661 this->Replace(vMatches[i] + i*nInc, vMatches[i]+sSymbol.length() + i*nInc, sNewSymbol);
5682 wxString sCurrentName;
5685 int nEndPos = this->GetLastPosition();
5689 sCurrentName = this->GetTextRange(this->WordStartPosition(nPos,
true), this->WordEndPosition(nPos,
true));
5691 if (!sCurrentName.length())
5696 nPos = this->WordStartPosition(nPos,
true);
5701 int retval = textdialog.ShowModal();
5703 if (retval == wxID_CANCEL)
5724 vector<int> vBlock = this->
BlockMatch(nStartPos);
5725 if (vBlock.back() != wxSTC_INVALID_POSITION)
5726 nEndPos = vBlock.back();
5733 nEndPos = WordEndPosition(nPos,
true);
5737 nStartPos = WordStartPosition(nPos,
true);
5741 vector<int> vNewNameOccurences =
m_search->
FindAll(sNewName, GetStyleAt(nPos), nStartPos, nEndPos);
5747 vNewNameOccurences =
m_search->
FindAll(sNewName, wxSTC_NSCR_CUSTOM_FUNCTION, nStartPos, nEndPos);
5752 vNewNameOccurences =
m_search->
FindAll(sNewName, wxSTC_MATLAB_IDENTIFIER, nStartPos, nEndPos);
5756 if (vNewNameOccurences.size())
5759 if (wxMessageBox(
_guilang.
get(
"GUI_DLG_RENAMESYMBOLS_ALREADYINUSE_WARNING"),
_guilang.
get(
"GUI_DLG_RENAMESYMBOLS_ALREADYINUSE"), wxCENTER | wxOK | wxCANCEL | wxICON_EXCLAMATION,
this) == wxCANCEL)
5764 this->BeginUndoAction();
5768 this->EndUndoAction();
5786 if (!HasSelection())
5790 int nStartPos = PositionFromLine(LineFromPosition(GetSelectionStart()));
5791 int nEndPos = GetLineEndPosition(LineFromPosition(GetSelectionEnd()));
5793 if (GetSelectionEnd() == PositionFromLine(LineFromPosition(GetSelectionEnd())))
5794 nEndPos = GetLineEndPosition(LineFromPosition(GetSelectionEnd()-1));
5796 int nCurrentBlockStart = 0;
5797 int nCurrentBlockEnd = GetLastPosition();
5799 std::list<wxString> lInputTokens;
5800 std::list<wxString> lOutputTokens;
5802 std::set<std::string> sArgumentListSet;
5803 std::set<std::string> sMatlabReturnListSet;
5814 while (sArgumentList.length())
5819 if (sCurrentArg.find_first_of(
" =") != std::string::npos)
5820 sCurrentArg.erase(sCurrentArg.find_first_of(
" ="));
5822 if (sCurrentArg.find(
'&') != std::string::npos)
5823 sCurrentArg.erase(sCurrentArg.find(
'&'), 1);
5827 sArgumentListSet.insert(sCurrentArg);
5834 std::string sReturnList =
getMatlabReturnList(LineFromPosition(nCurrentBlockStart)).ToStdString();
5837 while (sReturnList.length())
5844 std::vector<int> vBlock =
BlockMatch(nCurrentBlockStart);
5846 if (vBlock.back() != wxSTC_INVALID_POSITION && vBlock.back() > nEndPos)
5847 nCurrentBlockEnd = vBlock.back();
5852 nCurrentBlockStart = PositionFromLine(LineFromPosition(nCurrentBlockStart)+1);
5858 for (
int i = nStartPos; i <= nEndPos; i++)
5872 wxString sCurrentToken = GetTextRange(WordStartPosition(i,
true), WordEndPosition(i,
true));
5875 if (GetCharAt(WordStartPosition(i,
true)-1) ==
'.')
5879 std::vector<int> vMatch =
m_search->
FindAll(sCurrentToken, this->GetStyleAt(i), nCurrentBlockStart, nCurrentBlockEnd);
5885 if (vMatch.front() < nStartPos
5886 || (sArgumentListSet.size() && sArgumentListSet.find(sCurrentToken.ToStdString()) != sArgumentListSet.end()))
5887 lInputTokens.push_back(sCurrentToken);
5889 if (vMatch.back() > nEndPos
5890 && vMatch.front() < nStartPos
5892 lOutputTokens.push_back(sCurrentToken);
5893 else if (vMatch.back() > nEndPos
5894 && vMatch.front() >= nStartPos
5895 && sArgumentListSet.find(sCurrentToken.ToStdString()) == sArgumentListSet.end())
5896 lOutputTokens.push_back(sCurrentToken);
5897 else if (sMatlabReturnListSet.size()
5898 && sMatlabReturnListSet.find(sCurrentToken.ToStdString()) != sMatlabReturnListSet.end()
5900 lOutputTokens.push_back(sCurrentToken);
5903 i += sCurrentToken.length();
5910 wxString sCurrentToken = GetTextRange(WordStartPosition(i,
true), WordEndPosition(i,
true));
5913 if (GetCharAt(WordStartPosition(i,
true)-1) ==
'.')
5918 if ((!sMatlabReturnListSet.size() || sMatlabReturnListSet.find(sCurrentToken.ToStdString()) == sMatlabReturnListSet.end())
5919 && (!sArgumentListSet.size() || sArgumentListSet.find(sCurrentToken.ToStdString()) == sArgumentListSet.end()))
5923 std::vector<int> vMatch =
m_search->
FindAll(sCurrentToken, this->GetStyleAt(i), nCurrentBlockStart, nCurrentBlockEnd);
5929 if (sArgumentListSet.size() && sArgumentListSet.find(sCurrentToken.ToStdString()) != sArgumentListSet.end())
5930 lInputTokens.push_back(sCurrentToken);
5932 if (sMatlabReturnListSet.size() && sMatlabReturnListSet.find(sCurrentToken.ToStdString()) != sMatlabReturnListSet.end() &&
IsModifiedInSection(nStartPos, nEndPos, sCurrentToken, vMatch))
5933 lOutputTokens.push_back(sCurrentToken);
5936 i += sCurrentToken.length();
5943 wxString sCurrentToken = GetTextRange(WordStartPosition(i,
true), WordEndPosition(i,
true));
5946 std::vector<int> vMatch =
m_search->
FindAll(sCurrentToken, this->GetStyleAt(i), nCurrentBlockStart, nCurrentBlockEnd);
5952 if (vMatch.front() < nStartPos
5953 || (sArgumentListSet.find(sCurrentToken.ToStdString() +
"()") != sArgumentListSet.end()
5954 && GetStyleAt(i) == wxSTC_NSCR_CUSTOM_FUNCTION)
5955 || (sArgumentListSet.find(sCurrentToken.ToStdString() +
"{}") != sArgumentListSet.end()
5956 && GetStyleAt(i) == wxSTC_NSCR_CLUSTER))
5958 if (GetStyleAt(i) == wxSTC_NSCR_CLUSTER)
5959 lInputTokens.push_back(sCurrentToken +
"{}");
5961 lInputTokens.push_back(sCurrentToken +
"()");
5964 if (vMatch.back() > nEndPos
5967 if (GetStyleAt(i) == wxSTC_NSCR_CLUSTER)
5968 lOutputTokens.push_back(sCurrentToken +
"{}");
5970 lOutputTokens.push_back(sCurrentToken +
"()");
5974 i += sCurrentToken.length();
5980 if (lInputTokens.size())
5982 lInputTokens.sort();
5983 lInputTokens.unique();
5986 if (lOutputTokens.size())
5988 lOutputTokens.sort();
5989 lOutputTokens.unique();
5998 auto iter = lOutputTokens.begin();
6000 while (iter != lOutputTokens.end())
6002 if ((*iter).find(
"()") != std::string::npos
6003 || (*iter).find(
"{}") != std::string::npos)
6006 auto inputIter = std::find(lInputTokens.begin(), lInputTokens.end(), *iter);
6008 if (inputIter != lInputTokens.end())
6011 lInputTokens.push_back(*iter +
"&");
6013 iter = lOutputTokens.erase(iter);
6021 wxString sInputList;
6022 wxString sOutputList;
6025 for (
auto iter = lInputTokens.begin(); iter != lInputTokens.end(); ++iter)
6027 sInputList += *iter +
",";
6030 if (sInputList.length())
6031 sInputList.erase(sInputList.length()-1);
6033 for (
auto iter = lOutputTokens.begin(); iter != lOutputTokens.end(); ++iter)
6035 sOutputList += *iter +
",";
6038 if (sOutputList.length())
6039 sOutputList.erase(sOutputList.length()-1);
6067 wxStatusBar* statusbar = copyFrame->CreateStatusBar();
6068 int sizes[] = {-2, -1};
6069 statusbar->SetFieldsCount(2, sizes);
6070 statusbar->SetStatusText(
_guilang.
get(
"GUI_STATUSBAR_UNSAVEDFILE"), 0);
6078 edit->
SetFilename(wxFileName(
"numere.nprc"),
false);
6079 edit->SetText(
"\r\n");
6082 edit->AddText(
"## " +
_guilang.
get(
"GUI_REFACTORING_NOTE") +
"\r\n");
6083 edit->AddText(
"##\r\n");
6084 edit->AddText(
"## " +
_guilang.
get(
"GUI_REFACTORING_ARGUMENTLIST") +
"\r\n");
6087 edit->AddText(
"procedure $NEWPROCEDURE(" + sInputList +
")\r\n");
6090 wxString sCodeFragment = GetTextRange(nStartPos, nEndPos);
6091 size_t nLastChar = sCodeFragment.find_last_not_of(
"\r\n \t");
6092 bool hasReturn =
false;
6094 if (nLastChar != std::string::npos)
6095 hasReturn = sCodeFragment.find(
"return", sCodeFragment.find_last_of(
"\r\n", nLastChar)) != std::string::npos;
6097 edit->AddText(sCodeFragment +
"\r\n");
6100 if (sOutputList.length())
6102 edit->AddText(
"\t## " +
_guilang.
get(
"GUI_REFACTORING_RETURNVALUES") +
"\r\n");
6104 if (sOutputList.find(
',') != string::npos)
6105 edit->AddText(
"return {" + sOutputList +
"};\r\n");
6107 edit->AddText(
"return " + sOutputList +
";\r\n");
6109 else if (!hasReturn)
6110 edit->AddText(
"return void\r\n");
6112 edit->AddText(
"endprocedure\r\n");
6113 statusbar->SetStatusText(
_guilang.
get(
"GUI_STATUSBAR_NPRC"), 1);
6120 edit->SetText(
"\r\n");
6123 edit->AddText(
"% " +
_guilang.
get(
"GUI_REFACTORING_NOTE") +
"\r\n");
6124 edit->AddText(
"%\r\n");
6125 edit->AddText(
"% " +
_guilang.
get(
"GUI_REFACTORING_ARGUMENTLIST") +
"\r\n");
6127 if (sOutputList.length())
6128 edit->AddText(
"% " +
_guilang.
get(
"GUI_REFACTORING_RETURNVALUES") +
"\r\n");
6130 edit->AddText(
"function ");
6133 if (sOutputList.length())
6135 edit->AddText(
"[" + sOutputList +
"] = ");
6139 edit->AddText(
"NEWFUNCTION(" + sInputList +
")\r\n");
6142 edit->AddText(this->GetTextRange(nStartPos, nEndPos) +
"\r\n");
6143 edit->AddText(
"end\r\n");
6144 statusbar->SetStatusText(
_guilang.
get(
"GUI_STATUSBAR_M"), 1);
6155 copyFrame->SetSize(800, 600);
6158 copyFrame->SetFocus();
6181 static wxString sModificationOperators =
"+= -= /= ^= *= ++ --";
6184 for (
size_t i = 0; i < vMatch.size(); i++)
6188 if (vMatch[i] < nSectionStart)
6190 if (vMatch[i] > nSectionEnd)
6195 && (GetCharAt(vMatch[i]-1) ==
'.' || (GetCharAt(vMatch[i]-2) ==
'.' && GetCharAt(vMatch[i]-1) ==
'(')))
6200 for (
int j = vMatch[i]+sToken.length(); j < nSectionEnd; j++)
6203 if (GetCharAt(j) ==
' ' || GetCharAt(j) ==
'\t')
6215 if (j == wxSTC_INVALID_POSITION)
6218 else if (
isStyleType(
STYLE_OPERATOR, j) && (GetCharAt(j) ==
')' || GetCharAt(j) ==
']' || GetCharAt(j) ==
'}' || GetCharAt(j) ==
':'))
6239 j = BraceMatch(j+1);
6240 if (j == wxSTC_INVALID_POSITION)
6249 for (
int k = j; k < nSectionEnd; k++)
6282 wxString sReturn = GetLine(nFunctionStartLine);
6292 if (sReturn.find(
'(') == string::npos || sReturn.find(
')') == string::npos)
6296 sReturn.erase(0, sReturn.find(
'(')+1);
6297 sReturn.erase(sReturn.rfind(
')'));
6317 wxString sReturn = GetLine(nMatlabFunctionStartLine);
6320 if (sReturn.find(
"function") == string::npos)
6324 if (sReturn.find(
'=') == string::npos)
6328 sReturn.erase(0, sReturn.find(
"function")+8);
6329 sReturn.erase(sReturn.find(
'='));
6332 if (sReturn.find(
'[') != string::npos && sReturn.find(
']') != string::npos)
6334 sReturn.erase(0, sReturn.find(
'[')+1);
6335 sReturn.erase(sReturn.rfind(
']'));
6355 wxString template_file, template_type, timestamp;
6357 template_type =
"tmpl_procedure.nlng";
6367 while (template_file.find(
"%%1%%") != string::npos)
6368 template_file.replace(template_file.find(
"%%1%%"), 5, sFileName);
6371 while (template_file.find(
"%%2%%") != string::npos)
6372 template_file.replace(template_file.find(
"%%2%%"), 5, timestamp);
6374 return template_file;
6392 if (nPos <= GetCurrentPos() && WordEndPosition(nPos+1,
true) >= GetCurrentPos())
6396 if (nPos != WordStartPosition(nPos,
true))
6404 && (!searchMethod || GetCharAt(nPos-1) ==
'.'))
6428 std::map<wxString, int> mAutoCompMap;
6429 wxString wReturn =
"";
6430 std::string sCurrentWord;
6433 if (sPreDefList.length())
6435 while (sPreDefList.length())
6437 sCurrentWord = sPreDefList.substr(0, sPreDefList.find(
' '));
6438 mAutoCompMap[
toUpperCase(sCurrentWord.substr(0, sCurrentWord.find_first_of(
"(?"))) +
" |" + sCurrentWord] = -1;
6439 sPreDefList.erase(0, sPreDefList.find(
' '));
6441 if (sPreDefList.front() ==
' ')
6442 sPreDefList.erase(0, 1);
6447 bool searchMethod = GetCharAt(wordstartpos) ==
'.';
6448 wxString wordstart = GetTextRange(searchMethod ? wordstartpos+1 : wordstartpos, currpos);
6449 std::pair<int, int> context = std::make_pair(0, GetLineCount());
6454 unsigned int nPos = PositionFromLine(context.first);
6455 bool findAll = !useSmartSense
6459 int searchFlags = wxSTC_FIND_WORDSTART;
6463 if (useSmartSense && !searchMethod)
6465 wordstart.insert(0,
"\\<_*");
6466 searchFlags = wxSTC_FIND_REGEXP;
6471 while ((nPos = FindText(nPos, GetLineEndPosition(context.second), wordstart, searchFlags)) != std::string::npos)
6475 wxString sMatch = GetTextRange(nPos, WordEndPosition(nPos + 1,
true));
6487 mAutoCompMap[
toUpperCase(sMatch.ToStdString()) +
" |" + sMatch+sFillUp] = 1;
6494 if (useSmartSense && context.first != 0 && !searchMethod)
6497 std::vector<int> vMatches =
m_search->
FindAll(
"declare", wxSTC_NSCR_COMMAND, 0, PositionFromLine(context.first),
false);
6499 for (
int pos : vMatches)
6501 int lineEnd = GetLineEndPosition(LineFromPosition(pos));
6505 while ((pos = FindText(pos, lineEnd, wordstart, searchFlags)) != wxNOT_FOUND)
6509 wxString sMatch = GetTextRange(pos, WordEndPosition(pos + 1,
true));
6521 mAutoCompMap[
toUpperCase(sMatch.ToStdString()) +
" |" + sMatch+sFillUp] = 1;
6530 for (
auto iter = mAutoCompMap.begin(); iter != mAutoCompMap.end(); ++iter)
6532 if (iter->second == -1)
6534 if ((iter->first).find(
'(') != std::string::npos)
6536 if (mAutoCompMap.find((iter->first).substr(0, (iter->first).find(
'('))) != mAutoCompMap.end())
6538 mAutoCompMap.erase((iter->first).substr(0, (iter->first).find(
'(')));
6539 iter = mAutoCompMap.begin();
6544 if (mAutoCompMap.find((iter->first).substr(0, (iter->first).find(
'?'))) != mAutoCompMap.end())
6546 mAutoCompMap.erase((iter->first).substr(0, (iter->first).find(
'?')));
6547 iter = mAutoCompMap.begin();
6554 for (
const auto& iter : mAutoCompMap)
6555 wReturn += iter.first.substr(iter.first.find(
'|') + 1) +
" ";
6575 long int maxpos = this->GetLastPosition();
6577 IndicatorClearRange(0, maxpos);
6579 unsigned int nPos = 0;
6580 unsigned int nCurr = 0;
6581 vector<unsigned int> vSelectionList;
6597 while ((nPos = this->FindText(nCurr, maxpos,
m_clickedWord, wxSTC_FIND_MATCHCASE | wxSTC_FIND_WHOLEWORD)) != string::npos)
6599 vSelectionList.push_back(nPos);
6604 for (
size_t i = 0; i < vSelectionList.size(); i++)
6652 if (!
isNumeReFileType() || GetStyleAt(GetCurrentPos()) != wxSTC_NSCR_PROCEDURES)
6686 if (!
isNumeReFileType() || GetStyleAt(GetCurrentPos()) != wxSTC_NSCR_INCLUDES)
6704 if (!HasSelection())
6708 int nFirstPos = GetSelectionStart();
6709 int nLastPos = GetSelectionEnd();
6713 Replace(nFirstPos, nLastPos,
toUpperCase(GetSelectedText().ToStdString()));
6715 Replace(nFirstPos, nLastPos,
toLowerCase(GetSelectedText().ToStdString()));
6742 int nFirstLine = LineFromPosition(GetSelectionStart());
6743 int nLastLine = LineFromPosition(GetSelectionEnd());
6745 HideLines(nFirstLine, nLastLine);
6761 if (GetAllLinesVisible())
6764 ShowLines(0, LineFromPosition(GetLastPosition()));
6792 int charpos = GetCurrentPos();
6849 switch (event.GetId())
6878 nFirstLine = LineFromPosition(GetSelectionStart());
6879 nLastLine = LineFromPosition(GetSelectionEnd());
6882 if (GetSelectionEnd() == PositionFromLine(nLastLine))
6904 nFirstLine = LineFromPosition(GetSelectionStart());
6905 nLastLine = LineFromPosition(GetSelectionEnd());
6908 if (GetSelectionEnd() == PositionFromLine(nLastLine))
6914 if (wxTheClipboard->Open())
6916 wxTheClipboard->SetData(
new wxTextDataObject(sHtml));
6917 wxTheClipboard->Close();
6936 nFirstLine = LineFromPosition(GetSelectionStart());
6937 nLastLine = LineFromPosition(GetSelectionEnd());
6940 if (GetSelectionEnd() == PositionFromLine(nLastLine))
6946 sHtml.Replace(
" ",
" ");
6947 sHtml.Replace(
"\r\n",
"\n");
6948 sHtml.Replace(
"\n\n",
"<br> <br>");
6949 sHtml.Replace(
"\n",
"<br>");
6951 if (wxTheClipboard->Open())
6953 wxTheClipboard->SetData(
new wxHTMLDataObject(sHtml));
6954 wxTheClipboard->Close();
6991 detectCodeDuplicates(0, this->LineFromPosition(this->GetLastPosition()), nDuplicateFlag, nNumDuplicatedLines);
7056 IndicatorClearRange(0, GetLastPosition());
7059 IndicatorClearRange(0, GetLastPosition());
7061 if (nStart1 == -1 && nStart2 == -1 && nEnd1 == -1 && nEnd2 == -1)
7065 for (
int i = nStart1; i <= nEnd1; i++)
7069 for (
int i = nStart2; i <= nEnd2; i++)
7073 map<int, int> mDifferences =
getDifferences(nStart1, nEnd1, nStart2, nEnd2);
7076 for (
auto iter = mDifferences.begin(); iter != mDifferences.end(); ++iter)
7078 if ((iter->first) < 0)
7083 IndicatorFillRange(
abs(iter->first), iter->second);
7086 ScrollToLine(nSelectionLine);
7095 return word2.Trim(
false) == word1.Trim(
false);
7115 if (
id != wxNOT_FOUND)
7123 return (sWord ==
"if"
7127 || sWord ==
"classdef"
7128 || sWord ==
"properties"
7129 || sWord ==
"function"
7130 || sWord ==
"methods"
7132 || sWord ==
"switch"
7133 || (allowIntermediate && (sWord ==
"elseif"
7136 || sWord ==
"otherwise"
7137 || sWord ==
"catch"))) ? 1 : wxNOT_FOUND;
7158 if (
id != wxNOT_FOUND)
7165 return sWord ==
"end" ? 1 : wxNOT_FOUND;
7186 if (
id != wxNOT_FOUND
7191 return (sWord ==
"elseif" || sWord ==
"else" || sWord ==
"case" || sWord ==
"otherwise" || sWord ==
"catch") ? 1 : wxNOT_FOUND;
7211 if (
id != wxNOT_FOUND &&
vBlockDefs[
id].middleWord1.length())
7215 return sWord ==
"if"
7217 || sWord ==
"switch"
7218 || sWord ==
"elseif"
7221 || sWord ==
"otherwise"
7222 || sWord ==
"catch";
7242 for (
size_t i = 0; i <
vBlockDefs.size(); i++)
7255 || word ==
"classdef"
7256 || word ==
"properties"
7257 || word ==
"function"
7258 || word ==
"methods"
7265 || word ==
"otherwise"
7285 if (sWord ==
"layout" || sWord ==
"compose" || sWord ==
"group")
7287 else if (sWord ==
"try")
7289 else if (sWord ==
"procedure")
7290 return sWord +
" $|()\r\nendprocedure";
7291 else if (sWord ==
"else")
7293 else if (sWord ==
"elseif")
7294 return sWord +
" (|)";
7295 else if (sWord ==
"case" || sWord ==
"catch")
7296 return sWord +
" |:";
7297 else if (sWord ==
"default")
7298 return sWord +
":|";
7304 if (sWord ==
"else" || sWord ==
"otherwise")
7306 else if (sWord ==
"elseif" || sWord ==
"case" || sWord ==
"catch")
7307 return sWord +
" |";
7331 if (
id != wxNOT_FOUND)
7376 long int maxpos = GetLastPosition();
7377 IndicatorClearRange(0, maxpos);
7395 int position =
event.GetPosition();
7396 int linenum = LineFromPosition(position);
7401 int levelClick = GetFoldLevel(linenum);
7403 if ((levelClick & wxSTC_FOLDLEVELHEADERFLAG) > 0)
7404 ToggleFold(linenum);
7412 int nNextVisibleLine = linenum+1;
7414 while (!GetLineVisible(nNextVisibleLine))
7417 ShowLines(linenum, nNextVisibleLine);
7419 for (
int i = linenum; i < nNextVisibleLine; i++)
7431 else if (bCanUseBreakPoints)
7454 for (
int i = PositionFromLine(linenum); i < GetLineEndPosition(linenum); i++)
7461 && GetCharAt(i) !=
'\r'
7462 && GetCharAt(i) !=
'\n'
7463 && GetCharAt(i) !=
' '
7464 && GetCharAt(i) !=
'\t')
7539 if (LineFromPosition(nProcedureHeadPosition) != GetCurrentLine())
7543 sProcedureName.erase(sProcedureName.find(
'('));
7546 string sDocumentation =
"##! \\procedure " + sProcedureName.substr(1) +
"\r\n##! [Procedure description]";
7549 string sFunctionArgumentList =
getFunctionArgumentList(LineFromPosition(nProcedureHeadPosition)).ToStdString();
7551 if (sFunctionArgumentList.length())
7552 sDocumentation +=
"\r\n##!";
7555 while (sFunctionArgumentList.length())
7561 if (sCurArg.find(
'=') != string::npos)
7563 sDefault = sCurArg.substr(sCurArg.find_first_not_of(
" =\t", sCurArg.find(
'=')));
7564 sCurArg.erase(sCurArg.find_last_not_of(
" =", sCurArg.find(
'='))+1);
7567 sDocumentation +=
"\r\n##! \\param " + sCurArg +
" ";
7570 if (sDefault.length())
7571 sDocumentation +=
"(!!=" + sDefault +
"!!) ";
7573 sDocumentation +=
"[Parameter description]";
7577 InsertText(nProcedureHeadPosition, sDocumentation +
"\r\n");
7592 int markerLineBitmask = this->MarkerGet(linenum);
7593 return (markerLineBitmask & (1 << nMarker));
7612 double dMatch = 0.0;
7613 int nLongestMatch = 0;
7614 int nBlankLines = 0;
7615 int nLastStatusVal = 0;
7619 currentDuplicateCodeLength *= 2;
7624 if (GetThread()->TestDestroy())
7630 if ((
int)((
double)i / (
double)(
m_nLastLine - currentDuplicateCodeLength -
m_nFirstLine) * 100) != nLastStatusVal)
7635 wxQueueEvent(GetEventHandler(),
new wxThreadEvent());
7647 for (
int j = i + currentDuplicateCodeLength; j <=
m_nLastLine - currentDuplicateCodeLength; j++)
7667 else if (dComp < 0.75 || i + k == j)
7671 if (k - nBlankLines > currentDuplicateCodeLength)
7676 if (nLongestMatch < k - 1 - nBlankLines)
7677 nLongestMatch = k - 1 - nBlankLines;
7688 else if (dMatch < 0.0)
7701 wxQueueEvent(GetEventHandler(),
new wxThreadEvent());
7702 return (wxThread::ExitCode)0;
7727 if (CreateThread(wxTHREAD_DETACHED) != wxTHREAD_NO_ERROR)
7730 if (GetThread()->Run() != wxTHREAD_NO_ERROR)
7753 size_t nMatchedCount = 0;
7761 if (!sSemLine1.length() && sSemLine2.length())
7763 else if (!sSemLine1.length() && !sSemLine2.length())
7765 else if (sSemLine1.length() * 1.5 < sSemLine2.length() || sSemLine1.length() > sSemLine2.length() * 1.5)
7769 for (
size_t i = 0; i < sSemLine1.length(); i++)
7771 if (i >= sSemLine2.length())
7774 if (sSemLine1[i] == sSemLine2[i])
7778 return (
double)nMatchedCount / (double)
max(sSemLine1.length(), sSemLine2.length());
7829 string sSemLine =
"";
7831 for (
int i = this->PositionFromLine(nLine); i < this->GetLineEndPosition(nLine); i++)
7833 if (this->GetCharAt(i) ==
' '
7834 || this->GetCharAt(i) ==
'\t'
7835 || this->GetCharAt(i) ==
'\r'
7836 || this->GetCharAt(i) ==
'\n'
7841 && (this->GetStyleAt(i) == wxSTC_NSCR_DEFAULT
7842 || this->GetStyleAt(i) == wxSTC_NSCR_DEFAULT_VARS
7843 || this->GetStyleAt(i) == wxSTC_NSCR_IDENTIFIER))
7846 i = this->WordEndPosition(i,
true) - 1;
7848 while (this->GetStyleAt(i + 1) == wxSTC_NSCR_DEFAULT
7849 || this->GetStyleAt(i + 1) == wxSTC_NSCR_DEFAULT_VARS
7850 || this->GetStyleAt(i + 1) == wxSTC_NSCR_IDENTIFIER)
7855 else if ((nDuplicateFlags &
SEMANTICS_STRING) && this->GetStyleAt(i) == wxSTC_NSCR_STRING)
7860 while (this->GetStyleAt(i + 1) == wxSTC_NSCR_STRING)
7865 else if ((nDuplicateFlags &
SEMANTICS_NUM) && this->GetStyleAt(i) == wxSTC_NSCR_NUMBERS)
7868 while (this->GetStyleAt(i + 1) == wxSTC_NSCR_NUMBERS)
7871 if (sSemLine.back() ==
'-' || sSemLine.back() ==
'+')
7873 if (sSemLine.length() == 1)
7877 char cDelim = sSemLine[sSemLine.length() - 2];
7879 if (cDelim ==
':' || cDelim ==
'=' || cDelim ==
'?' || cDelim ==
',' || cDelim ==
';' || cDelim ==
'(' || cDelim ==
'[' || cDelim ==
'{')
7880 sSemLine.pop_back();
7886 else if ((nDuplicateFlags &
SEMANTICS_FUNCTION) && this->GetStyleAt(i) == wxSTC_NSCR_CUSTOM_FUNCTION)
7889 while (this->GetStyleAt(i + 1) == wxSTC_NSCR_CUSTOM_FUNCTION)
7895 sSemLine += this->GetCharAt(i);
7923 string sSemLine =
"";
7925 for (
int i = this->PositionFromLine(nLine); i < this->GetLineEndPosition(nLine); i++)
7927 if (this->GetCharAt(i) ==
' '
7928 || this->GetCharAt(i) ==
'\t'
7929 || this->GetCharAt(i) ==
'\r'
7930 || this->GetCharAt(i) ==
'\n'
7931 || this->GetStyleAt(i) == wxSTC_MATLAB_COMMENT)
7934 && (this->GetStyleAt(i) == wxSTC_MATLAB_DEFAULT
7935 || this->GetStyleAt(i) == wxSTC_MATLAB_IDENTIFIER))
7938 i = this->WordEndPosition(i,
true) - 1;
7940 while (this->GetStyleAt(i + 1) == wxSTC_MATLAB_DEFAULT
7941 || this->GetStyleAt(i + 1) == wxSTC_MATLAB_IDENTIFIER)
7946 else if ((nDuplicateFlags &
SEMANTICS_STRING) && this->GetStyleAt(i) == wxSTC_MATLAB_STRING)
7951 while (this->GetStyleAt(i + 1) == wxSTC_MATLAB_STRING)
7956 else if ((nDuplicateFlags &
SEMANTICS_NUM) && this->GetStyleAt(i) == wxSTC_MATLAB_NUMBER)
7959 while (this->GetStyleAt(i + 1) == wxSTC_MATLAB_NUMBER)
7962 if (sSemLine.back() ==
'-' || sSemLine.back() ==
'+')
7964 if (sSemLine.length() == 1)
7968 char cDelim = sSemLine[sSemLine.length() - 2];
7970 if (cDelim ==
':' || cDelim ==
'=' || cDelim ==
'?' || cDelim ==
',' || cDelim ==
';' || cDelim ==
'(' || cDelim ==
'[' || cDelim ==
'{')
7971 sSemLine.pop_back();
7978 sSemLine += this->GetCharAt(i);
8006 string sSemLine =
"";
8008 for (
int i = this->PositionFromLine(nLine); i < this->GetLineEndPosition(nLine); i++)
8010 if (this->GetCharAt(i) ==
' '
8011 || this->GetCharAt(i) ==
'\t'
8012 || this->GetCharAt(i) ==
'\r'
8013 || this->GetCharAt(i) ==
'\n'
8017 && (this->GetStyleAt(i) == wxSTC_C_DEFAULT
8018 || this->GetStyleAt(i) == wxSTC_C_IDENTIFIER))
8021 i = this->WordEndPosition(i,
true) - 1;
8023 while (this->GetStyleAt(i + 1) == wxSTC_C_DEFAULT
8024 || this->GetStyleAt(i + 1) == wxSTC_C_IDENTIFIER)
8029 else if ((nDuplicateFlags &
SEMANTICS_STRING) && (this->GetStyleAt(i) == wxSTC_C_STRING || this->GetStyleAt(i) == wxSTC_C_CHARACTER))
8034 while (this->GetStyleAt(i + 1) == wxSTC_C_STRING || this->GetStyleAt(i + 1) == wxSTC_C_CHARACTER)
8039 else if ((nDuplicateFlags &
SEMANTICS_NUM) && this->GetStyleAt(i) == wxSTC_C_NUMBER)
8042 while (this->GetStyleAt(i + 1) == wxSTC_C_NUMBER)
8045 if (sSemLine.back() ==
'-' || sSemLine.back() ==
'+')
8047 if (sSemLine.length() == 1)
8051 char cDelim = sSemLine[sSemLine.length() - 2];
8053 if (cDelim ==
':' || cDelim ==
'=' || cDelim ==
'?' || cDelim ==
',' || cDelim ==
';' || cDelim ==
'(' || cDelim ==
'[' || cDelim ==
'{')
8054 sSemLine.pop_back();
8061 sSemLine += this->GetCharAt(i);
8089 map<int, int> mDifferences;
8096 for (
int i = 0; i <= nEnd1 - nStart1; i++)
8098 nLinePos1 = this->PositionFromLine(nStart1 + i);
8099 nLinePos2 = this->PositionFromLine(nStart2 + i);
8102 while (nLinePos1 < this->GetLineEndPosition(nStart1 + i) || nLinePos2 < this->GetLineEndPosition(nStart2 + i))
8108 if (!sToken1.length() && !sToken2.length())
8112 if (sToken1.length() && !sToken2.length())
8113 mDifferences[-nLinePos1] = sToken1.length();
8114 else if (sToken2.length() && !sToken1.length())
8115 mDifferences[nLinePos2] = sToken2.length();
8118 if (sToken1 != sToken2)
8120 mDifferences[-nLinePos1] = sToken1.length();
8121 mDifferences[nLinePos2] = sToken2.length();
8126 nLinePos1 += sToken1.length();
8127 nLinePos2 += sToken2.length();
8129 if (nLinePos1 > this->GetLineEndPosition(nStart1 + i))
8130 nLinePos1 = this->GetLineEndPosition(nStart1 + i);
8132 if (nLinePos2 > this->GetLineEndPosition(nStart2 + i))
8133 nLinePos2 = this->GetLineEndPosition(nStart2 + i);
8137 return mDifferences;
8151 int nCurrentLineEnd = this->GetLineEndPosition(this->LineFromPosition(nPos));
8154 if (nPos >= nCurrentLineEnd)
8161 while (this->GetCharAt(nPos) ==
' '
8162 || this->GetCharAt(nPos) ==
'\t'
8163 || this->GetCharAt(nPos) ==
'\r'
8164 || this->GetCharAt(nPos) ==
'\n')
8168 if (nPos >= nCurrentLineEnd)
8170 nPos = nCurrentLineEnd;
8175 nCurrentStyle = this->GetStyleAt(nPos);
8179 while (this->GetStyleAt(nEndPos) == nCurrentStyle)
8183 if (nEndPos > nCurrentLineEnd)
8184 return this->GetTextRange(nPos, nCurrentLineEnd);
8186 return this->GetTextRange(nPos, nEndPos);
8204 return std::make_pair(0, GetLineCount());
8207 while (GetFoldParent(line) != wxNOT_FOUND)
8209 line = GetFoldParent(line);
8213 std::vector<int> vMatch =
BlockMatch(GetLineIndentPosition(line));
8215 if (vMatch.back() == wxNOT_FOUND)
8216 return std::make_pair(line, GetLineCount());
8218 return std::make_pair(line, LineFromPosition(vMatch.back()));
8259 return GetStyleAt(nPos) == wxSTC_NSCR_DEFAULT;
8261 return GetStyleAt(nPos) == wxSTC_NSCR_COMMENT_LINE
8262 || GetStyleAt(nPos) == wxSTC_NSCR_DOCCOMMENT_LINE
8263 || GetStyleAt(nPos) == wxSTC_NSCR_COMMENT_BLOCK
8264 || GetStyleAt(nPos) == wxSTC_NSCR_DOCCOMMENT_BLOCK
8265 || GetStyleAt(nPos) == wxSTC_NSCR_DOCKEYWORD;
8267 return GetStyleAt(nPos) == wxSTC_NSCR_COMMENT_LINE
8268 || GetStyleAt(nPos) == wxSTC_NSCR_DOCCOMMENT_LINE;
8270 return GetStyleAt(nPos) == wxSTC_NSCR_COMMENT_BLOCK
8271 || GetStyleAt(nPos) == wxSTC_NSCR_DOCCOMMENT_BLOCK;
8273 return GetStyleAt(nPos) == wxSTC_NSCR_DOCCOMMENT_LINE
8274 || GetStyleAt(nPos) == wxSTC_NSCR_DOCKEYWORD;
8276 return GetStyleAt(nPos) == wxSTC_NSCR_DOCCOMMENT_BLOCK
8277 || GetStyleAt(nPos) == wxSTC_NSCR_DOCKEYWORD;
8279 return GetStyleAt(nPos) == wxSTC_NSCR_COMMAND
8280 || GetStyleAt(nPos) == wxSTC_NPRC_COMMAND;
8282 return GetStyleAt(nPos) == wxSTC_NSCR_FUNCTION;
8284 return GetStyleAt(nPos) == wxSTC_NSCR_CUSTOM_FUNCTION;
8286 return GetStyleAt(nPos) == wxSTC_NSCR_OPERATORS;
8288 return GetStyleAt(nPos) == wxSTC_NSCR_PROCEDURES;
8290 return GetStyleAt(nPos) == wxSTC_NSCR_IDENTIFIER;
8292 return GetStyleAt(nPos) == wxSTC_NSCR_CUSTOM_FUNCTION || GetStyleAt(nPos) == wxSTC_NSCR_CLUSTER;
8294 return GetStyleAt(nPos) == wxSTC_NSCR_NUMBERS;
8296 return GetStyleAt(nPos) == wxSTC_NSCR_STRING_PARSER;
8298 return GetStyleAt(nPos) == wxSTC_NSCR_STRING;
8307 return GetStyleAt(nPos) == wxSTC_MATLAB_DEFAULT;
8311 return GetStyleAt(nPos) == wxSTC_MATLAB_COMMENT;
8313 return GetStyleAt(nPos) == wxSTC_MATLAB_COMMENT && GetTextRange(nPos, nPos + 2) ==
"%%";
8315 return GetStyleAt(nPos) == wxSTC_MATLAB_COMMENT && GetTextRange(nPos, nPos + 2) ==
"%%";
8317 return GetStyleAt(nPos) == wxSTC_MATLAB_KEYWORD;
8319 return GetStyleAt(nPos) == wxSTC_MATLAB_FUNCTIONS;
8323 return GetStyleAt(nPos) == wxSTC_MATLAB_OPERATOR;
8327 return GetStyleAt(nPos) == wxSTC_MATLAB_IDENTIFIER;
8331 return GetStyleAt(nPos) == wxSTC_MATLAB_NUMBER;
8335 return GetStyleAt(nPos) == wxSTC_MATLAB_STRING;
8344 return GetStyleAt(nPos) == wxSTC_C_DEFAULT;
8346 return GetStyleAt(nPos) == wxSTC_C_COMMENTLINE
8347 || GetStyleAt(nPos) == wxSTC_C_COMMENT
8348 || GetStyleAt(nPos) == wxSTC_C_COMMENTDOC
8349 || GetStyleAt(nPos) == wxSTC_C_COMMENTLINEDOC
8350 || GetStyleAt(nPos) == wxSTC_C_COMMENTDOCKEYWORD;
8352 return GetStyleAt(nPos) == wxSTC_C_COMMENTLINE
8353 || GetStyleAt(nPos) == wxSTC_C_COMMENTLINEDOC;
8355 return GetStyleAt(nPos) == wxSTC_C_COMMENT
8356 || GetStyleAt(nPos) == wxSTC_C_COMMENTDOC;
8358 return GetStyleAt(nPos) == wxSTC_C_COMMENTLINEDOC
8359 || GetStyleAt(nPos) == wxSTC_C_COMMENTDOCKEYWORD;
8361 return GetStyleAt(nPos) == wxSTC_C_COMMENTDOC
8362 || GetStyleAt(nPos) == wxSTC_C_COMMENTDOCKEYWORD;
8364 return GetStyleAt(nPos) == wxSTC_C_WORD;
8366 return GetStyleAt(nPos) == wxSTC_C_WORD2;
8370 return GetStyleAt(nPos) == wxSTC_C_OPERATOR;
8374 return GetStyleAt(nPos) == wxSTC_C_IDENTIFIER;
8378 return GetStyleAt(nPos) == wxSTC_C_NUMBER;
8382 return GetStyleAt(nPos) == wxSTC_C_STRING;
8404 for (
size_t i = 0; i < sStr.length(); i++)
8415 || sStr[i] == (
char)142
8416 || sStr[i] == (
char)132
8417 || sStr[i] == (
char)153
8418 || sStr[i] == (
char)148
8419 || sStr[i] == (
char)154
8420 || sStr[i] == (
char)129
8421 || sStr[i] == (
char)225
8422 || sStr[i] == (
char)167
8423 || sStr[i] == (
char)230
8442 lastpos = sLine.find(
' ');
8444 if (lastpos == string::npos)
8448 size_t firstpos = sLine.find_first_not_of(
' ', lastpos);
8452 if (sLine.find(
')') < lastpos || sLine.find(
'.') < lastpos)
8453 sLine.replace(lastpos, firstpos - lastpos,
" -> ");
8456 if (sLine.find(
"- ") == firstpos)
8459 if (firstpos - lastpos > 2)
8461 sLine.erase(lastpos, firstpos - lastpos - 2);
8462 sLine.insert(sLine.find(
"- "), firstpos - lastpos - 2,
' ');
8485 const unsigned int nMAXLINE = 100;
8487 string sReturn = sLine;
8490 while (sReturn.find(
"\\$") != string::npos)
8491 sReturn.erase(sReturn.find(
"\\$"), 1);
8493 unsigned int nDescStart = sReturn.find(
"- ");
8494 unsigned int nIndentPos = 4;
8495 unsigned int nLastLineBreak = 0;
8496 bool isItemize =
false;
8500 if (onlyDocumentation)
8503 sReturn.insert(0,
" ");
8506 sReturn.replace(nDescStart, 2,
"\n ");
8508 if (nDescStart == string::npos)
8511 nLastLineBreak = nDescStart;
8513 for (
unsigned int i = nDescStart; i < sReturn.length(); i++)
8515 if (sReturn[i] ==
'\n')
8519 if (sReturn.substr(i, 7) ==
"\n - ")
8525 if ((i == nMAXLINE && !nLastLineBreak)
8526 || (nLastLineBreak && i - nLastLineBreak == nMAXLINE))
8528 for (
int j = i; j >= 0; j--)
8530 if (sReturn[j] ==
' ')
8533 sReturn.insert(j + 1, nIndentPos + 2*isItemize,
' ');
8537 else if (sReturn[j] ==
'-' && j != (
int)i)
8541 (sReturn[j - 1] ==
' '
8542 || sReturn[j - 1] ==
'('
8543 || sReturn[j + 1] ==
')'
8544 || sReturn[j - 1] ==
'['
8545 || (sReturn[j + 1] >=
'0' && sReturn[j + 1] <=
'9')
8546 || sReturn[j + 1] ==
','
8547 || (sReturn[j + 1] ==
'"' && sReturn[j - 1] ==
'"')
8551 sReturn.insert(j + 1,
"\n");
8552 sReturn.insert(j + 2, nIndentPos + 2*isItemize,
' ');
8553 nLastLineBreak = j + 1;
8556 else if (sReturn[j] ==
',' && j != (
int)i && sReturn[j + 1] !=
' ')
8558 sReturn.insert(j + 1,
"\n");
8559 sReturn.insert(j + 2, nIndentPos + 2*isItemize,
' ');
8560 nLastLineBreak = j + 1;
8604 if (nLastLine <= 0 || nLastLine > GetLineCount())
8605 nLastLine = GetLineCount()-1;
8607 int nFirstPos = PositionFromLine(nFirstLine);
8608 int nLastPos = GetLineEndPosition(nLastLine);
8609 size_t maxLines = 0;
8615 std::vector<std::vector<wxString>> vTable;
8616 wxStringTokenizer tokenizer;
8617 wxString sDelimiter;
8626 wxString origSection = GetTextRange(nFirstPos, nLastPos);
8628 if (origSection.find(
';') != string::npos && origSection.find(
',') != string::npos)
8629 sDelimiter =
";\r\n";
8630 else if (origSection.find(
'.') != string::npos && origSection.find(
',') != string::npos)
8631 sDelimiter =
",\r\n";
8633 sDelimiter =
";,\r\n";
8636 sDelimiter =
"\t \r\n";
8639 for (
int i = nFirstLine; i <= nLastLine; i++)
8641 vTable.push_back(std::vector<wxString>());
8642 tokenizer.SetString(GetLine(i), sDelimiter);
8644 while (tokenizer.HasMoreTokens())
8645 vTable[i-nFirstLine].push_back(tokenizer.GetNextToken());
8649 if (vTable[i-nFirstLine].size() > maxLines)
8650 maxLines = vTable[i-nFirstLine].size();
8653 wxString finalLayout;
8656 for (
size_t i = 0; i < maxLines; i++)
8658 for (
size_t j = 0; j < vTable.size(); j++)
8660 if (vTable[j].size() > i)
8661 finalLayout += vTable[j][i];
8663 if (j+1 < vTable.size())
8664 finalLayout += sDelimiter[0];
8668 finalLayout +=
"\r\n";
8673 Replace(nFirstPos, nLastPos, finalLayout);
8688 wxString sHtml =
"<pre style=\"display: block; overflow-x: auto; padding: 0.5em; background-color: rgb(244, 244, 244); color: rgb(0, 0, 0); font-family: consolas, monospace;\">";
8693 if (nLastLine <= 0 || nLastLine > GetLineCount())
8694 nLastLine = GetLineCount()-1;
8696 int nFirstPos = PositionFromLine(nFirstLine);
8697 int nLastPos = GetLineEndPosition(nLastLine);
8698 int nLastStatePosition = nFirstPos;
8699 wxTextAttr textAttr;
8701 for (
int i = nFirstPos; i < nLastPos; i++)
8703 if (GetStyleAt(i) != GetStyleAt(nLastStatePosition) || i+1 == nLastPos)
8705 int style = GetStyleAt(nLastStatePosition);
8708 if (i+1 == nLastPos)
8709 textRange = GetTextRange(nLastStatePosition, i+1);
8711 textRange = GetTextRange(nLastStatePosition, i);
8715 textRange.Replace(
"<",
"<");
8716 textRange.Replace(
">",
">");
8718 if (textRange.find_first_not_of(
" \r\t\n") == std::string::npos)
8721 nLastStatePosition = i;
8725 sHtml +=
"<span style=\"color: rgb(" +
toString(StyleGetForeground(style).Red()) +
", " +
toString(StyleGetForeground(style).Green()) +
", " +
toString(StyleGetForeground(style).Blue()) +
");";
8727 if (StyleGetBackground(style) != *wxWHITE)
8728 sHtml +=
" background-color: rgb(" +
toString(StyleGetBackground(style).Red()) +
", " +
toString(StyleGetBackground(style).Green()) +
", " +
toString(StyleGetBackground(style).Blue()) +
");";
8730 if (StyleGetItalic(style))
8731 sHtml +=
" font-style: italic;";
8733 if (StyleGetBold(style))
8734 sHtml +=
" font-weight: bold;";
8736 if (StyleGetUnderline(style))
8737 sHtml +=
" text-decoration: underline;";
8739 sHtml +=
"\">" + textRange +
"</span>";
8740 nLastStatePosition = i;
8746 sHtml.Replace(
"\t",
" ");
std::string toLowerCase(const std::string &)
Converts uppercase to lowercase letters.
void run()
Starts the code analysis. Requires a pointer to the editor and to the options.
static void changeVariableType(std::string &sVarName, char type)
Change the variable's type to the passed type.
void SetResult(const std::vector< std::string > &vResult)
void SetProgress(double dPercentage)
NumeRe::CallTipProvider * getProvider()
This class handles the internal language system and returns the language strings of the selected lang...
std::string getKey(const std::string &sMessage) const
This member function searches the internal language map for an identifier, which starts similar with ...
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 uses a global Language instance to obtain the language string associated with a distinct c...
CallTip getOption(std::string sToken) const
Get the calltip for the selected option.
CallTip getConstant(std::string sToken) const
Get the calltip for the selected constant.
CallTip getMethod(std::string sToken) const
Get the calltip for the selected method.
CallTip getFunction(std::string sToken) const
Get the calltip for the selected (built-in) function.
CallTip getCommand(std::string sToken) const
Get the calltip for the selected command.
CallTip getPredef(std::string sToken) const
Get the calltip for the selected predefined symbol.
The class of the editor window.
void sortSelection(bool ascending=true)
Sorts the lines de- or ascending.
void AddProcedureDocumentation()
This member function handles the creation of documentation blocks in front of procedure heads.
wxString getMatlabReturnList(int nMatlabFunctionStartLine)
Gets the return list of a MATLAB function.
void SynchronizeBreakpoints()
Synchronizes all breakpoints between editor and kernel.
void OnTranspose()
On MenuEvent handler for the transpose functionality of the editor.
bool SaveNumeReFile(const wxString &filename)
Saves a NumeRe-specific file and tries to stick to ASCII encoding.
void SetEditorFont(const wxFont &font)
Changes the editor's font face.
void SetUnsaved()
Marks the editor as modified.
wxMenuItem * m_menuRefactoring
void ToggleSettings(int _setting)
Enables or disables an editor setting.
std::string getSemanticLine(int nLine, int nDuplicateFlags)
Returns the selected line as semantic code.
void OnRightClick(wxMouseEvent &event)
void OnClearBreakpoints(wxCommandEvent &event)
std::string addLinebreaks(const std::string &sLine, bool onlyDocumentation=false)
Adds linebreaks to the call tip language strings.
std::string getSemanticLineMATLAB(int nLine, int nDuplicateFlags)
Returns the selected line as semantic code.
wxString getTemplateContent(const wxString &sFileName)
Returns the contents of a template file.
void ApplyAutoIndentation(int nFirstLine=0, int nLastLine=-1)
Wrapper for CodeFormatter.
std::string m_sCallTipContent
int GetLineForMarkerOperation()
Gets the line belonging to the last right mouse click or the current line of the caret.
bool isStyleType(StyleType _type, int nPos)
Determine the syntax style type at the selected position.
void OnFindProcedure(wxCommandEvent &event)
Private event handler function for finding the procedure definition.
std::vector< int > BlockMatchMATLAB(int nPos)
Finds all matching flow control statements for MATLAB command syntax.
void registerProcedureViewer(ProcedureViewer *viewer)
Registers the passed procedure viewer.
void FindAndOpenProcedure(const wxString &procedurename)
Finds the procedure definition and displays it in the editor.
wxString getNextToken(int &nPos)
Returns the next syntax token starting from the selected position.
wxString GetFilenameString()
void Transpose(int nFirstLine=0, int nLastLine=-1)
This method transposes tabular data in between (including) starting and last line....
CodeFormatter * m_formatter
bool LoadFileText(wxString fileContents)
void OnMarginClick(wxStyledTextEvent &event)
Event handler called when clicking on the editor margin.
void markLocalVariableOfType(const wxString &command, bool bForceRefresh)
This method finds all local variables of the selected type and highlights their definitions.
wxString m_clickedInclude
bool SaveFile(const wxString &filename)
int getBlockID(const wxString &word)
This function returns the block ID.
int isBlockStart(const wxString &sWord, bool allowIntermediate=false)
This function returns true, if a passed word corresponds to a control flow statement block start.
wxString generateAutoCompList(int wordstartpos, int currpos, std::string sPreDefList)
Generates an autocompletion list based upon the file's contents.
bool InitDuplicateCode()
Displays the duplicated code dialog.
void markModified(int nLine)
Marks the selected line as modified.
void OnRemoveBreakpoint(wxCommandEvent &event)
void getMatchingBrace(int nPos)
Finds and highlights the matching brace.
void notifyDialogClose()
Notifies the editor that the duplicated code dialog had been closed.
bool getEditorSetting(EditorSettings _setting)
Returns true, if the selected setting is active.
void OnChangeCase(wxCommandEvent &event)
Changes the letters in the selection.
SearchController * m_search
wxString getBlockEnd(const wxString &sWord)
This member function returns the control flow statement block end, which corresponds to the passed wo...
void UpdateProcedureViewer()
Update the assigned procedure viewer.
virtual wxThread::ExitCode Entry()
Main thread loop for the duplicated code analysis.
void ClearDblClkIndicator()
Removes the double-click occurence indicators from the document.
bool Modified()
Returns whether the current file was modified after the last time saved.
void OnAbstrahizeSection(wxCommandEvent &event)
Private event handler for extracting the selected section.
void OnLeave(wxMouseEvent &event)
Called, when the mouse leaves the editor window.
void FoldAll()
Folds all fold markers.
std::vector< wxString > getProceduresInFile()
Wrapper for the search controller.
wxMenu * m_refactoringMenu
void OnLoseFocus(wxFocusEvent &event)
Called, when the editor loses focus.
void OnExtractFormatted()
On MenuEvent handler for the extract as formatted text functionality of the editor.
bool MarkerOnLine(int linenum, int nMarker)
Checks, whether the passed marker is set on the passed line.
void OnMouseUp(wxMouseEvent &event)
Called, when the user releases the mouse key.
void OnFindIncludeFromMenu()
Global event handler function for finding the included script.
void ResetRightClickLocation()
Invalidates the latest mouse right click position.
void OnAutoCompletion(wxStyledTextEvent &event)
This event handler fires, if the user selects an entry in the autocompletion list or if he presses e....
FileFilterType GetFileType(const wxString &filename)
Returns the FileFilterType which corresponds to the passed file name.
void OnHideSelection(wxCommandEvent &event)
Private event handling function for hiding the selection.
void OnIdle(wxIdleEvent &event)
Called, when the editor idles, i.e. the user is not using it.
wxMenuItem * m_menuFindProcedure
bool m_blockIndicatorActive
wxString m_clickedProcedure
wxString getBlockStart(const wxString &sWord)
This member function returns the control flow statement block start, which corresponds to the passed ...
int m_nDuplicateCodeLines
DuplicateCodeDialog * m_duplicateCode
void toggleBookmark()
Toggles a bookmark marker on the current line.
void ApplyAutoFormat(int nFirstLine=0, int nLastLine=-1)
Wrapper for CodeFormatter.
void JumpToBookmark(bool down=true)
Jumps the cursor to the next bookmark in the current file.
void AdvCallTipCancel()
Simply closes the calltip and resets its associated variables.
void OnMouseMotion(wxMouseEvent &event)
Event handler for moving while performing a drag 'n drop operation.
friend class SearchController
bool SaveGeneralFile(const wxString &filename)
Saves a general file without touching the encoding.
void OnFindDuplicateCode(int nDuplicateFlag=1, int nNumDuplicatedLines=6)
Wrapper for detectCodeDuplicates.
wxString getBlockAutoCompletion(const wxString &sWord)
This member function returns a the complete autocompletion block for the passed control flow statemen...
bool m_bLastSavedRemotely
void FoldCurrentBlock(int nLine)
Folds the block, to which the current line belongs.
void MakeBraceCheck()
Checks for corresponding braces.
ProcedureViewer * m_procedureViewer
EditorSettings
The possible per-editor settings.
bool isNoAutoIndentionKey(int keycode)
This method is a simple helper for AsynchActions to determine, which key should not trigger the autoi...
wxFileName m_fileNameAndPath
void OnFixTypes(wxCommandEvent &event)
Event wrapper for fixSymbolName.
void updateDefaultHighlightSettings()
Performs all general default syntax highlightings.
int isBlockMiddle(const wxString &sWord)
This function returns, whether a word matches to a block middle statement (e.g. elseif).
void markSections(bool bForceRefresh=false)
Adds markers to section headlines.
void OnAddBookmark(wxCommandEvent &event)
Adds a bookmark at the selected line.
void OnFindProcedureFromMenu()
Global event handler function for finding the procedure definition.
std::vector< int > BlockMatch(int nPos)
Finds all matching flow control statements.
wxMenuItem * m_menuFindInclude
void AbstrahizeSection()
Extracts the marked selection into a new procedure.
bool m_modificationHappened
void OnHelpOnSelection(wxCommandEvent &event)
Triggers the main frame to show the documentation viewer concerning the selected command.
void OnExtractAsHTML()
On MenuEvent handler for the extract as HTML functionality of the editor.
NumeReWindow * m_mainFrame
void OnSavePointLeft(wxStyledTextEvent &event)
Called, when the editor leaves the latest save point.
std::vector< int > BlockMatchNSCR(int nPos)
Finds all matching flow control statements for NumeRe command syntax.
wxCriticalSection m_editorCS
std::pair< int, int > getCurrentContext(int line)
Returns the start and end line of the current code context (i.e. the first and the last line of the c...
std::string getSemanticLineCPP(int nLine, int nDuplicateFlags)
Returns the selected line as semantic code.
wxTimer * m_analyzerTimer
FileFilterType m_fileType
void OnChar(wxStyledTextEvent &event)
size_t m_clickedWordLength
void OnAddBreakpoint(wxCommandEvent &event)
void OnRenameSymbols(wxCommandEvent &event)
Event wrapper for RenameSymbols.
void removeWhiteSpaces(int nType=RM_WS_BOTH)
Removes whitespaces depending on the passed type.
void OnRemoveBookmark(wxCommandEvent &event)
Removes a bookmark from the selected line.
std::vector< std::string > vDuplicateCodeResults
void AsynchEvaluations()
Performs asynchronous evaluations and is called automatically.
bool isWrappedLine(int line)
This member function checks, whether a line has been syntactically wrapped around.
@ STYLE_COMMENT_SECTION_BLOCK
@ STYLE_COMMENT_SECTION_LINE
int isBlockEnd(const wxString &sWord)
This function returns true, if a passed word corresponds to a control flow statement block end.
wxArrayInt GetBreakpoints()
void OnKeyDn(wxKeyEvent &event)
Checks key input events, before they are typed into the editor.
int countUmlauts(const std::string &sStr)
Counts the german umlauts in the current string.
friend class CodeFormatter
bool IsModifiedInSection(int nSectionStart, int nSectionEnd, const wxString &sToken, const std::vector< int > &vMatch)
Determines, whether sToken is modified in the section.
void UnfoldAll()
Unfolds all fold markers.
void OnEditorModified(wxStyledTextEvent &event)
void HandleFunctionCallTip()
This function handles the descriptive function call tip.
void markSaved()
Marks the complete document as saved.
void CreateProcedureFromSection(int nStartPos, int nEndPos, const wxString &sInputList, const wxString sOutputList)
Creates a new procedure from the analysed code section.
std::string realignLangString(std::string sLine, size_t &lastpos)
Re-alignes the passed language string to fit into a call tip.
std::vector< wxString > vRenameSymbolsChangeLog
void OnDrop(wxStyledTextEvent &event)
Event handler for stopping drag 'n drop. (Actually does nothing)
void OnKeyRel(wxKeyEvent &event)
Called, when the user releases a key.
int CallTipStartPos()
Returns the starting position of the currently displayed calltip.
CodeAnalyzer * m_analyzer
wxString getFunctionArgumentList(int nFunctionStartLine)
Gets the argument list of a procedure.
NumeReTerminal * m_terminal
void OnMouseCaptureLost(wxMouseCaptureLostEvent &event)
Called, when the mouse leaves the editor screen, but the user keeps the mouse pressed.
std::string GetCurrentArgument(const std::string &sCallTip, int nStartingBrace, int &nArgStartPos)
Finds the current argument below the cursor.
void AdvCallTipShow(int pos, const wxString &definition)
A more advanced calltip display routine.
void MakeBlockCheck()
Checks for corresponding flow control statements.
FileFilterType getFileType()
void ToggleCommentLine()
Toggles a line comment.
void OnClearBookmarks(wxCommandEvent &event)
Removes all bookmarks from the whole file.
friend class CodeAnalyzer
void OnAnalyzerTimer(wxTimerEvent &event)
This event handler fires, once the analyzer timer is finished and calls the time consuming analysis t...
void SetFilename(wxFileName filename, bool fileIsRemote)
void AsynchActions()
Performs asynchronous actions and is called automatically.
void OnAbstrahizeSectionFromMenu()
Global event handler for extracting the selected section.
void setBookmarks(const std::vector< int > &vBookmarks)
Set the bookmarks in the editor.
void ToggleCommentSelection()
Toggles block comments in a selection.
void AnalyseCode()
Wrapper for the static code analyzer.
void OnMouseDwell(wxStyledTextEvent &event)
Called, when the mouse dwells for some time.
void EnsureLineVisibility(int line)
Ensures that the selected line is visible and not hidden bei either a code fold or a explicit line hi...
void OnStartDrag(wxStyledTextEvent &event)
Event handler for starting drag 'n drop.
wxString ExtractAsHTML(int nFirstLine=0, int nLastLine=-1)
Extracts the selected lines as pre- formatted HTML and returns it.
void markLocalVariables(bool bForceRefresh=false)
This method wraps the detection of local variables.
void OnEnter(wxMouseEvent &event)
Called, when the mouse enters the editor window.
void OnRenameSymbolsFromMenu()
Global wrapper for RenameSymbols.
void UpdateIndicators()
Defines and applies styles to all needed indicators.
void clearBookmarks()
Removes all bookmark markers from the current document.
void OnDragOver(wxStyledTextEvent &event)
Event handler for stopping drag 'n drop.
void FindAndOpenInclude(const wxString &includename)
Finds the included script and displays it in the editor.
std::map< int, int > getDifferences(int nStart1, int nEnd1, int nStart2, int nEnd2)
Returns the actual word-wise differences in the selected lines.
void FocusOnLine(int linenumber, bool showMarker=true)
void UpdateSyntaxHighlighting(bool forceUpdate=false)
void AddBreakpoint(int linenum)
Adds a breakpoint to the selected line.
void IndicateDuplicatedLine(int nStart1, int nEnd1, int nStart2, int nEnd2, int nSelectionLine)
Highlights differences between two blocks of code.
wxMenuItem * m_menuHelpOnSelection
wxString GetFileNameAndPath()
std::vector< SyntaxBlockDefinition > vBlockDefs
bool m_braceIndicatorActive
std::string getSemanticLineNSCR(int nLine, int nDuplicateFlags)
Returns the selected line as semantic code.
void ReplaceMatches(const std::vector< int > &vMatches, const wxString &sSymbol, const wxString &sNewSymbol)
Replaces the matches with a new symbol.
bool hasBlockMiddle(const wxString &sWord)
This function returns, whether a block has block middle statements.
void OnMouseDn(wxMouseEvent &event)
Called, when the user presses the left mouse key.
void GotoPipe(int nStartPos=0)
Jumps to the predefined template caret position.
NumeReEditor(NumeReWindow *mframe, Options *options, wxWindow *parent, wxWindowID id, NumeReSyntax *__syntax, NumeReTerminal *__terminal, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxString &name=wxSTCNameStr)
Editor constructor.
wxMenuItem * m_menuShowValue
void OnFoldCurrentBlock(wxCommandEvent &event)
Event wrapper for FoldCurrentBlock.
void applyStrikeThrough()
Applies the strike-through effect.
bool isValidAutoCompMatch(int nPos, bool findAll, bool searchMethod)
Ensures that the current position follows all rules to be a valid autocompletion match.
void fixSymbolName(int pos)
Fixes the symbol's type depending on either the declaration point or the first assigned value.
void OnDisplayVariable(wxCommandEvent &event)
Highlights all word occurences permanently.
std::vector< int > getBookmarks()
Returns the line positions of the bookmarks.
void OnSavePointReached(wxStyledTextEvent &event)
Called, when the editor reaches the latest save point.
void RenameSymbols(int nPos)
Asks the user to supply a new name for the symbol at the passed position and replaces all occurences.
void OnMenuEvent(wxCommandEvent &event)
OnMenu event handler.
void OnMouseDblClk(wxMouseEvent &event)
Called, when the user double clicks.
std::vector< std::string > vParsedSemanticCode
void OnFindInclude(wxCommandEvent &event)
Private event handler function for finding the included script.
void RemoveBreakpoint(int linenum)
Removes a breakpoint from the selected line.
wxString m_simpleFileName
void OnThreadUpdate(wxThreadEvent &event)
Thread event handler function for the duplicated code detection functionality.
double compareCodeLines(int nLine1, int nLine2, int nDuplicateFlags)
Performs a semantic code comparsion of the two selected lines.
void detectCodeDuplicates(int startline, int endline, int nDuplicateFlags, int nNumDuplicatedLines)
Starts the duplicated code analysis.
void getMatchingBlock(int nPos)
Finds and highlights the matching flow control statements.
std::string GetCurrentFunctionContext(int &nStartingBrace)
Find the function, whose braces the cursor is currently located in.
void OnUnhideAllFromMenu()
Global event handling function to unhide all lines from the main frame's menu.
This class contains all needed keywords to highlight their occurences correspondingly....
std::string getNPRCCommands() const
std::string getConstants() const
std::string getAutoCompListCPP(std::string sFirstChars)
The same as above but specialized for C++ Commands.
std::string getOperators() const
std::string getMethods() const
std::string getDocKeyWords() const
std::string getAutoCompListMATLAB(std::string sFirstChars)
The same as above but specialized for MATLAB commands.
std::string getCommands() const
std::string getCpp() const
std::string getAutoCompListTeX(std::string sFirstChars)
The same as above but specialized for LaTeX Commands.
std::string getBlockDefs() const
Returns all block definitions as a folding string for the lexers.
std::string getSpecial() const
std::string getAutoCompList(std::string sFirstChars, bool useSmartSense=false)
This function returns the autocompletion list for the editor.
std::string getMatlab() const
std::vector< SyntaxBlockDefinition > getFullBlockDefs() const
std::string getCppFunctions() const
std::string getMatlabFunctions() const
std::string getProcAutoCompList(std::string sFirstChars, std::string sBaseNameSpace, std::string sSelectedNameSpace)
This function will return the autocompletion list for the procedures based upon the provided procedur...
std::string getFunctions() const
std::string getOptions() const
The terminal class for the GUI. It's a specialisation of the GenericTerminal.
Settings getKernelSettings()
This will return a copy of the internal settings object of the kernel.
void clearBreakpoints(const std::string &_sFilename)
This member function removes all breakpoints from the passed file.
void removeBreakpoint(const std::string &_sFilename, size_t nLine)
This member function removes a breakpoint from the passed file at the indicated line number.
std::vector< std::string > getPathSettings()
Returns the standard paths as a STL vector.
void addBreakpoint(const std::string &_sFilename, size_t nLine)
This member function adds a breakpoint to the passed file at the indicated line number.
This class is the actual NumeRe main frame. The application's logic is implemented here.
void NewFile(FileFilterType _filetype=FILE_NONSOURCE, const wxString &defaultfilename="")
bool GetFileContents(wxString fileToLoad, wxString &fileContents, wxString &fileName)
bool ShowHelp(const wxString &sDocId)
This member function displays the help page for the selected documentation ID.
void OpenSourceFile(wxArrayString fnames, unsigned int nLine=0, int nOpenFileFlag=OPENFILE_NOTHING)
Opens the given list of source files in the editor.
wxIcon getStandardIcon()
This public member function returns the default icon usable by different windows.
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.
bool GetHighlightLocalVariables() const
wxFont GetEditorFont() const
SyntaxStyles GetSyntaxStyle(size_t i) const
Return the selected syntax style by constructing it from the style string.
int GetCaretBlinkTime() const
int GetDebuggerFocusLine() const
bool GetKeepBackupFile() const
void updateProcedureList(const std::vector< wxString > &vProcedures)
bool replaceAfterCursor()
bool replaceInWholeFile()
bool replaceBeforeCursor()
std::vector< int > FindAll(const wxString &sSymbol, int nStyle, int nStartPos=0, int nEndPos=-1, bool bSearchInComments=false)
Finds all occurences of a code symbol considering the style.
wxString FindProceduresInCurrentFile(wxString sFirstChars, wxString sSelectedNameSpace)
Finds procedures, which might match the passed word start.
wxString FindMarkedProcedure(int charpos, bool ignoreDefinitions=true)
Extracts the procedure call at the selected position.
wxString FindNameSpaceOfProcedure(int charpos)
Finds the current namespace for the procedure call.
wxString FindProcedureDefinition()
Searches the definition below the cursor.
wxString FindMarkedInclude(int charpos)
Constructs the file name of the included file.
wxString FindClickedProcedure()
Gets the name of the clicked procedure.
wxString FindClickedInclude()
Gets the name of the clicked include file.
std::vector< wxString > getProceduresInFile()
Creates a list of procedures in the current file.
int FindCurrentProcedureHead(int pos)
Find the procedure head line for the selected position.
wxString FindClickedWord()
Returns the word under the cursor while clicking.
SettingsValue & getSetting(const std::string &value)
Returns a reference to the setting value, which corresponds to the passed string. Throws an exception...
bool useCustomLangFiles() const
Returns, whether user language files shall be used to override internal language strings.
bool isEnabled(const std::string &option) const
Returns true, if the setting with boolean value type is enabled, false otherwise. If the setting does...
bool & active()
Returns a reference to a boolean value type setting.
This class is the immutable (const) version of a string view. It can be constructed from a MutableStr...
FileRevisions * getRevisions(const wxString ¤tFile)
This method returns the file revisions as pointer.
This class generalizes a set of basic floating window functionalities like being closable by pressing...
@ MARKER_DUPLICATEINDICATOR_TWO
@ MARKER_DUPLICATEINDICATOR_ONE
@ ID_DEBUG_DISPLAY_SELECTION
@ ID_DEBUG_CLEAR_ALL_BREAKPOINTS
@ ID_DEBUG_REMOVE_BREAKPOINT
@ ID_DEBUG_ADD_BREAKPOINT
#define HIGHLIGHT_NOT_MATCHING_BLOCK
#define HIGHLIGHT_LOCALVARIABLES
#define HIGHLIGHT_MATCHING_BRACE
#define HIGHLIGHT_STRIKETHROUGH
static char applyFunctionHeuristics(const std::string &func)
Apply the function heuristics to detect the current symbol's type.
int CompareInts(int n1, int n2)
#define HIGHLIGHT_DIFFERENCES
static bool isEqualIgnoreWhitespace(wxString word1, wxString word2)
static char applyValueHeuristics(std::string val)
Apply the value heuristics to detect the current symbol's type.
static bool isOnlyActiveBlock(int nBlockID, std::vector< int > vBlocks)
Checks, if the selected block is the only block active.
#define SEMANTICS_FUNCTION
#define HIGHLIGHT_MATCHING_BLOCK
#define HIGHLIGHT_DIFFERENCE_SOURCE
static char applyCommandHeuristics(const std::string &command)
Apply the command heuristics to detect the current symbol's type.
std::string replacePathSeparator(const std::string &)
This function replaces the Windows style path sparators to UNIX style.
FindReplaceDialog * g_findReplace
bool fileExists(const string &)
This function checks, whether the file with the passed file name exists.
static Matrix selection(const MatFuncData &funcData, const MatFuncErrorInfo &errorInfo)
Extracts a selection from a matrix iterating through two matrices simultaneously.
unsigned int getMatchingParenthesis(const StringView &)
Returns the position of the closing parenthesis.
CONSTCD11 std::enable_if<!std::chrono::treat_as_floating_point< T >::value, T >::type trunc(T t) NOEXCEPT
CONSTCD11 std::chrono::duration< Rep, Period > abs(std::chrono::duration< Rep, Period > d)
Resample_Real(* func)(Resample_Real t)
void StripSpaces(std::string &)
Removes leading and trailing white spaces and tabulator characters.
#define SETTING_B_SMARTSENSE
#define SETTING_B_QUOTEAUTOCOMP
#define SETTING_B_BLOCKAUTOCOMP
#define SETTING_B_LINELENGTH
#define SETTING_B_HOMEENDCANCELS
#define SETTING_B_BRACEAUTOCOMP
This structure contains the data for a single calltip, which might be shown in the editor or the term...
std::string sDocumentation
A simple structure to define a syntax block for folding, etc.
This structure contains the necessary data to completely define a style for a distinctive syntax elem...
std::string toString(int)
Converts an integer to a string without the Settings bloat.