Prima

 view release on metacpan or  search on metacpan

Prima/Edit.pm  view on Meta::CPAN

	return if $nth < 2 || $nth > 3;
	return $self-> selection( 0, $xy[1], $sl, $xy[1]) if $nth == 3;

	$self-> cancel_block;
	$self-> cursor( @xy);

	my $p = $self->visual_to_physical(@xy);
	my ($l,$r);
	$sl = length $s;
	return unless $sl;

	$p = $sl-1 if $p >= $sl;
	my $word = quotemeta($self-> {wordDelimiters});
	my $nonword = "[$word]";
	$word = "[^$word]";
	if ( substr($s,$p,1) =~ /$word/) {
		substr($s,0,$p) =~ /($word*)$/;
		$l = $p - length $1;
		substr($s,$p) =~ /^($word*)/;
		$r = $p + length $1;
	} else {
		substr($s,0,$p) =~ /($nonword*)$/;
		$l = $p - length $1;
		substr($s,$p) =~ /^($nonword*)/;
		$r = $p + length $1;
	}

	$l = $self-> physical_to_visual( $l, $xy[1] );
	$r = $self-> physical_to_visual( $r - 1, $xy[1]);
	($l > $r) ? $l++ : $r++;

	$self-> selection( $l, $xy[1], $r, $xy[1] );
}

sub on_keydown
{
	my ( $self, $code, $key, $mod, $repeat) = @_;
	return if $self-> {readOnly};
	return if $mod & km::DeadKey;
	$mod &= ( km::Shift|km::Ctrl|km::Alt);
	$self-> notify(q(MouseUp),0,0,0) if $self-> {mouseTransaction};
	if ( $key == kb::Tab && !$self-> {wantTabs}) {
		return unless $mod & km::Ctrl;
		$mod &= ~km::Ctrl;
	}
	if  (
		( $code >= ord(' ') || ( $code == ord("\t"))) &&
		(( $mod  & (km::Alt | km::Ctrl)) == 0) &&
		(( $key == kb::NoKey) || ( $key == kb::Space) || ( $key == kb::Tab))
	) {
		$self-> begin_undo_group;

		my $block = $self-> has_selection;
		$self-> delete_block if $block;

		my @cs = $self-> cursor;
		my $c  = $self-> get_line( $cs[1]);
		my $l = 0;

		my $chr = chr $code;
		utf8::upgrade($chr) if $mod & km::Unicode;
		my $ll = $self-> get_chunk_cluster_length($cs[1]);
		$c .= ' ' x ($cs[0] - $ll) if $cs[0] > $ll;
		my $s = $self->get_shaped_chunk($cs[1]);
		my ($new_text, $new_offset) = $self->handle_bidi_input(
			action     => (($block || $self->insertMode) ? q(insert) : q(overtype)),
			at         => $cs[0],
			input      => $chr x $repeat,
			text       => $c,
			rtl        => $self->textDirection,
			glyphs     => $s,
			n_clusters => $ll,
		);
		$self-> set_line( $cs[1], $new_text, (($block || $self->insertMode) ?
			(q(add), $cs[0], $l + $repeat) : 
			q(overtype)
		));
		$self-> cursor(
			$self->get_shaped_chunk($cs[1])->index2cluster($new_offset, 1),
			$cs[1]
		);
		$self-> end_undo_group;
		$self-> clear_event;
	}
}

sub on_fontchanged
{
	my $self = $_[0];
	$self-> reset_render;
	$self-> reset_scrolls;
}

sub on_size
{
	my $self = $_[0];
	$self-> reset_render;
	$self-> reset_scrolls;
}

sub on_enable  { $_[0]-> repaint; }
sub on_disable { $_[0]-> repaint; }

sub on_enter
{
	my $self = $_[0];
	$self-> insertMode( $::application-> insertMode);
}

sub on_change { $_[0]-> {modified} = 1;}

sub on_parsesyntax { $_[0]-> {syntaxer}-> (@_); }

sub on_dragbegin
{
	my $self = shift;
	$self->{drop_transaction} = [];
}

sub on_dragover
{

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 1.851 second using v1.00-cache-2.02-grep-82fe00e-cpan-1925d2aa809 )