NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
codeformatter.hpp
Go to the documentation of this file.
1/*****************************************************************************
2 NumeRe: Framework fuer Numerische Rechnungen
3 Copyright (C) 2019 Erik Haenel et al.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17******************************************************************************/
18
19#ifndef CODEFORMATTER_HPP
20#define CODEFORMATTER_HPP
21
22#include <wx/wx.h>
23
24class NumeReEditor;
25
31{
32 private:
34
35 int determineIndentationLevel(int nLine, int& singleLineIndent);
36 int determineIndentationLevelNSCR(int nLine, int& singleLineIndent);
37 int determineIndentationLevelMATLAB(int nLine, int& singleLineIndent);
38 int determineIndentationLevelCPP(int nLine, int& singleLineIndent);
39 void ApplyAutoFormatNSCR(int nFirstLine, int nLastLine);
40 void ApplyAutoFormatMATLAB(int nFirstLine, int nLastLine);
41 void ApplyAutoFormatCPP(int nFirstLine, int nLastLine);
42 int formatFunctionParentheses(int& pos, int operatorStyleNum);
43 int formatOperators(int pos, char prevChar, char currentChar, char nextChar, bool isNSCR);
44 int formatStrings(int pos, bool isNSCR);
45
46 int insertTextAndMove(int nPosition, const wxString& sText);
47
48 public:
50
51 void IndentCode(int nFirstLine, int nLastLine);
52 void FormatCode(int nFirstLine, int nLastLine);
53};
54
55
56#endif // CODEFORMATTER_HPP
57
This class handles all formatting features of the editor.
void ApplyAutoFormatNSCR(int nFirstLine, int nLastLine)
Applies autoformatting to NumeRe code.
int determineIndentationLevel(int nLine, int &singleLineIndent)
Determines the indentation level of the selected line.
int formatFunctionParentheses(int &pos, int operatorStyleNum)
Formats the contents of function parentheses.
int determineIndentationLevelCPP(int nLine, int &singleLineIndent)
Determines the indentation level of the selected line of C++ code.
int determineIndentationLevelNSCR(int nLine, int &singleLineIndent)
Determines the indentation level of the selected line of NumeRe code.
CodeFormatter(NumeReEditor *edit)
void ApplyAutoFormatCPP(int nFirstLine, int nLastLine)
Applies autoformatting to C++ code.
NumeReEditor * m_editor
void IndentCode(int nFirstLine, int nLastLine)
Automatically indents the code based upon its hierarchy.
void FormatCode(int nFirstLine, int nLastLine)
Applies automatic formatting to the selected code lines.
int insertTextAndMove(int nPosition, const wxString &sText)
Inserts text and returns the length of the insertion.
int formatOperators(int pos, char prevChar, char currentChar, char nextChar, bool isNSCR)
Helper to format binary operators.
int formatStrings(int pos, bool isNSCR)
Helper to format characters around string literals.
int determineIndentationLevelMATLAB(int nLine, int &singleLineIndent)
Determines the indentation level of the selected line of MATLAB code.
void ApplyAutoFormatMATLAB(int nFirstLine, int nLastLine)
Applies autoformatting to MATLAB code.
The class of the editor window.
Definition: editor.h:53