Comments (10)
In that user patch #11469 (comment), I just quickly used the typography language to get something to toggle it.
There may be other more proper ways to toggle the patch than having to change typography language and having that need leak into profile/gestures - so let's not implement this feature request until it feels it is needed for other better reasons :)
The right way to help you is to tweak/improve the user patch, ie. by having it depend on another existing useless setting, or by having it properly add a menu item and a setting.
Quick try, that gets you a menu item in the first top level menu, add to the top of the patch (after the bunch of local = ... require(...)
:
ReaderRolling_orig_addToMainMenu = ReaderRolling.addToMainMenu
ReaderRolling.addToMainMenu = function(self, menu_items)
ReaderRolling_orig_addToMainMenu(self, menu_items)
menu_items.toggle_vertical_hack = {
text = "Toggle verting reading hack",
checked_func = function()
return self.ui.doc_settings:isTrue("vertical_reading_hack")
end,
callback = function()
self.ui.doc_settings:flipNilOrFalse("vertical_reading_hack")
self.ui:reloadDocument()
end,
}
end
and in the existing ReaderRolling.onPreRenderDocument
, replace the first condition check:
ReaderRolling.onPreRenderDocument = function(self)
-- Only enable these hacks when the typography language has been set to Japanese.
-- if self.ui.typography.text_lang_tag ~= "ja" then
-- Let's do it with a setting toggable via the menu item defined above
if not self.ui.doc_settings:isTrue("vertical_reading_hack") then
return
end
Pinging @plateaukao if you want to include/improve that , as after #11469 (comment), you are now the official maintainer of this user patch :)
from koreader.
For example
koreader/plugins/autostandby.koplugin/main.lua
Lines 53 to 55 in caea0e8
All menu item ids you can see in
https://github.com/koreader/koreader/blob/master/frontend/ui/elements/reader_menu_order.lua
from koreader.
Not sure what you have on line 949 of readertoc.lua (dunno which version of KOReader you are running, but I see nothing of interest in current nightly or last stable).
Didn't crash for me... because I had the NEW: menu item on the 2nd menu page. It crashes too when I use another document with less menu items so it gets on the first page.
Should fix that:
-- Add this to the top:
local UIManager = require("ui/uimanager")
-- And use this instead:
ReaderRolling_orig_addToMainMenu = ReaderRolling.addToMainMenu
ReaderRolling.addToMainMenu = function(self, menu_items)
ReaderRolling_orig_addToMainMenu(self, menu_items)
menu_items.toggle_vertical_hack = {
text = "Toggle verting reading hack",
checked_func = function()
return self.ui.doc_settings:isTrue("vertical_reading_hack")
end,
callback = function(touchmenu_instance)
self.ui.doc_settings:flipNilOrFalse("vertical_reading_hack")
UIManager:nextTick(function()
self.ui:reloadDocument()
end)
end,
}
end
Also, May I know further how I can debug more effeciently than just keep copying the modified script onto my device? If there's a developer doc that I missed, please let me know.
Dunno about how to speed things up on Android.
We have an emulator for linux desktops.
Otherwise, it's what you do: edit the file and push it on the device, and restart KOReader to test.
There is the Text Editor plugin to edit files, but it's not usable for developping, just for quick testing like changeing a value and restart.
As for developper docs, nothing more than this https://koreader.rocks/doc/ - and it's just best to read the existing code, related/similar parts to what you are doing and copy & pasting & experimenting...
from koreader.
That's what I am thinking too, to have an independent setting to toggle it. Thanks for providing the code snippet. I'll look into how to integrate it.
from koreader.
a menu item in the first top level menu
sorting_hint
may help to place it to the desired submenu.
from koreader.
@poire-z
I tried to integrate your code snippet, it crashes when clicking on the created menu item, with following error log:
ps. although it crashes, after I restart KOReader, the book is correctly enabled with the vertical_read feature. seems something wrong when calling self.ui:reloadDocument()
? Also, May I know further how I can debug more effeciently than just keep copying the modified script onto my device? If there's a developer doc that I missed, please let me know. Thanks!
my commit is here: plateaukao/koreader_patch_vertical_read@024e383
Hi, @hius07
What do you mean by sorting_hint may help to place it to the desired submenu.
?
is it a variable of some object, or any document I should look into?
from koreader.
Thanks @poire-z and @hius07
Now the script could work.
Hi, @smarliecy
I've modified the patch, so that it does not depend on epub file language. You can toggle the effect under second menu list with a new menu item "Toggle vertical reading". As for supporting gesture, I checked a bit, but couldn't figure out how to add it. So, I think it should be good enough for now. :)
file: https://github.com/plateaukao/koreader_plugin_vertical_read/blob/main/2-cre-rotate-japanese-book.lua
from koreader.
Hi, @poire-z
I tried to add Vertical-Reading-Toggle feature to action list, and it did appear in Gesture settings. However, when enabling it, and click on designated area, it seems failed to get document (or the self object) and crashed. Usually, there's no crash logs on screen.
pr: https://github.com/plateaukao/koreader_plugin_vertical_read/pull/1/files
Could you give me some hint how I can fix it? Or it's better to move the implementations to a normal plugin, so that self
object is available?
Thanks in advance.
from koreader.
Your code doesn't crash for me, when I associate it to tap top left corner or a multiswipe.
So, I really dunno what to tell you :)
Try to look into the crash.log - on Android the issue template says:
Android logs are kept in memory. Please go to [Menu] → Help → Bug Report to save these logs to a file.
I do get a crash though (in my original code) when I invoke Book information:
./luajit: ./patches/2-cre-rotate-japanese-book.lua:100: attempt to call method 'copy' (a nil value)
stack traceback:
./patches/2-cre-rotate-japanese-book.lua:100: in function 'getTextFromPositions'
frontend/apps/reader/modules/readerview.lua:1304: in function 'getCurrentPageLineWordCounts'
frontend/apps/filemanager/filemanagerbookinfo.lua:156: in function 'show'
frontend/apps/filemanager/filemanagerbookinfo.lua:298: in function 'handleEvent'
The getCurrentPageLineWordCounts doesn't provide real Geom objects to that getTextFromPositions, so :copy() does not exist.
Fix that case around line 100 with:
document.getTextFromPositions = function(self, pos0, pos1, do_not_draw_selection)
if not pos0.copy then -- not a real Geom object
return orig_getTextFromPositions(self, pos0, pos1, do_not_draw_selection)
end
pos0 = pos0:copy()
(Yes, we are adding hacks to a hack :/)
Or it's better to move the implementations to a normal plugin, so that self object is available?
No, and this is really not a "koreader plugin", and can't be: a plugin is some other independant module that do its own stuff, and usually don't hack into the core code.
Here, we just hack into the core code: we don't add any independant functionality - so it's quite non-convertible to a plugin. The only common things you could have in a plugin is the addToMainMenu and the onToggleVerticalReading event, which is only 20% of the work - but you can just as easily plug them into ReaderRolling, no need to have a plugin just to expose them.
On your project page, and to avoid confusion remove any notion of "plugin", and use "user-patch", and link to https://github.com/koreader/koreader/wiki/User-patches for how to install it.
from koreader.
@poire-z
Thanks for the reply and the clear explanation between user-patch and plugin! 😄
I found that my testing android device was using an old version of KOReader (way back to last year). After updating it to latest one, the action menu and normal menu works great!
Now the feature is almost perfect~ 🙇
from koreader.
Related Issues (20)
- FR: Colour saturation on Kobo Libra Colour HOT 17
- FR: [Android]Ability to use other virtual keyboards HOT 1
- Can't open books from library when files are associated on some Pocketbooks HOT 12
- Pdf annotations not migrated properly HOT 28
- Android app does not write highlights to PDF if app is closed HOT 1
- FR: be able to add a vertical line between two columns HOT 1
- koreader doen't launches on kindle PW5 (8GB) HOT 4
- Missing text in Weblate HOT 2
- FR: Display note in differend line in bookmarks list HOT 3
- Alignment of ruby text is affected by -epub-text-align-last HOT 1
- "Move to archive" action triggers directory metadata and cover refresh HOT 1
- Moving a book to another folder deleted my notes, highlights, bookmarks, and reading progress HOT 8
- FR: Open links in PocketBook web browser HOT 5
- Hot swapping dictionaries unavailable on NT devices HOT 3
- Some PDFs have stopped opening. HOT 9
- FR: Right Click Mouse Support HOT 6
- Building APK fails because of unknown switch of 7z HOT 5
- FR: Paginated Bookmark details
- Timer related features stopped working HOT 1
- Can not open feeds from Newsdownloder plugin after last update HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from koreader.