$cursor->move_right(3); # move cursor three chars to the right
$cursor->move_down(); # move cursor one line downwards
# and
my $left_pos = $cursor->move_left(1);
# position one char to the left of the cursor
my $start = $cursor->start_of_document();
####
sub frobnicate_position {
my ($self) = @_;
my $obj;
if (defined wantarray) {
$obj = $self->copy();
} else {
$obj = $self;
}
... calculate new position here,
... set $obj->line() and $obj->column()
return $obj
};
####
sub positional_mutator(&;$) {
my ($worker,$name) = @_;
no strict 'refs';
*{$name} = sub {
my $self = shift;
my $obj;
if (defined wantarray) {
$obj = $self->copy();
} else {
$obj = $self;
};
$worker->($obj,@_);
}
};
positional_mutator {
my ($obj,@args) = @_;
... calculate new position here
}, 'frobnicate_position';