- enhancement: Options -> editor -> custom C/C++ type keywords page
This commit is contained in:
parent
7b6dbb9865
commit
d86e93dc35
3
NEWS.md
3
NEWS.md
|
@ -4,7 +4,8 @@ Red Panda C++ Version 2.5
|
|||
- enhancemnet: add "Reserve word for Types" item in color scheme
|
||||
- enhancement: auto save / load problem set
|
||||
- enhancement: project's custom compile include/lib/bin directory is under folder of the app, save them using the path relative to the app
|
||||
- enhancement: slightly reduce memory usage
|
||||
- enhancement: slightly reduce memory usage
|
||||
- enhancement: Options -> editor -> custom C/C++ type keywords page
|
||||
|
||||
Red Panda C++ Version 2.4
|
||||
|
||||
|
|
|
@ -107,6 +107,7 @@ SOURCES += \
|
|||
settingsdialog/debuggeneralwidget.cpp \
|
||||
settingsdialog/editorautosavewidget.cpp \
|
||||
settingsdialog/editorcodecompletionwidget.cpp \
|
||||
settingsdialog/editorcustomctypekeywords.cpp \
|
||||
settingsdialog/editormiscwidget.cpp \
|
||||
settingsdialog/editorsnippetwidget.cpp \
|
||||
settingsdialog/editortooltipswidget.cpp \
|
||||
|
@ -241,6 +242,7 @@ HEADERS += \
|
|||
settingsdialog/debuggeneralwidget.h \
|
||||
settingsdialog/editorautosavewidget.h \
|
||||
settingsdialog/editorcodecompletionwidget.h \
|
||||
settingsdialog/editorcustomctypekeywords.h \
|
||||
settingsdialog/editormiscwidget.h \
|
||||
settingsdialog/editorsnippetwidget.h \
|
||||
settingsdialog/editortooltipswidget.h \
|
||||
|
@ -346,6 +348,7 @@ FORMS += \
|
|||
settingsdialog/debuggeneralwidget.ui \
|
||||
settingsdialog/editorautosavewidget.ui \
|
||||
settingsdialog/editorcodecompletionwidget.ui \
|
||||
settingsdialog/editorcustomctypekeywords.ui \
|
||||
settingsdialog/editormiscwidget.ui \
|
||||
settingsdialog/editorsnippetwidget.ui \
|
||||
settingsdialog/editortooltipswidget.ui \
|
||||
|
@ -464,7 +467,7 @@ RESOURCES += \
|
|||
|
||||
RC_ICONS = images/devcpp.ico images/associations/c.ico images/associations/cpp.ico images/associations/dev.ico images/associations/c.ico images/associations/cpp.ico images/associations/h.ico images/associations/hpp.ico
|
||||
|
||||
# fixed lrelease.prf
|
||||
## fixed lrelease.prf
|
||||
qtPrepareTool(QMAKE_LRELEASE, lrelease)
|
||||
|
||||
isEmpty(LRELEASE_DIR): LRELEASE_DIR = .qm
|
||||
|
|
|
@ -1024,7 +1024,15 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to
|
|||
//selection
|
||||
if (highlighter() && attr) {
|
||||
if (attr == highlighter()->keywordAttribute()) {
|
||||
if (CppTypeKeywords.contains(token)) {
|
||||
if (CppTypeKeywords.contains(token)
|
||||
||
|
||||
(
|
||||
highlighter()->language()==QSynedit::HighlighterLanguage::Cpp
|
||||
&&
|
||||
((QSynedit::CppHighlighter*)highlighter().get())->customTypeKeywords().contains(token)
|
||||
)
|
||||
)
|
||||
{
|
||||
PColorSchemeItem item = mStatementColors->value(StatementKind::skKeywordType,PColorSchemeItem());
|
||||
|
||||
if (item) {
|
||||
|
@ -3108,12 +3116,19 @@ void Editor::showCompletion(const QString& preWord,bool autoComplete, CodeComple
|
|||
if (highlighter()) {
|
||||
if (highlighter()->language() != QSynedit::HighlighterLanguage::Cpp ) {
|
||||
keywords = highlighter()->keywords();
|
||||
} else if (mUseCppSyntax) {
|
||||
foreach (const QString& keyword, CppKeywords.keys()) {
|
||||
keywords.insert(keyword);
|
||||
}
|
||||
} else {
|
||||
keywords = CKeywords;
|
||||
if (mUseCppSyntax) {
|
||||
foreach (const QString& keyword, CppKeywords.keys()) {
|
||||
keywords.insert(keyword);
|
||||
}
|
||||
} else {
|
||||
keywords = CKeywords;
|
||||
}
|
||||
if (pSettings->editor().enableCustomCTypeKeywords()) {
|
||||
foreach (const QString& keyword, pSettings->editor().customCTypeKeywords()) {
|
||||
keywords.insert(keyword);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4761,6 +4776,19 @@ void Editor::applySettings()
|
|||
setRightEdge(0);
|
||||
}
|
||||
|
||||
if (pSettings->editor().enableCustomCTypeKeywords()) {
|
||||
if (highlighter() && highlighter()->language() == QSynedit::HighlighterLanguage::Cpp) {
|
||||
QSet<QString> set;
|
||||
foreach(const QString& s, pSettings->editor().customCTypeKeywords())
|
||||
set.insert(s);
|
||||
((QSynedit::CppHighlighter*)(highlighter().get()))->setCustomTypeKeywords(set);
|
||||
}
|
||||
} else {
|
||||
if (highlighter() && highlighter()->language() == QSynedit::HighlighterLanguage::Cpp) {
|
||||
((QSynedit::CppHighlighter*)(highlighter().get()))->setCustomTypeKeywords(QSet<QString>());
|
||||
}
|
||||
}
|
||||
|
||||
this->setUndoLimit(pSettings->editor().undoLimit());
|
||||
this->setUndoMemoryUsage(pSettings->editor().undoMemoryUsage());
|
||||
|
||||
|
|
|
@ -301,6 +301,15 @@ void Settings::_Base::saveValue(const QString &key, const QVariant &value)
|
|||
mSettings->saveValue(key,value);
|
||||
}
|
||||
|
||||
void Settings::_Base::saveValue(const QString &key, const QSet<QString> &set)
|
||||
{
|
||||
QStringList val;
|
||||
foreach(const QString& s,set) {
|
||||
val.append(s);
|
||||
}
|
||||
mSettings->saveValue(key,val);
|
||||
}
|
||||
|
||||
QVariant Settings::_Base::value(const QString &key, const QVariant &defaultValue)
|
||||
{
|
||||
return mSettings->value(key,defaultValue);
|
||||
|
@ -326,6 +335,15 @@ QStringList Settings::_Base::stringListValue(const QString &key, const QStringLi
|
|||
return value(key,defaultValue).toStringList();
|
||||
}
|
||||
|
||||
QSet<QString> Settings::_Base::stringSetValue(const QString &key)
|
||||
{
|
||||
QStringList lst=value(key,QStringList()).toStringList();
|
||||
QSet<QString> result;
|
||||
foreach(const QString& s, lst)
|
||||
result.insert(s);
|
||||
return result;
|
||||
}
|
||||
|
||||
QColor Settings::_Base::colorValue(const QString &key, const QColor& defaultValue)
|
||||
{
|
||||
return value(key,defaultValue).value<QColor>();
|
||||
|
@ -675,6 +693,26 @@ void Settings::Editor::setParseTodos(bool newParseTodos)
|
|||
mParseTodos = newParseTodos;
|
||||
}
|
||||
|
||||
const QStringList &Settings::Editor::customCTypeKeywords() const
|
||||
{
|
||||
return mCustomCTypeKeywords;
|
||||
}
|
||||
|
||||
void Settings::Editor::setCustomCTypeKeywords(const QStringList &newCustomTypeKeywords)
|
||||
{
|
||||
mCustomCTypeKeywords = newCustomTypeKeywords;
|
||||
}
|
||||
|
||||
bool Settings::Editor::enableCustomCTypeKeywords() const
|
||||
{
|
||||
return mEnableCustomCTypeKeywords;
|
||||
}
|
||||
|
||||
void Settings::Editor::setEnableCustomCTypeKeywords(bool newEnableCustomCTypeKeywords)
|
||||
{
|
||||
mEnableCustomCTypeKeywords = newEnableCustomCTypeKeywords;
|
||||
}
|
||||
|
||||
bool Settings::Editor::highlightCurrentWord() const
|
||||
{
|
||||
return mHighlightCurrentWord;
|
||||
|
@ -1258,6 +1296,9 @@ void Settings::Editor::doSave()
|
|||
saveValue("auto_format_when_saved", mAutoFormatWhenSaved);
|
||||
saveValue("parse_todos",mParseTodos);
|
||||
|
||||
saveValue("custom_c_type_keywords", mCustomCTypeKeywords);
|
||||
saveValue("enable_custom_c_type_keywords",mEnableCustomCTypeKeywords);
|
||||
|
||||
//tooltips
|
||||
saveValue("enable_tooltips",mEnableTooltips);
|
||||
saveValue("enable_debug_tooltips",mEnableDebugTooltips);
|
||||
|
@ -1402,6 +1443,8 @@ void Settings::Editor::doLoad()
|
|||
mAutoFormatWhenSaved = boolValue("auto_format_when_saved", false);
|
||||
mParseTodos = boolValue("parse_todos",true);
|
||||
|
||||
mCustomCTypeKeywords = stringListValue("custom_c_type_keywords");
|
||||
mEnableCustomCTypeKeywords = boolValue("enable_custom_c_type_keywords",false);
|
||||
|
||||
//tooltips
|
||||
mEnableTooltips = boolValue("enable_tooltips",true);
|
||||
|
|
|
@ -64,11 +64,13 @@ private:
|
|||
void endGroup();
|
||||
void remove(const QString &key);
|
||||
void saveValue(const QString &key, const QVariant &value);
|
||||
void saveValue(const QString &key, const QSet<QString>& set);
|
||||
QVariant value(const QString &key, const QVariant& defaultValue);
|
||||
bool boolValue(const QString &key, bool defaultValue);
|
||||
QSize sizeValue(const QString &key);
|
||||
int intValue(const QString &key, int defaultValue);
|
||||
QStringList stringListValue(const QString &key, const QStringList& defaultValue=QStringList());
|
||||
QSet<QString> stringSetValue(const QString &key);
|
||||
QColor colorValue(const QString &key, const QColor& defaultValue);
|
||||
QString stringValue(const QString &key, const QString& defaultValue);
|
||||
void save();
|
||||
|
@ -370,6 +372,12 @@ public:
|
|||
bool parseTodos() const;
|
||||
void setParseTodos(bool newParseTodos);
|
||||
|
||||
const QStringList &customCTypeKeywords() const;
|
||||
void setCustomCTypeKeywords(const QStringList &newCustomTypeKeywords);
|
||||
|
||||
bool enableCustomCTypeKeywords() const;
|
||||
void setEnableCustomCTypeKeywords(bool newEnableCustomCTypeKeywords);
|
||||
|
||||
private:
|
||||
//General
|
||||
// indents
|
||||
|
@ -481,6 +489,9 @@ public:
|
|||
bool mAutoFormatWhenSaved;
|
||||
bool mParseTodos;
|
||||
|
||||
QStringList mCustomCTypeKeywords;
|
||||
bool mEnableCustomCTypeKeywords;
|
||||
|
||||
|
||||
//hints tooltip
|
||||
bool mEnableTooltips;
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
#include "editorcustomctypekeywords.h"
|
||||
#include "ui_editorcustomctypekeywords.h"
|
||||
#include "../settings.h"
|
||||
#include "../iconsmanager.h"
|
||||
|
||||
EditorCustomCTypeKeywordsWidget::EditorCustomCTypeKeywordsWidget(const QString& name, const QString& group, QWidget *parent) :
|
||||
SettingsWidget(name,group,parent),
|
||||
ui(new Ui::editorcustomctypekeywords)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
EditorCustomCTypeKeywordsWidget::~EditorCustomCTypeKeywordsWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void EditorCustomCTypeKeywordsWidget::doLoad()
|
||||
{
|
||||
ui->grpEnableCustomKeywords->setChecked(pSettings->editor().enableCustomCTypeKeywords());
|
||||
ui->lstKeywords->clear();
|
||||
foreach(const QString& s, pSettings->editor().customCTypeKeywords())
|
||||
addKeyword(s);
|
||||
}
|
||||
|
||||
void EditorCustomCTypeKeywordsWidget::doSave()
|
||||
{
|
||||
pSettings->editor().setEnableCustomCTypeKeywords(ui->grpEnableCustomKeywords->isChecked());
|
||||
QStringList lst;
|
||||
QSet<QString> added;
|
||||
for(int i=0;i<ui->lstKeywords->count();i++) {
|
||||
QString t=ui->lstKeywords->item(i)->text().trimmed();
|
||||
if (!t.isEmpty() && !added.contains(t)) {
|
||||
lst.append(t);
|
||||
added.insert(t);
|
||||
}
|
||||
}
|
||||
pSettings->editor().setCustomCTypeKeywords(lst);
|
||||
pSettings->editor().save();
|
||||
doLoad();
|
||||
}
|
||||
|
||||
void EditorCustomCTypeKeywordsWidget::updateIcons(const QSize &/*size*/)
|
||||
{
|
||||
pIconsManager->setIcon(ui->btnAdd, IconsManager::ACTION_MISC_ADD);
|
||||
pIconsManager->setIcon(ui->btnRemove, IconsManager::ACTION_MISC_REMOVE);
|
||||
pIconsManager->setIcon(ui->btnRemoveAll, IconsManager::ACTION_MISC_CLEAN);
|
||||
}
|
||||
|
||||
QListWidgetItem * EditorCustomCTypeKeywordsWidget::addKeyword(const QString &keyword)
|
||||
{
|
||||
QListWidgetItem * item = new QListWidgetItem(keyword,ui->lstKeywords);
|
||||
item->setFlags(Qt::ItemFlag::ItemIsEditable | Qt::ItemFlag::ItemIsEnabled);
|
||||
ui->lstKeywords->addItem(item);
|
||||
return item;
|
||||
}
|
||||
|
||||
void EditorCustomCTypeKeywordsWidget::on_btnAdd_clicked()
|
||||
{
|
||||
QListWidgetItem *item=addKeyword("");
|
||||
ui->lstKeywords->editItem(item);
|
||||
}
|
||||
|
||||
|
||||
void EditorCustomCTypeKeywordsWidget::on_btnRemove_clicked()
|
||||
{
|
||||
int row = ui->lstKeywords->currentRow();
|
||||
if (row>=0 && row<ui->lstKeywords->count()) {
|
||||
QListWidgetItem * item = ui->lstKeywords->takeItem(row);
|
||||
delete item;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void EditorCustomCTypeKeywordsWidget::on_btnRemoveAll_clicked()
|
||||
{
|
||||
ui->lstKeywords->clear();
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
#ifndef EDITORCUSTOMCTYPEKEYWORDS_H
|
||||
#define EDITORCUSTOMCTYPEKEYWORDS_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "settingswidget.h"
|
||||
|
||||
namespace Ui {
|
||||
class editorcustomctypekeywords;
|
||||
}
|
||||
|
||||
class QListWidgetItem;
|
||||
class EditorCustomCTypeKeywordsWidget : public SettingsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EditorCustomCTypeKeywordsWidget(const QString& name, const QString& group, QWidget *parent = nullptr);
|
||||
~EditorCustomCTypeKeywordsWidget();
|
||||
|
||||
private:
|
||||
Ui::editorcustomctypekeywords *ui;
|
||||
|
||||
// SettingsWidget interface
|
||||
protected:
|
||||
void doLoad() override;
|
||||
void doSave() override;
|
||||
|
||||
// SettingsWidget interface
|
||||
protected:
|
||||
void updateIcons(const QSize &size) override;
|
||||
QListWidgetItem * addKeyword(const QString& keyword) ;
|
||||
|
||||
private slots:
|
||||
void on_btnAdd_clicked();
|
||||
void on_btnRemove_clicked();
|
||||
void on_btnRemoveAll_clicked();
|
||||
};
|
||||
|
||||
#endif // EDITORCUSTOMCTYPEKEYWORDS_H
|
|
@ -0,0 +1,102 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>editorcustomctypekeywords</class>
|
||||
<widget class="QWidget" name="editorcustomctypekeywords">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>370</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Custom C/C++ Type Keywords</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="grpEnableCustomKeywords">
|
||||
<property name="title">
|
||||
<string>Enable Custom C/C++ Type Keywords</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnAdd">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnRemove">
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnRemoveAll">
|
||||
<property name="text">
|
||||
<string>Remove All</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>102</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="lstKeywords">
|
||||
<property name="uniformItemSizes">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Note: Custom keywords is not recognized by syntax checker.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -29,6 +29,7 @@
|
|||
#include "editortooltipswidget.h"
|
||||
#include "editorautosavewidget.h"
|
||||
#include "editorsnippetwidget.h"
|
||||
#include "editorcustomctypekeywords.h"
|
||||
#include "editormiscwidget.h"
|
||||
#include "environmentappearencewidget.h"
|
||||
#include "environmentshortcutwidget.h"
|
||||
|
@ -199,6 +200,9 @@ PSettingsDialog SettingsDialog::optionDialog()
|
|||
widget = new EditorAutoSaveWidget(tr("Auto save"),tr("Editor"));
|
||||
dialog->addWidget(widget);
|
||||
|
||||
widget = new EditorCustomCTypeKeywordsWidget(tr("Custom C/C++ Keywords"),tr("Editor"));
|
||||
dialog->addWidget(widget);
|
||||
|
||||
widget = new EditorMiscWidget(tr("Misc"),tr("Editor"));
|
||||
dialog->addWidget(widget);
|
||||
|
||||
|
|
|
@ -6743,6 +6743,10 @@
|
|||
<source>There are changes in the settings, do you want to save them before swtich to other page?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Custom C/C++ Keywords</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsWidget</name>
|
||||
|
@ -7072,6 +7076,33 @@
|
|||
<translation>Valor</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>editorcustomctypekeywords</name>
|
||||
<message>
|
||||
<source>Custom C/C++ Type Keywords</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Add</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Remove</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Remove All</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Enable Custom C/C++ Type Keywords</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Note: Custom keywords is not recognized by syntax checker.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>editorgeneralwidget</name>
|
||||
<message>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -6384,6 +6384,10 @@
|
|||
<source>There are changes in the settings, do you want to save them before swtich to other page?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Custom C/C++ Keywords</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsWidget</name>
|
||||
|
@ -6675,6 +6679,33 @@
|
|||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>editorcustomctypekeywords</name>
|
||||
<message>
|
||||
<source>Custom C/C++ Type Keywords</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Add</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Remove</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Remove All</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Enable Custom C/C++ Type Keywords</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Note: Custom keywords is not recognized by syntax checker.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>editorgeneralwidget</name>
|
||||
<message>
|
||||
|
|
|
@ -544,11 +544,9 @@ void CodeCompletionPopup::getCompletionFor(
|
|||
if(!mParser) {
|
||||
if (mShowKeywords) {
|
||||
//add keywords
|
||||
if (!customKeywords.isEmpty()) {
|
||||
foreach (const QString& keyword,customKeywords) {
|
||||
addKeyword(keyword);
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ SOURCES += qsynedit/CodeFolding.cpp \
|
|||
qsynedit/highlighter/base.cpp \
|
||||
qsynedit/highlighter/composition.cpp \
|
||||
qsynedit/highlighter/cpp.cpp \
|
||||
qsynedit/highlighter/customhighlighterv1.cpp \
|
||||
qsynedit/highlighter/glsl.cpp \
|
||||
qsynedit/Search.cpp \
|
||||
qsynedit/SearchBase.cpp \
|
||||
|
@ -59,6 +60,7 @@ HEADERS += qsynedit/Search.h \
|
|||
qsynedit/highlighter/base.h \
|
||||
qsynedit/highlighter/composition.h \
|
||||
qsynedit/highlighter/cpp.h \
|
||||
qsynedit/highlighter/customhighlighterv1.h \
|
||||
qsynedit/highlighter/glsl.h \
|
||||
|
||||
INCLUDEPATH += ../redpanda_qt_utils
|
||||
|
|
|
@ -1441,6 +1441,16 @@ void CppHighlighter::pushIndents(int indentType)
|
|||
mRange.indents.push_back(indentType);
|
||||
}
|
||||
|
||||
const QSet<QString> &CppHighlighter::customTypeKeywords() const
|
||||
{
|
||||
return mCustomTypeKeywords;
|
||||
}
|
||||
|
||||
void CppHighlighter::setCustomTypeKeywords(const QSet<QString> &newCustomTypeKeywords)
|
||||
{
|
||||
mCustomTypeKeywords = newCustomTypeKeywords;
|
||||
}
|
||||
|
||||
bool CppHighlighter::getTokenFinished() const
|
||||
{
|
||||
if (mTokenId == TokenId::Comment
|
||||
|
@ -1627,7 +1637,7 @@ void CppHighlighter::setLine(const QString &newLine, int lineNumber)
|
|||
|
||||
bool CppHighlighter::isKeyword(const QString &word)
|
||||
{
|
||||
return Keywords.contains(word);
|
||||
return Keywords.contains(word) || mCustomTypeKeywords.contains(word);
|
||||
}
|
||||
|
||||
TokenType CppHighlighter::getTokenType()
|
||||
|
@ -1738,7 +1748,9 @@ bool CppHighlighter::isIdentChar(const QChar &ch) const
|
|||
|
||||
QSet<QString> CppHighlighter::keywords() const
|
||||
{
|
||||
return Keywords;
|
||||
QSet<QString> set=Keywords;
|
||||
set.unite(mCustomTypeKeywords);
|
||||
return set;
|
||||
}
|
||||
|
||||
QString CppHighlighter::foldString()
|
||||
|
|
|
@ -166,6 +166,8 @@ private:
|
|||
int mLeftBraces;
|
||||
int mRightBraces;
|
||||
|
||||
QSet<QString> mCustomTypeKeywords;
|
||||
|
||||
PHighlighterAttribute mAsmAttribute;
|
||||
PHighlighterAttribute mPreprocessorAttribute;
|
||||
PHighlighterAttribute mInvalidAttribute;
|
||||
|
@ -218,6 +220,8 @@ public:
|
|||
// SynHighlighter interface
|
||||
public:
|
||||
QString foldString() override;
|
||||
const QSet<QString> &customTypeKeywords() const;
|
||||
void setCustomTypeKeywords(const QSet<QString> &newCustomTypeKeywords);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
#include "customhighlighterv1.h"
|
||||
|
||||
namespace QSynedit {
|
||||
CustomHighlighterV1::CustomHighlighterV1()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef CUSTOMHIGHLIGHTERV1_H
|
||||
#define CUSTOMHIGHLIGHTERV1_H
|
||||
#include "base.h"
|
||||
namespace QSynedit {
|
||||
|
||||
class CustomHighlighterV1:public Highlighter
|
||||
{
|
||||
public:
|
||||
CustomHighlighterV1();
|
||||
protected:
|
||||
bool mIgnoreCase;
|
||||
QSet<QString> mKeywords;
|
||||
QSet<QString> mTypeKeywords;
|
||||
QSet<QString> mCallableKeywords;
|
||||
QString mLanguageName;
|
||||
QSet<QString> mSuffixes;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // CUSTOMHIGHLIGHTERV1_H
|
Loading…
Reference in New Issue