From d92965ff87b1a160053e9a287ca8df00c00a8e9b Mon Sep 17 00:00:00 2001 From: mattias Date: Thu, 30 Oct 2003 18:25:18 +0000 Subject: [PATCH] fixed keymapping for irregular keys git-svn-id: trunk@4738 - --- COPYING | 8 ++-- designer/controlselection.pp | 2 +- ide/editoroptions.pp | 6 +-- ide/exttooleditdlg.pas | 10 ++--- ide/keymapping.pp | 87 +++++++++++++++++++++--------------- lcl/lcltype.pp | 9 ++-- 6 files changed, 69 insertions(+), 53 deletions(-) diff --git a/COPYING b/COPYING index 3d0c09aa97..cf1ed37270 100644 --- a/COPYING +++ b/COPYING @@ -13,11 +13,13 @@ The license directory tree: | +- debugger (GPL2) | + +- packager (GPL2) + | +- tools (GPL2) | +- examples (GPL2) | - +- lcl (modified LGPL) + +- lcl (modified LGPL, see there) | +- components/ | @@ -30,8 +32,8 @@ The license directory tree: +- gtkglarea (modified LGPL, with one exception: nvgl.pp) -The IDE files are the files in the , designer and debugger directory. -They are under the GPL 2, with the following exceptions: +The IDE files are the files in the , designer, packager and debugger +directory. They are under the GPL 2, with the following exceptions: objectinspector.pp, propedits.pp, transfermacros.pp, wordcompletion.pp, patheditordlg.pas, outputfilter.pas, inputfiledialog.pas, findreplacedialog.pp, findinfilesdlg.pas diff --git a/designer/controlselection.pp b/designer/controlselection.pp index 71b6735f6b..01963d24bc 100644 --- a/designer/controlselection.pp +++ b/designer/controlselection.pp @@ -1972,7 +1972,7 @@ var end; RestoreBrush:=true; end; - DC.Canvas.FillRect(Rect(RLeft,RTop,RRIght,RBottom)); + DC.Canvas.FillRect(Rect(RLeft,RTop,RRight,RBottom)); end; begin diff --git a/ide/editoroptions.pp b/ide/editoroptions.pp index b849e3587c..6e1093b43d 100644 --- a/ide/editoroptions.pp +++ b/ide/editoroptions.pp @@ -2961,10 +2961,10 @@ begin if (Key1=VK_UNKNOWN) and (Key2=VK_UNKNOWN) then Result:=Result+'none' else if (Key2=VK_UNKNOWN) then - Result:=Result+KeyAndShiftStateToStr(Key1,Shift1) + Result:=Result+KeyAndShiftStateToEditorKeyString(Key1,Shift1) else - Result:=Result+KeyAndShiftStateToStr(Key1,Shift1)+' or '+ - KeyAndShiftStateToStr(Key2,Shift2); + Result:=Result+KeyAndShiftStateToEditorKeyString(Key1,Shift1)+' or '+ + KeyAndShiftStateToEditorKeyString(Key2,Shift2); end; end; diff --git a/ide/exttooleditdlg.pas b/ide/exttooleditdlg.pas index 8c910aa637..bc5eae529c 100644 --- a/ide/exttooleditdlg.pas +++ b/ide/exttooleditdlg.pas @@ -457,8 +457,8 @@ begin Items.BeginUpdate; Items.Add('none'); for i:=1 to 145 do begin - s:=KeyAndShiftStateToStr(i,[]); - if lowercase(copy(s,1,5))<>'word(' then + s:=KeyAndShiftStateToEditorKeyString(i,[]); + if not EditorKeyStringIsIrregular(s) then Items.Add(s); end; Items.EndUpdate; @@ -552,7 +552,7 @@ begin fOptions.Filename:=FilenameEdit.Text; fOptions.CmdLineParams:=ParametersEdit.Text; fOptions.WorkingDirectory:=WorkingDirEdit.Text; - fOptions.Key:=StrToVKCode(KeyComboBox.Text); + fOptions.Key:=EditorKeyStringToVKCode(KeyComboBox.Text); fOptions.Shift:=[]; if fOptions.Key<>VK_UNKNOWN then begin if KeyCtrlCheckBox.Checked then include(fOptions.fShift,ssCtrl); @@ -571,7 +571,7 @@ begin FilenameEdit.Text:=fOptions.Filename; ParametersEdit.Text:=fOptions.CmdLineParams; WorkingDirEdit.Text:=fOptions.WorkingDirectory; - SetComboBox(KeyComboBox,KeyAndShiftStateToStr(fOptions.Key,[])); + SetComboBox(KeyComboBox,KeyAndShiftStateToEditorKeyString(fOptions.Key,[])); KeyCtrlCheckBox.Checked:=(ssCtrl in fOptions.Shift); KeyShiftCheckBox.Checked:=(ssShift in fOptions.Shift); KeyAltCheckBox.Checked:=(ssAlt in fOptions.Shift); @@ -826,7 +826,7 @@ begin KeyCtrlCheckBox.Checked:=(ssCtrl in Shift); KeyShiftCheckBox.Checked:=(ssShift in Shift); KeyAltCheckBox.Checked:=(ssAlt in Shift); - SetComboBox(KeyComboBox,KeyAndShiftStateToStr(Key,[])); + SetComboBox(KeyComboBox,KeyAndShiftStateToEditorKeyString(Key,[])); end; DeactivateGrabbing; end; diff --git a/ide/keymapping.pp b/ide/keymapping.pp index e041a9dd4c..83171190cc 100644 --- a/ide/keymapping.pp +++ b/ide/keymapping.pp @@ -353,7 +353,8 @@ type KeyIndex:integer; end; -function KeyAndShiftStateToStr(Key:Word; ShiftState:TShiftState):AnsiString; +function KeyAndShiftStateToEditorKeyString(Key:Word; + ShiftState:TShiftState):AnsiString; function ShowKeyMappingEditForm(Index:integer; AKeyCommandRelationList:TKeyCommandRelationList):TModalResult; function KeyStrokesConsistencyErrors(ASynEditKeyStrokes:TSynEditKeyStrokes; @@ -361,7 +362,7 @@ function KeyStrokesConsistencyErrors(ASynEditKeyStrokes:TSynEditKeyStrokes; function EditorCommandToDescriptionString(cmd: word):AnsiString; function EditorCommandLocalizedName(cmd: word; const DefaultName: string): string; -function StrToVKCode(const s: string): integer; +function EditorKeyStringToVKCode(const s: string): integer; procedure GetDefaultKeyForCommand(Command: word; var Key1: word; var Shift1: TShiftState; @@ -374,19 +375,20 @@ function KeySchemeNameToSchemeType(const SchemeName: string): TKeyMapScheme; function ShiftStateToStr(Shift:TShiftState):AnsiString; function KeyValuesToStr(Key1: word; Shift1: TShiftState; Key2: word; Shift2: TShiftState): string; +function EditorKeyStringIsIrregular(const s: string): boolean; var KeyMappingEditForm: TKeyMappingEditForm; const KeyCategoryToolMenuName = 'ToolMenu'; + UnknownVKPrefix = 'Word('''; + UnknownVKPostfix = ''')'; implementation const KeyMappingFormatVersion = 2; - UnknownVKPrefix = 'Word('''; - UnknownVKPostfix = ''')'; VirtualKeyStrings: TStringHashList = nil; @@ -398,21 +400,22 @@ begin Result:=DefaultName; end; -function StrToVKCode(const s: string): integer; +function EditorKeyStringToVKCode(const s: string): integer; var i: integer; Data: Pointer; begin Result:=VK_UNKNOWN; - if (length(UnknownVKPrefix)'none' then begin + if EditorKeyStringIsIrregular(s) then begin + Result:=StrToIntDef(copy(s,7,length(s)-8),VK_UNKNOWN); + exit; + end; + if (s<>'none') and (s<>'') then begin if VirtualKeyStrings=nil then begin VirtualKeyStrings:=TStringHashList.Create(true); for i:=1 to 300 do - VirtualKeyStrings.Add(KeyAndShiftStateToStr(i,[]),Pointer(i)); + VirtualKeyStrings.Add(KeyAndShiftStateToEditorKeyString(i,[]), + Pointer(i)); end; end else exit; @@ -919,6 +922,16 @@ begin +','+IntToStr(Key2)+','+ShiftStateToStr(Shift2); end; +function EditorKeyStringIsIrregular(const s: string): boolean; +begin + if (length(UnknownVKPrefix)=0 then AComboBox.ItemIndex:=i - else if lowercase(copy(s,1,5))='word(' then begin + else if EditorKeyStringIsIrregular(s) then begin AComboBox.Items.Add(s); AComboBox.ItemIndex:=AComboBox.Items.IndexOf(s); end else @@ -1245,11 +1258,11 @@ begin Protocol.Add(srkmConflic+IntToStr(Result)); Protocol.Add(srkmCommand1 +EditorCommandToDescriptionString(Key1.Command)+'"' - +'->'+KeyAndShiftStateToStr(Key1.Key,Key1.Shift)); + +'->'+KeyAndShiftStateToEditorKeyString(Key1.Key,Key1.Shift)); Protocol.Add(srkmConflicW); Protocol.Add(srkmCommand2 +EditorCommandToDescriptionString(Key2.Command)+'"' - +'->'+KeyAndShiftStateToStr(Key2.Key,Key2.Shift) + +'->'+KeyAndShiftStateToEditorKeyString(Key2.Key,Key2.Shift) ); Protocol.Add(''); end; @@ -1258,7 +1271,7 @@ begin end; end; -function KeyAndShiftStateToStr(Key:Word; ShiftState:TShiftState):AnsiString; +function KeyAndShiftStateToEditorKeyString(Key:Word; ShiftState:TShiftState):AnsiString; var p, ResultLen: integer; @@ -1480,8 +1493,8 @@ begin Items.BeginUpdate; Items.Add('none'); for a:=1 to 145 do begin - s:=KeyAndShiftStateToStr(a,[]); - if lowercase(copy(s,1,5))<>'word(' then + s:=KeyAndShiftStateToEditorKeyString(a,[]); + if not EditorKeyStringIsIrregular(s) then Items.Add(s); end; Items.EndUpdate; @@ -1554,8 +1567,8 @@ begin Items.BeginUpdate; Items.Add('none'); for a:=1 to 145 do begin - s:=KeyAndShiftStateToStr(a,[]); - if lowercase(copy(s,1,5))<>'word(' then + s:=KeyAndShiftStateToEditorKeyString(a,[]); + if not EditorKeyStringIsIrregular(s) then Items.Add(s); end; Items.EndUpdate; @@ -1588,7 +1601,7 @@ begin NewShiftState1:=[]; NewKey2:=VK_UNKNOWN; NewShiftState2:=[]; - NewKey1:=StrToVKCode(Key1KeyComboBox.Text); + NewKey1:=EditorKeyStringToVKCode(Key1KeyComboBox.Text); if NewKey1<>VK_UNKNOWN then begin if Key1CtrlCheckBox.Checked then include(NewShiftState1,ssCtrl); @@ -1602,12 +1615,13 @@ begin if (DummyRelation<>nil) and (DummyRelation<>KeyCommandRelationList.Relations[KeyIndex]) then begin - AText:=Format(srkmAlreadyConnected,[KeyAndShiftStateToStr(NewKey1,NewShiftState1),DummyRelation.Name]); + AText:=Format(srkmAlreadyConnected, + [KeyAndShiftStateToEditorKeyString(NewKey1,NewShiftState1),DummyRelation.Name]); MessageDlg(AText,mtError,[mbok],0); exit; end; - NewKey2:=StrToVKCode(Key2KeyComboBox.Text); + NewKey2:=EditorKeyStringToVKCode(Key2KeyComboBox.Text); if (NewKey1=NewKey2) and (NewShiftState1=NewShiftState2) then NewKey2:=VK_UNKNOWN; if NewKey2<>VK_UNKNOWN then @@ -1616,11 +1630,14 @@ begin if Key2AltCheckBox.Checked then include(NewShiftState2,ssAlt); if Key2ShiftCheckBox.Checked then include(NewShiftState2,ssShift); end; - DummyRelation:=KeyCommandRelationList.Find(NewKey2,NewShiftState2,CurRelation.Parent.Areas); + DummyRelation:=KeyCommandRelationList.Find(NewKey2,NewShiftState2, + CurRelation.Parent.Areas); - if (DummyRelation<>nil) and (DummyRelation<>KeyCommandRelationList.Relations[KeyIndex]) then + if (DummyRelation<>nil) + and (DummyRelation<>KeyCommandRelationList.Relations[KeyIndex]) then begin - AText:=Format(srkmAlreadyConnected,[KeyAndShiftStateToStr(NewKey2,NewShiftState2),DummyRelation.Name]); + AText:=Format(srkmAlreadyConnected, + [KeyAndShiftStateToEditorKeyString(NewKey2,NewShiftState2),DummyRelation.Name]); MessageDlg(AText,mterror,[mbok],0); exit; end; @@ -1713,11 +1730,11 @@ begin end; procedure TKeyMappingEditForm.FormKeyUp(Sender: TObject; var Key: Word; - Shift:TShiftState); + Shift: TShiftState); begin {writeln('TKeyMappingEditForm.FormKeyUp Sender=',Classname ,' Key=',Key,' Ctrl=',ssCtrl in Shift,' Shift=',ssShift in Shift - ,' Alt=',ssAlt in Shift,' AsString=',KeyAndShiftStateToStr(Key,Shift) + ,' Alt=',ssAlt in Shift,' AsString=',KeyAndShiftStateToEditorKeyString(Key,Shift) );} if Key in [VK_CONTROL, VK_SHIFT, VK_LCONTROL, VK_RCONTROl, VK_LSHIFT, VK_RSHIFT] then exit; @@ -1728,15 +1745,15 @@ begin Key1CtrlCheckBox.Checked:=(ssCtrl in Shift); Key1ShiftCheckBox.Checked:=(ssShift in Shift); Key1AltCheckBox.Checked:=(ssAlt in Shift); - SetComboBox(Key1KeyComboBox,KeyAndShiftStateToStr(Key,[])); + SetComboBox(Key1KeyComboBox,KeyAndShiftStateToEditorKeyString(Key,[])); end else if GrabbingKey=2 then - begin - Key2CtrlCheckBox.Checked:=(ssCtrl in Shift); - Key2ShiftCheckBox.Checked:=(ssShift in Shift); - Key2AltCheckBox.Checked:=(ssAlt in Shift); - SetComboBox(Key2KeyComboBox,KeyAndShiftStateToStr(Key,[])); - end; + begin + Key2CtrlCheckBox.Checked:=(ssCtrl in Shift); + Key2ShiftCheckBox.Checked:=(ssShift in Shift); + Key2AltCheckBox.Checked:=(ssAlt in Shift); + SetComboBox(Key2KeyComboBox,KeyAndShiftStateToEditorKeyString(Key,[])); + end; Key:=0; DeactivateGrabbing; end; diff --git a/lcl/lcltype.pp b/lcl/lcltype.pp index d7b3574b55..f150de0dda 100644 --- a/lcl/lcltype.pp +++ b/lcl/lcltype.pp @@ -505,12 +505,6 @@ PM_Remove = 1; VK_PA1 = $FD; VK_OEM_CLEAR = $FE; - // all other keys with no virtual key code are mapped to - // VK_IRREGULAR + KeyCode - // MWE: Obsolete - // VK_IRREGULAR = 1000; - - //============================================== // //============================================== @@ -1881,6 +1875,9 @@ end. { $Log$ + Revision 1.47 2003/10/30 18:25:18 mattias + fixed keymapping for irregular keys + Revision 1.46 2003/10/23 19:03:13 ajgenius re-add TByteArray