整体合入v1.22.2的代码

This commit is contained in:
爬山虎 2023-02-11 11:09:17 +08:00
parent 53ed334a5a
commit 24f4f6114e
36 changed files with 2898 additions and 1925 deletions

Binary file not shown.

View File

@ -51,11 +51,7 @@
<bool>true</bool>
</property>
<property name="plainText">
<string>This software is licensed under the terms of the GNU General Public License version 3 (GPLv3). You are free to redistribute and modify the software in accordance with the license.
This software is distributed with the hope that it will be useful, but without any warranties, including the implied warranties of merchantability or fitness for a particular purpose. Please see the GNU General Public License for more information.
A copy of the GPLv3 license should have been provided along with this software. If you have not received a copy, it can be found at https://www.gnu.org/licenses/.</string>
<string>This software is licensed under the terms of the GNU General Public License version 3 (GPLv3). You are free to redistribute and modify the software in accordance with the license.</string>
</property>
</widget>
</item>

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>770</width>
<height>195</height>
<width>661</width>
<height>211</height>
</rect>
</property>
<property name="windowTitle">
@ -39,27 +39,6 @@
<string>Open Mode</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="2">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Big Text File(&lt; 8G) Read only open, load in blocks, and turn pages manually.</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QRadioButton" name="hexMode">
<property name="text">
<string>Hex Bin</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QRadioButton" name="superBigTextMode">
<property name="text">
<string>Super Big Text Edit</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QLabel" name="label_4">
<property name="text">
@ -67,20 +46,6 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QRadioButton" name="textMode">
<property name="text">
<string>Text Mode</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Open directly in text mode.May be slow, Need wait.</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="bigTextMode">
<property name="text">
@ -91,6 +56,34 @@
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Open directly in text mode.May be slow, Need wait.</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QRadioButton" name="textMode">
<property name="text">
<string>Text Mode</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QRadioButton" name="hexMode">
<property name="text">
<string>Hex Bin</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Big Text File(&lt; 8G) Read only open, load in blocks, and turn pages manually.</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="label_5">
<property name="text">
@ -98,6 +91,13 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QRadioButton" name="superBigTextMode">
<property name="text">
<string>Super Big Text</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

File diff suppressed because it is too large Load Diff

View File

@ -112,7 +112,7 @@ public:
}
#endif
bool openFile(QString filePath);
bool openFile(QString filePath, int lineNum=-1);
bool tryRestoreFile(QString filePath);
void initTabNewOne();
@ -197,6 +197,7 @@ protected:
bool eventFilter(QObject *watched, QEvent *event)override;
#ifdef Q_OS_WIN
bool nativeEvent(const QByteArray &eventType, void *message, long *result) override;
bool nativeOpenfile(QString openFilePath);
#endif
#ifdef uos
void adjustWInPos(QWidget* pWin);
@ -269,16 +270,6 @@ private slots:
void slot_aboutNdd();
void slot_fileChange(QString filePath);
void slot_tabBarDoubleClicked(int index);
/*void slot_toLightBlueStyle();
void slot_toDefaultStyle();
void slot_toThinBlueStyle();
void slot_toRiceYellow();
void slot_toYellow();
void slot_toSilverStyle();
void slot_toDarkStyle();
void slot_toLavenderBlush();
void slot_toMistyRose();*/
//void slot_register();
void slot_slectionChanged();
void slot_preHexPage();
@ -354,6 +345,7 @@ private slots:
void slot_showWebAddr(bool check);
void slot_langFileSuffix();
void slot_shortcutManager();
void on_lineEndChange(int index);
private:
void initFindResultDockWin();
@ -365,7 +357,7 @@ private:
void initToolBar();
void setTxtLexer(ScintillaEditView * pEdit);
void saveTabEdit(int tabIndex);
void saveReceneOpenFile();
void updateSaveAllToolBarStatus();
void initReceneOpenFileMenu();
@ -377,7 +369,7 @@ private:
void setSaveAllButtonStatus(bool needSave);
void tabClose(int index, bool isInQuit=false);
void setDocEolMode(ScintillaEditView * pEdit, RC_LINE_FORM endStatus);
void convertDocLineEnd(RC_LINE_FORM endStatus);
bool convertDocLineEnd(RC_LINE_FORM endStatus);
void transDocToEncord(CODE_ID destCode);
void syncCurDocEncodeToMenu(QWidget * curEdit);
@ -394,7 +386,7 @@ private:
bool checkRoladFile(ScintillaEditView * pEdit);
void reloadEditFile(ScintillaEditView * pEidt);
void initFindWindow(FindTabIndex type= FIND_TAB);
int initFindWindow(FindTabIndex type= FIND_TAB);
void setToFileRightMenu();
@ -450,7 +442,8 @@ private:
void tabClose(QWidget* pEdit);
void init_toolsMenu();
void changeBlankShowStatus(int showBlank);
void syncBlankShowStatus();
#ifdef NO_PLUGIN
void loadPluginLib();
void loadPluginProcs(QString strLibDir, QMenu* pMenu);
@ -459,11 +452,12 @@ private:
void setUserDefShortcutKey();
void setNormalTextEditInitPro(ScintillaEditView* pEdit, QString filePath, CODE_ID code, RC_LINE_FORM lineEnd, bool isReadOnly, bool isModifyed);
void dealRecentFileMenuWhenColseFile(QString closeFilePath);
private:
Ui::CCNotePad ui;
QLabel* m_codeStatusLabel;
QLabel* m_lineEndLabel;
QComboBox* m_lineEndLabel;
QLabel* m_lineNumLabel;
QLabel* m_langDescLabel;
QLabel* m_zoomLabel;
@ -476,8 +470,6 @@ private:
QPointer<QDockWidget> m_dockFileListWin;
FileListView* m_fileListView;
//一个用于查找,一个用于排序
QMap <QString,QAction*> m_receneOpenFile;
QList<QString> m_receneOpenFileList;
QActionGroup *m_pEncodeActGroup;

View File

