示例#1
0
文件: ui.py 项目: rr-/hexvi
    def __init__(self, tab_manager, cmd_processor, app_state):
        self.blocked = False
        self._app_state = app_state
        self._main_window = MainWindow(app_state, cmd_processor, tab_manager,
                                       self)
        self._app_state.mode = AppState.MODE_NORMAL

        events.register_handler(events.ProgramExit, lambda *args: self._exit())
        events.register_handler(events.ColorChange, self._color_changed)

        self.loop = urwid.MainLoop(self._main_window,
                                   unhandled_input=self._key_pressed)
示例#2
0
文件: ui.py 项目: rr-/hexvi
class Ui(object):
    ''' The main UI facade. '''

    def __init__(self, tab_manager, cmd_processor, app_state):
        self.blocked = False
        self._app_state = app_state
        self._main_window = MainWindow(
            app_state, cmd_processor, tab_manager, self)
        self._app_state.mode = AppState.MODE_NORMAL

        events.register_handler(events.ProgramExit, lambda *args: self._exit())
        events.register_handler(events.ColorChange, self._color_changed)

        self.loop = urwid.MainLoop(
            self._main_window, unhandled_input=self._key_pressed)

    def show_confirmation_dialog(self, message, confirm_action, cancel_action):
        ConfirmationDialog(self, message, confirm_action, cancel_action)

    def run(self):
        self._main_window.started()
        self.loop.screen.set_terminal_properties(
            self._app_state.settings.term_colors)
        self.loop.run()

    def _color_changed(self, evt):
        scr = self.loop.screen
        scr.register_palette_entry(
            evt.target,
            evt.fg_style,
            evt.bg_style,
            foreground_high=evt.fg_style_high,
            background_high=evt.bg_style_high)
        scr.clear()

    @staticmethod
    def _exit():
        raise urwid.ExitMainLoop()

    def _key_pressed(self, key):
        if not self.blocked:
            self._app_state.mappings[self._app_state.mode].keypress(key)
示例#3
0
文件: ui.py 项目: rr-/hexvi
    def __init__(self, tab_manager, cmd_processor, app_state):
        self.blocked = False
        self._app_state = app_state
        self._main_window = MainWindow(
            app_state, cmd_processor, tab_manager, self)
        self._app_state.mode = AppState.MODE_NORMAL

        events.register_handler(events.ProgramExit, lambda *args: self._exit())
        events.register_handler(events.ColorChange, self._color_changed)

        self.loop = urwid.MainLoop(
            self._main_window, unhandled_input=self._key_pressed)
示例#4
0
文件: ui.py 项目: rr-/hexvi
class Ui(object):
    ''' The main UI facade. '''
    def __init__(self, tab_manager, cmd_processor, app_state):
        self.blocked = False
        self._app_state = app_state
        self._main_window = MainWindow(app_state, cmd_processor, tab_manager,
                                       self)
        self._app_state.mode = AppState.MODE_NORMAL

        events.register_handler(events.ProgramExit, lambda *args: self._exit())
        events.register_handler(events.ColorChange, self._color_changed)

        self.loop = urwid.MainLoop(self._main_window,
                                   unhandled_input=self._key_pressed)

    def show_confirmation_dialog(self, message, confirm_action, cancel_action):
        ConfirmationDialog(self, message, confirm_action, cancel_action)

    def run(self):
        self._main_window.started()
        self.loop.screen.set_terminal_properties(
            self._app_state.settings.term_colors)
        self.loop.run()

    def _color_changed(self, evt):
        scr = self.loop.screen
        scr.register_palette_entry(evt.target,
                                   evt.fg_style,
                                   evt.bg_style,
                                   foreground_high=evt.fg_style_high,
                                   background_high=evt.bg_style_high)
        scr.clear()

    @staticmethod
    def _exit():
        raise urwid.ExitMainLoop()

    def _key_pressed(self, key):
        if not self.blocked:
            self._app_state.mappings[self._app_state.mode].keypress(key)