View Single Post
Old 12-18-2024, 01:57 PM   #5
jwes
Connoisseur
jwes began at the beginning.
 
Posts: 82
Karma: 10
Join Date: Jul 2023
Device: none
I found a simpler way that works for me though I don't know if it would be useful for Sigil. The ability to search for text strings ignoring embedded HTML tags might be nice. I did find that I could eliminate screen flashing on the preview window by using setUpdatesEnabled(False) before updating and resetting it after scrolling and a short (200ms for now) timer delay.

I use html.parser to create a string of all the text in the HTML file and a list of offsets from the start of the HTML file for each character in the string. I could then use string find and the offsets to move the cursor in the code window. For the preview window I used findText() to scroll to the text and javascript to get scrollY. For updating the preview window, I used scrollTo(0, scrollY) to return after reloading the HTML file.

I'm sure there are special cases I have overlooked, but I happy with it for now.
jwes is offline   Reply With Quote