mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-08 05:19:08 +02:00
MG: added keymapping to designer
git-svn-id: trunk@2762 -
This commit is contained in:
parent
51c42f4fa4
commit
136deec1d4
@ -44,6 +44,8 @@ const
|
|||||||
These values can change from version to version, so DO NOT save them to file!
|
These values can change from version to version, so DO NOT save them to file!
|
||||||
|
|
||||||
}
|
}
|
||||||
|
ecNone = SynEditKeyCmds.ecNone;
|
||||||
|
|
||||||
ecFind = ecUserFirst + 1;
|
ecFind = ecUserFirst + 1;
|
||||||
ecFindAgain = ecUserFirst + 2;
|
ecFindAgain = ecUserFirst + 2;
|
||||||
ecFindNext = ecFindAgain;
|
ecFindNext = ecFindAgain;
|
||||||
@ -155,6 +157,15 @@ const
|
|||||||
ecGotoEditor0 = ecGotoEditor9 + 1;
|
ecGotoEditor0 = ecGotoEditor9 + 1;
|
||||||
|
|
||||||
|
|
||||||
|
type
|
||||||
|
TCommandArea = (caSourceEditor, caDesigner);
|
||||||
|
TCommandAreas = set of TCommandArea;
|
||||||
|
|
||||||
|
const
|
||||||
|
caAll = [caSourceEditor, caDesigner];
|
||||||
|
caSrcEditOnly = [caSourceEditor];
|
||||||
|
caDesignOnly = [caDesigner];
|
||||||
|
|
||||||
type
|
type
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
// TKeyCommandCategory is used to divide the key commands in handy packets
|
// TKeyCommandCategory is used to divide the key commands in handy packets
|
||||||
@ -163,9 +174,11 @@ type
|
|||||||
Name: string;
|
Name: string;
|
||||||
Description: string;
|
Description: string;
|
||||||
Parent: TKeyCommandCategory;
|
Parent: TKeyCommandCategory;
|
||||||
|
Areas: TCommandAreas;
|
||||||
procedure Clear; override;
|
procedure Clear; override;
|
||||||
procedure Delete(Index: Integer);
|
procedure Delete(Index: Integer);
|
||||||
constructor Create(const AName, ADescription: string);
|
constructor Create(const AName, ADescription: string;
|
||||||
|
TheAreas: TCommandAreas);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
@ -176,14 +189,14 @@ type
|
|||||||
procedure SetParent(const AValue: TKeyCommandCategory);
|
procedure SetParent(const AValue: TKeyCommandCategory);
|
||||||
public
|
public
|
||||||
Name: ShortString;
|
Name: ShortString;
|
||||||
Command: TSynEditorCommand; // see the ecXXX constants above
|
Command: word; // see the ecXXX constants above
|
||||||
Key1: word;
|
Key1: word;
|
||||||
Shift1: TShiftState;
|
Shift1: TShiftState;
|
||||||
Key2: word;
|
Key2: word;
|
||||||
Shift2: TShiftState;
|
Shift2: TShiftState;
|
||||||
property Parent: TKeyCommandCategory read fParent write SetParent;
|
property Parent: TKeyCommandCategory read fParent write SetParent;
|
||||||
constructor Create(AParent: TKeyCommandCategory; AName:ShortString;
|
constructor Create(AParent: TKeyCommandCategory; AName:ShortString;
|
||||||
ACommand:TSynEditorCommand;
|
ACommand: word;
|
||||||
AKey1:Word; AShift1:TShiftState; AKey2:Word; AShift2:TShiftState);
|
AKey1:Word; AShift1:TShiftState; AKey2:Word; AShift2:TShiftState);
|
||||||
function AsShortCut: TShortCut;
|
function AsShortCut: TShortCut;
|
||||||
end;
|
end;
|
||||||
@ -197,9 +210,10 @@ type
|
|||||||
fExtToolCount: integer;
|
fExtToolCount: integer;
|
||||||
function GetCategory(Index: integer): TKeyCommandCategory;
|
function GetCategory(Index: integer): TKeyCommandCategory;
|
||||||
function GetRelation(Index:integer):TKeyCommandRelation;
|
function GetRelation(Index:integer):TKeyCommandRelation;
|
||||||
function AddCategory(const Name, Description: string): integer;
|
function AddCategory(const Name, Description: string;
|
||||||
|
TheAreas: TCommandAreas): integer;
|
||||||
function Add(Category: TKeyCommandCategory; const Name:shortstring;
|
function Add(Category: TKeyCommandCategory; const Name:shortstring;
|
||||||
Command:TSynEditorCommand;
|
Command:word;
|
||||||
Key1:Word; Shift1:TShiftState;
|
Key1:Word; Shift1:TShiftState;
|
||||||
Key2:Word; Shift2:TShiftState):integer;
|
Key2:Word; Shift2:TShiftState):integer;
|
||||||
function ShiftStateToStr(Shift:TShiftState):AnsiString;
|
function ShiftStateToStr(Shift:TShiftState):AnsiString;
|
||||||
@ -207,14 +221,18 @@ type
|
|||||||
public
|
public
|
||||||
function Count: integer;
|
function Count: integer;
|
||||||
function CategoryCount: integer;
|
function CategoryCount: integer;
|
||||||
function Find(AKey:Word; AShiftState:TShiftState): TKeyCommandRelation;
|
function Find(AKey:Word; AShiftState:TShiftState;
|
||||||
function FindByCommand(ACommand:TSynEditorCommand): TKeyCommandRelation;
|
Areas: TCommandAreas): TKeyCommandRelation;
|
||||||
|
function FindByCommand(ACommand:word): TKeyCommandRelation;
|
||||||
function FindCategoryByName(const CategoryName: string): TKeyCommandCategory;
|
function FindCategoryByName(const CategoryName: string): TKeyCommandCategory;
|
||||||
|
function TranslateKey(AKey:Word; AShiftState:TShiftState;
|
||||||
|
Areas: TCommandAreas): word;
|
||||||
function IndexOf(ARelation: TKeyCommandRelation): integer;
|
function IndexOf(ARelation: TKeyCommandRelation): integer;
|
||||||
function CommandToShortCut(ACommand: TSynEditorCommand): TShortCut;
|
function CommandToShortCut(ACommand: word): TShortCut;
|
||||||
function LoadFromXMLConfig(XMLConfig:TXMLConfig; Prefix:AnsiString):boolean;
|
function LoadFromXMLConfig(XMLConfig:TXMLConfig; Prefix:AnsiString):boolean;
|
||||||
function SaveToXMLConfig(XMLConfig:TXMLConfig; Prefix:AnsiString):boolean;
|
function SaveToXMLConfig(XMLConfig:TXMLConfig; Prefix:AnsiString):boolean;
|
||||||
procedure AssignTo(ASynEditKeyStrokes:TSynEditKeyStrokes);
|
procedure AssignTo(ASynEditKeyStrokes:TSynEditKeyStrokes;
|
||||||
|
Areas: TCommandAreas);
|
||||||
constructor Create;
|
constructor Create;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
property ExtToolCount: integer read fExtToolCount write SetExtToolCount;
|
property ExtToolCount: integer read fExtToolCount write SetExtToolCount;
|
||||||
@ -261,7 +279,7 @@ function ShowKeyMappingEditForm(Index:integer;
|
|||||||
AKeyCommandRelationList:TKeyCommandRelationList):TModalResult;
|
AKeyCommandRelationList:TKeyCommandRelationList):TModalResult;
|
||||||
function KeyStrokesConsistencyErrors(ASynEditKeyStrokes:TSynEditKeyStrokes;
|
function KeyStrokesConsistencyErrors(ASynEditKeyStrokes:TSynEditKeyStrokes;
|
||||||
Protocol: TStrings; var Index1,Index2:integer):integer;
|
Protocol: TStrings; var Index1,Index2:integer):integer;
|
||||||
function EditorCommandToDescriptionString(cmd: TSynEditorCommand):AnsiString;
|
function EditorCommandToDescriptionString(cmd: word):AnsiString;
|
||||||
function StrToVKCode(s: string): integer;
|
function StrToVKCode(s: string): integer;
|
||||||
|
|
||||||
var KeyMappingEditForm: TKeyMappingEditForm;
|
var KeyMappingEditForm: TKeyMappingEditForm;
|
||||||
@ -344,7 +362,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function EditorCommandToDescriptionString(cmd: TSynEditorCommand):AnsiString;
|
function EditorCommandToDescriptionString(cmd: word):AnsiString;
|
||||||
begin
|
begin
|
||||||
case cmd of
|
case cmd of
|
||||||
ecNone: Result:= 'None';
|
ecNone: Result:= 'None';
|
||||||
@ -561,29 +579,31 @@ begin
|
|||||||
Key1:=ASynEditKeyStrokes[a];
|
Key1:=ASynEditKeyStrokes[a];
|
||||||
for b:=a+1 to ASynEditKeyStrokes.Count-1 do begin
|
for b:=a+1 to ASynEditKeyStrokes.Count-1 do begin
|
||||||
Key2:=ASynEditKeyStrokes[b];
|
Key2:=ASynEditKeyStrokes[b];
|
||||||
if (Key1.Command<>Key2.Command)
|
if (Key1.Key=VK_UNKNOWN)
|
||||||
and (Key1.Key<>VK_UNKNOWN)
|
or (Key1.Command=Key2.Command)
|
||||||
and (Key1.Key=Key2.Key) and (Key1.Shift=Key2.Shift) then begin
|
then
|
||||||
if (Key1.Key2=VK_UNKNOWN) or (Key2.Key2=VK_UNKNOWN)
|
continue;
|
||||||
or ((Key1.Key2=Key2.Key2) and (Key1.Shift2=Key2.Shift2)) then begin
|
if ((Key1.Key=Key2.Key) and (Key1.Shift=Key2.Shift))
|
||||||
// consistency error
|
or ((Key1.Key2<>VK_UNKNOWN)
|
||||||
if Result=0 then begin
|
and (Key1.Key2=Key2.Key) and (Key1.Shift2=Key2.Shift2)) then
|
||||||
Index1:=a;
|
begin
|
||||||
Index2:=b;
|
// consistency error
|
||||||
end;
|
if Result=0 then begin
|
||||||
inc(Result);
|
Index1:=a;
|
||||||
if Protocol<>nil then begin
|
Index2:=b;
|
||||||
Protocol.Add('Conflict '+IntToStr(Result));
|
end;
|
||||||
Protocol.Add(' command1 "'
|
inc(Result);
|
||||||
+EditorCommandToDescriptionString(Key1.Command)+'"'
|
if Protocol<>nil then begin
|
||||||
+'->'+KeyAndShiftStateToStr(Key1.Key,Key1.Shift));
|
Protocol.Add('Conflict '+IntToStr(Result));
|
||||||
Protocol.Add(' conflicts with ');
|
Protocol.Add(' command1 "'
|
||||||
Protocol.Add(' command2 "'
|
+EditorCommandToDescriptionString(Key1.Command)+'"'
|
||||||
+EditorCommandToDescriptionString(Key2.Command)+'"'
|
+'->'+KeyAndShiftStateToStr(Key1.Key,Key1.Shift));
|
||||||
+'->'+KeyAndShiftStateToStr(Key2.Key,Key2.Shift)
|
Protocol.Add(' conflicts with ');
|
||||||
);
|
Protocol.Add(' command2 "'
|
||||||
Protocol.Add('');
|
+EditorCommandToDescriptionString(Key2.Command)+'"'
|
||||||
end;
|
+'->'+KeyAndShiftStateToStr(Key2.Key,Key2.Shift)
|
||||||
|
);
|
||||||
|
Protocol.Add('');
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -884,7 +904,7 @@ procedure TKeyMappingEditForm.OkButtonClick(Sender:TObject);
|
|||||||
var NewKey1,NewKey2:integer;
|
var NewKey1,NewKey2:integer;
|
||||||
NewShiftState1,NewShiftState2:TShiftState;
|
NewShiftState1,NewShiftState2:TShiftState;
|
||||||
ACaption,AText:AnsiString;
|
ACaption,AText:AnsiString;
|
||||||
DummyRelation:TKeyCommandRelation;
|
DummyRelation, CurRelation:TKeyCommandRelation;
|
||||||
begin
|
begin
|
||||||
NewKey1:=VK_UNKNOWN;
|
NewKey1:=VK_UNKNOWN;
|
||||||
NewShiftState1:=[];
|
NewShiftState1:=[];
|
||||||
@ -896,7 +916,9 @@ begin
|
|||||||
if Key1AltCheckBox.Checked then include(NewShiftState1,ssAlt);
|
if Key1AltCheckBox.Checked then include(NewShiftState1,ssAlt);
|
||||||
if Key1ShiftCheckBox.Checked then include(NewShiftState1,ssShift);
|
if Key1ShiftCheckBox.Checked then include(NewShiftState1,ssShift);
|
||||||
end;
|
end;
|
||||||
DummyRelation:=KeyCommandRelationList.Find(NewKey1,NewShiftState1);
|
CurRelation:=KeyCommandRelationList.Relations[KeyIndex];
|
||||||
|
DummyRelation:=KeyCommandRelationList.Find(NewKey1,NewShiftState1,
|
||||||
|
CurRelation.Parent.Areas);
|
||||||
if (DummyRelation<>nil)
|
if (DummyRelation<>nil)
|
||||||
and (DummyRelation<>KeyCommandRelationList.Relations[KeyIndex]) then begin
|
and (DummyRelation<>KeyCommandRelationList.Relations[KeyIndex]) then begin
|
||||||
ACaption:='No No No';
|
ACaption:='No No No';
|
||||||
@ -916,7 +938,8 @@ begin
|
|||||||
if Key2AltCheckBox.Checked then include(NewShiftState2,ssAlt);
|
if Key2AltCheckBox.Checked then include(NewShiftState2,ssAlt);
|
||||||
if Key2ShiftCheckBox.Checked then include(NewShiftState2,ssShift);
|
if Key2ShiftCheckBox.Checked then include(NewShiftState2,ssShift);
|
||||||
end;
|
end;
|
||||||
DummyRelation:=KeyCommandRelationList.Find(NewKey2,NewShiftState2);
|
DummyRelation:=KeyCommandRelationList.Find(NewKey2,NewShiftState2,
|
||||||
|
CurRelation.Parent.Areas);
|
||||||
if (DummyRelation<>nil)
|
if (DummyRelation<>nil)
|
||||||
and (DummyRelation<>KeyCommandRelationList.Relations[KeyIndex]) then begin
|
and (DummyRelation<>KeyCommandRelationList.Relations[KeyIndex]) then begin
|
||||||
ACaption:='No No No';
|
ACaption:='No No No';
|
||||||
@ -930,7 +953,7 @@ begin
|
|||||||
NewShiftState1:=NewShiftState2;
|
NewShiftState1:=NewShiftState2;
|
||||||
NewKey2:=VK_UNKNOWN;
|
NewKey2:=VK_UNKNOWN;
|
||||||
end;
|
end;
|
||||||
with KeyCommandRelationList.Relations[KeyIndex] do begin
|
with CurRelation do begin
|
||||||
Key1:=NewKey1;
|
Key1:=NewKey1;
|
||||||
Shift1:=NewShiftState1;
|
Shift1:=NewShiftState1;
|
||||||
Key2:=NewKey2;
|
Key2:=NewKey2;
|
||||||
@ -1034,7 +1057,7 @@ end;
|
|||||||
{ TKeyCommandRelation }
|
{ TKeyCommandRelation }
|
||||||
|
|
||||||
constructor TKeyCommandRelation.Create(AParent: TKeyCommandCategory;
|
constructor TKeyCommandRelation.Create(AParent: TKeyCommandCategory;
|
||||||
AName:ShortString; ACommand:TSynEditorCommand;
|
AName:ShortString; ACommand:word;
|
||||||
AKey1:Word;AShift1:TShiftState;AKey2:Word;AShift2:TShiftState);
|
AKey1:Word;AShift1:TShiftState;AKey2:Word;AShift2:TShiftState);
|
||||||
begin
|
begin
|
||||||
Name:=AName;
|
Name:=AName;
|
||||||
@ -1085,7 +1108,7 @@ begin
|
|||||||
// create default keymapping
|
// create default keymapping
|
||||||
|
|
||||||
// moving
|
// moving
|
||||||
C:=Categories[AddCategory('CursorMoving','Cursor moving commands')];
|
C:=Categories[AddCategory('CursorMoving','Cursor moving commands',caSrcEditOnly)];
|
||||||
Add(C,'Move cursor word left',ecWordLeft, VK_LEFT, [ssCtrl],VK_UNKNOWN,[]);
|
Add(C,'Move cursor word left',ecWordLeft, VK_LEFT, [ssCtrl],VK_UNKNOWN,[]);
|
||||||
Add(C,'Move cursor word right',ecWordRight, VK_RIGHT, [ssCtrl],VK_UNKNOWN,[]);
|
Add(C,'Move cursor word right',ecWordRight, VK_RIGHT, [ssCtrl],VK_UNKNOWN,[]);
|
||||||
Add(C,'Move cursor to line start',ecLineStart, VK_HOME, [],VK_UNKNOWN,[]);
|
Add(C,'Move cursor to line start',ecLineStart, VK_HOME, [],VK_UNKNOWN,[]);
|
||||||
@ -1104,7 +1127,7 @@ begin
|
|||||||
Add(C,'Scroll right one char',ecScrollRight, VK_UNKNOWN, [],VK_UNKNOWN,[]);
|
Add(C,'Scroll right one char',ecScrollRight, VK_UNKNOWN, [],VK_UNKNOWN,[]);
|
||||||
|
|
||||||
// selection
|
// selection
|
||||||
C:=Categories[AddCategory('Selection','Text selection commands')];
|
C:=Categories[AddCategory('Selection','Text selection commands',caSrcEditOnly)];
|
||||||
Add(C,'Select All',ecSelectAll,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
Add(C,'Select All',ecSelectAll,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||||
Add(C,'Copy selection to clipboard',ecCopy,VK_C,[ssCtrl],VK_Insert,[ssCtrl]);
|
Add(C,'Copy selection to clipboard',ecCopy,VK_C,[ssCtrl],VK_Insert,[ssCtrl]);
|
||||||
Add(C,'Cut selection to clipboard',ecCut,VK_X,[ssCtrl],VK_Delete,[ssShift]);
|
Add(C,'Cut selection to clipboard',ecCut,VK_X,[ssCtrl],VK_Delete,[ssShift]);
|
||||||
@ -1127,7 +1150,7 @@ begin
|
|||||||
Add(C,'Uncomment selection',ecSelectionUncomment,VK_UNKNOWN, [],VK_UNKNOWN,[]);
|
Add(C,'Uncomment selection',ecSelectionUncomment,VK_UNKNOWN, [],VK_UNKNOWN,[]);
|
||||||
|
|
||||||
// editing
|
// editing
|
||||||
C:=Categories[AddCategory('editing commands','Text editing commands')];
|
C:=Categories[AddCategory('editing commands','Text editing commands',caSrcEditOnly)];
|
||||||
Add(C,'Indent block',ecBlockIndent,VK_I,[ssCtrl],VK_UNKNOWN,[]);
|
Add(C,'Indent block',ecBlockIndent,VK_I,[ssCtrl],VK_UNKNOWN,[]);
|
||||||
Add(C,'Unindent block',ecBlockUnindent,VK_U,[ssCtrl],VK_UNKNOWN,[]);
|
Add(C,'Unindent block',ecBlockUnindent,VK_U,[ssCtrl],VK_UNKNOWN,[]);
|
||||||
Add(C,'Delete last char',ecDeleteLastChar,VK_BACK, [],VK_BACK, [ssShift]);
|
Add(C,'Delete last char',ecDeleteLastChar,VK_BACK, [],VK_BACK, [ssShift]);
|
||||||
@ -1142,12 +1165,12 @@ begin
|
|||||||
Add(C,'Break line, leave cursor',ecInsertLine,VK_N,[ssCtrl],VK_UNKNOWN,[]);
|
Add(C,'Break line, leave cursor',ecInsertLine,VK_N,[ssCtrl],VK_UNKNOWN,[]);
|
||||||
|
|
||||||
// command commands
|
// command commands
|
||||||
C:=Categories[AddCategory('CommandCommands','Command commands')];
|
C:=Categories[AddCategory('CommandCommands','Command commands',caAll)];
|
||||||
Add(C,'Undo',ecUndo,VK_Z,[ssCtrl],VK_UNKNOWN,[]);
|
Add(C,'Undo',ecUndo,VK_Z,[ssCtrl],VK_UNKNOWN,[]);
|
||||||
Add(C,'Redo',ecRedo,VK_Z,[ssCtrl,ssShift],VK_UNKNOWN,[]);
|
Add(C,'Redo',ecRedo,VK_Z,[ssCtrl,ssShift],VK_UNKNOWN,[]);
|
||||||
|
|
||||||
// search & replace
|
// search & replace
|
||||||
C:=Categories[AddCategory('SearchReplace','Search and Replace commands')];
|
C:=Categories[AddCategory('SearchReplace','Text search and replace commands',caSrcEditOnly)];
|
||||||
Add(C,'Go to matching bracket',ecMatchBracket,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
Add(C,'Go to matching bracket',ecMatchBracket,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||||
Add(C,'Find text',ecFind,VK_F,[SSCtrl],VK_UNKNOWN,[]);
|
Add(C,'Find text',ecFind,VK_F,[SSCtrl],VK_UNKNOWN,[]);
|
||||||
Add(C,'Find next',ecFindNext,VK_F3,[],VK_UNKNOWN,[]);
|
Add(C,'Find next',ecFindNext,VK_F3,[],VK_UNKNOWN,[]);
|
||||||
@ -1162,7 +1185,7 @@ begin
|
|||||||
Add(C,'Open file at cursor',ecOpenFileAtCursor,VK_RETURN,[ssCtrl],VK_UNKNOWN,[]);
|
Add(C,'Open file at cursor',ecOpenFileAtCursor,VK_RETURN,[ssCtrl],VK_UNKNOWN,[]);
|
||||||
|
|
||||||
// marker
|
// marker
|
||||||
C:=Categories[AddCategory('Marker','Marker commands')];
|
C:=Categories[AddCategory('Marker','Text marker commands',caSrcEditOnly)];
|
||||||
Add(C,'Go to marker 0',ecGotoMarker0,VK_0,[ssCtrl],VK_UNKNOWN,[]);
|
Add(C,'Go to marker 0',ecGotoMarker0,VK_0,[ssCtrl],VK_UNKNOWN,[]);
|
||||||
Add(C,'Go to marker 1',ecGotoMarker1,VK_1,[ssCtrl],VK_UNKNOWN,[]);
|
Add(C,'Go to marker 1',ecGotoMarker1,VK_1,[ssCtrl],VK_UNKNOWN,[]);
|
||||||
Add(C,'Go to marker 2',ecGotoMarker2,VK_2,[ssCtrl],VK_UNKNOWN,[]);
|
Add(C,'Go to marker 2',ecGotoMarker2,VK_2,[ssCtrl],VK_UNKNOWN,[]);
|
||||||
@ -1185,7 +1208,7 @@ begin
|
|||||||
Add(C,'Set marker 9',ecSetMarker9,VK_9,[ssShift,ssCtrl],VK_UNKNOWN,[]);
|
Add(C,'Set marker 9',ecSetMarker9,VK_9,[ssShift,ssCtrl],VK_UNKNOWN,[]);
|
||||||
|
|
||||||
// codetools
|
// codetools
|
||||||
C:=Categories[AddCategory('CodeTools','CodeTools commands')];
|
C:=Categories[AddCategory('CodeTools','CodeTools commands',caSrcEditOnly)];
|
||||||
Add(C,'Code template completion',ecAutoCompletion,VK_J,[ssCtrl],VK_UNKNOWN,[]);
|
Add(C,'Code template completion',ecAutoCompletion,VK_J,[ssCtrl],VK_UNKNOWN,[]);
|
||||||
Add(C,'Word completion',ecWordCompletion,VK_W,[ssCtrl],VK_UNKNOWN,[]);
|
Add(C,'Word completion',ecWordCompletion,VK_W,[ssCtrl],VK_UNKNOWN,[]);
|
||||||
Add(C,'Complete code',ecCompleteCode,VK_C,[ssCtrl,ssShift],VK_UNKNOWN,[]);
|
Add(C,'Complete code',ecCompleteCode,VK_C,[ssCtrl,ssShift],VK_UNKNOWN,[]);
|
||||||
@ -1204,7 +1227,7 @@ begin
|
|||||||
Add(C,'Goto include directive',ecGotoIncludeDirective,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
Add(C,'Goto include directive',ecGotoIncludeDirective,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||||
|
|
||||||
// source notebook
|
// source notebook
|
||||||
C:=Categories[AddCategory('SourceNotebook','Source Notebook commands')];
|
C:=Categories[AddCategory('SourceNotebook','Source Notebook commands',caAll)];
|
||||||
Add(C,'Go to next editor',ecNextEditor, VK_S, [ssShift,ssCtrl], VK_UNKNOWN, []);
|
Add(C,'Go to next editor',ecNextEditor, VK_S, [ssShift,ssCtrl], VK_UNKNOWN, []);
|
||||||
Add(C,'Go to prior editor',ecPrevEditor, VK_A, [ssShift,ssCtrl], VK_UNKNOWN, []);
|
Add(C,'Go to prior editor',ecPrevEditor, VK_A, [ssShift,ssCtrl], VK_UNKNOWN, []);
|
||||||
Add(C,'Go to source editor 1',ecGotoEditor0,VK_1,[ssAlt],VK_UNKNOWN,[]);
|
Add(C,'Go to source editor 1',ecGotoEditor0,VK_1,[ssAlt],VK_UNKNOWN,[]);
|
||||||
@ -1219,7 +1242,7 @@ begin
|
|||||||
Add(C,'Go to source editor 10',ecGotoEditor0,VK_0,[ssAlt],VK_UNKNOWN,[]);
|
Add(C,'Go to source editor 10',ecGotoEditor0,VK_0,[ssAlt],VK_UNKNOWN,[]);
|
||||||
|
|
||||||
// file menu
|
// file menu
|
||||||
C:=Categories[AddCategory('FileMenu','File menu commands')];
|
C:=Categories[AddCategory('FileMenu','File menu commands',caAll)];
|
||||||
Add(C,'New',ecNew,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
Add(C,'New',ecNew,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||||
Add(C,'NewUnit',ecNewUnit,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
Add(C,'NewUnit',ecNewUnit,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||||
Add(C,'NewForm',ecNewForm,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
Add(C,'NewForm',ecNewForm,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||||
@ -1233,7 +1256,7 @@ begin
|
|||||||
Add(C,'Quit',ecQuit,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
Add(C,'Quit',ecQuit,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||||
|
|
||||||
// view menu
|
// view menu
|
||||||
C:=Categories[AddCategory('ViewMenu','View menu commands')];
|
C:=Categories[AddCategory('ViewMenu','View menu commands',caAll)];
|
||||||
Add(C,'Toggle view Object Inspector',ecToggleObjectInsp,VK_F11,[],VK_UNKNOWN,[]);
|
Add(C,'Toggle view Object Inspector',ecToggleObjectInsp,VK_F11,[],VK_UNKNOWN,[]);
|
||||||
Add(C,'Toggle view Project Explorer',ecToggleProjectExpl,VK_F11,[ssCtrl,ssAlt],VK_UNKNOWN,[]);
|
Add(C,'Toggle view Project Explorer',ecToggleProjectExpl,VK_F11,[ssCtrl,ssAlt],VK_UNKNOWN,[]);
|
||||||
Add(C,'Toggle view Code Explorer',ecToggleCodeExpl,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
Add(C,'Toggle view Code Explorer',ecToggleCodeExpl,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||||
@ -1249,7 +1272,7 @@ begin
|
|||||||
Add(C,'Toggle between Unit and Form',ecToggleFormUnit,VK_F12,[],VK_UNKNOWN,[]);
|
Add(C,'Toggle between Unit and Form',ecToggleFormUnit,VK_F12,[],VK_UNKNOWN,[]);
|
||||||
|
|
||||||
// project menu
|
// project menu
|
||||||
C:=Categories[AddCategory('ProjectMenu','Project menu commands')];
|
C:=Categories[AddCategory('ProjectMenu','Project menu commands',caAll)];
|
||||||
Add(C,'New project',ecNewProject,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
Add(C,'New project',ecNewProject,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||||
Add(C,'Open project',ecOpenProject,VK_F11,[ssCtrl],VK_UNKNOWN,[]);
|
Add(C,'Open project',ecOpenProject,VK_F11,[ssCtrl],VK_UNKNOWN,[]);
|
||||||
Add(C,'Save project',ecSaveProject,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
Add(C,'Save project',ecSaveProject,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||||
@ -1260,7 +1283,7 @@ begin
|
|||||||
Add(C,'View project options',ecProjectOptions,VK_F11,[ssShift,ssCtrl],VK_UNKNOWN,[]);
|
Add(C,'View project options',ecProjectOptions,VK_F11,[ssShift,ssCtrl],VK_UNKNOWN,[]);
|
||||||
|
|
||||||
// run menu
|
// run menu
|
||||||
C:=Categories[AddCategory('RunMenu','Run menu commands')];
|
C:=Categories[AddCategory('RunMenu','Run menu commands',caAll)];
|
||||||
Add(C,'Build project/program',ecBuild,VK_F9,[ssCtrl],VK_UNKNOWN,[]);
|
Add(C,'Build project/program',ecBuild,VK_F9,[ssCtrl],VK_UNKNOWN,[]);
|
||||||
Add(C,'Build all files of project/program',ecBuildAll,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
Add(C,'Build all files of project/program',ecBuildAll,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||||
Add(C,'Run program',ecRun,VK_F9,[],VK_UNKNOWN,[]);
|
Add(C,'Run program',ecRun,VK_F9,[],VK_UNKNOWN,[]);
|
||||||
@ -1273,20 +1296,20 @@ begin
|
|||||||
Add(C,'Run parameters',ecRunParameters,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
Add(C,'Run parameters',ecRunParameters,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||||
|
|
||||||
// tools menu
|
// tools menu
|
||||||
C:=Categories[AddCategory(KeyCategoryToolMenuName,'Tools menu commands')];
|
C:=Categories[AddCategory(KeyCategoryToolMenuName,'Tools menu commands',caAll)];
|
||||||
Add(C,'External Tools settings',ecExtToolSettings,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
Add(C,'External Tools settings',ecExtToolSettings,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||||
Add(C,'Build Lazarus',ecBuildLazarus,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
Add(C,'Build Lazarus',ecBuildLazarus,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||||
Add(C,'Configure "Build Lazarus"',ecConfigBuildLazarus,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
Add(C,'Configure "Build Lazarus"',ecConfigBuildLazarus,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||||
|
|
||||||
// environment menu
|
// environment menu
|
||||||
C:=Categories[AddCategory('EnvironmentMenu','Environment menu commands')];
|
C:=Categories[AddCategory('EnvironmentMenu','Environment menu commands',caAll)];
|
||||||
Add(C,'General environment options',ecEnvironmentOptions,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
Add(C,'General environment options',ecEnvironmentOptions,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||||
Add(C,'Editor options',ecEditorOptions,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
Add(C,'Editor options',ecEditorOptions,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||||
Add(C,'CodeTools options',ecCodeToolsOptions,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
Add(C,'CodeTools options',ecCodeToolsOptions,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||||
Add(C,'CodeTools defines editor',ecCodeToolsDefinesEd,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
Add(C,'CodeTools defines editor',ecCodeToolsDefinesEd,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||||
|
|
||||||
// help menu
|
// help menu
|
||||||
C:=Categories[AddCategory('HelpMenu','Help menu commands')];
|
C:=Categories[AddCategory('HelpMenu','Help menu commands',caAll)];
|
||||||
Add(C,'About Lazarus',ecAboutLazarus,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
Add(C,'About Lazarus',ecAboutLazarus,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1320,7 +1343,7 @@ end;
|
|||||||
|
|
||||||
function TKeyCommandRelationList.Add(Category: TKeyCommandCategory;
|
function TKeyCommandRelationList.Add(Category: TKeyCommandCategory;
|
||||||
const Name:shortstring;
|
const Name:shortstring;
|
||||||
Command:TSynEditorCommand;
|
Command:word;
|
||||||
Key1:Word; Shift1:TShiftState; Key2:Word; Shift2:TShiftState):integer;
|
Key1:Word; Shift1:TShiftState; Key2:Word; Shift2:TShiftState):integer;
|
||||||
begin
|
begin
|
||||||
Result:=FRelations.Add(TKeyCommandRelation.Create(Category,Name,Command
|
Result:=FRelations.Add(TKeyCommandRelation.Create(Category,Name,Command
|
||||||
@ -1443,22 +1466,24 @@ begin
|
|||||||
Result:=IntToStr(i);
|
Result:=IntToStr(i);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TKeyCommandRelationList.Find(AKey:Word; AShiftState:TShiftState
|
function TKeyCommandRelationList.Find(AKey:Word; AShiftState:TShiftState;
|
||||||
):TKeyCommandRelation;
|
Areas: TCommandAreas):TKeyCommandRelation;
|
||||||
var a:integer;
|
var a:integer;
|
||||||
begin
|
begin
|
||||||
Result:=nil;
|
Result:=nil;
|
||||||
if AKey=VK_UNKNOWN then exit;
|
if AKey=VK_UNKNOWN then exit;
|
||||||
for a:=0 to FRelations.Count-1 do with Relations[a] do
|
for a:=0 to FRelations.Count-1 do with Relations[a] do begin
|
||||||
|
if Parent.Areas*Areas=[] then continue;
|
||||||
if ((Key1=AKey) and (Shift1=AShiftState))
|
if ((Key1=AKey) and (Shift1=AShiftState))
|
||||||
or ((Key2=AKey) and (Shift2=AShiftState)) then begin
|
or ((Key2=AKey) and (Shift2=AShiftState)) then begin
|
||||||
Result:=Relations[a];
|
Result:=Relations[a];
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TKeyCommandRelationList.FindByCommand(
|
function TKeyCommandRelationList.FindByCommand(
|
||||||
ACommand:TSynEditorCommand):TKeyCommandRelation;
|
ACommand:word):TKeyCommandRelation;
|
||||||
var a:integer;
|
var a:integer;
|
||||||
begin
|
begin
|
||||||
Result:=nil;
|
Result:=nil;
|
||||||
@ -1470,14 +1495,19 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TKeyCommandRelationList.AssignTo(
|
procedure TKeyCommandRelationList.AssignTo(
|
||||||
ASynEditKeyStrokes:TSynEditKeyStrokes);
|
ASynEditKeyStrokes:TSynEditKeyStrokes; Areas: TCommandAreas);
|
||||||
var a,b,MaxKeyCnt,KeyCnt:integer;
|
var
|
||||||
|
a,b,MaxKeyCnt,KeyCnt:integer;
|
||||||
Key:TSynEditKeyStroke;
|
Key:TSynEditKeyStroke;
|
||||||
begin
|
begin
|
||||||
for a:=0 to FRelations.Count-1 do begin
|
for a:=0 to FRelations.Count-1 do begin
|
||||||
if Relations[a].Key1=VK_UNKNOWN then MaxKeyCnt:=0
|
if (Relations[a].Key1=VK_UNKNOWN)
|
||||||
else if Relations[a].Key2=VK_UNKNOWN then MaxKeyCnt:=1
|
or ((Relations[a].Parent.Areas*Areas)=[]) then
|
||||||
else MaxKeyCnt:=2;
|
MaxKeyCnt:=0
|
||||||
|
else if Relations[a].Key2=VK_UNKNOWN then
|
||||||
|
MaxKeyCnt:=1
|
||||||
|
else
|
||||||
|
MaxKeyCnt:=2;
|
||||||
KeyCnt:=1;
|
KeyCnt:=1;
|
||||||
b:=0;
|
b:=0;
|
||||||
while b<ASynEditKeyStrokes.Count do begin
|
while b<ASynEditKeyStrokes.Count do begin
|
||||||
@ -1528,10 +1558,10 @@ begin
|
|||||||
Result:=fCategories.Count;
|
Result:=fCategories.Count;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TKeyCommandRelationList.AddCategory(const Name, Description: string
|
function TKeyCommandRelationList.AddCategory(const Name, Description: string;
|
||||||
): integer;
|
TheAreas: TCommandAreas): integer;
|
||||||
begin
|
begin
|
||||||
Result:=fCategories.Add(TKeyCommandCategory.Create(Name,Description));
|
Result:=fCategories.Add(TKeyCommandCategory.Create(Name,Description,TheAreas));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TKeyCommandRelationList.FindCategoryByName(const CategoryName: string
|
function TKeyCommandRelationList.FindCategoryByName(const CategoryName: string
|
||||||
@ -1546,13 +1576,25 @@ begin
|
|||||||
Result:=nil;
|
Result:=nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TKeyCommandRelationList.TranslateKey(AKey: Word;
|
||||||
|
AShiftState: TShiftState; Areas: TCommandAreas): word;
|
||||||
|
var
|
||||||
|
ARelation: TKeyCommandRelation;
|
||||||
|
begin
|
||||||
|
ARelation:=Find(AKey,AShiftState,Areas);
|
||||||
|
if ARelation<>nil then
|
||||||
|
Result:=ARelation.Command
|
||||||
|
else
|
||||||
|
Result:=ecNone;
|
||||||
|
end;
|
||||||
|
|
||||||
function TKeyCommandRelationList.IndexOf(ARelation: TKeyCommandRelation
|
function TKeyCommandRelationList.IndexOf(ARelation: TKeyCommandRelation
|
||||||
): integer;
|
): integer;
|
||||||
begin
|
begin
|
||||||
Result:=fRelations.IndexOf(ARelation);
|
Result:=fRelations.IndexOf(ARelation);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TKeyCommandRelationList.CommandToShortCut(ACommand: TSynEditorCommand
|
function TKeyCommandRelationList.CommandToShortCut(ACommand: word
|
||||||
): TShortCut;
|
): TShortCut;
|
||||||
var ARelation: TKeyCommandRelation;
|
var ARelation: TKeyCommandRelation;
|
||||||
begin
|
begin
|
||||||
@ -1578,11 +1620,13 @@ begin
|
|||||||
inherited Delete(Index);
|
inherited Delete(Index);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TKeyCommandCategory.Create(const AName, ADescription: string);
|
constructor TKeyCommandCategory.Create(const AName, ADescription: string;
|
||||||
|
TheAreas: TCommandAreas);
|
||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
Name:=AName;
|
Name:=AName;
|
||||||
Description:=ADescription;
|
Description:=ADescription;
|
||||||
|
Areas:=TheAreas;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
195
ide/main.pp
195
ide/main.pp
@ -74,6 +74,7 @@ type
|
|||||||
procedure mnuNewUnitClicked(Sender : TObject);
|
procedure mnuNewUnitClicked(Sender : TObject);
|
||||||
procedure mnuNewFormClicked(Sender : TObject);
|
procedure mnuNewFormClicked(Sender : TObject);
|
||||||
procedure mnuOpenClicked(Sender : TObject);
|
procedure mnuOpenClicked(Sender : TObject);
|
||||||
|
procedure mnuOpenRecentClicked(Sender : TObject);
|
||||||
procedure mnuRevertClicked(Sender : TObject);
|
procedure mnuRevertClicked(Sender : TObject);
|
||||||
procedure mnuSaveClicked(Sender : TObject);
|
procedure mnuSaveClicked(Sender : TObject);
|
||||||
procedure mnuSaveAsClicked(Sender : TObject);
|
procedure mnuSaveAsClicked(Sender : TObject);
|
||||||
@ -159,6 +160,10 @@ type
|
|||||||
procedure mnuOpenFilePopupClick(Sender : TObject);
|
procedure mnuOpenFilePopupClick(Sender : TObject);
|
||||||
procedure ControlClick(Sender : TObject);
|
procedure ControlClick(Sender : TObject);
|
||||||
|
|
||||||
|
// Global IDE events
|
||||||
|
Procedure OnProcessIDECommand(Sender: TObject; Command: word;
|
||||||
|
var Handled: boolean);
|
||||||
|
|
||||||
// SourceNotebook events
|
// SourceNotebook events
|
||||||
Procedure OnSrcNoteBookActivated(Sender : TObject);
|
Procedure OnSrcNoteBookActivated(Sender : TObject);
|
||||||
Procedure OnSrcNoteBookAddJumpPoint(ACaretXY: TPoint; ATopLine: integer;
|
Procedure OnSrcNoteBookAddJumpPoint(ACaretXY: TPoint; ATopLine: integer;
|
||||||
@ -179,8 +184,6 @@ type
|
|||||||
Procedure OnSrcNotebookFindDeclaration(Sender : TObject);
|
Procedure OnSrcNotebookFindDeclaration(Sender : TObject);
|
||||||
Procedure OnSrcNotebookJumpToHistoryPoint(var NewCaretXY: TPoint;
|
Procedure OnSrcNotebookJumpToHistoryPoint(var NewCaretXY: TPoint;
|
||||||
var NewTopLine, NewPageIndex: integer; Action: TJumpHistoryAction);
|
var NewTopLine, NewPageIndex: integer; Action: TJumpHistoryAction);
|
||||||
Procedure OnSrcNotebookProcessCommand(Sender: TObject; Command: integer;
|
|
||||||
var Handled: boolean);
|
|
||||||
Procedure OnSrcNoteBookCtrlMouseUp(Sender : TObject;
|
Procedure OnSrcNoteBookCtrlMouseUp(Sender : TObject;
|
||||||
Button : TMouseButton; Shift: TShiftstate; X, Y: Integer);
|
Button : TMouseButton; Shift: TShiftstate; X, Y: Integer);
|
||||||
Procedure OnSrcNotebookSaveAll(Sender : TObject);
|
Procedure OnSrcNotebookSaveAll(Sender : TObject);
|
||||||
@ -188,7 +191,6 @@ type
|
|||||||
Procedure OnSrcNotebookToggleFormUnit(Sender : TObject);
|
Procedure OnSrcNotebookToggleFormUnit(Sender : TObject);
|
||||||
Procedure OnSrcNotebookViewJumpHistory(Sender : TObject);
|
Procedure OnSrcNotebookViewJumpHistory(Sender : TObject);
|
||||||
|
|
||||||
|
|
||||||
// ObjectInspector + PropertyEditorHook events
|
// ObjectInspector + PropertyEditorHook events
|
||||||
procedure OIOnSelectComponent(AComponent:TComponent);
|
procedure OIOnSelectComponent(AComponent:TComponent);
|
||||||
procedure OnPropHookGetMethods(TypeData:PTypeData; Proc:TGetStringProc);
|
procedure OnPropHookGetMethods(TypeData:PTypeData; Proc:TGetStringProc);
|
||||||
@ -384,6 +386,10 @@ type
|
|||||||
var ActiveUnitInfo:TUnitInfo); override;
|
var ActiveUnitInfo:TUnitInfo); override;
|
||||||
procedure GetUnitWithPageIndex(PageIndex:integer;
|
procedure GetUnitWithPageIndex(PageIndex:integer;
|
||||||
var ActiveSourceEditor:TSourceEditor; var ActiveUnitInfo:TUnitInfo);
|
var ActiveSourceEditor:TSourceEditor; var ActiveUnitInfo:TUnitInfo);
|
||||||
|
procedure GetDesignerUnit(ADesigner: TDesigner;
|
||||||
|
var ActiveSourceEditor:TSourceEditor; var ActiveUnitInfo:TUnitInfo);
|
||||||
|
procedure GetUnitWithForm(AForm: TCustomForm;
|
||||||
|
var ActiveSourceEditor:TSourceEditor; var ActiveUnitInfo:TUnitInfo);
|
||||||
function GetSourceEditorForUnitInfo(AnUnitInfo: TUnitInfo): TSourceEditor;
|
function GetSourceEditorForUnitInfo(AnUnitInfo: TUnitInfo): TSourceEditor;
|
||||||
procedure UpdateDefaultPascalFileExtensions;
|
procedure UpdateDefaultPascalFileExtensions;
|
||||||
function CreateSrcEditPageName(const AnUnitName, AFilename: string;
|
function CreateSrcEditPageName(const AnUnitName, AFilename: string;
|
||||||
@ -406,6 +412,8 @@ type
|
|||||||
// useful frontend methods
|
// useful frontend methods
|
||||||
procedure DoSwitchToFormSrc(var ActiveSourceEditor:TSourceEditor;
|
procedure DoSwitchToFormSrc(var ActiveSourceEditor:TSourceEditor;
|
||||||
var ActiveUnitInfo:TUnitInfo);
|
var ActiveUnitInfo:TUnitInfo);
|
||||||
|
procedure DoSwitchToFormSrc(ADesigner: TDesigner;
|
||||||
|
var ActiveSourceEditor:TSourceEditor; var ActiveUnitInfo:TUnitInfo);
|
||||||
procedure UpdateCaption;
|
procedure UpdateCaption;
|
||||||
function DoConvertDFMFileToLFMFile(const DFMFilename: string): TModalResult;
|
function DoConvertDFMFileToLFMFile(const DFMFilename: string): TModalResult;
|
||||||
|
|
||||||
@ -413,6 +421,8 @@ type
|
|||||||
procedure InitCodeToolBoss;
|
procedure InitCodeToolBoss;
|
||||||
function BeginCodeTool(var ActiveSrcEdit: TSourceEditor;
|
function BeginCodeTool(var ActiveSrcEdit: TSourceEditor;
|
||||||
var ActiveUnitInfo: TUnitInfo; SwitchToFormSrc: boolean): boolean;
|
var ActiveUnitInfo: TUnitInfo; SwitchToFormSrc: boolean): boolean;
|
||||||
|
function BeginCodeTool(ADesigner: TDesigner; var ActiveSrcEdit: TSourceEditor;
|
||||||
|
var ActiveUnitInfo: TUnitInfo; SwitchToFormSrc: boolean): boolean;
|
||||||
function DoJumpToCodePos(ActiveSrcEdit: TSourceEditor;
|
function DoJumpToCodePos(ActiveSrcEdit: TSourceEditor;
|
||||||
ActiveUnitInfo: TUnitInfo;
|
ActiveUnitInfo: TUnitInfo;
|
||||||
NewSource: TCodeBuffer; NewX, NewY, NewTopLine: integer;
|
NewSource: TCodeBuffer; NewX, NewY, NewTopLine: integer;
|
||||||
@ -1033,7 +1043,7 @@ begin
|
|||||||
SourceNotebook.OnNewClicked := @OnSrcNotebookFileNew;
|
SourceNotebook.OnNewClicked := @OnSrcNotebookFileNew;
|
||||||
SourceNotebook.OnOpenClicked := @OnSrcNotebookFileOpen;
|
SourceNotebook.OnOpenClicked := @OnSrcNotebookFileOpen;
|
||||||
SourceNotebook.OnOpenFileAtCursorClicked := @OnSrcNotebookFileOpenAtCursor;
|
SourceNotebook.OnOpenFileAtCursorClicked := @OnSrcNotebookFileOpenAtCursor;
|
||||||
SourceNotebook.OnProcessUserCommand := @OnSrcNotebookProcessCommand;
|
SourceNotebook.OnProcessUserCommand := @OnProcessIDECommand;
|
||||||
SourceNotebook.OnCtrlMouseUp := @OnSrcNoteBookCtrlMouseUp;
|
SourceNotebook.OnCtrlMouseUp := @OnSrcNoteBookCtrlMouseUp;
|
||||||
SourceNotebook.OnSaveClicked := @OnSrcNotebookFileSave;
|
SourceNotebook.OnSaveClicked := @OnSrcNotebookFileSave;
|
||||||
SourceNotebook.OnSaveAsClicked := @OnSrcNotebookFileSaveAs;
|
SourceNotebook.OnSaveAsClicked := @OnSrcNotebookFileSaveAs;
|
||||||
@ -1226,7 +1236,7 @@ end;
|
|||||||
procedure TMainIDE.SetRecentFilesMenu;
|
procedure TMainIDE.SetRecentFilesMenu;
|
||||||
begin
|
begin
|
||||||
SetRecentSubMenu(itmFileRecentOpen,EnvironmentOptions.RecentOpenFiles,
|
SetRecentSubMenu(itmFileRecentOpen,EnvironmentOptions.RecentOpenFiles,
|
||||||
@mnuOpenClicked);
|
@mnuOpenRecentClicked);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMainIDE.SetRecentProjectFilesMenu;
|
procedure TMainIDE.SetRecentProjectFilesMenu;
|
||||||
@ -1435,38 +1445,47 @@ var OpenDialog: TOpenDialog;
|
|||||||
AFilename: string;
|
AFilename: string;
|
||||||
I : Integer;
|
I : Integer;
|
||||||
begin
|
begin
|
||||||
if (Sender=itmFileOpen) or (Sender=OpenFileSpeedBtn)
|
OpenDialog:=TOpenDialog.Create(Application);
|
||||||
or (Sender is TSourceNoteBook) then begin
|
try
|
||||||
OpenDialog:=TOpenDialog.Create(Application);
|
InputHistories.ApplyFileDialogSettings(OpenDialog);
|
||||||
try
|
OpenDialog.Title:=lisOpenFile;
|
||||||
InputHistories.ApplyFileDialogSettings(OpenDialog);
|
OpenDialog.Options:=OpenDialog.Options+[ofAllowMultiSelect];
|
||||||
OpenDialog.Title:=lisOpenFile;
|
if OpenDialog.Execute and (OpenDialog.Files.Count>0) then begin
|
||||||
OpenDialog.Options:=OpenDialog.Options+[ofAllowMultiSelect];
|
For I := 0 to OpenDialog.Files.Count-1 do
|
||||||
if OpenDialog.Execute and (OpenDialog.Files.Count>0) then begin
|
Begin
|
||||||
For I := 0 to OpenDialog.Files.Count-1 do
|
AFilename:=ExpandFilename(OpenDialog.Files.Strings[i]);
|
||||||
Begin
|
if DoOpenEditorFile(AFilename,-1,[ofAddToRecent])=mrOk then begin
|
||||||
AFilename:=ExpandFilename(OpenDialog.Files.Strings[i]);
|
|
||||||
if DoOpenEditorFile(AFilename,-1,[ofAddToRecent])=mrOk then begin
|
|
||||||
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
UpdateEnvironment;
|
end;
|
||||||
end;
|
UpdateEnvironment;
|
||||||
InputHistories.StoreFileDialogSettings(OpenDialog);
|
end;
|
||||||
finally
|
InputHistories.StoreFileDialogSettings(OpenDialog);
|
||||||
OpenDialog.Free;
|
finally
|
||||||
end;
|
OpenDialog.Free;
|
||||||
end else if Sender is TMenuItem then begin
|
end;
|
||||||
AFileName:=ExpandFilename(TMenuItem(Sender).Caption);
|
end;
|
||||||
if DoOpenEditorFile(AFilename,-1,[ofAddToRecent])=mrOk then begin
|
|
||||||
|
procedure TMainIDE.mnuOpenRecentClicked(Sender: TObject);
|
||||||
|
|
||||||
|
procedure UpdateEnvironment;
|
||||||
|
begin
|
||||||
|
SetRecentFilesMenu;
|
||||||
|
SaveEnvironment;
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
AFilename: string;
|
||||||
|
begin
|
||||||
|
AFileName:=ExpandFilename(TMenuItem(Sender).Caption);
|
||||||
|
if DoOpenEditorFile(AFilename,-1,[ofAddToRecent])=mrOk then begin
|
||||||
|
UpdateEnvironment;
|
||||||
|
end else begin
|
||||||
|
// open failed
|
||||||
|
if not FileExists(AFilename) then begin
|
||||||
|
// file does not exist -> delete it from recent file list
|
||||||
|
EnvironmentOptions.RemoveFromRecentOpenFiles(AFilename);
|
||||||
UpdateEnvironment;
|
UpdateEnvironment;
|
||||||
end else begin
|
|
||||||
// open failed
|
|
||||||
if not FileExists(AFilename) then begin
|
|
||||||
// file does not exist -> delete it from recent file list
|
|
||||||
EnvironmentOptions.RemoveFromRecentOpenFiles(AFilename);
|
|
||||||
UpdateEnvironment;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1572,11 +1591,26 @@ begin
|
|||||||
mnuToggleFormUnitClicked(Sender);
|
mnuToggleFormUnitClicked(Sender);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TMainIDE.OnSrcNotebookProcessCommand(Sender: TObject;
|
Procedure TMainIDE.OnProcessIDECommand(Sender: TObject;
|
||||||
Command: integer; var Handled: boolean);
|
Command: word; var Handled: boolean);
|
||||||
|
var
|
||||||
|
ASrcEdit: TSourceEditor;
|
||||||
|
AnUnitInfo: TUnitInfo;
|
||||||
begin
|
begin
|
||||||
Handled:=true;
|
Handled:=true;
|
||||||
|
|
||||||
case Command of
|
case Command of
|
||||||
|
ecSave:
|
||||||
|
if Sender is TDesigner then begin
|
||||||
|
GetDesignerUnit(TDesigner(Sender),ASrcEdit,AnUnitInfo);
|
||||||
|
if (AnUnitInfo<>nil) and (AnUnitInfo.EditorIndex>=0) then
|
||||||
|
DoSaveEditorFile(AnUnitInfo.EditorIndex,[sfCheckAmbigiousFiles]);
|
||||||
|
end else if Sender is TSourceNotebook then
|
||||||
|
mnuSaveClicked(Self);
|
||||||
|
|
||||||
|
ecOpen:
|
||||||
|
mnuOpenClicked(Self);
|
||||||
|
|
||||||
ecSaveAll:
|
ecSaveAll:
|
||||||
DoSaveAll([sfCheckAmbigiousFiles]);
|
DoSaveAll([sfCheckAmbigiousFiles]);
|
||||||
|
|
||||||
@ -1767,6 +1801,7 @@ Begin
|
|||||||
OnModified:=@OnDesignerModified;
|
OnModified:=@OnDesignerModified;
|
||||||
OnActivated:=@OnDesignerActivated;
|
OnActivated:=@OnDesignerActivated;
|
||||||
OnRenameComponent:=@OnDesignerRenameComponent;
|
OnRenameComponent:=@OnDesignerRenameComponent;
|
||||||
|
OnProcessCommand:=@OnProcessIDECommand;
|
||||||
ShowHints:=EnvironmentOptions.ShowEditorHints;
|
ShowHints:=EnvironmentOptions.ShowEditorHints;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -4904,6 +4939,35 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TMainIDE.GetDesignerUnit(ADesigner: TDesigner;
|
||||||
|
var ActiveSourceEditor: TSourceEditor; var ActiveUnitInfo: TUnitInfo);
|
||||||
|
begin
|
||||||
|
if ADesigner<>nil then begin
|
||||||
|
GetUnitWithForm(ADesigner.Form,ActiveSourceEditor,ActiveUnitInfo);
|
||||||
|
end else begin
|
||||||
|
ActiveSourceEditor:=nil;
|
||||||
|
ActiveUnitInfo:=nil;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TMainIDE.GetUnitWithForm(AForm: TCustomForm;
|
||||||
|
var ActiveSourceEditor: TSourceEditor; var ActiveUnitInfo: TUnitInfo);
|
||||||
|
var
|
||||||
|
i: integer;
|
||||||
|
begin
|
||||||
|
if AForm<>nil then begin
|
||||||
|
i:=Project1.IndexOfUnitWithForm(AForm,false,nil);
|
||||||
|
if i>=0 then begin
|
||||||
|
ActiveUnitInfo:=Project1.Units[i];
|
||||||
|
ActiveSourceEditor:=SourceNoteBook.FindSourceEditorWithPageIndex(
|
||||||
|
ActiveUnitInfo.EditorIndex);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
ActiveSourceEditor:=nil;
|
||||||
|
ActiveUnitInfo:=nil;
|
||||||
|
end;
|
||||||
|
|
||||||
function TMainIDE.GetSourceEditorForUnitInfo(AnUnitInfo: TUnitInfo
|
function TMainIDE.GetSourceEditorForUnitInfo(AnUnitInfo: TUnitInfo
|
||||||
): TSourceEditor;
|
): TSourceEditor;
|
||||||
begin
|
begin
|
||||||
@ -5552,9 +5616,9 @@ end;
|
|||||||
|
|
||||||
procedure TMainIDE.OnDesignerComponentAdded(Sender: TObject;
|
procedure TMainIDE.OnDesignerComponentAdded(Sender: TObject;
|
||||||
AComponent: TComponent; AComponentClass: TRegisteredComponent);
|
AComponent: TComponent; AComponentClass: TRegisteredComponent);
|
||||||
var i: integer;
|
var
|
||||||
ActiveForm: TCustomForm;
|
|
||||||
ActiveUnitInfo: TUnitInfo;
|
ActiveUnitInfo: TUnitInfo;
|
||||||
|
ActiveSrcEdit: TSourceEditor;
|
||||||
FormClassName: string;
|
FormClassName: string;
|
||||||
begin
|
begin
|
||||||
if not (Sender is TDesigner) then begin
|
if not (Sender is TDesigner) then begin
|
||||||
@ -5562,19 +5626,13 @@ begin
|
|||||||
Sender.ClassName);
|
Sender.ClassName);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
ActiveForm:=TDesigner(Sender).Form;
|
BeginCodeTool(TDesigner(Sender),ActiveSrcEdit,ActiveUnitInfo,true);
|
||||||
i:=Project1.IndexOfUnitWithForm(ActiveForm,false,nil);
|
|
||||||
if i<0 then begin
|
|
||||||
raise Exception.Create('[TMainIDE.OnDesignerComponentAdded] Error: '
|
|
||||||
+'form without source');
|
|
||||||
end;
|
|
||||||
ActiveUnitInfo:=Project1.Units[i];
|
|
||||||
|
|
||||||
// add needed unit to source
|
// add needed unit to source
|
||||||
CodeToolBoss.AddUnitToMainUsesSection(ActiveUnitInfo.Source,
|
CodeToolBoss.AddUnitToMainUsesSection(ActiveUnitInfo.Source,
|
||||||
AComponentClass.UnitName,'');
|
AComponentClass.UnitName,'');
|
||||||
// add component definition to form source
|
// add component definition to form source
|
||||||
FormClassName:=ActiveForm.ClassName;
|
FormClassName:=TDesigner(Sender).Form.ClassName;
|
||||||
if not CodeToolBoss.PublishedVariableExists(ActiveUnitInfo.Source,
|
if not CodeToolBoss.PublishedVariableExists(ActiveUnitInfo.Source,
|
||||||
FormClassName,AComponent.Name) then begin
|
FormClassName,AComponent.Name) then begin
|
||||||
// ! AddPublishedVariable does not rebuild the CodeTree, so we need
|
// ! AddPublishedVariable does not rebuild the CodeTree, so we need
|
||||||
@ -5589,8 +5647,10 @@ procedure TMainIDE.OnDesignerRemoveComponent(Sender: TObject;
|
|||||||
var i: integer;
|
var i: integer;
|
||||||
ActiveForm: TCustomForm;
|
ActiveForm: TCustomForm;
|
||||||
ActiveUnitInfo: TUnitInfo;
|
ActiveUnitInfo: TUnitInfo;
|
||||||
|
ActiveSrcEdit: TSourceEditor;
|
||||||
FormClassName: string;
|
FormClassName: string;
|
||||||
begin
|
begin
|
||||||
|
BeginCodeTool(TDesigner(Sender),ActiveSrcEdit,ActiveUnitInfo,true);
|
||||||
ActiveForm:=TDesigner(Sender).Form;
|
ActiveForm:=TDesigner(Sender).Form;
|
||||||
if ActiveForm=nil then begin
|
if ActiveForm=nil then begin
|
||||||
writeln('[TMainIDE.OnDesignerAddComponent] Error: TDesigner without a form');
|
writeln('[TMainIDE.OnDesignerAddComponent] Error: TDesigner without a form');
|
||||||
@ -5814,11 +5874,20 @@ end;
|
|||||||
|
|
||||||
function TMainIDE.BeginCodeTool(var ActiveSrcEdit: TSourceEditor;
|
function TMainIDE.BeginCodeTool(var ActiveSrcEdit: TSourceEditor;
|
||||||
var ActiveUnitInfo: TUnitInfo; SwitchToFormSrc: boolean): boolean;
|
var ActiveUnitInfo: TUnitInfo; SwitchToFormSrc: boolean): boolean;
|
||||||
|
begin
|
||||||
|
Result:=BeginCodeTool(nil,ActiveSrcEdit,ActiveUnitInfo,SwitchToFormSrc);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TMainIDE.BeginCodeTool(ADesigner: TDesigner;
|
||||||
|
var ActiveSrcEdit: TSourceEditor; var ActiveUnitInfo: TUnitInfo;
|
||||||
|
SwitchToFormSrc: boolean): boolean;
|
||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
if SourceNoteBook.NoteBook=nil then exit;
|
if SourceNoteBook.NoteBook=nil then exit;
|
||||||
if SwitchToFormSrc then
|
if SwitchToFormSrc then
|
||||||
DoSwitchToFormSrc(ActiveSrcEdit,ActiveUnitInfo)
|
DoSwitchToFormSrc(ADesigner,ActiveSrcEdit,ActiveUnitInfo)
|
||||||
|
else if Designer<>nil then
|
||||||
|
GetDesignerUnit(ADesigner,ActiveSrcEdit,ActiveUnitInfo)
|
||||||
else
|
else
|
||||||
GetCurrentUnit(ActiveSrcEdit,ActiveUnitInfo);
|
GetCurrentUnit(ActiveSrcEdit,ActiveUnitInfo);
|
||||||
if (ActiveSrcEdit=nil) or (ActiveUnitInfo=nil) then exit;
|
if (ActiveSrcEdit=nil) or (ActiveUnitInfo=nil) then exit;
|
||||||
@ -6190,7 +6259,7 @@ end;
|
|||||||
Procedure TMainIDE.OnDesignerActivated(Sender : TObject);
|
Procedure TMainIDE.OnDesignerActivated(Sender : TObject);
|
||||||
begin
|
begin
|
||||||
FCodeLastActivated:=False;
|
FCodeLastActivated:=False;
|
||||||
FLastFormActivated := TCustomForm(Sender);
|
FLastFormActivated := TDesigner(Sender).Form;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMainIDE.OnDesignerRenameComponent(ADesigner: TDesigner;
|
procedure TMainIDE.OnDesignerRenameComponent(ADesigner: TDesigner;
|
||||||
@ -6212,7 +6281,7 @@ var
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
BeginCodeTool(ActiveSrcEdit,ActiveUnitInfo,false);
|
BeginCodeTool(ADesigner,ActiveSrcEdit,ActiveUnitInfo,true);
|
||||||
ActiveUnitInfo:=Project1.UnitWithForm(ADesigner.Form);
|
ActiveUnitInfo:=Project1.UnitWithForm(ADesigner.Form);
|
||||||
if CodeToolBoss.IsKeyWord(ActiveUnitInfo.Source,NewName) then
|
if CodeToolBoss.IsKeyWord(ActiveUnitInfo.Source,NewName) then
|
||||||
raise Exception.Create('Component name "'+Newname+'" is keyword');
|
raise Exception.Create('Component name "'+Newname+'" is keyword');
|
||||||
@ -6492,17 +6561,26 @@ end;
|
|||||||
|
|
||||||
procedure TMainIDE.DoSwitchToFormSrc(var ActiveSourceEditor: TSourceEditor;
|
procedure TMainIDE.DoSwitchToFormSrc(var ActiveSourceEditor: TSourceEditor;
|
||||||
var ActiveUnitInfo: TUnitInfo);
|
var ActiveUnitInfo: TUnitInfo);
|
||||||
|
begin
|
||||||
|
DoSwitchToFormSrc(nil,ActiveSourceEditor,ActiveUnitInfo);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TMainIDE.DoSwitchToFormSrc(ADesigner: TDesigner;
|
||||||
|
var ActiveSourceEditor: TSourceEditor; var ActiveUnitInfo: TUnitInfo);
|
||||||
var i: integer;
|
var i: integer;
|
||||||
begin
|
begin
|
||||||
if PropertyEditorHook1.LookupRoot<>nil then begin
|
if (ADesigner<>nil) then
|
||||||
i:=Project1.IndexOfUnitWithForm(PropertyEditorHook1.LookupRoot,false,nil);
|
i:=Project1.IndexOfUnitWithForm(ADesigner.Form,false,nil)
|
||||||
|
else if PropertyEditorHook1.LookupRoot<>nil then
|
||||||
|
i:=Project1.IndexOfUnitWithForm(PropertyEditorHook1.LookupRoot,false,nil)
|
||||||
|
else
|
||||||
|
i:=-1;
|
||||||
|
if (i>=0) then begin
|
||||||
|
i:=Project1.Units[i].EditorIndex;
|
||||||
if (i>=0) then begin
|
if (i>=0) then begin
|
||||||
i:=Project1.Units[i].EditorIndex;
|
SourceNoteBook.NoteBook.PageIndex:=i;
|
||||||
if (i>=0) then begin
|
GetCurrentUnit(ActiveSourceEditor,ActiveUnitInfo);
|
||||||
SourceNoteBook.NoteBook.PageIndex:=i;
|
exit;
|
||||||
GetCurrentUnit(ActiveSourceEditor,ActiveUnitInfo);
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
ActiveSourceEditor:=nil;
|
ActiveSourceEditor:=nil;
|
||||||
@ -6814,6 +6892,9 @@ end.
|
|||||||
|
|
||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.367 2002/09/09 12:36:34 lazarus
|
||||||
|
MG: added keymapping to designer
|
||||||
|
|
||||||
Revision 1.366 2002/09/08 12:23:40 lazarus
|
Revision 1.366 2002/09/08 12:23:40 lazarus
|
||||||
MG: TComponentPropertyEditor now shows child properties
|
MG: TComponentPropertyEditor now shows child properties
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user