CodeManager

 view release on metacpan or  search on metacpan

lib/Prima/CodeManager/File.pm  view on Meta::CPAN

		);
		$Prima::CodeManager::developer{ "space_$pageCount-$k-2" } = $Prima::CodeManager::developer{notes}->insert_to_page(
			$pageCount,
			Label	=>
			text		=>	'',
			backColor	=>	$self->licz_kolor(
				$Prima::CodeManager::info_of_files{$file}->{backColor},
				$self->{global}->{GLOBAL}{editor_backColor},
				($szer-$k)/$szer,
			),
			light3DColor=>	0x000000,
			dark3DColor	=>	0x000000,
			borderWidth	=>	0,
			autoWidth	=>	0,
			place => {
				x => 67 - 2*$szer + 2*$k,	relx => 0.0,	width  => 2,	relwidth  => 0,
				y =>  0,					rely => 0.5,	height => 0,	relheight => 1,
			},
		);
	}

	$Prima::CodeManager::developer{ "numer_$pageCount" } = $Prima::CodeManager::developer{notes}->insert_to_page(
		$pageCount,
		'CodeManager::Label'	=>
		text			=>	'',
		backColor		=>	$kolor_paska,
		light3DColor	=>	0x000000,
		dark3DColor		=>	0x000000,
		borderWidth		=>	0,
		alignment		=>	ta::Right,
		autoWidth		=>	0,
		lineSpace		=>	$self->{global}->{GLOBAL}{editor_lineSpace},
		place => {
			x => 25,	relx => 0.0,	width  => 50,	relwidth  => 0,
			y =>  0,	rely => 0.5,	height =>  0,	relheight => 1,
		},
		font => {
			name	=>	$self->{global}->{GLOBAL}{editor_fontName},
			$type_dimen	=>	$font_dimen,
			style	=>	fs::Normal,
		},
	);

	$Prima::CodeManager::developer{ "notes_$pageCount" } = $Prima::CodeManager::developer{notes}->insert_to_page(
		$pageCount,
		'CodeManager::Edit'	=>
		name			=>	"Edit_$pageCount",
		title			=>	$file,
		textRef			=>	\$cap,
		hScroll			=>	1,
		vScroll			=>	1,
		tabIndent		=>	4,
		syntaxHilite	=>	1,
		hiliteREs		=>	$::hilite{"rexp_$type"},
		hiliteCase		=>	$::hilite{"case_$type"},
		hiliteStyl		=>	$::hilite{"styl_$type"},
		hiliteBlok		=>	$::hilite{"blok_$type"},
		exportHTML		=>	0,
		backColor		=>	$self->{global}->{GLOBAL}{editor_backColor},
		borderWidth		=>	0,
		cursorWrap		=>	1,
		scope			=>	fds::Cursor,
		lineSpace		=>	$self->{global}->{GLOBAL}{editor_lineSpace},
		wheelRows		=>	5,
		place => {
			x => 33,	relx => 0.5,	width  =>-66,	relwidth  => 1,
			y => 0,		rely => 0.5,	height =>0,		relheight => 1,
		},
		font => {
			name	=>	$self->{global}->{GLOBAL}{editor_fontName},
			$type_dimen	=>	$font_dimen,
#			name	=>	$fontName,
#			size	=>	$fontSize,
			style	=>	fs::Normal,
		},
	);

	$Prima::CodeManager::info_of_files{$file}->{exists} = 1;
	$Prima::CodeManager::developer{notes}-> tabIndex($pageCount);
	$Prima::CodeManager::developer{"notes_$pageCount"}-> focus;

}

########################################################################################

