예제 #1
0
 def run(self):
     """Run command."""
     view = self.window.active_view()
     group_size = int(view.settings().get("hex_viewer_bits", None))
     bytes_wide = int(view.settings().get("hex_viewer_actual_bytes", None))
     common.clear_edits(view)
     self.window.run_command('hex_viewer', {"bits": group_size, "bytes": bytes_wide})
예제 #2
0
 def run(self):
     """Run command."""
     view = self.window.active_view()
     group_size = int(view.settings().get("hex_viewer_bits", None))
     bytes_wide = int(view.settings().get("hex_viewer_actual_bytes", None))
     common.clear_edits(view)
     self.window.run_command('hex_viewer', {"bits": group_size, "byte_array": bytes_wide})
예제 #3
0
    def finish_export(self):
        """Post export event."""

        if common.hv_settings("checksum_on_save", USE_CHECKSUM_ON_SAVE):
            hex_hash = Checksum()
            self.hex_buffer.seek(0)
            # Checksum will be threaded and will show the result when done
            sublime.set_timeout(lambda: sublime.status_message("Checksumming..."), 0)
            hex_hash.threaded_update(self.hex_buffer, parse_view_data, self.row)

        # Update the tab name
        self.view.set_name(common.basename(self.export_path) + ".hex")
        # Update the internal path
        self.view.settings().set("hex_viewer_file_name", self.export_path)
        # Tie it to a real view if not already
        self.view.settings().set("hex_viewer_fake", False)
        # Clear the marked edits
        common.clear_edits(self.view)
        # Reset class
        self.reset()
예제 #4
0
    def finish_export(self):
        """Post export event."""

        if common.hv_settings("checksum_on_save", USE_CHECKSUM_ON_SAVE):
            hex_hash = Checksum()
            self.hex_buffer.seek(0)
            # Checksum will be threaded and will show the result when done
            sublime.set_timeout(lambda: sublime.status_message("Checksumming..."), 0)
            hex_hash.threaded_update(self.hex_buffer, parse_view_data, self.row)

        # Update the tab name
        self.view.set_name(common.basename(self.export_path) + ".hex")
        # Update the internal path
        self.view.settings().set("hex_viewer_file_name", self.export_path)
        # Tie it to a real view if not already
        self.view.settings().set("hex_viewer_fake", False)
        # Clear the marked edits
        common.clear_edits(self.view)
        # Reset class
        self.reset()
예제 #5
0
    def run(self, bits=None, byte_array=None, starting_address=0, reload=False):
        """Run the command."""

        self.starting_address = starting_address
        if active_thread is not None and active_thread.is_alive():
            error(
                "HexViewer is already converting a file!\n"
                "Please run the abort command to stop the current conversion."
            )
            return
        # If thread is active cancel thread
        if self.thread is not None and self.thread.is_alive():
            self.abort_hex_load()
            return

        # Init Buffer
        file_name = self.buffer_init(bits, byte_array)

        # Identify view
        if self.handshake != -1 and self.handshake == self.view.id():
            self.reset()
        self.handshake = self.view.id()

        if file_name is not None and exists(file_name):
            # Decide whether to read in as a binary file or a traditional file
            if self.view.settings().has("hex_viewer_file_name"):
                self.view_type = "hex"
                if reload:
                    self.file_name = file_name
                    common.clear_edits(self.view)
                    self.read_bin(file_name)
                elif common.is_hex_dirty(self.view):
                    self.file_name = file_name
                    if bits is None and byte_array is None:
                        self.switch_type = "file"
                    else:
                        self.switch_type = "hex"
                    self.discard_panel()
                else:
                    if bits is None and byte_array is None:
                        # Switch back to traditional output
                        self.read_file(file_name)
                    else:
                        # Reload hex with new settings
                        self.read_bin(file_name)
            elif reload:
                error("Can't reload, current file is not in hex view!")
            else:
                # We are going to swap out the current file for hex output
                # So as not to clutter the screen.  Changes need to be saved
                # Or they will be lost
                if self.view.is_dirty():
                    self.file_name = file_name
                    self.switch_type = "hex"
                    self.discard_panel()
                else:
                    # Switch to hex output
                    self.read_bin(file_name)
        else:
            if file_name is None:
                error("Hex Viewer can only edit files. Save the contents to disk first!")
            else:
                error("%s does not exist on disk!" % basename(file_name))
예제 #6
0
    def run(self,
            bits=None,
            byte_array=None,
            starting_address=0,
            reload=False):
        """Run the command."""

        self.starting_address = starting_address
        if active_thread is not None and active_thread.is_alive():
            error(
                "HexViewer is already converting a file!\n"
                "Please run the abort command to stop the current conversion.")
            return
        # If thread is active cancel thread
        if self.thread is not None and self.thread.is_alive():
            self.abort_hex_load()
            return

        # Init Buffer
        file_name = self.buffer_init(bits, byte_array)

        # Identify view
        if self.handshake != -1 and self.handshake == self.id:
            self.reset()
        self.handshake = self.id

        if file_name is not None and exists(file_name):
            # Decide whether to read in as a binary file or a traditional file
            if self.sheet:
                self.file_name = file_name
                self.read_bin(file_name)
            elif self.view.settings().has("hex_viewer_file_name"):
                self.view_type = "hex"
                if reload:
                    self.file_name = file_name
                    common.clear_edits(self.view)
                    self.read_bin(file_name)
                elif common.is_hex_dirty(self.view):
                    self.file_name = file_name
                    if bits is None and byte_array is None:
                        self.switch_type = "file"
                    else:
                        self.switch_type = "hex"
                    self.discard_panel()
                else:
                    if bits is None and byte_array is None:
                        # Switch back to traditional output
                        self.read_file(file_name)
                    else:
                        # Reload hex with new settings
                        self.read_bin(file_name)
            elif reload:
                error("Can't reload, current file is not in hex view!")
            else:
                # We are going to swap out the current file for hex output
                # So as not to clutter the screen.  Changes need to be saved
                # Or they will be lost
                if self.view.is_dirty():
                    self.file_name = file_name
                    self.switch_type = "hex"
                    self.discard_panel()
                else:
                    # Switch to hex output
                    self.read_bin(file_name)
        else:
            if file_name is None:
                error(
                    "Hex Viewer can only edit files. Save the contents to disk first!"
                )
            else:
                error("%s does not exist on disk!" % basename(file_name))