@ -33,7 +33,7 @@ local TextEditor = WidgetContainer:new{
}
}
functionTextEditor:onDispatcherRegisterActions()
functionTextEditor:onDispatcherRegisterActions()
Dispatcher:registerAction("edit_last_edited_file",{category="none",event="OpenLastEditedFile",title=_("Texteditor: open last file"),device=true,separator=true,})
Dispatcher:registerAction("edit_last_edited_file",{category="none",event="OpenLastEditedFile",title=_("Texteditor: open last file"),device=true,separator=true})
end
end
functionTextEditor:init()
functionTextEditor:init()
@ -97,14 +97,17 @@ end
functionTextEditor:getSubMenuItems()
functionTextEditor:getSubMenuItems()
self:loadSettings()
self:loadSettings()
self.whenDoneFunc=nil-- discard reference to previous TouchMenu instance
self.whenDoneFunc=nil-- discard reference to previous TouchMenu instance
localsub_item_table={
localsub_item_table
sub_item_table={
{
{
text=_("Settings"),
text=_("Settings"),
sub_item_table={
sub_item_table={
{
{
text=_("Text font size"),
text_func=function()
returnT(_("Text font size (%1)"),self.font_size)
end,
keep_menu_open=true,
keep_menu_open=true,
callback=function()
callback=function(touchmenu_instance)
localSpinWidget=require("ui/widget/spinwidget")
localSpinWidget=require("ui/widget/spinwidget")
localfont_size=self.font_size
localfont_size=self.font_size
UIManager:show(SpinWidget:new{
UIManager:show(SpinWidget:new{
@ -116,6 +119,7 @@ function TextEditor:getSubMenuItems()
title_text=_("Text font size"),
title_text=_("Text font size"),
callback=function(spin)
callback=function(spin)
self.font_size=spin.value
self.font_size=spin.value
touchmenu_instance:updateItems()
end,
end,
})
})
end,
end,
@ -179,6 +183,31 @@ Export text to QR code, that can be scanned, for example, by a phone.]]),
callback=function()
callback=function()
self.qr_code_export=notself.qr_code_export
self.qr_code_export=notself.qr_code_export
end,
end,
separator=true,
},
{
text=_("Clean text editor history"),
enabled_func=function()
return#self.history>0
end,
keep_menu_open=true,
callback=function(touchmenu_instance)
UIManager:show(ConfirmBox:new{
text=_("Clean text editor history?"),
ok_text=_("Clean"),
ok_callback=function()
self.history={}
self.last_view_pos={}
-- remove history items from the parent menu
forj=#sub_item_table,1,-1do
ifsub_item_table[j]._texteditor_idthen
table.remove(sub_item_table)
end
end
touchmenu_instance:updateItems()
end,
})
end,
},
},
},
},
separator=true,
separator=true,
@ -227,8 +256,7 @@ Export text to QR code, that can be scanned, for example, by a phone.]]),
end
end
UIManager:show(ConfirmBox:new{
UIManager:show(ConfirmBox:new{
text=text,
text=text,
ok_text=_("Yes"),
ok_text=_("Remove"),
cancel_text=_("No"),
ok_callback=function()
ok_callback=function()
self:removeFromHistory(file_path)
self:removeFromHistory(file_path)
-- Also remove from menu itself
-- Also remove from menu itself
@ -297,7 +325,7 @@ function TextEditor:newFile()
UIManager:show(ConfirmBox:new{
UIManager:show(ConfirmBox:new{
text=_([[Tostarteditinganewfile,youwillhaveto:
text=_([[Tostarteditinganewfile,youwillhaveto:
-Firstselecta directory
-Firstselectafolder
-Thenenteranameforthenewfile
-Thenenteranameforthenewfile
-Andstarteditingit
-Andstarteditingit
@ -368,8 +396,7 @@ function TextEditor:checkEditFile(file_path, from_history, possibly_new_file)
ifnotpossibly_new_fileandnotattrthen
ifnotpossibly_new_fileandnotattrthen
UIManager:show(ConfirmBox:new{
UIManager:show(ConfirmBox:new{
text=T(_("This file does not exist anymore:\n\n%1\n\nDo you want to create it and start editing it?"),BD.filepath(file_path)),
text=T(_("This file does not exist anymore:\n\n%1\n\nDo you want to create it and start editing it?"),BD.filepath(file_path)),
ok_text=_("Yes"),
ok_text=_("Create"),
cancel_text=_("No"),
ok_callback=function()
ok_callback=function()
-- go again thru there with possibly_new_file=true
-- go again thru there with possibly_new_file=true
self:checkEditFile(file_path,from_history,true)
self:checkEditFile(file_path,from_history,true)
@ -404,8 +431,7 @@ function TextEditor:checkEditFile(file_path, from_history, possibly_new_file)
UIManager:show(ConfirmBox:new{
UIManager:show(ConfirmBox:new{
text=T(_("This file is %2:\n\n%1\n\nAre you sure you want to open it?\n\nOpening big files may take some time."),
text=T(_("This file is %2:\n\n%1\n\nAre you sure you want to open it?\n\nOpening big files may take some time."),