HiLite Tweak added...but not perfect
Posted: 15.11.2019 10:35
Recently I downloaded the HiLite plugin. Super! There was one side effect I didn't like: the flickering of the screen, especially when typeing text and/or moving the cursor around rapidly. I never used Python but I managed to tweak the script a little:
Added at the Top:
Added Time Init:
Added this code BEFORE the major highlighting:
The result of this is that the HiLite will not kick in as long as you are typeing or moving the cursor. But...there is a drawback: to HiLite you need to move the cursor again after all the activity.
Any other programming language on Windows I would have used a Timer that delays the Hilite for x milliseconds. This Timer is restarted everytime on_caret_move fires and thus cancelling the previous Timer.
I'd love to know how to do this in Python but I could not get threading.Timer to work...
Added at the Top:
Code: Select all
import time
Code: Select all
def __init__(self):
do_load_ops()
# Get the Time
self.lasttime=time.clock()
Code: Select all
def on_caret_move(self, ed_self):
if ed_self.get_carets(): return #donot allow mul-carets
if ed_self.get_text_len() > MAX_SIZE: return
# Compare Current Time with Time from Previous Visit to this Function
# and if that was too recent do NOT HiLite (this will prevent flickering)
difftime=time.clock()-self.lasttime
self.lasttime=time.clock()
if difftime<1:return
Any other programming language on Windows I would have used a Timer that delays the Hilite for x milliseconds. This Timer is restarted everytime on_caret_move fires and thus cancelling the previous Timer.
I'd love to know how to do this in Python but I could not get threading.Timer to work...