Compare commits

..

20 Commits
v0.1 ... main

Author SHA1 Message Date
5c49d2ecc8 优化菜单按钮响应代码,由网友提供:https://aarbbs.com/198.html#comment-104 2024-09-17 22:47:28 +08:00
efc8e21f46 更新 README.md 2024-07-20 22:14:14 +08:00
14efdfae8e 更新readme 2024-07-20 22:09:36 +08:00
d4c925c9b9 fix #2 修复程序标题显示逻辑错误问题 2024-07-20 21:53:13 +08:00
87d3adc4f8 增加Ctrl+S保存快捷键 2024-07-20 21:43:20 +08:00
72f279c6b7 修改about显示版本号 2024-07-07 22:49:15 +08:00
6fe5ab323e 修改about菜单 2024-07-07 22:43:58 +08:00
5fe1352ed6 fix #1 默认情况下,带英文冒号的字串搜索不到 2024-07-07 22:41:41 +08:00
2e416232b1 更新readme 2024-06-20 23:20:49 +08:00
cf62c0df8b 更新readme 2024-06-20 23:19:38 +08:00
6221a7dd6d 新增区分大小写搜索 2024-06-20 22:55:52 +08:00
6b628c7ac3 布局调整 2024-06-19 21:30:05 +08:00
d822c0e433 标题显示当前编辑的文件完整路径 2024-06-19 20:25:42 +08:00
0bcc5d19f4 去除部分调试信息 2024-06-19 20:15:16 +08:00
dfb3c82dcd 修复当范围内结果只有一个时不会循环搜索到该数据 2024-06-19 20:14:01 +08:00
c105bb17cd 弹出菜单添加删除行 2024-06-18 23:18:39 +08:00
da52c467cc 使用垃圾回收替代内存回收api 2024-06-18 23:08:53 +08:00
662a00aed3 增加添加行列弹出菜单,优化部分代码 2024-06-18 22:59:26 +08:00
947f767ac9 优化部分逻辑 2024-06-17 23:41:57 +08:00
6ac9cdfd6e 优化一些细节 2024-06-16 22:50:27 +08:00
10 changed files with 1471 additions and 196 deletions

View File

