Skip to content

Commit

Permalink
Merge pull request #5 from shtayeb/copy_text_from_output_and_refactors
Browse files Browse the repository at this point in the history
Copy text from output textarea and recatored the auto brackert insertion
  • Loading branch information
anze3db committed Jan 18, 2024
2 parents 9b33f7b + 7d248b5 commit 3f04b8c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 24 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Calendar Versioning](https://calver.org).

## [24.1] - 2023-01-18

### Added

Ability to copy from the output shell area. Thanks @shtayeb!

## [23.9] - 2023-12-19

### Added
Expand Down
2 changes: 1 addition & 1 deletion src/django_tui/__about__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2023-present Anže Pečar <[email protected]>
#
# SPDX-License-Identifier: MIT
__version__ = "23.9"
__version__ = "24.1"
34 changes: 11 additions & 23 deletions src/django_tui/management/commands/ish.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,28 +147,16 @@ class ExtendedTextArea(TextArea):
"""A subclass of TextArea with parenthesis-closing functionality."""

def _on_key(self, event: events.Key) -> None:
if event.character == "(":
self.insert("()")
self.move_cursor_relative(columns=-1)
event.prevent_default()

if event.character == "[":
self.insert("[]")
self.move_cursor_relative(columns=-1)
event.prevent_default()

if event.character == "{":
self.insert("{}")
self.move_cursor_relative(columns=-1)
event.prevent_default()

if event.character == '"':
self.insert('""')
self.move_cursor_relative(columns=-1)
event.prevent_default()

if event.character == "'":
self.insert("''")
auto_close_chars = {
"(": ")",
"{": "}",
"[": "]",
"'": "'",
'"': '"',
}
closing_char = auto_close_chars.get(event.character)
if closing_char:
self.insert(f"{event.character}{closing_char}")
self.move_cursor_relative(columns=-1)
event.prevent_default()

Expand Down Expand Up @@ -329,7 +317,7 @@ def action_copy_command(self) -> None:
copy_command = ["xclip", "-selection", "clipboard"]

try:
text_to_copy = self.input_tarea.selected_text
text_to_copy = self.input_tarea.selected_text or self.output_tarea.selected_text

run(
copy_command,
Expand Down

0 comments on commit 3f04b8c

Please sign in to comment.