diff --git a/src/RealCompare.rc b/src/RealCompare.rc index 55fa7fd..e5433f3 100755 Binary files a/src/RealCompare.rc and b/src/RealCompare.rc differ diff --git a/src/aboutndd.ui b/src/aboutndd.ui index 2eb3aa3..fa1fb6e 100755 --- a/src/aboutndd.ui +++ b/src/aboutndd.ui @@ -51,11 +51,7 @@ true - 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/. + 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. diff --git a/src/bigfilemessage.ui b/src/bigfilemessage.ui index c3514c6..455ac41 100755 --- a/src/bigfilemessage.ui +++ b/src/bigfilemessage.ui @@ -6,8 +6,8 @@ 0 0 - 770 - 195 + 661 + 211 @@ -39,27 +39,6 @@ Open Mode - - - - Big Text File(< 8G) Read only open, load in blocks, and turn pages manually. - - - - - - - Hex Bin - - - - - - - Super Big Text Edit - - - @@ -67,20 +46,6 @@ - - - - Text Mode - - - - - - - Open directly in text mode.May be slow, Need wait. - - - @@ -91,6 +56,34 @@ + + + + Open directly in text mode.May be slow, Need wait. + + + + + + + Text Mode + + + + + + + Hex Bin + + + + + + + Big Text File(< 8G) Read only open, load in blocks, and turn pages manually. + + + @@ -98,6 +91,13 @@ + + + + Super Big Text + + + diff --git a/src/cceditor/ccnotepad.cpp b/src/cceditor/ccnotepad.cpp index cd7cbc5..0f11c56 100755 --- a/src/cceditor/ccnotepad.cpp +++ b/src/cceditor/ccnotepad.cpp @@ -78,6 +78,7 @@ extern bool s_isAdminAuth; inline std::wstring StringToWString(const std::string& str) { +#if 0 int len = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, NULL, 0); wchar_t* wide = new wchar_t[len + 1]; memset(wide, '\0', sizeof(wchar_t) * (len + 1)); @@ -85,6 +86,10 @@ inline std::wstring StringToWString(const std::string& str) std::wstring w_str(wide); delete[] wide; return w_str; +#endif + + QString temp = QString::fromStdString(str); + return temp.toStdWString(); } #endif @@ -792,6 +797,12 @@ void CCNotePad::initLexerNameToIndex() m_lexerNameToIndex.insert("python", pNodes[i]); ++i; + pNodes[i].pAct = ui.actionR_2; + pNodes[i].index = L_R; + data.setValue(int(L_R)); + ui.actionR_2->setData(data); + m_lexerNameToIndex.insert("r", pNodes[i]); + ++i; pNodes[i].pAct = ui.actionRuby; pNodes[i].index = L_RUBY; @@ -1022,6 +1033,30 @@ QString getGlboalTempSaveDir() return fi.dir().absolutePath(); } +void setEditShowBlankStatus(ScintillaEditView* pEdit, int blankSet) +{ + if (blankSet == 1) + { + pEdit->setWhitespaceVisibility(QsciScintilla::WsVisible); + pEdit->setEolVisibility(false); + } + else if(blankSet == 2) + { + pEdit->setWhitespaceVisibility(QsciScintilla::WsInvisible); + pEdit->setEolVisibility(true); + } + else if (blankSet == 3) + { + pEdit->setWhitespaceVisibility(QsciScintilla::WsVisible); + pEdit->setEolVisibility(true); + } + else if (blankSet == 0) + { + pEdit->setWhitespaceVisibility(QsciScintilla::WsInvisible); + pEdit->setEolVisibility(false); + } +} + //根据文件类型给出语言id LexerInfo CCNotePad::getLangLexerIdByFileExt(QString filePath) { @@ -1208,12 +1243,15 @@ void CCNotePad::quickshow() m_codeStatusLabel = new QLabel("UTF8", ui.statusBar); + m_lineEndLabel = new QComboBox(ui.statusBar); + m_lineEndLabel->addItems(QStringList() << "Windows(CR LF)" << "Unix(LF)" << "Mac(CR)"); #ifdef Q_OS_WIN - m_lineEndLabel = new QLabel("Windows(CR LF)", ui.statusBar); -#endif -#ifdef Q_OS_UNIX - m_lineEndLabel = new QLabel("Windows(LF)", ui.statusBar); + m_lineEndLabel->setCurrentIndex(0); +#else + m_lineEndLabel->setCurrentIndex(1); #endif + connect(m_lineEndLabel, QOverload::of(&QComboBox::currentIndexChanged), this, &CCNotePad::on_lineEndChange); + m_lineNumLabel = new QLabel(tr("Ln:0 Col:0"), ui.statusBar); m_langDescLabel = new QLabel("Txt", ui.statusBar); @@ -1300,6 +1338,32 @@ void CCNotePad::quickshow() setUserDefShortcutKey(); } +void CCNotePad::on_lineEndChange(int index) +{ + + if (index == 0) + { + if (convertDocLineEnd(DOS_LINE)) + { + ui.actionconver_windows_CR_LF->setChecked(true); + } + } + else if (index == 1) + { + if (convertDocLineEnd(UNIX_LINE)) + { + ui.actionconvert_Unix_LF->setChecked(true); + } + } + else if (index == 2) + { + if (convertDocLineEnd(MAC_LINE)) + { + ui.actionconvert_Mac_CR->setChecked(true); + } + } +} + void CCNotePad::setUserDefShortcutKey(int shortcutId) { QKeySequence keySeq; @@ -1308,40 +1372,30 @@ void CCNotePad::setUserDefShortcutKey(int shortcutId) { case New_File_ID: keySeq = ShortcutKeyMgr::getUserDefShortcutKey(New_File); - if (!keySeq.isEmpty()) - { ui.actionNewFile->setShortcut(keySeq); - } + break; case Open_File_ID: keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Open_File); - if (!keySeq.isEmpty()) - { ui.actionOpenFile->setShortcut(keySeq); - } + break; case Save_File_ID: break; case Save_All_File_ID: keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Save_All_File); - if (!keySeq.isEmpty()) - { ui.actionSave_as->setShortcut(keySeq); - } + break; case Close_ID: keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Close); - if (!keySeq.isEmpty()) - { ui.actionClose->setShortcut(keySeq); - } + break; case Close_All_ID: keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Close_All); - if (!keySeq.isEmpty()) - { ui.actionClose_All->setShortcut(keySeq); - } + break; case Cut_ID: break; @@ -1355,128 +1409,108 @@ void CCNotePad::setUserDefShortcutKey(int shortcutId) break; case Find_ID: keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Find); - if (!keySeq.isEmpty()) - { ui.actionFind->setShortcut(keySeq); - } + break; case Replace_ID: keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Replace); - if (!keySeq.isEmpty()) - { ui.actionReplace->setShortcut(keySeq); - } + break; case Dir_Find_ID: keySeq = ShortcutKeyMgr::getUserDefShortcutKey(DirFind); - if (!keySeq.isEmpty()) - { ui.actionFind_In_Dir->setShortcut(keySeq); - } + break; case Mark_ID: break; case Word_highlight_ID: keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Word_highlight); - if (!keySeq.isEmpty()) - { m_signText->setShortcut(keySeq); - } + break; case Clear_all_highlight_ID: keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Clear_all_highlight); - if (!keySeq.isEmpty()) - { m_clearMark->setShortcut(keySeq); - } + break; case Zoom_In_ID: keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Zoom_In); - if (!keySeq.isEmpty()) - { m_zoomin->setShortcut(keySeq); - } + break; case Zoom_Out_ID: keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Zoom_Out); - if (!keySeq.isEmpty()) - { m_zoomout->setShortcut(keySeq); - } + break; case Word_Wrap_ID: keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Word_Wrap); - if (!keySeq.isEmpty()) - { ui.actionWrap->setShortcut(keySeq); - } + break; case Show_Blank_ID: keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Show_Blank); - if (!keySeq.isEmpty()) - { ui.actionShowAll->setShortcut(keySeq); - } + break; case Indent_Guide_ID: keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Indent_Guide); - if (!keySeq.isEmpty()) - { m_indentGuide->setShortcut(keySeq); - } + break; case Pre_Page_ID: keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Pre_Page); - if (!keySeq.isEmpty()) - { m_preHexPage->setShortcut(keySeq); - } + break; case Next_Page_ID: keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Next_Page); - if (!keySeq.isEmpty()) - { m_nextHexPage->setShortcut(keySeq); - } + break; case Goto_Page_ID: keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Goto_Page); - if (!keySeq.isEmpty()) - { ui.actionGoline->setShortcut(keySeq); - } + break; + case File_Compare_ID: + keySeq = ShortcutKeyMgr::getUserDefShortcutKey(File_Compare); + m_fileCompare->setShortcut(keySeq); + break; + case Dir_Compare_ID: + keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Dir_Compare); + m_dirCompare->setShortcut(keySeq); + + break; + case Bin_Compare_ID: + keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Bin_Compare); + m_binCompare->setShortcut(keySeq); + + break; case Trans_code_ID: keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Trans_code); - if (!keySeq.isEmpty()) - { m_transcode->setShortcut(keySeq); - } + break; case Batch_rename_ID: keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Batch_rename); - if (!keySeq.isEmpty()) - { m_rename->setShortcut(keySeq); - } + break; case Format_Xml_ID: keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Format_Xml); - if (!keySeq.isEmpty()) - { m_formatXml->setShortcut(keySeq); - } + break; case Format_Json_ID: keySeq = ShortcutKeyMgr::getUserDefShortcutKey(Format_Json); - if (!keySeq.isEmpty()) - { m_formatJson->setShortcut(keySeq); - } + break; default: @@ -1996,20 +2030,25 @@ void CCNotePad::slot_fileChange(QString filePath) QWidget *pw = nullptr; + int changeIndex = -1; + for (int i = 0; i < ui.editTabWidget->count(); ++i) { pw = ui.editTabWidget->widget(i); - if (pw != nullptr) + if (pw != nullptr && (pw->property(Edit_View_FilePath) == filePath)) { - if (pw->property(Edit_View_FilePath) == filePath) - { - //这里只设置1个标志,下次获取焦点时,才判定询问是否需要重新加载 - pw->setProperty(Modify_Outside, QVariant(true));; + pw->setProperty(Modify_Outside, QVariant(true)); + + changeIndex = i; break; } } + //如果就是当前文件,则直接弹窗提示 + if (ui.editTabWidget->currentIndex() == changeIndex) + { + checkRoladFile(dynamic_cast(pw)); } } @@ -2251,11 +2290,11 @@ void CCNotePad::autoSetDocLexer(ScintillaEditView* pEdit, int defLexerId) //如果没有特殊语法,而且默认给与语法不是-1,则按照默认语法设置 if (lxdata.lexerId == L_TXT && defLexerId != -1) { - lexer = pEdit->createLexer(defLexerId); + lexer = ScintillaEditView::createLexer(defLexerId); } else { - lexer = pEdit->createLexer(lxdata.lexerId, lxdata.tagName); + lexer = ScintillaEditView::createLexer(lxdata.lexerId, lxdata.tagName); } if (lexer != nullptr) @@ -2344,6 +2383,7 @@ void CCNotePad::slot_tabCurrentChanged(int index) { pEdit->setWrapMode((s_autoWarp == 0 ? QsciScintilla::WrapNone: QsciScintilla::WrapCharacter)); } + pEdit->viewport()->setFocus(); fileListSetCurItem(filePath); } @@ -2623,6 +2663,7 @@ void CCNotePad::initToolBar() connect(m_copyFile, &QAbstractButton::clicked, this, &CCNotePad::slot_copy); m_copyFile->setFixedSize(ICON_SIZE, ICON_SIZE); m_copyFile->setIcon(QIcon(CopyFileIcon)); + m_copyFile->setToolTip(tr("Copy")); ui.mainToolBar->addWidget(m_copyFile); m_pasteFile = new QToolButton(ui.mainToolBar); @@ -2703,39 +2744,26 @@ void CCNotePad::initToolBar() m_wordwrap = new QToolButton(ui.mainToolBar); m_wordwrap->setCheckable(true); m_wordwrap->setChecked((s_autoWarp != QsciScintilla::WrapNone)); - connect(m_wordwrap, &QAbstractButton::toggled, this, &CCNotePad::slot_wordwrap); + connect(m_wordwrap, &QAbstractButton::clicked, this, &CCNotePad::slot_wordwrap); m_wordwrap->setFixedSize(ICON_SIZE, ICON_SIZE); m_wordwrap->setToolTip(tr("Word Wrap")); ui.mainToolBar->addWidget(m_wordwrap); ui.actionWrap->setChecked((s_autoWarp != QsciScintilla::WrapNone)); - connect(ui.actionWrap, &QAction::toggled, m_wordwrap, [&](bool check) { - //避免循环触发 - if (check != m_wordwrap->isChecked()) - { - m_wordwrap->setChecked(check); - } - }); - - m_allWhite = new QToolButton(ui.mainToolBar); m_allWhite->setCheckable(true); - m_allWhite->setChecked((s_showblank == 1)); - connect(m_allWhite, &QAbstractButton::toggled, this, &CCNotePad::slot_allWhite); + m_allWhite->setChecked((s_showblank == 3)); + + //这里使用clicked信号。修改setChecked时,不会触发该信号,避免循环触发。 + //注意统一:凡是需要两个地方控制一个状态,同步的地方。按钮使用clicked信号,action使用triggered。 + //因为这两个信号,不会被setchecked修改,这样其他地方调用setchecked时,避免信号循环冲突 + connect(m_allWhite, &QAbstractButton::clicked, this, &CCNotePad::slot_allWhite); m_allWhite->setFixedSize(ICON_SIZE, ICON_SIZE); m_allWhite->setToolTip(tr("Show Blank")); ui.mainToolBar->addWidget(m_allWhite); - ui.actionShowAll->setChecked((s_showblank == 1)); - - connect(ui.actionShowAll, &QAction::toggled, m_allWhite, [&](bool check) { - //避免循环触发 - if (check != m_allWhite->isChecked()) - { - m_allWhite->setChecked(check); - } - }); + ui.actionShowAll->setChecked((s_showblank == 3)); m_indentGuide = new QToolButton(ui.mainToolBar); m_indentGuide->setCheckable(true); @@ -2839,6 +2867,7 @@ void CCNotePad::initToolBar() m_pLexerActGroup->addAction(ui.actionPov); m_pLexerActGroup->addAction(ui.actionProperties_file); m_pLexerActGroup->addAction(ui.actionPython); + m_pLexerActGroup->addAction(ui.actionR_2); m_pLexerActGroup->addAction(ui.actionRuby); m_pLexerActGroup->addAction(ui.actionRust); m_pLexerActGroup->addAction(ui.actionSpice); @@ -2895,18 +2924,6 @@ void CCNotePad::initToolBar() m_pLexerActGroup->addAction(ui.actionTxt); m_pLexerActGroup->addAction(ui.actionUserDefine); - //QActionGroup* skinStyleGroup = new QActionGroup(this); - //skinStyleGroup->addAction(ui.actionDefaultStyle); - //skinStyleGroup->addAction(ui.actionLightBlueStyle); - //skinStyleGroup->addAction(ui.actionThinBlue); - //skinStyleGroup->addAction(ui.actionYellow); - //skinStyleGroup->addAction(ui.actionRiceYellow); - //skinStyleGroup->addAction(ui.actionSilver); - //skinStyleGroup->addAction(ui.actionLavenderBlush); - //skinStyleGroup->addAction(ui.actionMistyRose); - //skinStyleGroup->addAction(ui.actionDark); - //connect(skinStyleGroup, &QActionGroup::triggered, this, &CCNotePad::slot_skinStyleGroup, Qt::QueuedConnection); - QActionGroup* langsGroup = new QActionGroup(this); langsGroup->addAction(ui.actionChinese); langsGroup->addAction(ui.actionEnglish); @@ -2925,6 +2942,8 @@ void CCNotePad::initToolBar() closeX->setIcon(QIcon(RightCloseIcon)); closeX->setToolTip(tr("Close")); ui.mainToolBar->addWidget(closeX); + + syncBlankShowStatus(); } @@ -3078,7 +3097,7 @@ void CCNotePad::slot_lexerActTrig(QAction *action) } } -//保存最近对比到数据库。文件只有在关闭时,才写入最近列表。不关闭的下次自动恢复打开 +//保存最近打开文件到数据库。文件只有在关闭时,才写入最近列表。不关闭的下次自动恢复打开 void CCNotePad::saveReceneOpenFile() { QString rFile("recentopenfile"); @@ -3127,11 +3146,10 @@ void CCNotePad::initReceneOpenFileMenu() for (QString var : fileList) { - if (!var.isEmpty() && (!m_receneOpenFile.contains(var))) + if (!var.isEmpty() && (-1 == m_receneOpenFileList.indexOf(var))) { - QAction* act = ui.menuFile->addAction(var, this, &CCNotePad::slot_openReceneFile); - act->setData(QVariant(var)); - m_receneOpenFile.insert(var, act); + QAction* act = ui.menuRecene_File->addAction(var, this, &CCNotePad::slot_openReceneFile); + act->setObjectName(var); m_receneOpenFileList.append(var); } } @@ -3218,7 +3236,14 @@ void CCNotePad::setCodeBarLabel(CODE_ID code) void CCNotePad::setLineEndBarLabel(RC_LINE_FORM lineEnd) { QString endStr = Encode::getLineEndById(lineEnd); - m_lineEndLabel->setText(endStr); + + if (m_lineEndLabel->currentText() != endStr) + { + //这里要禁止currentIndexChanged,避免循环触发 + disconnect(m_lineEndLabel, QOverload::of(&QComboBox::currentIndexChanged), this, &CCNotePad::on_lineEndChange); + m_lineEndLabel->setCurrentText(endStr); + connect(m_lineEndLabel, QOverload::of(&QComboBox::currentIndexChanged), this, &CCNotePad::on_lineEndChange); +} } void CCNotePad::setLangsDescLable(QString &langDesc) @@ -3407,6 +3432,70 @@ void CCNotePad::setSaveAllButtonStatus(bool needSave) }*/ } +QAction* findItemInMenuByName(QMenu* menu, QString name) +{ + return menu->findChild(name); +} + +void CCNotePad::dealRecentFileMenuWhenColseFile(QString closeFilePath) +{ + QAction* act = nullptr; + + //如果关闭的文件,已经在最近列表中,则移动到最前面即可 + int index = m_receneOpenFileList.indexOf(closeFilePath); + if (-1 != index) + { + QString filePath = m_receneOpenFileList.takeAt(index); + + act = findItemInMenuByName(ui.menuRecene_File, filePath); + + if (act != nullptr) + { + ui.menuRecene_File->removeAction(act); + } + } + else + { + act = new QAction(closeFilePath, ui.menuFile); + act->setObjectName(closeFilePath); + + connect(act, &QAction::triggered, this, &CCNotePad::slot_openReceneFile); + } + + + //在菜单最近列表上面添加。如果最近列表是空的,则放在退出菜单之上 + if (m_receneOpenFileList.isEmpty()) + { + ui.menuRecene_File->insertAction(nullptr, act); + } + else + { + //放在列表最上面 + QString curTopActionPath = m_receneOpenFileList.first(); + + QAction* topAct = findItemInMenuByName(ui.menuRecene_File, curTopActionPath); + if (topAct != nullptr) + { + ui.menuRecene_File->insertAction(topAct, act); + } + } + + m_receneOpenFileList.push_front(closeFilePath); + + //不能无限制变大,及时删除一部分 + if (m_receneOpenFileList.size() > 15) + { + QString k = m_receneOpenFileList.takeLast(); + QAction* lastAct = findItemInMenuByName(ui.menuRecene_File, k); + if (lastAct != nullptr) + { + ui.menuRecene_File->removeAction(act); + lastAct->deleteLater(); + } + + } +} + //isInQuit::是否在主程序退出状态 void CCNotePad::tabClose(int index, bool isInQuit) { @@ -3464,12 +3553,12 @@ void CCNotePad::tabClose(int index, bool isInQuit) { QApplication::beep(); - int ret = QMessageBox::question(this, tr("Do you want to save changes to « %1 » before closing?").arg(filePath), tr("If you don't save the changes you made, you'll lose them forever."), tr("Yes"), tr("No"), tr("Cancel")); + int ret = QMessageBox::question(this, tr("Do you want to save changes to before closing?"), tr("If you don't save the changes you made in file %1, you'll lose them forever.").arg(filePath), tr("Yes"), tr("No"), tr("Cancel")); //保存 if (ret == 0) { - slot_actionSaveFile_toggle(true); + saveTabEdit(index); //如果还是取消,即没有保存,则不能关闭 if (pEdit->property(Edit_Text_Change).toBool()) @@ -3500,51 +3589,7 @@ void CCNotePad::tabClose(int index, bool isInQuit) //如果关闭的是没有保存的新建文件,则不需要保存在最近打开列表中。新建文件需要保存 if (-1 == pEdit->property(Edit_File_New).toInt()) { - QAction* topRecentFile = nullptr; - - //如果关闭的文件,已经在最近列表中,则移动到最前面即可 - if (m_receneOpenFile.contains(filePath)) - { - topRecentFile = m_receneOpenFile.take(filePath); - - ui.menuFile->removeAction(topRecentFile); - m_receneOpenFileList.removeOne(filePath); - } - else - { - topRecentFile = new QAction(filePath, ui.menuFile); - connect(topRecentFile, &QAction::triggered, this, &CCNotePad::slot_openReceneFile); - } - - - //在菜单最近列表上面添加。如果最近列表是空的,则放在退出菜单之上 - if (m_receneOpenFileList.isEmpty()) - { - ui.menuFile->insertAction(m_quitAction, topRecentFile); - } - else - { - //放在列表最上面 - QString curTopActionPath = m_receneOpenFileList.first(); - if (m_receneOpenFile.contains(curTopActionPath)) - { - ui.menuFile->insertAction(m_receneOpenFile.value(curTopActionPath), topRecentFile); - } - } - - m_receneOpenFileList.push_front(filePath); - m_receneOpenFile.insert(filePath, topRecentFile); - - //不能无限制变大,及时删除一部分 - if (m_receneOpenFileList.size() > 15) - { - QString k = m_receneOpenFileList.takeLast(); - if (m_receneOpenFile.contains(k)) - { - m_receneOpenFile.remove(k); - } - - } + dealRecentFileMenuWhenColseFile(filePath); } //取消监控文件 @@ -3611,7 +3656,7 @@ ScintillaEditView* CCNotePad::newTxtFile(QString name, int index, QString conten //如果非空,则从contentPath中加载文件内容。做恢复文件使用 if (!contentPath.isEmpty()) { - int ret = FileManager::getInstance().loadFileDataInText(pEdit, contentPath, code, lineEnd, nullptr, false); + int ret = FileManager::getInstance().loadFileDataInText(pEdit, contentPath, code, lineEnd, nullptr, false, this); if (ret != 0) { ui.statusBar->showMessage(tr("Restore Last Temp File %1 Failed").arg(contentPath)); @@ -3676,11 +3721,7 @@ ScintillaEditView* CCNotePad::newTxtFile(QString name, int index, QString conten pEdit->setWrapMode(QsciScintilla::WrapCharacter); } - if (s_showblank == 1) - { - pEdit->setWhitespaceVisibility(QsciScintilla::WsVisible); - pEdit->setEolVisibility(true); - } + setEditShowBlankStatus(pEdit, s_showblank); if (s_zoomValue != 0) { @@ -3695,6 +3736,8 @@ ScintillaEditView* CCNotePad::newTxtFile(QString name, int index, QString conten addFileListView(name, pEdit); + pEdit->viewport()->setFocus(); + return pEdit; } @@ -3759,7 +3802,7 @@ bool CCNotePad::reloadTextFileWithCode(CODE_ID code) if (docType == TXT_TYPE) { - int errCode = FileManager::getInstance().loadFileDataInText(pEdit, filePath, code, lineEnd, this, false); + int errCode = FileManager::getInstance().loadFileDataInText(pEdit, filePath, code, lineEnd, this, false,this); if (errCode == 5) { //只读模式。暂时什么也不做 @@ -3891,11 +3934,8 @@ bool CCNotePad::openBigTextRoFile(QString filePath) { pEdit->setWrapMode(QsciScintilla::WrapCharacter); } - if (s_showblank == 1) - { - pEdit->setWhitespaceVisibility(QsciScintilla::WsVisible); - pEdit->setEolVisibility(true); - } + + setEditShowBlankStatus(pEdit, s_showblank); if (s_indent == 1) { @@ -3980,11 +4020,9 @@ bool CCNotePad::openSuperBigTextFile(QString filePath) { pEdit->setWrapMode(QsciScintilla::WrapCharacter); } - if (s_showblank == 1) - { - pEdit->setWhitespaceVisibility(QsciScintilla::WsVisible); - pEdit->setEolVisibility(true); - } + + setEditShowBlankStatus(pEdit, s_showblank); + if (s_indent == 1) { @@ -4008,7 +4046,7 @@ void CCNotePad::showChangePageTips(QWidget* pEdit) if ((BIG_TEXT_RO_TYPE == type) || (SUPER_BIG_TEXT_RO_TYPE == type) || (HEX_TYPE == type)) { - ui.statusBar->showMessage(tr("Use < (Pre) or > (Next) and Goto Buttons to Change Page Num ."), 10000); + ui.statusBar->showMessage(tr("Use < (Prev) or > (Next) and Goto Buttons to Change Page Num ."), 10000); } } @@ -4122,7 +4160,7 @@ bool CCNotePad::openTextFile(QString filePath, bool isCheckHex, CODE_ID code) //如果需要恢复,则加载交换文件的内容。 if (!isNeedRestoreFile) { - int ret = FileManager::getInstance().loadFileDataInText(pEdit, filePath, code, lineEnd, this, isCheckHex); + int ret = FileManager::getInstance().loadFileDataInText(pEdit, filePath, code, lineEnd, this, isCheckHex,this); if (4 == ret) { delete pEdit; @@ -4134,6 +4172,11 @@ bool CCNotePad::openTextFile(QString filePath, bool isCheckHex, CODE_ID code) isReadOnly = true; //只读模式 } + else if (6 == ret) + { + //可能存在乱码,给出警告。还是以编辑模式打开 + ui.statusBar->showMessage(tr("File %1 open success. But Exist Garbled code !")); + } else if (0 != ret) { delete pEdit; @@ -4143,7 +4186,7 @@ bool CCNotePad::openTextFile(QString filePath, bool isCheckHex, CODE_ID code) else { //使用上次的swap文件恢复当前文件 - if (0 != FileManager::getInstance().loadFileDataInText(pEdit, swapfile, code, lineEnd,this)) + if (0 != FileManager::getInstance().loadFileDataInText(pEdit, swapfile, code, lineEnd,this,false,this)) { ui.statusBar->showMessage(tr("File %1 Open Failed").arg(swapfile)); delete pEdit; @@ -4224,16 +4267,9 @@ void CCNotePad::setNormalTextEditInitPro(ScintillaEditView* pEdit, QString fileP { pEdit->setWrapMode(QsciScintilla::WrapCharacter); } - if (s_showblank == 1) - { - pEdit->setWhitespaceVisibility(QsciScintilla::WsVisible); - pEdit->setEolVisibility(true); - } - if (s_indent == 1) - { - pEdit->setIndentGuide(true); - } + setEditShowBlankStatus(pEdit, s_showblank); + if (s_zoomValue != 0) { @@ -4259,6 +4295,13 @@ void CCNotePad::setNormalTextEditInitPro(ScintillaEditView* pEdit, QString fileP { autoSetDocLexer(pEdit); } + + //缩进线要在autoSetDocLexer之后,发现lexer会修改缩进参考线 + if (s_indent == 1) + { + pEdit->setIndentGuide(true); + } + addFileListView(filePath, pEdit); } @@ -4737,7 +4780,7 @@ bool CCNotePad::tryRestoreFile(QString filePath) } return openFile(filePath); } -bool CCNotePad::openFile(QString filePath) +bool CCNotePad::openFile(QString filePath, int lineNum) { s_padTimes++; @@ -4761,7 +4804,22 @@ bool CCNotePad::openFile(QString filePath) if (-1 != retIndex) { ui.editTabWidget->setCurrentIndex(retIndex); - ui.statusBar->showMessage(tr("file %1 already open at tab %2").arg(filePath).arg(retIndex),5000); + + QWidget* pw = ui.editTabWidget->currentWidget(); + ScintillaEditView* pEdit = dynamic_cast(pw); + if (pEdit != nullptr) + { + //必须要先获得焦点,否则无法执行行跳转 + pEdit->viewport()->setFocus(); + + if (lineNum != -1) + { + pEdit->execute(SCI_GOTOLINE, lineNum - 1); + } + } + + ui.statusBar->showMessage(tr("file %1 already open at tab %2").arg(filePath).arg(retIndex),8000); + return true; } @@ -4772,8 +4830,18 @@ bool CCNotePad::openFile(QString filePath) } //非已知的后缀文件,暂时无条件以文本模式打开 - return openTextFile(filePath); + int ret = openTextFile(filePath); + if (ret && lineNum != -1) + { + QWidget* pw = ui.editTabWidget->currentWidget(); + ScintillaEditView* pEdit = dynamic_cast(pw); + if (pEdit != nullptr) + { + pEdit->execute(SCI_GOTOLINE, lineNum-1); } + } + return ret; +} void CCNotePad::slot_slectionChanged() { @@ -4806,6 +4874,18 @@ void CCNotePad::slot_actionOpenFile_toggle(bool /*checked*/) } } +#ifdef _WIN32 +void hide_file(const QString& szFile) +{ +#ifdef UNICODE + std::wstring wstr = szFile.toStdWString(); + ::SetFileAttributes(wstr.c_str(), FILE_ATTRIBUTE_HIDDEN); +#else + ::SetFileAttributes(szFile.toStdString()c_str(), FILE_ATTRIBUTE_HIDDEN); +#endif // !UNICODE +} +#endif // _WIN32 + //bool isBakWrite:是否进行保护写,即先写swap文件,再写源文件。这样可以避免突然断电导致源文件被清空 //isBakWrite 是否写保护swp文件,默认true。只有新文件时不需要,因为新文件不存在覆盖写的问题 //isStatic 是否静默:不弹出对话框,在外部批量查找替换文件夹时使用,避免弹窗中断。默认false @@ -4937,13 +5017,19 @@ bool CCNotePad::saveFile(QString fileName, ScintillaEditView* pEdit, bool isBak } else { - QString swapFile = getSwapFilePath(fileName); - QFile swapfile(swapFile); + QString swapFilePath = getSwapFilePath(fileName); + QFile swapfile(swapFilePath); //老文件则先写入交换文件,避免断电后破坏文件不能恢复 //再写入原本文件 bool success = saveWork(swapfile, fileName, true); if (success) { +#ifdef _WIN32 + if (!isClearSwpFile) + { + hide_file(swapFilePath); + } +#endif success = saveWork(srcfile, fileName); if (!success) { @@ -4952,7 +5038,7 @@ bool CCNotePad::saveFile(QString fileName, ScintillaEditView* pEdit, bool isBak } if (success && isClearSwpFile) { - QFile::remove(swapFile); + QFile::remove(swapFilePath); } } @@ -5006,11 +5092,10 @@ void CCNotePad::updateProAfterSaveNewFile(int curTabIndex, QString fileName, Sci addWatchFilePath(fileName); } -//保存文件的执行 -void CCNotePad::slot_actionSaveFile_toggle(bool /*checked*/) +// +void CCNotePad::saveTabEdit(int tabIndex) { - QWidget* pw = ui.editTabWidget->currentWidget(); - int index = ui.editTabWidget->currentIndex(); + QWidget* pw = ui.editTabWidget->widget(tabIndex); //16进制的处理逻辑 if (HEX_TYPE == getDocTypeProperty(pw)) @@ -5047,7 +5132,7 @@ void CCNotePad::slot_actionSaveFile_toggle(bool /*checked*/) int retIndex = findFileIsOpenAtPad(fileName); if (-1 != retIndex) { - QMessageBox::warning(this,tr("Error"), tr("file %1 already open at tab %2, please select other file name.").arg(fileName).arg(retIndex)); + QMessageBox::warning(this, tr("Error"), tr("file %1 already open at tab %2, please select other file name.").arg(fileName).arg(retIndex)); return; } @@ -5055,7 +5140,7 @@ void CCNotePad::slot_actionSaveFile_toggle(bool /*checked*/) { return; } - updateProAfterSaveNewFile(index, fileName, pEdit); + updateProAfterSaveNewFile(tabIndex, fileName, pEdit); } else { @@ -5092,11 +5177,11 @@ void CCNotePad::slot_actionSaveFile_toggle(bool /*checked*/) } //一旦保存后,设置tab为不需要保存状态 - ui.editTabWidget->setTabIcon(index, QIcon((StyleSet::getCurrentSytleId() != DEEP_BLACK) ? TabNoNeedSave : TabNoNeedSaveDark32)); + ui.editTabWidget->setTabIcon(tabIndex, QIcon((StyleSet::getCurrentSytleId() != DEEP_BLACK) ? TabNoNeedSave : TabNoNeedSaveDark32)); //m_saveFile->setIcon(QIcon(NoNeedSaveBarIcon)); m_saveFile->setEnabled(false); - + updateSaveAllToolBarStatus(); //只有保存后再打开文本变化监控 @@ -5104,6 +5189,13 @@ void CCNotePad::slot_actionSaveFile_toggle(bool /*checked*/) } } +//保存文件的执行 +void CCNotePad::slot_actionSaveFile_toggle(bool /*checked*/) +{ + int index = ui.editTabWidget->currentIndex(); + saveTabEdit(index); +} + //文件重命名 void CCNotePad::slot_actionRenameFile_toggle(bool checked) @@ -5235,7 +5327,9 @@ void CCNotePad::slot_actionSaveAsFile_toggle(bool /*checked*/) //如果是打开的本来就存在的文件,也弹出保存进行 QString filter("Text files (*.txt);;XML files (*.xml);;h files (*.h);;cpp file(*.cpp);;All types(*.*)"); - QString fileName = QFileDialog::getSaveFileName(this, tr("Save File As ..."), QString(), filter); + + QString curFilePath = getFilePathProperty(pEdit); + QString fileName = QFileDialog::getSaveFileName(this, tr("Save File As ..."), curFilePath, filter); if (!fileName.isEmpty()) { @@ -5377,9 +5471,7 @@ void CCNotePad::slot_saveAllFile() //从尾部开始依次调用保存所有文件。没修改的不需要保存 for (int i = ui.editTabWidget->count()-1; i >= 0; --i) { - ui.editTabWidget->setCurrentIndex(i); - - slot_actionSaveFile_toggle(true); + saveTabEdit(i); } //最后恢复之前的current ui.editTabWidget->setCurrentIndex(index); @@ -5641,54 +5733,7 @@ void CCNotePad::closeFileStatic(int index, QSettings& qs) FileManager::getInstance().delNewFileNode(newFileIndex); } - //如果关闭的是没有保存的新建文件,则不需要保存在最近打开列表中。新建文件需要保存 - if (-1 == pEdit->property(Edit_File_New).toInt()) - { - QAction* topRecentFile = nullptr; - - //如果关闭的文件,已经在最近列表中,则移动到最前面即可 - if (m_receneOpenFile.contains(filePath)) - { - topRecentFile = m_receneOpenFile.take(filePath); - - ui.menuFile->removeAction(topRecentFile); - m_receneOpenFileList.removeOne(filePath); - } - else - { - topRecentFile = new QAction(filePath, ui.menuFile); - connect(topRecentFile, &QAction::triggered, this, &CCNotePad::slot_openReceneFile); - } - - //在菜单最近列表上面添加。如果最近列表是空的,则放在退出菜单之上 - if (m_receneOpenFileList.isEmpty()) - { - ui.menuFile->insertAction(m_quitAction, topRecentFile); - } - else - { - //放在列表最上面 - QString curTopActionPath = m_receneOpenFileList.first(); - if (m_receneOpenFile.contains(curTopActionPath)) - { - ui.menuFile->insertAction(m_receneOpenFile.value(curTopActionPath), topRecentFile); - } - } - - m_receneOpenFileList.push_front(filePath); - m_receneOpenFile.insert(filePath, topRecentFile); - - //不能无限制变大,及时删除一部分 - if (m_receneOpenFileList.size() > 15) - { - QString k = m_receneOpenFileList.takeLast(); - if (m_receneOpenFile.contains(k)) - { - m_receneOpenFile.remove(k); - } - - } - } + //这里是在退出程序的过程中,不需要更新最近打开文件菜单列表 //取消监控文件 removeWatchFilePath(filePath); @@ -6034,17 +6079,11 @@ void CCNotePad::slot_zoomout() zoomto(s_zoomValue); } -//只切换了当前文档。可能会耗时,所以不全部换行。在文档切换的时候,需要检查下当前文档的自动换行状态。 +//只切换了当前文档。换行大批量切换,可能会非常耗时,所以不全部换行。在文档切换的时候,需要检查下当前文档的自动换行状态。 void CCNotePad::slot_wordwrap(bool checked) { QWidget* pw = ui.editTabWidget->currentWidget(); - //是m_wordwrap快捷按钮按钮发出,同步菜单上的状态 - if (nullptr != dynamic_cast(sender())) - { - ui.actionWrap->setChecked(checked); - } - ScintillaEditView* pEdit = dynamic_cast(pw); if (pEdit != nullptr) @@ -6061,59 +6100,78 @@ void CCNotePad::slot_wordwrap(bool checked) s_autoWarp = (checked) ? QsciScintilla::WrapCharacter : QsciScintilla::WrapNone; NddSetting::updataKeyValueFromNumSets(AUTOWARP_KEY, s_autoWarp); + + //同步两个按钮的状态 + if (ui.actionWrap->isChecked() != checked) + { + ui.actionWrap->setChecked(checked); } -void CCNotePad::slot_allWhite(bool checked) + if (m_wordwrap != nullptr && m_wordwrap->isChecked() != checked) { - //是m_wordwrap快捷按钮按钮发出,同步菜单上的状态 - if (nullptr != dynamic_cast(sender())) - { - ui.actionShowAll->setChecked(checked); + m_wordwrap->setChecked(checked); } +} + +void CCNotePad::syncBlankShowStatus() + { + //检查3个地方按钮的状态。这里务必注意,action使用trigged信号,setcheck修改不会触发该信号。避免循环 + //同样道理,button使用click信号,也是避免setcheck触发click信号,避免信号循环处理。 + ui.actionShowSpaces->setChecked((0 != (s_showblank & 0x1))); + ui.actionshow_end_of_line->setChecked((0 != (s_showblank & 0x2))); + ui.actionShowAll->setChecked((3 == s_showblank)); + m_allWhite->setChecked((3 == s_showblank)); + } + +//这里是对所有文档进行了空白的开启等。后续如果发现有效率问题,要学自动换行那样,可以只修当前文档;其余文档在切换是更新 +void CCNotePad::changeBlankShowStatus(int showBlank) +{ + //对比判断防止循环触发,这个是有必要的。 + if (s_showblank == showBlank) + { + return; + } + //0 全部不开启。1开始空白 2 开启行尾 3 全部开启 + s_showblank = showBlank; for (int i = ui.editTabWidget->count() - 1; i >= 0; --i) { QWidget* pw = ui.editTabWidget->widget(i); - ScintillaEditView* pEdit = dynamic_cast(pw); - if (pEdit != nullptr) { - if (checked) - { - pEdit->setWhitespaceVisibility(QsciScintilla::WsVisible); - pEdit->setEolVisibility(true); + setEditShowBlankStatus(pEdit, s_showblank); } - else - { - pEdit->setWhitespaceVisibility(QsciScintilla::WsInvisible); - pEdit->setEolVisibility(false); } - } -} - - s_showblank = (checked) ? 1 : 0; + NddSetting::updataKeyValueFromNumSets(SHOWSPACE_KEY, s_showblank); + + syncBlankShowStatus(); } - -void CCNotePad::slot_show_spaces(bool checked) +//有2个函数,都触发该函数。一个是ui.actionShowAll,一个是按钮m_allWhite。 +//状态以ui.actionShowAll为主。m_allWhite为辅助同步按钮状态。避免二者的信号互相干扰。 +void CCNotePad::slot_allWhite(bool checked) { - QWidget* pw = ui.editTabWidget->currentWidget(); - ScintillaEditView* pEdit = dynamic_cast(pw); - if (pEdit != nullptr) + //0 全部不开启。1开始空白 2 开启行尾 3 全部开启 + changeBlankShowStatus((checked ? 3 : 0)); +} + +//只控制空格和TAB,不控制行尾 +void CCNotePad::slot_show_spaces(bool checked) { + int showblank = s_showblank; if (checked) { - pEdit->setWhitespaceVisibility(QsciScintilla::WsVisible); + showblank |= 0x1; } else { - pEdit->setWhitespaceVisibility(QsciScintilla::WsInvisible); + showblank &= 0xe; } + changeBlankShowStatus(showblank); } -} //全部都会生效,和自动换行不一样,会全部设置 @@ -6199,9 +6257,10 @@ int CCNotePad::markAtBack(QString keyword) return pFind->markAllWord(keyword); } - -void CCNotePad::initFindWindow(FindTabIndex type) +//返回值:0 正常 1 选择自动为空 +int CCNotePad::initFindWindow(FindTabIndex type) { + int ret = 0; FindWin* pFind = nullptr; QWidget* pw = ui.editTabWidget->currentWidget(); int docType = getDocTypeProperty(pw); @@ -6298,6 +6357,7 @@ void CCNotePad::initFindWindow(FindTabIndex type) pFind->setFindText(text); pFind->setReplaceFindText(text); pFind->setDirFindText(text); + ret = 1; } } else if (HEX_TYPE == docType) @@ -6312,9 +6372,10 @@ void CCNotePad::initFindWindow(FindTabIndex type) { QString text; pFind->setFindText(text); + ret = 1; } } - + return ret; } //保存历史查找记录 @@ -6751,7 +6812,7 @@ void CCNotePad::setDocEolMode(ScintillaEditView* pEdit, RC_LINE_FORM endStatus) } } -void CCNotePad::convertDocLineEnd(RC_LINE_FORM endStatus) +bool CCNotePad::convertDocLineEnd(RC_LINE_FORM endStatus) { QWidget* pw = ui.editTabWidget->currentWidget(); @@ -6759,10 +6820,16 @@ void CCNotePad::convertDocLineEnd(RC_LINE_FORM endStatus) { ui.statusBar->showMessage(tr("Only Text File Can Use it, Current Doc is a Hex File !"), 10000); QApplication::beep(); - return; + return false; } ScintillaEditView* pEdit = dynamic_cast(pw); + if (pEdit != nullptr && pEdit->isReadOnly()) + { + ui.statusBar->showMessage(tr("The ReadOnly document does not allow this operation."), 8000); + QApplication::beep(); + return false; + } int eolMode = 0; @@ -6781,7 +6848,7 @@ void CCNotePad::convertDocLineEnd(RC_LINE_FORM endStatus) case PAD_LINE: case UNKNOWN_LINE: default: - return; + return false; } if (pEdit != nullptr) @@ -6805,6 +6872,7 @@ void CCNotePad::convertDocLineEnd(RC_LINE_FORM endStatus) setLineEndBarLabel(endStatus); } } + return true; } @@ -6862,25 +6930,19 @@ void CCNotePad::slot_gotoline() } } - - void CCNotePad::slot_show_line_end(bool checked) { - QWidget* pw = ui.editTabWidget->currentWidget(); - ScintillaEditView* pEdit = dynamic_cast(pw); - - if (pEdit != nullptr) - { + int showblank = s_showblank; if (checked) { - pEdit->setEolVisibility(true); + showblank |= 0x2; } else { - pEdit->setEolVisibility(false); + showblank &= 0xd; } + changeBlankShowStatus(showblank); } -} @@ -7318,9 +7380,9 @@ void CCNotePad::slot_about() { QMessageBox msgBox(this); QString msg = tr(R"( - Github repo: cxasm/notepad-- +https://gitee.com/cxasm/notepad--
- China Gitee: cxasm/notepad-- +https://github.com/cxasm/notepad-- )"); #if defined (Q_OS_MAC) @@ -7357,7 +7419,6 @@ void CCNotePad::slot_aboutNdd() #endif } - void CCNotePad::addWatchFilePath(QString filePath) { getRegularFilePath(filePath); @@ -7437,7 +7498,41 @@ bool CCNotePad::eventFilter(QObject * watched, QEvent * event) #ifdef Q_OS_WIN static const ULONG_PTR CUSTOM_TYPE = 10000; static const ULONG_PTR OPEN_NOTEPAD_TYPE = 10001; +static const ULONG_PTR CUSTOM_TYPE_FILE_LINENUM = 10002; +bool CCNotePad::nativeOpenfile(QString openFilePath) +{ + int retIndex = findFileIsOpenAtPad(openFilePath); + if (-1 == retIndex) + { + openFile(openFilePath); + } + else + { + ui.statusBar->showMessage(tr("file %1 already open at tab %2").arg(openFilePath).arg(retIndex)); + ui.editTabWidget->setCurrentIndex(retIndex); + } + //窗口如果最小化,则在任务栏下面闪动 + QApplication::alert(this); + + //发现在release模式下,必须要先最小再最大,窗口才能跑到最前面。而调试时则没有该现象。可能是哪里有个问题。 + if (!this->isMinimized()) + { + this->showMinimized(); + } + + if (this->isMaximized()) + { + this->showMaximized(); + } + else + { + this->showNormal(); + } + + this->activateWindow(); + return true; +} bool CCNotePad::nativeEvent(const QByteArray & eventType, void * message, long * result) { MSG *param = static_cast(message); @@ -7447,40 +7542,11 @@ bool CCNotePad::nativeEvent(const QByteArray & eventType, void * message, long * case WM_COPYDATA: { COPYDATASTRUCT *cds = reinterpret_cast(param->lParam); + if (cds->dwData == CUSTOM_TYPE) { QString openFilePath = QString::fromUtf8(reinterpret_cast(cds->lpData), cds->cbData); - - int retIndex = findFileIsOpenAtPad(openFilePath); - if (-1 == retIndex) - { - openFile(openFilePath); - } - else - { - ui.statusBar->showMessage(tr("file %1 already open at tab %2").arg(openFilePath).arg(retIndex)); - ui.editTabWidget->setCurrentIndex(retIndex); - } - //窗口如果最小化,则在任务栏下面闪动 - QApplication::alert(this); - - //发现在release模式下,必须要先最小再最大,窗口才能跑到最前面。而调试时则没有该现象。可能是哪里有个问题。 - if (!this->isMinimized()) - { - this->showMinimized(); - } - - if (this->isMaximized()) - { - this->showMaximized(); - } - else - { - this->showNormal(); - } - - - this->activateWindow(); + nativeOpenfile(openFilePath); *result = 1; return true; } @@ -7491,9 +7557,31 @@ bool CCNotePad::nativeEvent(const QByteArray & eventType, void * message, long * *result = 1; return true; + } + else if (cds->dwData == CUSTOM_TYPE_FILE_LINENUM) + { + QString openFilePath = QString::fromUtf8(reinterpret_cast(cds->lpData), cds->cbData); + QStringList paraList = openFilePath.split("|"); + if (paraList.size() == 2) + { + nativeOpenfile(paraList.at(0)); + bool ok = true; + int lineNum = paraList.at(1).toInt(&ok); + if (ok) + { + QWidget* pw = ui.editTabWidget->currentWidget(); + ScintillaEditView* pEdit = dynamic_cast(pw); + if (pEdit != nullptr) + { + pEdit->execute(SCI_GOTOLINE, lineNum - 1); + } + } + } + *result = 1; + return true; + } } } - } return QWidget::nativeEvent(eventType, message, result); } @@ -7853,7 +7941,7 @@ bool CCNotePad::restoreDirtyExistFile(QString& filePath, QString& tempFilePath) //如果非空,则从contentPath中加载文件内容。做恢复文件使用 if (!tempFilePath.isEmpty()) { - int ret = FileManager::getInstance().loadFileDataInText(pEdit, tempFilePath, code, lineEnd, nullptr, false); + int ret = FileManager::getInstance().loadFileDataInText(pEdit, tempFilePath, code, lineEnd, nullptr, false,this); if (ret != 0) { isLoadOrgin = true; @@ -7877,7 +7965,7 @@ bool CCNotePad::restoreDirtyExistFile(QString& filePath, QString& tempFilePath) if(isLoadOrgin) { - int ret = FileManager::getInstance().loadFileDataInText(pEdit, filePath, code, lineEnd, this, true); + int ret = FileManager::getInstance().loadFileDataInText(pEdit, filePath, code, lineEnd, this, true, this); if (4 == ret) { delete pEdit; @@ -7945,11 +8033,8 @@ bool CCNotePad::restoreDirtyExistFile(QString& filePath, QString& tempFilePath) pEdit->setWrapMode(QsciScintilla::WrapCharacter); } - if (s_showblank == 1) - { - pEdit->setWhitespaceVisibility(QsciScintilla::WsVisible); - pEdit->setEolVisibility(true); - } + setEditShowBlankStatus(pEdit, s_showblank); + if (s_indent == 1) { @@ -8686,22 +8771,56 @@ void CCNotePad::slot_sortLexDescIngCase() dealLineSort(SORTLINES_LEXICO_CASE_INSENS_DESCENDING); } - +//这里是从F3 F4快捷按下时的查找槽函数。 void CCNotePad::slot_findNext() { - initFindWindow(); - + //先检查一下,当前查找窗口是否存在而且显示。存在则直接调用查找框的功能。 + //避免F3和查找框里面的干扰 + if (!m_pFindWin.isNull() && m_pFindWin->isVisible()) + { FindWin* pFind = dynamic_cast(m_pFindWin.data()); pFind->setCurrentTab(FIND_TAB); pFind->findNext(); + return; +} + + int ret = initFindWindow(); + + if (ret == 0) + { + FindWin* pFind = dynamic_cast(m_pFindWin.data()); + pFind->setCurrentTab(FIND_TAB); + pFind->findNext(); + } + else + { + ui.statusBar->showMessage(tr("what find is null !"), 8000); + } } void CCNotePad::slot_findPrev() { - initFindWindow(); + //先检查一下,当前查找窗口是否存在而且显示。存在则直接调用查找框的功能。 + //避免F4和查找框里面的干扰 + if (!m_pFindWin.isNull() && m_pFindWin->isVisible()) + { FindWin* pFind = dynamic_cast(m_pFindWin.data()); pFind->setCurrentTab(FIND_TAB); pFind->findPrev(); + return; +} + + int ret = initFindWindow(); + if (ret == 0) + { + FindWin* pFind = dynamic_cast(m_pFindWin.data()); + pFind->setCurrentTab(FIND_TAB); + pFind->findPrev(); + } + else + { + ui.statusBar->showMessage(tr("what find is null !"), 8000); + } } //繁体BIG5 @@ -8738,7 +8857,7 @@ void CCNotePad::slot_escQuit() void CCNotePad::slot_formatXml() { ScintillaEditView* _pEditView = getCurEditView(); - if (_pEditView == nullptr && _pEditView->isReadOnly()) + if (_pEditView == nullptr || _pEditView->isReadOnly()) { return; } @@ -8764,7 +8883,7 @@ void CCNotePad::slot_formatXml() if (reader.hasError()) { - ui.statusBar->showMessage(tr("Xml format error, please check!"), 8000); + ui.statusBar->showMessage(tr("XML format error, please check!"), 8000); QApplication::beep(); return; } @@ -8794,7 +8913,7 @@ void CCNotePad::slot_formatJson() if (QJsonParseError::NoError != parseError.error) { - ui.statusBar->showMessage(tr("Json format error, please check!"),8000); + ui.statusBar->showMessage(tr("JSON format error, please check!"),8000); QApplication::beep(); return; } @@ -8806,14 +8925,8 @@ void CCNotePad::slot_formatJson() //清空历史打开记录 void CCNotePad::slot_clearHistoryOpenList() { - for (QMap ::iterator it = m_receneOpenFile.begin(); it != m_receneOpenFile.end(); ++it) - { - ui.menuFile->removeAction(*it); - delete (*it); - } - - m_receneOpenFile.clear(); + ui.menuRecene_File->clear(); m_receneOpenFileList.clear(); } @@ -8926,4 +9039,4 @@ void CCNotePad::slot_shortcutManager() adjustWInPos(pWin); #endif pWin->show(); -} \ No newline at end of file +} diff --git a/src/cceditor/ccnotepad.h b/src/cceditor/ccnotepad.h index f4063e5..da59ddf 100755 --- a/src/cceditor/ccnotepad.h +++ b/src/cceditor/ccnotepad.h @@ -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 m_dockFileListWin; FileListView* m_fileListView; - //一个用于查找,一个用于排序 - QMap m_receneOpenFile; QList m_receneOpenFileList; QActionGroup *m_pEncodeActGroup; diff --git a/src/cceditor/ccnotepad.ui b/src/cceditor/ccnotepad.ui index eeb912f..41c84e8 100755 --- a/src/cceditor/ccnotepad.ui +++ b/src/cceditor/ccnotepad.ui @@ -87,8 +87,13 @@ Qt::LeftToRight - File (&F) + &File + + + Recene File + + @@ -97,13 +102,14 @@ + Qt::LeftToRight - Edit (&E) + &Edit @@ -180,7 +186,7 @@ - Search (&S) + &Search @@ -204,7 +210,7 @@ - View (&V) + &View @@ -232,7 +238,7 @@ - Encoding (&N) + E&ncoding @@ -263,7 +269,7 @@ - Language (&L) + &Language @@ -306,6 +312,7 @@ R + @@ -466,7 +473,7 @@ - Set (&T) + Se&t @@ -479,6 +486,8 @@ + + @@ -495,7 +504,7 @@ - Tools (&O) + T&ools @@ -506,6 +515,7 @@ + @@ -819,7 +829,7 @@ true - Php + PHP @@ -939,7 +949,7 @@ true - Virsual Basic + Visual Basic @@ -955,7 +965,7 @@ true - Css + CSS @@ -987,7 +997,7 @@ true - Tex + TeX @@ -1224,7 +1234,7 @@ true - Nncrontab + NCrontab @@ -1248,7 +1258,7 @@ true - LaTex + LaTeX @@ -1397,7 +1407,7 @@ true - json + JSON @@ -1445,7 +1455,7 @@ true - Spice + SPICE @@ -1479,7 +1489,7 @@ true - go + Go @@ -1575,11 +1585,6 @@ Chinese - - - - - Theme Style @@ -2033,6 +2038,16 @@ Shortcut Key Manager + + + R + + + + + test + + @@ -3447,6 +3462,22 @@ + + actionWrap + triggered(bool) + CCNotePad + slot_wordwrap(bool) + + + -1 + -1 + + + 728 + 394 + + + slot_actionNewFile_toggle(bool) @@ -3505,7 +3536,7 @@ slot_removeEndBlank() slot_removeHeadEndBlank() slot_columnBlockEdit() - slot_wordwrap() + slot_wordwrap(bool) slot_defineLangs() slot_uppercase() slot_lowercase() diff --git a/src/cceditor/filemanager.cpp b/src/cceditor/filemanager.cpp index 725c360..96383cc 100755 --- a/src/cceditor/filemanager.cpp +++ b/src/cceditor/filemanager.cpp @@ -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 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); diff --git a/src/cceditor/filemanager.h b/src/cceditor/filemanager.h index 95f829a..565f9aa 100755 --- a/src/cceditor/filemanager.h +++ b/src/cceditor/filemanager.h @@ -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); diff --git a/src/findwin.cpp b/src/findwin.cpp index c3998ed..14aad6c 100755 --- a/src/findwin.cpp +++ b/src/findwin.cpp @@ -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); diff --git a/src/findwin.h b/src/findwin.h index 8731656..6eebf1f 100755 --- a/src/findwin.h +++ b/src/findwin.h @@ -111,6 +111,8 @@ private: void dealWithZeroFoundShowTip(QsciScintilla * pEdit, bool isShowTip=true); + void adjustSearchStartPosChange(QsciScintilla* pEdit); + void dofindNext(); bool replaceFindNext(QsciScintilla* pEdit, bool showZeroFindTip); diff --git a/src/findwin.ui b/src/findwin.ui index 81831ea..28b310f 100755 --- a/src/findwin.ui +++ b/src/findwin.ui @@ -40,7 +40,7 @@ - 1 + 0 @@ -1386,54 +1386,68 @@ + findinfilesTab findComboBox findTextNext + findTextPrev + countBt findAllinCourrent findAllinAllOpen + findClearBt findCloseBt findBackwardBox findMatchWholeBox findMatchCaseBox findWrapBox findModeNormalBt + findModeExtendBt findModeRegularBt replaceTextBox - replaceBackwardBox - replaceMatchWholeBox - replaceMatchCaseBox - replaceWrapBox - replaceModeRegularBt - replaceModeNormalBox + replaceWithBox replaceFindNextBox replaceBt replaceAllBt replaceAllinAllOpenBt replaceCloseBt + replaceBackwardBox + replaceMatchWholeBox + replaceMatchCaseBox + replaceWrapBox + replaceModeNormalBox + replaceModeExtendBox + replaceModeRegularBt destFindDir - selectDir dirFindWhat + dirReplaceWhat + selectDir + dirFindAll + dirReplaceAll + clearBt + dirClose dealFileType fileType + skipDir + skipDirNames dirFindMatchWholeBox dirFindMatchCaseBox - dirFindModeRegularBt dirFindModeNormalBox + dirFindModeExtendBox + dirFindModeRegularBt skipChildDirs skipHideFile skipBinary skipFileMaxSize maxFileSizeSpinBox - dirFindAll - dirReplaceAll - dirClose markTextBox - markMatchWholeBox - markMatchCaseBox - markModeRegularBt - markModeNormalBox markAllBox markClearBox + markClearAllBox markCloseBt + markMatchWholeBox + markMatchCaseBox + markModeNormalBox + markModeExtendBox + markModeRegularBt @@ -1462,8 +1476,8 @@ close() - 674 - 288 + 572 + 251 169 @@ -1510,8 +1524,8 @@ slot_replaceFindNext() - 448 - 69 + 94 + 60 588 @@ -1526,8 +1540,8 @@ close() - 448 - 213 + 94 + 45 588 @@ -1542,8 +1556,8 @@ slot_replace() - 448 - 103 + 94 + 64 588 @@ -1558,8 +1572,8 @@ slot_replaceAll() - 448 - 137 + 94 + 67 588 @@ -1574,8 +1588,8 @@ slot_replaceAllInOpenDoc() - 448 - 180 + 94 + 76 588 @@ -1638,8 +1652,8 @@ close() - 674 - 171 + 572 + 142 564 @@ -1718,8 +1732,8 @@ slot_findPrev() - 674 - 103 + 484 + 73 294 diff --git a/src/main.cpp b/src/main.cpp index 65d5bd7..5d94509 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -31,15 +31,16 @@ #include 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(nullptr), reinterpret_cast(©data)); + } + + 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 diff --git a/src/qscidisplaywindow.cpp b/src/qscidisplaywindow.cpp index 5d5584b..7423fa0 100755 --- a/src/qscidisplaywindow.cpp +++ b/src/qscidisplaywindow.cpp @@ -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); { diff --git a/src/qscint/src/Qsci/qscilexerr.h b/src/qscint/src/Qsci/qscilexerr.h new file mode 100755 index 0000000..b3a7cf8 --- /dev/null +++ b/src/qscint/src/Qsci/qscilexerr.h @@ -0,0 +1,104 @@ +#pragma once +#pragma once +// This defines the interface to the QsciLexerR class. +// +// Copyright (c) 2021 Riverbank Computing Limited +// +// 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 + +#include +#include + + +//! \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&); +}; diff --git a/src/qscint/src/qscilexer.cpp b/src/qscint/src/qscilexer.cpp index 716e652..070a4a6 100755 --- a/src/qscint/src/qscilexer.cpp +++ b/src/qscint/src/qscilexer.cpp @@ -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(); diff --git a/src/qscint/src/qscilexerasm.cpp b/src/qscint/src/qscilexerasm.cpp index fbf35e9..fdb2851 100755 --- a/src/qscint/src/qscilexerasm.cpp +++ b/src/qscint/src/qscilexerasm.cpp @@ -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); diff --git a/src/qscint/src/qscilexerglobal.cpp b/src/qscint/src/qscilexerglobal.cpp index fdbb54d..0ac42e3 100755 --- a/src/qscint/src/qscilexerglobal.cpp +++ b/src/qscint/src/qscilexerglobal.cpp @@ -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: diff --git a/src/qscint/src/qscilexerr.cpp b/src/qscint/src/qscilexerr.cpp new file mode 100755 index 0000000..1de7014 --- /dev/null +++ b/src/qscint/src/qscilexerr.cpp @@ -0,0 +1,237 @@ + +#include "Qsci/qsciLexerr.h" + +#include +#include +#include + + +// 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); +} diff --git a/src/qscint/src/qscintilla.pro b/src/qscint/src/qscintilla.pro index f0f9852..eb7089f 100755 --- a/src/qscint/src/qscintilla.pro +++ b/src/qscint/src/qscintilla.pro @@ -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 \ diff --git a/src/qtlangset.cpp b/src/qtlangset.cpp index 70f1672..533623a 100755 --- a/src/qtlangset.cpp +++ b/src/qtlangset.cpp @@ -17,50 +17,6 @@ #include #include -#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); //ȫֵʽ֪ͨǰеı༭ȥ޸DZȫʽ @@ -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); //ȫֵʽ֪ͨǰеı༭ȥ޸DZȫʽ @@ -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); //ȫֵʽ֪ͨǰеı༭ȥ޸DZȫʽ @@ -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(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(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(); + + //ȫֵʽ֪ͨǰеı༭ȥ޸DZȫʽ + CCNotePad* pMainNote = dynamic_cast(parent()); + if (pMainNote != nullptr) + { + + for (int i = 0; i <= GLOBAL_STYLES::URL_HOVERRED; ++i) + { + pMainNote->setGlobalFont(i); +} + } + } } //ָԵijʼá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)); } + + //ﻹһ + //ﻹ⣬Ҫѵǰĵȫַһ£ȫֲЧ + + //ȫֵʽ֪ͨǰеı༭ȥ޸DZȫʽ + CCNotePad* pMainNote = dynamic_cast(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); //ȫֵʽ֪ͨǰеı༭ȥ޸DZȫʽ CCNotePad* pMainNote = dynamic_cast(parent()); @@ -1436,7 +1465,7 @@ void QtLangSet::slot_changeBkColor() } else if (!ui.useGlobalColor->isVisible()) { - setGlobalBgColor(m_selectStyleId, color); + StyleSet::setGlobalBgColor(m_selectStyleId, color); //ȫֵʽ֪ͨǰеı༭ȥ޸DZȫʽ CCNotePad* pMainNote = dynamic_cast(parent()); @@ -1887,33 +1916,11 @@ void QtLangSet::updateThemes() } } -//ȫֵǰһIJһ -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); } } diff --git a/src/qtlangset.h b/src/qtlangset.h index 04e44d6..614733a 100755 --- a/src/qtlangset.h +++ b/src/qtlangset.h @@ -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); diff --git a/src/qtlangset.ui b/src/qtlangset.ui index 0ad13c5..855d4fe 100755 --- a/src/qtlangset.ui +++ b/src/qtlangset.ui @@ -37,6 +37,13 @@ + + + + Global Set + + + @@ -737,8 +744,8 @@ slot_useAlobalFont(bool) - 1009 - 291 + 844 + 238 491 @@ -753,8 +760,8 @@ slot_useAlobalFontBold(bool) - 1009 - 413 + 844 + 238 491 @@ -769,8 +776,8 @@ slot_useAlobalFontItalic(bool) - 1009 - 474 + 844 + 238 491 @@ -785,8 +792,8 @@ slot_useAlobalFontUnderline(bool) - 1009 - 535 + 844 + 238 491 @@ -801,8 +808,8 @@ slot_useAlobalFontSize(bool) - 1009 - 352 + 844 + 238 491 @@ -858,6 +865,22 @@ + + pushButton + clicked() + QtLangSetClass + on_showGlobalItem() + + + 103 + 56 + + + 197 + 69 + + + slot_saveClick() @@ -872,5 +895,6 @@ slot_useAlobalFontItalic(bool) slot_useAlobalBkColor(bool) on_themesChange(int) + on_showGlobalItem() diff --git a/src/rcglobal.h b/src/rcglobal.h index 9ecbe0e..62a86d0 100755 --- a/src/rcglobal.h +++ b/src/rcglobal.h @@ -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 diff --git a/src/realcompare_zh.qm b/src/realcompare_zh.qm index 9f992f6..472ce1b 100755 Binary files a/src/realcompare_zh.qm and b/src/realcompare_zh.qm differ diff --git a/src/realcompare_zh.ts b/src/realcompare_zh.ts index 31abb45..ee6f9d2 100755 --- a/src/realcompare_zh.ts +++ b/src/realcompare_zh.ts @@ -4,22 +4,46 @@ AboutNddClass - - AboutNdd - 关于Ndd + 关于Ndd - - <html><head/><body><p><a href="https://gitee.com/cxasm/notepad--"><span style=" font-size:10pt; text-decoration: underline; color:#0000ff;">Click to get the latest version of notepad-- or source code</span></a></p></body></html> - <html><head/><body><p><a href="https://gitee.com/cxasm/notepad--"><span style=" font-size:10pt; text-decoration: underline; color:#0000ff;">点击获取最新版的 notepad-- 或开源代码</span></a></p></body></html> + <html><head/><body><p><a href="https://gitee.com/cxasm/notepad--"><span style=" font-size:10pt; text-decoration: underline; color:#0000ff;">点击获取最新版的 notepad-- 或开源代码</span></a></p></body></html> - - opensoure web:https://gitee.com/cxasm/notepad-- - 开源网址:https://gitee.com/cxasm/notepad-- + 开源网址:https://gitee.com/cxasm/notepad-- + + + + + About Notepad-- + 关于 Notepad-- + + + + + General Public License + + + + + + 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. + + + + + + <html><head/><body><p>Home: <a href="https://gitee.com/cxasm/notepad--"><span style=" font-size:10pt; text-decoration: underline; color:#0000ff;">https://gitee.com/cxasm/notepad--</span></a></p></body></html> + + + + + + Okay + 好的 @@ -227,32 +251,30 @@ 打开方式 - - + + Big Text File(< 8G) Read only open, load in blocks, and turn pages manually. 大文本只读模式(文件小于8G时推荐)可显示行号,行号跳转。 - - Super Big Text Edit - 超大文本模式 + 超大文本模式 - - + + Text Mode 文本模式 - - + + Open directly in text mode.May be slow, Need wait. 直接以普通文本打开,注意:可能比较慢或卡顿,需要等待。(不推荐) - - + + Big Text 大文本模式 @@ -261,23 +283,29 @@ 分块只读打开大文件,速度快,需要手动进行前后翻页。(推荐) - - + + Hex Bin 二进制模式 - - + + Binary Open,load in blocks, and turn pages manually. 二进制打开,速度快,需要手动进行前后翻页。 - - + + Super big Text File(> 8G bits) Read only open, load in blocks, and turn pages manually. 超大文本只读模式(文件大于8G时推荐)顺序翻页可显示行号,支持地址跳转。 + + + + Super Big Text + 超大文本模式 + @@ -302,8 +330,8 @@ 编辑 - - + + Format Conversion 换行符转换 @@ -316,8 +344,8 @@ 视图 - - + + Display symbols 显示符号 @@ -326,130 +354,138 @@ 编码 - - + + Language 语言 - - + + P - - - - + + + Recene File + 最近文件 + + + + + + C - - + + J - - - - + + + + + + R - - + + H - - + + M - - + + B - - + + I - - + + N - - + + A - - + + S - - + + V - - + + L - - + + T - - + + F - - - - - - + + + + + + D - - + + O - - + + E - - + + G @@ -462,8 +498,8 @@ 皮肤风格 - - + + About 关于 @@ -472,8 +508,8 @@ 对比 - - + + Recently 最近对比 @@ -486,373 +522,374 @@ 文件... - - + + New 新建 - - + + Open ... 打开 - - + + Ctrl+O - - + + Save 保存 - - + + Ctrl+S - - + + Save As ... 另存为 - - + + Ctrl+Alt+S - - - - + + + + Close 关闭 - - + + Ctrl+W - - + + Exit 退出 - - + + Ctrl+Q - - - + + + Close All 关闭所有 - - + + Ctrl+Shift+W - - - + + + Undo 撤销 - - + + Ctrl+Z - - - + + + Redo 重做 - - + + Ctrl+Y - - - + + + Cut 剪切 - - + + Ctrl+X - - + + + Copy 拷贝 - - + + Ctrl+C - - - + + + Paste 粘贴 - - + + Ctrl+V - - + + Select All 全选 - - + + Ctrl+A - - + + Windows(CR+LF) - - + + Unix(LF) - - + + Mac(CR) - - - + + + Find 查找 - - + + Ctrl+F - - - + + + Replace 替换 - - + + Go line 跳转 - - + + Ctrl+G - - + + Show spaces/tabs 显示空格 - - + + Show end of line 显示行尾 - - + + Show all 显示所有 - - + + Encode in GBK 编码 GBK - - + + Encode in UTF8 编码 UTF8 - - + + Encode in UTF8-BOM 编码 UTF8-BOM - - + + Encode in UCS-2 BE BOM 编码 UCS-2 BE BOM - - + + Encode in UCS-2 LE BOM 编码 UCS-2 LE BOM - - + + Convert to GBK 转换为 GBK 编码 - - + + Convert to UTF8 转换为 UTF8 编码 - - + + Convert to UTF8-BOM 转换为 UTF8-BOM 编码 - - + + Convert to UCS-2 BE BOM 转换为 UCS-2 BE BOM 编码 - - + + Convert to UCS-2 LE BOM 转换为 UCS-2 LE BOM 编码 - - + + Batch convert 批量转换编码 - - + + Options 选项 - - + + BugFix 问题反馈 - - + + Donate 捐赠作者 - - + + Default 默认 - - + + LightBlue 亮蓝 - - + + ThinBlue 淡蓝 - - + + RiceYellow 纸黄 - - - - + + + + Yellow 黄色 - - + + Silver 银色 - - + + LavenderBlush 淡紫红 - - + + MistyRose 浅玫瑰色 - - + + English 英文 - - + + Chinese 中文 @@ -861,148 +898,160 @@ 捐赠软件 - - + + TXT - - + + Search Result 查找结果 - - - - + + + + + + test - - - go + + + Go + go - - + + File compare 文件对比 - + notepad-- - - File(&F) + + &File + File(&F) 文件(&F) - - - Edit(&E) + + + &Edit + Edit(&E) 编辑(&E) - - + + Blank CharOperate 空白字符操作 - - + + Convert Case to 大小写转换 - - + + Line Operations 行编辑 - - - Search(&S) + + + &Search + Search(&S) 查找(&S) - - - Book Mark + + + Bookmark + Book Mark 书签 - - + + Mark Color 标记颜色... - - - View(&V) + + + &View + View(&V) 视图(&V) - - + + Icon Size 图标大小 - - - Encoding(&N) + + + E&ncoding + Encoding(&N) 编码(&N) - - + + Other 其它编码 - - + + Convert to Other 转换为其它编码 - - - Language(&L) + + + &Language + Language(&L) 语言(&L) - - - Set(&T) + + + Se&t + Set(&T) 设置(&T) - + Format Language 格式化语言 - - + + Feedback 反馈问题 - - - Compare(&C) + + + &Compare + Compare(&C) 对比(&C) @@ -1010,514 +1059,522 @@ 最近对比(&R) - - + + Ctrl+T - - + + Ctrl+H - - + + Dir compare 目录对比 - - + + XML - - + + YAML - - - Php + + + PHP + Php - - + + C++ - - + + C# - - + + Objective C - - + + Java - - + + RC - - + + HTML - - + + Makefile - - + + Pascal - - + + Batch - - + + ini - - + + Nfo - - + + Asp - - + + Sql - - - Virsual Basic + + + Visual Basic + Virsual Basic - - + + JavaScript - - - Css + + + CSS + Css - - + + Perl - - + + Python - - + + Lua - - - Tex + + + TeX + Tex - - + + Fortran - - + + Shell - - + + ActionScript - - + + NSIS - - + + Tcl - - + + Lisp - - + + Scheme - - + + Assembly - - + + Diff - - + + Properties file - - + + PostScript - - + + Ruby - - + + Smalltalk - - + + VHDL - - + + AutoIt - - + + CMake - - + + PowerShell - - + + Jsp - - + + CoffeeScript - - + + BaanC - - + + S-Record - - + + TypeScript - - + + Visual Prolog - - + + Txt2tags - - + + Rust - - + + Registry - - + + REBOL - - + + OScript - - - Nncrontab + + + NCrontab + Nncrontab - - + + Nim - - + + MMIXAL - - - LaTex + + + LaTeX + LaTex - - + + Forth - - + + ESCRIPT - - + + Erlang - - + + Csound - - + + FreeBasic - - + + BlitzBasic - - + + PureBasic - - + + AviSynth - - + + ASN.1 - - + + Swift - - + + Intel HEX - - + + Fortran77 - - + + Edifact - - - - + + + + MarkDown - - + + Octave - - + + Po - - + + Pov - - - json + + + JSON + json - - + + AVS - - + + Bash - - + + IDL - - + + Matlab - - - Spice + + + SPICE + Spice - - + + Verilog - - + + Register 注册版本 - - + + Language File Suffix 语法文件后缀关联 - - + + Shortcut Key Manager 快捷键管理 @@ -1526,588 +1583,589 @@ 编程语言格式 - - + + Open In Text 以文本模式打开 - - + + Open In Bin 以二进制模式打开 - - + + Remove Head Blank 去除行首空白 - - + + Remove End Blank 去除行尾空白 - - + + Remove Head End Blank 去除行首尾空白 - - + + Column Block Editing 列块编辑 - - + + Wrap 自动换行 - - + + Define Language 自定义语言 - - + + UPPERCASE 转成大写 - - + + lowercase 转成小写 - - + + Proper Case 每词转成仅首字母大写 - - + + Proper Case (blend) 每词的首字母转成大写 - - + + Sentence case 每句转成仅首字母大写 - - + + Sentence case (blend) 每句的首字母转成大写 - - + + Invert Case 大小写互换 - - + + Random Case 随机大小写 - - + + Remove Empty Lines 移除空行 - - + + Remove Empty Lines (Containing Blank characters) 移除空行(包括空白字符) - - + + UserDefine 用户自定义 - - + + Column Block Mode 列块模式... - - + + TAB to Space TAB 转空格 - - + + Space to TAB (All) 空格转 TAB (全部) - - + + Space to TAB (Leading) 空格转 TAB (行首) - - + + Duplicate Current Line 复制当前行 - - + + Ctrl+D - - + + Remove Duplicate Lines 删除重复行 - - + + Remove Consecutive Duplicate Lines 删除连续的重复行 - - + + Split Lines 分隔行 - - + + Join Lines 合并行 - - + + Move Up Current Line 上移当前行 - - + + Ctrl+Shift+Up - - + + Move Down Current Line 下移当前行 - - + + Ctrl+Shift+Down - - + + Insert Blank Line Above Current 在当前行上方插入空行 - - + + Ctrl+Alt+Return - - + + Insert Blank Line Below Current 在当前行下方插入空行 - - + + Ctrl+Alt+Shift+Return - - + + Reverse Line Order 反排序行 - - + + Randomize Line Order - - + + Sort Lines Lexicographically Ascending 升序排列文本行 - - + + Sort Lines Lex. Ascending Ignoring Case 升序排列文本行(不分大小写) - - + + Sort Lines As Integers Ascending - - + + Sort Lines As Decimals (Comma) Ascending - - + + Sort Lines As Decimals (Dot) Ascending - - + + Sort Lines Lexicographically Descending 降序排列文本行 - - + + Sort Lines Lex. Descending Ignoring Case 降序排列文本行(不分大小写) - - + + Sort Lines As Integers Descending - - + + Sort Lines As Decimals (Comma) Descending - - + + Sort Lines As Decimals (Dot) Descending - - + + Find In Dir 在目录查找 - - + + Ctrl+Shift+D - - - - + + + + 1 - - - + + + Format Xml 格式化 Xml - - - + + + Format Json 格式化 Json - - + + Dark 深色 - - + + VB - - + + 2 - - + + 3 - - + + 4 - - + + 5 - - + + loop - - + + Clear History 清除历史打开记录 - - + + FileListView 文件列表窗口 - - + + Show ToolBar 显示工具栏 - - - + + + Batch Find 批量查找替换 - - + + Show Web Addr(Not recommended) 显示网站(不推荐开启) - - + + Find Next 查找下一个 - - + + menuDir 目录对比记录 - - + + menuReceFile 文件对比记录 - - - Tools(&O) + + + T&ools + Tools(&O) 工具(&O) - - + + Theme Style 主题与语法样式 - - + + F3 - - + + Find Prev 查找前一个 - - + + F4 - - + + Red - - + + Blue - - - - + + + + Big5 Big5(繁体中文) - - + + 24x24 - - + + 36x36 - - + + 48x48 - - + + AboutNdd About ndd - 关于Ndd + 关于 Ndd info 信息 - - + + Ln:0 Col:0 行 0 列 0 - - + + Quit 退出 - + Edit with Notepad-- Edit with Notebook CC - + Close Current Document 关闭当前文档 - + Close Non-Current documents 关闭所有非当前文档 - + Close Left All 关闭左边所有文档 - + Close Right All 关闭右边所有文档 - + Current Document Sava as... 当前文件另存为 - + Show File in Explorer... 定位到文件路径 - + Open in New Window 在新窗口中打开 - + Can't Get Admin Auth, Open File %1 failed 获取管理员权限失败,打开文件 %1 失败。修改系统文件请以管理员权限执行ndd程序。 - + Please run in admin auth 请在管理员权限下执行程序 - + Rename Current Document 重命名当前文件 - + Reload With Text Mode 重新以文本模式打开 - + Reload With Hex Mode 重新以二进制模式打开 - + Select Left Cmp File 选择为左边对比文件 - + Select Right Cmp File 选择为右边对比文件 @@ -2116,108 +2174,108 @@ 大文本文件只读模式 - + New File 新建 - + Open File 打开 - - + + Save File 保存 - + Save All File 保存所有 - + Cycle Auto Save 周期自动保存 - + Mark 标记 - + word highlight(F8) 高亮单词(F8) - + clear all highlight(F7) 取消所有高亮(F7) - + Zoom In 放大 - + Zoom Out 缩小 - + Word Wrap 自动换行 - + Show Blank 显示空白字符 - + Indent Guide 缩进参考线 - + Pre Hex Page 上一页/位置 - + Next Hex Page 下一页/位置 - + Goto Hex Page 跳转到文件偏移地址 - + File Compare 文件对比 - + Dir Compare 目录对比 - + Bin Compare 二进制对比 - + transform encoding 转换编码 - + batch rename file 批量重命名 @@ -2227,128 +2285,149 @@ 缩放率: %1% - + Big5(Traditional Chinese) Big5(繁体中文) - + + Do you want to save changes to before closing? + Do you want to save changes to « %1 » before closing? + 关闭文件之前,是否保存修改? + + + + If you don't save the changes you made in file %1, you'll lose them forever. + 如果你不保存在文件 %1 中的修改,变更操作将不会生效。 + + + New File Finished [Text Mode] Zoom %1% 创建新文件成功 缩放率 %1% - - Use < (Pre) or > (Next) and Goto Buttons to Change Page Num . + + Use < (Prev) or > (Next) and Goto Buttons to Change Page Num . + Use < (Pre) or > (Next) and Goto Buttons to Change Page Num . 使用工具栏按钮 < (前一页) >(下一页) Go(跳转) 进行翻页。 - + File %1 File Size %2 > %3M, How to Open it ? 文件 %1 文件大小 %2 大于 %3M,请选择打开方式。 - + + File %1 open success. But Exist Garbled code ! + + + + File %1 Open Finished [Text Mode] Zoom %2% 文件 %1 打开成功 [文本模式] 缩放率 %2% - - + + Format Error - - - - + + + + Not a txt format file , load with big txt is garbled code! 文件不是文本格式,强制以大文本打开时乱码! - - + + Current offset is %1 , line nums is %2 - %3 load Contens Size is %4, File Total Size is %5 当前文件偏移 %1 ,行号 %2-%3 ,分块加载大小 %4 ,文件大小是 %5 - + File List 文件列表 - + Save Swap File %1 failed. Write the target file directly ? 保存交换文件 %1 失败,是否直接保存写入原始文件? - - + + Current Zoom Value is %1% 当前缩放率 %1% - + out of file line range,mar line num is %1 ! - - Ndd Version %1 - - - - + Registered Version 注册过的正版软件!(恭喜) - + Free Trial 免费永久试用版本(捐赠可获取注册码) - + %1 is not a file, skip open it... %1 不是一个文件,跳过打开它...... - - - + + + + The ReadOnly document does not allow this operation. 当前只读显示文件不允许该操作! - + Column Edit Mode Tips 列块模式提示 - + "ALT+Mouse Click" or "Alt+Shift+Arrow keys" Switch to mode! 请使用'ALT+鼠标点选' 或 'Alt+Shif+箭头键'切换列块模式。 - + SortingError 排序错误 - + Unable to perform numeric sorting due to line %1. 行 %1 不能进行排序操作! - - Xml format error, please check! + + + what find is null ! + 查找字段为空 + + + + XML format error, please check! + Xml format error, please check! Xml 格式化错误,请检查文件格式! - - Json format error, please check! + + JSON format error, please check! + Json format error, please check! Json 格式化错误,请检查文件格式! @@ -2356,76 +2435,90 @@ File Size %2 > %3M, How to Open it ? 已打开的窗口背景颜色,将在文件重新打开后才会生效! - + GB18030(Simplified Chinese) GB18030(简体中文) - + Language: %1 语法:%1 - + Reload 重加载 - + Yes 保存 - - + + No 放弃修改 - + Cancel 取消 - - + + Restore Last Temp File %1 Failed 恢复临时文件 %1 失败! - + Recover File? 是否恢复文件? - + File %1 abnormally closed last time , Restore it ? 文件 %1 上次异常退出并留下未保存存档,是否恢复文件存档? - + Restore 恢复文件? - - + + File %1 Open Failed 文件 %1 打开失败! - + + +<a href="https://gitee.com/cxasm/notepad--">https://gitee.com/cxasm/notepad--</a> +<br/> +<a href="https://github.com/cxasm/notepad--">https://github.com/cxasm/notepad--</a> + + + + + + Notepad-- Version %1 + + + + File %1 Open Finished [Text Mode] 文件 %1 打开成功 [文本模式] - - + + Current offset is %1 , load Contens Size is %2, File Total Size is %3 当前文件偏移 %1 , 加载内容大小是 %2,文件总大小是 %3 (字节) - + File %1 Open Finished [Hex ReayOnly Mode] 文件 %1 打开成功 [二进制只读模式] @@ -2434,23 +2527,23 @@ File Size %2 > %3M, How to Open it ? 文件 %1 可能是二进制文件,尝试以文本格式打开。 - + Save File %1 failed. You may not have write privileges Please save as a new file! 保存文件 %1 失败! 你可能没有文件写权限,请另存为一个新文件! - + Cycle autosave on ... 周期性自动保存文件已开启... - + Cycle autosave off ... 周期性自动保存文件已关闭... - + The current document has been automatically saved 当前文件周期性自动保存完毕! @@ -2467,52 +2560,50 @@ Do you want to reload it? %1\n\n \n文件已在外部被其它程序修改。\n是否重新加载该文件? - - + + Ln: %1 Col: %2 行:%1 列:%2 - Save File? - 保存文件? + 保存文件? - if save file %1 ? - 是否保存文件 %1 ? + 是否保存文件 %1 ? Current offset is %1 , File Size is %2 当前文件偏移 %1 , 文件大小是 %2 (字节) - - - - - - - - + + + + + + + + Error 错误 - + file %1 not exist. 文件 %1 不存在 - - + + file %1 already open at tab %2 文件 %1 已经在页面 %2 中打开 - - + + Save File %1 failed. Can not write auth, Please save as new file 保存 %1 失败。当前文件没有写权限,请另存为一个新文件 @@ -2521,148 +2612,148 @@ Do you want to reload it? 打开文件 %1 失败 - - - - + + + + Only Text File Can Use it, Current Doc is a Hex File ! 只有文本模式才能使用该功能,当前文件是二进制文件! - + "%1" This file has been modified by another program. Do you want to reload it? %1 该文件已在外部被其它程序修改,是否重新加载? - + Run As Admin Failed to save the file. Please check the file permissions. 以管理员模式保存文件失败!请检查文件的权限。 - + Plugin Manager 插件管理 - + plugin %1 load failed ! - + Plugin 插件 - + If display exceptions,Please Install System Font Courier 如果界面字体不满意,还请安装windows系统字体 Courier - + Set/Remove BookMark 设置/取消书签 - + Next BookMark 下一书签 - + Prev BookMark 上一书签 - + ClearAll BookMark 清除所有书签 - + Cut BookMark Lines 剪切书签行 - + Copy BookMark Lines 复制书签行 - + Paste BookMark Lines 粘贴(替换)书签行 - + Delete BookMark Lines 删除书签行 - + Delete UnBookMark Lines 删除未标记行 - + Clip BookMark 反向标记书签 - + Color %1 颜色 %1 - + The currently file %1 is already in text mode 当前文件 %1 已经是文本模式 - + The currently file %1 is already in bin mode 当前文件 %1 已经是二进制模式 - - + + File %1 Open Finished [Text ReadOnly Mode] (Note: display up to 50K bytes ...) 文件 %1 打开成功 [文本只读模式] (乱码:二进制文件强行以文本格式显示,最多显示50K字节的内容,后面忽略...) - - + + file %1 already open at tab %2, please select other file name. 文件 %1 已经存在于页面 %2 中,请选择一个其它名称 - + Rename File As ... 重命名... - + file %1 reanme failed! 文件 %1 重命名失败! - - + + Save File As ... 另存为文件 ... - + Close ? 关闭? - + already has child window open, close all ? 目前还有子窗口处于打开状态,关闭所有窗口吗? - + Find result 查找结果 @@ -2671,50 +2762,50 @@ Do you want to reload it? 文件已关闭 - - + + Find result - %1 hit 查找结果 - %1 命中 - + Convert end of line In progress, please wait ... 行尾转换中,请等待... - + Convert end of line finish. 行尾转换完毕 - + Go to line 跳转到行 - + Line Num: 行号 - + no more pre pos 没有前一个位置了 - + no more next pos 没有后一个位置了 - - - + + + The Last Page ! Current offset is %1 , load Contens Size is %2, File Total Size is %3 最后一页!当前文件偏移是 %1 ,加载内容大小是 %2 ,文件总大小是 %3 (字节) - + Only Hex File Can Use it, Current Doc not a Hex File ! 只有二进制文件具备该功能。当前文件不是二进制文件! @@ -2723,46 +2814,44 @@ Do you want to reload it? 最后一页!当前文件偏移是 %1 ,文件大小是 %2 (字节) - + file %1 was not exists ! 文件 %1 不存在! - - + + Error file offset addr , please check ! 错误的文件偏移量地址,请检查! - - + + File Size is %1, addr %2 is exceeds file size 文件大小是 %1,当前地址 %2 超过了文件大小。 - + Current Text Doc Can Not Use it ! Current Text Doc Canp Not Use it ! 当前是常规文本文档,不能使用该功能! - - bugfix: https://github.com/cxasm/notepad-- china: https://gitee.com/cxasm/notepad-- bugfix: https://github.com/cxasm/notepad-- - bug反馈:https://github.com/cxasm/notepad-- + bug反馈:https://github.com/cxasm/notepad-- 国内:https://gitee.com/cxasm/notepad-- - - + + notice 消息 - - + + file path not exist, remove recent record! 文件路径不存在,删除历史记录! @@ -2795,7 +2884,7 @@ china: https://gitee.com/cxasm/notepad-- 文件开始偏移位置超过文件长度! - + BigFile Compare, left linenum %1 , right lineNum %2, Please Waiting ! 大文件对比,左文件行数 %1 ,右文件行数 %2, 请等待 ! @@ -2898,7 +2987,7 @@ china: https://gitee.com/cxasm/notepad-- Capital - + 大写 @@ -4474,54 +4563,56 @@ Left Equal ratio %4 Right Equal ratio %5 FileManager - - - + + Error 错误 - Open File %1 failed Can not read auth - 打开文件 %1 失败。没有读文件的权限。 + 打开文件 %1 失败。没有读文件的权限。 - + Open File %1 failed 打开文件 %1 失败。 - + File is too big to be opened by Notepad-- 文件太大,不能使用Notepad--打开! - + The file %1 is likely to be binary. Do you want to open it in binary? 文件 %1 可能是二进制格式,你想以二进制(只读)格式打开文件吗? - Open with Text or Hex? - 二进制或文本打开? + 二进制或文本打开? - + Hex Open 以二进制打开 - + Text Open 以文本打开 - + Cancel 取消 - + + Open with Text or Hex? [Exist Garbled Code] + + + + load bit text file tree in progress file size %1, please wait ... 加载大文件中,文件大小 %1,请等待... @@ -4790,13 +4881,13 @@ file size %1, please wait ... FindWin - + MainWindow 查找与替换 - + find 查找 @@ -4804,17 +4895,17 @@ file size %1, please wait ... - - - + + + Find what : 查找目标: - - + + Backward direction 反向查找 @@ -4823,10 +4914,10 @@ file size %1, please wait ... - - - - + + + + Match whole word only 全词匹配 @@ -4835,18 +4926,18 @@ file size %1, please wait ... - - - - + + + + Match case 匹配大小写 - - + + Wrap around 循环查找 @@ -4855,10 +4946,10 @@ file size %1, please wait ... - - - - + + + + Search Mode 查找模式 @@ -4867,10 +4958,10 @@ file size %1, please wait ... - - - - + + + + Regular expression 正则表达式 @@ -4879,10 +4970,10 @@ file size %1, please wait ... - - - - + + + + Normal 普通 @@ -4891,83 +4982,83 @@ file size %1, please wait ... - - - - + + + + Extend(\n,\r,\t,\0,\x...) 扩展(\n,\r,\t,\0,\x...) - + Find Next(F3) 查找下一个(F3) - + F3 - + Find Prev(F4) 查找上一个(F4) - + F4 - + Counter(T) 计数(T) - + Ctrl+T - + Find Next 查找下一个 - + File Type : 文件类型: - + Skip Dir Name : 跳过目录名: - + Clear All 清除全部标记 - + Find All in Current Document 在当前文件中查找 - + Find All in All Opened Documents 查找所有打开文件 @@ -4977,95 +5068,95 @@ file size %1, please wait ... - - - - + + + + Close 关闭 - - + + Replace 替换 - - + + Replace with : 替换为: - + Replace All 在当前文件中替换 - + Replace All in All Opened Documents 替换所有打开文件 - + Replace In File 在目录文件中替换 - - + + Clear Result 清空结果 - + Mark 标记 - + Mark What 标记目标: - + Mark All 全部标记 - + Clear Mark 清除 - + Dir Find 在目录查找 - + Dest Dir : 目标目录: - + Select 选择 @@ -5075,7 +5166,7 @@ file size %1, please wait ... - + *.c:*.cpp:*.h @@ -5085,277 +5176,277 @@ file size %1, please wait ... - + debug:Debug:.vs:.git:.svn - + Options 选项 - + Skip child dirs 跳过子目录 - + Skip hide file 跳过隐藏文件 - + Skip binary file 跳过二进制文件 - + Skip Big file exceed 跳过超过大小的文件 - + MB - + Find All 全部查找 - - - - - - - - - - - + + + + + + + + + + + what find is null ! 查找字段为空 - - - - - + + + + + cant't find text '%1' 找不到字段 '%1' - - + + no more find text '%1' 没有更多的字段 '%1' - - - - + + + + The ReadOnly document does not allow this operation. 当前只读显示文件不允许该操作! - - + + find finished, total %1 found! 查找完成,一共 %1 处发现。 - - + + The mode of the current document does not allow this operation. 当前模式下的文档不允许该操作! - - - - + + + + The ReadOnly document does not allow replacement. 当前只读文档不允许执行替换操作! - - + + no more replace text '%1' 没有更多替换文本 '%1' - + find-regex-zero-length-match 正则查找零长匹配 - + target info linenum %1 pos is %2 - %3 目标在行 %1 位置 %2 - %3 - - + + count %1 times with '%2' 计数 %1 次匹配 '%2' - + total %1 keyword, please wait ... - - + + The mode of the current document does not allow replacement. 当前模式的文档不允许执行替换操作! - - + + Replace All current Doc 在所有打开文件中替换 - - + + Are you sure replace all occurrences in current documents? 是否确认在当前打开的文档中替换? - - + + replace finished, total %1 replaced! 替换完成,一共 %1 处替换! - + Replace All Open Doc 替换所有打开的文档 - + Are you sure replace all occurrences in all open documents? 是否确认在所有打开的文档中替换? - + Replace in Opened Files: %1 occurrences were replaced. 在打开的文档中替换:%1 处已经被替换。 - - + + what mark is null ! 标记字段为空! - + cant't mark text '%1' 不能标记文本 ‘%1’ - + mark finished, total %1 found! 标记完成,一共 %1 处发现! - + The mode of the current document does not allow mark. 当前模式的文档不允许执行标记操作! - + Open Directory 打开目录 - + load dir file in progress , please wait ... 加载目录文件中,请等待... - - + + skip dir %1 跳过目录 %1 - + found %1 dir %2 发现 %1 个目录 %2 - + ext type skip file %1 跳过类型文件 %1 - + found in dir canceled ... 查找取消... - + Continue Find ? 是否继续查找? - + The search results have been greater than %1 times in %2 files, and more may be slow. Continue to search? 查找结果已经有 %1 处在 %2 个文件中,结果太多会比较慢,是否继续查找? - + Yes 继续查找 - + Abort 终止查找 - - + + please select find dest dir ! 请选择目标文件夹! - + dest dir %1 not exist ! 目标文件夹 %1 不存在! - + find finished, total %1 found in %2 file! 查找完成,一共发现 %1 处在 %2 个文件中! - + Replace All Dirs 目录全部替换 - + Are you sure replace all "%1" to "%2" occurrences in selected dirs ? 您确定替换目录文件中所有 "%1" 为 "%2" 吗? - + replace finished, total %1 replace in %2 file! 替换完成,一共替换 %1 处在 %2 个文件中! @@ -5998,38 +6089,38 @@ Double-click a column item to modify the syntax association file. QObject - + Text Mode 文本模式 - + Hex ReadOnly Mode 二进制只读模式 - + Big Text ReadOnly Mode Bit Text ReadOnly Mode 大文本只读模式 - + Big Text ReadWrite Mode - + Super Big Text ReadOnly Mode 超大文本只读模式 - + Text ReadOnly Mode 文本只读模式 - + File Mode 文件模式 @@ -6072,135 +6163,135 @@ Double-click a column item to modify the syntax association file. QsciLexerGlobal Global override - 全局样式覆盖所有语言 + 全局样式覆盖所有语言 Default - 默认 + 默认 Indent guideline style - 缩进参考线风格 + 缩进参考线风格 Brace highlight style - 括弧高亮风格 + 括弧高亮风格 Current line background colour - 当前行背景色 + 当前行背景色 Select text colour - 选中文本颜色 + 选中文本颜色 Caret colour - 光标颜色 + 光标颜色 Line number margin - 行号风格 + 行号风格 Bookmark margin - 书签风格 + 书签风格 Fold - 折叠符号风格 + 折叠符号风格 Fold active - 折叠激活风格(目前无效) + 折叠激活风格(目前无效) Fold margin - 折叠样式 + 折叠样式 White space symbol - 空白字符样式 + 空白字符样式 Smart HighLighting - 智能高亮 + 智能高亮 Find Mark Style - 查找结果样式 + 查找结果样式 Mark Style 1 - 标记样式1 + 标记样式1 Mark Style 2 - 标记样式2 + 标记样式2 Mark Style 3 - 标记样式3 + 标记样式3 Mark Style 4 - 标记样式4 + 标记样式4 Mark Style 5 - 标记样式5 + 标记样式5 URL hovered - 网址鼠标悬浮样式 + 网址鼠标悬浮样式 QsciLexerText Chinese And Others - 中文字符及其它 + 中文字符及其它 Ascii - 英文字符 + 英文字符 Keyword - 关键词 + 关键词 QsciScintilla &Cut - 剪切 + 剪切 &Copy - 复制 + 复制 &Paste - 粘贴 + 粘贴 Delete - 删除 + 删除 Select All - 全选 + 全选 Show File in Explorer - 定位到文件目录 + 定位到文件目录 QtLangSet - + Save Change 保存修改 @@ -6209,74 +6300,74 @@ Double-click a column item to modify the syntax association file. 当前语言的格式风格已经被修改,是否保存? - - + + AllGlobal 全局格式统一设置 - + Current themes : %1, language : %2 当前主题:%1,当前语言:%2 - + %1 style configuration has been modified. Do you want to save it? %1 类型的显示风格已经被修改,是否保存? - + Read %1 language user define format error. 读取 %1 语言用户自定义格式失败! - + Save Finished ! 保存成功! - + Not change, no need save ! 没有改变,无需保存! - + Style Foreground Color 风格背景色 风格前景色 - + Style Background Color 风格背景色 - + Reset Style 重置风格 - + Are you sure to reset language %1 sytle 您确定重置语言 %1 的风格吗? - + Reset All Style 重置所有风格 - + Are you sure to reset All language sytle 您确定重置所有语言风格吗? - + themes changing, please waiting ... 主题切换中,请等待 ... - + themes changed finished ... 主题切换完成 ... @@ -6285,167 +6376,173 @@ Double-click a column item to modify the syntax association file. QtLangSetClass - + QtLangSet 编程语言样式 - + + Global Set + 全局设置 + + + + Select Main: 选择主题: - - + + Default(stylers.xml) 默认主题 - - + + Bespin - - + + Black board - - + + Blue Light - - + + Choco - - + + DansLeRuSH-Dark - - + + Deep Black - - + + Lavender - - + + HotFudgeSundae - - + + Misty Rose - - + + Mono Industrial - - + + Monokai - - + + Obsidian - - + + Plastic Code Wrap - - + + Ruby Blue - - + + Twilight - - + + Vibrant Ink - - + + Yellow Rice - - + + Language 语言 - - + + User Define Language 自定义语言 - - + + Style 样式 - - + + Color 颜色 - - + + Foreground: 前景色 - - - - + + + + TextLabel - - - - + + + + Select 选择 @@ -6454,86 +6551,86 @@ Double-click a column item to modify the syntax association file. 修改所有风格 - - + + background: 背景色 - - + + Same As Theme 与主题保存一致 - - + + Font 字体 - - + + Font Size: 字体大小 - - + + Bold 粗体 - - + + Italic 斜体 - - + + Underline 下划线 - - + + Name: 名称: - - + + Use Global Color 全局颜色 - - + + Keyword And Mother 关键词和母版 - - + + Mother Language: 母版语言: - - + + None - - + + Cpp - - + + Ext File Type: 关联文件后缀名: @@ -6542,68 +6639,68 @@ Double-click a column item to modify the syntax association file. 全局风格设置 - - + + Use Global Foreground Color 使用全局前景色 - - + + Use Global Background Color 使用全局背景色 - - + + Global Style Font 全局样式字体 - - + + Use Global Font 使用全局字体 - - + + Use Global FontSize 使用全局字体大小 - - + + Use Global Bold Font 使用全局粗体样式 - - + + Use Global Italic Font 使用全局斜体样式 - - + + Use Global Underline Font 使用全局下划线样式 - - + + reset 重置 - - + + Save 保存 - - + + Close 关闭 @@ -6887,51 +6984,72 @@ Double-click a column item to modify the syntax association file. ScintillaEditView - + Show File in Explorer 定位到文件目录 - - + + mark with color 使用颜色标记 - - + + Color %1 颜色 %1 - - - + + + Clear Select 清除选择标记 - - - + + + Clear All 清除全部标记 - + Add/Del line comment 添加/删除当行注释 - + Add Block comment 区块注释 - + Del Block comment 清除区块注释 + + + Word Count + 字数统计 + + + + + Word Nums + 字符数量 + + + + Current Select Word Nums is %1 . + 当前选择的字符数量是 %1 . + + + + Current Doc Word Nums is %1 . + 当前文档的字符数量是 %1 . + ShortcutKeyEditWin @@ -6950,235 +7068,243 @@ Double-click a column item to modify the syntax association file. ShortcutKeyEditWinClass - + ShortcutKeyEditWin 快捷键编辑 - - + + Current Key Sequence: 当前快捷键: - - + + New Key Sequence: 新的快捷键: - - + + Ok 确定 - - + + Cancel 取消 + + + + Delete + 删除 + ShortcutKeyMgr - + New File 新建 - + Open File 打开 - + Save File 保存 - + Save All File 保存所有 - + Close 关闭 - + Close All 关闭所有 - + Cut 剪切 - + Copy 拷贝 - + Paste 粘贴 - + Undo 撤销 - + Redo 重做 - + Find 查找 - + Replace 替换 - + Dir Find 在目录查找 - + Mark 标记 - + word highlight(F8) 高亮单词(F8) - + clear all highlight(F7) 取消所有高亮(F7) - + Zoom In 放大 - + Zoom Out 缩小 - + Word Wrap 自动换行 - + Show Blank 显示空白字符 - + Indent Guide 缩进参考线 - + Pre Hex Page 上一页/位置 - + Next Hex Page 下一页/位置 - + Goto Hex Page 跳转到文件偏移地址 - + File Compare 文件对比 - + Dir Compare 目录对比 - + Bin Compare 二进制对比 - + transform encoding 转换编码 - + batch rename file 批量重命名 - + Format Xml 格式化 Xml - + Format Json 格式化 Json - - + + Can't Modify 不可修改 - + Double Click To Modify 双击修改快捷键 - + row %1 shortcut key '%2' can't modify ! 行 %1 快捷键 ‘%2’不可修改! - + + modify row %1 to '%2' shortcut key success! 修改行 %1 快捷键为 %2 成功! - + + error:modify row %1 to '%2' shortcut key failed ! 错误:修改行 %1 为快捷键 %2 失败! - + conflict error! '%1' Already exist at row %2 冲突错误!'%1' 已经存在行 %2 - + conflict error! '%1' Already exist at qscint row %2 冲突错误!'%1' 已经存在于qscint表格行 %2 - + modify canceled ! 修改取消! @@ -7187,49 +7313,49 @@ Double-click a column item to modify the syntax association file. ShortcutKeyMgrClass - + ShortcutKeyMgr 快捷键管理 - + Ndd Shortcut Ndd 快捷键 - - - - + + + + Function 功能 - - - - + + + + Shortcut Key 快捷键 - - - - + + + + Comment 说明 - - + + Qscint Shortcut Qscint 快捷键 - - + + Close 关闭 @@ -7565,31 +7691,36 @@ You will get the registration code! - save left document ? + Save Left Document? + save left document ? 保存左边文档? - save right document ? + Save Right Document? + save right document ? 保存右边文档? - save selected + Save Selected + save selected 保存所选文档 - discard + Discard + discard 放弃修改 - cancel + Cancel + cancel 取消 diff --git a/src/scintillaeditview.cpp b/src/scintillaeditview.cpp index f09b962..f3413a6 100755 --- a/src/scintillaeditview.cpp +++ b/src/scintillaeditview.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -64,6 +65,7 @@ #include #include #include +#include #include @@ -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; diff --git a/src/scintillaeditview.h b/src/scintillaeditview.h index 867f7ab..db44317 100755 --- a/src/scintillaeditview.h +++ b/src/scintillaeditview.h @@ -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); diff --git a/src/shortcutkeyeditwin.cpp b/src/shortcutkeyeditwin.cpp index 5a8fc30..7e253d3 100755 --- a/src/shortcutkeyeditwin.cpp +++ b/src/shortcutkeyeditwin.cpp @@ -39,4 +39,10 @@ void ShortcutKeyEditWin::slot_ok() m_newKeys = keys; done(1); -} \ No newline at end of file +} + +//ɾΪ +void ShortcutKeyEditWin::on_delete() +{ + done(2); +} diff --git a/src/shortcutkeyeditwin.h b/src/shortcutkeyeditwin.h index 6d2ba66..2c95de9 100755 --- a/src/shortcutkeyeditwin.h +++ b/src/shortcutkeyeditwin.h @@ -17,6 +17,7 @@ public: private slots: void slot_ok(); + void on_delete(); private: Ui::ShortcutKeyEditWinClass ui; diff --git a/src/shortcutkeyeditwin.ui b/src/shortcutkeyeditwin.ui index 98186a4..996e9e6 100755 --- a/src/shortcutkeyeditwin.ui +++ b/src/shortcutkeyeditwin.ui @@ -14,18 +14,6 @@ ShortcutKeyEditWin - - 3 - - - 3 - - - 3 - - - 3 - @@ -57,19 +45,26 @@ - + Ok - + Cancel + + + + Delete + + + @@ -78,14 +73,14 @@ - pushButton_2 + cancelBt clicked() ShortcutKeyEditWinClass reject() - 388 - 103 + 448 + 88 414 @@ -94,14 +89,14 @@ - pushButton + okBt clicked() ShortcutKeyEditWinClass slot_ok() - 153 - 95 + 163 + 88 186 @@ -109,8 +104,26 @@ + + deleteBt + clicked() + ShortcutKeyEditWinClass + on_delete() + + + 332 + 111 + + + 311 + 130 + + + slot_ok() + on_reset() + on_delete() diff --git a/src/shortcutkeymgr.cpp b/src/shortcutkeymgr.cpp index 601ade5..3a2507a 100755 --- a/src/shortcutkeymgr.cpp +++ b/src/shortcutkeymgr.cpp @@ -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(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 !")); } -} \ No newline at end of file +} diff --git a/src/shortcutkeymgr.ui b/src/shortcutkeymgr.ui index a4f550b..cf6ba84 100755 --- a/src/shortcutkeymgr.ui +++ b/src/shortcutkeymgr.ui @@ -57,6 +57,9 @@ QAbstractItemView::NoEditTriggers + + false + Function diff --git a/src/styleset.cpp b/src/styleset.cpp index 55bedb7..d4162c8 100755 --- a/src/styleset.cpp +++ b/src/styleset.cpp @@ -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(); -} \ No newline at end of file +} + +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; + } +} diff --git a/src/styleset.h b/src/styleset.h index 223e956..564b0a0 100755 --- a/src/styleset.h +++ b/src/styleset.h @@ -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; }; diff --git a/src/texteditsetwin.cpp b/src/texteditsetwin.cpp index 10d70a7..78d82bc 100755 --- a/src/texteditsetwin.cpp +++ b/src/texteditsetwin.cpp @@ -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(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() { diff --git a/src/texteditsetwin.h b/src/texteditsetwin.h index 417fe60..093331d 100755 --- a/src/texteditsetwin.h +++ b/src/texteditsetwin.h @@ -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 };