view release on metacpan or search on metacpan
lib/Text/Editor/Easy/Abstract.pm view on Meta::CPAN
'F3' => \&Text::Editor::Easy::next_search,
'ctrl_c' => [ \&Text::Editor::Easy::Abstract::Key::copy, 'Abstract' ],
'ctrl_C' => [ \&Text::Editor::Easy::Abstract::Key::copy, 'Abstract' ],
'ctrl_f' => \&Text::Editor::Easy::Key::search,
'ctrl_F' => \&Text::Editor::Easy::Key::search,
'ctrl_i' => [ \&Text::Editor::Easy::Abstract::test_new_insert, 'Abstract' ],
'ctrl_I' => [ \&Text::Editor::Easy::Abstract::test_new_insert, 'Abstract' ],
'ctrl_j' => \&Text::Editor::Easy::Abstract::print_clipboard,
'ctrl_J' => \&Text::Editor::Easy::Abstract::print_clipboard,
'ctrl_l' => \&Text::Editor::Easy::Key::close,
'ctrl_L' => \&Text::Editor::Easy::Key::close,
'ctrl_m' => \&decrease_line_space,
'ctrl_M' => \&decrease_line_space,
'ctrl_p' => \&increase_line_space,
'ctrl_P' => \&increase_line_space,
'ctrl_q' => \&Text::Editor::Easy::Key::query_segments,
'ctrl_Q' => \&Text::Editor::Easy::Key::query_segments,
lib/Text/Editor/Easy/Abstract.pm view on Meta::CPAN
$compteur += 1;
$abstract{$_}->[GRAPHIC]->manage_event();
last;
}
if ( !$compteur ) {
print STDERR
"Can't call manage_event loop when no Text::Editor::Easy object is created\n";
}
}
sub clipboard_set {
my ( $self, $string ) = @_;
print "Dans clipboard_set de abstract : |$string|\n";
for ( keys %abstract ) {
return $abstract{$_}->[GRAPHIC]->clipboard_set( $string );
}
print STDERR
"Can't call clipboard_set when no Text::Editor::Easy object is created\n";
return;
}
sub clipboard_get {
for ( keys %abstract ) {
return $abstract{$_}->[GRAPHIC]->clipboard_get();
}
print STDERR
"Can't call clipboard_get when no Text::Editor::Easy object is created\n";
return;
}
sub print_clipboard {
my $clipboard = clipboard_get();
my @lines = split( /\n/, $clipboard );
for my $line ( @lines ) {
print "$line|\n\t";
for my $indice ( 0..length($line) - 1 ) {
my $char = substr( $line, $indice, 1 );
print ord($char), ":";
}
print "\n";
}
}
lib/Text/Editor/Easy/Abstract.pm view on Meta::CPAN
######################################################################
#
# INTERFACE
#
######################################################################
sub test_new_insert {
my ( $edit_ref ) = @_;
my $text = $edit_ref->[GRAPHIC]->clipboard_get;
my $options_ref = do 'options_ref.txt';
# Test gros bloc
#$text = "";
#my $texte = " : ligne n° : ";
#my $indice = 0;
#while ( $indice++ < 100000 ) {
# $text .= "\n" . $indice . $texte . $indice;
#}
#
#print "start time ", scalar(localtime), "\n";
lib/Text/Editor/Easy/Abstract.pm view on Meta::CPAN
my ($self) = values %abstract;
print "In increase_line_offset\n";
$self->[GRAPHIC]->decrease_line_offset;
resize_all();
}
sub paste {
my ( $edit_ref ) = @_;
my $string = $edit_ref->[GRAPHIC]->clipboard_get;
insert($edit_ref, $string, { 'bloc' => 1 } );
}
sub resize_all {
#my @zones = Text::Editor::Easy::Zone->list;
#ZONE: for my $zone ( @zones ) {
#print "Zone $zone\n";
#my $graphic = Text::Editor::Easy::Graphic->get_graphic_focused_in_zone ( $zone );
for my $abstract_ref ( values %abstract ) {
lib/Text/Editor/Easy/Abstract.pm view on Meta::CPAN
=head2 change_title
=head2 check_cursor
=head2 clean
=head2 clear_screen
=head2 clic
=head2 clipboard_get
Retrieve the content of the clipboard (for paste operation)
=head2 clipboard_set
Set the content of the clipboard (for copy operation)
=head2 concat
=head2 create_line_ref_from_ref
=head2 create_text_in_line
=head2 cursor_abs
=head2 cursor_display
lib/Text/Editor/Easy/Abstract.pm view on Meta::CPAN
=head2 at_top
=head2 on_top_ref_editor
Returns the reference of the Text::Editor::Easy instance that is above the other.
=head2 parent
=head2 paste
Copy the clipboard content to the cursor position.
=head2 position_cursor_in_display
=head2 position_cursor_in_line
=head2 read_next_line
=head2 read_previous_line
=head2 reference_zone_event
lib/Text/Editor/Easy/Abstract/Key.pm view on Meta::CPAN
$stop_pos = $select_ref->{'start_pos'};
}
my $buffer;
if ( $ref_stop_line != $ref_start_line ) {
$buffer = substr ( $self->[PARENT]->line_text( $ref_start_line) , $start_pos );
$buffer .= "\n";
}
else {
$buffer = substr ( $self->[PARENT]->line_text( $ref_start_line ), $start_pos, $stop_pos - $start_pos );
print "========Debut buffer\n$buffer\n==========Fin buffer\n";
Text::Editor::Easy->clipboard_set($buffer);
return;
}
my ( $ref_line ) = $self->[PARENT]->next_line( $ref_start_line );
while ( defined $ref_line and $ref_line != $ref_stop_line ) {
$ref_start_line = $ref_line;
$buffer .= $self->[PARENT]->line_text( $ref_line ) . "\n";
( $ref_line ) = $self->[PARENT]->next_line( $ref_line );
}
if ( ! defined $ref_line ) { # stop line suppressed ?
print STDERR "Can't copy : no line after line with reference $ref_start_line\n";
return;
}
$buffer .= substr ( $self->[PARENT]->line_text( $ref_line ), 0, $stop_pos );
#print "========Debut buffer\n$buffer\n==========Fin buffer\n";
Text::Editor::Easy->clipboard_set($buffer);
return $buffer;
#$buffer = $self->cursor->line->text . "\n";
}
sub delete_selection {
my ( $self ) = @_;
my $select_ref = $self->[SELECTION];
return if ( ! defined $select_ref );
lib/Text/Editor/Easy/Comm.pm view on Meta::CPAN
Text::Editor::Easy->ask_thread(
'add_thread_method',
0,
{
'package' => 'Text::Editor::Easy::Abstract',
'method' => [
'reference_zone_events',
'exit',
'abstract_join',
'manage_event',
'clipboard_set',
'clipboard_get',
'on_top_ref_editor',
'on_editor_destroy',
'repeat',
'repeat_class_method',
'window_set',
'window_get',
'graphic_zone_update',
]
}
);
lib/Text/Editor/Easy/Comm.pm view on Meta::CPAN
# ==> there is no pre-emption (use another thread or another process for that)
# Generally, long interruptible task will be called asynchronously (but not mandatory :
# blocking the calling thread with a synchronous call does not prevent other threads
# from making calls to the executing thread)
# If a long interruptible task launch another long interruptible task, the first
# task will recover CPU only when the 2nd launched task is over
my $self_server = $thread_knowledge{'self_server'};
my ( $method, $call_id, $reference, @param ) = get_task_to_do;
if ( $method eq 'clipboard_set' ) {
print "HAVE_TASK_DONE : Appel clipboard_set, @param\n";
}
execute_task( 'async', $self_server, $method, $call_id, $reference,
@param );
}
sub execute_this_task {
my ( $method, $call_id, $reference, @param ) = @_;
my $self_server = $thread_knowledge{'self_server'};
execute_task( 'async', $self_server, $method, $call_id, $reference,
@param );
lib/Text/Editor/Easy/Graphic/Tk_glue.pm view on Meta::CPAN
}
return $graphic->[TOP_LEVEL]->fontCreate(
-family => $hash_ref->{family},
-size => $hash_ref->{size},
-weight => $hash_ref->{weight},
@underline,
@slant,
);
}
sub clipboard_get {
my ( $self ) = @_;
my $string = $self->[TOP_LEVEL]->SelectionGet(
-selection => "CLIPBOARD" ,
-type => "STRING"
);
# Null character not managed by Tk (?)
# My former regular exp didn't work ===> s/x00.*$//
my @lines = split( /\n/, $string, -1 );
lib/Text/Editor/Easy/Graphic/Tk_glue.pm view on Meta::CPAN
my $char = substr( $line, $indice, 1 );
if ( ord($char) == 0 ) {
return $buffer;
}
$buffer .= $char;
}
}
return $buffer;
}
sub clipboard_set {
my ( $self, $string ) = @_;
#print "Dans clipboard_set de Tk_glue |$self|$string|\n";
# usefull ?
$self->[TOP_LEVEL]->clipboardClear;
$self->[TOP_LEVEL]->clipboardAppend('--', $string);
return 1;
}
sub manage_event {
#my ( $self ) = @_;
#print "On rentre dans la mainloop\n";
MainLoop;
}
lib/Text/Editor/Easy/Key.pm view on Meta::CPAN
}
my $buffer;
if ( $stop_line != $start_line ) {
$buffer = substr ( $start_line->text, $start_pos );
$buffer .= "\n";
}
else {
# A gérer
$buffer = substr ( $start_line->text, $start_pos, $stop_pos - $start_pos );
print "========Debut buffer\n$buffer\n==========Fin buffer\n";
Text::Editor::Easy->clipboard_set($buffer);
return;
}
my $line = $start_line->next;
while ( defined $line and $line != $stop_line ) {
$buffer .= $line->text . "\n";
$line = $line->next;
}
return if ( ! defined $line ); # stop line suppressed
$buffer .= substr ( $line->text, 0, $stop_pos );
print "========Debut buffer\n$buffer\n==========Fin buffer\n";
Text::Editor::Easy->clipboard_set($buffer);
#$buffer = $self->cursor->line->text . "\n";
}
sub cut_line {
my ($self) = @_;
my $cursor = $self->cursor;
my $line = $cursor->line;
$buffer = $line->text;
$cursor->set(0);
$self->erase( length( $line->text ) + 1 );
}
sub paste {
my ($self) = @_;
$self->insert(Text::Editor::Easy->clipboard_get());
}
sub wrap {
my ($self) = @_;
my $screen = $self->screen;
if ( $screen->wrap ) {
$screen->unset_wrap;
}
else {
lib/Text/Editor/Easy/Key.pm view on Meta::CPAN
=head1 FUNCTIONS
=head2 backspace
=head2 close
Should behave like a standard file close.
=head2 copy
Copy the selected text to the clipboard.
=head2 copy_line
=head2 cut_line
=head2 delete_start_selection_point
Delete from memory the start point of the selected text.
=head2 display_cursor_display