(self)
Fills len data with given byte
Fills len data with given byte
Fills len data with given byte
def on_cm_fill(self):
        """ Fills len data with given byte
        """
        start = self.selection.start
        end = self.selection.end
        count = 0
        byte = 0

        if start == end:
            # ask how many bytes
            res, exp = InputDialog.input(
                self, hint='byte * count', placeholder='0x00*10')
            if res and exp:
                if not '*' in exp:
                    return

                byte, count = exp.split('*')
                try:
                    count = int(count, 10)
                    byte = int(byte, 16)
                except ValueError:
                    return
        else:
            # ask for byte
            res, exp = InputDialog.input(self, hint='byte', placeholder='0x00')
            if res and exp:
                if '*' in exp:
                    return

                try:
                    count = end - start
                    byte = int(exp, 16)
                except ValueError:
                    return

        if count <= 0 or count > len(self.data):
            return

        if start == end:
            start_loc = self.caret.position
        else:
            start_loc = start

        data_bt = bytearray(self.data)

        for i in range(start_loc, start_loc + count):
            data_bt[i] = byte

        self.data = bytes(data_bt)
        self.add_highlight(HighLight('edited', start_loc + self.base, count))
        self.dataChanged.emit(start_loc, count)
        self.viewChanged.emit()
def on_cm_fill ( self ) : start = self . selection . start end = self . selection . end count = 0 byte = 0 if start == end : # ask how many bytes res , exp = InputDialog . input ( self , hint = 'byte * count' , placeholder = '0x00*10' ) if res and exp : if not '*' in exp : return byte , count = exp . split ( '*' ) try : count = int ( count , 10 ) byte = int ( byte , 16 ) except ValueError : return else : # ask for byte res , exp = InputDialog . input ( self , hint = 'byte' , placeholder = '0x00' ) if res and exp : if '*' in exp : return try : count = end - start byte = int ( exp , 16 ) except ValueError : return if count <= 0 or count > len ( self . data ) : return if start == end : start_loc = self . caret . position else : start_loc = start data_bt = bytearray ( self . data ) for i in range ( start_loc , start_loc + count ) : data_bt [ i ] = byte self . data = bytes ( data_bt ) self . add_highlight ( HighLight ( 'edited' , start_loc + self . base , count ) ) self . dataChanged . emit ( start_loc , count ) self . viewChanged . emit ( )