diff --git a/RedPandaIDE/RedPandaIDE.pro b/RedPandaIDE/RedPandaIDE.pro index 13405036..bc8dc0c7 100644 --- a/RedPandaIDE/RedPandaIDE.pro +++ b/RedPandaIDE/RedPandaIDE.pro @@ -14,6 +14,7 @@ QMAKE_CXXFLAGS_DEBUG += -Werror=return-type SOURCES += \ HighlighterManager.cpp \ + codeformatter.cpp \ colorscheme.cpp \ compiler/compiler.cpp \ compiler/compilermanager.cpp \ @@ -32,6 +33,8 @@ SOURCES += \ settingsdialog/editorautosavewidget.cpp \ settingsdialog/editorcodecompletionwidget.cpp \ settingsdialog/editormiscwidget.cpp \ + settingsdialog/formattergeneralwidget.cpp \ + settingsdialog/formatteridentationwidget.cpp \ widgets/classbrowser.cpp \ widgets/codecompletionlistview.cpp \ widgets/codecompletionpopup.cpp \ @@ -83,6 +86,7 @@ SOURCES += \ HEADERS += \ HighlighterManager.h \ + codeformatter.h \ colorscheme.h \ compiler/compiler.h \ compiler/compilermanager.h \ @@ -101,6 +105,8 @@ HEADERS += \ settingsdialog/editorautosavewidget.h \ settingsdialog/editorcodecompletionwidget.h \ settingsdialog/editormiscwidget.h \ + settingsdialog/formattergeneralwidget.h \ + settingsdialog/formatteridentationwidget.h \ widgets/classbrowser.h \ widgets/codecompletionlistview.h \ widgets/codecompletionpopup.h \ @@ -156,6 +162,8 @@ FORMS += \ settingsdialog/editorautosavewidget.ui \ settingsdialog/editorcodecompletionwidget.ui \ settingsdialog/editormiscwidget.ui \ + settingsdialog/formattergeneralwidget.ui \ + settingsdialog/formatteridentationwidget.ui \ widgets/cpudialog.ui \ mainwindow.ui \ settingsdialog/compilersetdirectorieswidget.ui \ diff --git a/RedPandaIDE/codeformatter.cpp b/RedPandaIDE/codeformatter.cpp new file mode 100644 index 00000000..be89ff4a --- /dev/null +++ b/RedPandaIDE/codeformatter.cpp @@ -0,0 +1,6 @@ +#include "codeformatter.h" + +CodeFormatter::CodeFormatter() +{ + +} diff --git a/RedPandaIDE/codeformatter.h b/RedPandaIDE/codeformatter.h new file mode 100644 index 00000000..6a88afc7 --- /dev/null +++ b/RedPandaIDE/codeformatter.h @@ -0,0 +1,11 @@ +#ifndef CODEFORMATTER_H +#define CODEFORMATTER_H + + +class CodeFormatter +{ +public: + CodeFormatter(); +}; + +#endif // CODEFORMATTER_H diff --git a/RedPandaIDE/settings.cpp b/RedPandaIDE/settings.cpp index 27701b8f..a9a5df88 100644 --- a/RedPandaIDE/settings.cpp +++ b/RedPandaIDE/settings.cpp @@ -2690,3 +2690,9 @@ void Settings::CodeCompletion::doLoad() mAppendFunc = boolValue("append_func",true); mShowCodeIns = boolValue("show_code_ins",true); } + +Settings::CodeFormatter::CodeFormatter(Settings *settings): + _Base(settings,SETTING_CODE_FORMATTER) +{ + +} diff --git a/RedPandaIDE/settings.h b/RedPandaIDE/settings.h index 49a9532b..5c9ac7bc 100644 --- a/RedPandaIDE/settings.h +++ b/RedPandaIDE/settings.h @@ -19,6 +19,7 @@ #define SETTING_DEBUGGER "Debugger" #define SETTING_HISTORY "History" #define SETTING_CODE_COMPLETION "CodeCompletion" +#define SETTING_CODE_FORMATTER "CodeFormatter" #define SETTING_COMPILTER_SETS "CompilerSets" #define SETTING_COMPILTER_SETS_DEFAULT_INDEX "defaultIndex" #define SETTING_COMPILTER_SETS_COUNT "count" @@ -464,6 +465,94 @@ public: }; + class CodeFormatter: public _Base { + public: + explicit CodeFormatter(Settings* settings); + private: + int mBraceStyle; + int mIndentStyle; + int mTabWidth; + bool mAttachNamespaces; + bool mAttachClasses; + bool mAttachInlines; + bool mAttachExternC; + bool mAttachClosingWhile; + bool mIndentClasses; + bool mIndentModifiers; + bool mIndentCases; + bool mIndentNamespaces; + bool mIndentContinuation; + bool mIndentLabels; + bool mIndentPreprocBlock; + bool mIndentPreprocCond; + bool mIndentPreprocDefine; + bool mIndentCollComments; + int mMinConditionalIndent; + int mMaxContinuationIndent; + bool mBreakBlocks; + bool mBreakBlocksAll; + bool mPadOper; + bool mPadComma; + bool mPadParen; + bool mPadParenOut; + bool mPadFirstParenOut; + bool mPadParenIn; + bool mPadHeader; + bool mUnpadParen; + bool mDeleteEmptyLines; + bool mDeleteMultipleEmptyLines; + bool mFillEmptyLines; + int mAlignPointerStyle; + int mAlignReferenceStyle; + bool mBreakClosingBraces; + bool mBreakElseIf; + bool mBreakOneLineHeaders; + bool mAddBraces; + bool mAddOneLineBraces; + bool mRemoveBraces; + bool mBreakRetureType; + bool mBreakReturnTypeDecl; + bool mAttachReturnType; + bool mAttachReturnTypeDecl; + bool mKeepOneLineBlocks; + bool mKeepOneLineStatements; + bool mConvertTabs; + bool mCloseTemplates; + bool mRemoveCommentPrefix; + int maxCodeLength; + bool mBreakAfterLogical; + + + + + int mBracketStyle; + int mIndentStyle; + int mTabWidth; + int mMaxLineLength; + bool mModifyMaxLineLength; + //Indentation options: + bool mIndentClasses; // --indent-classes + bool mIndentSwitches; //-indent-switches + bool mIndentCases; // --indent-cases + bool mIndentNamespaces; // --indent-namespaces + bool mIndentLabels; // --indent-labels + fIndentPreprocessor: Boolean; // --indent-preprocessor + //Padding options + fPadOper: boolean; // --pad-oper; add spaces around an operator + fPadHeader: boolean; // --pad-header; add spaces after 'if','for',etc. + fPointerAlign: integer; // --align-pointer=none/type/middle/name + fReferenceAlign: integer; // --align-reference=none/type/middle/name + + fDeleteEmptyLines: boolean; + fDeleteMultipleEmptyLines: boolean; + + fCustomCommand: AnsiString; + + fFullCommand: AnsiString; // includes customizations + fAStyleDir: AnsiString; + fAStyleFile: AnsiString; + }; + class History: public _Base { public: explicit History(Settings *settings); diff --git a/RedPandaIDE/settingsdialog/formattergeneralwidget.cpp b/RedPandaIDE/settingsdialog/formattergeneralwidget.cpp new file mode 100644 index 00000000..698067ff --- /dev/null +++ b/RedPandaIDE/settingsdialog/formattergeneralwidget.cpp @@ -0,0 +1,14 @@ +#include "formattergeneralwidget.h" +#include "ui_formattergeneralwidget.h" + +FormatterGeneralWidget::FormatterGeneralWidget(QWidget *parent) : + QWidget(parent), + ui(new Ui::FormatterGeneralWidget) +{ + ui->setupUi(this); +} + +FormatterGeneralWidget::~FormatterGeneralWidget() +{ + delete ui; +} diff --git a/RedPandaIDE/settingsdialog/formattergeneralwidget.h b/RedPandaIDE/settingsdialog/formattergeneralwidget.h new file mode 100644 index 00000000..2348a523 --- /dev/null +++ b/RedPandaIDE/settingsdialog/formattergeneralwidget.h @@ -0,0 +1,22 @@ +#ifndef FORMATTERGENERALWIDGET_H +#define FORMATTERGENERALWIDGET_H + +#include + +namespace Ui { +class FormatterGeneralWidget; +} + +class FormatterGeneralWidget : public QWidget +{ + Q_OBJECT + +public: + explicit FormatterGeneralWidget(QWidget *parent = nullptr); + ~FormatterGeneralWidget(); + +private: + Ui::FormatterGeneralWidget *ui; +}; + +#endif // FORMATTERGENERALWIDGET_H diff --git a/RedPandaIDE/settingsdialog/formattergeneralwidget.ui b/RedPandaIDE/settingsdialog/formattergeneralwidget.ui new file mode 100644 index 00000000..6909db80 --- /dev/null +++ b/RedPandaIDE/settingsdialog/formattergeneralwidget.ui @@ -0,0 +1,199 @@ + + + FormatterGeneralWidget + + + + 0 + 0 + 400 + 430 + + + + Form + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Default brace style + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + sdafasdf<br/>dsafd + + + true + + + + + + + Brace modifications + + + + + + Attach spaces to namespace statements + + + + + + + Attach spaces to classes + + + + + + + Attach spaces to class inline function definitions + + + + + + + Attach spaces to extern "C" statements + + + + + + + Attach the closing while of do-while to the close brace + + + + + + + + + + Indent with: + + + + + + Indent using spaces + + + Spaces + + + + + + + Indent using tabs + + + Tabs + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Tab Size: + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + diff --git a/RedPandaIDE/settingsdialog/formatteridentationwidget.cpp b/RedPandaIDE/settingsdialog/formatteridentationwidget.cpp new file mode 100644 index 00000000..18925740 --- /dev/null +++ b/RedPandaIDE/settingsdialog/formatteridentationwidget.cpp @@ -0,0 +1,14 @@ +#include "formatteridentationwidget.h" +#include "ui_formatteridentationwidget.h" + +FormatterIdentationWidget::FormatterIdentationWidget(QWidget *parent) : + QWidget(parent), + ui(new Ui::FormatterIdentationWidget) +{ + ui->setupUi(this); +} + +FormatterIdentationWidget::~FormatterIdentationWidget() +{ + delete ui; +} diff --git a/RedPandaIDE/settingsdialog/formatteridentationwidget.h b/RedPandaIDE/settingsdialog/formatteridentationwidget.h new file mode 100644 index 00000000..0b66416a --- /dev/null +++ b/RedPandaIDE/settingsdialog/formatteridentationwidget.h @@ -0,0 +1,22 @@ +#ifndef FORMATTERIDENTATIONWIDGET_H +#define FORMATTERIDENTATIONWIDGET_H + +#include + +namespace Ui { +class FormatterIdentationWidget; +} + +class FormatterIdentationWidget : public QWidget +{ + Q_OBJECT + +public: + explicit FormatterIdentationWidget(QWidget *parent = nullptr); + ~FormatterIdentationWidget(); + +private: + Ui::FormatterIdentationWidget *ui; +}; + +#endif // FORMATTERIDENTATIONWIDGET_H diff --git a/RedPandaIDE/settingsdialog/formatteridentationwidget.ui b/RedPandaIDE/settingsdialog/formatteridentationwidget.ui new file mode 100644 index 00000000..4d7285f6 --- /dev/null +++ b/RedPandaIDE/settingsdialog/formatteridentationwidget.ui @@ -0,0 +1,21 @@ + + + + + FormatterIdentationWidget + + + + 0 + 0 + 400 + 300 + + + + Form + + + + +