~ubuntu-branches/ubuntu/saucy/padre/saucy-proposed

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package t::lib::Padre::Editor;

use strict;
use warnings;
use Padre::Wx::Editor ();

our @ISA = 'Padre::Wx::Editor';

sub new {
	my $self = bless {}, shift;
	return $self;
}

sub set_document {
	my ( $self, $doc ) = @_;

	if ( defined $doc->{original_content} ) {
		$self->SetText( $doc->{original_content} );
	}
}

sub main {
	undef;
}

sub SetEOLMode {

}

sub ConvertEOLs {

}

sub EmptyUndoBuffer {

}

sub SetText {
	my ($self, $text) = @_;
	$self->{text}            = $text;
	$self->{pos}             = 0;
	$self->{selection_start} = 0;
	$self->{selection_start} = 0;
	return;
}

sub LineFromPosition {
	my ($self, $pos) = @_;
	return 0 if $pos == 0;
	my $str = substr($self->{text}, 0, $pos);
	#warn "str $pos '$str'\n";
	my @lines = split /\n/, $str, -1;
	return @lines-1; 
}

sub GetLineEndPosition {
	my ($self, $line) = @_;
	my @lines = split(/\n/, $self->{text}, -1);
	my $str = join "\n", @lines[0..$line];
	return length($str)+1;
}

sub PositionFromLine {
	my ($self, $line) = @_;
	return 0 if $line == 0;
	my @lines = split(/\n/, $self->{text}, -1);
	my $str = join "\n", @lines[0..$line-1];
	return length($str)+1;
}

sub GetColumn {
	my ($self, $pos) = @_;
	my $line  = $self->LineFromPosition($pos);
	my $start = $self->PositionFromLine($line);
	return $pos - $start;
}

sub GetText {
	return $_[0]->{text}
}

sub GetCurrentPos {
	return $_[0]->{pos};
}

sub GetSelectionEnd {
	return $_->{selection_end};
}

sub SetSelectionStart {
	$_[0]->{selection_start} = $_[1]
}

sub GotoPos {
	$_[0]->{pos} = $_[1];
}

1;