新增区分大小写搜索

This commit is contained in:
阿甘 2024-06-20 22:55:52 +08:00
parent 6b628c7ac3
commit 6221a7dd6d
3 changed files with 31 additions and 16 deletions

View File

@ -1,3 +1,7 @@
# TabEditor--
<p align="center">
<img src="./res/app.ico" width="200" />
</p>
<h1 align="center">TabEditor++ - 制表符分隔的文本数据编辑工具</h1>
制表符分隔数据的txt文本编辑器

View File

@ -5,9 +5,10 @@ winform.add(
btnSearchNext={cls="button";text="查找下一个(F)";left=218;top=83;right=306;bottom=113;db=1;dl=1;font=LOGFONT(name='微软雅黑');z=1};
btnSearchPrev={cls="button";text="查找下上个(V)";left=119;top=83;right=207;bottom=113;db=1;dl=1;font=LOGFONT(name='微软雅黑');z=2};
button={cls="button";text="关闭";left=327;top=82;right=386;bottom=112;db=1;dl=1;font=LOGFONT(name='微软雅黑');z=4};
checkbox={cls="checkbox";text="单元格匹配";left=16;top=86;right=108;bottom=113;bgcolor=16777215;checked=1;font=LOGFONT(h=-14);z=6};
editSearchInput={cls="combobox";left=81;top=28;right=392;bottom=54;db=1;dl=1;edge=1;font=LOGFONT(name='微软雅黑');items={};mode="dropdown";z=3};
static={cls="static";text="查找内容:";left=12;top=29;right=72;bottom=55;align="right";bgcolor=16777215;center=1;db=1;dl=1;font=LOGFONT(name='微软雅黑');transparent=1;z=5}
checkbox={cls="checkbox";text="区分大小写";left=19;top=60;right=111;bottom=87;bgcolor=16777215;font=LOGFONT(h=-14);z=6};
checkbox2={cls="checkbox";text="单元格匹配";left=19;top=92;right=111;bottom=119;bgcolor=16777215;font=LOGFONT(h=-14);z=7};
editSearchInput={cls="combobox";left=81;top=15;right=392;bottom=41;db=1;dl=1;edge=1;font=LOGFONT(name='微软雅黑');items={};mode="dropdown";z=3};
static={cls="static";text="查找内容:";left=12;top=16;right=72;bottom=42;align="right";bgcolor=16777215;center=1;db=1;dl=1;font=LOGFONT(name='微软雅黑');transparent=1;z=5}
)
/*}}*/
@ -37,7 +38,7 @@ winform.onCancel = function(){
}
pushSearchNext = function(){
publish("search_next", winform.editSearchInput.text, winform.checkbox.checked);
publish("search_next", winform.editSearchInput.text, winform.checkbox.checked, winform.checkbox2.checked);
}
winform.onOk = function(){

View File

@ -344,7 +344,6 @@ mainForm.popmenuRight.add('删除列',function(id){
mainForm.release();
} )
mainForm.g_flexcell.onMouseUp = function(Button , Shift, x, y){
/*** 鼠标按键放开。
Button 当前按下的鼠标按钮1左按钮2右按钮4中间按钮同时按下时执行位或操作。
@ -389,7 +388,7 @@ var accelerator = win.ui.accelerator({
},mainForm );
research_flag = true;
searchNextContent = function(data, firstRow, firstCol, lastRow, lastCol, isRangeSearch, selFirstRow, selFirstCol, searchContent, isCellMatching){
searchNextContent = function(data, firstRow, firstCol, lastRow, lastCol, isRangeSearch, selFirstRow, selFirstCol, searchContent, isCaseSensitive, isCellMatching){
if(isRangeSearch){// 从一个范围开始搜索
var tempRow = firstRow;
var tempCol = firstCol;
@ -406,8 +405,13 @@ searchNextContent = function(data, firstRow, firstCol, lastRow, lastCol, isRange
if (i == pre_searched_row and i2 == pre_searched_col){
continue;
}
var currStr = v[v2];
if(!isCaseSensitive){
currStr = string.lower(currStr);
searchContent = string.lower(searchContent);
}
if (isCellMatching){
if(v[v2] == searchContent){
if(currStr == searchContent){
research_flag = true;
pre_searched_row = i;
pre_searched_col = i2;
@ -415,7 +419,7 @@ searchNextContent = function(data, firstRow, firstCol, lastRow, lastCol, isRange
}
}
else {
if(string.find(v[v2], searchContent)){
if(string.find(currStr, searchContent)){
research_flag = true;
pre_searched_row = i;
pre_searched_col = i2;
@ -431,7 +435,7 @@ searchNextContent = function(data, firstRow, firstCol, lastRow, lastCol, isRange
research_flag = false;
pre_searched_row = null;
pre_searched_col = null;
row, col = searchNextContent(data, selFirstRow, selFirstCol, lastRow, lastCol, isRangeSearch, selFirstRow, selFirstCol, searchContent, isCellMatching);
row, col = searchNextContent(data, selFirstRow, selFirstCol, lastRow, lastCol, isRangeSearch, selFirstRow, selFirstCol, searchContent, isCaseSensitive, isCellMatching);
return row, col;
}
research_flag = true;
@ -448,14 +452,19 @@ searchNextContent = function(data, firstRow, firstCol, lastRow, lastCol, isRange
if(i == firstRow and i2 == firstCol){
continue;
}
var currStr = v[v2];
if(!isCaseSensitive){
currStr = string.lower(currStr);
searchContent = string.lower(searchContent);
}
if (isCellMatching){
if(v[v2] == searchContent){
if(currStr == searchContent){
research_flag = true;
return i, i2;
}
}
else {
if(string.find(v[v2], searchContent)){
if(string.find(currStr, searchContent)){
research_flag = true;
return i, i2;
}
@ -466,7 +475,7 @@ searchNextContent = function(data, firstRow, firstCol, lastRow, lastCol, isRange
// 搜不到了,重头搜索
if(research_flag){
research_flag = false;
row, col = searchNextContent(data, 1, 1, 1, 1, isRangeSearch, selFirstRow, selFirstCol, searchContent, isCellMatching);
row, col = searchNextContent(data, 1, 1, 1, 1, isRangeSearch, selFirstRow, selFirstCol, searchContent, isCaseSensitive, isCellMatching);
return row, col;
}
research_flag = true;
@ -482,7 +491,8 @@ subscribe("search_prev",function(...){
subscribe("search_next",function(...){
var args = {...};
var searchContent = args[1];
var isCellMatching = args[2];
var isCaseSensitive = args[2];
var isCellMatching = args[3];
var curSelection = mainForm.g_flexcell.selection();
var firstRow = curSelection.FirstRow;
var firstCol = curSelection.FirstCol;
@ -495,7 +505,7 @@ subscribe("search_next",function(...){
if(pre_searched_row != null and pre_searched_col != null){
mainForm.g_flexcell.Cell(pre_searched_row, pre_searched_col).BackColor = 0xffffff;
}
var row, col = searchNextContent(mainForm.g_flexcell.getVlistData(), firstRow, firstCol, lastRow, lastCol, isRangeSearch, firstRow, firstCol, searchContent, isCellMatching);
var row, col = searchNextContent(mainForm.g_flexcell.getVlistData(), firstRow, firstCol, lastRow, lastCol, isRangeSearch, firstRow, firstCol, searchContent, isCaseSensitive, isCellMatching);
//console.dump(row, col);
if(row != null && col != null){
if(isRangeSearch){