Commits

Herbert Breunung committed 5be7e60

make menu entry shortcuts that rely on menu ID

  • Participants
  • Parent commits f628d73

Comments (0)

Files changed (4)

File lib/Kephra/App/Menu.pm

 	my $menu_def = shift;
 	die "__PACKAGE__::assemble got no array ref" unless ref $menu_def eq ref [];
 	my $cmd_list = Kephra::CommandList::_raw();
+	my $menu_ID = '';
 	my @menu_data;
 
-	for my $menu_def (@$menu_def) {
-		if    (ref $menu_def eq ref []) { push  @menu_data, assemble($menu_def) }
-		elsif (ref $menu_def eq ref {}) { push  @menu_data,          $menu_def  }
-		elsif (not defined $menu_def or not $menu_def) {
+	for my $item_def (@$menu_def) {
+		if    (ref $item_def eq ref []) { push  @menu_data, assemble($item_def) }
+		elsif (ref $item_def eq ref {}) {
+			$menu_ID = $item_def->{'menu_ID'}
+				if defined $item_def->{'menu_ID'} and not $menu_ID;
+			push  @menu_data, $item_def;
+		}
+		elsif (not defined $item_def or not $item_def) {
 			push  @menu_data, 'separator';
 		} else  {
-			next unless exists $cmd_list->{$menu_def};
+			$item_def = $menu_ID.$item_def if substr($item_def, 0, 1) eq '-';
+			next unless exists $cmd_list->{$item_def};
 			push @menu_data, {
 				'type' => 'item',
-				'label'=> ucfirst $cmd_list->{$menu_def}{'name'},
-				'callref' => $cmd_list->{$menu_def}{'callref'},
+				'label'=> ucfirst $cmd_list->{$item_def}{'name'},
+				'callref' => $cmd_list->{$item_def}{'callref'},
 			};
 		}
 	}

File lib/Kephra/App/Panel/Editor.pm

 		$doc->assign_file($file);
 		$main_doc_bar->SetPageText( $main_doc_bar->GetSelection , $doc->file_name );
 	} else {                                         # make new editor
-		$doc = Kephra::Document->new({ file => $file });
+		$doc = Kephra::Document->new();
 		$doc->assign_file( $file );
 		$doc->editor( Kephra::App::Editor->new( $win ) );
 		Kephra::DocumentStash::add( $doc );

File lib/Kephra/Config/Default/MainMenu.pm

 sub get {
 	return [
 		[	{menu_ID => 'file'},
-			'file_new',
-			'file_open',
-			'file_save',
-			'file_close',
+			'-new',
+			'-open',
+			'-save',
+			'-close',
 			'',
-			'app_close_save',
+			'app-close-save',
 		],
 		[	{menu_ID => 'config'},
-			'config_dialog',
+			'-dialog',
 		],
 		[	{menu_ID => 'help'},
-			'help_documentation',
-			'help_homepage',
-			'help_bugreport',
+			'-documentation',
+			'-homepage',
+			'-bugreport',
 			'',
-			'help_about',
+			'-about',
 		],
 	];
 }

File lib/Kephra/Document.pm

 has folded_lines => ( is  => 'rw', );
 has marked_lines => ( is  => 'rw', );
 
-around BUILDARGS => sub {
-   my $orig = shift;
-   my ( $class, @args ) = @_;
-   #print $args[0]{'file'}, " $orig\n";
-   #$class->assign_file( $args[0]{'file'} ) if defined $args[0]{'file'};
-   return $class->$orig( @args );
- };
+#after BUILDARGS => sub {
+   #my ( $self, @args ) = @_;
+   #print scalar @args, " $self\n";
+   #print $args[1], " $self\n" if $args[1];
+   #$self->assign_file( $args[1] ) if $args[1];
+   #return $class->$orig( @args );
+ #};
 
  
 sub assign_file {