Source

Kephra / lib / Kephra / Document.pm

Full commit
package Kephra::Document;
use Moo;
use Kephra::File;
use File::Spec;


has editor => (
	is  => 'rw',
	isa => sub {Kephra::Log::warning("$_[0] is no editor")
				unless ref $_[0] eq 'Kephra::App::Editor'},
);
has panel => (
	is  => 'rw',
	isa => sub {Kephra::Log::error("$_[0] is no panel")
				unless ref $_[0] eq 'Wx::Panel' or ref $_[0] eq 'Kephra::App::Panel'
				},
);
has file_path    => ( is  => 'rw', );
has file_dir     => ( is  => 'rw', );
has file_name    => ( is  => 'rw', );
#has content      => ( is  => 'rw' );
has notes        => ( is  => 'rw', );

has syntax_mode  => ( is  => 'rw', default => sub { 'perl' } );
has readonly     => ( is  => 'rw', );
has active_config=> ( is  => 'rw', );
has caret_pos    => ( is  => 'rw', );
has edit_pos     => ( is  => 'rw', );
has coding       => ( is  => 'rw', );
has EOL          => ( is  => 'rw', );
has tab_size     => ( is  => 'rw', );
has tab_use      => ( is  => 'rw', );
has folded_lines => ( is  => 'rw', );
has marked_lines => ( is  => 'rw', );

sub assign_file_name {
	my ($self, $file_path) = @_;
	return unless defined $file_path and -e $file_path;
	if ($file_path){
		$file_path = Kephra::File::normalize_name($file_path);
		$self->file_path($file_path);
		my @path_parts = File::Spec->splitpath( $_[0]->file_path );
		$self->file_dir( $path_parts[1] );
		$self->file_name( $path_parts[2] );
	} else {
		$self->file_path('');
		$self->file_dir('');
		$self->file_name('');
	}
	$self;
}
sub insert_before_caret {}
sub insert_after_caret {}
sub find {}

1;