@ -87,8 +87,13 @@
<enum>Qt::LeftToRight</enum>
</property>
<property name="title">
<string>File (&amp;F)</string>
<string>&amp;File</string>
</property>
<widget class="QMenu" name="menuRecene_File">
<property name="title">
<string>Recene File</string>
</property>
</widget>
<addaction name="actionNewFile"/>
<addaction name="actionOpenFile"/>
<addaction name="actionSave"/>
@ -97,13 +102,14 @@
<addaction name="actionClose_All"/>
<addaction name="separator"/>
<addaction name="actionClear_History"/>
<addaction name="menuRecene_File"/>
</widget>
<widget class="QMenu" name="menuEdit">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="title">
<string>Edit (&amp;E)</string>
<string>&amp;Edit</string>
</property>
<widget class="QMenu" name="menuformat_conversion">
<property name="title">
@ -180,7 +186,7 @@
</widget>
<widget class="QMenu" name="menuSearch">
<property name="title">
<string>Search (&amp;S)</string>
<string>&amp;Search</string>
</property>
<widget class="QMenu" name="menuBook_Mark">
<property name="title">
@ -204,7 +210,7 @@
</widget>
<widget class="QMenu" name="menuView">
<property name="title">
<string>View (&amp;V)</string>
<string>&amp;View</string>
</property>
<widget class="QMenu" name="menudisplay_symbols">
<property name="title">
@ -232,7 +238,7 @@
</widget>
<widget class="QMenu" name="menuCode">
<property name="title">
<string>Encoding (&amp;N)</string>
<string>E&amp;ncoding</string>
</property>
<widget class="QMenu" name="menuASNI">
<property name="title">
@ -263,7 +269,7 @@
</widget>
<widget class="QMenu" name="menuLanguage">
<property name="title">
<string>Language (&amp;L)</string>
<string>&amp;Language</string>
</property>
<widget class="QMenu" name="menuP">
<property name="title">
@ -306,6 +312,7 @@
<property name="title">
<string>R</string>
</property>
<addaction name="actionR_2"/>
<addaction name="actionRC"/>
<addaction name="actionRuby"/>
<addaction name="actionRust"/>
@ -466,7 +473,7 @@
</widget>
<widget class="QMenu" name="menuSet">
<property name="title">
<string>Set (&amp;T)</string>
<string>Se&amp;t</string>
</property>
<widget class="QMenu" name="menuLanguage_2">
<property name="title">
@ -479,6 +486,8 @@
<addaction name="menuLanguage_2"/>
<addaction name="actionLanguage_Format"/>
<addaction name="actionDefine_Language"/>
<addaction name="actionLanguage_File_Suffix"/>
<addaction name="actionShortcut_Key_Manager"/>
</widget>
<widget class="QMenu" name="menuAbout">
<property name="title">
@ -495,7 +504,7 @@
</widget>
<widget class="QMenu" name="menuTools">
<property name="title">
<string>Tools (&amp;O)</string>
<string>T&amp;ools</string>
</property>
</widget>
<addaction name="menuFile"/>
@ -506,6 +515,7 @@
<addaction name="menuLanguage"/>
<addaction name="menuSet"/>
<addaction name="menuTools"/>
<addaction name="menuCompare"/>
<addaction name="menuAbout"/>
<addaction name="menuAbout_2"/>
</widget>
@ -819,7 +829,7 @@
<bool>true</bool>
</property>
<property name="text">
<string>Php</string>
<string>PHP</string>
</property>
</action>
<action name="actionC">
@ -939,7 +949,7 @@
<bool>true</bool>
</property>
<property name="text">
<string>Virsual Basic</string>
<string>Visual Basic</string>
</property>
</action>
<action name="actionJavaScript">
@ -955,7 +965,7 @@
<bool>true</bool>
</property>
<property name="text">
<string>Css</string>
<string>CSS</string>
</property>
</action>
<action name="actionPerl">
@ -987,7 +997,7 @@
<bool>true</bool>
</property>
<property name="text">
<string>Tex</string>
<string>TeX</string>
</property>
</action>
<action name="actionFortran">
@ -1224,7 +1234,7 @@
<bool>true</bool>
</property>
<property name="text">
<string>Nncrontab</string>
<string>NCrontab</string>
</property>
</action>
<action name="actionNim">
@ -1248,7 +1258,7 @@
<bool>true</bool>
</property>
<property name="text">
<string>LaTex</string>
<string>LaTeX</string>
</property>
</action>
<action name="actionForth">
@ -1397,7 +1407,7 @@
<bool>true</bool>
</property>
<property name="text">
<string>json</string>
<string>JSON</string>
</property>
</action>
<action name="actionD_2">
@ -1445,7 +1455,7 @@
<bool>true</bool>
</property>
<property name="text">
<string>Spice</string>
<string>SPICE</string>
</property>
</action>
<action name="actionVerilog">
@ -1479,7 +1489,7 @@
<bool>true</bool>
</property>
<property name="text">
<string>go</string>
<string>Go</string>
</property>
</action>
<action name="actionSearch_Result">
@ -1575,11 +1585,6 @@
<string>Chinese</string>
</property>
</action>
<action name="actionLanguage_Format">
<property name="text">
<string>Theme Style</string>
@ -2033,6 +2038,16 @@
<string>Shortcut Key Manager</string>
</property>
</action>
<action name="actionR_2">
<property name="text">
<string>R</string>
</property>
</action>
<action name="actiontest_3">
<property name="text">
<string>test</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>
@ -3447,6 +3462,22 @@
</hint>
</hints>
</connection>
<connection>
<sender>actionWrap</sender>
<signal>triggered(bool)</signal>
<receiver>CCNotePad</receiver>
<slot>slot_wordwrap(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>728</x>
<y>394</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>slot_actionNewFile_toggle(bool)</slot>
@ -3505,7 +3536,7 @@
<slot>slot_removeEndBlank()</slot>
<slot>slot_removeHeadEndBlank()</slot>
<slot>slot_columnBlockEdit()</slot>
<slot>slot_wordwrap()</slot>
<slot>slot_wordwrap(bool)</slot>
<slot>slot_defineLangs()</slot>
<slot>slot_uppercase()</slot>
<slot>slot_lowercase()</slot>

View File

@ -218,13 +218,14 @@ void FileManager::delNewFileNode(int fileIndex)
}
}
//这里是以文本方式加载文件。但是可能遇到的是二进制文件,里面会做判断
//二进制时hexAsk是否询问当用户指定打开格式时不需要询问
int FileManager::loadFileDataInText(ScintillaEditView* editView, QString filePath, CODE_ID& fileTextCode, RC_LINE_FORM& lineEnd,CCNotePad * callbackObj, bool hexAsk)
//MsgBoxParent::尽量把这个给一下让MsgBox有图标不那么难看。
int FileManager::loadFileDataInText(ScintillaEditView* editView, QString filePath, CODE_ID& fileTextCode, RC_LINE_FORM& lineEnd,CCNotePad * callbackObj, bool hexAsk, QWidget* msgBoxParent)
{
QFile file(filePath);
//如果文件不存在,直接返回
if (!file.exists())
{
@ -233,34 +234,12 @@ int FileManager::loadFileDataInText(ScintillaEditView* editView, QString filePat
QFlags<QFileDevice::Permission> power = QFile::permissions(filePath);
#if 0
if (!power.testFlag(QFile::ReadOwner))
{
//文件不能读
QMessageBox::warning(nullptr, tr("Error"), tr("Open File %1 failed Can not read auth").arg(filePath));
return 1;
}
#endif
//直接以只读的方式打开,至于能不能保存,是保存时需要考虑的问题。
//只需要在保存的时候获取admin权限即可
QIODevice::OpenMode mode;
mode = QIODevice::ExistingOnly | QIODevice::ReadOnly;
#if 0
if (!power.testFlag(QFile::WriteUser))
{
//文件不能写
mode = QIODevice::ExistingOnly | QIODevice::ReadOnly;
}
else
{
mode = QIODevice::ExistingOnly | QIODevice::ReadWrite;
}
#endif
if (!file.open(mode))
{
qDebug() << file.error();
@ -276,7 +255,7 @@ int FileManager::loadFileDataInText(ScintillaEditView* editView, QString filePat
}
#endif
#ifdef Q_OS_UNIX
QMessageBox::warning(nullptr, tr("Error"), tr("Open File %1 failed").arg(filePath));
QMessageBox::warning(msgBoxParent, tr("Error"), tr("Open File %1 failed").arg(filePath));
#endif
return 2;
}
@ -293,10 +272,9 @@ int FileManager::loadFileDataInText(ScintillaEditView* editView, QString filePat
qint64 bufferSizeRequested = fileSize + qMin((qint64)(1 << 20), (qint64)(fileSize / 6));
// As a 32bit application, we cannot allocate 2 buffer of more than INT_MAX size (it takes the whole address space)
if (bufferSizeRequested > INT_MAX)
{
QMessageBox::warning(nullptr, tr("Error"), tr("File is too big to be opened by Notepad--"));
QMessageBox::warning(msgBoxParent, tr("Error"), tr("File is too big to be opened by Notepad--"));
file.close();
return 3;
}
@ -320,7 +298,7 @@ int FileManager::loadFileDataInText(ScintillaEditView* editView, QString filePat
if (isHexFile && hexAsk)
{
//检测到文件很可能是二进制文件,询问用户,是否以二进制加载
int ret = QMessageBox::question(nullptr, tr("Open with Text or Hex?"), tr("The file %1 is likely to be binary. Do you want to open it in binary?").arg(filePath), tr("Hex Open"), tr("Text Open"), tr("Cancel"));
int ret = QMessageBox::question(msgBoxParent, tr("Open with Text or Hex? [Exist Garbled Code]"), tr("The file %1 is likely to be binary. Do you want to open it in binary?").arg(filePath), tr("Hex Open"), tr("Text Open"), tr("Cancel"));
if (ret == 0)
{
@ -412,11 +390,17 @@ int FileManager::loadFileDataInText(ScintillaEditView* editView, QString filePat
}
else
{
//20230203有github用户反馈说存在乱码的文件被截断所以后续还是不走截断
editView->setText(text);
return 6;
#if 0
//这种情况,为了不编辑二进制模式,是可能只读的。
if (1 == editView->setUtf8Text(text))
{
return 5;//只读模式
}
#endif
}
return 0;
@ -906,6 +890,8 @@ bool FileManager::loadFileData(QString filePath, TextFileMgr* & textFileOut, RC_
//读取了1M的内容从尾部往找找到第一个换行符号。如果没有怎么办说明是一个巨长的行不妙
buf[ret] = '\0';
//检测是否为unicode_le编码要特殊对待。
//bool isUnLeCode = CmpareMode::isUnicodeLeBomFile((uchar*)buf, 2);
CODE_ID code = CmpareMode::getTextFileEncodeType((uchar*)buf, ret, filePath, true);

View File

@ -154,7 +154,7 @@ public:
void delNewFileNode(int fileIndex);
int loadFileDataInText(ScintillaEditView * editView, QString filePath, CODE_ID & fileTextCode, RC_LINE_FORM &lineEnd, CCNotePad * callbackObj=nullptr, bool hexAsk = true);
int loadFileDataInText(ScintillaEditView * editView, QString filePath, CODE_ID & fileTextCode, RC_LINE_FORM &lineEnd, CCNotePad * callbackObj=nullptr, bool hexAsk = true, QWidget* MsgBoxParent=nullptr);
int loadFileForSearch(ScintillaEditView * editView, QString filePath);

View File

@ -21,11 +21,14 @@ enum TAB_TYPES {
MARK_TYPE,
};
const int MAX_RECORD_KEY_LENGTH = 20;
FindWin::FindWin(QWidget *parent):QMainWindow(parent), m_editTabWidget(nullptr), m_isFindFirst(true), m_findHistory(nullptr), \
pEditTemp(nullptr), m_curEditWin(nullptr), m_isStatic(false), m_isReverseFind(false), m_pMainPad(parent)
{
ui.setupUi(this);
//默认值要与界面初始值一样。
m_BackwardDir = false;
m_matchWhole = false;
m_matchCase = false;
@ -33,6 +36,15 @@ FindWin::FindWin(QWidget *parent):QMainWindow(parent), m_editTabWidget(nullptr),
m_extend = false;
m_searchMode = 1;
m_re = false;
m_cs = false;
m_wo = false;
m_wrap = true;
m_forward = true;;//是否向前查找。注意如果向后要为false
m_extend = false;
m_isFound = false;
connect(ui.findModeRegularBt, &QRadioButton::toggled, this, &FindWin::slot_findModeRegularBtChange);
connect(ui.replaceModeRegularBt, &QRadioButton::toggled, this, &FindWin::slot_replaceModeRegularBtChange);
connect(ui.dealFileType, &QCheckBox::stateChanged, this,&FindWin::slot_dealFileTypeChange);
@ -40,7 +52,7 @@ FindWin::FindWin(QWidget *parent):QMainWindow(parent), m_editTabWidget(nullptr),
connect(ui.clearBt, &QAbstractButton::clicked, this, &FindWin::sign_clearResult);
connect(ui.findClearBt, &QAbstractButton::clicked, this, &FindWin::sign_clearResult);
connect(ui.findinfilesTab, &QTabWidget::currentChanged, this, &FindWin::slot_tabIndexChange);
#if 0 //这样是无效的,记住一下,不删除,避免后面再做无用功
Qt::WindowFlags m_flags = windowFlags();
@ -74,9 +86,11 @@ void FindWin::slot_tabIndexChange(int index)
if (RELPACE_TYPE == type)
{
ui.replaceTextBox->setFocus();
if (ui.replaceTextBox->currentText().isEmpty() && !ui.findComboBox->currentText().isEmpty())
{
if (ui.findComboBox->currentText().size() < 255)
if (ui.findComboBox->currentText().size() < MAX_RECORD_KEY_LENGTH)
{
ui.replaceTextBox->setCurrentText(ui.findComboBox->currentText());
}
@ -84,14 +98,24 @@ void FindWin::slot_tabIndexChange(int index)
}
else if(FIND_TYPE == type)
{
ui.findComboBox->setFocus();
if (ui.findComboBox->currentText().isEmpty() && !ui.replaceTextBox->currentText().isEmpty())
{
if (ui.replaceTextBox->currentText().size() < 255)
if (ui.replaceTextBox->currentText().size() < MAX_RECORD_KEY_LENGTH)
{
ui.findComboBox->setCurrentText(ui.replaceTextBox->currentText());
}
}
}
else if (DIR_FIND_TYPE == type)
{
ui.dirFindWhat->setFocus();
}
else if (MARK_TYPE == type)
{
ui.markTextBox->setFocus();
}
m_isFindFirst = true;
@ -228,11 +252,11 @@ void FindWin::removeLineHeadEndBlank(int mode)
if (mode == 1)
{
ui.replaceTextBox->setCurrentText("^\\s+");
ui.replaceTextBox->setCurrentText("^[ ]+");
}
else if (mode == 2)
{
ui.replaceTextBox->setCurrentText("\\s+$");
ui.replaceTextBox->setCurrentText("[ ]+$");
}
ui.replaceWithBox->setText("");
@ -557,7 +581,7 @@ void FindWin::updateParameterFromUI()
void FindWin::addFindHistory(QString &text)
{
//太长会导致看起来很杂乱,也不记录
if (text.isEmpty() || text.size() >= 255)
if (text.isEmpty() || text.size() >= MAX_RECORD_KEY_LENGTH)
{
return;
}
@ -786,6 +810,18 @@ void FindWin::dealWithZeroFound(QsciScintilla* pEdit)
}
}
//调整光标变化后,查找位置需要调整的情况
void FindWin::adjustSearchStartPosChange(QsciScintilla* pEdit)
{
int caretPos = pEdit->SendScintilla(SCI_GETCURRENTPOS);
FindState& state = pEdit->getLastFindState();
if (state.targend != caretPos)
{
state.startpos = caretPos;
}
}
/*处理查找时零长的问题。一定要处理,否则会死循环,因为每次都在原地查找。
* startpos往前一个startpos找到自己
* dealWithZeroFound是一样的
@ -869,6 +905,8 @@ void FindWin::dofindNext()
//查找下一个
if (pEdit != nullptr)
{
adjustSearchStartPosChange(pEdit);
if (!pEdit->findNext())
{
ui.statusbar->showMessage(tr("no more find text \'%1\'").arg(m_expr), 8000);
@ -1373,6 +1411,7 @@ bool FindWin::replaceFindNext(QsciScintilla* pEdit, bool showZeroFindTip)
//查找下一个
if (pEdit != nullptr)
{
adjustSearchStartPosChange(pEdit);
if (!pEdit->findNext())
{
ui.statusbar->showMessage(tr("no more find text \'%1\'").arg(m_expr), 8000);
@ -2030,7 +2069,13 @@ void FindWin::slot_clearAllMark()
//选择查找目录
void FindWin::slot_dirSelectDest()
{
QString destDir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), CCNotePad::s_lastOpenDirPath, QFileDialog::DontResolveSymlinks);
QString curDirPath = ui.destFindDir->text();
if (curDirPath.isEmpty())
{
curDirPath = CCNotePad::s_lastOpenDirPath;
}
QString destDir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), curDirPath, QFileDialog::DontResolveSymlinks);
if (!destDir.isEmpty())
{
ui.destFindDir->setText(destDir);

View File

@ -111,6 +111,8 @@ private:
void dealWithZeroFoundShowTip(QsciScintilla * pEdit, bool isShowTip=true);
void adjustSearchStartPosChange(QsciScintilla* pEdit);
void dofindNext();
bool replaceFindNext(QsciScintilla* pEdit, bool showZeroFindTip);

View File

@ -40,7 +40,7 @@
</size>
</property>
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="tab_find">
<attribute name="title">
@ -1386,54 +1386,68 @@
<widget class="QStatusBar" name="statusbar"/>
</widget>
<tabstops>
<tabstop>findinfilesTab</tabstop>
<tabstop>findComboBox</tabstop>
<tabstop>findTextNext</tabstop>
<tabstop>findTextPrev</tabstop>
<tabstop>countBt</tabstop>
<tabstop>findAllinCourrent</tabstop>
<tabstop>findAllinAllOpen</tabstop>
<tabstop>findClearBt</tabstop>
<tabstop>findCloseBt</tabstop>
<tabstop>findBackwardBox</tabstop>
<tabstop>findMatchWholeBox</tabstop>
<tabstop>findMatchCaseBox</tabstop>
<tabstop>findWrapBox</tabstop>
<tabstop>findModeNormalBt</tabstop>
<tabstop>findModeExtendBt</tabstop>
<tabstop>findModeRegularBt</tabstop>
<tabstop>replaceTextBox</tabstop>
<tabstop>replaceBackwardBox</tabstop>
<tabstop>replaceMatchWholeBox</tabstop>
<tabstop>replaceMatchCaseBox</tabstop>
<tabstop>replaceWrapBox</tabstop>
<tabstop>replaceModeRegularBt</tabstop>
<tabstop>replaceModeNormalBox</tabstop>
<tabstop>replaceWithBox</tabstop>
<tabstop>replaceFindNextBox</tabstop>
<tabstop>replaceBt</tabstop>
<tabstop>replaceAllBt</tabstop>
<tabstop>replaceAllinAllOpenBt</tabstop>
<tabstop>replaceCloseBt</tabstop>
<tabstop>replaceBackwardBox</tabstop>
<tabstop>replaceMatchWholeBox</tabstop>
<tabstop>replaceMatchCaseBox</tabstop>
<tabstop>replaceWrapBox</tabstop>
<tabstop>replaceModeNormalBox</tabstop>
<tabstop>replaceModeExtendBox</tabstop>
<tabstop>replaceModeRegularBt</tabstop>
<tabstop>destFindDir</tabstop>
<tabstop>selectDir</tabstop>
<tabstop>dirFindWhat</tabstop>
<tabstop>dirReplaceWhat</tabstop>
<tabstop>selectDir</tabstop>
<tabstop>dirFindAll</tabstop>
<tabstop>dirReplaceAll</tabstop>
<tabstop>clearBt</tabstop>
<tabstop>dirClose</tabstop>
<tabstop>dealFileType</tabstop>
<tabstop>fileType</tabstop>
<tabstop>skipDir</tabstop>
<tabstop>skipDirNames</tabstop>
<tabstop>dirFindMatchWholeBox</tabstop>
<tabstop>dirFindMatchCaseBox</tabstop>
<tabstop>dirFindModeRegularBt</tabstop>
<tabstop>dirFindModeNormalBox</tabstop>
<tabstop>dirFindModeExtendBox</tabstop>
<tabstop>dirFindModeRegularBt</tabstop>
<tabstop>skipChildDirs</tabstop>
<tabstop>skipHideFile</tabstop>
<tabstop>skipBinary</tabstop>
<tabstop>skipFileMaxSize</tabstop>
<tabstop>maxFileSizeSpinBox</tabstop>
<tabstop>dirFindAll</tabstop>
<tabstop>dirReplaceAll</tabstop>
<tabstop>dirClose</tabstop>
<tabstop>markTextBox</tabstop>
<tabstop>markMatchWholeBox</tabstop>
<tabstop>markMatchCaseBox</tabstop>
<tabstop>markModeRegularBt</tabstop>
<tabstop>markModeNormalBox</tabstop>
<tabstop>markAllBox</tabstop>
<tabstop>markClearBox</tabstop>
<tabstop>markClearAllBox</tabstop>
<tabstop>markCloseBt</tabstop>
<tabstop>markMatchWholeBox</tabstop>
<tabstop>markMatchCaseBox</tabstop>
<tabstop>markModeNormalBox</tabstop>
<tabstop>markModeExtendBox</tabstop>
<tabstop>markModeRegularBt</tabstop>
</tabstops>
<resources>
<include location="RealCompare.qrc"/>
@ -1462,8 +1476,8 @@
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>674</x>
<y>288</y>
<x>572</x>
<y>251</y>
</hint>
<hint type="destinationlabel">
<x>169</x>
@ -1510,8 +1524,8 @@
<slot>slot_replaceFindNext()</slot>
<hints>
<hint type="sourcelabel">
<x>448</x>
<y>69</y>
<x>94</x>
<y>60</y>
</hint>
<hint type="destinationlabel">
<x>588</x>
@ -1526,8 +1540,8 @@
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>448</x>
<y>213</y>
<x>94</x>
<y>45</y>
</hint>
<hint type="destinationlabel">
<x>588</x>
@ -1542,8 +1556,8 @@
<slot>slot_replace()</slot>
<hints>
<hint type="sourcelabel">
<x>448</x>
<y>103</y>
<x>94</x>
<y>64</y>
</hint>
<hint type="destinationlabel">
<x>588</x>
@ -1558,8 +1572,8 @@
<slot>slot_replaceAll()</slot>
<hints>
<hint type="sourcelabel">
<x>448</x>
<y>137</y>
<x>94</x>
<y>67</y>
</hint>
<hint type="destinationlabel">
<x>588</x>
@ -1574,8 +1588,8 @@
<slot>slot_replaceAllInOpenDoc()</slot>
<hints>
<hint type="sourcelabel">
<x>448</x>
<y>180</y>
<x>94</x>
<y>76</y>
</hint>
<hint type="destinationlabel">
<x>588</x>
@ -1638,8 +1652,8 @@
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>674</x>
<y>171</y>
<x>572</x>
<y>142</y>
</hint>
<hint type="destinationlabel">
<x>564</x>
@ -1718,8 +1732,8 @@
<slot>slot_findPrev()</slot>
<hints>
<hint type="sourcelabel">
<x>674</x>
<y>103</y>
<x>484</x>
<y>73</y>
</hint>
<hint type="destinationlabel">
<x>294</x>

View File

@ -31,15 +31,16 @@
#include <qt_windows.h>
const ULONG_PTR CUSTOM_TYPE = 10000;
const ULONG_PTR OPEN_NOTEPAD_TYPE = 10001;
const ULONG_PTR CUSTOM_TYPE_FILE_LINENUM = 10002;
bool s_isAdminAuth = false;
#endif
bool s_isAdminAuth = false;
const QString c_strTitle = "Ndd";
#ifdef Q_OS_UNIX
#if defined(Q_OS_MAC)
QSharedMemory shared("CCNotebook116");;//mac下面后面带一个版本号避免新的打不开
QSharedMemory shared("CCNotebook122");;//mac下面后面带一个版本号避免新的打不开
#else
QSharedMemory shared("CCNotebook");
#endif
@ -119,13 +120,16 @@ class MyApplication : public QApplication
int main(int argc, char *argv[])
{
//可以防止某些屏幕下的字体拥挤重叠问题
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#ifdef Q_OS_MAC
MyApplication a(argc, argv);
#else
QApplication a(argc, argv);
#endif
QDir::setCurrent(QCoreApplication::applicationDirPath());
//不能开启,开启后相对路径打开文件失败
//QDir::setCurrent(QCoreApplication::applicationDirPath());
#if defined(Q_OS_UNIX)
QApplication::setStyle(QStyleFactory::create("fusion"));
@ -135,6 +139,22 @@ int main(int argc, char *argv[])
QStringList arguments = QCoreApplication::arguments();
//目前就三种
//1) ndd filepath
//2) ndd filepath -n linenum
//3) ndd -multi filepath
//只有 1 2 需要处理短路径
if ((arguments.size() == 2) || (arguments.size() == 4))
{
QFileInfo fi(arguments[1]);
if (fi.isRelative())
{
QString absDir = QDir::currentPath();
//获取绝对路径
arguments[1] = QString("%1/%2").arg(absDir).arg(arguments.at(1));
}
}
#ifdef uos
QFont font("Noto Sans CJK SC,9,-1,5,50,0,0,0,0,0,Regular", 9);
QApplication::setFont(font);
@ -147,8 +167,11 @@ int main(int argc, char *argv[])
// qDebug() << QApplication::font().toString();
#endif
bool isGotoLine = false;
#ifdef Q_OS_WIN
QSharedMemory shared("ccnotepad");
if (arguments.size() > 2)
{
//如果是多开请求,这种是从管理员权限申请后重开过来的
@ -167,7 +190,19 @@ int main(int argc, char *argv[])
goto authAdmin;
}
else if ((arguments.size() == 4) && arguments[2] == QString("-n"))
{
//使用的是 file -n lineNums 方式。目前只有windows下支持 xxxfile -n linenum的格式
isGotoLine = true;
}
}
#else
if ((arguments.size() == 4) && (arguments[2] == QString("-n")))
{
//使用的是 file -n lineNums 方式。目前只有windows下支持 xxxfile -n linenum的格式
isGotoLine = true;
}
#endif
//attach成功表示已经存在该内存了表示当前存在实例
@ -177,7 +212,8 @@ int main(int argc, char *argv[])
if (arguments.size() > 1)
{
#if defined(Q_OS_WIN)
int tryTimes = 0;
do {
qlonglong hwndId;
shared.lock();
memcpy(&hwndId, shared.data(), sizeof(qlonglong));
@ -187,6 +223,9 @@ int main(int argc, char *argv[])
if (::IsWindow(hwnd))
{
if (!isGotoLine)
{
//就是ndd filepath的命令行格式
//去掉第一个参数,后续的参数拼接起来。其实参数中间有空格还是需要使用""引用起来,避免空格参数分隔为多个
arguments.takeFirst();
@ -202,9 +241,39 @@ int main(int argc, char *argv[])
}
else
{
//是 filepath -n linenums 方式。不考虑filepath含有空格的情况因为前面做了严格判断
QString para = QString("%1|%2").arg(arguments[1]).arg(arguments[3]);
QByteArray data = para.toUtf8();
COPYDATASTRUCT copydata;
copydata.dwData = CUSTOM_TYPE_FILE_LINENUM; //自定义类型
copydata.lpData = data.data(); //数据大小
copydata.cbData = data.size(); // 指向数据的指针
::SendMessage(hwnd, WM_COPYDATA, reinterpret_cast<WPARAM>(nullptr), reinterpret_cast<LPARAM>(&copydata));
}
break;
}
else
{
//20230304 右键多个文件同时打开比如3个。此时只有第1个可获取锁其余2个均走这里。
//因为第个还没有来的及写入hwnd。此时不要goto drop_old。等一下再重试
QThread::sleep(1);
++tryTimes;
//2次识别后没法了只能通过继续往下走。
//失败了,此时说明前一个窗口极可能状态错误了。如果不处理,则再也打不开程序了
if (tryTimes > 2)
{
goto drop_old;
}
}
} while (true);
#elif defined (Q_OS_MAC)
{
//mac下面不需要有他自身的机制保证
@ -223,7 +292,11 @@ int main(int argc, char *argv[])
memcpy((char*)nppShared.data()+sizeof(pid_t),data.data(),data.size());
nppShared.unlock();
kill(pid,SIGUSR1);
//if kill failed, then open a new process
if(0 != kill(pid,SIGUSR1))
{
goto unix_goon;
}
#endif
}
else if (arguments.size() == 1)
@ -266,7 +339,10 @@ int main(int argc, char *argv[])
nppShared.unlock();
qDebug()<<"empty file send";
kill(pid,SIGUSR1);
if(0 != kill(pid,SIGUSR1))
{
goto unix_goon;
}
#endif
}
return 0;
@ -281,6 +357,8 @@ int main(int argc, char *argv[])
nppShared.create(32);
}
#else
unix_goon:
shared.create(32);
nppShared.create(2048);
@ -349,7 +427,6 @@ drop_old:
pMainNotepad->initTabNewOne();
}
#endif
if (arguments.size() == 2)
{
#ifdef Q_OS_WIN
@ -367,6 +444,17 @@ drop_old:
pMainNotepad->openFile(arguments[1]);
#endif
}
else if (isGotoLine)
{
//是filepath -n xxx 格式。
bool ok = true;
int lineNum = arguments[3].toInt(&ok);
if (!ok)
{
lineNum = -1;
}
pMainNotepad->openFile(arguments[1], lineNum);
}
#ifdef Q_OS_WIN
pMainNotepad->checkAppFont();
#endif

View File

@ -84,11 +84,17 @@ void QsciDisplayWindow::setFoldColor(int margin, QColor fgClack, QColor bkColor)
void QsciDisplayWindow::setStyleOptions()
{
if (StyleSet::m_curStyleId != BLACK_SE)
{
//if (StyleSet::m_curStyleId != BLACK_SE)
//{
setMarginsForegroundColor(QColor(0x80, 0x80, 0x80)); //默认0x80, 0x80, 0x80
}
else
//}
//else
//{
// setMarginsForegroundColor(QColor(0xde, 0xde, 0xde)); //默认0x80, 0x80, 0x80
//}
//setMarginsBackgroundColor(StyleSet::marginsBackgroundColor);
//setFoldMarginColors(StyleSet::marginsBackgroundColor, StyleSet::marginsBackgroundColor);
setMarginsBackgroundColor(0xf0f0f0);
setFoldMarginColors(0xf0f0f0, 0xf0f0f0);
{

104
src/qscint/src/Qsci/qscilexerr.h Executable file
View File

@ -0,0 +1,104 @@
#pragma once
#pragma once
// This defines the interface to the QsciLexerR class.
//
// Copyright (c) 2021 Riverbank Computing Limited <info@riverbankcomputing.com>
//
// This file is part of QScintilla.
//
// This file may be used under the terms of the GNU General Public License
// version 3.0 as published by the Free Software Foundation and appearing in
// the file LICENSE included in the packaging of this file. Please review the
// following information to ensure the GNU General Public License version 3.0
// requirements will be met: http://www.gnu.org/copyleft/gpl.html.
//
// If you do not wish to use this file under the terms of the GPL version 3.0
// then you may purchase a commercial license. For more information contact
// info@riverbankcomputing.com.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#include <QObject>
#include <Qsci/qsciglobal.h>
#include <Qsci/qscilexer.h>
//! \brief The QsciLexerR class encapsulates the Scintilla Bash lexer.
class QSCINTILLA_EXPORT QsciLexerR : public QsciLexer
{
Q_OBJECT
public:
//! This enum defines the meanings of the different styles used by the
//! Bash lexer.
enum {
DEFAULT=0,
COMMENT,
KWORD,
BASEKWORD,
OTHERKWORD,
NUMBER,
STRING,
STRING2,
OPERATOR,
IDENTIFIER,
INFIX,
INFIXEOL,
};
//! Construct a QsciLexerR with parent \a parent. \a parent is
//! typically the QsciScintilla instance.
QsciLexerR(QObject* parent = 0);
//! Destroys the QsciLexerR instance.
virtual ~QsciLexerR();
//! Returns the name of the language.
const char* language() const;
//! Returns the name of the lexer. Some lexers support a number of
//! languages.
const char* lexer() const;
//! Returns the string of characters that comprise a word.
const char* wordCharacters() const;
//! Returns the foreground colour of the text for style number \a style.
//!
//! \sa defaultPaper()
QColor defaultColor(int style) const;
//! Returns the end-of-line fill for style number \a style.
bool defaultEolFill(int style) const;
//! Returns the font for style number \a style.
QFont defaultFont(int style) const;
//! Returns the background colour of the text for style number \a style.
//!
//! \sa defaultColor()
QColor defaultPaper(int style) const;
//! Returns the set of keywords for the keyword set \a set recognised
//! by the lexer as a space separated string.
const char* keywords(int set);
//! Returns the descriptive name for style number \a style. If the
//! style is invalid for this language then an empty QString is returned.
//! This is intended to be used in user preference dialogs.
QString description(int style) const;
public slots:
protected:
//! The lexer's properties are read from the settings \a qs. \a prefix
//! (which has a trailing '/') should be used as a prefix to the key of
//! each setting. true is returned if there is no error.
//!
private:
QsciLexerR(const QsciLexerR&);
QsciLexerR& operator=(const QsciLexerR&);
};

View File

@ -182,10 +182,21 @@ QsciLexer::StyleData& QsciLexer::setThemesDefaultStyleData(int style) const
//如果是非默认主题,则无条件的把所有属性都设置为默认值
//这样一来默认都是GLobal的默认风格只有文件中存在配置值的才是其它指定风格
//外部已经使用Global的默认值填充了QsciLexer的默认值
if (L_GLOBAL != lexerId())
{
// See if this is a new style by checking if the colour is valid.
if (m_themesId != 0 || !sd.color.isValid())
//20230209 默认风格,不能全部使用默认值,使用风格本身值,否则默认风格丢失
//20230209 发现当默认重置,切换到黑色,再切换到默认,默认丢失颜色高亮。
//因为语法其实没有使用默认赋值。
if (m_themesId == 0)
{
sd.color = defaultColor(style);
sd.paper = defaultPaper(style);
sd.font = defaultFont(style);
sd.eol_fill = defaultEolFill(style);
}
else if (m_themesId != 0 || !sd.color.isValid())
{
sd.color = defaultColor();
sd.paper = defaultPaper();

View File

@ -29,7 +29,9 @@
QsciLexerAsm::QsciLexerAsm(QObject* parent)
: QsciLexer(parent), fold_compact(true)
{
m_commentSymbol = "#";
m_commentSymbol = ";";
m_commentStart = "/*";
m_commentEnd = "*/";
}
@ -64,25 +66,46 @@ QColor QsciLexerAsm::defaultColor(int style) const
switch (style)
{
case DEFAULT:
return QColor(0x00, 0x00, 0x00);
case COMMENT:
return QColor(0x00, 0x80, 0x00);
case NUMBER:
return QColor(0xff, 0x80, 0x00);
case STRING:
return QColor(0x80, 0x80, 0x80);
case OPERATOR:
return QColor(0x00, 0x00, 0x80);
case IDENTIFIER:
return QColor(0x00, 0x00, 0x00);
case CPUINSTRUCTION: //key word:
return QColor(0x00, 0x00, 0xff);
case MATHINSTRUCTION:
return QColor(0x00, 0x80, 0xc0);
case REGISTER:
return QColor(0x80, 0x80, 0xff);
case COMMENT:
return QColor(0x00, 0x7f, 0x00);
case DIRECTIVE:
return QColor(0x00, 0x80, 0xff);
case NUMBER:
return QColor(0x00, 0x7f, 0x7f);
case DIRECTIVEOPERAND:
return QColor(0x00, 0x00, 0x80);
case IDENTIFIER:
return QColor(0x80, 0x00, 0xff);
case COMMENTBLOCK:
return QColor(0x00, 0x80, 0x00);
case STRINGEOL:
return QColor(0x7f, 0x00, 0x7f);
case CHARACTER:
return QColor(0x80, 0x80, 0x00);
case CPUINSTRUCTION: //key word:
return QColor(0x00, 0x00, 0xff);
case EXTINSTRUCTION:
return QColor(0x80, 0x40, 0x00);
}
return QsciLexer::defaultColor(style);

View File

@ -136,8 +136,8 @@ QFont QsciLexerGlobal::defaultFont(int style) const
case INACTIVE_TABS:*/
case URL_HOVERRED:
//这些都是不能设置字体的,统一设置为空
f.setFamily("");
f.setPointSize(-1);
/* f.setFamily("");
f.setPointSize(-1);*/
break;
case GLOBAL_OVERRIDE:

237
src/qscint/src/qscilexerr.cpp Executable file
View File

@ -0,0 +1,237 @@
#include "Qsci/qsciLexerr.h"
#include <qcolor.h>
#include <qfont.h>
#include <qsettings.h>
// The ctor.
QsciLexerR::QsciLexerR(QObject* parent)
: QsciLexer(parent)
{
m_commentSymbol = "#";
m_commentStart = "\"";
m_commentEnd = "\"";
}
// The dtor.
QsciLexerR::~QsciLexerR()
{
}
// Returns the language name.
const char* QsciLexerR::language() const
{
return "R";
}
// Returns the lexer name.
const char* QsciLexerR::lexer() const
{
return "r";
}
// Return the string of characters that comprise a word.
const char* QsciLexerR::wordCharacters() const
{
return "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$@%&";
}
// Returns the foreground colour of the text for a style.
QColor QsciLexerR::defaultColor(int style) const
{
switch (style)
{
case DEFAULT:
return QColor(0x80, 0x80, 0x80);
case KWORD:
case BASEKWORD:
case OTHERKWORD:
return QColor(0x00, 0x00, 0xff);
case COMMENT:
return QColor(0x00, 0x7f, 0x00);
case NUMBER:
return QColor(0x00, 0x7f, 0x7f);
case IDENTIFIER:
return QColor(0x80, 0x00, 0xff);
case STRING:
case STRING2:
return QColor(0x7f, 0x00, 0x7f);
}
return QsciLexer::defaultColor(style);
}
// Returns the end-of-line fill for a style.
bool QsciLexerR::defaultEolFill(int style) const
{
return QsciLexer::defaultEolFill(style);
}
// Returns the font of the text for a style.
QFont QsciLexerR::defaultFont(int style) const
{
QFont f;
switch (style)
{
case COMMENT:
#if defined(Q_OS_WIN)
f = QFont("Courier New", 11);
#elif defined(Q_OS_MAC)
f = QFont("Comic Sans MS", 12);
#else
f = QFont("Bitstream Vera Serif", 9);
#endif
break;
case KWORD:
case BASEKWORD:
case OTHERKWORD:
f = QsciLexer::defaultFont(style);
f.setBold(true);
break;
case STRING:
case STRING2:
#if defined(Q_OS_WIN)
f = QFont("Courier New", QsciLexer::s_defaultFontSize);
#elif defined(Q_OS_MAC)
f = QFont("Courier", 12);
#else
f = QFont("Bitstream Vera Sans Mono", 9);
#endif
break;
default:
f = QsciLexer::defaultFont(style);
}
return f;
}
// Returns the set of keywords.
const char* QsciLexerR::keywords(int set)
{
if (set == 1)
{
return "if else repeat while function for in next break TRUE FALSE NULL NA Inf NaN";
}
else if (set == 2)
{
return "abbreviate abline abs acf acos acosh addmargins aggregate agrep alarm alias alist all anova any aov "
"aperm append apply approx approxfun apropos ar args arima array arrows asin asinh assign assocplot atan "
"atanh attach attr attributes autoload autoloader ave axis backsolve barplot basename beta bindtextdomain "
"binomial biplot bitmap bmp body box boxplot bquote break browser builtins bxp by bzfile c call cancor "
"capabilities casefold cat category cbind ccf ceiling character charmatch chartr chol choose chull citation "
"class close cm cmdscale codes coef coefficients col colnames colors colorspaces colours comment complex confint "
"conflicts contour contrasts contributors convolve cophenetic coplot cor cos cosh cov covratio cpgram crossprod "
"cummax cummin cumprod cumsum curve cut cutree cycle data dataentry date dbeta dbinom dcauchy dchisq de debug "
"debugger decompose delay deltat demo dendrapply density deparse deriv det detach determinant deviance dexp df "
"dfbeta dfbetas dffits dgamma dgeom dget dhyper diag diff diffinv difftime digamma dim dimnames dir dirname dist "
"dlnorm dlogis dmultinom dnbinom dnorm dotchart double dpois dput drop dsignrank dt dump dunif duplicated dweibull "
"dwilcox eapply ecdf edit effects eigen emacs embed end environment eval evalq example exists exp expression factanal "
"factor factorial family fft fifo file filter find fitted fivenum fix floor flush for force formals format formula "
"forwardsolve fourfoldplot frame frequency ftable function gamma gaussian gc gcinfo gctorture get getenv geterrmessage "
"gettext gettextf getwd gl glm globalenv gray grep grey grid gsub gzcon gzfile hat hatvalues hcl hclust head heatmap "
"help hist history hsv httpclient iconv iconvlist identical identify if ifelse image influence inherits integer "
"integrate interaction interactive intersect invisible isoreg jitter jpeg julian kappa kernapply kernel kmeans knots "
"kronecker ksmooth labels lag lapply layout lbeta lchoose lcm legend length letters levels lfactorial lgamma library "
"licence license line lines list lm load loadhistory loadings local locator loess log logb logical loglin lowess "
"ls lsfit machine mad mahalanobis makepredictcall manova mapply match matlines matplot matpoints matrix max mean median "
"medpolish menu merge message methods mget min missing mode monthplot months mosaicplot mtext mvfft names napredict "
"naprint naresid nargs nchar ncol next nextn ngettext nlevels nlm nls noquote nrow numeric objects offset open optim "
"optimise optimize options order ordered outer pacf page pairlist pairs palette par parse paste pbeta pbinom pbirthday "
"pcauchy pchisq pdf pentagamma person persp pexp pf pgamma pgeom phyper pi pico pictex pie piechart pipe plclust plnorm "
"plogis plot pmatch pmax pmin pnbinom png pnorm points poisson poly polygon polym polyroot postscript power ppoints "
"ppois ppr prcomp predict preplot pretty princomp print prmatrix prod profile profiler proj promax prompt provide psigamma "
"psignrank pt ptukey punif pweibull pwilcox q qbeta qbinom qbirthday qcauchy qchisq qexp qf qgamma qgeom qhyper qlnorm qlogis qnbinom "
"qnorm qpois qqline qqnorm qqplot qr qsignrank qt qtukey quantile quarters quasi quasibinomial quasipoisson quit qunif quote qweibull "
"qwilcox rainbow range rank raw rbeta rbind rbinom rcauchy rchisq readline real recover rect reformulate regexpr relevel remove reorder rep "
"repeat replace replicate replications require reshape resid residuals restart return rev rexp rf rgamma rgb rgeom rhyper rle rlnorm rlogis rm "
"rmultinom rnbinom rnorm round row rownames rowsum rpois rsignrank rstandard rstudent rt rug runif runmed rweibull rwilcox sample sapply save savehistory scale scan "
"screen screeplot sd search searchpaths seek segments seq sequence serialize setdiff setequal setwd shell sign signif sin single sinh sink smooth solve sort "
"source spectrum spline splinefun split sprintf sqrt stack stars start stderr stdin stdout stem step stepfun stl stop stopifnot str strftime strheight stripchart strptime "
"strsplit strtrim structure strwidth strwrap sub subset substitute substr substring sum summary sunflowerplot supsmu svd sweep switch symbols symnum system t table tabulate "
"tail tan tanh tapply tempdir tempfile termplot terms tetragamma text time title toeplitz tolower topenv toupper trace traceback transform trigamma trunc truncate try ts tsdiag "
"tsp typeof unclass undebug union unique uniroot unix unlink unlist unname unserialize unsplit unstack untrace unz update upgrade url var varimax vcov vector version vi vignette "
"warning warnings weekdays weights which while "
"window windows with write wsbrowser xedit xemacs xfig xinch xor xtabs xyinch yinch zapsmall";
}
else if (set == 3)
{
return "acme aids aircondit amis aml banking barchart barley beaver bigcity boot brambles breslow bs bwplot calcium cane "
"capability cav censboot channing city claridge cloth cloud coal condense contourplot control corr darwin densityplot "
"dogs dotplot ducks empinf envelope environmental ethanol fir frets gpar grav gravity grob hirose histogram islay knn "
"larrows levelplot llines logit lpoints lsegments lset ltext lvqinit lvqtest manaus melanoma motor multiedit neuro "
"nitrofen nodal ns nuclear oneway parallel paulsen poisons polar qq qqmath remission rfs saddle salinity shingle "
"simplex singer somgrid splom stripplot survival tau tmd tsboot tuna unit urine viewport wireframe wool xyplot";
}
}
// Returns the user name of a style.
QString QsciLexerR::description(int style) const
{
switch (style)
{
case DEFAULT:
return tr("Default");
case COMMENT:
return tr("Comment");
case KWORD:
return tr("Kword");
case BASEKWORD:
return tr("Basekword");
case OTHERKWORD:
return tr("OtherKeyWord");
case NUMBER:
return tr("Number");
case STRING: //key word
return tr("String");
case STRING2:
return tr("String2");
case OPERATOR:
return tr("Operator");
case IDENTIFIER:
return tr("Identifier");
case INFIX:
return tr("Infix");
case INFIXEOL:
return tr("Infix Eol");
}
return QString();
}
// Returns the background colour of the text for a style.
QColor QsciLexerR::defaultPaper(int style) const
{
return QsciLexer::defaultPaper(style);
}

View File

@ -138,6 +138,7 @@ HEADERS = \
./Qsci/qscilexerpov.h \
./Qsci/qscilexerproperties.h \
./Qsci/qscilexerpython.h \
./Qsci/qscilexerr.h \
./Qsci/qscilexerruby.h \
./Qsci/qscilexerspice.h \
./Qsci/qscilexersql.h \
@ -268,6 +269,7 @@ SOURCES = \
qscilexerpov.cpp \
qscilexerproperties.cpp \
qscilexerpython.cpp \
qscilexerr.cpp \
qscilexerruby.cpp \
qscilexerspice.cpp \
qscilexersql.cpp \

View File

@ -17,50 +17,6 @@
#include <QDebug>
#include <QDir>
#if 0
//要注意与common.h的保持一致。
enum LangType {
L_TEXT = -1, L_PHP, L_C, L_CPP, L_CS, L_OBJC, L_JAVA, L_RC, \
L_HTML, L_XML, L_MAKEFILE, L_PASCAL, L_BATCH, L_INI, L_ASCII, L_USER, \
L_ASP, L_SQL, L_VB, L_JS, L_CSS, L_PERL, L_PYTHON, L_LUA, \
L_TEX, L_FORTRAN, L_BASH, L_FLASH, L_NSIS, L_TCL, L_LISP, L_SCHEME, \
L_ASM, L_DIFF, L_PROPS, L_PS, L_RUBY, L_SMALLTALK, L_VHDL, L_KIX, L_AU3, \
L_CAML, L_ADA, L_VERILOG, L_MATLAB, L_HASKELL, L_INNO, L_SEARCHRESULT, \
L_CMAKE, L_YAML, L_COBOL, L_GUI4CLI, L_D, L_POWERSHELL, L_R, L_JSP, \
L_COFFEESCRIPT, L_JSON, L_JAVASCRIPT, L_FORTRAN_77, L_BAANC, L_SREC, \
L_IHEX, L_TEHEX, L_SWIFT, \
L_ASN1, L_AVS, L_BLITZBASIC, L_PUREBASIC, L_FREEBASIC, \
L_CSOUND, L_ERLANG, L_ESCRIPT, L_FORTH, L_LATEX, \
L_MMIXAL, L_NIM, L_NNCRONTAB, L_OSCRIPT, L_REBOL, \
L_REGISTRY, L_RUST, L_SPICE, L_TXT2TAGS, L_VISUALPROLOG, L_TYPESCRIPT, \
L_EDIFACT, L_MARKDOWN, L_OCTAVE, L_PO, L_POV, L_IDL, L_GO, L_TXT, \
// Don't use L_JS, use L_JAVASCRIPT instead
// The end of enumated language type, so it should be always at the end
L_EXTERNAL = 100, L_USER_DEFINE = 200
};
#endif
//static const QColor blackColor(Qt::black);
//static const QColor lightColor(0xdedede);
//
//static const QColor blackColor1(0x0000ff);
//static const QColor lightColor1(0xffaa00);
//
////C++注释的默认颜色,不显眼
//static const QColor blackColor2(0x007f00);
//static const QColor lightColor2(0xaaff7f);
//
//static const QColor blackColor3(0x7f7f00);
//static const QColor lightColor3(0xfca287);
//
//static const QColor blackColor4(0x8000ff);
//static const QColor lightColor4(0xffaa00);
//
//static const QColor blackColor5(0x007f7f);
//static const QColor lightColor5(0xaaff7f);
//
//static const QColor blackColor6(0x7f007f);
//static const QColor lightColor6(0x00ffff);
QtLangSet::QtLangSet(QString initTag, QWidget *parent)
: QMainWindow(parent), m_selectLexer(nullptr), m_selectStyleId(0), m_isStyleChange(false),m_isStyleChildChange(false), m_initShowLexerTag(initTag), m_previousSysLangItem(nullptr),m_isGlobelItem(false)
@ -70,7 +26,6 @@ QtLangSet::QtLangSet(QString initTag, QWidget *parent)
initUserDefineLangList();
startSignSlot();
//initDarkColorMap();
m_themesId = StyleSet::getCurrentSytleId();
m_lastThemesId = -1;
@ -191,7 +146,7 @@ void QtLangSet::slot_fontBoldChange(int state)
{
//全局非第一个样式,修改当前全局字体大小
//全局样式的非第一个
setGlobalFont(m_selectStyleId, m_curStyleData.font);
StyleSet::setGlobalFont(m_selectStyleId, m_curStyleData.font);
//保存全局样式第一条样式本身
saveLangeSet(m_selectLexer);
@ -238,7 +193,7 @@ void QtLangSet::slot_fontItalicChange(int state)
{
//全局非第一个样式,修改当前全局字体大小
//全局样式的非第一个
setGlobalFont(m_selectStyleId, m_curStyleData.font);
StyleSet::setGlobalFont(m_selectStyleId, m_curStyleData.font);
saveLangeSet(m_selectLexer);
//这里就是全局的样式。通知当前所有的编辑框,去修改他们本身的全局样式
@ -283,7 +238,7 @@ void QtLangSet::slot_fontUnderlineChange(int state)
{
//全局非第一个样式,修改当前全局字体大小
//全局样式的非第一个
setGlobalFont(m_selectStyleId, m_curStyleData.font);
StyleSet::setGlobalFont(m_selectStyleId, m_curStyleData.font);
saveLangeSet(m_selectLexer);
//这里就是全局的样式。通知当前所有的编辑框,去修改他们本身的全局样式
@ -308,7 +263,6 @@ void QtLangSet::slot_fontSizeChange(int v)
//即时设置风格
if (m_selectLexer != nullptr)
{
//全局修改,把所有语言的所有风格都设置
//全局修改,把所有语言的所有风格都设置
if (m_isGlobelItem)
{
@ -334,7 +288,7 @@ void QtLangSet::slot_fontSizeChange(int v)
{
//全局非第一个样式,修改当前全局字体大小
//全局样式的非第一个
setGlobalFont(m_selectStyleId, m_curStyleData.font);
StyleSet::setGlobalFont(m_selectStyleId, m_curStyleData.font);
saveLangeSet(m_selectLexer);
//这里就是全局的样式。通知当前所有的编辑框,去修改他们本身的全局样式
@ -411,13 +365,19 @@ void QtLangSet::updateAllLangeStyleWithGlobal(GLOBAL_STYLE_SET flag)
{
QFont oldfont;
bool isGlobalChange = false;
for (int index = 0; index <= L_TXT; ++index)
{
//GLOBAL本身不保存因为GLOBAL不是语法样式而是全局的属性风格
//如果全局修改的是全局字体或字体大小,全局也修改一下。避免括弧等大小和全局字体不一样大。
if (index == L_GLOBAL)
{
if (flag != GLOBAL_FONT_SIZE && flag != GLOBAL_FONT)
{
continue;
}
}
QsciLexer *pLexer = ScintillaEditView::createLexer(index);
if (nullptr != pLexer)
@ -427,6 +387,9 @@ void QtLangSet::updateAllLangeStyleWithGlobal(GLOBAL_STYLE_SET flag)
{
case GLOBAL_FONT:
{
//非全局修改所有的语法对应样式
if (index != L_GLOBAL)
{
for (int i = 0; i <= 255; ++i)
{
if (!pLexer->description(i).isEmpty())
@ -436,10 +399,30 @@ void QtLangSet::updateAllLangeStyleWithGlobal(GLOBAL_STYLE_SET flag)
pLexer->setFont(oldfont, i);
}
}
}
else
{
//是全局属性修改字体
QsciLexerGlobal* pGlobalLexer = dynamic_cast<QsciLexerGlobal*>(pLexer);
if (pGlobalLexer != nullptr)
{
for (int i = 0; i <= GLOBAL_STYLES::URL_HOVERRED; ++i)
{
oldfont = pLexer->font(i);
oldfont.setFamily(m_curStyleData.font.family());
pLexer->setFont(oldfont, i);
}
isGlobalChange = true;
}
}
}
break;
case GLOBAL_FONT_SIZE:
{
//非全局修改所有的语法对应样式
if (index != L_GLOBAL)
{
for (int i = 0; i <= 255; ++i)
{
if (!pLexer->description(i).isEmpty())
@ -449,6 +432,23 @@ void QtLangSet::updateAllLangeStyleWithGlobal(GLOBAL_STYLE_SET flag)
pLexer->setFont(oldfont, i);
}
}
}
else
{
//是全局
QsciLexerGlobal* pGlobalLexer = dynamic_cast<QsciLexerGlobal*>(pLexer);
if (pGlobalLexer != nullptr)
{
for (int i = 0; i <= GLOBAL_STYLES::URL_HOVERRED; ++i)
{
oldfont = pLexer->font(i);
oldfont.setPointSize(m_curStyleData.font.pointSize());
pLexer->setFont(oldfont, i);
}
isGlobalChange = true;
}
}
}
break;
case GLOBAL_FONT_BOLD:
@ -510,6 +510,27 @@ void QtLangSet::updateAllLangeStyleWithGlobal(GLOBAL_STYLE_SET flag)
}
delete pLexer;
}
//如果全局变化了,把当前全局界面刷新一下
//还有,还需要把当前打开文档的全局风格设置一下,否则全局不生效
if (isGlobalChange)
{
m_previousSysLangItem = nullptr;
slot_langListCurRowChanged(0);
StyleSet::reloadGolbalStyleFromSetFile();
//这里就是全局的样式。通知当前所有的编辑框,去修改他们本身的全局样式
CCNotePad* pMainNote = dynamic_cast<CCNotePad*>(parent());
if (pMainNote != nullptr)
{
for (int i = 0; i <= GLOBAL_STYLES::URL_HOVERRED; ++i)
{
pMainNote->setGlobalFont(i);
}
}
}
}
//恢复所有语言的初始配置。与restoreOriginLangOneStyle类似但是粒度更大
@ -522,7 +543,6 @@ void QtLangSet::restoreOriginLangAllStyle()
for (int index = 0; index <= L_TXT; ++index)
{
pLexer = ScintillaEditView::createLexer(index);
if (pLexer == nullptr)
@ -541,8 +561,14 @@ void QtLangSet::restoreOriginLangAllStyle()
delete pLexer;
pLexer = nullptr;
//如果是全局的,把当前内存中的全局风格也更新一下
if (index == L_GLOBAL)
{
StyleSet::loadGolbalStyle();
}
}
}
//只在restoreOriginLangOneStyle中调用
static void restoreLangFontFgColorToDarkStyle(QsciLexer *pLexer, int i)
@ -630,22 +656,12 @@ void QtLangSet::restoreOriginLangOneStyle(GLOBAL_STYLE_SET flag)
oldClor = pOriginLexer->color(i);
pLexer->setColor(oldClor, i);
/*if (BLACK_SE == StyleSet::getCurrentSytleId())
{
restoreLangFontFgColorToDarkStyle(pLexer, i);
}*/
}
break;
case GLOBAL_BK_COLOR:
{
oldClor = pOriginLexer->paper(i);
pLexer->setPaper(oldClor, i);
/*if (BLACK_SE == StyleSet::getCurrentSytleId())
{
restoreLangPaperColorToDarkStyle(pLexer, i);
}*/
}
break;
default:
@ -659,6 +675,7 @@ void QtLangSet::restoreOriginLangOneStyle(GLOBAL_STYLE_SET flag)
delete pOriginLexer;
}
}
//预览全局修改字体效果。把当前所有的语法,风格字体都修改一遍
void QtLangSet::previewAllGoblalChange()
{
@ -670,6 +687,19 @@ void QtLangSet::previewAllGoblalChange()
{
emit viewLexerChange(tags.at(i));
}
//这里还差一步
//这里还有问题,还需要把当前打开文档的全局风格设置一下,否则全局不生效
//这里就是全局的样式。通知当前所有的编辑框,去修改他们本身的全局样式
CCNotePad* pMainNote = dynamic_cast<CCNotePad*>(parent());
if (pMainNote != nullptr)
{
for (int i = 0; i <= GLOBAL_STYLES::URL_HOVERRED; ++i)
{
pMainNote->setGlobalFont(i);
}
}
}
void QtLangSet::slot_fontChange(const QFont &font)
@ -700,7 +730,7 @@ void QtLangSet::slot_fontChange(const QFont &font)
else if(!ui.useGlobalFont->isVisible())
{
//全局样式的非第一个
setGlobalFont(m_selectStyleId, m_curStyleData.font);
StyleSet::setGlobalFont(m_selectStyleId, m_curStyleData.font);
//保存全局样式第一条样式本身
saveLangeSet(m_selectLexer);
@ -1241,17 +1271,18 @@ bool QtLangSet::readLangSettings(QsciLexer *lexer, QString tag, int StyleId)
}
else//这里应该加个逻辑完备的保护。如果没有读取到用户配置,则应该从标准目标去读原始配置
{
return readLangOriginSettings(lexer, tag, StyleId);
return readLangOriginSettings(lexer, tag, StyleId, true);
}
return false;
}
//读取特定语言的原始样式设置StyleId-1则读取当前主题否则指定的StyleId主题
bool QtLangSet::readLangOriginSettings(QsciLexer* lexer, QString tag, int StyleId)
//force:无条件读取
bool QtLangSet::readLangOriginSettings(QsciLexer* lexer, QString tag, int StyleId, bool force)
{
//默认主题不需要读取,内存中已经存在
if (StyleId == 0)
if (StyleId == 0 && !force)
{
return true;
}
@ -1259,8 +1290,6 @@ bool QtLangSet::readLangOriginSettings(QsciLexer* lexer, QString tag, int StyleI
//默认皮肤路径放在软件的同级目录下面的themes目录
QString cfgPath = QString("%1/themes/%2/%3.ini").arg(QCoreApplication::applicationDirPath()).arg((StyleId == -1)?StyleSet::getCurrentStyle(): StyleSet::getStyleName(StyleId)).arg(tag);
QSettings qs(cfgPath, QSettings::IniFormat);
//QSettings qs(QSettings::IniFormat, QSettings::UserScope, cfgPath);
if (QFile::exists(qs.fileName()))
{
return lexer->readSettings(qs);
@ -1276,7 +1305,7 @@ void QtLangSet::saveLangeSet(QsciLexer *lexer, int StyleId)
{
QString tag = lexer->lexerTag();
QString cfgPath = QString("notepad/userstyle/%1/%2").arg((StyleId == -1) ? StyleSet::getCurrentStyle() : StyleSet::getStyleName(StyleId)).arg(tag);
QString cfgPath = QString("notepad/userstyle/%1/%2").arg(((StyleId == -1) ? StyleSet::getCurrentStyle() : StyleSet::getStyleName(StyleId))).arg(tag);
QSettings qs(QSettings::IniFormat, QSettings::UserScope, cfgPath);
lexer->writeSettings(qs);
@ -1338,7 +1367,7 @@ void QtLangSet::slot_changeFgColor()
else if(!ui.useGlobalColor->isVisible())
{
//全局样式的非第一个
setGlobalFgColor(m_selectStyleId, color);
StyleSet::setGlobalFgColor(m_selectStyleId, color);
//这里就是全局的样式。通知当前所有的编辑框,去修改他们本身的全局样式
CCNotePad* pMainNote = dynamic_cast<CCNotePad*>(parent());
@ -1436,7 +1465,7 @@ void QtLangSet::slot_changeBkColor()
}
else if (!ui.useGlobalColor->isVisible())
{
setGlobalBgColor(m_selectStyleId, color);
StyleSet::setGlobalBgColor(m_selectStyleId, color);
//这里就是全局的样式。通知当前所有的编辑框,去修改他们本身的全局样式
CCNotePad* pMainNote = dynamic_cast<CCNotePad*>(parent());
@ -1887,33 +1916,11 @@ void QtLangSet::updateThemes()
}
}
//全局的前景背景和一般的不一样。
void QtLangSet::setGlobalFgColor(int style, QColor color)
//增加一个快捷显示全局的按钮,避免用户经常找不到
void QtLangSet::on_showGlobalItem()
{
One_Stype_Info* pStyle = &StyleSet::s_global_style->global_style;
if (pStyle[style].fgColor != color)
if (ui.langListWidget->currentRow() != 0)
{
pStyle[style].fgColor = color;
}
}
void QtLangSet::setGlobalBgColor(int style, QColor color)
{
One_Stype_Info* pStyle = &StyleSet::s_global_style->global_style;
if (pStyle[style].bgColor != color)
{
pStyle[style].bgColor = color;
}
}
void QtLangSet::setGlobalFont(int style, QFont font)
{
One_Stype_Info* pStyle = &StyleSet::s_global_style->global_style;
if (pStyle[style].font != font)
{
pStyle[style].font = font;
ui.langListWidget->setCurrentRow(0);
}
}

View File

@ -37,7 +37,7 @@ public:
//static bool isExistDarkLangSetings();
void selectInitLangTag(QString initLangTag);
static bool readLangSettings(QsciLexer * lexer, QString tag, int StyleId = -1);
static bool readLangOriginSettings(QsciLexer* lexer, QString tag, int StyleId=-1);
static bool readLangOriginSettings(QsciLexer* lexer, QString tag, int StyleId=-1, bool force=false);
private:
//static void setLangFontFgColorToDarkStyle(LangType langId, QString tag="");
static void createOneLangStyleFromThemes(int styleId, LangType langId, QString tag = "");
@ -84,6 +84,7 @@ private slots:
void slot_useAlobalFontItalic(bool);
void on_themesChange(int index);
void on_showGlobalItem();
private:
@ -109,9 +110,9 @@ private:
bool isUseGlobalFgColor();
bool isUseGlobalBgColor();
void setGlobalFgColor(int style, QColor color);
void setGlobalBgColor(int style, QColor color);
void setGlobalFont(int style, QFont font);
//void setGlobalFgColor(int style, QColor color);
//void setGlobalBgColor(int style, QColor color);
//void setGlobalFont(int style, QFont font);
bool isExistThemesSetings(int styleId);
void createUserStyleFormThemes(int styleId);

View File

@ -37,6 +37,13 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Global Set</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_10">
<property name="text">
@ -737,8 +744,8 @@
<slot>slot_useAlobalFont(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>1009</x>
<y>291</y>
<x>844</x>
<y>238</y>
</hint>
<hint type="destinationlabel">
<x>491</x>
@ -753,8 +760,8 @@
<slot>slot_useAlobalFontBold(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>1009</x>
<y>413</y>
<x>844</x>
<y>238</y>
</hint>
<hint type="destinationlabel">
<x>491</x>
@ -769,8 +776,8 @@
<slot>slot_useAlobalFontItalic(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>1009</x>
<y>474</y>
<x>844</x>
<y>238</y>
</hint>
<hint type="destinationlabel">
<x>491</x>
@ -785,8 +792,8 @@
<slot>slot_useAlobalFontUnderline(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>1009</x>
<y>535</y>
<x>844</x>
<y>238</y>
</hint>
<hint type="destinationlabel">
<x>491</x>
@ -801,8 +808,8 @@
<slot>slot_useAlobalFontSize(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>1009</x>
<y>352</y>
<x>844</x>
<y>238</y>
</hint>
<hint type="destinationlabel">
<x>491</x>
@ -858,6 +865,22 @@
</hint>
</hints>
</connection>
<connection>
<sender>pushButton</sender>
<signal>clicked()</signal>
<receiver>QtLangSetClass</receiver>
<slot>on_showGlobalItem()</slot>
<hints>
<hint type="sourcelabel">
<x>103</x>
<y>56</y>
</hint>
<hint type="destinationlabel">
<x>197</x>
<y>69</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>slot_saveClick()</slot>
@ -872,5 +895,6 @@
<slot>slot_useAlobalFontItalic(bool)</slot>
<slot>slot_useAlobalBkColor(bool)</slot>
<slot>on_themesChange(int)</slot>
<slot>on_showGlobalItem()</slot>
</slots>
</ui>

View File

@ -8,10 +8,10 @@
//#define TEST_PRE
#ifdef TEST_PRE
static const char* VersionStr = u8"(内部测试非稳定) v1.22.0";
static const char* VersionStr = u8"(内部测试非稳定) v1.22.1";
#else
static const char* VersionStr = "v1.22.0";
static const char* VersionStr = "v1.22.2";
#endif // TEST_PRE

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -44,6 +44,7 @@
#include <Qsci/qscilexerpov.h>
#include <Qsci/qscilexerproperties.h>
#include <Qsci/qscilexerpython.h>
#include <Qsci/qscilexerr.h>
#include <Qsci/qscilexerruby.h>
#include <Qsci/qscilexerspice.h>
#include <Qsci/qscilexersql.h>
@ -64,6 +65,7 @@
#include <QClipboard>
#include <QDesktopServices>
#include <QDebug>
#include <QMessageBox>
#include <stdexcept>
@ -450,6 +452,10 @@ QString ScintillaEditView::getTagByLexerId(int lexerId)
case L_PS:
break;
case L_R:
return "r";
case L_RUBY:
return "ruby";
@ -597,6 +603,9 @@ QsciLexer* ScintillaEditView::createLexer(int lexerId, QString tag, bool isOrigi
case L_PHP:
ret = new QsciLexerHTML();
ret->setLexerTag("php");
ret->setCommentLineSymbol("//");
ret->setCommentStart("/*");
ret->setCommentEnd("*/");
break;
case L_HTML:
ret = new QsciLexerHTML();
@ -704,6 +713,9 @@ QsciLexer* ScintillaEditView::createLexer(int lexerId, QString tag, bool isOrigi
break;
case L_PS:
break;
case L_R:
ret = new QsciLexerR();
break;
case L_RUBY:
ret = new QsciLexerRuby();
break;
@ -955,23 +967,10 @@ void ScintillaEditView::init()
setMarginSensitivity(_SC_MARGE_SYBOLE, true);
connect(this, &QsciScintilla::marginClicked, this, &ScintillaEditView::slot_bookMarkClicked);
//adjuctSkinStyle();
//开始括号匹配比如html的<>,开启前后这类字段的匹配
setBraceMatching(SloppyBraceMatch);
//if (StyleSet::m_curStyleId != BLACK_SE)
//{
// setMatchedBraceForegroundColor(QColor(191, 141, 255));
// setMatchedBraceBackgroundColor(QColor(222, 222, 222));
//}
//else
//{
// setMatchedBraceForegroundColor(QColor(246, 81, 246));
// setMatchedBraceBackgroundColor(QColor(18, 90, 36));
//}
//自动补全效果不好不开启20211017
//setAutoCompletionSource(QsciScintilla::AcsAPIs); //设置源,自动补全所有地方出现的
//setAutoCompletionCaseSensitivity(true); //设置自动补全大小写敏感
@ -1106,8 +1105,6 @@ void ScintillaEditView::showBigTextLineAddr(qint64 fileOffset)
int lineNums = this->lines();
int lineLength = 0;
qint64 curLineAddr = fileOffset;
int style = STYLE_LINENUMBER;
for (int i = 0; i < lineNums; ++i)
@ -1164,8 +1161,6 @@ void ScintillaEditView::showBigTextLineAddr(qint64 fileOffset, qint64 fileEndOff
int lineNums = this->lines();
int lineLength = 0;
qint64 curLineAddr = fileOffset;
int style = STYLE_LINENUMBER;
quint32 startLineNumOffset = 0;
@ -1894,6 +1889,11 @@ void ScintillaEditView::contextUserDefineMenuEvent(QMenu* menu)
menu->addAction(tr("Del Block comment"), [this]() {
undoStreamComment();
});
menu->addSeparator();
menu->addAction(tr("Word Count"), [this]() {
showWordNums();
});
}
menu->show();
@ -2036,7 +2036,9 @@ bool ScintillaEditView::doBlockComment(Comment_Mode currCommentMode)
if (avoidIndent)
lineIndent = lineStart;
size_t linebufferSize = lineEnd - lineIndent + 1;
//这里linebufferSize不需要包含字符串后面的\0所以不需要预留1个\0符号
size_t linebufferSize = lineEnd - lineIndent;
QByteArray linebuf;
linebuf.resize(linebufferSize);
this->getText(linebuf.data(), lineIndent, lineEnd);
@ -2081,7 +2083,7 @@ bool ScintillaEditView::doBlockComment(Comment_Mode currCommentMode)
continue;
}
}
else // isSingleLineAdvancedMode
else
{
if ((qstrncmp(linebufStr.data(), advCommentStart.data(), advCommentStart_length - 1) == 0) &&
(qstrncmp(linebufStr.mid(linebufStr.length() - advCommentEnd_length + 1, advCommentEnd_length - 1).data(), advCommentEnd.mid(1, advCommentEnd_length - 1).data(), advCommentEnd_length - 1) == 0))
@ -2195,6 +2197,24 @@ bool ScintillaEditView::doBlockComment(Comment_Mode currCommentMode)
return true;
}
//显示文字的字数
void ScintillaEditView::showWordNums()
{
if (hasSelectedText())
{
QString word = selectedText();
if (!word.isEmpty())
{
QMessageBox::about(this, tr("Word Nums"), tr("Current Select Word Nums is %1 .").arg(word.size()));
}
}
else
{
QMessageBox::about(this, tr("Word Nums"), tr("Current Doc Word Nums is %1 .").arg(this->text().size()));
}
}
bool ScintillaEditView::undoStreamComment(bool tryBlockComment)
{
QByteArray commentStart;

View File

@ -275,6 +275,8 @@ private:
void slot_markColorGroup(QAction * action);
void replaceSelWith(const char* replaceText);
void showWordNums();
private slots:
void slot_delayWork();
void slot_scrollYValueChange(int value);

View File

@ -39,4 +39,10 @@ void ShortcutKeyEditWin::slot_ok()
m_newKeys = keys;
done(1);
}
}
//删除为空
void ShortcutKeyEditWin::on_delete()
{
done(2);
}

View File

@ -17,6 +17,7 @@ public:
private slots:
void slot_ok();
void on_delete();
private:
Ui::ShortcutKeyEditWinClass ui;

View File

@ -14,18 +14,6 @@
<string>ShortcutKeyEditWin</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
@ -57,19 +45,26 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pushButton">
<widget class="QPushButton" name="okBt">
<property name="text">
<string>Ok</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_2">
<widget class="QPushButton" name="cancelBt">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="deleteBt">
<property name="text">
<string>Delete</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
@ -78,14 +73,14 @@
<resources/>
<connections>
<connection>
<sender>pushButton_2</sender>
<sender>cancelBt</sender>
<signal>clicked()</signal>
<receiver>ShortcutKeyEditWinClass</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>388</x>
<y>103</y>
<x>448</x>
<y>88</y>
</hint>
<hint type="destinationlabel">
<x>414</x>
@ -94,14 +89,14 @@
</hints>
</connection>
<connection>
<sender>pushButton</sender>
<sender>okBt</sender>
<signal>clicked()</signal>
<receiver>ShortcutKeyEditWinClass</receiver>
<slot>slot_ok()</slot>
<hints>
<hint type="sourcelabel">
<x>153</x>
<y>95</y>
<x>163</x>
<y>88</y>
</hint>
<hint type="destinationlabel">
<x>186</x>
@ -109,8 +104,26 @@
</hint>
</hints>
</connection>
<connection>
<sender>deleteBt</sender>
<signal>clicked()</signal>
<receiver>ShortcutKeyEditWinClass</receiver>
<slot>on_delete()</slot>
<hints>
<hint type="sourcelabel">
<x>332</x>
<y>111</y>
</hint>
<hint type="destinationlabel">
<x>311</x>
<y>130</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>slot_ok()</slot>
<slot>on_reset()</slot>
<slot>on_delete()</slot>
</slots>
</ui>

View File

@ -52,6 +52,23 @@ ShortcutKeyMgr::ShortcutKeyMgr(QWidget *parent)
ui.qscintTableWidget->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
ui.qscintTableWidget->horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
ui.qscintTableWidget->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
QString tabQss = "QHeaderView::section{"
"border-top:0px solid #E5E5E5;"
"border-left:0px solid #E5E5E5;"
"border-right:0.5px solid #E5E5E5;"
"border-bottom: 0.5px solid #E5E5E5;"
"background-color:white;"
"padding:4px;"
"}";
ui.tableWidget->horizontalHeader()->setStyleSheet(tabQss);
ui.tableWidget->verticalHeader()->setStyleSheet(tabQss);
ui.qscintTableWidget->horizontalHeader()->setStyleSheet(tabQss);
ui.qscintTableWidget->verticalHeader()->setStyleSheet(tabQss);
}
ShortcutKeyMgr::~ShortcutKeyMgr()
@ -270,7 +287,9 @@ void ShortcutKeyMgr::slot_edit(QTableWidgetItem* item)
ShortcutKeyEditWin* pWin = new ShortcutKeyEditWin(this);
pWin->setTitle(shortCutTable.at(row).name);
pWin->setCurKeyDesc(shortCutTable.at(row).key.toString());
if (1 == pWin->exec())
int ret = pWin->exec();
if (1 == ret) //È·¶¨
{
QKeySequence newKeySeq = pWin->getNewKeySeq();
@ -310,8 +329,31 @@ void ShortcutKeyMgr::slot_edit(QTableWidgetItem* item)
}
}
}
else if (2 == ret)//ɾ³ý
{
QKeySequence newKeySeq(QKeySequence::UnknownKey);
QTableWidgetItem* item = ui.tableWidget->item(row, 1);
if (item != nullptr)
{
if (ModifyShortCutKey(shortCutTable.at(row).iniTag, newKeySeq.toString()))
{
CCNotePad* pNotePad = dynamic_cast<CCNotePad*>(m_pNoteEdit);
if (pNotePad != nullptr)
{
pNotePad->setUserDefShortcutKey(row);
}
item->setText(newKeySeq.toString());
ui.plainTextEdit->setPlainText(tr("modify row %1 to '%2' shortcut key success!").arg(row + 1).arg("NULL"));
}
else
{
ui.plainTextEdit->setPlainText(tr("error:modify row %1 to '%2' shortcut key failed !").arg(row + 1).arg("NULL"));
}
}
}
else
{
ui.plainTextEdit->setPlainText(tr("modify canceled !"));
}
}
}

View File

@ -57,6 +57,9 @@
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<attribute name="verticalHeaderShowSortIndicator" stdset="0">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string>Function</string>

View File

@ -128,6 +128,12 @@ void StyleSet::setSkin(int id)
}
}
//ÖØмÓÔØGlobalÈ«¾Ö·ç¸ñ
void StyleSet::reloadGolbalStyleFromSetFile()
{
loadGolbalStyle();
}
void StyleSet::loadGolbalStyle()
{
QsciLexer* pLexer = ScintillaEditView::createLexer(L_GLOBAL);
@ -355,4 +361,34 @@ void StyleSet::setCommonStyle()
qApp->setStyleSheet(styleSheet);
}
file.close();
}
}
void StyleSet::setGlobalFgColor(int style, QColor color)
{
One_Stype_Info* pStyle = &StyleSet::s_global_style->global_style;
if (pStyle[style].fgColor != color)
{
pStyle[style].fgColor = color;
}
}
void StyleSet::setGlobalBgColor(int style, QColor color)
{
One_Stype_Info* pStyle = &StyleSet::s_global_style->global_style;
if (pStyle[style].bgColor != color)
{
pStyle[style].bgColor = color;
}
}
void StyleSet::setGlobalFont(int style, QFont font)
{
One_Stype_Info* pStyle = &StyleSet::s_global_style->global_style;
if (pStyle[style].font != font)
{
pStyle[style].font = font;
}
}

View File

@ -83,6 +83,7 @@ public:
static void setCommonStyle(QColor foldfgColor_, QColor foldbgColor_, QColor marginsBackgroundColor_, QString colorName);
static void init();
static void loadGolbalStyle();
static void reloadGolbalStyleFromSetFile();
static void setSkin(int id);
static void setCurrentStyle(int themes);
static QString getCurrentStyle();
@ -110,5 +111,9 @@ public:
static void setBlackStyle();
static void setCommonStyle();
static void setGlobalFgColor(int style, QColor color);
static void setGlobalBgColor(int style, QColor color);
static void setGlobalFont(int style, QFont font);
static GLOBAL_STYLE_OPS* s_global_style;
};

View File

@ -24,6 +24,11 @@ TextEditSetWin::TextEditSetWin(QWidget *parent)
QPalette pal = QApplication::palette();
QPixmap f(32, 32);
f.fill(pal.text().color());
ui.appFontColorLabel->setPixmap(f);
//ui.appFontColorLabel
}
TextEditSetWin::~TextEditSetWin()
@ -101,39 +106,63 @@ void TextEditSetWin::slot_txtFontSet()
pWin->show();
pWin->selectInitLangTag("txt");
}
#if 0
void TextEditSetWin::slot_selectFont()
//app字体颜色设置
void TextEditSetWin::slot_appFontColor()
{
QPalette pal = qApp->palette();
QColor oldColor = pal.text().color();
QColor color = QColorDialog::getColor(pal.text().color(), this, tr("App Font Foreground Color"));
if (color.isValid() && color != oldColor)
{
pal.setColor(QPalette::WindowText, color);//设置颜色
pal.setColor(QPalette::Text, color);//设置颜色
pal.setColor(QPalette::ButtonText, color);//设置颜色
pal.setColor(QPalette::ToolTipText, color);
qApp->setPalette(pal);
QPixmap f(32, 32);
f.fill(pal.text().color());
ui.appFontColorLabel->setPixmap(f);
//发现如果修改APP字体颜色后必须要把存在的窗口关闭一下否则存在的窗口的字体颜色无法生效。
CCNotePad* pMainWin = dynamic_cast<CCNotePad*>(m_notepadWin);
if (pMainWin != nullptr)
{
//是从主界面调用的,执行一下颜色的更新
pMainWin->changeAppFontColor(color);
return;
}
}
}
#endif
#if 0
//不能整体修改QApplication::font(),会引发语法里面的文字重叠破坏。
//只针对菜单和状态栏,查找框字体进行修改。
void TextEditSetWin::slot_selectAppFont()
{
QFont ft;
#if defined(Q_OS_WIN)
ft.fromString(u8"宋体,14,-1,5,50,0,0,0,0,0,常规");
#elif defined(Q_OS_MAC)
ft.fromString(u8"STSong,14,-1,5,50,0,0,0,0,0,Regular");
#else
ft.fromString(u8"CESI宋体-GB2312,12,-1,5,50,0,0,0,0,0,Regular");
#endif
QFont curAppFont = QApplication::font();
bool ok = false;//定义bool型输出变量
ft = QFontDialog::getFont(&ok, m_curFont, this,tr("User define Txt Font"));
ft = QFontDialog::getFont(&ok, curAppFont, this,tr("The App Font"));
if (ok)
{
ui.curTextFontEdit->setText(ft.toString());
ui.appFontEdit->setText(ft.toString());
if (m_curFont != ft)
if (curAppFont != ft)
{
m_curFont = ft;
emit signTxtFontChange(ft);
//emit signAppFontChange(ft);
QApplication::setFont(ft,"FindResultWin");
}
}
else
{
ui.curTextFontEdit->setText(ft.toString());
m_curFont = ft;
}
}
#endif
#if 0
void TextEditSetWin::slot_selectProLangFont()
{

View File

@ -11,13 +11,13 @@ public:
TextEditSetWin(QWidget *parent = Q_NULLPTR);
~TextEditSetWin();
void setNotePadWin(QWidget * w);
//void setFont(QFont & font);
#if 0
void setProgramLangFont(QFont & font);
#endif
signals:
void sendTabFormatChange(bool, bool);
//void signTxtFontChange(QFont& font);
//void signAppFontChange(QFont& font);
void signProLangFontChange(QFont& font);
private:
@ -27,16 +27,19 @@ private:
private slots:
#if 0
void slot_selectFont();
void slot_selectAppFont();
void slot_selectProLangFont();
void slot_appFontColor();
#endif
void slot_txtFontSet();
private:
Ui::TextEditSetWin ui;
QWidget* m_notepadWin;
//QFont m_curFont;//text的font
//QFont m_curProLangFont; //编程语言的font
};