@ -1,3 +1,46 @@
# TabEditor-- <p align="center">
<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.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"> <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">
<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,19 +5,13 @@ 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};
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}; checkbox={cls="checkbox";text="区分大小写";left=19;top=60;right=111;bottom=87;bgcolor=16777215;font=LOGFONT(h=-14);z=6};
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} 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}
) )
/*}}*/ /*}}*/
winform.onCancel = function(){
winform.show(false);
}
winform.onOk = function(){
publish("search_next", winform.editSearchInput.text);
}
/* /*
窗口会自动检测默认的对话框快捷键, 窗口会自动检测默认的对话框快捷键,
默认Enter会触发onOk事件ESC键会触发onCancel事件 默认Enter会触发onOk事件ESC键会触发onCancel事件
@ -39,9 +33,16 @@ winform.isDialogMessage = function(hwnd,msg){
return win.isDialogMessage(hwnd,msg); return win.isDialogMessage(hwnd,msg);
} }
winform.onClose = function(hwnd,message,wParam,lParam){ winform.onCancel = function(){
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){
@ -49,7 +50,7 @@ winform.btnSearchPrev.oncommand = function(id,event){
} }
winform.btnSearchNext.oncommand = function(id,event){ winform.btnSearchNext.oncommand = function(id,event){
publish("search_next", winform.editSearchInput.text); pushSearchNext();
} }
winform.button.oncommand = function(id,event){ winform.button.oncommand = function(id,event){
@ -60,6 +61,11 @@ 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,6 +1,11 @@
//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.

1151
lib/message.aardio Normal file

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;name='iconfont'); font = LOGFONT(h=this.ico_size+5;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;name='iconfont'); font = LOGFONT(h=this.ico_size+5;name='iconfont');
style = { style = {
background={}; background={};
foreground={}; foreground={};
@ -264,86 +264,53 @@ class TeMenu{
}; };
this.init(); this.init();
}; };
setCommandFunc = function(side, idx, func){
select(side) { getSid = function(side, idx) {
case 0 { var std = {};
if (idx > 0 and idx <= #this.toolbars_left) { if (side == 0) {
var ctrl = winform['plus_left'+idx]; std.sd = "plus_left";
winform['plus_left'+idx].oncommand = func(ctrl); std.n = #this.toolbars_left;
} } else {
else { std.sd = "plus_right";
return false; std.n = #this.toolbars_right;
} }
}
case 1 { if (idx > 0 && idx <= std.n) {
if (idx > 0 and idx <= #this.toolbars_right) { std.ctrl = winform[std.sd ++ idx];
var ctrl = winform['plus_right'+idx]; return std;
winform['plus_right'+idx].oncommand = func(ctrl); }
} return;
else { }
return false;
} setCommandFunc = function(side, idx, func) {
} var std = this.getSid(side, idx);
else { if (std) {
return false; std.ctrl.oncommand = func(std.ctrl);
} } else {
} return;
}; }
setRightClickFunc = function(side, idx, func){ }
select(side) {
case 0 { setRightClickFunc = function(side, idx, func) {
if (idx > 0 and idx <= #this.toolbars_left) { var std = this.getSid(side, idx);
var ctrl = winform['plus_left'+idx]; if (std) {
winform['plus_left'+idx].wndproc = function(hwnd,message,wParam,lParam){ std.ctrl.wndproc = function(hwnd, message, wParam, lParam) {
if (message == 0x205/*_WM_RBUTTONUP*/) { if (message == 0x205 /*_WM_RBUTTONUP*/) {
func(ctrl); func(std.ctrl);
} }
} }
} } else {
else { return;
return false; }
} }
}
case 1 { disabled = function(side, idx, status) {
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].wndproc = function(hwnd,message,wParam,lParam){ std.ctrl.disabled = status;
if (message == 0x205/*_WM_RBUTTONUP*/) { } else {
func(ctrl); return;
}
}
}
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,6 +55,9 @@ 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();
} }
@ -100,7 +103,6 @@ getTxtTableData = function(reference_row = 2){
} }
col_count += 1; col_count += 1;
} }
break;
} }
} }
@ -111,7 +113,9 @@ 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;
@ -137,6 +141,7 @@ 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,7 +1,6 @@
//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;
@ -11,7 +10,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}
@ -21,27 +20,26 @@ 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(){
var hanld = process.OpenProcess(0x1f0fff,false,process.getId()) collectgarbage("collect");
EmptyWorkingSet(hanld) collectgarbage("collect");
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控件初始化
g_flexcell = flexcell.FlexGrid(mainForm.custom,,,1); mainForm.g_flexcell = flexcell.FlexGrid(mainForm.custom,,,1);
g_flexcell.setTheme(flexcell.FlexGrid.themeWps); mainForm.g_flexcell.setTheme(flexcell.FlexGrid.themeWps);
g_flexcell.isModified = false; mainForm.g_flexcell.isModified = false;
g_flexcell.ShowResizeTip = true; mainForm.g_flexcell.ShowResizeTip = true;
teUtils.initFlexCellShow(g_flexcell); teUtils.initFlexCellShow(mainForm.g_flexcell);
g_flexcell.AllowFilter = false; mainForm.g_flexcell.AllowFilter = false;
var showModifyStyle = function(){ var showModifyStyle = function(){
g_flexcell.isModified = true; mainForm.g_flexcell.isModified = true;
if(teUtils.getCurFilePath() == null){ if(teUtils.getCurFilePath() == null){
g_teMenus.disabled(0, 3, true); g_teMenus.disabled(0, 3, true);
} }
@ -54,7 +52,7 @@ var showModifyStyle = function(){
} }
var showUnmodifyStyle = function(){ var showUnmodifyStyle = function(){
g_flexcell.isModified = false; mainForm.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, '[ ][\*]', "");
@ -65,48 +63,46 @@ showUnmodifyStyle();
//menu-新建 //menu-新建
g_teMenus.newFile = function(ctrl){ g_teMenus.newFile = function(ctrl){
return function(){ return function(){
var curRow = g_flexcell.ActiveCell().Row; var curRow = mainForm.g_flexcell.ActiveCell().Row;
var curCol = g_flexcell.ActiveCell().Col; var curCol = mainForm.g_flexcell.ActiveCell().Col;
g_flexcell.FrozenRows = 0; mainForm.g_flexcell.FrozenRows = 0;
g_flexcell.FrozenCols = 0; mainForm.g_flexcell.FrozenCols = 0;
g_flexcell.range(0,0,0,g_flexcell.colCount).ClearBackColor(); mainForm.g_flexcell.range(0,0,mainForm.g_flexcell.rowCount,mainForm.g_flexcell.colCount).ClearBackColor();
g_flexcell.range(0,0,g_flexcell.rowCount,0).ClearBackColor(); mainForm.g_flexcell.isModified = true;//避免 ModifyStyle, UnmodifyStyle 切换闪烁
mainForm.g_flexcell.clear();
g_flexcell.isModified = true;//避免 ModifyStyle, UnmodifyStyle 切换闪烁 teUtils.initFlexCellShow(mainForm.g_flexcell);
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){
g_flexcell.AutoRedraw = false; mainForm.text = g_mainform_text_default;
g_flexcell.setTable(t,,t.fields); mainForm.text += "[ " + teUtils.getCurFilePath() + " ]";
g_flexcell.column(0).AutoFit(); g_teMenus.newFile();
g_flexcell.AutoRedraw = true; mainForm.g_flexcell.AutoRedraw = false;
g_flexcell.Refresh(); mainForm.g_flexcell.setTable(t,,t.fields);
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;
mainForm.g_flexcell.Refresh();
collectgarbage("collect");
collectgarbage("collect");
showModifyStyle();
} }
frmMask.show(false);
showModifyStyle();
} }
} }
//menu-保存 //menu-保存
g_teMenus.saveFile = function(ctrl){ g_teMenus.saveFile = function(ctrl){
return function(){ return function(){
teUtils.saveTxtTableData(g_flexcell.getVlistData()); teUtils.saveTxtTableData(mainForm.g_flexcell.getVlistData());
showUnmodifyStyle(); showUnmodifyStyle();
} }
} }
@ -114,7 +110,8 @@ g_teMenus.saveFile = function(ctrl){
//menu-另存为 //menu-另存为
g_teMenus.saveAsFile = function(ctrl){ g_teMenus.saveAsFile = function(ctrl){
return function(){ return function(){
teUtils.saveAsTxtTableData(g_flexcell.getVlistData()); teUtils.saveAsTxtTableData(mainForm.g_flexcell.getVlistData());
mainForm.text += "[ " + teUtils.getCurFilePath() + " ]";
showUnmodifyStyle(); showUnmodifyStyle();
} }
} }
@ -122,7 +119,7 @@ g_teMenus.saveAsFile = function(ctrl){
//menu-设置背景色 //menu-设置背景色
g_teMenus.setBackground = function(ctrl){ g_teMenus.setBackground = function(ctrl){
return function(){ return function(){
g_flexcell.selection().BackColor = color.rgbReverse(ctrl.backgroundColor); mainForm.g_flexcell.selection().BackColor = color.rgbReverse(ctrl.backgroundColor);
} }
} }
import win.ui.ctrl.pick; import win.ui.ctrl.pick;
@ -155,7 +152,7 @@ g_teMenus.setBackgroundRClick = function(ctrl){
//menu-设置前景色 //menu-设置前景色
g_teMenus.setForeground = function(ctrl){ g_teMenus.setForeground = function(ctrl){
return function(){ return function(){
g_flexcell.selection().ForeColor = color.rgbReverse(ctrl.argbColor); mainForm.g_flexcell.selection().ForeColor = color.rgbReverse(ctrl.argbColor);
} }
} }
g_teMenus.setForegroundRClick = function(ctrl){ g_teMenus.setForegroundRClick = function(ctrl){
@ -192,29 +189,29 @@ var flexFreeeRow = FlexFreeeItem();
var setFlexFreee = function(freee){ var setFlexFreee = function(freee){
if(flexFreeeCol.change){ if(flexFreeeCol.change){
g_flexcell.range(flexFreeeCol.start_row, mainForm.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){
g_flexcell.range(flexFreeeRow.start_row, mainForm.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;}
g_flexcell.range(flexFreeeCol.start_row, flexFreeeCol.start_col, flexFreeeCol.end_row, flexFreeeCol.end_col mainForm.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*/);
g_flexcell.range(flexFreeeRow.start_row, flexFreeeRow.start_col, flexFreeeRow.end_row, flexFreeeRow.end_col mainForm.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 = g_flexcell.ActiveCell().Row; var curRow = mainForm.g_flexcell.ActiveCell().Row;
var curCol = g_flexcell.ActiveCell().Col; var curCol = mainForm.g_flexcell.ActiveCell().Col;
setFlexFreee(false); setFlexFreee(false);
@ -222,7 +219,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 = g_flexcell.rowCount; flexFreeeCol.end_row = mainForm.g_flexcell.rowCount;
flexFreeeCol.end_col = curCol; flexFreeeCol.end_col = curCol;
//绘制冻结行的底部边框线 //绘制冻结行的底部边框线
@ -230,14 +227,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 = g_flexcell.colCount; flexFreeeRow.end_col = mainForm.g_flexcell.colCount;
setFlexFreee(true); setFlexFreee(true);
//冻结行 //冻结行
g_flexcell.FrozenRows = curRow; mainForm.g_flexcell.FrozenRows = curRow;
//冻结列 //冻结列
g_flexcell.FrozenCols = curCol; mainForm.g_flexcell.FrozenCols = curCol;
} }
} }
@ -245,8 +242,8 @@ g_teMenus.freeeRowCol = function(ctrl){
g_teMenus.unfreeeRowCol = function(ctrl){ g_teMenus.unfreeeRowCol = function(ctrl){
return function(){ return function(){
setFlexFreee(false); setFlexFreee(false);
g_flexcell.FrozenRows = 0; mainForm.g_flexcell.FrozenRows = 0;
g_flexcell.FrozenCols = 0; mainForm.g_flexcell.FrozenCols = 0;
} }
} }
@ -265,7 +262,9 @@ g_teMenus.exportTxt = function(ctrl){
//menu-关于 //menu-关于
g_teMenus.showAbout = function(ctrl){ g_teMenus.showAbout = function(ctrl){
return function(){ return function(){
//g_flexcell.AboutBox(); import fsys.version;
var version = fsys.version.getInfo(io._exepath).productVersion;
mainForm.msgbox(version);
} }
} }
@ -296,31 +295,82 @@ pre_searched_row = null;
pre_searched_col = null; pre_searched_col = null;
/*消息回调{{*/ /*消息回调{{*/
g_flexcell.onCellChange = function(Row,Col){ mainForm.g_flexcell.onCellChange = function(Row,Col){
if(!g_flexcell.isModified){ if(!mainForm.g_flexcell.isModified){
showModifyStyle(); showModifyStyle();
} }
g_flexcell.isModified = true; mainForm.g_flexcell.isModified = true;
} }
g_flexcell.onClick = function(Row,Col){ mainForm.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){
g_flexcell.cell(g_flexcell.MouseRow,g_flexcell.MouseCol).Select(); mainForm.g_flexcell.cell(mainForm.g_flexcell.MouseRow, mainForm.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){
g_flexcell.Cell(pre_searched_row, pre_searched_col).BackColor = 0xffffff; mainForm.g_flexcell.Cell(pre_searched_row, pre_searched_col).BackColor = 0xffffff;
pre_searched_row = null;
pre_searched_col = null;
} }
} }
g_flexcell.onSelChange = function(FirstRow,FirstCol,LastRow,LastCol){ mainForm.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);
@ -328,22 +378,9 @@ 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, str){ searchNextContent = function(data, firstRow, firstCol, lastRow, lastCol, isRangeSearch, selFirstRow, selFirstCol, searchContent, isCaseSensitive, isCellMatching){
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;
@ -353,18 +390,35 @@ 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;
} }
if(v[v2] == str){ var currStr = v[v2];
research_flag = true; if(#currStr == 0 and #searchContent != 0){
pre_searched_row = i; continue;
pre_searched_col = i2; }
return i, i2; if(!isCaseSensitive){
currStr = string.lower(currStr);
searchContent = string.lower(searchContent);
}
if (isCellMatching){
if(currStr == searchContent){
research_flag = true;
pre_searched_row = i;
pre_searched_col = 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;
@ -373,28 +427,44 @@ searchNextContent = function(data, firstRow, firstCol, lastRow, lastCol, isRange
// 搜不到了,重头搜索 // 搜不到了,重头搜索
if(research_flag){ if(research_flag){
research_flag = false; research_flag = false;
row, col = searchNextContent(data, selFirstRow, selFirstCol, lastRow, lastCol, isRangeSearch, selFirstRow, selFirstCol, str); pre_searched_row = null;
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;
} }
if(v[v2] == str){ var currStr = v[v2];
research_flag = true; if(#currStr == 0 and #searchContent != 0){
return i, i2; continue;
}
if(!isCaseSensitive){
currStr = string.lower(currStr);
searchContent = string.lower(searchContent);
}
if (isCellMatching){
if(currStr == searchContent){
research_flag = true;
return i, i2;
}
}
else {
if(string.find(currStr, searchContent) or currStr == searchContent){
research_flag = true;
return i, i2;
}
} }
} }
firstCol = 1; firstCol = 1;
@ -402,8 +472,7 @@ searchNextContent = function(data, firstRow, firstCol, lastRow, lastCol, isRange
// 搜不到了,重头搜索 // 搜不到了,重头搜索
if(research_flag){ if(research_flag){
research_flag = false; research_flag = false;
//console.dump("搜不到了,重头搜索"); row, col = searchNextContent(data, 1, 1, 1, 1, isRangeSearch, selFirstRow, selFirstCol, searchContent, isCaseSensitive, isCellMatching);
row, col = searchNextContent(data, 1, 1, 1, 1, isRangeSearch, selFirstRow, selFirstCol, str);
return row, col; return row, col;
} }
research_flag = true; research_flag = true;
@ -417,7 +486,11 @@ subscribe("search_prev",function(...){
subscribe("search_next",function(...){ subscribe("search_next",function(...){
var curSelection = g_flexcell.selection(); var args = {...};
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;
@ -427,21 +500,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){
g_flexcell.Cell(pre_searched_row, pre_searched_col).BackColor = 0xffffff; mainForm.g_flexcell.Cell(pre_searched_row, pre_searched_col).BackColor = 0xffffff;
} }
var row, col = searchNextContent(g_flexcell.getVlistData(), firstRow, firstCol, lastRow, lastCol, isRangeSearch, firstRow, firstCol, ...); var row, col = searchNextContent(mainForm.g_flexcell.getVlistData(), firstRow, firstCol, lastRow, lastCol, isRangeSearch, firstRow, firstCol, searchContent, isCaseSensitive, isCellMatching);
//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){
g_flexcell.Cell(pre_searched_row, pre_searched_col).BackColor = 0xff00ff; mainForm.g_flexcell.Cell(pre_searched_row, pre_searched_col).BackColor = 0xff00ff;
} }
g_flexcell.Cell(row, col).EnsureVisible(); mainForm.g_flexcell.Cell(row, col).EnsureVisible();
} }
else { else {
pre_searched_row = null; pre_searched_row = null;
pre_searched_col = null; pre_searched_col = null;
g_flexcell.cell(row, col).Select(); mainForm.g_flexcell.cell(row, col).Select();
} }
} }
else { else {
@ -450,6 +523,31 @@ 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);

BIN
res/demo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB