change text size of left panel and synchronize scrolling in Linux (Ubuntu) version
I've modified the RemarkableWindow.py script to address these new features. Please let me know, I find them very useful and they improve the usability of the tool a lot!
Really nice work. I get more reliable synchronizing if I increase the GLib.timeout from 0 to around 50 (last line below).
def scroll_with_delay(): view.run_javascript("let e = document.getElementById('remarkable-cursor'); if (e) { e.scrollIntoView({ behavior: 'auto', block: 'center', inline: 'nearest' }); }", None, None, None) return False # To run only once GLib.timeout_add(50, scroll_with_delay)
Does that make sense?
Absolutely, makes perfect sense! A small timeout of 50 ms gives enough time to finish the layout and make the element available before you try to scroll. With 0, it’s a bit too optimistic, and often the layout isn’t ready yet, so the scroll silently fails. Of course, that tiny delay isn’t the nicest thing and I’m personally not a big fan of it. but in the end it’s really a matter of taste...
Hello again. I did some more work on trying to get the timeouts right because on my 20 year old computer, the preview screen tended to jump a lot or get stuck at the top, especially with big documents. So what I have done is:
- Changed the line starting:
self.default_html_end = '<script src=...
by adding the following to the scripts:
<script>window.document.getElementById("remarkable-cursor").scrollIntoView({behavior: "auto", block: "center", inline: "nearest"})</script>
This is the javascript that your code inserts into the preview with webkit.
-
I have kept your bit of code which adds the 'remarkable-cursor' html tag whenever a change to the text window is made.
-
Sadly, your really clever code which inserted the javascript, is now superfluous so I regret I have missed it out!!
So from def scroll_after_load(view, event): to scroll_handler_id = self.live_preview.connect('load-changed', scroll_after_load) has been missed out.
The end result, for me at least, is that the preview screen does not jump or stick and I believe it behaves exactly like it should and did, but then I will be biased on that!
My version of your code is here:
I have left in all the changes you made to do with the font size - actually I haven't tried that out yet. Anyway, I was wondering if you might possibly be able to test this out.
My impression is that it might be a bit less jumpy on older computers!