def find_block_by_number(self, number: int) -> gui.TextBlock: block = self.findBlockByNumber(number) if not block.isValid(): raise ValueError( f"{number} not a valid block index. Block count: {self.blockCount()}" ) return gui.TextBlock(block)
def find_block_by_line_number(self, line_number: int) -> gui.TextBlock: block = self.findBlockByLineNumber(line_number) if not block.isValid(): raise ValueError( f"{line_number} not a valid line index. Line count: {self.lineCount()}" ) return gui.TextBlock(block)
def get_current_block(self) -> gui.TextBlock: return gui.TextBlock(self.currentBlock())
def get_first_block(self) -> gui.TextBlock: return gui.TextBlock(self.firstBlock())
def get_last_block(self) -> gui.TextBlock: return gui.TextBlock(self.lastBlock())
def __iter__(self) -> Iterator[gui.TextBlock]: return iter( gui.TextBlock(self.findBlockByNumber(i)) for i in range(self.blockCount()) )
def __getitem__(self, index: int) -> gui.TextBlock: return gui.TextBlock(self.findBlockByNumber(index))
def test_textblock(): block = gui.TextBlock() repr(block) assert 1 not in block
def get_blocklist(self) -> list[gui.TextBlock]: return [gui.TextBlock(i) for i in self.blockList()]
def __iter__(self) -> Iterator[gui.TextBlock]: return iter(gui.TextBlock(i) for i in self.blockList())