(self, linebuf)
Store the given line buffer.
Store the given line buffer.
Store the given line buffer .
def store_line(self, linebuf):
        """Store the given line buffer."""
        if self.protected:
            raise error.BASICError(error.IFC)
        # get the new line number
        linebuf.seek(1)
        scanline = self.lister.detokenise_line_number(linebuf)
        # check if linebuf is an empty line after the line number
        empty = (linebuf.skip_blank_read() in tk.END_LINE)
        pos, afterpos, deleteable, beyond = self.find_pos_line_dict(scanline, scanline)
        if empty and not deleteable:
            raise error.BASICError(error.UNDEFINED_LINE_NUMBER)
        # read the remainder of the program into a buffer to be pasted back after the write
        self.bytecode.seek(afterpos)
        rest = self.bytecode.read()
        # insert
        self.bytecode.seek(pos)
        # write the line buffer to the program buffer
        length = 0
        if not empty:
            # set offsets
            linebuf.seek(3) # pass \x00\xC0\xDE
            length = len(linebuf.getvalue())
            # check for free memory
            # variables are cleared upon program code storage
            if self.code_start + 1 + pos + length > self._memory.stack_start():
                raise error.BASICError(error.OUT_OF_MEMORY)
            self.bytecode.write(
                struct.pack('<BH', 0, self.code_start + 1 + pos + length) + linebuf.read()
            )
        # write back the remainder of the program
        self.truncate(rest)
        # update all next offsets by shifting them by the length of the added line
        self.update_line_dict(pos, afterpos, length, deleteable, beyond)
        if not empty:
            self.line_numbers[scanline] = pos
        self.last_stored = scanline
def store_line ( self , linebuf ) : if self . protected : raise error . BASICError ( error . IFC ) # get the new line number linebuf . seek ( 1 ) scanline = self . lister . detokenise_line_number ( linebuf ) # check if linebuf is an empty line after the line number empty = ( linebuf . skip_blank_read ( ) in tk . END_LINE ) pos , afterpos , deleteable , beyond = self . find_pos_line_dict ( scanline , scanline ) if empty and not deleteable : raise error . BASICError ( error . UNDEFINED_LINE_NUMBER ) # read the remainder of the program into a buffer to be pasted back after the write self . bytecode . seek ( afterpos ) rest = self . bytecode . read ( ) # insert self . bytecode . seek ( pos ) # write the line buffer to the program buffer length = 0 if not empty : # set offsets linebuf . seek ( 3 ) # pass \x00\xC0\xDE length = len ( linebuf . getvalue ( ) ) # check for free memory # variables are cleared upon program code storage if self . code_start + 1 + pos + length > self . _memory . stack_start ( ) : raise error . BASICError ( error . OUT_OF_MEMORY ) self . bytecode . write ( struct . pack ( '<BH' , 0 , self . code_start + 1 + pos + length ) + linebuf . read ( ) ) # write back the remainder of the program self . truncate ( rest ) # update all next offsets by shifting them by the length of the added line self . update_line_dict ( pos , afterpos , length , deleteable , beyond ) if not empty : self . line_numbers [ scanline ] = pos self . last_stored = scanline