21#include "../terminal/terminal.hpp"
22#include "../../common/datastructures.h"
23#include "../../kernel/syntax.hpp"
24#include "../dialogs/duplicatecodedialog.hpp"
30#include <wx/stc/stc.h>
32#include <wx/dynarray.h>
61 const wxSize& size = wxDefaultSize,
long style = 0,
62 const wxString&
name = wxSTCNameStr);
81 bool SaveFile(
const wxString& filename);
95 void OnChar(wxStyledTextEvent& event);
98 void OnKeyDn(wxKeyEvent& event);
104 void OnEnter(wxMouseEvent& event);
105 void OnLeave(wxMouseEvent& event);
111 void OnIdle(wxIdleEvent& event);
113 int isBlockStart(
const wxString& sWord,
bool allowIntermediate =
false);
130 std::string
GetCurrentArgument(
const std::string& sCallTip,
int nStartingBrace,
int& nArgStartPos);
143 void FocusOnLine(
int linenumber,
bool showMarker =
true);
158 void SetFilename(wxFileName filename,
bool fileIsRemote);
200 virtual wxThread::ExitCode
Entry();
227 void Transpose(
int nFirstLine = 0,
int nLastLine = -1);
228 wxString
ExtractAsHTML(
int nFirstLine = 0,
int nLastLine = -1);
254 MoveSelectedLinesDown();
256 MoveSelectedLinesUp();
353 std::string
addLinebreaks(
const std::string& sLine,
bool onlyDocumentation =
false);
361 void OnDrop(wxStyledTextEvent& event);
366 void ReplaceMatches(
const std::vector<int>& vMatches,
const wxString& sSymbol,
const wxString& sNewSymbol);
370 bool IsModifiedInSection(
int nSectionStart,
int nSectionEnd,
const wxString& sToken,
const std::vector<int>& vMatch);
380 void detectCodeDuplicates(
int startline,
int endline,
int nDuplicateFlags,
int nNumDuplicatedLines);
386 std::map<int, int>
getDifferences(
int nStart1,
int nEnd1,
int nStart2,
int nEnd2);
454 DECLARE_EVENT_TABLE()
This class analyzes the code handled by the editor by accessing it with friends rights.
This class represents the notebook containing all editors of one main pane.
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.
wxFileName GetExecutableFileName()
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.
bool LoadLocalFile(const wxString &filename)
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 MoveSelection(bool down=true)
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.
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.
void SetSyntax(NumeReSyntax *__syntax)
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.
void SetTerminal(NumeReTerminal *_terminal)
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.
wxFileName m_executableFilename
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.
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.
wxMenuItem * m_menuAddWatch
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 SetExecutableFilename(wxFileName filename)
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....
The terminal class for the GUI. It's a specialisation of the GenericTerminal.
This class is the actual NumeRe main frame. The application's logic is implemented here.
This class implements an interface of the internal Settings object adapted to be usable from the GUI.
This class handles all specialized search requests of the assigned editor.