TextUndo(3pm)

πŸ’– TextUndo β€” the Tk::TextUndo era πŸ’–

okay bestie so Tk::TextUndo is a perl/tk text widget, and it comes with bindings that let you undo your changes. that's the whole vibe. it lives in section 3pm of the perl manual, iykyk. πŸ¦‹


✨ SYNOPSIS ✨

use Tk::TextUndo;

$testundo = $parent->TextUndo(?-option=>value, ...?);

like, that's it. that's the whole summoning ritual. πŸ’…


🌸 DESCRIPTION 🌸

so this widget IS-A text widget β€” it inherits all that text widget energy β€” but with one iconic upgrade: an unlimited 'undo' history. πŸ”₯

lowkey important caveat tho: there is no re'undo' capability. no cap. you can go backwards forever, but you cannot go back forwards. it's giving one-way street. 😭

πŸŽ€ Bindings πŸŽ€

the TextUndo widget has the exact same bindings as the Text widget, bestie. but in addition, there's this extra one:

  • Event <L4> <<Undo>> β€” undoes the last change. and the way that pressing <L4> several times undoes the changes step by step?? obsessed. every press rewinds you one more step through everything you did to the text widget. πŸ‘‘

🧚 Methods 🧚

same methods as the Text widget, obviously, it IS-A text widget. but here are the extra ones TextUndo brings to the group chat:

  • $text->Load($filename); β€” loads the contents of $filename into the text widget. heads up bestie: Load() deletes the previous contents of the text widget, and it also wipes the undo history of the previous file. clean slate, periodt. 🫢
  • $text->Save(?$otherfilename?) β€” saves the contents of the text widget to a file. if $otherfilename isn't specified, it writes the contents to the file of $filename that was used in the last Load() call. if no file was previously Load()'ed... an error message pops up. πŸ’€ and btw, the default filename from the last Load() call is not overwritten by $otherfilename. noted. πŸ“
  • $text->FileName(?$otherfilename?) β€” if you pass it an argument, it sets the file name associated with the loaded document. and either way it returns the current file name associated with the document. dual purpose icon. ✨

πŸ”‘ KEYS πŸ”‘

  • widget
  • text
  • undo

πŸ‘€ SEE ALSO πŸ‘€

  • Tk::Text
  • Tk::ROText

and that's the whole page bestie!! 🌈 this was written by the perl crew and shipped as part of perl v5.40.1, dated 2025-04-13. mwah, go undo something. πŸ’–πŸ’…πŸŽ€

πŸ“¦ where this page comes from