Merge pull request #527 from Arthur-Milchior/explode_on_bridge_cmd

Explode on bridge cmd
This commit is contained in:
Damien Elmes 2020-03-27 15:22:14 +10:00 committed by GitHub
commit 2264fe3f66
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -367,8 +367,16 @@ class Editor:
# shutdown
return
# focus lost or key/button pressed?
if cmd.startswith("blur") or cmd.startswith("key"):
(type, ord, nid, txt) = cmd.split(":", 3)
splitted = cmd.split(":", 1)
cmd = splitted[0]
args = splitted[1:]
if cmd in self._links:
self._links[cmd](self, *args) # type: ignore
else:
print("uncaught cmd", cmd)
def onBlurOrKey(self, args):
ord, nid, txt = args.split(":", 2)
ord = int(ord)
try:
nid = int(nid)
@ -387,27 +395,27 @@ class Editor:
if not self.addMode:
self.note.flush()
self.mw.requireReset()
if type == "blur":
return ord
def onBlur(self, args):
ord = self.onBlurOrKey(args)
self.currentField = None
# run any filters
if gui_hooks.editor_did_unfocus_field(False, self.note, ord):
if gui_hooks.editor_did_unfocus_field(False, self.note, int(ord)):
# something updated the note; update it after a subsequent focus
# event has had time to fire
self.mw.progress.timer(100, self.loadNoteKeepingFocus, False)
else:
self.checkValid()
else:
def onKey(self, args):
self.onBlurOrKey(args)
gui_hooks.editor_did_fire_typing_timer(self.note)
self.checkValid()
# focused into field?
elif cmd.startswith("focus"):
(type, num) = cmd.split(":", 1)
def onFocus(self, num):
self.currentField = int(num)
gui_hooks.editor_did_focus_field(self.note, self.currentField)
elif cmd in self._links:
self._links[cmd](self)
else:
print("uncaught cmd", cmd)
def mungeHTML(self, txt):
if txt in ("<br>", "<div><br></div>"):
@ -970,6 +978,9 @@ to a cloze type first, via Edit>Change Note Type."""
dupes=showDupes,
paste=onPaste,
cutOrCopy=onCutOrCopy,
blur=onBlur,
focus=onFocus,
key=onKey,
)