diff --git a/RedPandaIDE/RedPandaIDE.pro b/RedPandaIDE/RedPandaIDE.pro index 15612ce7..6cb1ec15 100644 --- a/RedPandaIDE/RedPandaIDE.pro +++ b/RedPandaIDE/RedPandaIDE.pro @@ -40,6 +40,7 @@ SOURCES += \ settingsdialog/editorcolorschemewidget.cpp \ settingsdialog/editorfontwidget.cpp \ settingsdialog/editorgeneralwidget.cpp \ + settingsdialog/editorsymbolcompletionwidget.cpp \ settingsdialog/environmentappearencewidget.cpp \ settingsdialog/settingsdialog.cpp \ settingsdialog/settingswidget.cpp \ @@ -81,6 +82,7 @@ HEADERS += \ settingsdialog/editorcolorschemewidget.h \ settingsdialog/editorfontwidget.h \ settingsdialog/editorgeneralwidget.h \ + settingsdialog/editorsymbolcompletionwidget.h \ settingsdialog/environmentappearencewidget.h \ settingsdialog/settingsdialog.h \ settingsdialog/settingswidget.h \ @@ -99,6 +101,7 @@ FORMS += \ settingsdialog/editorcolorschemewidget.ui \ settingsdialog/editorfontwidget.ui \ settingsdialog/editorgeneralwidget.ui \ + settingsdialog/editorsymbolcompletionwidget.ui \ settingsdialog/environmentappearencewidget.ui \ settingsdialog/settingsdialog.ui diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index d6a9683a..b807285f 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -247,6 +247,34 @@ void Editor::focusOutEvent(QFocusEvent *event) pMainWindow->updateForStatusbarModeInfo(); } +void Editor::keyPressEvent(QKeyEvent *event) +{ + bool handled = false; + QString t = event->text(); + if (!t.isEmpty()) { + QChar ch = t; + switch (ch.unicode()) { + case '"': + case '\'': + case '(': + case ')': + case '{': + case '}': + case '[': + case ']': + case '<': + case '>': + case ';': + handled = handleSymbolCompletion(ch); + } + } + if (!handled) { + SynEdit::keyPressEvent(event); + } else { + event->accept(); + } +} + void Editor::copyToClipboard() { if (pSettings->editor().copySizeLimit()) { @@ -403,7 +431,12 @@ void Editor::onStatusChanged(SynStatusChanges changes) pMainWindow->updateEditorActions(); -// mainForm.CaretList.AddCaret(self,fText.CaretY,fText.CaretX); + // mainForm.CaretList.AddCaret(self,fText.CaretY,fText.CaretX); +} + +bool Editor::handleSymbolCompletion(QChar ch) +{ + } void Editor::applySettings() diff --git a/RedPandaIDE/editor.h b/RedPandaIDE/editor.h index 22bd668d..3c385cc4 100644 --- a/RedPandaIDE/editor.h +++ b/RedPandaIDE/editor.h @@ -79,6 +79,9 @@ protected slots: void onModificationChanged(bool status) ; void onStatusChanged(SynStatusChanges changes); +private: + bool handleSymbolCompletion(QChar ch); + private: static int newfileCount; QByteArray mEncodingOption; // the encoding type set by the user @@ -93,6 +96,7 @@ protected: void wheelEvent(QWheelEvent *event) override; void focusInEvent(QFocusEvent *event); void focusOutEvent(QFocusEvent *event); + void keyPressEvent(QKeyEvent *event); }; #endif // EDITOR_H diff --git a/RedPandaIDE/settings.cpp b/RedPandaIDE/settings.cpp index 28bbc0e2..2f46deaf 100644 --- a/RedPandaIDE/settings.cpp +++ b/RedPandaIDE/settings.cpp @@ -293,6 +293,106 @@ void Settings::Editor::setColorScheme(const QString &colorScheme) mColorScheme = colorScheme; } +bool Settings::Editor::removeMathcingSymbol() const +{ + return mRemoveMathcingSymbol; +} + +void Settings::Editor::setRemoveMathcingSymbol(bool removeMathcingSymbol) +{ + mRemoveMathcingSymbol = removeMathcingSymbol; +} + +bool Settings::Editor::overwriteSymbols() const +{ + return mOverwriteSymbols; +} + +void Settings::Editor::setOverwriteSymbols(bool overwriteSymbols) +{ + mOverwriteSymbols = overwriteSymbols; +} + +bool Settings::Editor::completeGlobalInclude() const +{ + return mCompleteGlobalInclude; +} + +void Settings::Editor::setCompleteGlobalInclude(bool completeGlobalInclude) +{ + mCompleteGlobalInclude = completeGlobalInclude; +} + +bool Settings::Editor::completeDoubleQuote() const +{ + return mCompleteDoubleQuote; +} + +void Settings::Editor::setCompleteDoubleQuote(bool completeDoubleQuote) +{ + mCompleteDoubleQuote = completeDoubleQuote; +} + +bool Settings::Editor::completeSingleQuote() const +{ + return mCompleteSingleQuote; +} + +void Settings::Editor::setCompleteSingleQuote(bool completeSingleQuote) +{ + mCompleteSingleQuote = completeSingleQuote; +} + +bool Settings::Editor::completeComment() const +{ + return mCompleteComment; +} + +void Settings::Editor::setCompleteComment(bool completeComment) +{ + mCompleteComment = completeComment; +} + +bool Settings::Editor::completeBrace() const +{ + return mCompleteBrace; +} + +void Settings::Editor::setCompleteBrace(bool completeBrace) +{ + mCompleteBrace = completeBrace; +} + +bool Settings::Editor::completeBracket() const +{ + return mCompleteBracket; +} + +void Settings::Editor::setCompleteBracket(bool completeBracket) +{ + mCompleteBracket = completeBracket; +} + +bool Settings::Editor::completeParenthese() const +{ + return mCompleteParenthese; +} + +void Settings::Editor::setCompleteParenthese(bool completeParenthese) +{ + mCompleteParenthese = completeParenthese; +} + +bool Settings::Editor::completeSymbols() const +{ + return mCompleteSymbols; +} + +void Settings::Editor::setCompleteSymbols(bool completeSymbols) +{ + mCompleteSymbols = completeSymbols; +} + QString Settings::Editor::copyHTMLColorScheme() const { return mCopyHTMLColorScheme; @@ -610,6 +710,18 @@ void Settings::Editor::doSave() //color scheme saveValue("color_scheme", mColorScheme); + + //Symbol Completion + saveValue("complete_symbols", mCompleteSymbols); + saveValue("complete_parenthese", mCompleteParenthese); + saveValue("complete_bracket", mCompleteBracket); + saveValue("complete_brace", mCompleteBrace); + saveValue("complete_comment", mCompleteComment); + saveValue("complete_single_quote", mCompleteSingleQuote); + saveValue("complete_double_quote", mCompleteDoubleQuote); + saveValue("complete_global_include", mCompleteGlobalInclude); + saveValue("overwrite_symbols", mOverwriteSymbols); + saveValue("remove_matching_symbols",mRemoveMathcingSymbol); } void Settings::Editor::doLoad() @@ -664,13 +776,25 @@ void Settings::Editor::doLoad() mCopyWithFormatAs = intValue("copy_with_format_as",0); mCopyRTFUseBackground = boolValue("copy_rtf_use_background",false); mCopyRTFUseEditorColor = boolValue("copy_rtf_use_editor_color_scheme",true); - mCopyRTFColorScheme = stringValue("copy_rtf_color_scheme",""); + mCopyRTFColorScheme = stringValue("copy_rtf_color_scheme","Intellij Classic"); mCopyHTMLUseBackground = boolValue("copy_html_use_background",false); mCopyHTMLUseEditorColor = boolValue("copy_html_use_editor_color_scheme",true); - mCopyHTMLColorScheme = stringValue("copy_html_color_scheme",""); + mCopyHTMLColorScheme = stringValue("copy_html_color_scheme","Intellij Classic"); //color mColorScheme = stringValue("color_scheme", "VS Code"); + + //Symbol Completion + mCompleteSymbols = boolValue("complete_symbols",true); + mCompleteParenthese = boolValue("complete_parenthese",true); + mCompleteBracket = boolValue("complete_bracket",true); + mCompleteBrace = boolValue("complete_brace",true); + mCompleteComment = boolValue("complete_comment",true); + mCompleteSingleQuote = boolValue("complete_single_quote",true); + mCompleteDoubleQuote = boolValue("complete_double_quote",true); + mCompleteGlobalInclude = boolValue("complete_global_include",true); + mOverwriteSymbols = boolValue("overwrite_symbols",true); + mRemoveMathcingSymbol = boolValue("remove_matching_symbols",true); } SynEditCaretType Settings::Editor::caretForOverwrite() const @@ -1833,7 +1957,7 @@ Settings::Environment::Environment(Settings *settings):_Base(settings, SETTING_E void Settings::Environment::doLoad() { //Appearence - mTheme = stringValue("theme","default"); + mTheme = stringValue("theme","dark"); mInterfaceFont = stringValue("interface font","Segoe UI"); mInterfaceFontSize = intValue("interface font size",10); mLanguage = stringValue("language", QLocale::system().name()); diff --git a/RedPandaIDE/settings.h b/RedPandaIDE/settings.h index 58893c1d..d6f53ceb 100644 --- a/RedPandaIDE/settings.h +++ b/RedPandaIDE/settings.h @@ -218,6 +218,36 @@ public: QString colorScheme() const; void setColorScheme(const QString &colorScheme); + bool completeSymbols() const; + void setCompleteSymbols(bool completeSymbols); + + bool completeParenthese() const; + void setCompleteParenthese(bool completeParenthese); + + bool completeBracket() const; + void setCompleteBracket(bool completeBracket); + + bool completeBrace() const; + void setCompleteBrace(bool completeBrace); + + bool completeComment() const; + void setCompleteComment(bool completeComment); + + bool completeSingleQuote() const; + void setCompleteSingleQuote(bool completeSingleQuote); + + bool completeDoubleQuote() const; + void setCompleteDoubleQuote(bool completeDoubleQuote); + + bool completeGlobalInclude() const; + void setCompleteGlobalInclude(bool completeGlobalInclude); + + bool overwriteSymbols() const; + void setOverwriteSymbols(bool overwriteSymbols); + + bool removeMathcingSymbol() const; + void setRemoveMathcingSymbol(bool removeMathcingSymbol); + private: QByteArray mDefaultEncoding; //General @@ -277,6 +307,18 @@ public: //Color QString mColorScheme; + //Symbol Completion + bool mCompleteSymbols; + bool mCompleteParenthese; + bool mCompleteBracket; + bool mCompleteBrace; + bool mCompleteComment; + bool mCompleteSingleQuote; + bool mCompleteDoubleQuote; + bool mCompleteGlobalInclude; + bool mOverwriteSymbols; + bool mRemoveMathcingSymbol; + // _Base interface protected: void doSave() override; diff --git a/RedPandaIDE/settingsdialog/editorsymbolcompletionwidget.cpp b/RedPandaIDE/settingsdialog/editorsymbolcompletionwidget.cpp new file mode 100644 index 00000000..5dceb274 --- /dev/null +++ b/RedPandaIDE/settingsdialog/editorsymbolcompletionwidget.cpp @@ -0,0 +1,14 @@ +#include "editorsymbolcompletionwidget.h" +#include "ui_editorsymbolcompletionwidget.h" + +EditorSymbolCompletionWidget::EditorSymbolCompletionWidget(const QString& name, const QString& group, QWidget *parent) : + SettingsWidget(name,group,parent), + ui(new Ui::EditorSymbolCompletionWidget) +{ + ui->setupUi(this); +} + +EditorSymbolCompletionWidget::~EditorSymbolCompletionWidget() +{ + delete ui; +} diff --git a/RedPandaIDE/settingsdialog/editorsymbolcompletionwidget.h b/RedPandaIDE/settingsdialog/editorsymbolcompletionwidget.h new file mode 100644 index 00000000..96373e61 --- /dev/null +++ b/RedPandaIDE/settingsdialog/editorsymbolcompletionwidget.h @@ -0,0 +1,28 @@ +#ifndef EDITORSYMBOLCOMPLETIONWIDGET_H +#define EDITORSYMBOLCOMPLETIONWIDGET_H + +#include +#include "settingswidget.h" + +namespace Ui { +class EditorSymbolCompletionWidget; +} + +class EditorSymbolCompletionWidget : public SettingsWidget +{ + Q_OBJECT + +public: + explicit EditorSymbolCompletionWidget(const QString& name, const QString& group, QWidget *parent = nullptr); + ~EditorSymbolCompletionWidget(); + +private: + Ui::EditorSymbolCompletionWidget *ui; + + // SettingsWidget interface +protected: + void doLoad(); + void doSave(); +}; + +#endif // EDITORSYMBOLCOMPLETIONWIDGET_H diff --git a/RedPandaIDE/settingsdialog/editorsymbolcompletionwidget.ui b/RedPandaIDE/settingsdialog/editorsymbolcompletionwidget.ui new file mode 100644 index 00000000..370a39f5 --- /dev/null +++ b/RedPandaIDE/settingsdialog/editorsymbolcompletionwidget.ui @@ -0,0 +1,143 @@ + + + EditorSymbolCompletionWidget + + + + 0 + 0 + 606 + 413 + + + + Form + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Complete Symbols + + + true + + + + + + GroupBox + + + + 11 + + + 11 + + + 11 + + + 11 + + + + + Complete Braces{} + + + + + + + Complete Brackets [] + + + + + + + Complete Parenthesis () + + + + + + + Complete Multiline Comments /**/ + + + + + + + Complete Single Quotations '' + + + + + + + Complete Double Quotations "" + + + + + + + Complete #include <> + + + + + + + + + + Skip matching symbols while typing + + + + + + + Remove matching symbols when delete chars + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + diff --git a/RedPandaIDE/settingsdialog/settingsdialog.cpp b/RedPandaIDE/settingsdialog/settingsdialog.cpp index a3af00e1..1b34df21 100644 --- a/RedPandaIDE/settingsdialog/settingsdialog.cpp +++ b/RedPandaIDE/settingsdialog/settingsdialog.cpp @@ -6,6 +6,7 @@ #include "editorfontwidget.h" #include "editorclipboardwidget.h" #include "editorcolorschemewidget.h" +#include "editorsymbolcompletionwidget.h" #include "environmentappearencewidget.h" #include #include @@ -47,7 +48,9 @@ SettingsDialog::SettingsDialog(QWidget *parent) : pEditorColorSchemeWidget->init(); addWidget(pEditorColorSchemeWidget); - + pEditorSymbolCompletionWidget = new EditorSymbolCompletionWidget(tr("Symbol Completion"),tr("Editor")); + pEditorSymbolCompletionWidget->init(); + addWidget(pEditorSymbolCompletionWidget); ui->widgetsView->expandAll(); //select the first widget of the first group diff --git a/RedPandaIDE/settingsdialog/settingsdialog.h b/RedPandaIDE/settingsdialog/settingsdialog.h index 5d35de7a..e885bd54 100644 --- a/RedPandaIDE/settingsdialog/settingsdialog.h +++ b/RedPandaIDE/settingsdialog/settingsdialog.h @@ -10,11 +10,12 @@ namespace Ui { class SettingsDialog; } +class PCompilerSet; class CompilerSetOptionWidget; class EditorGeneralWidget; class EditorFontWidget; class EditorClipboardWidget; -class PCompilerSet; +class EditorSymbolCompletionWidget; class EditorColorSchemeWidget; class EnvironmentAppearenceWidget; class SettingsWidget; @@ -52,6 +53,7 @@ private: EditorClipboardWidget *pEditorClipboardWidget; EditorColorSchemeWidget *pEditorColorSchemeWidget; EnvironmentAppearenceWidget* pEnvironmentAppearenceWidget; + EditorSymbolCompletionWidget* pEditorSymbolCompletionWidget; }; #endif // SETTINGSDIALOG_H