1.23.2 发布,代码整体合入

This commit is contained in:
爬山虎 2023-02-26 14:10:35 +08:00
parent 079483ab87
commit aaf7010cb2
54 changed files with 4054 additions and 1974 deletions

View File

@ -1,90 +0,0 @@
cmake_minimum_required(VERSION 3.16)
project(NotePad-- VERSION 1.22.0)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets Concurrent Network PrintSupport XmlPatterns)
# qscint
add_subdirectory(${PROJECT_SOURCE_DIR}/src/qscint)
#
# helloworld
add_subdirectory(${PROJECT_SOURCE_DIR}/src/plugin/helloworld)
# winUNICODETCHAR
if(CMAKE_HOST_WIN32)
add_definitions(-D_UNICODE -DUNICODE)
endif()
if(${PLUGIN_EN})
if(${PLUGIN_EN} STREQUAL on)
add_definitions(-DNO_PLUGIN=1)
endif(${PLUGIN_EN})
endif()
file(GLOB UI_SRC ${PROJECT_SOURCE_DIR}/src/*.ui)
set(UI_SRC ${UI_SRC} ${PROJECT_SOURCE_DIR}/src/cceditor/ccnotepad.ui)
aux_source_directory(${PROJECT_SOURCE_DIR}/src SRC)
aux_source_directory(${PROJECT_SOURCE_DIR}/src/cceditor SRC)
if(CMAKE_HOST_WIN32)
# WIN32
list(APPEND WIN_RCS ${PROJECT_SOURCE_DIR}/src/RealCompareToMinGw.rc)
add_executable(${PROJECT_NAME} WIN32 ${WIN_RCS} ${SRC} ${UI_SRC} ${PROJECT_SOURCE_DIR}/src/RealCompare.qrc)
else()
add_executable(${PROJECT_NAME} ${SRC} ${UI_SRC} ${PROJECT_SOURCE_DIR}/src/RealCompare.qrc)
endif()
target_include_directories(${PROJECT_NAME} PRIVATE
${PROJECT_SOURCE_DIR}/src
${PROJECT_SOURCE_DIR}/src/cceditor
${PROJECT_SOURCE_DIR}/src/qscint/src
${PROJECT_SOURCE_DIR}/src/qscint/src/Qsci
${PROJECT_SOURCE_DIR}/src/qscint/scintilla/src
${PROJECT_SOURCE_DIR}/src/qscint/scintilla/include
${PROJECT_SOURCE_DIR}/src/qscint/scintilla/lexlib
${PROJECT_SOURCE_DIR}/src/qscint/scintilla/boostregex
)
target_link_libraries(${PROJECT_NAME} qscint Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Concurrent Qt5::Network Qt5::PrintSupport Qt5::XmlPatterns)
# set(PROJECT_BINARY_DIR "${PROJECT_BINARY_DIR}/bin")
# set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
if(CMAKE_HOST_UNIX)
install(
TARGETS ${PROJECT_NAME}
DESTINATION "bin"
)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/src/linux/usr
DESTINATION "/")
include(${PROJECT_SOURCE_DIR}/cmake/deb_package_config.cmake)
include(CPack)
elseif(CMAKE_HOST_WIN32)
install(TARGETS ${PROJECT_NAME}
DESTINATION "/")
install(DIRECTORY ${PROJECT_SOURCE_DIR}/build/bin/
DESTINATION "/")
#
set(CPACK_PACKAGE_NAME "NotePad--")
set(CPACK_PACKAGE_DESCRIPTION "NotePad--")
set(CPACK_PACKAGE_COPYRIGHT "Copyright (c) 2023")
set(CPACK_PACKAGE_VERSION "1.22.0")
set(CPACK_PACKAGE_VERSION_MAJOR "1")
set(CPACK_PACKAGE_VERSION_MINOR "22")
set(CPACK_PACKAGE_VERSION_PATCH "0")
include(${PROJECT_SOURCE_DIR}/cmake/nsis_package_config.cmake)
include(CPack)
endif()

View File

@ -1,17 +0,0 @@
UNAME:=WIN32
UNAME:=$(shell uname)
# Win下使用Git Bash运行make
ifeq ($(UNAME), Linux)
all:linux
linux:
make -f linux.mk package
else
all:
make -f win.mk all
msvc:
make -f win.mk msvc
mingw:
make -f win.mk mingw
endif

View File

@ -6,7 +6,7 @@
这是一个使用C++编写的文本编辑器Notepad--,可以支持Win/Linux/Mac平台。
我们的目标是要进行文本编辑类软件的国产可替代重点在国产Uos系统、Mac 系统上发展。
我们的目标是要进行文本编辑类软件的国产可替代重点在国产Uos/Linux系统、Mac 系统上发展。
一个支持windows/linux/mac的文本编辑器目标是要国产替换同类软件来自中国。
@ -30,49 +30,8 @@ NDD已初步推出插件编写功能希望广大的CPP/QT开发者加入我
![输入图片说明](6688.png)
## 编译
见build目录下文档 linux开源编译及下载说明.txt
**CMake工具链编译说明:**
- Ubuntu/Debian
1. 安装编译环境 `sudo apt-get install g++ make cmake`
1. 安装qt工具和库 `sudo apt-get install qtbase5-dev qt5-qmake qtbase5-dev-tools libqt5printsupport5 libqt5xmlpatterns5-dev `
1. 配置 `cmake -B build -DCMAKE_BUILD_TYPE=Release`
1. 编译 `cd build && make -j`
1. 打包 `cpack`
- ArchLinux
1. 安装编译环境 `sudo pacman -S gcc cmake make ninja`
1. 安装 qt 工具和库 `sudo pacman -S qt5-tools qt5-base qt5-xmlpatterns`
1. 配置 `cmake -S . -Bbuild -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -W no-dev`
1. 编译 `ninja -C build && ninja -C build install`
1. 打包: 使用 [AUR/notepad---git](https://aur.archlinux.org/packages/notepad---git) `yay -S notepad---git`
1. 安装:
- 预编译包添加 [ArchLinuxCN/notepad---git](https://github.com/archlinuxcn/repo) 镜像 `yay -S archlinuxcn/notepad---git`
- 预编译包 [Debuginfod/notepad---git-debug](https://wiki.archlinux.org/title/Debuginfod) 包 `yay -S archlinuxcn/notepad---git-debug`
- openSUSE Tumbleweed
1. 安装编译环境和Qt工具库 `sudo zypper in -t pattern devel_C_C++ devel_basis devel_qt5 `
1. 配置 `cmake -B build -DCMAKE_BUILD_TYPE=Release `
1. 编译 `cd build && make -j `
1. 打包使用 OBS (Open Build Service)
**Qt工程编译说明**
1使用qtcreator 或 vs 先打开qscint/src/qscintilla.pro 。先编译出这个qscintlla的依赖库。
2再打开RealCompare.pro 加载后编译。
3由于编译的平台较多涉及windows/linux/mac有任何编译问题还请加qq群 959439826 。欢迎广大网友实现新功能后提交代码给我们。
代码上线不久,删除了商业的对比功能和注册功能(这部分有商业原因,请理解),除此以外,所有功能全部保留。
4Arch Linux 及其衍生版可以通过 AUR 仓库安装:[notepad---git](https://aur.archlinux.org/packages/notepad---git)
```
yay -S notepad---git
```
## 联络方式
QQ群959439826 用户群做NDD的问题反馈、功能建议等。
@ -85,6 +44,6 @@ QQ群 616606091 开发群建议懂CPP/QT、愿意参与NDD项目代码贡献
![输入图片说明](png/6.png)
![输入图片说明](png/%E6%88%AA%E5%B1%8F2023-02-26%2011.41.20.png)
![Mac系统运行图](png/%E6%88%AA%E5%B1%8F2023-02-26%2011.41.20.png)
![输入图片说明](png/%E6%88%AA%E5%B1%8F2023-02-26%2011.45.48.png)
![Mac系统文件对比图](png/%E6%88%AA%E5%B1%8F2023-02-26%2011.45.48.png)

View File

@ -1,15 +0,0 @@
## 第三方依赖
## 源码依赖
- [[GPL v3](src/qscint/LICENSE)] [QScintilla](https://riverbankcomputing.com/software/qscintilla/intro)
- [GPL v3]
- [boostregex](src/qscint/scintilla/boostregex)
- [rgba_icons.h](src/rgba_icons.h)
- [xmlMatchedTagsHighlighter.cpp](src/qscint/src/xmlMatchedTagsHighlighter.cpp)
- [xmlMatchedTagsHighlighter.h](src/qscint/src/xmlMatchedTagsHighlighter.h)
## 开发、打包时依赖
- [[zlib/libpng](https://nsis.sourceforge.io/License)] [NSIS](https://nsis.sourceforge.io)
打包工具

View File

@ -1,3 +1,34 @@
Ndd V1.23 发布 20230226
功能:
1 希望可以支持xml按照层次折叠和展开操作
2 能否增加自动刷新和滚动文本功能以及手动重新打开文件。提供tailf方式。
3 建议 查找与替换 添加ESC键响应ESC键退出查找替换窗体
4 查找替换没有默认选中
5 新窗口打开的文件,不能再拖放回去
6 无法计算选中内容的行数
7 json 格式化提供json格式化插件命令行插件等
8 高清屏幕适配一些列问题
9 能否支持在软件内设置文件关联。安装包支持
10 希望记录一下关闭软件时的标签页
11 增加md5/sha计算
改进:
1 新建文件缩进参考线会消失
2 XML 文件 注释部分文字偏小看不清
3 关闭编辑器之后,编辑器的设置窗口还在,如果多次就会有下图的样子
4 Ctrl+F时建议文本框内的内容默认选中
5 建议程序打开时tab页为最后关闭时tab页
6 选中多个文件右键打开时会启动多个窗口,而非多个标签,
7 双击英文句点全部文本都会高亮
8 command只能-缩小,+没用 不能放大
9 CTRL+F搜索框丢失焦点后再用快捷键CTRL+F不能自动聚焦
10 已设置的快捷键可以取消
11 希望显示总字数
12 Ctrl+S时并不能删除.swp临时文件建议隐藏.swp文件
13 建议 增加 打开当前文件目录下 命令提示符的功能
14 显示空格的问题
15 鼠标选择文本后高亮
Ndd V1.22 预发布 20230202
1 提供大文本、超大文本打开两种方式;并尽量显示行号。
2 增加ASM语言的语法高亮;增加shell语法高亮。

View File

@ -1,13 +0,0 @@
set(CPACK_GENERATOR "DEB")
set(CPACK_PACKAGE_NAME "notepad--")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "a text editor like notepad++")
set(CPACK_PACKAGE_CONTACT "coconil")
set(CPACK_PACKAGE_VERSION "1.22.0")
set(CPACK_PACKAGE_VERSION_MAJOR "1")
set(CPACK_PACKAGE_VERSION_MINOR "22")
set(CPACK_PACKAGE_VERSION_PATCH "0")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqt5concurrent5,libqt5core5a,libqt5gui5,libqt5network5,libqt5printsupport5,libqt5xmlpatterns5")

View File

@ -1,59 +0,0 @@
set(CPACK_GENERATOR NSIS)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_NAME}")
#
set(CPACK_PACKAGE_CONTACT "XiaoPb")
set(P4_VERSION_INFO_CL_HIGH "0")
set(P4_VERSION_INFO_CL_LOW "0")
# set(CPACK_PACKAGE_VERSION_PATCH "0")
set (CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}")
set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_NAME}V${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
set(CPACK_NSIS_PACKAGE_NAME "${CPACK_PACKAGE_NAME}V${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL "ON")
set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}/src/Resources/ico/txt (9).ico")
set(CPACK_NSIS_MUI_UNIICON "${CMAKE_CURRENT_SOURCE_DIR}/src/Resources/ico/txt (9).ico")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License")
set (CPACK_PACKAGE_EXECUTABLES "${PROJECT_NAME}" "${PROJECT_NAME}" )
#
set (CPACK_NSIS_DEFINES "
${CPACK_NSIS_DEFINES}
VIProductVersion ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${P4_VERSION_INFO_CL_HIGH}.${P4_VERSION_INFO_CL_LOW}
VIFileVersion ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${P4_VERSION_INFO_CL_HIGH}.${P4_VERSION_INFO_CL_LOW}
VIAddVersionKey /LANG=0 \\\"ProductName\\\" \\\"${CPACK_PACKAGE_NAME}\\\"
VIAddVersionKey /LANG=0 \\\"ProductVersion\\\" \\\"v${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}${CPACK_PACKAGE_BUILD_TYPE_REVISION}\\\"
VIAddVersionKey /LANG=0 \\\"Comments\\\" \\\"${CPACK_PACKAGE_DESCRIPTION}\\\"
VIAddVersionKey /LANG=0 \\\"CompanyName\\\" \\\"${CPACK_PACKAGE_VENDOR}\\\"
VIAddVersionKey /LANG=0 \\\"LegalCopyright\\\" \\\"${CPACK_PACKAGE_COPYRIGHT}\\\"
VIAddVersionKey /LANG=0 \\\"FileDescription\\\" \\\"${CPACK_PACKAGE_NAME} Installer\\\"
VIAddVersionKey /LANG=0 \\\"FileVersion\\\" \\\"v${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}${CPACK_PACKAGE_BUILD_TYPE_REVISION}\\\"
"
)
#
set (CPACK_NSIS_EXTRA_INSTALL_COMMANDS "
WriteRegStr SHCTX \\\"Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\App Paths\\\\${PROJECT_NAME}\\\" \\\"\\\" \\\"$INSTDIR\\\\bin\\\\${PROJECT_NAME}.exe\\\"
WriteRegStr SHCTX \\\"Software\\\\Classes\\\\${PROJECT_NAME}\\\\shell\\\" \\\"\\\" \\\"open\\\"
WriteRegStr SHCTX \\\"Software\\\\Classes\\\\${PROJECT_NAME}\\\\shell\\\\open\\\\command\\\" \\\"\\\" \\\"$\\\\\\\"$INSTDIR\\\\bin\\\\${PROJECT_NAME}.exe$\\\\\\\" $\\\\\\\"%1$\\\\\\\"\\\"
WriteRegStr SHCTX \\\"Software\\\\Classes\\\\.txt\\\\OpenWithProgids\\\" \\\"${PROJECT_NAME}\\\" \\\"\\\"
WriteRegStr SHCTX \\\"Software\\\\Classes\\\\*\\\\shell\\\\${PROJECT_NAME}\\\" \\\"\\\" \\\"Edit with ${PROJECT_NAME}\\\"
WriteRegStr SHCTX \\\"Software\\\\Classes\\\\*\\\\shell\\\\${PROJECT_NAME}\\\" \\\"Icon\\\" \\\"$INSTDIR\\\\bin\\\\${PROJECT_NAME}.exe\\\"
WriteRegStr SHCTX \\\"Software\\\\Classes\\\\*\\\\shell\\\\${PROJECT_NAME}\\\\command\\\" \\\"\\\" \\\"$\\\\\\\"$INSTDIR\\\\bin\\\\${PROJECT_NAME}.exe$\\\\\\\" $\\\\\\\"%1$\\\\\\\"\\\"
")
#
set (CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "
Delete \\\"$DESKTOP\\\\${PROJECT_NAME}.lnk\\\"
Delete \\\"$SMPROGRAMS\\\\${PROJECT_NAME}.lnk\\\"
DeleteRegKey SHCTX \\\"Software\\\\Classes\\\\*\\\\shell\\\\${PROJECT_NAME}\\\"
DeleteRegKey SHCTX \\\"Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\App Paths\\\\bin\\\\${PROJECT_NAME}.exe\\\" \\\"\\\" \\\"$INSTDIR\\\\bin\\\\${PROJECT_NAME}.exe\\\"
DeleteRegKey SHCTX \\\"Software\\\\${PROJECT_NAME}\\\"
DeleteRegValue SHCTX \\\"Software\\\\Classes\\\\.txt\\\\OpenWithProgids\\\" \\\"${PROJECT_NAME}\\\"
DeleteRegKey SHCTX \\\"Software\\\\Classes\\\\${PROJECT_NAME}\\\"
")

View File

@ -1,42 +0,0 @@
CPUS=$(shell nproc)
CALENDAR=$(shell date '+%Y%m%d')
OSID=$(shell lsb_release -si)
OSRELEASE=$(shell lsb_release -sr)
SUFFIX=
ifneq ("$(OSID)", "")
SUFFIX=_$(OSID)$(OSRELEASE)
endif
PROJECT_NAME=notepad--
PACKAGE_NAME=com.hmja.notepad
all:
mkdir -p build
cd build && cmake ..
cd build && make -j$(CPUS)
run: all
exec $(shell find build/ -maxdepth 1 -type f -executable | grep $(PROJECT_NAME))
debug:
mkdir -p build
cd build && cmake -DCMAKE_BUILD_TYPE=Debug ..
cd build && make -j$(CPUS)
release:
mkdir -p build
cd build && cmake -DCMAKE_BUILD_TYPE=Release -DPLUGIN_EN=off -DPACKAGE_SUFFIX="$(SUFFIX)" ..
cd build && make -j$(CPUS)
package: release
cd build && make package
tree build/_CPack_Packages/Linux/DEB/$(PROJECT_NAME)-*
# dpkg-deb --contents build/$(PROJECT_NAME)$(SUFFIX).deb
builddeps:
cd build && make builddeps
cpus:
@echo "CPU数量: $(CPUS)"

View File

@ -132,7 +132,6 @@ CODE_ID CmpareMode::getTextFileEncodeType(uchar* fileFpr, int fileLength, QStrin
//是否跳过前面的LE头。默认不跳过。只有文件块开头第一块才需要跳过。
bool CmpareMode::tranUnicodeLeToUtf8Bytes(uchar* fileFpr, const int fileLength, QString &outUtf8Bytes, bool isSkipHead)
{
int lineNums = 0;
CODE_ID code = CODE_ID::UNICODE_LE;
int lineStartPos = (isSkipHead ? 2:0); //uicode_le前面有2个特殊标识故跳过2

View File

@ -145,5 +145,7 @@
<file>Resources/img/expand.png</file>
<file>Resources/img/fold.png</file>
<file>qss/common.qss</file>
<file>notepad/tailf.png</file>
<file>Resources/edit/styledeepblue/tailf.png</file>
</qresource>
</RCC>

Binary file not shown.

View File

@ -1,8 +1,9 @@
#include "batchfindreplace.h"
#include "batchfindreplace.h"
#include "scintillaeditview.h"
#include "ccnotepad.h"
#include "progresswin.h"
#include "nddsetting.h"
#include "ctipwin.h"
#include <QTableWidgetItem>
#include <QFileDialog>
@ -31,7 +32,7 @@ void BatchFindReplace::setTabWidget(QTabWidget* editTabWidget)
m_editTabWidget = editTabWidget;
}
//自动调整当前窗口的状态,如果发生了变化,则需要认定为是首次查找
//自动调整当前窗口的状态,如果发生了变化,则需要认定为是首次查找
QWidget* BatchFindReplace::autoAdjustCurrentEditWin()
{
QWidget* pw = m_editTabWidget->currentWidget();
@ -53,7 +54,7 @@ void BatchFindReplace::appendToFindTable(QString findKeyword)
ui.findReplaceTable->setItem(rNum, 1, new QTableWidgetItem());
}
//这里不能追加而是插入即对应的Item必须已经存在。否则不插入
//这里不能追加而是插入即对应的Item必须已经存在。否则不插入
void BatchFindReplace::insertToReplaceTable(int row, QString replaceKeyword)
{
QTableWidgetItem* item = ui.findReplaceTable->item(row, 1);
@ -97,11 +98,11 @@ void BatchFindReplace::appendToFindReplaceTable(QStringList& findKeyword)
bool BatchFindReplace::tranInputKeyword(QString& findKeyWord, QStringList& outputKeyWordList)
{
//把空白字符,空格或者\t \r\n 等字符进行替换为空格
//把空白字符,空格或者\t \r\n 等字符进行替换为空格
QRegExp re("\\s");
findKeyWord.replace(re, QString(" "));
//再进行空格分隔处理
//再进行空格分隔处理
outputKeyWordList = findKeyWord.split(" ");
if (outputKeyWordList.size() > 20000)
@ -110,7 +111,7 @@ bool BatchFindReplace::tranInputKeyword(QString& findKeyWord, QStringList& outpu
return false;
}
//删除每一个空的元素
//删除每一个空的元素
for (int i = outputKeyWordList.size() - 1; i >= 0; --i)
{
if (outputKeyWordList[i].trimmed().isEmpty())
@ -166,61 +167,48 @@ void BatchFindReplace::on_freshBtClick()
}
}
//进行批量查找工作
//进行批量查找工作
void BatchFindReplace::on_findBtClick()
{
if (m_mainNotepad != nullptr && m_mainNotepad)
{
int rowNums = ui.findReplaceTable->rowCount();
if (rowNums == 0)
{
CTipWin::showTips(this, tr("Please fresh first !"), 1200);
return;
}
ProgressWin* loadFileProcessWin = new ProgressWin(this);
loadFileProcessWin->setWindowModality(Qt::WindowModal);
loadFileProcessWin->info(tr("total %1 keyword, please wait ...").arg(rowNums));
loadFileProcessWin->setTotalSteps(rowNums);
loadFileProcessWin->show();
int foundTimes = 0;
QStringList findKeyList;
for (int i = 0; i < rowNums; ++i)
{
QTableWidgetItem* item = ui.findReplaceTable->item(i, 0);
if (item != nullptr && !item->text().isEmpty())
{
if (loadFileProcessWin->isCancel())
{
break;
}
foundTimes += m_mainNotepad->findAtBack(item->text());
loadFileProcessWin->moveStep();
QCoreApplication::processEvents();
findKeyList.append(item->text());
}
}
delete loadFileProcessWin;
foundTimes = m_mainNotepad->findAtBack(findKeyList);
ui.statusBar->showMessage(tr("Batch Find Finished! total %1 found.").arg(foundTimes),10000);
}
}
//进行批量替换工作
//进行批量替换工作
void BatchFindReplace::on_replaceBtClick()
{
if (m_mainNotepad != nullptr && m_mainNotepad)
if (m_mainNotepad != nullptr)
{
int rowNums = ui.findReplaceTable->rowCount();
if (rowNums == 0)
{
CTipWin::showTips(this, tr("Please fresh first !"), 1200);
return;
}
int replaceTimes = 0;
QStringList findKeyList;
QStringList replaceKeyList;
@ -241,9 +229,9 @@ void BatchFindReplace::on_replaceBtClick()
}
}
}
replaceTimes = m_mainNotepad->replaceAtBack(findKeyList, replaceKeyList);
m_mainNotepad->replaceAtBack(findKeyList, replaceKeyList);
ui.statusBar->showMessage(tr("Batch Replace Finished, total Replace %1 times !").arg(replaceTimes), 10000);
ui.statusBar->showMessage(tr("Batch Replace Finished, total Replace %1 times !").arg(findKeyList.size()), 10000);
}
}
@ -306,9 +294,9 @@ void BatchFindReplace::on_import()
QFileDialog fd(this, QString(), CCNotePad::s_lastOpenDirPath);
fd.setFileMode(QFileDialog::ExistingFile);
if (fd.exec() == QDialog::Accepted) //如果成功的执行
if (fd.exec() == QDialog::Accepted) //如果成功的执行
{
QStringList fileNameList = fd.selectedFiles(); //返回文件列表的名称
QStringList fileNameList = fd.selectedFiles(); //返回文件列表的名称
QFileInfo fi(fileNameList[0]);
QSettings setting(fi.filePath(), QSettings::IniFormat);
@ -332,40 +320,24 @@ void BatchFindReplace::on_mark()
int rowNums = ui.findReplaceTable->rowCount();
if (rowNums == 0)
{
CTipWin::showTips(this, tr("Please fresh first !"), 1200);
return;
}
int markTimes = 0;
ProgressWin* loadFileProcessWin = new ProgressWin(this);
loadFileProcessWin->setWindowModality(Qt::WindowModal);
loadFileProcessWin->info(tr("total %1 keyword, please wait ...").arg(rowNums));
loadFileProcessWin->setTotalSteps(rowNums);
loadFileProcessWin->show();
QStringList findKeyList;
for (int i = 0; i < rowNums; ++i)
{
QTableWidgetItem* item = ui.findReplaceTable->item(i, 0);
if (item != nullptr && !item->text().isEmpty())
{
if (loadFileProcessWin->isCancel())
{
break;
}
markTimes += m_mainNotepad->markAtBack(item->text());
loadFileProcessWin->moveStep();
QCoreApplication::processEvents();
findKeyList.append(item->text());
}
}
delete loadFileProcessWin;
markTimes = m_mainNotepad->markAtBack(findKeyList);
ui.statusBar->showMessage(tr("Batch Mark Finished, total Mark %1 times !").arg(markTimes), 10000);
}
}

View File

@ -1,4 +1,5 @@
#include "bigfilemessage.h"
#include "bigfilemessage.h"
#include "nddsetting.h"
BigFileMessage::BigFileMessage(QWidget *parent)
: QDialog(parent), m_result(-1)
@ -41,19 +42,19 @@ void BigFileMessage::slot_okBt()
{
if (ui.textMode->isChecked())
{
m_result = TXT_TYPE;//普通文本
m_result = TXT_TYPE;//普通文本
}
else if(ui.bigTextMode->isChecked())
{
m_result = BIG_TEXT_RO_TYPE; //小于8G的大文本
m_result = BIG_TEXT_RO_TYPE; //小于8G的大文本
}
else if (ui.superBigTextMode->isChecked())
{
m_result = SUPER_BIG_TEXT_RO_TYPE;//8G以上的大文本
m_result = SUPER_BIG_TEXT_RO_TYPE;//8G以上的大文本
}
else if (ui.hexMode->isChecked())
{
m_result = HEX_TYPE;//二进制
m_result = HEX_TYPE;//二进制
}
done(m_result);
}
@ -62,4 +63,4 @@ void BigFileMessage::slot_cancelBt()
{
m_result = -1;
done(m_result);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -35,6 +35,10 @@ struct HexFileMgr;
struct TextFileMgr;
struct BigTextEditFileMgr;
static const char* Tail_Thread = "tailthread";
//编码类型,int
static const char* Edit_Text_Code = "code";
enum OpenAttr {
Text = 1,
@ -100,18 +104,7 @@ public:
void initLexerNameToIndex();
static LexerInfo getLangLexerIdByFileExt(QString filePath);
#if 0
static QFont & getTxtFont()
{
return s_txtFont;
}
static QFont & getProLangFont()
{
return s_proLangFont;
}
#endif
bool openFile(QString filePath, int lineNum=-1);
bool tryRestoreFile(QString filePath);
@ -143,8 +136,8 @@ public:
void clearHighlightWord(QString signWord, ScintillaEditView* pEdit = nullptr);
bool closeFileByEditWidget(QWidget* pEdit);
void showChangePageTips(QWidget* pEdit);
int markAtBack(QString keyword);
int findAtBack(QString keyword);
int markAtBack(QStringList& keyword);
int findAtBack(QStringList& keyword);
int replaceAtBack(QStringList& keyword, QStringList& replace);
void updateThemes();
@ -154,10 +147,15 @@ public:
void changeMarkColor(int sytleId);
void setUserDefShortcutKey(int shortcutId);
QtLangSet* getLangSet();
signals:
void signSendRegisterKey(QString key);
void signRegisterReplay(int code);
void signLinkNetServer();
#ifdef Q_OS_WIN
void tailFileChange(ScintillaEditView*);
#endif
public slots:
void slot_changeChinese();
void slot_changeEnglish();
@ -171,8 +169,10 @@ public slots:
void slot_actionCloseNonCurDoc();
void slot_actionCloseLeftAll();
void slot_actionCloseRightAll();
void slot_quit(bool);
void slot_closeAllFile(bool);
void slot_batch_convert();
void slot_batch_rename();
@ -183,12 +183,15 @@ public slots:
void slot_viewLexerChange(QString tag);
void slot_findInDir();
void slot_showFileInExplorer();
#ifdef Q_OS_WIN
void slot_showCmdInExplorer();
#endif
void slot_wordHighlight();
void slot_clearWordHighlight();
void slot_clearMark();
void slot_zoomValueChange();
void on_quitActiveWindow();
protected:
void closeEvent(QCloseEvent *event) override;
@ -260,6 +263,7 @@ private slots:
void slot_compareDir();
void slot_binCompare();
void slot_tabBarClicked(int index);
void on_tabBarDoubleClicked(int index);
void slot_reOpenTextMode();
void slot_reOpenHexMode();
void slot_selectLeftFile();
@ -338,8 +342,9 @@ private slots:
void slot_showToolBar(bool);
void slot_dynamicLoadToolMenu();
void slot_batchFind();
#ifdef NO_PLUGIN
void on_loadReceneFile();
void slot_pluginMgr();
#ifdef NO_PLUGIN
void onPlugWork(bool check);
void sendParaToPlugin(NDD_PROC_DATA& procData);
#endif
@ -347,6 +352,11 @@ private slots:
void slot_langFileSuffix();
void slot_shortcutManager();
void on_lineEndChange(int index);
void on_tailfile(bool isOn);
#ifdef Q_OS_WIN
void on_roladFile(ScintillaEditView* pEdit);
#endif
void on_md5hash();
private:
void initFindResultDockWin();
@ -376,6 +386,7 @@ private:
void syncCurDocEncodeToMenu(QWidget * curEdit);
void syncCurDocLineEndStatusToMenu(QWidget * curEdit);
void syncCurDocLexerToMenu(QWidget* pEdit);
void syncCurDocTailfToMenu(QWidget* curEdit);
void cmpSelectFile();
@ -386,7 +397,7 @@ private:
void removeWatchFilePath(QString filePath);
bool checkRoladFile(ScintillaEditView * pEdit);
void reloadEditFile(ScintillaEditView * pEidt);
void reloadEditFile(ScintillaEditView * pEidt, bool isTailfOn = false);
int initFindWindow(FindTabIndex type= FIND_TAB);
void setToFileRightMenu();
@ -445,6 +456,7 @@ private:
void init_toolsMenu();
void changeBlankShowStatus(int showBlank);
void syncBlankShowStatus();
void openFileInNewWin(int index);
#ifdef NO_PLUGIN
void loadPluginLib();
void loadPluginProcs(QString strLibDir, QMenu* pMenu);
@ -453,7 +465,12 @@ private:
void setUserDefShortcutKey();
void setNormalTextEditInitPro(ScintillaEditView* pEdit, QString filePath, CODE_ID code, RC_LINE_FORM lineEnd, bool isReadOnly, bool isModifyed);
void registerCommentShortKey(int type, QKeySequence& keySeq);
void dealRecentFileMenuWhenColseFile(QString closeFilePath);
void registerFoldShortKey(int type, QKeySequence& keySeq, bool isFold);
void doFold(int type, bool mode);
void doComment(int type);
void tailfile(bool isOn, ScintillaEditView* pEdit);
private:
Ui::CCNotePad ui;
@ -478,11 +495,15 @@ private:
QActionGroup *m_pLexerActGroup;
QActionGroup *m_pIconSize;
#if 0
QAction* m_quitAction;
#endif
//关闭时,询问保存文件,用户点击了取消,此时不能走关闭程序
//设置一个标志记录该状态,确定最终是否要退出
bool m_isQuitCancel;
//是否主窗口。可以打开多个,但是只有第一个是主窗口
bool m_isMainWindows;
QMap<QString, LexerNode> m_lexerNameToIndex;
@ -493,12 +514,13 @@ private:
QString m_cmpRightFilePath;
QPointer<QMainWindow> m_pFindWin;
QPointer <QWidget> m_columnEditWin;
QPointer<QWidget> m_columnEditWin;
QPointer<QMainWindow> m_langSetWin;
QPointer<QWidget> m_optionsView;
QSharedMemory* m_shareMem;
//是否主窗口。可以打开多个,但是只有第一个是主窗口
bool m_isMainWindows;
//最近打开的对比文件和目录列表。做一个环形区
//保存在数据库中
@ -511,6 +533,7 @@ private:
QAction* m_openInNewWinAct;
QAction* m_showFileDirAct;
QAction* m_showCmdAct;
QAction* m_openWithText;
QAction* m_openWithHex;
@ -563,6 +586,7 @@ private:
QToolButton* m_wordwrap;
QToolButton* m_allWhite;
QToolButton* m_indentGuide;
QToolButton* m_tailf;
QToolButton* m_preHexPage;
QToolButton* m_nextHexPage;
QToolButton* m_gotoHexPage;
@ -585,6 +609,8 @@ private:
bool m_isInitBookMarkAct;
bool m_isRecentFileLoaded;
QList<QAction*>m_styleMarkActList;
QList<NDD_PROC_DATA> m_pluginList;

View File

@ -57,9 +57,6 @@
<height>22</height>
</size>
</property>
<property name="elideMode">
<enum>Qt::ElideNone</enum>
</property>
<property name="usesScrollButtons">
<bool>true</bool>
</property>
@ -69,6 +66,9 @@
<property name="movable">
<bool>true</bool>
</property>
<property name="tabBarAutoHide">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
@ -506,6 +506,7 @@
<property name="title">
<string>T&amp;ools</string>
</property>
<addaction name="actionMd5_Sha"/>
</widget>
<widget class="QMenu" name="menuPlugin">
<property name="title">
@ -2060,6 +2061,11 @@
<string>Plugin Manager</string>
</property>
</action>
<action name="actionMd5_Sha">
<property name="text">
<string>Md5/Sha</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>
@ -3474,6 +3480,22 @@
</hint>
</hints>
</connection>
<connection>
<sender>actionMd5_Sha</sender>
<signal>triggered()</signal>
<receiver>CCNotePad</receiver>
<slot>on_md5hash()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>728</x>
<y>394</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>slot_actionNewFile_toggle(bool)</slot>
@ -3577,5 +3599,6 @@
<slot>slot_showWebAddr(bool)</slot>
<slot>slot_langFileSuffix()</slot>
<slot>slot_shortcutManager()</slot>
<slot>on_md5hash()</slot>
</slots>
</ui>

View File

@ -456,7 +456,10 @@ int FileManager::loadFileForSearch(ScintillaEditView* editView, QString filePath
CODE_ID fileTextCode = CODE_ID::UNKOWN;
CmpareMode::scanFileOutPut(fileTextCode, filePath, outputLineInfoVec, maxLineSize, charsNums, isHexFile);
fileTextCode = CmpareMode::scanFileOutPut(fileTextCode, filePath, outputLineInfoVec, maxLineSize, charsNums, isHexFile);
//20230218 这里必须指明一下编码,否则后续会导致编码被修改
editView->setProperty(Edit_Text_Code, fileTextCode);
if (isHexFile)
{

View File

@ -1,4 +1,4 @@
#include "ctipwin.h"
#include "ctipwin.h"
#include <QTimer>
@ -34,3 +34,20 @@ void CTipWin::slot_delayClose()
close();
}
void CTipWin::showTips(QWidget* parent, QString text, int sec)
{
if (parent != nullptr)
{
CTipWin* pWin = new CTipWin();
pWin->setTipText(text);
pWin->setAttribute(Qt::WA_DeleteOnClose);
pWin->showMsg(sec);
QPoint pos = parent->pos();
QSize size = parent->size();
QPoint newPos(pos.x() + 10, pos.y() + size.height() - 20);
pWin->move(newPos);
}
}

View File

@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <QWidget>
#include "ui_ctipwin.h"
@ -12,6 +12,7 @@ public:
~CTipWin();
void setTipText(QString text);
void showMsg(int sec = 2000);
static void showTips(QWidget* parent, QString text, int sec);
private slots:
void slot_delayClose();

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>295</width>
<height>69</height>
<height>35</height>
</rect>
</property>
<property name="maximumSize">

48
src/dectfilechanges.cpp Executable file
View File

@ -0,0 +1,48 @@
#include "dectfilechanges.h"
#ifdef WIN32
DectFileChanges::DectFileChanges()
{
_szFile = NULL;
_dwNotifyFilter = 0;
}
DectFileChanges::~DectFileChanges()
{
}
BOOL DectFileChanges::DetectChanges() {
WIN32_FILE_ATTRIBUTE_DATA fInfo;
BOOL rValue = FALSE;
::GetFileAttributesEx(_szFile, GetFileExInfoStandard, &fInfo);
if ((_dwNotifyFilter & FILE_NOTIFY_CHANGE_SIZE) && (fInfo.nFileSizeHigh != _lastFileInfo.nFileSizeHigh || fInfo.nFileSizeLow != _lastFileInfo.nFileSizeLow)) {
rValue = TRUE;
}
if ((_dwNotifyFilter & FILE_NOTIFY_CHANGE_LAST_WRITE) && (fInfo.ftLastWriteTime.dwHighDateTime != _lastFileInfo.ftLastWriteTime.dwHighDateTime || fInfo.ftLastWriteTime.dwLowDateTime != _lastFileInfo.ftLastWriteTime.dwLowDateTime)) {
rValue = TRUE;
}
_lastFileInfo = fInfo;
return rValue;
}
void DectFileChanges::AddFile(LPCTSTR szFile, DWORD dwNotifyFilter)
{
_szFile = szFile;
_dwNotifyFilter = dwNotifyFilter;
::GetFileAttributesEx(szFile, GetFileExInfoStandard, &_lastFileInfo);
}
void DectFileChanges::Terminate()
{
_szFile = NULL;
_dwNotifyFilter = 0;
}
#endif

32
src/dectfilechanges.h Executable file
View File

@ -0,0 +1,32 @@
#pragma once
#ifdef WIN32
#include <stdio.h>
#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN
#endif
//下面NOMINMAX保证std::min不重复定义
#define NOMINMAX
#include <windows.h>
class DectFileChanges
{
public:
DectFileChanges();
~DectFileChanges();
void AddFile(LPCTSTR szDirectory, DWORD dwNotifyFilter);
BOOL DetectChanges();
void Terminate();
private:
LPCTSTR _szFile = nullptr;
DWORD _dwNotifyFilter = 0;
WIN32_FILE_ATTRIBUTE_DATA _lastFileInfo = {};
};
#endif

View File

@ -600,6 +600,9 @@ void FindResultWin::appendResultsToShow(FindRecords* record)
QStandardItem* childItem = new QStandardItem(text);
childItem->setData(QVariant(v.pos), ResultItemPos);
childItem->setData(QVariant(v.end - v.pos), ResultItemLen);
#if defined(Q_OS_MAC)
childItem->setTextAlignment(Qt::AlignVCenter);
#endif
descItem->appendRow(childItem);
}
if (!record->records.isEmpty())
@ -695,6 +698,9 @@ void FindResultWin::appendResultsToShow(QVector<FindRecords*>* record, int hits,
text = tr("<font style='font-size:14px;color:#ffffff'>Line </font><font style='font-size:14px;color:#ff8040'>%1</font> : %2").arg(v.lineNum + 1).arg(richText);
}
QStandardItem* childItem = new QStandardItem(text);
#if defined(Q_OS_MAC)
childItem->setTextAlignment(Qt::AlignVCenter);
#endif
childItem->setData(QVariant(v.pos), ResultItemPos);
childItem->setData(QVariant(v.end - v.pos), ResultItemLen);
descItem->appendRow(childItem);

View File

@ -1,4 +1,4 @@
#include "findwin.h"
#include "findwin.h"
#include "scintillaeditview.h"
#include "ccnotepad.h"
#include "progresswin.h"
@ -12,6 +12,7 @@
#include <QFileDialog>
#include <functional>
#include <BoostRegexSearch.h>
#include <QClipboard>
#include <QDebug>
enum TAB_TYPES {
@ -87,6 +88,7 @@ void FindWin::slot_tabIndexChange(int index)
if (RELPACE_TYPE == type)
{
ui.replaceTextBox->setFocus();
ui.replaceTextBox->lineEdit()->selectAll();
if (ui.replaceTextBox->currentText().isEmpty() && !ui.findComboBox->currentText().isEmpty())
{
@ -99,6 +101,7 @@ void FindWin::slot_tabIndexChange(int index)
else if(FIND_TYPE == type)
{
ui.findComboBox->setFocus();
ui.findComboBox->lineEdit()->selectAll();
if (ui.findComboBox->currentText().isEmpty() && !ui.replaceTextBox->currentText().isEmpty())
{
@ -111,10 +114,12 @@ void FindWin::slot_tabIndexChange(int index)
else if (DIR_FIND_TYPE == type)
{
ui.dirFindWhat->setFocus();
ui.dirFindWhat->lineEdit()->selectAll();
}
else if (MARK_TYPE == type)
{
ui.markTextBox->setFocus();
ui.markTextBox->lineEdit()->selectAll();
}
m_isFindFirst = true;
@ -123,13 +128,20 @@ void FindWin::slot_tabIndexChange(int index)
{
return;
}
}
}
void FindWin::slot_dealFileTypeChange(int state)
{
if (state == Qt::Checked)
{
ui.fileType->setEnabled(true);
if (ui.fileType->text().isEmpty())
{
ui.fileType->setText(ui.fileType->placeholderText());
}
ui.fileType->setFocus();
ui.fileType->selectAll();
}
else
{
@ -142,6 +154,13 @@ void FindWin::slot_skipDirChange(int state)
if (state == Qt::Checked)
{
ui.skipDirNames->setEnabled(true);
if (ui.skipDirNames->text().isEmpty())
{
ui.skipDirNames->setText(ui.skipDirNames->placeholderText());
}
ui.skipDirNames->setFocus();
ui.skipDirNames->selectAll();
}
else
{
@ -169,10 +188,12 @@ void FindWin::setCurrentTab(FindTabIndex index)
if (FIND_TAB == index)
{
ui.findComboBox->setFocus();
ui.findComboBox->lineEdit()->selectAll();
}
else if(REPLACE_TAB == index)
{
ui.replaceTextBox->setFocus();
ui.replaceTextBox->lineEdit()->selectAll();
}
raise();
@ -189,6 +210,32 @@ void FindWin::setFindText(QString &text)
addFindHistory(text);
}
void FindWin::keywordWinGetFouse(FindTabIndex tabIndex)
{
switch (tabIndex)
{
case FIND_TAB:
this->setFocus();
ui.findComboBox->setFocus();
ui.findComboBox->lineEdit()->selectAll();
break;
case REPLACE_TAB:
ui.replaceTextBox->setFocus();
ui.replaceTextBox->lineEdit()->selectAll();
break;
case DIR_FIND_TAB:
ui.dirFindWhat->setFocus();
ui.dirFindWhat->lineEdit()->selectAll();
break;
case MARK_TAB:
ui.markTextBox->setFocus();
ui.markTextBox->lineEdit()->selectAll();
break;
default:
break;
}
}
void FindWin::setReplaceFindText(QString& text)
{
ui.replaceTextBox->setEditText(text);
@ -201,6 +248,13 @@ void FindWin::setDirFindText(QString& text)
addFindHistory(text);
}
void FindWin::setMarkFindText(QString& text)
{
ui.markTextBox->setEditText(text);
addFindHistory(text);
}
void FindWin::disableReplace()
{
ui.tab_replace->setEnabled(false);
@ -575,8 +629,20 @@ void FindWin::updateParameterFromUI()
if (ui.findinfilesTab->currentIndex() == 0)
{
m_forward = (m_isReverseFind ? !m_forward : m_forward);
}
}
#if 0
//开始做了历史记录重复删除的,后面发现时序有问题,暂时不做
void findItemAndRemove(QComboBox* pCombox, QString& text)
{
int index = pCombox->findText(text);
if (index != -1)
{
pCombox->removeItem(index);
}
}
#endif
void FindWin::addFindHistory(QString &text)
{
@ -585,19 +651,55 @@ void FindWin::addFindHistory(QString &text)
{
return;
}
if ((m_findHistory != nullptr) && (-1 == m_findHistory->indexOf(text)))
if (m_findHistory != nullptr)
{
m_findHistory->push_front(text);
int index = m_findHistory->indexOf(text,0);
//已经是最上面一个了,直接返回
if (0 == index)
{
return;
}
//没有直接添加到最前面。不做查找删除重复,一是慢,而是删除会引起信号逻辑时许有误
if (-1 == index)
{
m_findHistory->push_front(text);
ui.findComboBox->insertItem(0, text);
ui.replaceTextBox->insertItem(0, text);
ui.dirFindWhat->insertItem(0, text);
ui.markTextBox->insertItem(0, text);
}
else
{
//有了怎么办,删除旧的,加新的
m_findHistory->removeAt(index);
m_findHistory->push_front(text);
//发现不能只删除旧的有bug一旦删除后查找框乱了被切换到下一个。
ui.findComboBox->removeItem(index);
ui.replaceTextBox->removeItem(index);
ui.dirFindWhat->removeItem(index);
ui.markTextBox->removeItem(index);
ui.findComboBox->insertItem(0, text);
ui.replaceTextBox->insertItem(0, text);
ui.dirFindWhat->insertItem(0, text);
ui.markTextBox->insertItem(0, text);
//发现不能只删除旧的有bug一旦删除后查找框乱了被切换到下一个。
//必须重新设置一下,否则查找框里面字段乱跳到下一个去了
ui.findComboBox->setCurrentIndex(0);
ui.replaceTextBox->setCurrentIndex(0);
ui.dirFindWhat->setCurrentIndex(0);
ui.markTextBox->setCurrentIndex(0);
}
if (m_findHistory->size() >= 15)
{
m_findHistory->takeLast();
}
ui.findComboBox->insertItem(0, text);
ui.replaceTextBox->insertItem(0, text);
ui.dirFindWhat->insertItem(0,text);
ui.markTextBox->insertItem(0, text);
}
}
@ -1048,10 +1150,11 @@ static QString trimmedEnd(QString lineText)
return lineText;
}
void FindWin::addCurFindRecord(ScintillaEditView* pEdit, FindRecords& recordRet,bool isMark)
//getResult:是否提取结果目标字符串。在正则查找时,还是有用的
QString FindWin::addCurFindRecord(ScintillaEditView* pEdit, FindRecords& recordRet,bool isMark, bool getResult)
{
FindRecord aRecord;
QString ret;
//看了源码,当前查找到的结果,是会被选中的。所以可通过选中范围,来记录当前被查找中的结果
//光标在选择词的尾部下一个位置
#if 0
@ -1066,54 +1169,54 @@ void FindWin::addCurFindRecord(ScintillaEditView* pEdit, FindRecords& recordRet,
//mark模式不需要这么多信息可直接返回
if (!isMark)
{
aRecord.lineNum = pEdit->execute(SCI_LINEFROMPOSITION, aRecord.pos);
aRecord.lineStartPos = pEdit->execute(SCI_POSITIONFROMLINE, aRecord.lineNum);
int lineLens = pEdit->execute(SCI_LINELENGTH, aRecord.lineNum);
aRecord.lineNum = pEdit->execute(SCI_LINEFROMPOSITION, aRecord.pos);
aRecord.lineStartPos = pEdit->execute(SCI_POSITIONFROMLINE, aRecord.lineNum);
int lineLens = pEdit->execute(SCI_LINELENGTH, aRecord.lineNum);
if (lineLens <= 0)
{
return;
}
if (lineLens <= 0)
{
return ret;
}
char* lineText = new char[lineLens + 1];
memset(lineText, 0, lineLens + 1);
char* lineText = new char[lineLens + 1];
memset(lineText, 0, lineLens + 1);
//这里有个bug,是qscint的查找最后一行会漏掉最后一个字符
pEdit->execute(SCI_GETLINE, aRecord.lineNum, reinterpret_cast<sptr_t>(lineText));
//这里有个bug,是qscint的查找最后一行会漏掉最后一个字符
pEdit->execute(SCI_GETLINE, aRecord.lineNum, reinterpret_cast<sptr_t>(lineText));
//务必要去掉行位的换行,否则显示结果列表会显示换行
aRecord.lineContents = trimmedEnd(QString(lineText));
//务必要去掉行位的换行,否则显示结果列表会显示换行
aRecord.lineContents = trimmedEnd(QString(lineText));
delete[]lineText;
delete[]lineText;
//如果需要结果,再把结果提取一下
if (getResult && (state.targend - state.targstart > 0))
{
Sci_TextRange lineText;
lineText.chrg.cpMin = static_cast<Sci_Position>(state.targstart);
lineText.chrg.cpMax = static_cast<Sci_Position>(state.targend);
QByteArray result;
result.resize(state.targend - state.targstart);
lineText.lpstrText = result.data();
//获取原始行的内容
pEdit->SendScintilla(SCI_GETTEXTRANGE, 0, &lineText);
ret = QString(result);
}
}
recordRet.records.append(aRecord);
return ret;
}
//在后台查找
int FindWin::findAtBack(QString keyword)
//在后台批量查找
int FindWin::findAtBack(QStringList& keyword)
{
this->setCurrentTab(FIND_TAB);
ui.findComboBox->setCurrentText(keyword);
ui.findBackwardBox->setChecked(false);
ui.findMatchCaseBox->setChecked(true);
ui.findWrapBox->setChecked(false);
ui.findMatchWholeBox->setChecked(false);
ui.findModeNormalBt->setChecked(true);
m_isStatic = true;
int times = findAllInCurDoc();
m_isStatic = false;
return times;
}
//在后台替换
int FindWin::replaceAtBack(QStringList& keyword, QStringList& replace)
{
assert(keyword.size() == replace.size());
this->setCurrentTab(REPLACE_TAB);
if (keyword.isEmpty())
{
return 0;
}
QWidget* pw = autoAdjustCurrentEditWin();
ScintillaEditView* pEdit = dynamic_cast<ScintillaEditView*>(pw);
@ -1127,49 +1230,148 @@ int FindWin::replaceAtBack(QStringList& keyword, QStringList& replace)
}
}
ui.replaceBackwardBox->setChecked(false);
ui.replaceMatchWholeBox->setChecked(false);
ui.replaceMatchCaseBox->setChecked(true);
ui.replaceWrapBox->setChecked(false);
ui.replaceModeNormalBox->setChecked(true);
m_isStatic = true;
int times = 0;
ProgressWin* loadFileProcessWin = nullptr;
if (keyword.size() > 1000)
{
loadFileProcessWin = new ProgressWin(this);
loadFileProcessWin->setWindowModality(Qt::WindowModal);
loadFileProcessWin->info(tr("total %1 keyword, please wait ...").arg(keyword.size()));
loadFileProcessWin->setTotalSteps(keyword.size() / 100);
loadFileProcessWin->show();
}
QString text = pEdit->text();
QByteArray bytes = text.toUtf8();
QByteArray findBytes;
int keyLens = 0;
int index = 0;
for (int i = 0; i < keyword.size(); ++i)
{
if ((loadFileProcessWin != nullptr) && loadFileProcessWin->isCancel())
{
break;
}
index = 0;
//20230223 不走老的逻辑了,批量替换太慢。直接把文件读取处理,在内存中一次性处理完毕。
//但是这样就不知道到底有多少字符串被替换了
findBytes = keyword.at(i).toUtf8();
keyLens = findBytes.size();
while (true)
{
index = bytes.indexOf(findBytes,index);
if (index == -1)
{
break;
}
++times;
index += keyLens;
}
if ((loadFileProcessWin != nullptr)&& ((i % 100) == 0))
{
loadFileProcessWin->moveStep();
QCoreApplication::processEvents();
}
}
if (loadFileProcessWin != nullptr)
{
delete loadFileProcessWin;
}
return times;
}
//在后台批量替换
int FindWin::replaceAtBack(QStringList& keyword, QStringList& replace)
{
assert(keyword.size() == replace.size());
//this->setCurrentTab(REPLACE_TAB);
if (keyword.isEmpty())
{
return 0;
}
QWidget* pw = autoAdjustCurrentEditWin();
ScintillaEditView* pEdit = dynamic_cast<ScintillaEditView*>(pw);
if (pEdit != nullptr)
{
if (pEdit->isReadOnly())
{
ui.statusbar->showMessage(tr("The ReadOnly document does not allow replacement."), 8000);
QApplication::beep();
return 0;
}
}
m_isStatic = true;
int times = 0;
pEdit->execute(SCI_BEGINUNDOACTION);
ProgressWin* loadFileProcessWin = new ProgressWin(this);
ProgressWin* loadFileProcessWin = nullptr;
loadFileProcessWin->setWindowModality(Qt::WindowModal);
if (keyword.size() > 1000)
{
loadFileProcessWin = new ProgressWin(this);
loadFileProcessWin->info(tr("total %1 keyword, please wait ...").arg(keyword.size()));
loadFileProcessWin->setWindowModality(Qt::WindowModal);
loadFileProcessWin->setTotalSteps(keyword.size());
loadFileProcessWin->info(tr("total %1 keyword, please wait ...").arg(keyword.size()));
loadFileProcessWin->show();
loadFileProcessWin->setTotalSteps(keyword.size() / 10);
loadFileProcessWin->show();
}
QString text = pEdit->text();
for (int i = 0; i < keyword.size(); ++i)
{
if (loadFileProcessWin->isCancel())
if ((loadFileProcessWin!=nullptr) && loadFileProcessWin->isCancel())
{
break;
}
//20230223 不走老的逻辑了,批量替换太慢。直接把文件读取处理,在内存中一次性处理完毕。
//但是这样就不知道到底有多少字符串被替换了
text.replace(keyword.at(i), replace.at(i));
ui.replaceTextBox->setCurrentText(keyword.at(i));
ui.replaceWithBox->setText(replace.at(i));
updateParameterFromUI();
QString whatFind = ui.replaceTextBox->currentText();
QString replaceText = ui.replaceWithBox->text();
times += doReplaceAll(pEdit, whatFind, replaceText, false);
loadFileProcessWin->moveStep();
QCoreApplication::processEvents();
if ((loadFileProcessWin != nullptr) && ((i % 10) == 0))
{
loadFileProcessWin->moveStep();
QCoreApplication::processEvents();
}
}
//替换外部后,一次性整体替换
int selectionEnd = pEdit->length();
pEdit->execute(SCI_SETTARGETRANGE, 0, selectionEnd);
QByteArray bytes = text.toUtf8();
pEdit->execute(SCI_REPLACETARGET, bytes.size(), reinterpret_cast<sptr_t>(bytes.data()));
if (loadFileProcessWin != nullptr)
{
delete loadFileProcessWin;
}
delete loadFileProcessWin;
pEdit->execute(SCI_ENDUNDOACTION);
@ -1178,7 +1380,121 @@ int FindWin::replaceAtBack(QStringList& keyword, QStringList& replace)
return times;
}
int FindWin::findAllInCurDoc()
//在后台批量高亮
int FindWin::markAtBack(QStringList& keyword)
{
if (keyword.isEmpty())
{
return 0;
}
QWidget* pw = autoAdjustCurrentEditWin();
ScintillaEditView* pEdit = dynamic_cast<ScintillaEditView*>(pw);
if (pEdit != nullptr)
{
if (pEdit->isReadOnly())
{
ui.statusbar->showMessage(tr("The ReadOnly document does not allow replacement."), 8000);
QApplication::beep();
return 0;
}
}
m_isStatic = true;
int times = 0;
ProgressWin* loadFileProcessWin = nullptr;
if (keyword.size() > 1000)
{
loadFileProcessWin = new ProgressWin(this);
loadFileProcessWin->setWindowModality(Qt::WindowModal);
loadFileProcessWin->info(tr("total %1 keyword, please wait ...").arg(keyword.size()));
loadFileProcessWin->setTotalSteps(keyword.size() / 100);
loadFileProcessWin->show();
}
QString text = pEdit->text();
QByteArray bytes = text.toUtf8();
QByteArray findBytes;
int keyLens = 0;
int index = 0;
QMap<QByteArray, QVector<int>* > keyPos;
for (int i = 0; i < keyword.size(); ++i)
{
if ((loadFileProcessWin != nullptr) && loadFileProcessWin->isCancel())
{
break;
}
index = 0;
//20230223 不走老的逻辑了,批量替换太慢。直接把文件读取处理,在内存中一次性处理完毕。
//但是这样就不知道到底有多少字符串被替换了
findBytes = keyword.at(i).toUtf8();
keyLens = findBytes.size();
if (keyLens == 0)
{
continue;
}
QVector<int>* vec = new QVector<int>();
vec->reserve(128);
keyPos.insert(findBytes, vec);
while (true)
{
index = bytes.indexOf(findBytes, index);
if (index == -1)
{
break;
}
++times;
vec->append(index);
index += keyLens;
}
if ((loadFileProcessWin != nullptr) && ((i % 100) == 0))
{
loadFileProcessWin->moveStep();
QCoreApplication::processEvents();
}
}
//把结果高亮起来。
for (QMap<QByteArray, QVector<int>* >::iterator it = keyPos.begin(); it != keyPos.end(); ++it)
{
int foundTextLen = it.key().size();
QVector<int>* pVect = (*it);
for (int i = 0, s = pVect->size(); i < s; ++i)
{
pEdit->execute(SCI_SETINDICATORCURRENT, CCNotePad::s_curMarkColorId);
pEdit->execute(SCI_INDICATORFILLRANGE, pVect->at(i), foundTextLen);
}
delete pVect;
}
if (loadFileProcessWin != nullptr)
{
delete loadFileProcessWin;
}
return times;
}
int FindWin::findAllInCurDoc(QStringList* reResult)
{
if (ui.findComboBox->currentText().isEmpty())
{
@ -1201,6 +1517,8 @@ int FindWin::findAllInCurDoc()
return 0;
}
QString resultDestStr;
int askAbortTimes = 0;
FindRecords results;
results.pEdit = pEdit;
@ -1208,10 +1526,13 @@ int FindWin::findAllInCurDoc()
updateParameterFromUI();
//正则模式下面,拷贝所有结果到剪切板
bool isNeedResult(m_re && (reResult != nullptr));
int srcPostion = pEdit->execute(SCI_GETCURRENTPOS);
int firstDisLineNum = pEdit->execute(SCI_GETFIRSTVISIBLELINE);
int replaceNums = 0;
int findNums = 0;
//无条件进行第一次查找从0行0列开始查找而且不回环。如果没有找到则替换完毕
QString whatFind = ui.findComboBox->currentText();
@ -1232,8 +1553,8 @@ int FindWin::findAllInCurDoc()
if (!m_isStatic)
{
QApplication::beep();
emit sign_findAllInCurDoc(&results);
QApplication::beep();
emit sign_findAllInCurDoc(&results);
}
m_isFindFirst = true;
@ -1245,17 +1566,40 @@ int FindWin::findAllInCurDoc()
dealWithZeroFound(pEdit);
}
addCurFindRecord(pEdit, results);
resultDestStr = addCurFindRecord(pEdit, results, false, isNeedResult);
++replaceNums;
//正则模式下面,拷贝所有结果到剪切板
if (isNeedResult)
{
reResult->append(resultDestStr);
}
++findNums;
//找到了,把结果收集起来
while (pEdit->findNext())
{
addCurFindRecord(pEdit, results);
++replaceNums;
resultDestStr = addCurFindRecord(pEdit, results, false, isNeedResult);
++findNums;
//正则模式下面,拷贝所有结果到剪切板
if (isNeedResult)
{
reResult->append(resultDestStr);
}
dealWithZeroFound(pEdit);
//2000 和 4000时各询问一次避免查询结果过大
if (((askAbortTimes == 0) && findNums > 2000) || ((askAbortTimes == 1) && findNums > 4000))
{
int ret = QMessageBox::question(this, tr("Continue Find ?"), tr("The search results have been greater than %1 times in %2 files, and more may be slow. Continue to search?").arg(findNums).arg(1), tr("Yes"), tr("Abort"));
if (ret == 1)
{
break;
}
++askAbortTimes;
}
}
pEdit->execute(SCI_GOTOPOS, srcPostion);
@ -1264,11 +1608,21 @@ int FindWin::findAllInCurDoc()
//全部替换后,下次查找,必须算第一次查找
m_isFindFirst = true;
ui.statusbar->showMessage(tr("find finished, total %1 found!").arg(replaceNums), 10000);
if (!isNeedResult)
{
ui.statusbar->showMessage(tr("find finished, total %1 found!").arg(findNums), 10000);
}
else
{
ui.statusbar->showMessage(tr("find finished, total %1 found! Result in clipboard.").arg(findNums), 10000);
}
emit sign_findAllInCurDoc(&results);
return replaceNums;
return findNums;
}
else
{
@ -2365,7 +2719,7 @@ int FindWin::walkDirfile(QString path, int &foundTimes, bool isSkipBinary, bool
{
loadFileProcessWin->setCancel();
break;
}
}
else
{
if (canAbort && (hitFileNums > 100 || foundTimes > 1000))
@ -2627,3 +2981,22 @@ void FindWin::slot_dirReplaceAll()
ui.statusbar->showMessage(tr("replace finished, total %1 replace in %2 file!").arg(replaceNums).arg(filesNum), 10000);
}
//把正则查找的结果,拷贝到剪切板
void FindWin::on_copyReFindResult()
{
if (!ui.findModeRegularBt->isChecked())
{
ui.statusbar->showMessage(tr("Only regular lookup mode can be used!"),10000);
return;
}
QStringList reResult;
findAllInCurDoc(&reResult);
if (!reResult.isEmpty())
{
QClipboard* clipboard = QApplication::clipboard();
clipboard->setText(reResult.join("\n"));
}
}

View File

@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <QMainWindow>
#include <QTabWidget>
@ -63,8 +63,10 @@ public:
void setCurrentTab(FindTabIndex index);
void setTabWidget(QTabWidget * editTabWidget);
void setFindText(QString & text);
void keywordWinGetFouse(FindTabIndex tabIndex);
void setReplaceFindText(QString& text);
void setDirFindText(QString& text);
void setMarkFindText(QString& text);
void disableReplace();
void setFindHistory(QList<QString>* findHistory);
int markAllWord(QString& word);
@ -74,11 +76,10 @@ public:
void findNext();
void findPrev();
void setFindBackward(bool isBackward);
int findAtBack(QString keyword);
int findAtBack(QStringList& keyword);
int markAtBack(QStringList& keyword);
int replaceAtBack(QStringList& keyword, QStringList& replace);
protected:
virtual void focusInEvent(QFocusEvent *ev);
@ -97,7 +98,8 @@ private:
void updateParameterFromUI();
void addFindHistory(QString & text);
bool isFirstFind();
void addCurFindRecord(ScintillaEditView * pEdit, FindRecords & recordRet, bool isMark=false);
QString addCurFindRecord(ScintillaEditView * pEdit, FindRecords & recordRet, bool isMark=false, bool getResult=false);
bool findTextInFile(QString & filePath, int & findNums, QVector<FindRecords*>* allfileInDirRecord);
@ -125,7 +127,7 @@ private:
int markAll();
int findAllInCurDoc();
int findAllInCurDoc(QStringList * reResult=nullptr);
private slots:
@ -169,6 +171,8 @@ private slots:
void slot_tabIndexChange(int index);
void on_copyReFindResult();
private:
Ui::FindWin ui;

View File

@ -286,6 +286,13 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="copyReResultBt">
<property name="text">
<string>Copy Regular Result</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="findClearBt">
<property name="minimumSize">
@ -1476,8 +1483,8 @@
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>572</x>
<y>251</y>
<x>672</x>
<y>291</y>
</hint>
<hint type="destinationlabel">
<x>169</x>
@ -1524,8 +1531,8 @@
<slot>slot_replaceFindNext()</slot>
<hints>
<hint type="sourcelabel">
<x>94</x>
<y>60</y>
<x>458</x>
<y>61</y>
</hint>
<hint type="destinationlabel">
<x>588</x>
@ -1540,8 +1547,8 @@
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>94</x>
<y>45</y>
<x>458</x>
<y>198</y>
</hint>
<hint type="destinationlabel">
<x>588</x>
@ -1556,8 +1563,8 @@
<slot>slot_replace()</slot>
<hints>
<hint type="sourcelabel">
<x>94</x>
<y>64</y>
<x>458</x>
<y>95</y>
</hint>
<hint type="destinationlabel">
<x>588</x>
@ -1572,8 +1579,8 @@
<slot>slot_replaceAll()</slot>
<hints>
<hint type="sourcelabel">
<x>94</x>
<y>67</y>
<x>458</x>
<y>129</y>
</hint>
<hint type="destinationlabel">
<x>588</x>
@ -1588,8 +1595,8 @@
<slot>slot_replaceAllInOpenDoc()</slot>
<hints>
<hint type="sourcelabel">
<x>94</x>
<y>76</y>
<x>458</x>
<y>169</y>
</hint>
<hint type="destinationlabel">
<x>588</x>
@ -1757,6 +1764,22 @@
</hint>
</hints>
</connection>
<connection>
<sender>copyReResultBt</sender>
<signal>clicked()</signal>
<receiver>FindWin</receiver>
<slot>on_copyReFindResult()</slot>
<hints>
<hint type="sourcelabel">
<x>534</x>
<y>222</y>
</hint>
<hint type="destinationlabel">
<x>344</x>
<y>191</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>slot_findNext()</slot>
@ -1775,5 +1798,6 @@
<slot>sign_clearResult()</slot>
<slot>slot_findPrev()</slot>
<slot>slot_clearAllMark()</slot>
<slot>on_copyReFindResult()</slot>
</slots>
</ui>

View File

@ -2,7 +2,8 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "Notepad--"
#define MyAppVersion "1.22.0"
#define MyAppVersion "1.23.2"
#define MyAppDesc MyAppName + MyAppVersion + "(Ndd主程序)"
#define MyAppPublisher "ndd¿ªÔ´×éÖ¯"
#define MyAppURL "https://gitee.com/cxasm/notepad--"
#define MyAppExeName "Notepad--.exe"
@ -10,6 +11,20 @@
#define MyAppAssocExt ".txt"
#define MyAppAssocKey StringChange(MyAppAssocName, " ", "") + MyAppAssocExt
#define MyAppAssocExt1 ".ini"
#define MyAppAssocExt2 ".log"
#define MyAppAssocExt3 ".sh"
#define MyAppAssocExt4 ".h"
#define MyAppAssocExt5 ".c"
#define MyAppAssocExt6 ".cpp"
#define MyAppAssocExt7 ".py"
#define MyAppAssocExt8 ".xml"
#define MyAppAssocExt9 ".def"
#define MyAppAssocExt10 ".json"
#define MyAppAssocExt11 ".pro"
#define MyAppAssocExt12 ".csv"
[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
@ -35,6 +50,7 @@ Compression=lzma
SolidCompression=yes
WizardStyle=modern
[Languages]
Name: "ChineseSimplified"; MessagesFile: "compiler:Languages\ChineseSimplified.isl"
@ -47,14 +63,35 @@ Source: "D:\CCNotePad\x64\Release\*"; DestDir: "{app}"; Flags: ignoreversion rec
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Registry]
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocExt}\OpenWithProgids"; ValueType: string; ValueName: "{#MyAppAssocKey}"; ValueData: ""; Flags: uninsdeletevalue
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}"; ValueType: string; ValueName: ""; ValueData: "{#MyAppAssocName}"; Flags: uninsdeletekey
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\{#MyAppExeName},0"
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""%1"""
Root: HKA; Subkey: "Software\Classes\Applications\{#MyAppExeName}\SupportedTypes"; ValueType: string; ValueName: ".myp"; ValueData: ""
Root: HKA; Subkey: "Software\Classes\*\shell\Notepad--"; ValueType: string; ValueName: ""; ValueData: "Edit with Notepad--"; Flags: uninsdeletekey
Root: HKA; Subkey: "Software\Classes\*\shell\Notepad--"; ValueType: string; ValueName: "Icon"; ValueData: """{app}\{#MyAppExeName}"""
Root: HKA; Subkey: "Software\Classes\*\shell\Notepad--\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""%1""" ;
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocExt}\OpenWithProgids"; ValueType: string; ValueName: "{#MyAppAssocKey}"; ValueData: ""; Flags: uninsdeletevalue; Components: main
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocExt1}\OpenWithProgids"; ValueType: string; ValueName: "{#MyAppAssocKey}"; ValueData: ""; Flags: uninsdeletevalue ; Components: ass
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocExt2}\OpenWithProgids"; ValueType: string; ValueName: "{#MyAppAssocKey}"; ValueData: ""; Flags: uninsdeletevalue; Components: ass
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocExt3}\OpenWithProgids"; ValueType: string; ValueName: "{#MyAppAssocKey}"; ValueData: ""; Flags: uninsdeletevalue; Components: ass
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocExt4}\OpenWithProgids"; ValueType: string; ValueName: "{#MyAppAssocKey}"; ValueData: ""; Flags: uninsdeletevalue; Components: ass
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocExt5}\OpenWithProgids"; ValueType: string; ValueName: "{#MyAppAssocKey}"; ValueData: ""; Flags: uninsdeletevalue; Components: ass
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocExt6}\OpenWithProgids"; ValueType: string; ValueName: "{#MyAppAssocKey}"; ValueData: ""; Flags: uninsdeletevalue; Components: ass
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocExt7}\OpenWithProgids"; ValueType: string; ValueName: "{#MyAppAssocKey}"; ValueData: ""; Flags: uninsdeletevalue; Components: ass
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocExt8}\OpenWithProgids"; ValueType: string; ValueName: "{#MyAppAssocKey}"; ValueData: ""; Flags: uninsdeletevalue; Components: ass
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocExt9}\OpenWithProgids"; ValueType: string; ValueName: "{#MyAppAssocKey}"; ValueData: ""; Flags: uninsdeletevalue; Components: ass
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocExt10}\OpenWithProgids"; ValueType: string; ValueName: "{#MyAppAssocKey}"; ValueData: ""; Flags: uninsdeletevalue; Components: ass
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocExt11}\OpenWithProgids"; ValueType: string; ValueName: "{#MyAppAssocKey}"; ValueData: ""; Flags: uninsdeletevalue; Components: ass
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}"; ValueType: string; ValueName: ""; ValueData: "{#MyAppAssocName}"; Flags: uninsdeletekey; Components: main
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\{#MyAppExeName},0"; Components: main
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""%1"""; Components: main
Root: HKA; Subkey: "Software\Classes\Applications\{#MyAppExeName}"; ValueType: string; ValueName: ""; ValueData: ""; Flags: uninsdeletekey; Components: main
Root: HKA; Subkey: "Software\Classes\Applications\{#MyAppExeName}\SupportedTypes"; ValueType: string; ValueName: ".myp"; ValueData: ""; Flags: uninsdeletekey; Components: main
;Root: HKA; Subkey: "Software\Classes\Applications\{#MyAppExeName}\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""%1"""; Flags: uninsdeletekey; Components: main
Root: HKA; Subkey: "Software\Classes\*\shell\Notepad--"; ValueType: string; ValueName: ""; ValueData: "Edit with Notepad--"; Flags: uninsdeletekey; Components: main
Root: HKA; Subkey: "Software\Classes\*\shell\Notepad--"; ValueType: string; ValueName: "Icon"; ValueData: """{app}\{#MyAppExeName}""" ; Components: main
Root: HKA; Subkey: "Software\Classes\*\shell\Notepad--\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""%1""" ; Components: main
[Components]
Name: "main"; Description: "{#MyAppDesc}"; Types: full compact custom; Flags: fixed
Name: "ass"; Description: "关联打开常见文本类型"; Types: full
[Icons]

View File

@ -40,7 +40,7 @@ const QString c_strTitle = "Ndd";
#ifdef Q_OS_UNIX
#if defined(Q_OS_MAC)
QSharedMemory shared("CCNotebook122");;//mac下面后面带一个版本号避免新的打不开
QSharedMemory shared("CCNotebook123");;//mac下面后面带一个版本号避免新的打不开
#else
QSharedMemory shared("CCNotebook");
#endif

153
src/md5hash.cpp Executable file
View File

@ -0,0 +1,153 @@
#include "md5hash.h"
#include "ccnotepad.h"
#include "ctipwin.h"
#include <QCryptographicHash>
#include <QFile>
#include <QFileDialog>
#include <QClipboard>
Md5hash::Md5hash(QWidget *parent)
: QWidget(parent), m_isFile(false)
{
ui.setupUi(this);
m_btGroup.addButton(ui.md4RadioBt, 0);
m_btGroup.addButton(ui.md5RadioBt, 1);
m_btGroup.addButton(ui.sha1RadioBt, 2);
m_btGroup.addButton(ui.sha256RadioBt, 4);
m_btGroup.addButton(ui.sha3RadioBt, 12);
m_btGroup.addButton(ui.kec256RadioBt, 8);
#if (QT_VERSION <= QT_VERSION_CHECK(5,15,0))
connect(&m_btGroup, QOverload<int>::of(&QButtonGroup::buttonClicked), this, &Md5hash::on_methodIdChange);
#else
connect(&m_btGroup, &QButtonGroup::idClicked, this, &Md5hash::on_methodIdChange);
#endif
connect(ui.srcTextEdit,&QPlainTextEdit::textChanged,this,&Md5hash::on_hash);
}
Md5hash::~Md5hash()
{}
void Md5hash::slot_select()
{
QFileDialog fd(this, QString(), CCNotePad::s_lastOpenDirPath);
fd.setFileMode(QFileDialog::ExistingFile);
m_fileList.clear();
if (fd.exec() == QDialog::Accepted) //如果成功的执行
{
m_fileList = fd.selectedFiles(); //返回文件列表的名称
if (!m_fileList.isEmpty())
{
m_isFile = true;
ui.srcTextEdit->setPlainText(m_fileList.join("\n"));
}
}
else
{
fd.close();
}
}
void Md5hash::on_methodIdChange(int id)
{
on_hash();
}
void Md5hash::on_hash()
{
QCryptographicHash::Algorithm method = QCryptographicHash::Md5;
if (ui.md5RadioBt->isChecked())
{
method = QCryptographicHash::Md5;
}
else if (ui.md4RadioBt->isChecked())
{
method = QCryptographicHash::Md4;
}
else if (ui.sha1RadioBt->isChecked())
{
method = QCryptographicHash::Sha1;
}
else if (ui.sha256RadioBt->isChecked())
{
method = QCryptographicHash::Sha256;
}
else if (ui.sha3RadioBt->isChecked())
{
method = QCryptographicHash::Sha3_256;
}
else if (ui.kec256RadioBt->isChecked())
{
method = QCryptographicHash::Keccak_256;
}
//如果是文本
if (!m_isFile)
{
QString text = ui.srcTextEdit->toPlainText();
QByteArray data = text.toUtf8();
if (!text.isEmpty())
{
QByteArray result = QCryptographicHash::hash(data, method);
ui.hashTextEdit->setPlainText(result.toHex());
}
}
else
{
QCryptographicHash fileHash(method);
QByteArray rs;
QList<QByteArray> result;
for (int i = 0; i < m_fileList.size(); ++i)
{
rs.clear();
QFile file(m_fileList.at(i));
if (file.open(QIODevice::ReadOnly))
{
if (fileHash.addData(&file))
{
rs = fileHash.result();
result.append(rs.toHex());
}
else
{
result.append("Error Null");
}
file.close();
}
else
{
result.append("Error Null");
}
}
for (int i = 0; i < result.size(); ++i)
{
QString info = QString("File %1 cyp hash is \n%2").arg(m_fileList.at(i)).arg(QString(result.at(i)));
ui.hashTextEdit->appendPlainText(info);
}
m_isFile = false;
}
}
void Md5hash::on_copyClipboard()
{
if (!ui.hashTextEdit->toPlainText().isEmpty())
{
QClipboard* clipboard = QApplication::clipboard();
clipboard->setText(ui.hashTextEdit->toPlainText());
CTipWin::showTips(this, tr("Copy to clipboard Finished!"), 1200);
}
}

26
src/md5hash.h Executable file
View File

@ -0,0 +1,26 @@
#pragma once
#include <QWidget>
#include <QButtonGroup>
#include "ui_md5hash.h"
class Md5hash : public QWidget
{
Q_OBJECT
public:
Md5hash(QWidget *parent = nullptr);
~Md5hash();
private slots:
void slot_select();
void on_hash();
void on_methodIdChange(int id);
void on_copyClipboard();
private:
Ui::Md5hashClass ui;
QButtonGroup m_btGroup;
QStringList m_fileList;
bool m_isFile;
};

203
src/md5hash.ui Executable file
View File

@ -0,0 +1,203 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Md5hashClass</class>
<widget class="QWidget" name="Md5hashClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>560</width>
<height>436</height>
</rect>
</property>
<property name="windowTitle">
<string>Md5hash</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Copy Text Or Select File</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton">
<property name="text">
<string>select</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPlainTextEdit" name="srcTextEdit"/>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Algorithm</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QRadioButton" name="md4RadioBt">
<property name="text">
<string>Md4</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="sha1RadioBt">
<property name="text">
<string>Sha1</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QRadioButton" name="sha3RadioBt">
<property name="text">
<string>Sha3_256</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="md5RadioBt">
<property name="text">
<string>Md5</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QRadioButton" name="sha256RadioBt">
<property name="text">
<string>Sha256</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QRadioButton" name="kec256RadioBt">
<property name="text">
<string>Keccak_256</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="hashTextEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>80</height>
</size>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Copy to Clipboard</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelBt">
<property name="text">
<string>Close</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections>
<connection>
<sender>toolButton</sender>
<signal>clicked()</signal>
<receiver>Md5hashClass</receiver>
<slot>slot_select()</slot>
<hints>
<hint type="sourcelabel">
<x>534</x>
<y>19</y>
</hint>
<hint type="destinationlabel">
<x>552</x>
<y>239</y>
</hint>
</hints>
</connection>
<connection>
<sender>cancelBt</sender>
<signal>clicked()</signal>
<receiver>Md5hashClass</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>503</x>
<y>412</y>
</hint>
<hint type="destinationlabel">
<x>338</x>
<y>430</y>
</hint>
</hints>
</connection>
<connection>
<sender>pushButton</sender>
<signal>clicked()</signal>
<receiver>Md5hashClass</receiver>
<slot>on_copyClipboard()</slot>
<hints>
<hint type="sourcelabel">
<x>393</x>
<y>415</y>
</hint>
<hint type="destinationlabel">
<x>539</x>
<y>430</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>slot_select()</slot>
<slot>on_copyClipboard()</slot>
</slots>
</ui>

View File

@ -15,7 +15,7 @@ bool NddSetting::s_isContentChanged = false;
QSettings* NddSetting::s_nddSet = nullptr;
QSettings* NddSetting::s_winPosSet = nullptr;
QSettings* NddSetting::s_nddDelaySet = nullptr;
//如果key不存在则新增key-value。存在返回true
bool NddSetting::checkNoExistAdd(QString key, QVariant& value)
@ -96,7 +96,7 @@ void NddSetting::init()
addKeyValueToSets(SOFT_KEY, "0");
addKeyValueToSets(RESTORE_CLOSE_FILE, "1");
addKeyValueToNumSets(RESTORE_CLOSE_FILE, 1);
//0 24 1 36 2 48
addKeyValueToNumSets(ICON_SIZE, 1);
@ -227,6 +227,10 @@ void NddSetting::init()
QVariant v(14);
checkNoExistAdd(FIND_RESULT_FONT_SIZE, v);
}
{
QVariant v(0);
checkNoExistAdd(LAST_ACTION_TAB_INDEX, v);
}
} while (false);
}
@ -310,10 +314,10 @@ void NddSetting::close()
}
//在这里保存一下子窗口的位置。不排除有可能子窗口还在,主窗口已经退出的情况,不过问题不大。
if (s_winPosSet != nullptr)
if (s_nddDelaySet != nullptr)
{
s_winPosSet->sync();
s_winPosSet = nullptr;
s_nddDelaySet->sync();
s_nddDelaySet = nullptr;
}
}
}
@ -322,25 +326,41 @@ void NddSetting::close()
//子窗口的位置单独放在一个winpos.ini文件中而且启动程序时不需要读取可避免启动时拖慢速度
QByteArray NddSetting::getWinPos(QString key)
{
winPosInit();
return s_winPosSet->value(key, "").toByteArray();
nddDelaySetInit();
return s_nddDelaySet->value(key, "").toByteArray();
}
void NddSetting::updataWinPos(QString key, QByteArray& value)
{
winPosInit();
s_winPosSet->setValue(key, QVariant(value));
nddDelaySetInit();
s_nddDelaySet->setValue(key, QVariant(value));
}
void NddSetting::winPosInit()
void NddSetting::nddDelaySetInit()
{
if (s_winPosSet == nullptr)
if (s_nddDelaySet == nullptr)
{
QString settingDir = QString("notepad/delayset");
QSettings qs(QSettings::IniFormat, QSettings::UserScope, settingDir);
QString qsSetPath = qs.fileName();
s_winPosSet = new QSettings(QSettings::IniFormat, QSettings::UserScope, settingDir);
s_winPosSet->setIniCodec("UTF-8");
s_nddDelaySet = new QSettings(QSettings::IniFormat, QSettings::UserScope, settingDir);
s_nddDelaySet->setIniCodec("UTF-8");
}
}
//写一个总的获取配置的接口,避免以后每个字段都需要写一个读写接口
QString NddSetting::getKeyValueFromDelaySets(QString key)
{
nddDelaySetInit();
return s_nddDelaySet->value(key, "").toString();
}
bool NddSetting::updataKeyValueFromDelaySets(QString key, QString value)
{
nddDelaySetInit();
s_nddDelaySet->setValue(key, value);
s_isContentChanged = true;
return true;
}

View File

@ -24,6 +24,9 @@ static QString TOOLBARSHOW = "showbar"; //是否显示工具栏
static QString FINDWINSIZE = "findwinsize";//保存查找框的大小。150%放大时界面永久。保留避免每次手动调整
static QString SHOWWEBADDR = "showweb";//高亮web地址双击网页打开
static QString FIND_RESULT_FONT_SIZE = "frfs";//查找结果的默认字体大小默认为14
static QString LAST_ACTION_TAB_INDEX = "lati";//上次关闭时当前激活的tab标签页序号
static QString RECENT_OPEN_FILE = "recentopenfile";
//下面这个是winpos.ini中的key避免单个文件太大拖慢启动速度
@ -58,14 +61,16 @@ public:
static void updataWinPos(QString key, QByteArray& value);
static QString getKeyValueFromDelaySets(QString key);
static bool updataKeyValueFromDelaySets(QString key, QString value);
static bool isDbExist()
{
return s_isExistDb;
}
private:
static void winPosInit();
static void nddDelaySetInit();
private:
static bool s_isExistDb;
@ -74,5 +79,7 @@ private:
static QSettings* s_nddSet;
static QSettings* s_winPosSet;
//基本和s_nddSet一样不过在启动的时候不需要读取该文件。加快启动速度
//启动完毕后,其他操作触发加载该文件
static QSettings* s_nddDelaySet;
};

View File

@ -7,6 +7,10 @@ PluginMgr::PluginMgr(QWidget *parent, QList<NDD_PROC_DATA>& pluginList)
{
ui.setupUi(this);
ui.pluginTable->horizontalHeader()->setStretchLastSection(true);
ui.pluginTable->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
ui.pluginTable->horizontalHeader()->setSectionResizeMode(3, QHeaderView::ResizeToContents);
//ui.pluginTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
init(pluginList);
}

View File

@ -37,7 +37,10 @@
// Define QSCINTILLA_MAKE_DLL to create a QScintilla shared library, or
// define QSCINTILLA_DLL to link against a QScintilla shared library, or define
// neither to either build or link against a static QScintilla library.
#define QSCINTILLA_DLL
#ifdef QSCINTILLA_DLL
#undef QSCINTILLA_DLL
#endif
//#define QSCINTILLA_DLL
#if defined(QSCINTILLA_DLL)
#define QSCINTILLA_EXPORT Q_DECL_IMPORT

View File

@ -47,7 +47,9 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
const char *desc;
};
//20230216 屏蔽一些生僻的命令,加宽速度,让出快捷键
static struct sci_cmd cmd_table[] = {
{
QsciCommand::LineDown,
Qt::Key_Down,
@ -58,6 +60,7 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
#endif
QT_TRANSLATE_NOOP("QsciCommand", "Move down one line")
},
{
QsciCommand::LineDownExtend,
Qt::Key_Down | Qt::SHIFT,
@ -127,7 +130,7 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
#if defined(USING_OSX_KEYS)
Qt::Key_Home,
#else
0,
Qt::Key_Home | Qt::CTRL,
#endif
0,
QT_TRANSLATE_NOOP("QsciCommand", "Scroll to start of document")
@ -137,11 +140,12 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
#if defined(USING_OSX_KEYS)
Qt::Key_End,
#else
0,
Qt::Key_End | Qt::CTRL,
#endif
0,
QT_TRANSLATE_NOOP("QsciCommand", "Scroll to end of document")
},
#if 0
{
QsciCommand::VerticalCentreCaret,
#if defined(USING_OSX_KEYS)
@ -159,6 +163,10 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
0,
QT_TRANSLATE_NOOP("QsciCommand", "Move down one paragraph")
},
#endif
#if 0
//测试无效
{
QsciCommand::ParaDownExtend,
Qt::Key_BracketRight | Qt::CTRL | Qt::SHIFT,
@ -166,12 +174,15 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
QT_TRANSLATE_NOOP("QsciCommand",
"Extend selection down one paragraph")
},
#endif
{
QsciCommand::ParaUp,
Qt::Key_BracketLeft | Qt::CTRL,
0,
QT_TRANSLATE_NOOP("QsciCommand", "Move up one paragraph")
},
#if 0
{
QsciCommand::ParaUpExtend,
Qt::Key_BracketLeft | Qt::CTRL | Qt::SHIFT,
@ -179,6 +190,7 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
QT_TRANSLATE_NOOP("QsciCommand",
"Extend selection up one paragraph")
},
#endif
{
QsciCommand::CharLeft,
Qt::Key_Left,
@ -189,6 +201,8 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
#endif
QT_TRANSLATE_NOOP("QsciCommand", "Move left one character")
},
{
QsciCommand::CharLeftExtend,
Qt::Key_Left | Qt::SHIFT,
@ -200,6 +214,7 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
QT_TRANSLATE_NOOP("QsciCommand",
"Extend selection left one character")
},
{
QsciCommand::CharLeftRectExtend,
Qt::Key_Left | Qt::ALT | Qt::SHIFT,
@ -243,6 +258,8 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
QT_TRANSLATE_NOOP("QsciCommand",
"Extend rectangular selection right one character")
},
#if 0
{
QsciCommand::WordLeft,
#if defined(USING_OSX_KEYS)
@ -253,6 +270,7 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
0,
QT_TRANSLATE_NOOP("QsciCommand", "Move left one word")
},
#endif
{
QsciCommand::WordLeftExtend,
#if defined(USING_OSX_KEYS)
@ -263,6 +281,7 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
0,
QT_TRANSLATE_NOOP("QsciCommand", "Extend selection left one word")
},
#if 0
{
QsciCommand::WordRight,
#if defined(USING_OSX_KEYS)
@ -273,12 +292,16 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
0,
QT_TRANSLATE_NOOP("QsciCommand", "Move right one word")
},
#endif
#if 0
{
QsciCommand::WordRightExtend,
Qt::Key_Right | Qt::CTRL | Qt::SHIFT,
0,
QT_TRANSLATE_NOOP("QsciCommand", "Extend selection right one word")
},
#endif
#if 0
{
QsciCommand::WordLeftEnd,
0,
@ -313,6 +336,8 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
QT_TRANSLATE_NOOP("QsciCommand",
"Extend selection to end of next word")
},
#endif
#if 0
{
QsciCommand::WordPartLeft,
Qt::Key_Slash | Qt::CTRL,
@ -339,6 +364,8 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
QT_TRANSLATE_NOOP("QsciCommand",
"Extend selection right one word part")
},
#endif
#if 0
{
QsciCommand::Home,
#if defined(USING_OSX_KEYS)
@ -371,6 +398,8 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
QT_TRANSLATE_NOOP("QsciCommand",
"Extend rectangular selection to start of document line")
},
#endif
#if 0
{
QsciCommand::HomeDisplay,
#if defined(USING_OSX_KEYS)
@ -406,6 +435,8 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
QT_TRANSLATE_NOOP("QsciCommand",
"Extend selection to start of display or document line")
},
#endif
{
QsciCommand::VCHome,
#if defined(USING_OSX_KEYS)
@ -417,6 +448,7 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
QT_TRANSLATE_NOOP("QsciCommand",
"Move to first visible character in document line")
},
{
QsciCommand::VCHomeExtend,
#if defined(USING_OSX_KEYS)
@ -428,6 +460,7 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
QT_TRANSLATE_NOOP("QsciCommand",
"Extend selection to first visible character in document line")
},
#if 0
{
QsciCommand::VCHomeRectExtend,
#if defined(USING_OSX_KEYS)
@ -453,6 +486,7 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
QT_TRANSLATE_NOOP("QsciCommand",
"Extend selection to first visible character in display or document line")
},
#endif
{
QsciCommand::LineEnd,
#if defined(USING_OSX_KEYS)
@ -463,6 +497,7 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
0,
QT_TRANSLATE_NOOP("QsciCommand", "Move to end of document line")
},
{
QsciCommand::LineEndExtend,
#if defined(USING_OSX_KEYS)
@ -474,6 +509,7 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
QT_TRANSLATE_NOOP("QsciCommand",
"Extend selection to end of document line")
},
#if 0
{
QsciCommand::LineEndRectExtend,
#if defined(USING_OSX_KEYS)
@ -485,6 +521,8 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
QT_TRANSLATE_NOOP("QsciCommand",
"Extend rectangular selection to end of document line")
},
#endif
#if 0
{
QsciCommand::LineEndDisplay,
#if defined(USING_OSX_KEYS)
@ -495,6 +533,8 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
0,
QT_TRANSLATE_NOOP("QsciCommand", "Move to end of display line")
},
#endif
#if 0
{
QsciCommand::LineEndDisplayExtend,
#if defined(USING_OSX_KEYS)
@ -520,6 +560,7 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
QT_TRANSLATE_NOOP("QsciCommand",
"Extend selection to end of display or document line")
},
#endif
{
QsciCommand::DocumentStart,
#if defined(USING_OSX_KEYS)
@ -568,7 +609,7 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
0,
QT_TRANSLATE_NOOP("QsciCommand", "Move up one page")
},
{
/* {
QsciCommand::PageUpExtend,
Qt::Key_PageUp | Qt::SHIFT,
0,
@ -580,7 +621,7 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
0,
QT_TRANSLATE_NOOP("QsciCommand",
"Extend rectangular selection up one page")
},
},*/
{
QsciCommand::PageDown,
Qt::Key_PageDown,
@ -591,7 +632,7 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
#endif
QT_TRANSLATE_NOOP("QsciCommand", "Move down one page")
},
{
/*{
QsciCommand::PageDownExtend,
Qt::Key_PageDown | Qt::SHIFT,
#if defined(USING_OSX_KEYS)
@ -611,7 +652,8 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
#endif
QT_TRANSLATE_NOOP("QsciCommand",
"Extend rectangular selection down one page")
},
},*/
#if 0
{
QsciCommand::StutteredPageUp,
0,
@ -638,6 +680,7 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
QT_TRANSLATE_NOOP("QsciCommand",
"Stuttered extend selection down one page")
},
#endif
{
QsciCommand::Delete,
Qt::Key_Delete,
@ -658,6 +701,7 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
#endif
QT_TRANSLATE_NOOP("QsciCommand", "Delete previous character")
},
#if 0
{
QsciCommand::DeleteBackNotLine,
0,
@ -677,6 +721,8 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
0,
QT_TRANSLATE_NOOP("QsciCommand", "Delete word to right")
},
#endif
#if 0
{
QsciCommand::DeleteWordRightEnd,
#if defined(USING_OSX_KEYS)
@ -688,6 +734,7 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
QT_TRANSLATE_NOOP("QsciCommand",
"Delete right to end of next word")
},
#endif
{
QsciCommand::DeleteLineLeft,
Qt::Key_Backspace | Qt::CTRL | Qt::SHIFT,
@ -729,18 +776,21 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
QT_TRANSLATE_NOOP("QsciCommand",
"Transpose current and previous lines")
},*/
#if 0
{
QsciCommand::LineDuplicate,
0,
0,
QT_TRANSLATE_NOOP("QsciCommand", "Duplicate the current line")
},
#endif
{
QsciCommand::SelectAll,
Qt::Key_A | Qt::CTRL,
0,
QT_TRANSLATE_NOOP("QsciCommand", "Select all")
},
#if 0
{
QsciCommand::MoveSelectedLinesUp,
0,
@ -754,12 +804,15 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
QT_TRANSLATE_NOOP("QsciCommand",
"Move selected lines down one line")
},
#endif
#if 0
{
QsciCommand::SelectionDuplicate,
Qt::Key_D | Qt::CTRL,
0,
QT_TRANSLATE_NOOP("QsciCommand", "Duplicate selection")
},
#endif
{
QsciCommand::SelectionLowerCase,
Qt::Key_U | Qt::CTRL,
@ -802,18 +855,21 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
Qt::Key_Return | Qt::SHIFT,
QT_TRANSLATE_NOOP("QsciCommand", "Insert newline")
},
#if 0
{
QsciCommand::Formfeed,
0,
0,
QT_TRANSLATE_NOOP("QsciCommand", "Formfeed")
},
#endif
{
QsciCommand::Tab,
Qt::Key_Tab,
0,
QT_TRANSLATE_NOOP("QsciCommand", "Indent one level")
},
#if 0
{
QsciCommand::Backtab,
Qt::Key_Tab | Qt::SHIFT,
@ -826,6 +882,7 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
0,
QT_TRANSLATE_NOOP("QsciCommand", "Cancel")
},
#endif
{
QsciCommand::Undo,
Qt::Key_Z | Qt::CTRL,
@ -842,9 +899,10 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
0,
QT_TRANSLATE_NOOP("QsciCommand", "Redo last command")
},
#if 1
{
QsciCommand::ZoomIn,
Qt::Key_Plus | Qt::CTRL,
Qt::Key_Equal | Qt::CTRL,
0,
QT_TRANSLATE_NOOP("QsciCommand", "Zoom in")
},
@ -853,7 +911,9 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
Qt::Key_Minus | Qt::CTRL,
0,
QT_TRANSLATE_NOOP("QsciCommand", "Zoom out")
},
},
#endif
#if 0
{
QsciCommand::MoveLineUp,
Qt::Key_Up | Qt::CTRL | Qt::SHIFT,
@ -867,6 +927,7 @@ QsciCommandSet::QsciCommandSet(QsciScintilla *qs) : qsci(qs)
0,
QT_TRANSLATE_NOOP("QsciCommand", "Move Line down")
},
#endif
};
// Clear the default map.

