1 # improved stack functionality for DCT, by Shiar
3 # 1.13.0 200411042045 - added swap and stack from main
5 # - stack cycle would crash with undefined stack
6 # 1.10.1 200410150045 - set initial value to prevent crash when no undos set
7 # 1.10.0 200410150000 - single-level undo from main
12 my $undo = []; # stack backup
13 my $stackpos = 0; # position of stack browser
15 push @{$hook{preaction}}, sub {
17 $undo = [@stack]; # backup stack
18 $stackpos = 0; # reset position of stack navigation
19 } # stack-modifying operations (type>=0)
22 $action{undo} = [-1, sub { ($undo, @stack) = ([@stack], @$undo) }]; # undo/redo
24 $action{swap} = [ 2, sub { reverse @_ }]; # swap x<->y
26 $action{stack} = [-2, sub {
27 $stackpos %= @stack if @stack; # cycle
28 $val{i} = $stack[$stackpos++];
33 title => "stack functions",