Example #1
0
 def __init__(self, app_state, file_buffer):
     self.file_buffer = file_buffer
     self._app_state = app_state
     self._pane = self.PANE_HEX
     self._top_offset = 0
     self._cur_offset = 0
     self._window_size = app_state.window_size
     self._offset_digits = 0
     events.register_handler(events.WindowSizeChange, self.window_size_changed)
Example #2
0
File: ui.py Project: 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)
Example #3
0
File: ui.py Project: 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)
Example #4
0
def main():
    anything_printed = False

    def print_message_handler(evt):
        nonlocal anything_printed
        anything_printed = True
        print(evt.message)

    events.register_handler(events.PrintMessage, print_message_handler)

    # basic initialization
    args = parse_args()
    settings = Settings()
    app_state = AppState(settings, args)
    tab_manager = TabManager(app_state)
    cmd_processor = CommandProcessor(app_state, tab_manager)

    user_interface = Ui(tab_manager, cmd_processor, app_state)

    # initial configuration
    cmd_processor.exec('source',
                       os.path.join(app_state.resources_dir, 'hexvirc'))
    for path in ['~/.hexvirc', '~/.config/hexvirc']:
        if os.path.exists(os.path.expanduser(path)):
            cmd_processor.exec('source', path)

    paths = util.filter_unique_paths(args.paths)
    for path in paths:
        try:
            tab_manager.open_tab(path)
        except Exception as ex:
            events.notify(events.PrintMessage(str(ex), style='msg-error'))
    if not tab_manager.tabs:
        tab_manager.open_tab()
    tab_manager.tab_index = 0

    # print collected messages, if any
    events.unregister_handler(events.PrintMessage, print_message_handler)
    if anything_printed:
        input('Press Enter to continue...')

    user_interface.run()
Example #5
0
 def __init__(self, app_state, tab_manager, *args, **kwargs):
     urwid.Widget.__init__(self, *args, **kwargs)
     self._app_state = app_state
     self._tab_manager = tab_manager
     events.register_handler(events.OffsetChange, lambda *_: self._invalidate())
     events.register_handler(events.ModeChange, lambda *_: self._invalidate())
     events.register_handler(events.TabChange, lambda *_: self._invalidate())
Example #6
0
def main():
    anything_printed = False
    def print_message_handler(evt):
        nonlocal anything_printed
        anything_printed = True
        print(evt.message)
    events.register_handler(events.PrintMessage, print_message_handler)

    # basic initialization
    args = parse_args()
    settings = Settings()
    app_state = AppState(settings, args)
    tab_manager = TabManager(app_state)
    cmd_processor = CommandProcessor(app_state, tab_manager)

    user_interface = Ui(tab_manager, cmd_processor, app_state)

    # initial configuration
    cmd_processor.exec(
        'source', os.path.join(app_state.resources_dir, 'hexvirc'))
    for path in ['~/.hexvirc', '~/.config/hexvirc']:
        if os.path.exists(os.path.expanduser(path)):
            cmd_processor.exec('source', path)

    paths = util.filter_unique_paths(args.paths)
    for path in paths:
        try:
            tab_manager.open_tab(path)
        except Exception as ex:
            events.notify(events.PrintMessage(str(ex), style='msg-error'))
    if not tab_manager.tabs:
        tab_manager.open_tab()
    tab_manager.tab_index = 0

    # print collected messages, if any
    events.unregister_handler(events.PrintMessage, print_message_handler)
    if anything_printed:
        input('Press Enter to continue...')

    user_interface.run()
Example #7
0
File: dump.py Project: rr-/hexvi
 def __init__(self, app_state, cmd_processor, tab_state, ui):
     self.editing = False
     self.tab_state = tab_state
     self._ui = ui
     self._cmd_processor = cmd_processor
     self._app_state = app_state
     self._user_byte_input = ''
     events.register_handler(events.PaneChange, lambda *_: self._invalidate())
     events.register_handler(events.OffsetChange, lambda *_: self._invalidate())
     events.register_handler(events.TabChange, self._tab_changed)
Example #8
0
 def __init__(self, app_state, cmd_processor, tab_state, ui):
     self.editing = False
     self.tab_state = tab_state
     self._ui = ui
     self._cmd_processor = cmd_processor
     self._app_state = app_state
     self._user_byte_input = ''
     events.register_handler(events.PaneChange,
                             lambda *_: self._invalidate())
     events.register_handler(events.OffsetChange,
                             lambda *_: self._invalidate())
     events.register_handler(events.TabChange, self._tab_changed)
Example #9
0
 def started(self):
     events.register_handler(events.PrintMessage, self._message_requested)
     events.register_handler(events.ConfirmMessage, self._confirm_requested)
     events.register_handler(events.ModeChange, self._mode_changed)
Example #10
0
 def started(self):
     events.register_handler(events.PrintMessage, self._message_requested)
     events.register_handler(events.ConfirmMessage, self._confirm_requested)
     events.register_handler(events.ModeChange, self._mode_changed)
Example #11
0
File: tab_bar.py Project: rr-/hexvi
 def __init__(self, tab_manager):
     super().__init__([], dividechars=1)
     self._tab_manager = tab_manager
     events.register_handler(events.TabOpen, lambda *_: self._update())
     events.register_handler(events.TabClose, lambda *_: self._update())
     events.register_handler(events.TabChange, lambda *_: self._update())