解说社区

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 141|回复: 1

[原创] 剪切板编辑器v2.0增加了剪切板和收藏夹列表同时显示,增加了拆分粘贴。

[复制链接]
发表于 2024-2-29 15:43:41 来自手机 | 显示全部楼层 |阅读模式
打开插件,最上面是编辑框,接着是十二个按钮,复制、追加复制、添加到收藏、删除中文、删除英文、合并连续空白、删除空白、删除空行、删行首空白、删行尾空白、英文字母转小写、英文字母转大写,在下面是列表。左边的列表是剪切板,右边的列表是收藏夹,单击会把所在的条目粘贴到编辑框。长按列表项目弹出菜单,第一个是编辑,会把锁在条目输出到编辑框进行编辑,第二个是拆分粘贴,把所选条目按行拆分,第三个按钮是添加到收藏夹。最下面就是说明剪切板收藏夹的管理按钮。



  来自解说社区客户端
回复

使用道具 举报

 楼主| 发表于 2024-2-29 15:44:12 来自手机 | 显示全部楼层
require "import"
import "android.widget.*"
function cfzt(o)
require"import"
local t1,t2={},{}
for s in o:gmatch"[^\n]+"
table.insert(t1,s.."\n")
end
local dlg=LuaDialog()
.setTitle("共"..table.size(t1).."行")
.setMultiChoiceItems(t1,t2)
.setButton("确定",function()
task(300,function()
service.paste(table.concat(t2))
end)
end)
.show()
dlg.onItemClick=function(l,v,p,i)
v=v.text
te=table.find(t2,v)
if not te
table.insert(t2,v)
else
table.remove(t2,te)
end
end
end
local text={
TextView,
id="tv",
layout_height="5%h",
layout_width="fill",
}
data,data2={},{}
local jqb=service.getClipboardList()
local scj=service.getFavoritesList()
for i=0,#jqb-1 do
table.insert(data,{tv=jqb})
end
adapter=LuaAdapter(this,data,text)
for i=0,#scj-1 do
table.insert(data2,{tv=scj})
end
adapter2=LuaAdapter(this,data2,text)
layout={
LinearLayout,
orientation="vertical",
layout_width="fill",
{
EditText,
id="edit",
layout_width="fill",
layout_height="5%h",
},
{LinearLayout,
orientation="horizontal",
layout_height="5%h",
{Button,
text="复制",
onClick=function()
service.copy(edit.text)
end,
layout_width="16.6%w",
},
{Button,
text="追加复制",
onClick=function()
service.appendCopy(edit.text)
end,
layout_width="16.6%w",
},
{Button,
text="添加到收藏",
onClick=function()
service.addFavorites(edit.text)
end,
layout_width="16.6%w",
},
{Button,
text="删除中文",
onClick=function()
local txt=edit.text
s=utf8.gsub(txt,"[\u4e00-\u9fa5-,。?!:;…()、“”—‘’【】《》]","")
edit.text=s
end,
layout_width="16.6%w",
},
{Button,
text="删除英文",
onClick=function()
local txt=edit.text
s=utf8.gsub(txt,"[a-zA-Z,%.%:%!%?%,%~%_@]","")
edit.text=s
end,
layout_width="16.6%w",
},
{Button,
text="合并连续空白",
onClick=function()
local txt=edit.text
s=utf8.gsub(txt,"[  ]+"," ")
edit.text=s
end,
layout_width="16.6%w",
},
},
{LinearLayout,
orientation="horizontal",
layout_height="5%h",
{Button,
text="删除空白",
onClick=function()
local txt=edit.text
s=utf8.gsub(txt,"[  ]","")
edit.text=s
end,
layout_width="16.6%w",
},
{Button,
text="删除空行",
onClick=function()
local txt=edit.text
s=utf8.gsub(txt,"\n+","\n")
s=utf8.gsub(s,"\r+","\r")
edit.text=s
end,
layout_width="16.6%w",
},
{Button,
text="删行首空白",
onClick=function()
local txt=edit.text
s=utf8.gsub(txt,"[  ]*([^\n]*)","%1")
edit.text=s
end,
layout_width="16.6%w",
},
{Button,
text="删行尾空白",
onClick=function()
local txt=edit.text
s=utf8.gsub(txt,"[  ]+\n","\n")
s=utf8.gsub(s,"%s+$","")
edit.text=s
end,
layout_width="16.6%w",
},
{Button,
text="英文字母转小写",
onClick=function()
local s=edit.text
s=utf8.lower(s)
edit.text=s
end,
layout_width="16.6%w",
},
{Button,
text="英文字母转大写",
onClick=function()
local s=edit.text
s=utf8.upper(s)
edit.text=s
end,
layout_width="16.6%w",
},
},
{LinearLayout,
orientation="horizontal",
layout_width=-1,
layout_weight=1,
{ ListView,
id="list",
layout_width="50%w",
layout_height="75%h",
},
{ ListView,
id="list2",
layout_width="50%w",
layout_height="75%h",
},
},
{LinearLayout,
orientation="horizontal",
layout_width=-1,
layout_height="5%h",
layout_weight=1,
{Button,
text="说明",
onClick=function()
print("打开插件,最上面是编辑框,接着是十二个按钮,复制、追加复制、添加到收藏、删除中文、删除英文、合并连续空白、删除空白、删除空行、删行首空白、删行尾空白、英文字母转小写、英文字母转大写,在下面是列表。左边的列表是剪切板,右边的列表是收藏夹,单击会把所在的条目粘贴到编辑框。长按列表项目弹出菜单,第一个是编辑,会把锁在条目输出到编辑框进行编辑,第二个是拆分粘贴,把所选条目按行拆分,第三个按钮是添加到收藏夹。最下面就是说明剪切板收藏夹的管理按钮。")
end,
layout_width=-1,
layout_weight=1,
},

{Button,
text="剪切板管理",
onClick=function()
bjq.dismiss()
service.execute("剪切板",node)
end,
layout_width=-1,
layout_weight=1,
},
{Button,
text="收藏夹管理",
onClick=function()
bjq.dismiss()
service.execute("收藏夹",node)
end,
layout_width=-1,
layout_weight=1,
},

{Button,
text="输出到编辑框",
onClick=function()
bjq.dismiss()
task(200,function()
service.setText(edit.text)
end)
end,
layout_width=-1,
layout_weight=1,
},
},
}
local cj={"编辑","拆分粘贴","添加到收藏"}
bjq=LuaDialog(this)
bjq.setView(loadlayout(layout))
bjq.show()
list.adapter=adapter
list2.adapter=adapter2
list.onItemClick=function(l,v,p)
bjq.dismiss()
task(200,function()
service.paste(v.text)
end)
end
list.onItemLongClick=function(l,v,p)
local dlg=LuaDialog()
.setItems(cj)
.show()
o=v.text
dlg.onItemClick=function(l,v,p,i)
dlg.dismiss()
if cj=="编辑"
edit.text=o
elseif cj=="拆分粘贴"
cfzt(o)
bjq.dismiss()
else
service.addFavorites(o)
service.speak(o.."已添加")
end
end
return true
end
list2.onItemClick=function(l,v,p)
bjq.dismiss()
task(200,function()
service.paste(v.text)
end)
end
list2.onItemLongClick=function(l,v,p,i)
local dlg=LuaDialog()
.setItems(cj)
.show()
o=v.text
dlg.onItemClick=function(l,v,p,i)
dlg.dismiss()
if cj=="编辑"
edit.text=o
elseif cj=="拆分粘贴"
cfzt(o)
bjq.dismiss()
else
service.addFavorites(o)
service.speak(o.."已添加")
end
end
return true
end
return true



  来自解说社区客户端
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|解说社区

GMT+8, 2024-5-3 06:20 , Processed in 0.039186 second(s), 13 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表