View File

@ -163,7 +163,7 @@ QColor QsciLexerGlobal::defaultColor(int style) const
switch (style)
{
case GLOBAL_OVERRIDE:
return QColor(0xFFFF80);
return QColor(Qt::black);
case DEFAULT_STYLE:
return QColor(Qt::black);
@ -328,7 +328,7 @@ QColor QsciLexerGlobal::defaultPaper(int style) const
switch (style)
{
case GLOBAL_OVERRIDE:
return QColor(0xFF8000);
return QColor(0xFFFFFF);
case DEFAULT_STYLE:
return QColor(0xFFFFFF);

View File

@ -312,21 +312,21 @@ QFont QsciLexerHTML::defaultFont(int style) const
case Default:
case Entity:
#if defined(Q_OS_WIN)
f = QFont("Courier New",13);
f = QFont("Courier New", QsciLexer::s_defaultFontSize);
#elif defined(Q_OS_MAC)
f = QFont("Courier New", 13);
f = QFont("Courier New", QsciLexer::s_defaultFontSize);
#else
f = QFont("Bitstream Charter",10);
f = QFont("Bitstream Charter", QsciLexer::s_defaultFontSize);
#endif
break;
case HTMLComment:
#if defined(Q_OS_WIN)
f = QFont("Courier New",9);
f = QFont("Courier New", QsciLexer::s_defaultFontSize);
#elif defined(Q_OS_MAC)
f = QFont("Verdana", 12);
f = QFont("Verdana", QsciLexer::s_defaultFontSize);
#else
f = QFont("Bitstream Vera Sans",8);
f = QFont("Bitstream Vera Sans", QsciLexer::s_defaultFontSize);
#endif
break;
@ -354,9 +354,9 @@ QFont QsciLexerHTML::defaultFont(int style) const
#if defined(Q_OS_WIN)
f = QFont("Courier New",QsciLexer::s_defaultFontSize);
#elif defined(Q_OS_MAC)
f = QFont("Comic Sans MS", 12);
f = QFont("Comic Sans MS", QsciLexer::s_defaultFontSize);
#else
f = QFont("Bitstream Vera Serif",9);
f = QFont("Bitstream Vera Serif", QsciLexer::s_defaultFontSize);
#endif
f.setBold(true);
break;
@ -381,9 +381,9 @@ QFont QsciLexerHTML::defaultFont(int style) const
#if defined(Q_OS_WIN)
f = QFont("Courier New",QsciLexer::s_defaultFontSize);
#elif defined(Q_OS_MAC)
f = QFont("Comic Sans MS", 12);
f = QFont("Comic Sans MS", QsciLexer::s_defaultFontSize);
#else
f = QFont("Bitstream Vera Serif",9);
f = QFont("Bitstream Vera Serif", QsciLexer::s_defaultFontSize);
#endif
break;
@ -400,9 +400,9 @@ QFont QsciLexerHTML::defaultFont(int style) const
#if defined(Q_OS_WIN)
f = QFont("Courier New",QsciLexer::s_defaultFontSize);
#elif defined(Q_OS_MAC)
f = QFont("Lucida Grande", 12);
f = QFont("Lucida Grande", QsciLexer::s_defaultFontSize);
#else
f = QFont("Bitstream Vera Serif",9);
f = QFont("Bitstream Vera Serif", QsciLexer::s_defaultFontSize);
#endif
break;
@ -411,9 +411,9 @@ QFont QsciLexerHTML::defaultFont(int style) const
#if defined(Q_OS_WIN)
f = QFont("Courier New",QsciLexer::s_defaultFontSize);
#elif defined(Q_OS_MAC)
f = QFont("Lucida Grande", 12);
f = QFont("Lucida Grande", QsciLexer::s_defaultFontSize);
#else
f = QFont("Bitstream Vera Serif",9);
f = QFont("Bitstream Vera Serif", QsciLexer::s_defaultFontSize);
#endif
f.setBold(false);
break;
@ -425,9 +425,9 @@ QFont QsciLexerHTML::defaultFont(int style) const
#if defined(Q_OS_WIN)
f = QFont("Courier New",QsciLexer::s_defaultFontSize);
#elif defined(Q_OS_MAC)
f = QFont("Courier New", 12);
f = QFont("Courier New", QsciLexer::s_defaultFontSize);
#else
f = QFont("Bitstream Vera Sans Mono",9);
f = QFont("Bitstream Vera Sans Mono", QsciLexer::s_defaultFontSize);
#endif
break;
@ -442,9 +442,9 @@ QFont QsciLexerHTML::defaultFont(int style) const
#if defined(Q_OS_WIN)
f = QFont("Courier New",QsciLexer::s_defaultFontSize);
#elif defined(Q_OS_MAC)
f = QFont("Comic Sans MS", 12);
f = QFont("Comic Sans MS", QsciLexer::s_defaultFontSize);
#else
f = QFont("Bitstream Vera Serif",9);
f = QFont("Bitstream Vera Serif", QsciLexer::s_defaultFontSize);
#endif
f.setItalic(true);
break;

View File

@ -189,8 +189,8 @@ QColor QsciLexerMarkdown::defaultPaper(int style) const
case UnorderedListItem:
return QColor(0xde, 0xd8, 0xc3);
case OrderedListItem:
return QColor(0xb8, 0xc3, 0xe1);
/*case OrderedListItem:
return QColor(0xb8, 0xc3, 0xe1);*/
case BlockQuote:
return QColor(0xcb, 0xdc, 0xcb);

View File

@ -72,23 +72,10 @@ QFont QsciLexerText::defaultFont(int style) const
switch (style)
{
case Default:
#if defined(Q_OS_WIN)
return s_defaultTxtFont;
#elif defined(Q_OS_MAC)
//return QFont("Courier", 12);
return s_defaultTxtFont;
#else
return s_defaultTxtFont;//sQFont("Bitstream Vera Sans Mono", 9);
#endif
break;
case Ascii:
#if defined(Q_OS_WIN)
return QFont("Courier New", 12);
#elif defined(Q_OS_MAC)
return QFont("Courier New", 14);
#else
return s_defaultTxtFont;
#endif
break;
case Keyword:
#if defined(Q_OS_WIN)

View File

@ -2370,7 +2370,9 @@ QString QsciScintilla::selectedText() const
if (!selText)
return QString();
char *buf = new char[SendScintilla(SCI_GETSELECTIONEND) - SendScintilla(SCI_GETSELECTIONSTART) + 1];
//char *buf = new char[SendScintilla(SCI_GETSELECTIONEND) - SendScintilla(SCI_GETSELECTIONSTART) + 1];
int size = SendScintilla(SCI_GETSELTEXT, 0);
char* buf = new char[size];
SendScintilla(SCI_GETSELTEXT, buf);

View File

@ -371,9 +371,10 @@ void QtLangSet::updateAllLangeStyleWithGlobal(GLOBAL_STYLE_SET flag)
{
//GLOBAL本身不保存因为GLOBAL不是语法样式而是全局的属性风格
//如果全局修改的是全局字体或字体大小,全局也修改一下。避免括弧等大小和全局字体不一样大。
//全局颜色前景和背景时也要特殊对待要单独修改全局default的修改否则编辑界面看起来颜色杂乱
if (index == L_GLOBAL)
{
if (flag != GLOBAL_FONT_SIZE && flag != GLOBAL_FONT)
if (flag != GLOBAL_FONT_SIZE && flag != GLOBAL_FONT && flag != GLOBAL_FG_COLOR && flag != GLOBAL_BK_COLOR)
{
continue;
}
@ -492,14 +493,37 @@ void QtLangSet::updateAllLangeStyleWithGlobal(GLOBAL_STYLE_SET flag)
break;
case GLOBAL_FG_COLOR:
{
//非全局修改所有的语法对应样式
if (index != L_GLOBAL)
{
pLexer->setColor(m_curStyleData.color, -1);
pLexer->setDefaultColor(m_curStyleData.color);
}
else
{
//全局时只修改default的颜色
pLexer->setColor(m_curStyleData.color, GLOBAL_STYLES::GLOBAL_OVERRIDE);
pLexer->setColor(m_curStyleData.color, GLOBAL_STYLES::DEFAULT_STYLE);
isGlobalChange = true;
}
}
break;
case GLOBAL_BK_COLOR:
{
//非全局修改所有的语法对应样式
if (index != L_GLOBAL)
{
pLexer->setPaper(m_curStyleData.paper, -1);
//默认纸背景色会和QPalette保持一致。单独需要单独设置一下
pLexer->setDefaultPaper(m_curStyleData.paper);
}
else
{
//全局时只修改default的颜色
pLexer->setPaper(m_curStyleData.paper, GLOBAL_STYLES::GLOBAL_OVERRIDE);
pLexer->setPaper(m_curStyleData.paper, GLOBAL_STYLES::DEFAULT_STYLE);
isGlobalChange = true;
}
}
break;
default:
@ -515,6 +539,12 @@ void QtLangSet::updateAllLangeStyleWithGlobal(GLOBAL_STYLE_SET flag)
//还有,还需要把当前打开文档的全局风格设置一下,否则全局不生效
if (isGlobalChange)
{
refreshGlobalSet();
}
}
void QtLangSet::refreshGlobalSet()
{
m_previousSysLangItem = nullptr;
slot_langListCurRowChanged(0);
@ -524,14 +554,13 @@ void QtLangSet::updateAllLangeStyleWithGlobal(GLOBAL_STYLE_SET flag)
CCNotePad* pMainNote = dynamic_cast<CCNotePad*>(parent());
if (pMainNote != nullptr)
{
for (int i = 0; i <= GLOBAL_STYLES::URL_HOVERRED; ++i)
{
pMainNote->setGlobalFont(i);
}
}
}
}
//恢复所有语言的初始配置。与restoreOriginLangOneStyle类似但是粒度更大
void QtLangSet::restoreOriginLangAllStyle()
@ -655,7 +684,6 @@ void QtLangSet::restoreOriginLangOneStyle(GLOBAL_STYLE_SET flag)
{
oldClor = pOriginLexer->color(i);
pLexer->setColor(oldClor, i);
}
break;
case GLOBAL_BK_COLOR:
@ -669,11 +697,30 @@ void QtLangSet::restoreOriginLangOneStyle(GLOBAL_STYLE_SET flag)
}
}
}
switch (flag)
{
case GLOBAL_FG_COLOR:
//把默认颜色修改一下
oldClor = pOriginLexer->defaultColor();
pLexer->setDefaultColor(oldClor);
break;
case GLOBAL_BK_COLOR:
//把默认颜色修改一下
oldClor = pOriginLexer->defaultPaper();
pLexer->setDefaultPaper(oldClor);
break;
}
saveLangeSet(pLexer);
}
delete pLexer;
delete pOriginLexer;
}
//全局变化了,把当前全局界面刷新一下
//还有,还需要把当前打开文档的全局风格设置一下,否则全局不生效
refreshGlobalSet();
}
//预览全局修改字体效果。把当前所有的语法,风格字体都修改一遍
@ -1154,7 +1201,9 @@ void QtLangSet::syncShowStyleItemToUI(QListWidgetItem *item)
QsciLexer::StyleData & sd = m_selectLexer->styleData(styleId);
m_curStyleData = sd;
setStyleShow(sd.font, sd.color, sd.paper);
m_isStyleChange = false;
//这里不能直接设置为非修改,如果之前已经修改过,则还是要认定为修改。
//m_isStyleChange = false;
//如果是全局,则把不能修改的全局样式灰掉,避免干扰用户的选择
if (m_isGlobelItem)
@ -1194,7 +1243,7 @@ void QtLangSet::syncShowStyleItemToUI(QListWidgetItem *item)
//点击当前的风格item
void QtLangSet::slot_styleItemSelect(QListWidgetItem *current)
{
qDebug() << "slot_styleItemSelect";
//qDebug() << "slot_styleItemSelect";
syncShowStyleItemToUI(current);
@ -1220,7 +1269,7 @@ void QtLangSet::slot_styleItemSelect(QListWidgetItem *current)
//使用键盘上下切换
void QtLangSet::slot_styleListCurRowChanged(int row)
{
qDebug() << "slot_curRowChanged";
//qDebug() << "slot_curRowChanged";
QListWidgetItem* current = ui.styleListWidget->item(row);
slot_styleItemSelect(current);
}
@ -1478,6 +1527,24 @@ void QtLangSet::slot_changeBkColor()
}
}
else
{
//当前背景色是否变化
if (m_curStyleData.paper != color)
{
m_curStyleData.paper = color;
fillBackgroundColor(color);
m_isStyleChange = true;
//即时设置风格
if (m_selectLexer != nullptr)
{
m_selectLexer->setPaper(color, m_selectStyleId);
emit viewStyleChange(m_selectLexer->lexerTag(), m_selectStyleId, m_curStyleData.color, m_curStyleData.paper, m_curStyleData.font, false);
}
}
}
// else if (!ui.modiryAllColor->isChecked())
// {
// //当前前景色是否变化
@ -1495,26 +1562,9 @@ void QtLangSet::slot_changeBkColor()
// }
// }
//}
else
{
//全部风格颜色修改
//当前前景色是否变化
m_curStyleData.paper = color;
fillBackgroundColor(color);
m_isStyleChange = true;
//即时设置风格
if (m_selectLexer != nullptr)
{
m_selectLexer->setPaper(color, -1);
saveCurLangSettings();
emit viewLexerChange(m_selectLexer->lexerTag());
}
}
}
}
void QtLangSet::slot_saveClick()
{

View File

@ -110,12 +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);
bool isExistThemesSetings(int styleId);
void createUserStyleFormThemes(int styleId);
void refreshGlobalSet();
private:
Ui::QtLangSetClass ui;

