Skip to content

Better Mouse Support #1387

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/full-screen/calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def accept(buff):
@kb.add("c-c")
@kb.add("c-q")
def _(event):
" Pressing Ctrl-Q or Ctrl-C will exit the user interface. "
"Pressing Ctrl-Q or Ctrl-C will exit the user interface."
event.app.exit()

# Style.
Expand Down
2 changes: 1 addition & 1 deletion examples/full-screen/hello-world.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

@kb.add("c-c")
def _(event):
" Quit when control-c is pressed. "
"Quit when control-c is pressed."
event.app.exit()


Expand Down
2 changes: 1 addition & 1 deletion examples/full-screen/pager.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def get_statusbar_text():
@bindings.add("c-c")
@bindings.add("q")
def _(event):
" Quit. "
"Quit."
event.app.exit()


Expand Down
2 changes: 1 addition & 1 deletion examples/full-screen/simple-demos/alignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

@kb.add("q")
def _(event):
" Quit application. "
"Quit application."
event.app.exit()


Expand Down
2 changes: 1 addition & 1 deletion examples/full-screen/simple-demos/autocompletion.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
@kb.add("q")
@kb.add("c-c")
def _(event):
" Quit application. "
"Quit application."
event.app.exit()


Expand Down
2 changes: 1 addition & 1 deletion examples/full-screen/simple-demos/colorcolumn.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

@kb.add("q")
def _(event):
" Quit application. "
"Quit application."
event.app.exit()


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

@kb.add("q")
def _(event):
" Quit application. "
"Quit application."
event.app.exit()


Expand Down
2 changes: 1 addition & 1 deletion examples/full-screen/simple-demos/float-transparency.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@

@kb.add("q")
def _(event):
" Quit application. "
"Quit application."
event.app.exit()


Expand Down
2 changes: 1 addition & 1 deletion examples/full-screen/simple-demos/floats.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@

@kb.add("q")
def _(event):
" Quit application. "
"Quit application."
event.app.exit()


Expand Down
2 changes: 1 addition & 1 deletion examples/full-screen/simple-demos/focus.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

@kb.add("q")
def _(event):
" Quit application. "
"Quit application."
event.app.exit()


Expand Down
2 changes: 1 addition & 1 deletion examples/full-screen/simple-demos/horizontal-align.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@

@kb.add("q")
def _(event):
" Quit application. "
"Quit application."
event.app.exit()


Expand Down
2 changes: 1 addition & 1 deletion examples/full-screen/simple-demos/horizontal-split.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

@kb.add("q")
def _(event):
" Quit application. "
"Quit application."
event.app.exit()


Expand Down
4 changes: 2 additions & 2 deletions examples/full-screen/simple-demos/line-prefixes.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ def get_line_prefix(lineno, wrap_count):
@kb.add("q")
@kb.add("c-c")
def _(event):
" Quit application. "
"Quit application."
event.app.exit()


@kb.add("w")
def _(event):
" Disable/enable wrapping. "
"Disable/enable wrapping."
global wrap_lines
wrap_lines = not wrap_lines

Expand Down
2 changes: 1 addition & 1 deletion examples/full-screen/simple-demos/margins.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
@kb.add("q")
@kb.add("c-c")
def _(event):
" Quit application. "
"Quit application."
event.app.exit()


Expand Down
2 changes: 1 addition & 1 deletion examples/full-screen/simple-demos/vertical-align.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@

@kb.add("q")
def _(event):
" Quit application. "
"Quit application."
event.app.exit()


Expand Down
2 changes: 1 addition & 1 deletion examples/full-screen/simple-demos/vertical-split.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

@kb.add("q")
def _(event):
" Quit application. "
"Quit application."
event.app.exit()


Expand Down
4 changes: 2 additions & 2 deletions examples/full-screen/text-editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def __pt_container__(self):

@bindings.add("c-c")
def _(event):
" Focus menu. "
"Focus menu."
event.app.layout.focus(root_container.window)


