def __init__(self, change_set, *args, **kwargs):
super().__init__(*args, **kwargs)
self.name = 'Preview'
self.apply_changes = False
def apply(sender):
self.apply_changes = True
self.close()
button = ui.ButtonItem('Apply', action=apply)
self.right_button_items = [button]
textview = ui.TextView(frame=self.bounds, flex='WH')
textview.editable = False
diff = _change_set_diff(change_set)
attributed_string = _diff_to_attributed_string(diff)
_set_attributed_text(textview, attributed_string)
self.add_subview(textview)
def cancel():
self.close()
self.handlers = [
register_key_event_handler(UIEventKeyCode.escape, cancel),
register_key_event_handler(UIEventKeyCode.dot, cancel, modifier=UIKeyModifier.command),
register_key_event_handler(UIEventKeyCode.enter, lambda: apply(None))
]
评论列表
文章目录