Compare commits

..

No commits in common. "main" and "v0.1" have entirely different histories.
main ... v0.1

10 changed files with 194 additions and 1469 deletions

View File

@ -1,46 +1,3 @@
<p align="center"> # TabEditor--
<img src="./res/app.ico" width="200" />
</p>
<h1 align="center">TabEditor++</h1>
<p align="center">
一个制表符分隔的文本数据编辑工具
</p>
<p align="center" style="color:red;"><strong>使用 FlexCell 控件,请支持正版:<a href="https://www.grid2000.com/cn/index.html">https://www.grid2000.com/cn/index.html</a></strong></p>
制表符分隔数据的txt文本编辑器
TabEditor++仅适用于特定场景,小众应用。
## 📃 功能
- 读取以制表符分隔数据的txt文本编辑保存都不会更改其原本格式。
> 若用 Excel 打开这类txt文本保存时会将部分数据添加上双引号以及每行数据末尾都会出现多个多余的制表符
- 制表符分隔的txt文本数据与 sqlite3 数据格式转换
## ✨ 演示
![demo](./res/demo.png)
## 📝 更新日志
- [发行](https://gitea.iioio.com:3000/aardio/TabEditor/releases)
## ✨ 贡献
欢迎贡献、建议、错误报告和修复!
## 💖 致谢
感谢 aardio 的创造者 [aardio 官网](https://aardio.com/) aardio 历经 17 年活跃更新。小轻快,永久免费。一款超好用的 Windows 桌面软件开发工具!!!
感谢 光庆 大佬 [aardio 资源网](https://aar.chengxu.online/)
- flexcell —— 光庆大佬封装的 flexcell 库
- message —— 光庆大佬封装 [message 简单信息框](https://aar.chengxu.online/thread-18.htm)
感谢 FlexCell 作者 [FlexCell 官网](https://www.grid2000.com/cn/index.html),一款灵活易用的表格控件。

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<project ver="10" name="TabEditor++" libEmbed="true" icon="res\app.ico" ui="win" output="TabEditor++.exe" CompanyName="" FileDescription="TabEditor++" LegalCopyright="Copyright (C) iioio.com 2024" ProductName="TabEditor++" InternalName="TabEditor++" FileVersion="0.0.0.11" ProductVersion="0.0.0.11" publishDir="/dist/" dstrip="true" local="false" ignored="false"> <project ver="10" name="TabEditor++" libEmbed="true" icon="res\app.png" ui="win" output="TabEditor++.exe" CompanyName="单位名称" FileDescription="TabEditor++" LegalCopyright="Copyright (C) 作者 2024" ProductName="TabEditor++" InternalName="TabEditor++" FileVersion="0.0.0.4" ProductVersion="0.0.0.4" publishDir="/dist/" dstrip="false" local="false" ignored="false">
<file name="main.aardio" path="main.aardio" comment="main.aardio"/> <file name="main.aardio" path="main.aardio" comment="main.aardio"/>
<folder name="资源文件" path="res" embed="true" local="false" ignored="false"> <folder name="资源文件" path="res" embed="true" local="false" ignored="false">
<file name="app.ico" path="res\app.ico" comment="res\app.ico"/> <file name="app.ico" path="res\app.ico" comment="res\app.ico"/>

View File

@ -5,13 +5,19 @@ winform.add(
btnSearchNext={cls="button";text="查找下一个(F)";left=218;top=83;right=306;bottom=113;db=1;dl=1;font=LOGFONT(name='微软雅黑');z=1}; 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}; 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}; 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=19;top=60;right=111;bottom=87;bgcolor=16777215;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};
checkbox2={cls="checkbox";text="单元格匹配";left=19;top=92;right=111;bottom=119;bgcolor=16777215;font=LOGFONT(h=-14);z=7}; 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}
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}
) )
/*}}*/ /*}}*/
winform.onCancel = function(){
winform.show(false);
}
winform.onOk = function(){
publish("search_next", winform.editSearchInput.text);
}
/* /*
窗口会自动检测默认的对话框快捷键, 窗口会自动检测默认的对话框快捷键,
默认Enter会触发onOk事件ESC键会触发onCancel事件 默认Enter会触发onOk事件ESC键会触发onCancel事件
@ -33,16 +39,9 @@ winform.isDialogMessage = function(hwnd,msg){
return win.isDialogMessage(hwnd,msg); return win.isDialogMessage(hwnd,msg);
} }
winform.onCancel = function(){ winform.onClose = function(hwnd,message,wParam,lParam){
winform.show(false); winform.show(false);
} return false;//禁止关闭
pushSearchNext = function(){
publish("search_next", winform.editSearchInput.text, winform.checkbox.checked, winform.checkbox2.checked);
}
winform.onOk = function(){
pushSearchNext();
} }
winform.btnSearchPrev.oncommand = function(id,event){ winform.btnSearchPrev.oncommand = function(id,event){
@ -50,7 +49,7 @@ winform.btnSearchPrev.oncommand = function(id,event){
} }
winform.btnSearchNext.oncommand = function(id,event){ winform.btnSearchNext.oncommand = function(id,event){
pushSearchNext(); publish("search_next", winform.editSearchInput.text);
} }
winform.button.oncommand = function(id,event){ winform.button.oncommand = function(id,event){
@ -61,11 +60,6 @@ winform.btnSearchPrev.disabled = true;
winform.editSearchInput.setFocus(); winform.editSearchInput.setFocus();
winform.onClose = function(hwnd,message,wParam,lParam){
winform.show(false);
return false;//禁止关闭
}
winform.show(false); winform.show(false);
win.loopMessage(); win.loopMessage();
return winform; return winform;

View File

@ -1,11 +1,6 @@
//flexcell-智能提示 //flexcell-智能提示
//内购版本,严禁外传 //内购版本,严禁外传
import com.activeX;
import util.metaProperty;
import gdip;
import fsys;
if ..io.exist("/lib/flexcell/user.aardio") if ..io.exist("/lib/flexcell/user.aardio")
loadcodex("/lib/flexcell/user.aardio","flexcell"); loadcodex("/lib/flexcell/user.aardio","flexcell");
else loadcodex($"/lib/flexcell/user.lib"); else loadcodex($"/lib/flexcell/user.lib");

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -130,7 +130,7 @@ class TeMenu{
[9] = { [9] = {
tips = "txt 导出 Sqlite3"; tips = "txt 导出 Sqlite3";
text = '\uE612'; text = '\uE612';
font = LOGFONT(h=this.ico_size+5;name='iconfont'); font = LOGFONT(h=this.ico_size;name='iconfont');
style = { style = {
background={}; background={};
foreground={}; foreground={};
@ -144,7 +144,7 @@ class TeMenu{
[10] = { [10] = {
tips = "Sqlite3 导出 txt"; tips = "Sqlite3 导出 txt";
text = '\uE612'; text = '\uE612';
font = LOGFONT(h=this.ico_size+5;name='iconfont'); font = LOGFONT(h=this.ico_size;name='iconfont');
style = { style = {
background={}; background={};
foreground={}; foreground={};
@ -264,53 +264,86 @@ class TeMenu{
}; };
this.init(); this.init();
}; };
setCommandFunc = function(side, idx, func){
getSid = function(side, idx) { select(side) {
var std = {}; case 0 {
if (side == 0) { if (idx > 0 and idx <= #this.toolbars_left) {
std.sd = "plus_left"; var ctrl = winform['plus_left'+idx];
std.n = #this.toolbars_left; winform['plus_left'+idx].oncommand = func(ctrl);
} else {
std.sd = "plus_right";
std.n = #this.toolbars_right;
} }
else {
if (idx > 0 && idx <= std.n) { return false;
std.ctrl = winform[std.sd ++ idx];
return std;
}
return;
}
setCommandFunc = function(side, idx, func) {
var std = this.getSid(side, idx);
if (std) {
std.ctrl.oncommand = func(std.ctrl);
} else {
return;
} }
} }
case 1 {
setRightClickFunc = function(side, idx, func) { if (idx > 0 and idx <= #this.toolbars_right) {
var std = this.getSid(side, idx); var ctrl = winform['plus_right'+idx];
if (std) { winform['plus_right'+idx].oncommand = func(ctrl);
std.ctrl.wndproc = function(hwnd, message, wParam, lParam) { }
if (message == 0x205 /*_WM_RBUTTONUP*/) { else {
func(std.ctrl); return false;
} }
} }
} else { else {
return; return false;
} }
} }
};
disabled = function(side, idx, status) { setRightClickFunc = function(side, idx, func){
var std = this.getSid(side, idx); select(side) {
if (std) { case 0 {
std.ctrl.disabled = status; if (idx > 0 and idx <= #this.toolbars_left) {
} else { var ctrl = winform['plus_left'+idx];
return; winform['plus_left'+idx].wndproc = function(hwnd,message,wParam,lParam){
if (message == 0x205/*_WM_RBUTTONUP*/) {
func(ctrl);
} }
} }
}
else {
return false;
}
}
case 1 {
if (idx > 0 and idx <= #this.toolbars_right) {
var ctrl = winform['plus_right'+idx];
winform['plus_right'+idx].wndproc = function(hwnd,message,wParam,lParam){
if (message == 0x205/*_WM_RBUTTONUP*/) {
func(ctrl);
}
}
}
else {
return false;
}
}
else {
return false;
}
}
}
disabled = function(side, idx, status){
select(side) {
case 0 {
if (idx > 0 and idx <= #this.toolbars_left) {
winform['plus_left'+idx].disabled = status;
}
else {
return false;
}
}
case 1 {
if (idx > 0 and idx <= #this.toolbars_right) {
winform['plus_right'+idx].disabled = status;
}
else {
return false;
}
}
else {
return false;
}
}
};
} }