View File

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

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -7,12 +7,12 @@
#include "qtlangset.h"
#include "findwin.h"
#include "filemanager.h"
#include "shortcutkeymgr.h"
#include <Scintilla.h>
#include <SciLexer.h>
#include <QImage>
#include <Qsci/qscilexerpython.h>
//#include <Qsci/qscilexeravs.h>
#include <Qsci/qscilexerasm.h>
#include <Qsci/qscilexerbash.h>
#include <Qsci/qscilexerbatch.h>
@ -198,6 +198,9 @@ LanguageName ScintillaEditView::langNames[L_EXTERNAL + 1] = {
ScintillaEditView::ScintillaEditView(QWidget *parent,bool isBigText)
: QsciScintilla(parent), m_NoteWin(nullptr), m_preFirstLineNum(0), m_curPos(0), m_hasHighlight(false), m_bookmarkPng(nullptr), m_styleColorMenu(nullptr), m_isBigText(isBigText), m_curBlockLineStartNum(0)
#ifdef Q_OS_WIN
,m_isInTailStatus(false)
#endif
{
init();
}
@ -210,8 +213,44 @@ ScintillaEditView::~ScintillaEditView()
{
delete m_bookmarkPng;
}
#ifdef Q_OS_WIN
deleteTailFileThread();
#endif
}
//截获ESC键盘让界面去退出当前的子界面
void ScintillaEditView::keyPressEvent(QKeyEvent* event)
{
switch (event->key())
{
case Qt::Key_Escape:
if (m_NoteWin != nullptr)
{
m_NoteWin->on_quitActiveWindow();
}
break;
default:
break;
}
return QsciScintilla::keyPressEvent(event);
}
void ScintillaEditView::mouseReleaseEvent(QMouseEvent* ev)
{
QsciScintilla::mouseReleaseEvent(ev);
if (ev->button() == Qt::LeftButton)
{
if (hasSelectedText())
{
emit delayWork();
}
}
}
void ScintillaEditView::setBigTextMode(bool isBigText)
{
m_isBigText = isBigText;
@ -432,6 +471,12 @@ QString ScintillaEditView::getTagByLexerId(int lexerId)
case L_FLASH:
return("flash");
case L_MATLAB:
return ("matlab");
case L_MARKDOWN:
return("markdown");
case L_NSIS:
return "nsis";
@ -475,9 +520,6 @@ QString ScintillaEditView::getTagByLexerId(int lexerId)
case L_VERILOG:
return "verilog";
case L_MATLAB:
return "matlab";
case L_HASKELL:
break;
case L_INNO:
@ -692,6 +734,12 @@ QsciLexer* ScintillaEditView::createLexer(int lexerId, QString tag, bool isOrigi
ret = new QsciLexerCPP();
ret->setLexerTag("flash");
break;
case L_MATLAB:
ret = new QsciLexerMatlab();
break;
case L_MARKDOWN:
ret = new QsciLexerMarkdown();
break;
case L_NSIS:
ret = new QsciLexerNsis();
break;
@ -735,9 +783,6 @@ QsciLexer* ScintillaEditView::createLexer(int lexerId, QString tag, bool isOrigi
case L_VERILOG:
ret = new QsciLexerVerilog();
break;
case L_MATLAB:
ret = new QsciLexerMatlab();
break;
case L_HASKELL:
break;
case L_INNO:
@ -1720,7 +1765,7 @@ void ScintillaEditView::highlightViewWithWord(QString & word2Hilite)
QByteArray whatMark = word2Hilite.toUtf8();
SendScintilla(SCI_SETSEARCHFLAGS, SCFIND_REGEXP | SCFIND_MATCHCASE | SCFIND_WHOLEWORD | SCFIND_REGEXP_SKIPCRLFASONE);
SendScintilla(SCI_SETSEARCHFLAGS, SCFIND_MATCHCASE /*| SCFIND_WHOLEWORD*/ | SCFIND_REGEXP_SKIPCRLFASONE);
for (; currentLine < lastLine; ++currentLine)
{
@ -2205,12 +2250,34 @@ void ScintillaEditView::showWordNums()
QString word = selectedText();
if (!word.isEmpty())
{
QMessageBox::about(this, tr("Word Nums"), tr("Current Select Word Nums is %1 .").arg(word.size()));
int lineNum = word.count("\n");
if (!word.endsWith("\n"))
{
++lineNum;
}
//\s是包含了换行符的所有要单独统计\r\n换换行符排除一下
QRegExp warpRe("[\r\n]");
int wrapNums = word.count(warpRe);
QRegExp bkRe("\\s");
int blank = word.count(bkRe);
QMessageBox::about(this, tr("Word Nums"), tr("Current Select Word Nums is %1 . \nLine nums is %2 . \nSpace nums is %3, Non-space is %4 .").\
arg(word.size()-wrapNums).arg(lineNum).arg(blank-wrapNums).arg(word.size()-blank));
}
}
else
{
QMessageBox::about(this, tr("Word Nums"), tr("Current Doc Word Nums is %1 .").arg(this->text().size()));
int lineNum = this->lines();
QString text = this->text();
//\s是包含了换行符的所有要单独统计\r\n换换行符排除一下
QRegExp warpRe("[\r\n]");
int wrapNums = text.count(warpRe);
QRegExp bkRe("\\s");
int blank = text.count(bkRe);
QMessageBox::about(this, tr("Word Nums"), tr("Current Doc Word Nums is %1 . \nLine nums is %2 . \nSpace nums is %3, Non-space is %4 .").\
arg(text.size() - wrapNums).arg(lineNum).arg(blank - wrapNums).arg(text.size() - blank));
}
}
@ -2568,12 +2635,22 @@ void ScintillaEditView::mouseDoubleClickEvent(QMouseEvent * e)
} while (0);
}
//20230219先双击选中再按住ctrl再双击别的地方选中。此时是进入多选状态。
//这里必须要直接返回不能做delayWork。否则因为delaywork里面不能判断多选而数据越界崩溃
if (hasSelectedText())
{
QsciScintilla::mouseDoubleClickEvent(e);
return;
}
//执行下面mouseDoubleClickEvent后又会选中。此时如果上面已经有选中则会多选
QsciScintilla::mouseDoubleClickEvent(e);
if (hasSelectedText())
{
emit delayWork();
}
}
void ScintillaEditView::changeCase(const TextCaseType & caseToConvert, QString& strToConvert) const
@ -4024,3 +4101,172 @@ void ScintillaEditView::setGlobalFont(int style)
break;
}
}
bool ScintillaEditView::isFoldIndentBased() const
{
QsciLexer* lexer = this->lexer();
if (lexer != nullptr)
{
int lexerId = lexer->lexerId();
return lexerId == L_PYTHON
|| lexerId == L_COFFEESCRIPT
|| lexerId == L_HASKELL
|| lexerId == L_VB
|| lexerId == L_YAML;
}
return false;
}
const int MAX_FOLD_COLLAPSE_LEVEL = 8;
struct FoldLevelStack
{
int levelCount = 0;
intptr_t levelStack[MAX_FOLD_COLLAPSE_LEVEL]{};
void push(intptr_t level)
{
while (levelCount != 0 && level <= levelStack[levelCount - 1])
{
--levelCount;
}
levelStack[levelCount++] = level;
}
};
bool ScintillaEditView::isFolded(size_t line)
{
return (0 != execute(SCI_GETFOLDEXPANDED, line));
};
void ScintillaEditView::fold(size_t line, bool mode)
{
auto endStyled = execute(SCI_GETENDSTYLED);
auto len = execute(SCI_GETTEXTLENGTH);
if (endStyled < len)
execute(SCI_COLOURISE, 0, -1);
intptr_t headerLine;
auto level = execute(SCI_GETFOLDLEVEL, line);
if (level & SC_FOLDLEVELHEADERFLAG)
headerLine = line;
else
{
headerLine = execute(SCI_GETFOLDPARENT, line);
if (headerLine == -1)
return;
}
if (isFolded(headerLine) != mode)
{
execute(SCI_TOGGLEFOLD, headerLine);
//SCNotification scnN;
//scnN.nmhdr.code = SCN_FOLDINGSTATECHANGED;
//scnN.nmhdr.hwndFrom = _hSelf;
//scnN.nmhdr.idFrom = 0;
//scnN.line = headerLine;
//scnN.foldLevelNow = isFolded(headerLine) ? 1 : 0; //folded:1, unfolded:0
//::SendMessage(_hParent, WM_NOTIFY, 0, reinterpret_cast<LPARAM>(&scnN));
}
}
void ScintillaEditView::collapseFoldIndentBased(int level, bool mode)
{
execute(SCI_COLOURISE, 0, -1);
FoldLevelStack levelStack;
++level;
const intptr_t maxLine = execute(SCI_GETLINECOUNT);
intptr_t line = 0;
while (line < maxLine)
{
intptr_t level = execute(SCI_GETFOLDLEVEL, line);
if (level & SC_FOLDLEVELHEADERFLAG)
{
level &= SC_FOLDLEVELNUMBERMASK;
levelStack.push(level);
if (level == levelStack.levelCount)
{
if (isFolded(line) != mode)
{
fold(line, mode);
}
line = execute(SCI_GETLASTCHILD, line, -1);
}
}
++line;
}
}
void ScintillaEditView::collapse(int level, bool mode)
{
if (isFoldIndentBased())
{
return collapseFoldIndentBased(level, mode);
}
execute(SCI_COLOURISE, 0, -1);
intptr_t maxLine = execute(SCI_GETLINECOUNT);
for (int line = 0; line < maxLine; ++line)
{
intptr_t lineLevel = execute(SCI_GETFOLDLEVEL, line);
if (lineLevel & SC_FOLDLEVELHEADERFLAG)
{
lineLevel -= SC_FOLDLEVELBASE;
if (level == (lineLevel & SC_FOLDLEVELNUMBERMASK))
if (isFolded(line) != mode)
{
fold(line, mode);
}
}
}
}
void ScintillaEditView::comment(int type)
{
switch (type)
{
case ADD_DEL_LINE_COM:
doBlockComment(cm_toggle);
break;
case ADD_BK_COM:
doStreamComment();
break;
case DEL_BK_COM:
undoStreamComment();
break;
default:
break;
}
}
#ifdef Q_OS_WIN
void ScintillaEditView::deleteTailFileThread()
{
if (m_isInTailStatus)
{
m_isInTailStatus = false;
qlonglong threadAddr = this->property(Tail_Thread).toLongLong();
std::thread* pListenThread = (std::thread*)(threadAddr);
if (pListenThread->joinable())
{
pListenThread->join();
}
delete pListenThread;
}
}
#endif

