ide/frames/editor_keymapping_options.lfm | 34 +++++++++++++++++-------- ide/frames/editor_keymapping_options.pas | 43 ++++++++++++++++++++++++++++++++ ide/lazarus.lpi | 1 - ide/lazarusidestrconsts.pas | 1 + lcl/interfaces/win32/win32wsdialogs.pp | 2 -- 5 files changed, 67 insertions(+), 14 deletions(-) diff --git a/ide/frames/editor_keymapping_options.lfm b/ide/frames/editor_keymapping_options.lfm index 42ff94356c..fe3c4e643f 100644 --- a/ide/frames/editor_keymapping_options.lfm +++ b/ide/frames/editor_keymapping_options.lfm @@ -200,12 +198,26 @@ object EditorKeymappingOptionsFrame: TEditorKeymappingOptionsFrame Left = 288 Height = 25 Top = 0 Width = 96 AutoSize = True BorderSpacing.Left = 20 Caption = 'ExportButton' TabOrder = 3 OnClick = ExportButtonClick + end + object ExportCsvButton: TButton + AnchorSideLeft.Control = ExportButton + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = ExportButton + AnchorSideTop.Side = asrCenter + Left = 393 + Height = 25 + Top = 0 + Width = 75 + BorderSpacing.Left = 10 + Caption = 'ExportTxtButton' + OnClick = ExportCsvButtonClick + TabOrder = 4 end end end diff --git a/ide/frames/editor_keymapping_options.pas b/ide/frames/editor_keymapping_options.pas index 9a2ca9517d..3ed617f5ed 100644 --- a/ide/frames/editor_keymapping_options.pas +++ b/ide/frames/editor_keymapping_options.pas @@ -46,6 +46,7 @@ type TEditorKeymappingOptionsFrame = class(TAbstractIDEOptionsEditor) BtnPanel: TPanel; + ExportCsvButton: TButton; ExportButton: TButton; ChooseSchemeButton: TBitBtn; ClearButton: TBitBtn; @@ -63,6 +64,7 @@ type EditMenuItem: TMenuItem; ClearMenuItem: TMenuItem; PopupMenu1: TPopupMenu; + procedure ExportCsvButtonClick(Sender: TObject); procedure ClearMenuItemClick(Sender: TObject); procedure ConflictsTreeViewMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); @@ -394,6 +396,46 @@ begin ClearConflict(ConflictsTreeView.Selected); end; +procedure TEditorKeymappingOptionsFrame.ExportCsvButtonClick(Sender: TObject); +var + dlg : TSaveDialog; + stl: TStringList; + exp : TKeyCommandRelationList; + i : integer; + str: String; +begin + stl := nil; + dlg := TSaveDialog.Create(Self); + exp := TKeyCommandRelationList.Create; + try + dlg.InitialDir := UserKeySchemeDirectory(True); + dlg.DefaultExt:='csv'; + dlg.Filter := dlgFilterCSV + '|*.csv|' + dlgFilterAll +'|'+GetAllFilesMask; + dlg.FilterIndex := 0; + if not dlg.Execute then Exit; + stl:= TStringList.Create(true); + exp.Assign(FEditingKeyMap); + for i:=0 to exp.RelationCount-1 do begin + str:= exp.Relations[i].Name + ',' + exp.Relations[i].GetCategoryAndName + + ',' + HumanKeyToStr(exp.Relations[i].ShortcutA.Key1) + + ',' + HumanShiftStateToStr(exp.Relations[i].ShortcutA.Shift1) + + ',' + HumanKeyToStr(exp.Relations[i].ShortcutA.Key2) + + ',' + HumanShiftStateToStr(exp.Relations[i].ShortcutA.Shift2) + + ',' + HumanKeyToStr(exp.Relations[i].ShortcutB.Key1) + + ',' + HumanShiftStateToStr(exp.Relations[i].ShortcutB.Shift1) + + ',' + HumanKeyToStr(exp.Relations[i].ShortcutB.Key2) + + ',' + HumanShiftStateToStr(exp.Relations[i].ShortcutB.Shift2) + ; + stl.Append(str); + end; + stl.SaveToFile(dlg.FileName); + finally + exp.Free; + dlg.Free; + stl.Free; + end; +end; + procedure TEditorKeymappingOptionsFrame.ConflictsTreeViewMouseDown( Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); var @@ -426,6 +468,7 @@ begin EditMenuItem.Caption := lisEdit; ClearMenuItem.Caption := lisClear; ExportButton.Caption := lisExport; + ExportCsvButton.Caption := lisExport+' csv'; TreeView.Images := IDEImages.Images_16; ConflictsTreeView.Images := IDEImages.Images_16; diff --git a/ide/lazarusidestrconsts.pas b/ide/lazarusidestrconsts.pas index 4254c4e53c..80e702c5df 100644 --- a/ide/lazarusidestrconsts.pas +++ b/ide/lazarusidestrconsts.pas @@ -1513,6 +1513,7 @@ resourcestring dlgFilterAll = 'All files'; dlgFilterXML = 'XML files'; dlgFilterHTML = 'HTML files'; + dlgFilterCSV = 'CSV files'; dlgFilterPrograms = 'Programs'; dlgFilterExecutable = 'Executable'; dlgFilterLazarusFile = 'Lazarus file';