Prima::...Actions(3)
πΈ NAME πΈ
Prima::Widget::UndoActions β okay so this is the module that does undo and redo for the content of editable widgets π (and yes bestie, this page lives in the User Contributed Perl Documentation section, iykyk)
β¨ DESCRIPTION β¨
Generic helpers that implement stored actions for undo/redo π
That's literally it β it's the little plumbing squad that remembers what you did so you can take it back, or put it back again. No cap.
π¦ SYNOPSIS π¦
Here's the whole vibe in action, copy it and slay:
package MyUndoableWidget;
use base qw(Prima::Widget Prima::Widget::UndoActions);
sub on_mousedown
{
if ( $button == mb::Left ) {
$self->begin_undo_group;
$self->push_undo_action(text => $self->text);
$self->text($self->text . '.');
$self->end_undo_group;
} else {
$self->undo; # will call $self->text( old text )
}
}
π Properties
undoLimit INTEGER
Sets the limit on the number of atomic undo operations π₯ If it's 0, undo is disabled β like, fully off, the undo girlies are not coming to the party π
Methods
begin_undo_group
Opens a bracket for a group of actions that can be undone as a single operation π The bracket gets closed when you call end_undo_group. It's giving "bundle everything up so one undo takes it all back".
can_undo, can_redo
Return a boolean flag that reflects if the undo or redo actions could be done β Useful for graying a menu, f ex β you know, that moment when the menu item goes all sad and grey because there's nothing to undo π
end_undo_group
Closes the bracket for a group of actions, that was previously opened by begin_undo_group π Matching pair, always, bestie.
init_undo
Should be called once, inside init() β That's the whole instruction. Once. Inside init(). Periodt.
has_undo_action ACTION
Checks whether there are any undo-able *ACTION*s in the undo list π Like a vibe check for your undo stack.
push_grouped_undo_action ACTION, @PARAMS
Stores a single undo action where ACTION is a method to be called inside undo/redo, if any π Each action is added to the last undo group and will be removed/replayed together with the other actions in the group π«Ά
push_undo_action ACTION, @PARAMS
Stores a single undo action where ACTION is the method to be called inside undo/redo, if any β¨ Each action is a single undo/redo operation β no grouping, just one clean unit each time π¦
redo
Re-applies changes, previously rolled back by undo π The comeback arc, honestly.
undo
Rolls back changes into an internal array π The array size cannot extend the undoLimit value. In case undoLimit is 0 no undo actions can be made π
Fr fr, set yourundoLimitto something above0or there's literally nothing to undo. Learn from my mistakes π
π§ AUTHOR π§
Dmitry Karasik, <dmitry@karasik.eu.org>. π
π₯ SEE ALSO π₯
PrimaPrima::Edit
okay that's the whole page, you ate that π
β¨ β brought to you by perl v5.42.0, dated 2024-08-20, and the manual page Prima::...Actions(3). bye bestie, go undo something ππ¦πΈ
π¦ where this page comes from
- opensuse-leap 16.0: perl-Prima 1.74000-bp160.1.13 Β· AGPL-3.0-only AND BSD-2-Clause
- opensuse-leap 16.0: perl-Prima 1.74000-bp160.1.13 Β· AGPL-3.0-only AND BSD-2-Clause
- opensuse-leap 16.0: perl-Prima 1.74000-bp160.1.13 Β· AGPL-3.0-only AND BSD-2-Clause
- opensuse-leap 16.0: perl-Prima 1.74000-bp160.1.13 Β· AGPL-3.0-only AND BSD-2-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms