mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Get console print working from within the iframe as well
This commit is contained in:
parent
bce5112268
commit
5e7c2fbde5
@ -118,6 +118,7 @@ class IframeBoss:
|
||||
print('Unknown action in message to iframe from parent: ' + data.action)
|
||||
|
||||
def initialize(self, data):
|
||||
nonlocal print
|
||||
self.gcm_from_parent, self.gcm_to_parent = GCM(data.secret.subarray(0, 32)), GCM(data.secret.subarray(32))
|
||||
scroll_viewport.update_window_size(data.width, data.height)
|
||||
if data.translations:
|
||||
@ -128,9 +129,13 @@ class IframeBoss:
|
||||
window.addEventListener('wheel', self.onwheel)
|
||||
window.addEventListener('keydown', self.onkeydown)
|
||||
document.documentElement.addEventListener('contextmenu', self.oncontextmenu)
|
||||
create_touch_handlers()
|
||||
self.color_scheme = data.color_scheme
|
||||
self.encrypted_communications = True
|
||||
print = self.print_to_parent
|
||||
create_touch_handlers()
|
||||
|
||||
def print_to_parent(self, *args):
|
||||
self.send_message('print', string=' '.join(map(str, args)))
|
||||
|
||||
def onerror(self, msg, script_url, line_number, column_number, error_object):
|
||||
if error_object:
|
||||
|
@ -119,6 +119,7 @@ class View:
|
||||
'bump_font_size': self.bump_font_size,
|
||||
'find_in_spine': self.on_find_in_spine,
|
||||
'request_size': self.on_request_size,
|
||||
'print': self.on_print,
|
||||
}
|
||||
self.currently_showing = {}
|
||||
|
||||
@ -158,6 +159,9 @@ class View:
|
||||
w, h = self.iframe_size()
|
||||
self.send_message('window_size', width=w, height=h)
|
||||
|
||||
def on_print(self, data):
|
||||
print(data.string)
|
||||
|
||||
def find(self, text, backwards):
|
||||
self.send_message('find', text=text, backwards=backwards, searched_in_spine=False)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user