View File

@ -55,9 +55,6 @@ initFlexCellShow = function(fc){
fc.AutoRedraw = false; fc.AutoRedraw = false;
fc.setTable(t, t.fields, t.fields); fc.setTable(t, t.fields, t.fields);
fc.column(0).AutoFit(); fc.column(0).AutoFit();
if(fc.Column(0).Width < 40){
fc.Column(0).Width = 40;
}
fc.AutoRedraw = true; fc.AutoRedraw = true;
fc.Refresh(); fc.Refresh();
} }
@ -103,6 +100,7 @@ getTxtTableData = function(reference_row = 2){
} }
col_count += 1; col_count += 1;
} }
break;
} }
} }
@ -113,9 +111,7 @@ getTxtTableData = function(reference_row = 2){
for i in ..string.lines(str,'\r\n','\t', col_count){ for i in ..string.lines(str,'\r\n','\t', col_count){
var col_values = {}; var col_values = {};
var isEmptyLine = false; var isEmptyLine = false;
temp_cur_line += 1; temp_cur_line += 1;
for (j=1; col_count; 1) { for (j=1; col_count; 1) {
if(#i == 0){ if(#i == 0){
isEmptyLine = true; isEmptyLine = true;
@ -141,7 +137,6 @@ getTxtTableData = function(reference_row = 2){
var writeTxtFile = function(file_path, vlist_data){ var writeTxtFile = function(file_path, vlist_data){
var file = ..io.open(file_path,"w"); var file = ..io.open(file_path,"w");
setCurFilePath(file_path);
for(i=1;#vlist_data;1){ for(i=1;#vlist_data;1){
var arrLine = {}; var arrLine = {};
for(j=1;#vlist_data.fields;1){ for(j=1;#vlist_data.fields;1){

View File

@ -1,6 +1,7 @@
//RUNAS //RUNAS
import win; import win;
import win.ui; import win.ui;
import win.ui.mask;
import win.ui.toolbar; import win.ui.toolbar;
import win.ui.accelerator; import win.ui.accelerator;
import fonts.fontAwesome; import fonts.fontAwesome;
@ -10,7 +11,7 @@ import flexcell;
import teUtils; import teUtils;
import teMenu; import teMenu;
/*DSG{{*/ /*DSG{{*/
var mainForm = win.form(text="TabEditor++";right=1399;bottom=799;bgcolor=16777215) var mainForm = win.form(text="TabEditor--";right=1399;bottom=799;bgcolor=16777215)
mainForm.add( mainForm.add(
custom={cls="custom";text="自定义控件";left=0;top=36;right=1400;bottom=800;ah=1;aw=1;bgcolor=12639424;db=1;dl=1;dr=1;dt=1;z=2}; custom={cls="custom";text="自定义控件";left=0;top=36;right=1400;bottom=800;ah=1;aw=1;bgcolor=12639424;db=1;dl=1;dr=1;dt=1;z=2};
plus={cls="plus";left=0;top=0;right=1400;bottom=36;bgcolor=16777215;border={left=1;top=1;right=1;color=-6250332};clipBk=false;clipch=1;dl=1;dr=1;dt=1;font=LOGFONT(h=-18);forecolor=16777215;notify=1;repeat="stretch";z=1} plus={cls="plus";left=0;top=0;right=1400;bottom=36;bgcolor=16777215;border={left=1;top=1;right=1;color=-6250332};clipBk=false;clipch=1;dl=1;dr=1;dt=1;font=LOGFONT(h=-18);forecolor=16777215;notify=1;repeat="stretch";z=1}
@ -20,26 +21,27 @@ plus={cls="plus";left=0;top=0;right=1400;bottom=36;bgcolor=16777215;border={left
//整理内存 //整理内存
import process; import process;
import raw; import raw;
EmptyWorkingSet := ::Psapi.api("EmptyWorkingSet","bool(pointer hanld)")
mainForm.release = function(){ mainForm.release = function(){
collectgarbage("collect"); var hanld = process.OpenProcess(0x1f0fff,false,process.getId())
collectgarbage("collect"); EmptyWorkingSet(hanld)
raw.closehandle(hanld)
} }
var frmChild = mainForm.loadForm("\dlg\searchForm.aardio"); var frmChild = mainForm.loadForm("\dlg\searchForm.aardio");
var g_mainform_text_default = mainForm.text;
//菜单控件初始化 //菜单控件初始化
g_teMenus = teMenu.TeMenu(mainForm.plus); g_teMenus = teMenu.TeMenu(mainForm.plus);
//flexcell控件初始化 //flexcell控件初始化
mainForm.g_flexcell = flexcell.FlexGrid(mainForm.custom,,,1); g_flexcell = flexcell.FlexGrid(mainForm.custom,,,1);
mainForm.g_flexcell.setTheme(flexcell.FlexGrid.themeWps); g_flexcell.setTheme(flexcell.FlexGrid.themeWps);
mainForm.g_flexcell.isModified = false; g_flexcell.isModified = false;
mainForm.g_flexcell.ShowResizeTip = true; g_flexcell.ShowResizeTip = true;
teUtils.initFlexCellShow(mainForm.g_flexcell); teUtils.initFlexCellShow(g_flexcell);
mainForm.g_flexcell.AllowFilter = false; g_flexcell.AllowFilter = false;
var showModifyStyle = function(){ var showModifyStyle = function(){
mainForm.g_flexcell.isModified = true; g_flexcell.isModified = true;
if(teUtils.getCurFilePath() == null){ if(teUtils.getCurFilePath() == null){
g_teMenus.disabled(0, 3, true); g_teMenus.disabled(0, 3, true);
} }
@ -52,7 +54,7 @@ var showModifyStyle = function(){
} }
var showUnmodifyStyle = function(){ var showUnmodifyStyle = function(){
mainForm.g_flexcell.isModified = false; g_flexcell.isModified = false;
g_teMenus.disabled(0, 3, true); g_teMenus.disabled(0, 3, true);
g_teMenus.disabled(0, 4, true); g_teMenus.disabled(0, 4, true);
mainForm.text = string.replace(mainForm.text, '[ ][\*]', ""); mainForm.text = string.replace(mainForm.text, '[ ][\*]', "");
@ -63,46 +65,48 @@ showUnmodifyStyle();
//menu-新建 //menu-新建
g_teMenus.newFile = function(ctrl){ g_teMenus.newFile = function(ctrl){
return function(){ return function(){
var curRow = mainForm.g_flexcell.ActiveCell().Row; var curRow = g_flexcell.ActiveCell().Row;
var curCol = mainForm.g_flexcell.ActiveCell().Col; var curCol = g_flexcell.ActiveCell().Col;
mainForm.g_flexcell.FrozenRows = 0; g_flexcell.FrozenRows = 0;
mainForm.g_flexcell.FrozenCols = 0; g_flexcell.FrozenCols = 0;
mainForm.g_flexcell.range(0,0,mainForm.g_flexcell.rowCount,mainForm.g_flexcell.colCount).ClearBackColor(); g_flexcell.range(0,0,0,g_flexcell.colCount).ClearBackColor();
mainForm.g_flexcell.isModified = true;//避免 ModifyStyle, UnmodifyStyle 切换闪烁 g_flexcell.range(0,0,g_flexcell.rowCount,0).ClearBackColor();
mainForm.g_flexcell.clear();
teUtils.initFlexCellShow(mainForm.g_flexcell); g_flexcell.isModified = true;//避免 ModifyStyle, UnmodifyStyle 切换闪烁
g_flexcell.clear();
teUtils.initFlexCellShow(g_flexcell);
showUnmodifyStyle(); showUnmodifyStyle();
mainForm.release();
} }
} }
//menu-打开 //menu-打开
g_teMenus.openFile = function(ctrl){ g_teMenus.openFile = function(ctrl){
return function(){ return function(){
var curRow = g_flexcell.ActiveCell().Row;
var curCol = g_flexcell.ActiveCell().Col;
g_flexcell.FrozenRows = 0;
g_flexcell.FrozenCols = 0;
g_flexcell.range(0,0,0,g_flexcell.colCount).ClearBackColor();
g_flexcell.range(0,0,g_flexcell.rowCount,0).ClearBackColor();
var frmMask = win.ui.mask(mainForm,true)
frmMask.show(true);
var t = teUtils.getTxtTableData(); var t = teUtils.getTxtTableData();
if(t){ if(t){
mainForm.text = g_mainform_text_default; g_flexcell.AutoRedraw = false;
mainForm.text += "[ " + teUtils.getCurFilePath() + " ]"; g_flexcell.setTable(t,,t.fields);
g_teMenus.newFile(); g_flexcell.column(0).AutoFit();
mainForm.g_flexcell.AutoRedraw = false; g_flexcell.AutoRedraw = true;
mainForm.g_flexcell.setTable(t,,t.fields); g_flexcell.Refresh();
mainForm.g_flexcell.column(0).AutoFit();
if(mainForm.g_flexcell.Column(0).Width < 40){
mainForm.g_flexcell.Column(0).Width = 40;
} }
mainForm.g_flexcell.AutoRedraw = true; frmMask.show(false);
mainForm.g_flexcell.Refresh();
collectgarbage("collect");
collectgarbage("collect");
showModifyStyle(); showModifyStyle();
} }
}
} }
//menu-保存 //menu-保存
g_teMenus.saveFile = function(ctrl){ g_teMenus.saveFile = function(ctrl){
return function(){ return function(){
teUtils.saveTxtTableData(mainForm.g_flexcell.getVlistData()); teUtils.saveTxtTableData(g_flexcell.getVlistData());
showUnmodifyStyle(); showUnmodifyStyle();
} }
} }
@ -110,8 +114,7 @@ g_teMenus.saveFile = function(ctrl){
//menu-另存为 //menu-另存为
g_teMenus.saveAsFile = function(ctrl){ g_teMenus.saveAsFile = function(ctrl){
return function(){ return function(){
teUtils.saveAsTxtTableData(mainForm.g_flexcell.getVlistData()); teUtils.saveAsTxtTableData(g_flexcell.getVlistData());
mainForm.text += "[ " + teUtils.getCurFilePath() + " ]";
showUnmodifyStyle(); showUnmodifyStyle();
} }
} }
@ -119,7 +122,7 @@ g_teMenus.saveAsFile = function(ctrl){
//menu-设置背景色 //menu-设置背景色
g_teMenus.setBackground = function(ctrl){ g_teMenus.setBackground = function(ctrl){
return function(){ return function(){
mainForm.g_flexcell.selection().BackColor = color.rgbReverse(ctrl.backgroundColor); g_flexcell.selection().BackColor = color.rgbReverse(ctrl.backgroundColor);
} }
} }
import win.ui.ctrl.pick; import win.ui.ctrl.pick;
@ -152,7 +155,7 @@ g_teMenus.setBackgroundRClick = function(ctrl){
//menu-设置前景色 //menu-设置前景色
g_teMenus.setForeground = function(ctrl){ g_teMenus.setForeground = function(ctrl){
return function(){ return function(){
mainForm.g_flexcell.selection().ForeColor = color.rgbReverse(ctrl.argbColor); g_flexcell.selection().ForeColor = color.rgbReverse(ctrl.argbColor);
} }
} }
g_teMenus.setForegroundRClick = function(ctrl){ g_teMenus.setForegroundRClick = function(ctrl){
@ -189,29 +192,29 @@ var flexFreeeRow = FlexFreeeItem();
var setFlexFreee = function(freee){ var setFlexFreee = function(freee){
if(flexFreeeCol.change){ if(flexFreeeCol.change){
mainForm.g_flexcell.range(flexFreeeCol.start_row, g_flexcell.range(flexFreeeCol.start_row,
flexFreeeCol.start_col, flexFreeeCol.start_col,
flexFreeeCol.end_row, flexFreeeCol.end_row,
flexFreeeCol.end_col).setBorders(2/*_FlexCell2_Edge_Right*/, 0/*_FlexCell2_BorderStyle_cellFlat*/ ); flexFreeeCol.end_col).setBorders(2/*_FlexCell2_Edge_Right*/, 0/*_FlexCell2_BorderStyle_cellFlat*/ );
} }
if(flexFreeeRow.change){ if(flexFreeeRow.change){
mainForm.g_flexcell.range(flexFreeeRow.start_row, g_flexcell.range(flexFreeeRow.start_row,
flexFreeeRow.start_col, flexFreeeRow.start_col,
flexFreeeRow.end_row, flexFreeeRow.end_row,
flexFreeeRow.end_col).setBorders(8/*_FlexCell2_Edge_Bottom*/ , 0/*_FlexCell2_BorderStyle_cellFlat*/ ); flexFreeeRow.end_col).setBorders(8/*_FlexCell2_Edge_Bottom*/ , 0/*_FlexCell2_BorderStyle_cellFlat*/ );
} }
if(!freee){return true;} if(!freee){return true;}
mainForm.g_flexcell.range(flexFreeeCol.start_row, flexFreeeCol.start_col, flexFreeeCol.end_row, flexFreeeCol.end_col g_flexcell.range(flexFreeeCol.start_row, flexFreeeCol.start_col, flexFreeeCol.end_row, flexFreeeCol.end_col
).setBorders(2/*_FlexCell2_Edge_Right*/, 1/*_FlexCell2_BorderStyle_cellFlat*/); ).setBorders(2/*_FlexCell2_Edge_Right*/, 1/*_FlexCell2_BorderStyle_cellFlat*/);
mainForm.g_flexcell.range(flexFreeeRow.start_row, flexFreeeRow.start_col, flexFreeeRow.end_row, flexFreeeRow.end_col g_flexcell.range(flexFreeeRow.start_row, flexFreeeRow.start_col, flexFreeeRow.end_row, flexFreeeRow.end_col
).setBorders(8/*_FlexCell2_Edge_Bottom*/ , 1/*_FlexCell2_BorderStyle_cellFlat*/);; ).setBorders(8/*_FlexCell2_Edge_Bottom*/ , 1/*_FlexCell2_BorderStyle_cellFlat*/);;
} }
//menu-冻结行&列 //menu-冻结行&列
g_teMenus.freeeRowCol = function(ctrl){ g_teMenus.freeeRowCol = function(ctrl){
return function(){ return function(){
var curRow = mainForm.g_flexcell.ActiveCell().Row; var curRow = g_flexcell.ActiveCell().Row;
var curCol = mainForm.g_flexcell.ActiveCell().Col; var curCol = g_flexcell.ActiveCell().Col;
setFlexFreee(false); setFlexFreee(false);
@ -219,7 +222,7 @@ g_teMenus.freeeRowCol = function(ctrl){
flexFreeeCol.change = true; flexFreeeCol.change = true;
flexFreeeCol.start_row = curRow+1; flexFreeeCol.start_row = curRow+1;
flexFreeeCol.start_col = curCol; flexFreeeCol.start_col = curCol;
flexFreeeCol.end_row = mainForm.g_flexcell.rowCount; flexFreeeCol.end_row = g_flexcell.rowCount;
flexFreeeCol.end_col = curCol; flexFreeeCol.end_col = curCol;
//绘制冻结行的底部边框线 //绘制冻结行的底部边框线
@ -227,14 +230,14 @@ g_teMenus.freeeRowCol = function(ctrl){
flexFreeeRow.start_row = curRow; flexFreeeRow.start_row = curRow;
flexFreeeRow.start_col = curCol+1; flexFreeeRow.start_col = curCol+1;
flexFreeeRow.end_row = curRow; flexFreeeRow.end_row = curRow;
flexFreeeRow.end_col = mainForm.g_flexcell.colCount; flexFreeeRow.end_col = g_flexcell.colCount;
setFlexFreee(true); setFlexFreee(true);
//冻结行 //冻结行
mainForm.g_flexcell.FrozenRows = curRow; g_flexcell.FrozenRows = curRow;
//冻结列 //冻结列
mainForm.g_flexcell.FrozenCols = curCol; g_flexcell.FrozenCols = curCol;
} }
} }
@ -242,8 +245,8 @@ g_teMenus.freeeRowCol = function(ctrl){
g_teMenus.unfreeeRowCol = function(ctrl){ g_teMenus.unfreeeRowCol = function(ctrl){
return function(){ return function(){
setFlexFreee(false); setFlexFreee(false);
mainForm.g_flexcell.FrozenRows = 0; g_flexcell.FrozenRows = 0;
mainForm.g_flexcell.FrozenCols = 0; g_flexcell.FrozenCols = 0;
} }
} }
@ -262,9 +265,7 @@ g_teMenus.exportTxt = function(ctrl){
//menu-关于 //menu-关于
g_teMenus.showAbout = function(ctrl){ g_teMenus.showAbout = function(ctrl){
return function(){ return function(){
import fsys.version; //g_flexcell.AboutBox();
var version = fsys.version.getInfo(io._exepath).productVersion;
mainForm.msgbox(version);
} }
} }
@ -295,82 +296,31 @@ pre_searched_row = null;
pre_searched_col = null; pre_searched_col = null;
/*消息回调{{*/ /*消息回调{{*/
mainForm.g_flexcell.onCellChange = function(Row,Col){ g_flexcell.onCellChange = function(Row,Col){
if(!mainForm.g_flexcell.isModified){ if(!g_flexcell.isModified){
showModifyStyle(); showModifyStyle();
} }
mainForm.g_flexcell.isModified = true; g_flexcell.isModified = true;
} }
mainForm.g_flexcell.onClick = function(Row,Col){ g_flexcell.onClick = function(Row,Col){
var row,col=owner.toRelativeRow(Row),owner.toRelativeCol(Col); var row,col=owner.toRelativeRow(Row),owner.toRelativeCol(Col);
} }
//左侧弹出菜单 g_flexcell.onMouseUp = function(Button , Shift, x, y){
mainForm.popmenuLeft = win.ui.popmenu(mainForm);
mainForm.popmenuLeft.add('向上插入一行',function(id){
var curSelection = mainForm.g_flexcell.selection();
teUtils.insertFlexCellNewRow(mainForm.g_flexcell, curSelection.FirstRow, 1, mainForm.g_flexcell.colCount);
curSelection.release();
mainForm.release();
} )
mainForm.popmenuLeft.add('向下插入一行',function(id){
var curSelection = mainForm.g_flexcell.selection();
teUtils.insertFlexCellNewRow(mainForm.g_flexcell, curSelection.FirstRow + 1, 1, mainForm.g_flexcell.colCount);
curSelection.release();
mainForm.release();
} )
mainForm.popmenuLeft.add('删除行',function(id){
var curSelection = mainForm.g_flexcell.selection();
mainForm.g_flexcell.delRow(curSelection.FirstRow, 1/*删除数量*/);
curSelection.release();
mainForm.release();
} )
//右侧弹出菜单
mainForm.popmenuRight = win.ui.popmenu(mainForm);
mainForm.popmenuRight.add('向左插入一列',function(id){
var curSelection = mainForm.g_flexcell.selection();
teUtils.insertFlexCellNewCol(mainForm.g_flexcell, curSelection.FirstCol, 1, mainForm.g_flexcell.colCount);
curSelection.release();
mainForm.release();
} )
mainForm.popmenuRight.add('向右插入一列',function(id){
var curSelection = mainForm.g_flexcell.selection();
teUtils.insertFlexCellNewCol(mainForm.g_flexcell, curSelection.FirstCol+1, 1, mainForm.g_flexcell.colCount);
curSelection.release();
mainForm.release();
} )
mainForm.popmenuRight.add('删除列',function(id){
var curSelection = mainForm.g_flexcell.selection();
//TODO
mainForm.msgbox("暂无删除列功能--TODO");
curSelection.release();
mainForm.release();
} )
mainForm.g_flexcell.onMouseUp = function(Button , Shift, x, y){
/*** 鼠标按键放开。 /*** 鼠标按键放开。
Button 当前按下的鼠标按钮1左按钮2右按钮4中间按钮同时按下时执行位或操作。 Button 当前按下的鼠标按钮1左按钮2右按钮4中间按钮同时按下时执行位或操作。
Shift 功能键状态1SHIFT2CTRL4ALT同时按下时执行位或操作。 Shift 功能键状态1SHIFT2CTRL4ALT同时按下时执行位或操作。
x,y 鼠标指针当前位置 ***/ x,y 鼠标指针当前位置 ***/
if(Button == 2){ if(Button == 2){
mainForm.g_flexcell.cell(mainForm.g_flexcell.MouseRow, mainForm.g_flexcell.MouseCol).Select(); g_flexcell.cell(g_flexcell.MouseRow,g_flexcell.MouseCol).Select();
var x,y = win.getMessagePos();
if(mainForm.g_flexcell.MouseCol == 0){
mainForm.popmenuLeft.popup(x,y,true)
}
elseif(mainForm.g_flexcell.MouseRow == 0){
mainForm.popmenuRight.popup(x,y,true)
}
} }
if(pre_searched_row != null and pre_searched_col != null){ if(pre_searched_row != null and pre_searched_col != null){
mainForm.g_flexcell.Cell(pre_searched_row, pre_searched_col).BackColor = 0xffffff; g_flexcell.Cell(pre_searched_row, pre_searched_col).BackColor = 0xffffff;
pre_searched_row = null;
pre_searched_col = null;
} }
} }
mainForm.g_flexcell.onSelChange = function(FirstRow,FirstCol,LastRow,LastCol){ g_flexcell.onSelChange = function(FirstRow,FirstCol,LastRow,LastCol){
/*** 在Selection选择范围改变时发生。参数起始行起始列结束行结束列 ***/ /*** 在Selection选择范围改变时发生。参数起始行起始列结束行结束列 ***/
var row1,col1=owner.toRelativeRow(FirstRow),owner.toRelativeCol(FirstCol); var row1,col1=owner.toRelativeRow(FirstRow),owner.toRelativeCol(FirstCol);
var row2,col2=owner.toRelativeRow(LastRow),owner.toRelativeCol(LastCol); var row2,col2=owner.toRelativeRow(LastRow),owner.toRelativeCol(LastCol);
@ -378,9 +328,22 @@ mainForm.g_flexcell.onSelChange = function(FirstRow,FirstCol,LastRow,LastCol){
} }
/*}}*/ /*}}*/
//搜索窗口
var openSearchForm = function(){
frmChild.show();
}
var accelerator = win.ui.accelerator({
{
ctrl = true; vkey = 'F'#;
oncommand = function() openSearchForm();
};
},mainForm );
research_flag = true; research_flag = true;
searchNextContent = function(data, firstRow, firstCol, lastRow, lastCol, isRangeSearch, selFirstRow, selFirstCol, searchContent, isCaseSensitive, isCellMatching){ searchNextContent = function(data, firstRow, firstCol, lastRow, lastCol, isRangeSearch, selFirstRow, selFirstCol, str){
if(isRangeSearch){// 从一个范围开始搜索 if(isRangeSearch){// 从一个范围开始搜索
//console.dump("从一个范围开始搜索");
var tempRow = firstRow; var tempRow = firstRow;
var tempCol = firstCol; var tempCol = firstCol;
firstRow = pre_searched_row != null and research_flag ? pre_searched_row : firstRow; firstRow = pre_searched_row != null and research_flag ? pre_searched_row : firstRow;
@ -390,89 +353,57 @@ searchNextContent = function(data, firstRow, firstCol, lastRow, lastCol, isRange
continue; continue;
} }
for i2,v2 in table.eachIndex(data.fields){ for i2,v2 in table.eachIndex(data.fields){
//console.debug("当前搜索行列:", i, i2);
if(i2 < firstCol or i2 > lastCol){ if(i2 < firstCol or i2 > lastCol){
continue; continue;
} }
if (i == pre_searched_row and i2 == pre_searched_col){ if (i == pre_searched_row and i2 == pre_searched_col){
continue; continue;
} }
var currStr = v[v2]; if(v[v2] == str){
if(#currStr == 0 and #searchContent != 0){
continue;
}
if(!isCaseSensitive){
currStr = string.lower(currStr);
searchContent = string.lower(searchContent);
}
if (isCellMatching){
if(currStr == searchContent){
research_flag = true; research_flag = true;
pre_searched_row = i; pre_searched_row = i;
pre_searched_col = i2; pre_searched_col = i2;
return i, i2; return i, i2;
} }
} }
else {
if(string.find(currStr, searchContent) or currStr == searchContent){
research_flag = true;
pre_searched_row = i;
pre_searched_col = i2;
return i, i2;
}
}
}
firstCol = tempRow; firstCol = tempRow;
firstCol = tempCol; firstCol = tempCol;
} }
// 搜不到了,重头搜索 // 搜不到了,重头搜索
if(research_flag){ if(research_flag){
research_flag = false; research_flag = false;
pre_searched_row = null; row, col = searchNextContent(data, selFirstRow, selFirstCol, lastRow, lastCol, isRangeSearch, selFirstRow, selFirstCol, str);
pre_searched_col = null;
row, col = searchNextContent(data, selFirstRow, selFirstCol, lastRow, lastCol, isRangeSearch, selFirstRow, selFirstCol, searchContent, isCaseSensitive, isCellMatching);
return row, col; return row, col;
} }
research_flag = true; research_flag = true;
} }
else {// 从一个点开始搜索 else {// 从一个点开始搜索
//console.dump("从一个点开始搜索");
for i,v in table.eachIndex(data){ for i,v in table.eachIndex(data){
if(i < firstRow){ if(i < firstRow){
continue; continue;
} }
for i2,v2 in table.eachIndex(data.fields){ for i2,v2 in table.eachIndex(data.fields){
//console.debug("当前搜索行列:", i, i2);
if(i2 < firstCol){ if(i2 < firstCol){
continue continue
} }
if(i == firstRow and i2 == firstCol){ if(i == firstRow and i2 == firstCol){
continue; continue;
} }
var currStr = v[v2]; if(v[v2] == str){
if(#currStr == 0 and #searchContent != 0){
continue;
}
if(!isCaseSensitive){
currStr = string.lower(currStr);
searchContent = string.lower(searchContent);
}
if (isCellMatching){
if(currStr == searchContent){
research_flag = true; research_flag = true;
return i, i2; return i, i2;
} }
} }
else {
if(string.find(currStr, searchContent) or currStr == searchContent){
research_flag = true;
return i, i2;
}
}
}
firstCol = 1; firstCol = 1;
} }
// 搜不到了,重头搜索 // 搜不到了,重头搜索
if(research_flag){ if(research_flag){
research_flag = false; research_flag = false;
row, col = searchNextContent(data, 1, 1, 1, 1, isRangeSearch, selFirstRow, selFirstCol, searchContent, isCaseSensitive, isCellMatching); //console.dump("搜不到了,重头搜索");
row, col = searchNextContent(data, 1, 1, 1, 1, isRangeSearch, selFirstRow, selFirstCol, str);
return row, col; return row, col;
} }
research_flag = true; research_flag = true;
@ -486,11 +417,7 @@ subscribe("search_prev",function(...){
subscribe("search_next",function(...){ subscribe("search_next",function(...){
var args = {...}; var curSelection = g_flexcell.selection();
var searchContent = args[1];
var isCaseSensitive = args[2];
var isCellMatching = args[3];
var curSelection = mainForm.g_flexcell.selection();
var firstRow = curSelection.FirstRow; var firstRow = curSelection.FirstRow;
var firstCol = curSelection.FirstCol; var firstCol = curSelection.FirstCol;
var lastRow = curSelection.LastRow; var lastRow = curSelection.LastRow;
@ -500,21 +427,21 @@ subscribe("search_next",function(...){
isRangeSearch = true; isRangeSearch = true;
} }
if(pre_searched_row != null and pre_searched_col != null){ if(pre_searched_row != null and pre_searched_col != null){
mainForm.g_flexcell.Cell(pre_searched_row, pre_searched_col).BackColor = 0xffffff; 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, isCaseSensitive, isCellMatching); var row, col = searchNextContent(g_flexcell.getVlistData(), firstRow, firstCol, lastRow, lastCol, isRangeSearch, firstRow, firstCol, ...);
//console.dump(row, col); //console.dump(row, col);
if(row != null && col != null){ if(row != null && col != null){
if(isRangeSearch){ if(isRangeSearch){
if(pre_searched_row != null and pre_searched_col != null){ if(pre_searched_row != null and pre_searched_col != null){
mainForm.g_flexcell.Cell(pre_searched_row, pre_searched_col).BackColor = 0xff00ff; g_flexcell.Cell(pre_searched_row, pre_searched_col).BackColor = 0xff00ff;
} }
mainForm.g_flexcell.Cell(row, col).EnsureVisible(); g_flexcell.Cell(row, col).EnsureVisible();
} }
else { else {
pre_searched_row = null; pre_searched_row = null;
pre_searched_col = null; pre_searched_col = null;
mainForm.g_flexcell.cell(row, col).Select(); g_flexcell.cell(row, col).Select();
} }
} }
else { else {
@ -523,31 +450,6 @@ subscribe("search_next",function(...){
curSelection.release(); curSelection.release();
} ) } )
//搜索窗口
var openSearchForm = function(){
frmChild.show();
frmChild.editSearchInput.setFocus();
}
var accelerator = win.ui.accelerator({
{
ctrl = true; vkey = 'F'#;
oncommand = function() openSearchForm();
};
{
ctrl = true; vkey = 'S'#;
oncommand = function(){
var curRow = mainForm.g_flexcell.ActiveCell().Row;
var curCol = mainForm.g_flexcell.ActiveCell().Col;
mainForm.g_flexcell.Cell(curRow, curCol).SetFocus(); // 不加这个,光标处于的单元格内容不会被保存----规避方案
teUtils.saveTxtTableData(mainForm.g_flexcell.getVlistData());
showUnmodifyStyle();
};
};
},mainForm );
import win.ui.minmax; import win.ui.minmax;
win.ui.minmax(mainForm,860,400); win.ui.minmax(mainForm,860,400);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 98 KiB