View File

@ -139,9 +139,6 @@ public:
bool gotoPrePos();
bool gotoNextPos();
/*virtual void adjuctSkinStyle();*/
//设置文档的缩进参考线
void setIndentGuide(bool willBeShowed);
@ -210,13 +207,20 @@ public:
//获取当前块的开始行号。只在大文件只读模式下有效。其余模式下均返回0
quint32 getBigTextBlockStartLine();
void setBigTextBlockStartLine(quint32 line);
void collapse(int level, bool mode);
void comment(int type);
#ifdef Q_OS_WIN
void deleteTailFileThread();
#endif
signals:
void delayWork();
protected:
virtual void addHotSpot();
void setStylesFont(const QFont& f, int style, int setBitMask = ALL_SET_Bit);
void keyPressEvent(QKeyEvent* event) override;
virtual void mouseReleaseEvent(QMouseEvent* ev) override;
private:
@ -237,6 +241,12 @@ private:
void changeStyleColor(int sytleId);
void initStyleColorMenu();
bool isFolded(size_t line);
void fold(size_t line, bool mode);
void collapseFoldIndentBased(int level, bool mode);
bool isFoldIndentBased() const;
public:
static const int _SC_MARGE_LINENUMBER;
static const int _SC_MARGE_SYBOLE;
@ -319,4 +329,9 @@ public:
static int s_bigTextSize;
bool m_hasHighlight;
#ifdef Q_OS_WIN
std::atomic<bool> m_isInTailStatus;
#endif
};

