Thread Kephra: Texteditor nur in Perl (538 answers)
Opened by lichtkind at 2008-03-09 00:08

renee
 2009-11-26 09:53
#128597 #128597
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Kephra::Plugin::HTMLColor:
Code (perl): (dl )
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
package Kephra::Plugin::HTMLColor;
our $VERSION = '0.01';

use strict;
use warnings;

use Wx qw(wxC2S_HTML_SYNTAX wxID_CANCEL);

sub choose_color {
    my $ep    = &Kephra::App::EditPanel::_ref;
    my $color = $ep->GetSelectedText || '#ffffff';
    
    $color = sprintf "#%s", $color unless index( $color, '#' ) == 0;

    my $color_obj = Wx::Colour->new( $color );
  
    my $data = Wx::ColourData->new;
    $data->SetColour( $color_obj );
    $data->SetChooseFull( 1 );

    my $dialog = Wx::ColourDialog->new( Kephra::App::Window::_ref(), $data );

    if( $dialog->ShowModal != wxID_CANCEL ) {
        my $data      = $dialog->GetColourData;
        my $ret_color = $data->GetColour;
    
        my $html_color = $ret_color->GetAsString( wxC2S_HTML_SYNTAX );
        $html_color =~ s/^#//;
        $ep->ReplaceSelection( $html_color );
    
    }
}


1;


In folgenden Dateien dann ein Menüeintrag hinzufügen:

commands.conf:
Code: (dl )
			color-replace = Kephra::Plugin::HTMLColor::choose_color()


(ich habe es unterhalb von "delete-tab" im "Bearbeiten"-Menü eingetrage)


mainmenu.yml:
Code: (dl )
1
2
      -
- item edit-color-replace

(unterhalb von "item edit-delete")

Und in Kephra.pm noch ein require Kephra::Plugin::HTMLColor; einfügen. Und schon hast Du Deinen Wunsch erfüllt...
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/

View full thread Kephra: Texteditor nur in Perl