FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-94521: IDLE: Auto-select and copy/cut current line if no selection on copy/cut by Wulian233 · Pull Request #126034 · python/cpython · GitHub

Repository navigation

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) .rst  (1) .txt  (1) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 2 additions & 0 deletions Lib/idlelib/News3.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ What's New in IDLE 3.15.0
Released on 2026-10-01
=========================

gh-94521: If no selection is made during copy/cut, the current line
will copy/cut automatically.

gh-152745: When "Run... Customized" with "Restart shell" unchecked
while Shell is running code, including waiting for an input('prompt:')
Expand Down
18 changes: 18 additions & 0 deletions Lib/idlelib/iomenu.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def __init__(self, editwin):
self.save_a_copy)
self.fileencoding = 'utf-8'
self.__id_print = self.text.bind("<<print-window>>", self.print_window)
self.__id_copy = self.text.bind("<<copy>>", self.copy)
self.__id_cut = self.text.bind("<<cut>>", self.cut)

def close(self):
# Undo command bindings
Expand All @@ -41,6 +43,8 @@ def close(self):
self.text.unbind("<<save-window-as-file>>",self.__id_saveas)
self.text.unbind("<<save-copy-of-window-as-file>>", self.__id_savecopy)
self.text.unbind("<<print-window>>", self.__id_print)
self.text.unbind("<<copy>>", self.__id_copy)
self.text.unbind("<<cut>>", self.__id_cut)
# Break cycles
self.editwin = None
self.text = None
Expand Down Expand Up @@ -375,6 +379,20 @@ def print_window(self, event):
os.unlink(tempfilename)
return "break"

def copy(self, event):
if not self.text.tag_ranges("sel"):
self.text.tag_add("sel", "insert linestart", "insert+1l linestart")
self.text.mark_set("insert", "insert linestart")
self.text.event_generate("<<Copy>>")
return "break"

def cut(self, event):
if not self.text.tag_ranges("sel"):
self.text.tag_add("sel", "insert linestart", "insert+1l linestart")
self.text.mark_set("insert", "insert linestart")
self.text.event_generate("<<Cut>>")
return "break"

opendialog = None
savedialog = None

Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
If no selection is made during copy/cut, the current line will copy/cut
automatically.
Loading

Back | FazBrowse Home | New Git URL