Update readertypeset.lua

This commit is contained in:
hius07
2025-03-10 18:15:38 +02:00
committed by GitHub
parent e2a33a0946
commit 9facc38ea8

View File

@@ -75,10 +75,15 @@ function ReaderTypeset:onReadSettings(config)
self:onSetPageMargins(self.unscaled_margins)
self.sync_t_b_page_margins = self.configurable.sync_t_b_page_margins == 1 and true or false
-- default to disable TXT formatting as it does more harm than good
self.txt_preformatted = config:readSetting("txt_preformatted")
or G_reader_settings:readSetting("txt_preformatted")
or 1
if self.ui.document.is_txt then
-- default to disable TXT formatting as it does more harm than good
self.txt_preformatted = config:readSetting("txt_preformatted")
or G_reader_settings:readSetting("txt_preformatted")
or 1
else
-- for other formats, it affects crengine cache
self.txt_preformatted = 1
end
self.ui.document:setTxtPreFormatted(self.txt_preformatted)
-- default to disable smooth scaling
@@ -313,27 +318,30 @@ This stylesheet is to be used only with FB2 and FB3 documents, which are not cla
sub_item_table = obsoleted_table,
separator = true,
})
table.insert(style_table, {
text_func = function()
return _("Preformatted text in TXT files") .. (G_reader_settings:has("txt_preformatted") and "" or "")
end,
checked_func = function()
return self.txt_preformatted == 1
end,
callback = function()
self.txt_preformatted = self.txt_preformatted == 1 and 0 or 1
self.ui.doc_settings:saveSetting("txt_preformatted", self.txt_preformatted)
self.ui.rolling:showReloadConfirmBox()
end,
hold_callback = function(touchmenu_instance)
if G_reader_settings:has("txt_preformatted") then
G_reader_settings:delSetting("txt_preformatted")
else
G_reader_settings:saveSetting("txt_preformatted", 0)
end
touchmenu_instance:updateItems()
end,
})
if self.ui.document.is_txt then
table.insert(style_table, {
text_func = function()
return _("Auto-detect TXT files layout") .. (G_reader_settings:has("txt_preformatted") and "" or "")
end,
checked_func = function()
return self.txt_preformatted == 0
end,
callback = function()
self.txt_preformatted = self.txt_preformatted == 1 and 0 or 1
self.ui.doc_settings:saveSetting("txt_preformatted", self.txt_preformatted)
-- setting txt_preformatted for the open document causes segfault, hence reload
self.ui.rolling:showReloadConfirmBox()
end,
hold_callback = function(touchmenu_instance)
if G_reader_settings:has("txt_preformatted") then
G_reader_settings:delSetting("txt_preformatted")
else
G_reader_settings:saveSetting("txt_preformatted", 0)
end
touchmenu_instance:updateItems()
end,
})
end
return style_table
end