App-Music-ChordPro
view release on metacpan or search on metacpan
lib/ChordPro/Wx/Editor.pm view on Meta::CPAN
}
}
sub SetFont( $self, $font ) {
die("XXX\n") unless $font->IsOk;
$self->StyleSetFont( $_, $font ) for 0..7;
$self->{font} = $font;
}
sub GetFont( $self ) {
$self->{font} // $self->StyleGetFont(0);
}
sub OSXDisableAllSmartSubstitutions( $self ) {
}
sub OnStyleNeeded( $self, $event ) { # scintilla
$self->style_text;
}
sub OnChanged( $self, $event ) { # scintilla
$state{editchanged}++;
}
sub Replace( $self, $from=-1, $to=-1, $text="" ) {
# We will only call this to replace the selection.
$self->ReplaceSelection($text);
}
# STC::Remove is missing...
sub Remove( $self, $from=-1, $to=-1 ) {
$self->Replace( $from, $to, "" );
}
################ Methods ################
package ChordPro::Wx::TextEditor;
use parent qw( -norequire Wx::TextCtrl );
use Wx ':everything';
use ChordPro::Files;
use ChordPro::Wx::Config;
use ChordPro::Wx::Utils;
sub new( $class, $parent, $id=undef ) {
my $self = $class->SUPER::new( $parent, wxID_ANY, "",
wxDefaultPosition, wxDefaultSize,
wxHSCROLL|wxTE_MULTILINE );
return $self;
}
sub refresh( $self, $prefs = undef ) {
my $ctrl = $self;
$prefs //= \%preferences;
my $mod = $self->IsModified;
# TextCtrl only supports background colour and font.
my $theme = $prefs->{editortheme};
my $c = $prefs->{editcolour}{$theme};
my $bgcol = Wx::Colour->new( $c->{bg} );
my $fgcol = Wx::Colour->new( $c->{fg} );
$ctrl->SetBackgroundColour($bgcol);
$ctrl->SetStyle( 0, $ctrl->GetLastPosition,
Wx::TextAttr->new( $fgcol, $bgcol ) );
$ctrl->SetFont( Wx::Font->new($prefs->{editfont}) );
$ctrl->SetModified($mod);
}
sub AddText( $self, $text ) {
$self->WriteText($text);
}
sub GetLineCount( $self ) {
$self->GetNumberOfLines;
}
sub GetSelectedText( $self ) {
$self->GetStringSelection;
}
sub GetText( $self ) {
$self->GetValue;
}
sub SetText( $self, $text ) {
$self->SetValue($text);
}
sub SetColour( $self, $colour ) {
$self->SetStyle( 0, $self->GetLastPosition,
Wx::TextAttr->new( Wx::Colour->new($colour) ) );
}
sub SetViewLineNumbers( $self, $b ) {
}
sub EmptyUndoBuffer($self) {
}
sub OSXDisableAllSmartSubstitutions( $self ) {
return unless is_macos;
$self->SUPER::OSXDisableAllSmartSubstitutions;
}
################
1;
( run in 1.056 second using v1.01-cache-2.11-cpan-d8267643d1d )