Subject: | ->get_cell bound checking and translation |
As discussed: Tickit::RenderBuffer->get_cell does not take the current translation into account.
The attached case is hopefully valid - the idea is that ->char_at and ->get_cell should be consistent:
$rb->char_at(0,0, $ch);
is $rb->get_cell(0,0)->char, $ch;
Currently working around this with a version check (walk the parents to accumulate total offset), and ->get_cell works fine for valid co-ordinates there.
Positions outside the renderbuffer appear to cause a segfault, however (see second case). Things work fine if you pre-validate the values, so it looks like it's just a case of adding the appropriate bounds check to ->get_cell.
cheers,
Tom
Subject: | get_cell.t |
use strict;
use warnings;
use Test::More;
use Tickit::Window;
use Tickit::Test;
my ( $term, $win ) = mk_term_and_window;
my $float = $win->make_float(
2, 2, 3, 3
);
$float->set_on_expose(with_rb => sub {
my ($win, $rb, $rect) = @_;
$rb->clear;
my $ch = ord 'x';
$rb->char_at(0, 0, $ch);
is($rb->get_cell(0, 0)->char, $ch, 'have t at 0,0');
isnt($rb->get_cell(2, 2)->char, $ch, 'and something else at 2,2');
});
$win->expose;
flush_tickit;
done_testing;
Subject: | get_cell_segfault.t |
use strict;
use warnings;
use Test::More;
use Test::Fatal;
use Tickit::Window;
use Tickit::Test;
my ( $term, $win ) = mk_term_and_window;
my $float = $win->make_float(
2, 2, 3, 3
);
$float->set_on_expose(with_rb => sub {
my ($win, $rb, $rect) = @_;
$rb->clear;
my $ch = ord 'x';
$rb->char_at(0, 0, $ch);
is(exception {
$rb->get_cell(300, 300)->char
}, undef, 'can request position outside renderbuffer');
});
$win->expose;
flush_tickit;
done_testing;