App/Chart/Gtk2/Ex/TextViewBits.pm untested

filter: Statementstmt 0.0% 0 / 14 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 19 CC 1 SCAR 6.9
CC
1
Cov
0%
window_linenum
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 # Copyright 2010 Kevin Ryde
2  
3 # This file is part of Chart.
4 #
5 # Chart is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 3, or (at your option) any later version.
8 #
9 # Chart is distributed in the hope that it will be useful, but WITHOUT ANY
10 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12 # details.
13 #
14 # You should have received a copy of the GNU General Public License along
15 # with Chart. If not, see <http://www.gnu.org/licenses/>.
16  
17  
18 package App::Chart::Gtk2::Ex::TextViewBits;
19 use 5.010;
20 use strict;
21 use warnings;
22  
23 # uncomment this to run the ### lines
24 #use Smart::Comments;
25  
26 sub window_linenum {
27 my ($textview) = @_;
28 my ($x, $y) = $textview->window_to_buffer_coords ('text', 0, 0);
29 my ($win_iter, $line_top) = $textview->get_line_at_y ($y);
30 return $win_iter->get_line;
31 }
32  
33  
34 # TextBufferBits replace_lines() better
35  
36 # sub replace_text {
37 # my ($textview, $str) = @_;
38 # ### TextViewBits replace_text()
39 # my $linenum = window_linenum ($textview);
40 # ### window linenum: $linenum
41 #
42 # my $textbuf = $textview->get_buffer;
43 # $textbuf->set_text ($str);
44 #
45 # # Had lots of trouble here. scroll_to_iter didn't take effect unless
46 # # called twice, and then stubbornly refused to put the last page visible.
47 # # scroll_to_mark works, but the first time through have to do a
48 # # place_cursor or else it starts off showing the end of the buffer instead
49 # # of the start. :-(
50 # #
51 # # Still not quite right if you do it too rapidly :-(
52 # #
53 # my $iter = $textbuf->get_iter_at_line ($linenum);
54 # $textbuf->place_cursor ($iter);
55 # my $mark = $textbuf->get_mark (__PACKAGE__);
56 # if ($mark) { $textbuf->move_mark ($mark, $iter); }
57 # else { $mark = $textbuf->create_mark (__PACKAGE__, $iter, 0); }
58 # $textview->scroll_to_mark ($mark, 0, 1, 0.0, 0.0);
59 # }
60  
61 # =item C<< App::Chart::Gtk2::Ex::TextViewBits::replace_text ($textview, $str) >>
62 #
63 # Replace the text in C<$textview>'s buffer, preserving its window position.
64  
65  
66 1;
67 __END__