View File

@ -130,3 +130,4 @@ void ScintillaHexEditView::updateThemes()
setMarginsBackgroundColor(StyleSet::s_global_style->line_number_margin.bgColor);
setPaper(StyleSet::s_global_style->default_style.bgColor);
}

View File

@ -10,12 +10,9 @@
QMap<QString, int>* ShortcutKeyMgr::s_shortcutKeysMap = nullptr;
//QMap<QString, int> * qScintShortcutKeyValueMap = nullptr;
struct ShortcutKeySt {
QString iniTag;//保存在Ini文件中的名称
QString name;//显示在表格中的名称
//QString keyDesc;//qkeysequence的描述
QKeySequence key;
bool canModify;//能否修改
@ -86,12 +83,12 @@ void ShortcutKeyMgr::initShortcutKeysMap()
<< ShortcutKeySt(tr("Save All File"), Save_All_File) \
<< ShortcutKeySt(tr("Close"), Close, QString("Ctrl+W")) \
<< ShortcutKeySt(tr("Close All"), Close_All, QString("Ctrl+Shift+W")) \
<< ShortcutKeySt(tr("Cut"), Cut, QString("Ctrl+X"),false) \
<< ShortcutKeySt(tr("Cut"), Cut, QString("Ctrl+X"), false) \
<< ShortcutKeySt(tr("Copy"), Copy, QString("Ctrl+C"), false) \
<< ShortcutKeySt(tr("Paste"), Paste, QString("Ctrl+V"), false) \
<< ShortcutKeySt(tr("Undo"), Undo, QString("Ctrl+Z"), false) \
<< ShortcutKeySt(tr("Redo"), Redo, QString("Ctrl+Y"), false) \
<< ShortcutKeySt(tr("Find"), Find, QString("Ctrl+F"),false) \
<< ShortcutKeySt(tr("Find"), Find, QString("Ctrl+F"), false) \
<< ShortcutKeySt(tr("Replace"), Replace, QString("Ctrl+H")) \
<< ShortcutKeySt(tr("Dir Find"), DirFind, QString("Ctrl+Shift+D")) \
<< ShortcutKeySt(tr("Mark"), Mark) \
@ -111,9 +108,27 @@ void ShortcutKeyMgr::initShortcutKeysMap()
<< ShortcutKeySt(tr("transform encoding"), Trans_code) \
<< ShortcutKeySt(tr("batch rename file"), Batch_rename) \
<< ShortcutKeySt(tr("Format Xml"), Format_Xml) \
<< ShortcutKeySt(tr("Format Json"), Format_Json);
<< ShortcutKeySt(tr("Format Json"), Format_Json) \
<< ShortcutKeySt(tr("Add/Del Line Comment"), ADD_DELETE_LINE_COMMENT, QString("Ctrl+Q")) \
<< ShortcutKeySt(tr("Add Block Comment"), ADD_BLOCK_COMMENT, QString("Ctrl+K")) \
<< ShortcutKeySt(tr("Del Block Comment"), CANCEL_BLOCK_COMMENT, QString("Ctrl+Shift+K")) \
<< ShortcutKeySt(tr("Fold Level 1"), FOLD_1, QString("Alt+1")) \
<< ShortcutKeySt(tr("Fold Level 2"), FOLD_2, QString("Alt+2")) \
<< ShortcutKeySt(tr("Fold Level 3"), FOLD_3, QString("Alt+3")) \
<< ShortcutKeySt(tr("Fold Level 4"), FOLD_4, QString("Alt+4")) \
<< ShortcutKeySt(tr("Fold Level 5"), FOLD_5, QString("Alt+5")) \
<< ShortcutKeySt(tr("Fold Level 6"), FOLD_6, QString("Alt+6")) \
<< ShortcutKeySt(tr("Fold Level 7"), FOLD_7, QString("Alt+7")) \
<< ShortcutKeySt(tr("Fold Level 8"), FOLD_8, QString("Alt+8")) \
<< ShortcutKeySt(tr("UNFold Level 1"), UNFOLD_1, QString("Alt+Shift+1")) \
<< ShortcutKeySt(tr("UNFold Level 2"), UNFOLD_2, QString("Alt+Shift+2")) \
<< ShortcutKeySt(tr("UNFold Level 3"), UNFOLD_3, QString("Alt+Shift+3")) \
<< ShortcutKeySt(tr("UNFold Level 4"), UNFOLD_4, QString("Alt+Shift+4")) \
<< ShortcutKeySt(tr("UNFold Level 5"), UNFOLD_5, QString("Alt+Shift+5")) \
<< ShortcutKeySt(tr("UNFold Level 6"), UNFOLD_6, QString("Alt+Shift+6")) \
<< ShortcutKeySt(tr("UNFold Level 7"), UNFOLD_7, QString("Alt+Shift+7")) \
<< ShortcutKeySt(tr("UNFold Level 8"), UNFOLD_8, QString("Alt+Shift+8"));
for (int i = 0; i < shortCutTable.size(); ++i)
{
s_shortcutKeysMap->insert(shortCutTable.at(i).iniTag, i);

View File

@ -36,7 +36,25 @@ enum Shortcut_Key_ID {
Batch_rename_ID,
Format_Xml_ID,
Format_Json_ID,
ADD_DEL_LINE_COM,
ADD_BK_COM,
DEL_BK_COM,
S_K_FOLD_1,
S_K_FOLD_2,
S_K_FOLD_3,
S_K_FOLD_4,
S_K_FOLD_5,
S_K_FOLD_6,
S_K_FOLD_7,
S_K_FOLD_8,
S_K_UNFOLD_1,
S_K_UNFOLD_2,
S_K_UNFOLD_3,
S_K_UNFOLD_4,
S_K_UNFOLD_5,
S_K_UNFOLD_6,
S_K_UNFOLD_7,
S_K_UNFOLD_8,
Shortcut_End_ID,//总是在最底下
};
@ -74,6 +92,26 @@ static const char* Batch_rename = "batchrename";
static const char* Format_Xml = "formatxml";
static const char* Format_Json = "formatjson";
static const char* ADD_DELETE_LINE_COMMENT = "linecom";
static const char* ADD_BLOCK_COMMENT = "bkcom";
static const char* CANCEL_BLOCK_COMMENT = "cbkcom";
static const char* FOLD_1 = "fold_1";
static const char* FOLD_2 = "fold_2";
static const char* FOLD_3 = "fold_3";
static const char* FOLD_4 = "fold_4";
static const char* FOLD_5 = "fold_5";
static const char* FOLD_6 = "fold_6";
static const char* FOLD_7 = "fold_7";
static const char* FOLD_8 = "fold_8";
static const char* UNFOLD_1 = "unfold_1";
static const char* UNFOLD_2 = "unfold_2";
static const char* UNFOLD_3 = "unfold_3";
static const char* UNFOLD_4 = "unfold_4";
static const char* UNFOLD_5 = "unfold_5";
static const char* UNFOLD_6 = "unfold_6";
static const char* UNFOLD_7 = "unfold_7";
static const char* UNFOLD_8 = "unfold_8";
class ShortcutKeyMgr : public QMainWindow
{

View File

@ -97,15 +97,21 @@ void TextEditSetWin::slot_txtFontSet()
//是从对比规则里面弹出来的,不进行文本的设置
return;
}
QtLangSet* pWin = pMainWin->getLangSet();
#if 0
QtLangSet* pWin = new QtLangSet(QString("txt"), this);
pWin->setAttribute(Qt::WA_DeleteOnClose);
connect(pWin, &QtLangSet::viewStyleChange, pMainWin, &CCNotePad::slot_viewStyleChange);
connect(pWin, &QtLangSet::viewLexerChange, pMainWin, &CCNotePad::slot_viewLexerChange);
pWin->show();
#endif
if (pWin != nullptr)
{
pWin->selectInitLangTag("txt");
}
}
#if 0
//app字体颜色设置

View File

@ -1,5 +0,0 @@
cd build/bin
windeployqt notepad--.exe
@REM copy .\src\qscint\libqscint.a .\%1\plugin
@REM copy .\src\plugin\^*\^*.dll .\%1\plugin

42
win.mk
View File

@ -1,42 +0,0 @@
# 基于 Git Bash 环境编写
# 设置编译链信息是为了避免环境存在多个Qt环境时编译异常
# 填入Qt的Mingw相关工具安装路径 不使用MINGW时可不填
# 填入Mingw Qt G++程序完整路径
Qt_MINGW_CXX_COMPILER:=d:/SOFT/Qt/Qt5.14.2/Tools/mingw730_64/bin/g++.exe
# 填入Mingw Qt GCC程序完整路径
Qt_MINGW_C_COMPILER:=d:/SOFT/Qt/Qt5.14.2/Tools/mingw730_64/bin/gcc.exe
# 填入Mingw Qt库查找路径
Qt_MINGW_PREFIX_PATH:=d:/SOFT/Qt/Qt5.14.2/5.14.2/mingw73_64
# 指定生成的Makefiles格式
Qt_MINGW_G:=CodeBlocks - MinGW Makefiles
# 填入Qt的msvc相关工具安装路径 不使用MSVC时可不填
# 填入Msvc Qt库查找路径
Qt_MSVC_PREFIX_PATH:=d:/CompilationTools/Qt/5.15.2/msvc2019_64
all:msvc
mingw:
cmake -G"${Qt_MINGW_G}" -Bbuild -DCMAKE_BUILD_TYPE=Release -DPLUGIN_EN=on -DCMAKE_PREFIX_PATH=${Qt_MINGW_PREFIX_PATH} -DCMAKE_CXX_COMPILER=${Qt_MINGW_CXX_COMPILER} -DCMAKE_C_COMPILER=${Qt_MINGW_C_COMPILER} .
cmake --build ./build --config=Release -- -j$$(nproc)
mkdir -p build/bin/plugin
cp -f build/NotePad--.exe build/bin/
cd build/bin && windeployqt --qmldir=${Qt_MINGW_PREFIX_PATH}/qml NotePad--.exe
cp -r -f build/src/*/*/*.dll build/bin/plugin
cp -r -f build/src/*/*.a build/bin/plugin
cd build && cpack --config CPackConfig.cmake
msvc:
cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DPLUGIN_EN=on -DCMAKE_PREFIX_PATH=${Qt_MSVC_PREFIX_PATH} .
cmake --build ./build --config=Release -j$$(nproc)
mkdir -p build/bin/plugin
cp -f build/Release/NotePad--.exe build/bin/
cd build/bin && windeployqt --qmldir=${Qt_MSVC_PREFIX_PATH}/qml NotePad--.exe
cp -r -f build/src/*/*/Release/*.dll build/bin/plugin
cp -r -f build/src/*/Release/*.lib build/bin/plugin
cd build && cpack --config CPackConfig.cmake