NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
|
This class handles all formatting features of the editor. More...
#include <codeformatter.hpp>
Public Member Functions | |
CodeFormatter (NumeReEditor *edit) | |
void | IndentCode (int nFirstLine, int nLastLine) |
Automatically indents the code based upon its hierarchy. More... | |
void | FormatCode (int nFirstLine, int nLastLine) |
Applies automatic formatting to the selected code lines. More... | |
Private Member Functions | |
int | determineIndentationLevel (int nLine, int &singleLineIndent) |
Determines the indentation level of the selected line. More... | |
int | determineIndentationLevelNSCR (int nLine, int &singleLineIndent) |
Determines the indentation level of the selected line of NumeRe code. More... | |
int | determineIndentationLevelMATLAB (int nLine, int &singleLineIndent) |
Determines the indentation level of the selected line of MATLAB code. More... | |
int | determineIndentationLevelCPP (int nLine, int &singleLineIndent) |
Determines the indentation level of the selected line of C++ code. More... | |
void | ApplyAutoFormatNSCR (int nFirstLine, int nLastLine) |
Applies autoformatting to NumeRe code. More... | |
void | ApplyAutoFormatMATLAB (int nFirstLine, int nLastLine) |
Applies autoformatting to MATLAB code. More... | |
void | ApplyAutoFormatCPP (int nFirstLine, int nLastLine) |
Applies autoformatting to C++ code. More... | |
int | formatFunctionParentheses (int &pos, int operatorStyleNum) |
Formats the contents of function parentheses. More... | |
int | formatOperators (int pos, char prevChar, char currentChar, char nextChar, bool isNSCR) |
Helper to format binary operators. More... | |
int | formatStrings (int pos, bool isNSCR) |
Helper to format characters around string literals. More... | |
int | insertTextAndMove (int nPosition, const wxString &sText) |
Inserts text and returns the length of the insertion. More... | |
Private Attributes | |
NumeReEditor * | m_editor |
This class handles all formatting features of the editor.
Definition at line 30 of file codeformatter.hpp.
|
inline |
Definition at line 49 of file codeformatter.hpp.
|
private |
Applies autoformatting to C++ code.
nFirstLine | int |
nLastLine | int |
Definition at line 776 of file codeformatter.cpp.
References FILE_CPP, formatFunctionParentheses(), formatOperators(), formatStrings(), NumeReEditor::getFileType(), insertTextAndMove(), NumeReEditor::isStyleType(), m_editor, NumeReEditor::STYLE_COMMAND, NumeReEditor::STYLE_COMMENT_BLOCK, and NumeReEditor::STYLE_COMMENT_LINE.
Referenced by FormatCode().
|
private |
Applies autoformatting to MATLAB code.
nFirstLine | int |
nLastLine | int |
Definition at line 578 of file codeformatter.cpp.
References FILE_MATLAB, formatFunctionParentheses(), formatOperators(), formatStrings(), NumeReEditor::getFileType(), insertTextAndMove(), and m_editor.
Referenced by FormatCode().
|
private |
Applies autoformatting to NumeRe code.
nFirstLine | int |
nLastLine | int |
Definition at line 340 of file codeformatter.cpp.
References FILE_NPRC, FILE_NSCR, formatFunctionParentheses(), formatOperators(), formatStrings(), NumeReEditor::getBlockID(), NumeReEditor::getFileType(), insertTextAndMove(), NumeReEditor::isBlockEnd(), NumeReEditor::isBlockStart(), NumeReEditor::isStyleType(), m_editor, NumeReEditor::STYLE_COMMENT_BLOCK, and NumeReEditor::STYLE_COMMENT_LINE.
Referenced by FormatCode().
|
private |
Determines the indentation level of the selected line.
nLine | int |
singleLineIndent | int& |
This function determines the indentation level of the code at the selected line by delegating this task to the language specific calculator.
Definition at line 136 of file codeformatter.cpp.
References determineIndentationLevelCPP(), determineIndentationLevelMATLAB(), determineIndentationLevelNSCR(), FILE_CPP, FILE_MATLAB, FILE_NPRC, FILE_NSCR, NumeReEditor::getFileType(), and m_editor.
Referenced by IndentCode().
|
private |
Determines the indentation level of the selected line of C++ code.
nLine | int |
singleLineIndent | int& |
Definition at line 262 of file codeformatter.cpp.
References m_editor.
Referenced by determineIndentationLevel().
|
private |
Determines the indentation level of the selected line of MATLAB code.
nLine | int |
singleLineIndent | int& |
Definition at line 222 of file codeformatter.cpp.
References NumeReEditor::isBlockEnd(), NumeReEditor::isBlockMiddle(), NumeReEditor::isBlockStart(), and m_editor.
Referenced by determineIndentationLevel().
|
private |
Determines the indentation level of the selected line of NumeRe code.
nLine | int |
singleLineIndent | int& |
Definition at line 160 of file codeformatter.cpp.
References FILE_NSCR, NumeReEditor::getFileType(), NumeReEditor::isBlockEnd(), NumeReEditor::isBlockMiddle(), NumeReEditor::isBlockStart(), and m_editor.
Referenced by determineIndentationLevel().
void CodeFormatter::FormatCode | ( | int | nFirstLine, |
int | nLastLine | ||
) |
Applies automatic formatting to the selected code lines.
nFirstLine | int |
nLastLine | int |
Formatting is done by delegating this taks to the specialized formatting function. It also indents the code automatically based upon its hierarchy.
Definition at line 311 of file codeformatter.cpp.
References ApplyAutoFormatCPP(), ApplyAutoFormatMATLAB(), ApplyAutoFormatNSCR(), FILE_CPP, FILE_MATLAB, FILE_NPRC, FILE_NSCR, NumeReEditor::getFileType(), IndentCode(), and m_editor.
Referenced by NumeReEditor::ApplyAutoFormat().
|
private |
Formats the contents of function parentheses.
pos | int& |
operatorStyleNum | int |
Definition at line 973 of file codeformatter.cpp.
References insertTextAndMove(), and m_editor.
Referenced by ApplyAutoFormatCPP(), ApplyAutoFormatMATLAB(), and ApplyAutoFormatNSCR().
|
private |
Helper to format binary operators.
pos | int |
prevChar | char |
currentChar | char |
nextChar | char |
isNSCR | bool |
Definition at line 1024 of file codeformatter.cpp.
References insertTextAndMove(), and m_editor.
Referenced by ApplyAutoFormatCPP(), ApplyAutoFormatMATLAB(), and ApplyAutoFormatNSCR().
|
private |
Helper to format characters around string literals.
pos | int |
isNSCR | bool |
Definition at line 1082 of file codeformatter.cpp.
References insertTextAndMove(), and m_editor.
Referenced by ApplyAutoFormatCPP(), ApplyAutoFormatMATLAB(), and ApplyAutoFormatNSCR().
void CodeFormatter::IndentCode | ( | int | nFirstLine, |
int | nLastLine | ||
) |
Automatically indents the code based upon its hierarchy.
nFirstLine | int |
nLastLine | int |
Definition at line 51 of file codeformatter.cpp.
References determineIndentationLevel(), FILE_CPP, NumeReEditor::getFileType(), NumeReEditor::isStyleType(), m_editor, NumeReEditor::STYLE_COMMENT_BLOCK, and NumeReEditor::STYLE_COMMENT_LINE.
Referenced by NumeReEditor::ApplyAutoIndentation(), and FormatCode().
|
private |
Inserts text and returns the length of the insertion.
nPosition | int |
sText | const wxString& |
This is a simple helper function to simplify keeping track of the actual insertion position.
Definition at line 35 of file codeformatter.cpp.
References m_editor.
Referenced by ApplyAutoFormatCPP(), ApplyAutoFormatMATLAB(), ApplyAutoFormatNSCR(), formatFunctionParentheses(), formatOperators(), and formatStrings().
|
private |
Definition at line 33 of file codeformatter.hpp.
Referenced by ApplyAutoFormatCPP(), ApplyAutoFormatMATLAB(), ApplyAutoFormatNSCR(), determineIndentationLevel(), determineIndentationLevelCPP(), determineIndentationLevelMATLAB(), determineIndentationLevelNSCR(), FormatCode(), formatFunctionParentheses(), formatOperators(), formatStrings(), IndentCode(), and insertTextAndMove().