Expand Down Expand Up @@ -204,7 +204,7 @@ async def coroutine():


async def show_dialog_as_float(dialog):
" Coroutine. "
"Coroutine."
float_ = Float(content=dialog)
root_container.floats.insert(0, float_)

Expand Down
4 changes: 2 additions & 2 deletions examples/progress-bar/custom-key-bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ def _(event):

@kb.add("q")
def _(event):
" Quit by setting cancel flag. "
"Quit by setting cancel flag."
cancel[0] = True

@kb.add("x")
def _(event):
" Quit by sending SIGINT to the main thread. "
"Quit by sending SIGINT to the main thread."
os.kill(os.getpid(), signal.SIGINT)

# Use `patch_stdout`, to make sure that prints go above the
Expand Down
2 changes: 1 addition & 1 deletion examples/prompts/clock-input.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


def get_prompt():
" Tokens to be shown before the prompt. "
"Tokens to be shown before the prompt."
now = datetime.datetime.now()
return [
("bg:#008800 #ffffff", "%s:%s:%s" % (now.hour, now.minute, now.second)),
Expand Down
2 changes: 1 addition & 1 deletion examples/prompts/custom-key-binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def _(event):

@bindings.add("a", "b", "c")
def _(event):
" Typing 'abc' should insert 'd'. "
"Typing 'abc' should insert 'd'."
event.app.current_buffer.insert_text("d")

@bindings.add("c-t")
Expand Down
4 changes: 2 additions & 2 deletions examples/prompts/custom-vi-operator-and-text-object.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def main():

@operator("R")
def _(event, text_object):
" Custom operator that reverses text. "
"Custom operator that reverses text."
buff = event.current_buffer

# Get relative start/end coordinates.
Expand All @@ -43,7 +43,7 @@ def _(event, text_object):

@text_object("A")
def _(event):
" A custom text object that involves everything. "
"A custom text object that involves everything."
# Note that a `TextObject` has coordinates, relative to the cursor position.
buff = event.current_buffer
return TextObject(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def main():

@bindings.add("c-t")
def _(event):
" When ControlT has been pressed, toggle visibility. "
"When ControlT has been pressed, toggle visibility."
hidden[0] = not hidden[0]

print("Type Control-T to toggle password visible.")
Expand Down
2 changes: 1 addition & 1 deletion examples/prompts/swap-light-and-dark-colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def main():

@bindings.add("c-t")
def _(event):
" When ControlT has been pressed, toggle light/dark colors. "
"When ControlT has been pressed, toggle light/dark colors."
swapped[0] = not swapped[0]

def bottom_toolbar():
Expand Down
4 changes: 2 additions & 2 deletions examples/prompts/switch-between-vi-emacs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ def run():
# Add an additional key binding for toggling this flag.
@bindings.add("f4")
def _(event):
" Toggle between Emacs and Vi mode. "
"Toggle between Emacs and Vi mode."
if event.app.editing_mode == EditingMode.VI:
event.app.editing_mode = EditingMode.EMACS
else:
event.app.editing_mode = EditingMode.VI

def bottom_toolbar():
" Display the current input mode. "
"Display the current input mode."
if get_app().editing_mode == EditingMode.VI:
return " [F4] Vi "
else:
Expand Down
14 changes: 7 additions & 7 deletions prompt_toolkit/application/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ async def redraw_in_future() -> None:

@property
def invalidated(self) -> bool:
" True when a redraw operation has been scheduled. "
"True when a redraw operation has been scheduled."
return self._invalidated

def _redraw(self, render_as_done: bool = False) -> None:
Expand Down Expand Up @@ -650,7 +650,7 @@ async def run_async(
assert not self._is_running, "Application is already running."

async def _run_async() -> _AppResult:
" Coroutine. "
"Coroutine."
loop = get_event_loop()
f = loop.create_future()
self.future = f # XXX: make sure to set this before calling '_redraw'.
Expand Down Expand Up @@ -946,17 +946,17 @@ def in_terminal() -> None:

@overload
def exit(self) -> None:
" Exit without arguments. "
"Exit without arguments."

@overload
def exit(self, *, result: _AppResult, style: str = "") -> None:
" Exit with `_AppResult`. "
"Exit with `_AppResult`."

@overload
def exit(
self, *, exception: Union[BaseException, Type[BaseException]], style: str = ""
) -> None:
" Exit with exception. "
"Exit with exception."

def exit(
self,
Expand Down Expand Up @@ -1095,7 +1095,7 @@ def print_text(

@property
def is_running(self) -> bool:
" `True` when the application is currently active/running. "
"`True` when the application is currently active/running."
return self._is_running

@property
Expand Down Expand Up @@ -1234,7 +1234,7 @@ def _ok(event: E) -> None:

@key_bindings.add(Keys.Any)
def _ignore(event: E) -> None:
" Disallow typing. "
"Disallow typing."
pass

session: PromptSession[None] = PromptSession(
Expand Down
14 changes: 7 additions & 7 deletions prompt_toolkit/buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@


class EditReadOnlyBuffer(Exception):
" Attempt editing of read-only :class:`.Buffer`. "
"Attempt editing of read-only :class:`.Buffer`."


class ValidationState(Enum):
" The validation state of a buffer. This is set after the validation. "
"The validation state of a buffer. This is set after the validation."
VALID = "VALID"
INVALID = "INVALID"
UNKNOWN = "UNKNOWN"
Expand Down Expand Up @@ -440,7 +440,7 @@ def load_history_done(f: "asyncio.Future[None]") -> None:
# <getters/setters>

def _set_text(self, value: str) -> bool:
""" set text at current working_index. Return whether it changed. """
"""set text at current working_index. Return whether it changed."""
working_index = self.working_index
working_lines = self._working_lines

Expand All @@ -460,7 +460,7 @@ def _set_text(self, value: str) -> bool:
return False

def _set_cursor_position(self, value: int) -> bool:
""" Set cursor position. Return whether it changed. """
"""Set cursor position. Return whether it changed."""
original_position = self.__cursor_position
self.__cursor_position = max(0, value)

Expand Down Expand Up @@ -725,7 +725,7 @@ def cursor_right(self, count: int = 1) -> None:
self.cursor_position += self.document.get_cursor_right_position(count=count)

def cursor_up(self, count: int = 1) -> None:
""" (for multiline edit). Move cursor to the previous line. """
"""(for multiline edit). Move cursor to the previous line."""
original_column = self.preferred_column or self.document.cursor_position_col
self.cursor_position += self.document.get_cursor_up_position(
count=count, preferred_column=original_column
Expand All @@ -735,7 +735,7 @@ def cursor_up(self, count: int = 1) -> None:
self.preferred_column = original_column

def cursor_down(self, count: int = 1) -> None:
""" (for multiline edit). Move cursor to the next line. """
"""(for multiline edit). Move cursor to the next line."""
original_column = self.preferred_column or self.document.cursor_position_col
self.cursor_position += self.document.get_cursor_down_position(
count=count, preferred_column=original_column
Expand Down Expand Up @@ -1918,7 +1918,7 @@ async def new_coroutine(*a: Any, **kw: Any) -> Any:


class _Retry(Exception):
" Retry in `_only_one_at_a_time`. "
"Retry in `_only_one_at_a_time`."


def indent(buffer: Buffer, from_row: int, to_row: int, count: int = 1) -> None:
Expand Down
2 changes: 1 addition & 1 deletion prompt_toolkit/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def get(self, key: _T, getter_func: Callable[[], _U]) -> _U:
return value

def clear(self) -> None:
" Clear cache. "
"Clear cache."
self._data = {}
self._keys = deque()

Expand Down
Loading