sub file_close
{
	my ( $self ) = ( shift );

	my $nr = $Prima::CodeManager::developer{notes}-> pageIndex;
	if ( $nr >= 0 ) {
		if ( $Prima::CodeManager::developer{ "notes_$nr" }-> modified) {
			my $r =  Prima::MsgBox::message_box (
				'File not saved! ',
				'File '.$Prima::CodeManager::list_of_files[$nr].' has been modified.  Save?', mb::YesNoCancel | mb::Warning
			);
			$self-> clear_event, return if mb::Cancel == $r;
			$self-> clear_event, return unless $self->file_save_batch( $nr );
		}

		$Prima::CodeManager::developer{notes}-> tabIndex($nr);
		for ( my $i = $nr; $i < $Prima::CodeManager::developer{notes}->pageCount - 1; $i++ ) {
			for ( $Prima::CodeManager::developer{notes}-> widgets_from_page( $i ) ) {
				$Prima::CodeManager::developer{notes}-> delete_widget ( $_ );
			}
			my $hn = $i + 1;
			for ( $Prima::CodeManager::developer{notes}-> widgets_from_page( $hn ) ) {
				$Prima::CodeManager::developer{notes}-> move_widget ( $_, $i );
				$Prima::CodeManager::developer{notes}-> widget_set( $_,
					visible => 1,
					autoEnableChildren => 1,
					enabled => 1,
					geometry => gt::Default,
				);
				my $k = 0;
				while ( $Prima::CodeManager::developer{ "space_$i-$k-1" } ) {
					$Prima::CodeManager::developer{ "space_$i-$k-1" } = $Prima::CodeManager::developer{ "space_$hn-$k-1" };
					$Prima::CodeManager::developer{ "space_$i-$k-2" } = $Prima::CodeManager::developer{ "space_$hn-$k-2" };
					$k++;
				}
				$Prima::CodeManager::developer{ "numer_$i" } = $Prima::CodeManager::developer{ "numer_$hn" };

lib/Prima/CodeManager/File.pm  view on Meta::CPAN

		replaceText  => '',
		findText     => $this-> get_selected_text,
		replaceItems => [],
		findItems    => [],
		options      => 0,
		scope        => fds::Cursor,
	) unless defined $findData;
	$findData->{findText} = $this-> get_selected_text;
	my $fd = $findData;
	my @props = qw(findText options scope);
	push( @props, q(replaceText)) unless $findStyle;
	if ( $fd) { for( @props) { $prf{$_} = $fd-> {$_}}}
	my $findDialog = Prima::FindDialog-> create;
	$findDialog-> set( %prf, findStyle => $findStyle);
	$findDialog-> Find-> items($fd-> {findItems});
	$findDialog-> Replace-> items($fd-> {replaceItems}) unless $findStyle;
	my $ret = 0;
	my $rf  = $findDialog-> execute;
	if ( $rf != mb::Cancel) {
		{ for( @props) { $findData-> {$_} = $findDialog-> $_()}}
		$findData-> {result} = $rf;
		$findData-> {asFind} = $findStyle;
##############
		my @pozycje = @{$findDialog-> Find-> items};
		my @newitems;
		for ( my $i = 0 ; $i < @pozycje; $i++ ) {
			my $czy = 1;
			for ( my $j = 0 ; $j < $i; $j++ ) {
				$czy = 0 if lc($pozycje[$i]) eq lc($pozycje[$j]);
				last unless $czy;
			}
			push @newitems, $pozycje[$i] if $czy;
		}
##############
		@{$findData-> {findItems}} = @newitems;
#		@{$findData-> {findItems}} = @{$findDialog-> Find-> items};
		@{$findData-> {replaceItems}} = @{$findDialog-> Replace-> items}
			unless $findStyle;
		$ret = 1;
	}
	return $ret;
}
#--------------------------------------------------------------------------------------
sub do_find
{
	my ( $self ) = ( shift );
	my $e = $Prima::CodeManager::developer{ "notes_".$Prima::CodeManager::developer{notes}-> pageIndex };
#	my $e = $this;
#	my $p = $this-> {findData};
	my $p = $findData;
	my @scope;
	FIND:{
		if ( $$p{scope} != fds::Cursor) {
			if ( $e-> has_selection) {
				my @sel = $e-> selection;
				@scope = ($$p{scope} == fds::Top) ? ($sel[0],$sel[1]) : ($sel[2], $sel[3]);
			} else {
				@scope = ($$p{scope} == fds::Top) ? (0,0) : (-1,-1);
			}
		} else {
			@scope = $e-> cursor;
		}
		my @n = $e-> find( $$p{findText}, @scope, $$p{replaceText}, $$p{options});
		if ( !defined $n[0]) {
			Prima::MsgBox::message( "No more matches found!" , mb::NoSound | mb::Information );
			return;
		}
		$e-> cursor(($$p{options} & fdo::BackwardSearch) ? $n[0] : $n[0] + $n[2], $n[1]);
		$e-> selection( $n[0], $n[1], $n[0] + $n[2], $n[1]);
		unless ( $$p{asFind}) {
			if ( $$p{options} & fdo::ReplacePrompt) {
				my $r = Prima::MsgBox::message_box( "Replace...","Replace text '$$p{findText}'?", mb::YesNoCancel|mb::Information|mb::NoSound);
#				my $r = Prima::MsgBox::message_box( $e-> text,
#				"Replace this text?",
#				mb::YesNoCancel|mb::Information|mb::NoSound);
				redo FIND if ($r == mb::No) && ($$p{result} == mb::ChangeAll);
				last FIND if $r == mb::Cancel;
			}
			$e-> set_line( $n[1], $n[3]);
			redo FIND if $$p{result} && $$p{result} == mb::ChangeAll;
		}
	}
}
#-------------------------------------------------------------------------------
sub find_next
{
	my ( $self ) = ( shift );
#	my ( $this ) = ( $Prima::CodeManager::developer{ "notes_".$Prima::CodeManager::developer{notes}->pageIndex } );
#	return unless $this-> {findData};
	return unless $findData;
	$self-> do_find;
}
#-------------------------------------------------------------------------------
sub replace
{
	my ( $self ) = ( shift );
#	my ( $self ) = ( $d::eveloper{ "notes_".$Prima::CodeManager::developer{notes}->pageIndex } );
	return unless find_dialog(0);
	$self-> do_find;
}
################################################################################
sub about
{
	my ( $self ) = @_;
	my $project_color = 0x0088ff;
	my @dim = ( 360, 170 );
#	my $img = $self-> load_icon( "$::Prima::CodeManager::CodeManager_directory/img/CodeManager64.png" );
	my $tmp_popup = Prima::Dialog-> create(
		icon => $self-> load_icon( "$Prima::CodeManager::CodeManager_directory/img/cm64.png" ),
		title		=> "CodeManager - About",
		text		=> "CodeManager - About",
		size		=>	[ @dim ],
		origin		=>	[ 0, 0 ],
		borderIcons	=>  bi::SystemMenu,
		centered	=>	1,
#		borderStyle	=> bs::None,
		backColor	=> $self->licz_kolor( 0xffffff, $project_color, 0.5, 0 ),
		onPaint => sub {
			my ( $this, $canvas) = @_;
			$canvas-> clear;
			$canvas-> color( $self->licz_kolor( 0xffffff, $project_color, 0.2, 0 ) );
			$canvas-> bar( 0, 0, $this-> width, $this-> height);
			my $margin = 2;
			my $width  = 1;
			$canvas-> color( $self->licz_kolor( 0xffffff, $project_color, 0.8, 0 ) );
			$canvas-> fillpoly([
				$margin,						$margin,
				$margin,						$this-> height - $margin - 1,



( run in 1.801 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )