mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2026-01-04 01:40:31 +01:00
IDE: Always enable Source -> Use Unit feature. Also non-project units can be added through the dialog.
git-svn-id: trunk@31387 -
This commit is contained in:
parent
3e228ec5c1
commit
4bc2ef3c3c
115
ide/main.pp
115
ide/main.pp
@ -3848,76 +3848,65 @@ var
|
||||
AnUnitInfo: TUnitInfo;
|
||||
Editable, SelEditable, SelAvail, IdentFound, StringFound: Boolean;
|
||||
CurrentUnitName: String;
|
||||
AvailUnits: TStringList;
|
||||
StartCode, EndCode: TCodeBuffer;
|
||||
StartPos, EndPos: TPoint;
|
||||
NewX, NewY, NewTopLine: integer;
|
||||
CursorXY: TPoint;
|
||||
begin
|
||||
AvailUnits:=nil;
|
||||
try
|
||||
Editable:=False;
|
||||
SelAvail:=False;
|
||||
IdentFound:=False;
|
||||
StringFound:=False;
|
||||
if BeginCodeTool(ASrcEdit,AnUnitInfo,[]) then begin
|
||||
Assert(Assigned(ASrcEdit));
|
||||
Editable:=not ASrcEdit.ReadOnly;
|
||||
SelAvail:=ASrcEdit.SelectionAvailable;
|
||||
Editable:=False;
|
||||
SelAvail:=False;
|
||||
IdentFound:=False;
|
||||
StringFound:=False;
|
||||
if BeginCodeTool(ASrcEdit,AnUnitInfo,[]) then begin
|
||||
Assert(Assigned(ASrcEdit));
|
||||
Editable:=not ASrcEdit.ReadOnly;
|
||||
SelAvail:=ASrcEdit.SelectionAvailable;
|
||||
|
||||
// Get Available Units count to enable UseProjUnit feature.
|
||||
AvailUnits:=GetProjAvailableUnits(ASrcEdit, CurrentUnitName, true);
|
||||
// Try to find main identifier declaration to enable rename feature.
|
||||
CursorXY:=ASrcEdit.EditorComponent.LogicalCaretXY;
|
||||
IdentFound:=CodeToolBoss.FindMainDeclaration(AnUnitInfo.Source,
|
||||
CursorXY.X,CursorXY.Y,StartCode,NewX,NewY,NewTopLine);
|
||||
|
||||
// Try to find main identifier declaration to enable rename feature.
|
||||
CursorXY:=ASrcEdit.EditorComponent.LogicalCaretXY;
|
||||
IdentFound:=CodeToolBoss.FindMainDeclaration(AnUnitInfo.Source,
|
||||
CursorXY.X,CursorXY.Y,StartCode,NewX,NewY,NewTopLine);
|
||||
|
||||
// Calculate start and end of string expr to enable ResourceString feature.
|
||||
if ASrcEdit.EditorComponent.SelAvail then
|
||||
CursorXY:=ASrcEdit.EditorComponent.BlockBegin;
|
||||
if CodeToolBoss.GetStringConstBounds(AnUnitInfo.Source,CursorXY.X,CursorXY.Y,
|
||||
StartCode,StartPos.X,StartPos.Y,
|
||||
EndCode,EndPos.X,EndPos.Y,true) then
|
||||
StringFound:=(StartCode<>EndCode) or (CompareCaret(StartPos,EndPos)<>0);
|
||||
end;
|
||||
SelEditable:=Editable and SelAvail;
|
||||
with MainIDEBar do begin
|
||||
//itmSourceBlockActions
|
||||
itmSourceCommentBlock.Enabled:=SelEditable;
|
||||
itmSourceUncommentBlock.Enabled:=SelEditable;
|
||||
itmSourceEncloseBlock.Enabled:=SelEditable;
|
||||
itmSourceEncloseInIFDEF.Enabled:=SelEditable;
|
||||
itmSourceCompleteCode.Enabled:=Editable;
|
||||
itmSourceUseUnit.Enabled:=Editable and
|
||||
Assigned(AvailUnits) and (AvailUnits.Count>0);
|
||||
//itmSourceInsertions
|
||||
//itmSourceInsertCVSKeyWord
|
||||
itmSourceInsertCVSAuthor.Enabled:=Editable;
|
||||
itmSourceInsertCVSDate.Enabled:=Editable;
|
||||
itmSourceInsertCVSHeader.Enabled:=Editable;
|
||||
itmSourceInsertCVSID.Enabled:=Editable;
|
||||
itmSourceInsertCVSLog.Enabled:=Editable;
|
||||
itmSourceInsertCVSName.Enabled:=Editable;
|
||||
itmSourceInsertCVSRevision.Enabled:=Editable;
|
||||
itmSourceInsertCVSSource.Enabled:=Editable;
|
||||
//itmSourceInsertGeneral
|
||||
itmSourceInsertGPLNotice.Enabled:=Editable;
|
||||
itmSourceInsertLGPLNotice.Enabled:=Editable;
|
||||
itmSourceInsertModifiedLGPLNotice.Enabled:=Editable;
|
||||
itmSourceInsertUsername.Enabled:=Editable;
|
||||
itmSourceInsertDateTime.Enabled:=Editable;
|
||||
itmSourceInsertChangeLogEntry.Enabled:=Editable;
|
||||
//itmSourceRefactor
|
||||
//itmRefactorCodeTools
|
||||
itmRefactorRenameIdentifier.Enabled:=Editable and IdentFound;
|
||||
itmRefactorExtractProc.Enabled:=Editable and SelAvail;
|
||||
itmRefactorInvertAssignment.Enabled:=Editable and SelAvail;
|
||||
//itmRefactorAdvanced
|
||||
itmRefactorMakeResourceString.Enabled:=Editable and StringFound;
|
||||
end;
|
||||
finally
|
||||
AvailUnits.Free;
|
||||
// Calculate start and end of string expr to enable ResourceString feature.
|
||||
if ASrcEdit.EditorComponent.SelAvail then
|
||||
CursorXY:=ASrcEdit.EditorComponent.BlockBegin;
|
||||
if CodeToolBoss.GetStringConstBounds(AnUnitInfo.Source,CursorXY.X,CursorXY.Y,
|
||||
StartCode,StartPos.X,StartPos.Y,
|
||||
EndCode,EndPos.X,EndPos.Y,true) then
|
||||
StringFound:=(StartCode<>EndCode) or (CompareCaret(StartPos,EndPos)<>0);
|
||||
end;
|
||||
SelEditable:=Editable and SelAvail;
|
||||
with MainIDEBar do begin
|
||||
//itmSourceBlockActions
|
||||
itmSourceCommentBlock.Enabled:=SelEditable;
|
||||
itmSourceUncommentBlock.Enabled:=SelEditable;
|
||||
itmSourceEncloseBlock.Enabled:=SelEditable;
|
||||
itmSourceEncloseInIFDEF.Enabled:=SelEditable;
|
||||
itmSourceCompleteCode.Enabled:=Editable;
|
||||
//itmSourceInsertions
|
||||
//itmSourceInsertCVSKeyWord
|
||||
itmSourceInsertCVSAuthor.Enabled:=Editable;
|
||||
itmSourceInsertCVSDate.Enabled:=Editable;
|
||||
itmSourceInsertCVSHeader.Enabled:=Editable;
|
||||
itmSourceInsertCVSID.Enabled:=Editable;
|
||||
itmSourceInsertCVSLog.Enabled:=Editable;
|
||||
itmSourceInsertCVSName.Enabled:=Editable;
|
||||
itmSourceInsertCVSRevision.Enabled:=Editable;
|
||||
itmSourceInsertCVSSource.Enabled:=Editable;
|
||||
//itmSourceInsertGeneral
|
||||
itmSourceInsertGPLNotice.Enabled:=Editable;
|
||||
itmSourceInsertLGPLNotice.Enabled:=Editable;
|
||||
itmSourceInsertModifiedLGPLNotice.Enabled:=Editable;
|
||||
itmSourceInsertUsername.Enabled:=Editable;
|
||||
itmSourceInsertDateTime.Enabled:=Editable;
|
||||
itmSourceInsertChangeLogEntry.Enabled:=Editable;
|
||||
//itmSourceRefactor
|
||||
//itmRefactorCodeTools
|
||||
itmRefactorRenameIdentifier.Enabled:=Editable and IdentFound;
|
||||
itmRefactorExtractProc.Enabled:=Editable and SelAvail;
|
||||
itmRefactorInvertAssignment.Enabled:=Editable and SelAvail;
|
||||
//itmRefactorAdvanced
|
||||
itmRefactorMakeResourceString.Enabled:=Editable and StringFound;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user