Commits

Herbert Breunung committed 97d4e64

simple keymap view dialog works now

Comments (0)

Files changed (5)

lib/Kephra/App/Dialog/Keymap.pm

 use warnings;
 
 use Wx;
+use Kephra::CommandList;
 
 package Kephra::App::Dialog::Keymap;
 my $cache;
 	return $cache if defined $cache;
 	my $dialog = $cache = Wx::Dialog->new(
 		Kephra::App::Dialog::_parent(shift), -1,
-		$Kephra::NAME . ' '.$Kephra::VERSION .' Keymap Settings'
+		$Kephra::NAME . ' '.$Kephra::VERSION .' Keymap Settings', [-1,-1], [800,600]
 	);
-	#Wx::BoxSizer->new( &Wx::wxVERTICAL );
-	#Kephra::CommandList
+	my $list = Wx::ListCtrl->new(
+		$dialog, -1,  &Wx::wxDefaultPosition, &Wx::wxDefaultSize, &Wx::wxLC_REPORT 
+	);
+	my $col;
+	my $data = Kephra::CommandList::_raw();
+	$list->InsertColumn($col++, $_) for qw(Command Keys Help);
+	$list->SetColumnWidth(0, 220);
+	$list->SetColumnWidth(1, 100);
+	$list->SetColumnWidth(2, 480);
+	my $row;
+	for (sort keys %$data){
+		my $iid = $list->InsertImageStringItem( $row++, $_, 0 ); # imd 3rd index
+		$list->SetItem( $iid, 1, $data->{$_}{keys}, 0) if $data->{$_}{keys};
+		$list->SetItem( $iid, 2, $data->{$_}{help}, 0) if $data->{$_}{help};
+	}
+
+	my @button_label = qw(Accept Cancel); # from left to right
+	my %button;
+	$button{lc $_} = Wx::Button->new( $dialog, -1, $_ ) for @button_label;
+	my $keysizer = Wx::BoxSizer->new( &Wx::wxHORIZONTAL );
+	$keysizer->AddStretchSpacer();
+	$keysizer->Add($button{lc($_)}, 0, &Wx::wxGROW | &Wx::wxALL, 10) for @button_label;
+	my $sizer = Wx::BoxSizer->new( &Wx::wxVERTICAL );
+	$sizer->Add($list, 1, Wx::wxGROW, 0);
+	$sizer->Add($keysizer, 0, &Wx::wxGROW, 0);
+	$dialog->SetSizer($sizer);
+
+	Wx::Event::EVT_BUTTON($dialog, $button{'accept'}, sub {
+		$dialog->EndModal(0);
+	});
+	Wx::Event::EVT_BUTTON($dialog, $button{'cancel'}, sub {
+		$dialog->EndModal(0);
+	});
+
 	$dialog;
 }
 

lib/Kephra/CommandList.pm

 my %namespace;
 my %switch   = ( 'name' => {}, 'package' => {} );
 
