[Python] Python:prompt_toolkit TextArea.buffer.cursor_position += 4 setting to 4 instead of...

Discussão em 'Python' iniciado por Stack, Julho 16, 2025.

  1. Stack

    Stack Membro Participativo

    i am trying to make a text editor with prompt_toolkit. while implementing tab indentation, i came across this weird behaviour:


    def keybinds(self):
    kb = KeyBindings()
    @kb.add("tab")
    def _(event):
    if config.get("functional.tabspace"):
    self.textArea.text += " " * config.get("functional.tabwidth")
    self.textArea.buffer.cursor_position += config.get("functional.tabwidth")

    return kb

    this sets the cursor position to 4 ( functional.tabwidth = 4 ), instead of adding 4 to the cursor position.

    how do i fix this?

    Continue reading...

Compartilhe esta Página