diff --git a/NEWS.md b/NEWS.md index 13b5ea5..74b73a7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,18 @@ # Scrunch Edit news +## Version 2.1 (2 November 2022) + +Backported some improvements from AntiWiki 1.3 + +### Added + +* Format -> Join Lines command + +### Fixed + +* Pasting over a selection now replaces it. +* Ctrl-A now actually does Select All. + ## Version 2.0.2 (27 June 2022) ### Fixed diff --git a/scrunch2.py b/scrunch2.py index 69e8d13..814b251 100644 --- a/scrunch2.py +++ b/scrunch2.py @@ -44,7 +44,7 @@ else: about_text = """ A two-pane outliner -Version 2.0.2 (27 Jun 2022) +Version 2.1 (2 November 2022) MIT License """ @@ -436,11 +436,15 @@ def copy_content(): top.tk.eval("tk_textCopy " + str(editor)) def paste_content(): + if len(editor.tag_ranges("sel")) > 0: + editor.delete("sel.first", "sel.last") top.tk.eval("tk_textPaste " + str(editor)) + return "break" def select_all(widget): widget.tag_remove("sel", "1.0", "end") widget.tag_add("sel", "1.0", "end") + return "break" def handle_find(): global search, term @@ -505,6 +509,13 @@ def upper_case(): else: status["text"] = "Nothing selected." +def join_lines(): + text = text_selection(editor).replace("\n", " ") + if len(text) > 0: + editor.replace("sel.first", "sel.last", text) + else: + status["text"] = "Nothing selected." + def add_child(): answer = askstring("Add section", "New section title:", parent=top) if answer == None: @@ -744,6 +755,10 @@ edit_menu.add_command( format_menu = Menu(menubar) menubar.add_cascade(menu=format_menu, label="Format", underline=1) +format_menu.add_command( + label="Join lines", underline=0, accelerator="Alt-J", + command=join_lines) +format_menu.add_separator() format_menu.add_command( label="Lower case", underline=0, accelerator="Alt-L", command=lower_case) @@ -834,6 +849,7 @@ top.bind("", lambda e: handle_quit()) # Undo is already bound to Ctrl-z by default. editor.bind("", lambda e: editor.edit_redo()) +editor.bind("", lambda e: paste_content()) editor.bind("", lambda e: select_all(editor)) top.bind("", lambda e: handle_find()) top.bind("", lambda e: find_again())