+sub _raw { \%list }
+
 
 # register means: to be called before init-on compile/module block execution time
 sub register_switch_var {

lib/Kephra/Edit/Comment.pm

 package Kephra::App::Editor;
 
 Kephra::CommandList::register_cmd({
- '-comment-toggle'=>{sub=>'$ed->toggle_comment', label=>'Toggle Comment', keys=>'alt+#' },
+ '+-comment-toggle'=>{sub=>'$ed->toggle_comment', label=>'Toggle Comment', keys=>'alt+#' },
 });
 
 my $delimiter = '#';

lib/Kephra/Edit/Format.pm

 package Kephra::App::Editor;
 
 Kephra::CommandList::register_cmd({
- '-goto-block-up'    =>{sub=>'$ed->ParaUp',                    label=>'Block Up',    keys=>'ctrl+up' },
- '-goto-block-down'  =>{sub=>'$ed->ParaDown',                  label=>'Block Down',  keys=>'ctrl+down' },
- '-select-block-up'  =>{sub=>'$ed->ParaUpExtend',              label=>'Block Up',    keys=>'ctrl+shift+up' },
- '-select-block-down'=>{sub=>'$ed->ParaDownExtend',            label=>'Block Down',  keys=>'ctrl+shift+down' },
- '-indent-level'     =>{sub=>'$ed->indent_level',              label=>'Indent Level',keys=>'alt+right' },
- '-dedent-level'     =>{sub=>'$ed->dedent_level',              label=>'Dedent Level',keys=>'alt+left' },
- '-move-line-up'     =>{sub=>'$ed->move_sel_or_line_up',       label=>'Line Up',     keys=>'alt+up' },
- '-move-line-down'   =>{sub=>'$ed->move_sel_or_line_down',     label=>'Line Down',   keys=>'alt+down' },
- '-move-page-up'     =>{sub=>'$ed->move_sel_or_line_page_up',  label=>'Page Up',     keys=>'' },
- '-move-page-down'   =>{sub=>'$ed->move_sel_or_line_page_down',label=>'Page Down',   keys=>'' },
- '-move-begin'       =>{sub=>'$ed->move_sel_or_line_begin',    label=>'Doc Begin',   keys=>'alt+home' },
- '-move-end'         =>{sub=>'$ed->move_sel_or_line_end',      label=>'Doc End',     keys=>'alt+end' },
- '-move-word-left'   =>{sub=>'$ed->move_sel_or_word_left',     label=>'Word Left',   keys=>'alt+shift+left' },
- '-move-word-right'  =>{sub=>'$ed->move_sel_or_word_right',    label=>'Word Right',  keys=>'alt+shift+right' },
+ '+-goto-block-up'    =>{sub=>'$ed->ParaUp',                    label=>'Block Up',    keys=>'ctrl+up' },
+ '+-goto-block-down'  =>{sub=>'$ed->ParaDown',                  label=>'Block Down',  keys=>'ctrl+down' },
+ '+-select-block-up'  =>{sub=>'$ed->ParaUpExtend',              label=>'Block Up',    keys=>'ctrl+shift+up' },
+ '+-select-block-down'=>{sub=>'$ed->ParaDownExtend',            label=>'Block Down',  keys=>'ctrl+shift+down' },
+ '+-indent-level'     =>{sub=>'$ed->indent_level',              label=>'Indent Level',keys=>'alt+right' },
+ '+-dedent-level'     =>{sub=>'$ed->dedent_level',              label=>'Dedent Level',keys=>'alt+left' },
+ '+-move-line-up'     =>{sub=>'$ed->move_sel_or_line_up',       label=>'Line Up',     keys=>'alt+up' },
+ '+-move-line-down'   =>{sub=>'$ed->move_sel_or_line_down',     label=>'Line Down',   keys=>'alt+down' },
+ '+-move-page-up'     =>{sub=>'$ed->move_sel_or_line_page_up',  label=>'Page Up',     keys=>'' },
+ '+-move-page-down'   =>{sub=>'$ed->move_sel_or_line_page_down',label=>'Page Down',   keys=>'' },
+ '+-move-begin'       =>{sub=>'$ed->move_sel_or_line_begin',    label=>'Doc Begin',   keys=>'alt+home' },
+ '+-move-end'         =>{sub=>'$ed->move_sel_or_line_end',      label=>'Doc End',     keys=>'alt+end' },
+ '+-move-word-left'   =>{sub=>'$ed->move_sel_or_word_left',     label=>'Word Left',   keys=>'alt+shift+left' },
+ '+-move-word-right'  =>{sub=>'$ed->move_sel_or_word_right',    label=>'Word Right',  keys=>'alt+shift+right' },
 });
 
 

lib/Kephra/Edit/Search.pm

 package Kephra::App::Editor;
 
 Kephra::CommandList::register_cmd({
- '-goto-char-left'   =>{sub=>'$ed->CharLeft',          label=>'Char Left',    keys=>'left' },
- '-goto-char-right'  =>{sub=>'$ed->CharRight',         label=>'Char Right',   keys=>'right' },
- '-select-char-left' =>{sub=>'$ed->CharLeftExtend',    label=>'Select Left',  keys=>'shift+left' },
- '-select-char-right'=>{sub=>'$ed->CharRightExtend',   label=>'Select Right', keys=>'shift+right' },
- '-goto-word-left'   =>{sub=>'$ed->WordLeft',          label=>'Word Left',    keys=>'ctrl+left' },
- '-goto-word-right'  =>{sub=>'$ed->WordRight',         label=>'Word Right',   keys=>'ctrl+right' },
- '-select-word-left' =>{sub=>'$ed->WordLeftExtend',    label=>'Word Left',    keys=>'ctrl+shift+left' },
- '-select-word-right'=>{sub=>'$ed->WordRightExtend',   label=>'Word Right',   keys=>'ctrl+shift+right' },
- '-goto-line-start'  =>{sub=>'$ed->Home',              label=>'Line Start',   keys=>'home'},
- '-goto-line-end'    =>{sub=>'$ed->LineEnd',           label=>'Line End',     keys=>'end' },
- '-select-line-start'=>{sub=>'$ed->HomeExtend',        label=>'Line Start',   keys=>'shift+home'},
- '-select-line-end'  =>{sub=>'$ed->LineEndExtend',     label=>'Line End',     keys=>'shift+end' },
- #'-goto-line-up'     =>{sub=>'$ed->LineUp',            label=>'Line Up',     keys =>'up' },
- #'-goto-line-down'   =>{sub=>'$ed->LineDown',          label=>'Line Down',   keys =>'down' },
- '-select-line-up'   =>{sub=>'$ed->LineUpExtend',      label=>'Line Up',      keys=>'shift+up' },
- '-select-line-down' =>{sub=>'$ed->LineDownExtend',    label=>'Line Down',    keys=>'shift+down' },
- '-goto-page-up'     =>{sub=>'$ed->PageUp',            label=>'Page Up',      keys=>'pageup' },
- '-goto-page-down'   =>{sub=>'$ed->PageDown',          label=>'Page Down',    keys=>'pagedown' },
- '-select-page-up'   =>{sub=>'$ed->PageUpExtend',      label=>'Page Up',      keys=>'shift+pageup' },
- '-select-page-down' =>{sub=>'$ed->PageDownExtend',    label=>'Page Down',    keys=>'shift+pagedown'},
- '-goto-doc-start'   =>{sub=>'$ed->DocumentStart',     label=>'Doc Start',    keys=>'ctrl+home'},
- '-goto-doc-end'     =>{sub=>'$ed->DocumentEnd',       label=>'Doc End',      keys=>'ctrl+end' },
- '-select-doc-start' =>{sub=>'$ed->DocumentStartExtend',label=>'Doc Start',   keys=>'ctrl+shift+home'},
- '-select-doc-end'   =>{sub=>'$ed->DocumentEndExtend', label=>'Doc End',      keys=>'ctrl+shift+end' },
- '-goto-last-change' =>{sub=>'$ed->goto_last_change',  label=>'Last Change',  keys=>'ctrl+shift+g'},
- '-find-next-comment'=>{sub=>'$ed->next_comment',      label=>'Next Comment', keys=>'ctrl+#' },
- '-find-prev-comment'=>{sub=>'$ed->prev_comment',      label=>'Prev Comment', keys=>'ctrl+shift+#' },
+ '+-goto-char-left'   =>{sub=>'$ed->CharLeft',          label=>'Char Left',    keys=>'left' },
+ '+-goto-char-right'  =>{sub=>'$ed->CharRight',         label=>'Char Right',   keys=>'right' },
+ '+-select-char-left' =>{sub=>'$ed->CharLeftExtend',    label=>'Select Left',  keys=>'shift+left' },
+ '+-select-char-right'=>{sub=>'$ed->CharRightExtend',   label=>'Select Right', keys=>'shift+right' },
+ '+-goto-word-left'   =>{sub=>'$ed->WordLeft',          label=>'Word Left',    keys=>'ctrl+left' },
+ '+-goto-word-right'  =>{sub=>'$ed->WordRight',         label=>'Word Right',   keys=>'ctrl+right' },
+ '+-select-word-left' =>{sub=>'$ed->WordLeftExtend',    label=>'Word Left',    keys=>'ctrl+shift+left' },
+ '+-select-word-right'=>{sub=>'$ed->WordRightExtend',   label=>'Word Right',   keys=>'ctrl+shift+right' },
+ '+-goto-line-start'  =>{sub=>'$ed->Home',              label=>'Line Start',   keys=>'home'},
+ '+-goto-line-end'    =>{sub=>'$ed->LineEnd',           label=>'Line End',     keys=>'end' },
+ '+-select-line-start'=>{sub=>'$ed->HomeExtend',        label=>'Line Start',   keys=>'shift+home'},
+ '+-select-line-end'  =>{sub=>'$ed->LineEndExtend',     label=>'Line End',     keys=>'shift+end' },
+ #'+-goto-line-up'     =>{sub=>'$ed->LineUp',            label=>'Line Up',     keys =>'up' },
+ #'+-goto-line-down'   =>{sub=>'$ed->LineDown',          label=>'Line Down',   keys =>'down' },
+ '+-select-line-up'   =>{sub=>'$ed->LineUpExtend',      label=>'Line Up',      keys=>'shift+up' },
+ '+-select-line-down' =>{sub=>'$ed->LineDownExtend',    label=>'Line Down',    keys=>'shift+down' },
+ '+-goto-page-up'     =>{sub=>'$ed->PageUp',            label=>'Page Up',      keys=>'pageup' },
+ '+-goto-page-down'   =>{sub=>'$ed->PageDown',          label=>'Page Down',    keys=>'pagedown' },
+ '+-select-page-up'   =>{sub=>'$ed->PageUpExtend',      label=>'Page Up',      keys=>'shift+pageup' },
+ '+-select-page-down' =>{sub=>'$ed->PageDownExtend',    label=>'Page Down',    keys=>'shift+pagedown'},
+ '+-goto-doc-start'   =>{sub=>'$ed->DocumentStart',     label=>'Doc Start',    keys=>'ctrl+home'},
+ '+-goto-doc-end'     =>{sub=>'$ed->DocumentEnd',       label=>'Doc End',      keys=>'ctrl+end' },
+ '+-select-doc-start' =>{sub=>'$ed->DocumentStartExtend',label=>'Doc Start',   keys=>'ctrl+shift+home'},
+ '+-select-doc-end'   =>{sub=>'$ed->DocumentEndExtend', label=>'Doc End',      keys=>'ctrl+shift+end' },
+ '+-goto-last-change' =>{sub=>'$ed->goto_last_change',  label=>'Last Change',  keys=>'ctrl+shift+g'},
+ '+-find-next-comment'=>{sub=>'$ed->next_comment',      label=>'Next Comment', keys=>'ctrl+#' },
+ '+-find-prev-comment'=>{sub=>'$ed->prev_comment',      label=>'Prev Comment', keys=>'ctrl+shift+#' },
 });