mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 13:17:18 +02:00
IDE: source editor: set ifdef node states on page changed
git-svn-id: trunk@41185 -
This commit is contained in:
parent
5878ba9053
commit
f83e1b7112
@ -1429,7 +1429,7 @@ begin
|
|||||||
CurDirective^.State:=lsdsSkipped;
|
CurDirective^.State:=lsdsSkipped;
|
||||||
CurDirective^.CleanPos:=CommentStartPos-CopiedSrcPos+CleanedLen;
|
CurDirective^.CleanPos:=CommentStartPos-CopiedSrcPos+CleanedLen;
|
||||||
CurDirective^.Code:=Code;
|
CurDirective^.Code:=Code;
|
||||||
CurDirective^.SrcPos:=SrcPos;
|
CurDirective^.SrcPos:=CommentStartPos;
|
||||||
CurDirective^.Level:=IfLevel;
|
CurDirective^.Level:=IfLevel;
|
||||||
inc(FDirectivesCount);
|
inc(FDirectivesCount);
|
||||||
end;
|
end;
|
||||||
|
@ -45,7 +45,7 @@ uses
|
|||||||
SynEditMouseCmds, Classes, SysUtils, Math, Controls, ExtendedNotebook,
|
SynEditMouseCmds, Classes, SysUtils, Math, Controls, ExtendedNotebook,
|
||||||
LCLProc, LCLType, LResources, LCLIntf, FileUtil, Forms, ComCtrls, Dialogs,
|
LCLProc, LCLType, LResources, LCLIntf, FileUtil, Forms, ComCtrls, Dialogs,
|
||||||
StdCtrls, Graphics, Translations, ClipBrd, types, Extctrls, Menus, HelpIntfs,
|
StdCtrls, Graphics, Translations, ClipBrd, types, Extctrls, Menus, HelpIntfs,
|
||||||
LConvEncoding, Messages, LazLoggerBase, lazutf8classes,
|
LConvEncoding, Messages, LazLoggerBase, lazutf8classes, LazLogger,
|
||||||
// codetools
|
// codetools
|
||||||
BasicCodeTools, CodeBeautifier, CodeToolManager, CodeCache, SourceLog,
|
BasicCodeTools, CodeBeautifier, CodeToolManager, CodeCache, SourceLog,
|
||||||
LinkScanner,
|
LinkScanner,
|
||||||
@ -2622,18 +2622,36 @@ var
|
|||||||
LastSortedIndex: integer;
|
LastSortedIndex: integer;
|
||||||
aDirective: PLSDirective;
|
aDirective: PLSDirective;
|
||||||
Scanner: TLinkScanner;
|
Scanner: TLinkScanner;
|
||||||
|
CleanPos: integer;
|
||||||
begin
|
begin
|
||||||
Result:=idnInvalid;
|
Result:=idnInvalid;
|
||||||
debugln(['TSourceEditorSharedValues.GetIfDefNodeState x=',x,' y=',y,' ',Filename]);
|
//debugln(['TSourceEditorSharedValues.GetIfDefNodeState x=',x,' y=',y,' ',Filename]);
|
||||||
CodeBuffer.LineColToPosition(y,x,p);
|
CodeBuffer.LineColToPosition(y,x,p);
|
||||||
if p<1 then begin
|
if p<1 then begin
|
||||||
debugln(['TSourceEditorSharedValues.GetIfDefNodeState out of code x=',x,' y=',y,' ',Filename]);
|
debugln(['TSourceEditorSharedValues.GetIfDefNodeState out of code x=',x,' y=',y,' ',Filename]);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
Scanner:=GetMainLinkScanner(true);
|
Scanner:=GetMainLinkScanner(true);
|
||||||
|
case Scanner.CursorToCleanPos(p,CodeBuffer,CleanPos) of
|
||||||
|
-1:
|
||||||
|
begin
|
||||||
|
// CursorPos was skipped, CleanPos between two links
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
1:
|
||||||
|
begin
|
||||||
|
// CursorPos beyond scanned code
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
if not Scanner.FindDirective(CodeBuffer,p,FirstSortedIndex,LastSortedIndex)
|
if not Scanner.FindDirective(CodeBuffer,p,FirstSortedIndex,LastSortedIndex)
|
||||||
then begin
|
then begin
|
||||||
debugln(['TSourceEditorSharedValues.GetIfDefNodeState no directive at x=',x,' y=',y,' ',Filename]);
|
debugln(['TSourceEditorSharedValues.GetIfDefNodeState no directive at x=',x,' y=',y,' SrcPos=',p,' ',Filename,' Line="',CodeBuffer.GetLine(y-1),'" CleanSrc="',DbgStr(Scanner.CleanedSrc,CleanPos-15,15),'|',dbgstr(Scanner.CleanedSrc,CleanPos,15),'"']);
|
||||||
|
{for i:=0 to Scanner.DirectiveCount-1 do begin
|
||||||
|
aDirective:=Scanner.DirectivesSorted[i];
|
||||||
|
if TCodeBuffer(aDirective^.Code)<>CodeBuffer then continue;
|
||||||
|
debugln(['TSourceEditorSharedValues.GetIfDefNodeState CleanPos=',aDirective^.CleanPos,' SrcPos=',aDirective^.SrcPos,' Src="',dbgstr(CodeBuffer.Source,aDirective^.SrcPos,30),'"']);
|
||||||
|
end;}
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
if FirstSortedIndex<LastSortedIndex then begin
|
if FirstSortedIndex<LastSortedIndex then begin
|
||||||
@ -5445,8 +5463,8 @@ begin
|
|||||||
case aDirective^.State of
|
case aDirective^.State of
|
||||||
lsdsActive: SynState:=idnEnabled;
|
lsdsActive: SynState:=idnEnabled;
|
||||||
lsdsInactive: SynState:=idnDisabled;
|
lsdsInactive: SynState:=idnDisabled;
|
||||||
lsdsSkipped: SynState:=idnInvalid;
|
|
||||||
end;
|
end;
|
||||||
|
debugln(['TSourceEditor.UpdateIfDefNodeStates y=',y,' x=',x,' ',dbgs(aDirective^.State)]);
|
||||||
EditorComponent.SetIfdefNodeState(Y,X,SynState);
|
EditorComponent.SetIfdefNodeState(Y,X,SynState);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -7903,7 +7921,7 @@ end;
|
|||||||
|
|
||||||
procedure TSourceNotebook.NotebookPageChanged(Sender: TObject);
|
procedure TSourceNotebook.NotebookPageChanged(Sender: TObject);
|
||||||
var
|
var
|
||||||
TempEditor:TSourceEditor;
|
SrcEdit:TSourceEditor;
|
||||||
CaretXY: TPoint;
|
CaretXY: TPoint;
|
||||||
TopLine: Integer;
|
TopLine: Integer;
|
||||||
Begin
|
Begin
|
||||||
@ -7916,41 +7934,44 @@ Begin
|
|||||||
DebugBoss.LockCommandProcessing;
|
DebugBoss.LockCommandProcessing;
|
||||||
try
|
try
|
||||||
Exclude(States, snNotbookPageChangedNeeded);
|
Exclude(States, snNotbookPageChangedNeeded);
|
||||||
TempEditor:=GetActiveSE;
|
SrcEdit:=GetActiveSE;
|
||||||
if (FHintWindow <> nil) and FHintWindow.Visible then
|
if (FHintWindow <> nil) and FHintWindow.Visible then
|
||||||
HideHint;
|
HideHint;
|
||||||
|
|
||||||
DebugLn(SRCED_PAGES, ['TSourceNotebook.NotebookPageChanged TempEdit=', DbgSName(TempEditor)]);
|
DebugLn(SRCED_PAGES, ['TSourceNotebook.NotebookPageChanged TempEdit=', DbgSName(SrcEdit)]);
|
||||||
if TempEditor <> nil then
|
if SrcEdit <> nil then
|
||||||
begin
|
begin
|
||||||
if not TempEditor.Visible then begin
|
if not SrcEdit.Visible then begin
|
||||||
// As long as SynEdit had no Handle, it had kept all those Values untouched
|
// As long as SynEdit had no Handle, it had kept all those Values untouched
|
||||||
CaretXY := TempEditor.EditorComponent.CaretXY;
|
CaretXY := SrcEdit.EditorComponent.CaretXY;
|
||||||
TopLine := TempEditor.EditorComponent.TopLine;
|
TopLine := SrcEdit.EditorComponent.TopLine;
|
||||||
TSynEditMarkupManager(TempEditor.EditorComponent.MarkupMgr).IncPaintLock;
|
TSynEditMarkupManager(SrcEdit.EditorComponent.MarkupMgr).IncPaintLock;
|
||||||
TempEditor.BeginUpdate;
|
SrcEdit.BeginUpdate;
|
||||||
TempEditor.Visible := True;
|
{$IFDEF WithSynMarkupIfDef}
|
||||||
TempEditor.EndUpdate;
|
SrcEdit.UpdateIfDefNodeStates;
|
||||||
|
{$ENDIF}
|
||||||
|
SrcEdit.Visible := True;
|
||||||
|
SrcEdit.EndUpdate;
|
||||||
// Restore the intial Positions, must be after lock
|
// Restore the intial Positions, must be after lock
|
||||||
TempEditor.EditorComponent.LeftChar := 1;
|
SrcEdit.EditorComponent.LeftChar := 1;
|
||||||
TempEditor.EditorComponent.CaretXY := CaretXY;
|
SrcEdit.EditorComponent.CaretXY := CaretXY;
|
||||||
TempEditor.EditorComponent.TopLine := TopLine;
|
SrcEdit.EditorComponent.TopLine := TopLine;
|
||||||
TSynEditMarkupManager(TempEditor.EditorComponent.MarkupMgr).DecPaintLock;
|
TSynEditMarkupManager(SrcEdit.EditorComponent.MarkupMgr).DecPaintLock;
|
||||||
end;
|
end;
|
||||||
if (fAutoFocusLock=0) and (Screen.ActiveCustomForm=GetParentForm(Self)) and
|
if (fAutoFocusLock=0) and (Screen.ActiveCustomForm=GetParentForm(Self)) and
|
||||||
not(Manager.HasAutoFocusLock)
|
not(Manager.HasAutoFocusLock)
|
||||||
then
|
then
|
||||||
begin
|
begin
|
||||||
DebugLnEnter(SRCED_PAGES, ['TSourceNotebook.NotebookPageChanged BEFORE SetFocus ', DbgSName(TempEditor.EditorComponent),' Page=', FindPageWithEditor(TempEditor), ' ', TempEditor.FileName]);
|
DebugLnEnter(SRCED_PAGES, ['TSourceNotebook.NotebookPageChanged BEFORE SetFocus ', DbgSName(SrcEdit.EditorComponent),' Page=', FindPageWithEditor(SrcEdit), ' ', SrcEdit.FileName]);
|
||||||
TempEditor.FocusEditor; // recursively calls NotebookPageChanged, via EditorEnter
|
SrcEdit.FocusEditor; // recursively calls NotebookPageChanged, via EditorEnter
|
||||||
DebugLnExit(SRCED_PAGES, ['TSourceNotebook.NotebookPageChanged AFTER SetFocus ', DbgSName(TempEditor.EditorComponent),' Page=', FindPageWithEditor(TempEditor)]);
|
DebugLnExit(SRCED_PAGES, ['TSourceNotebook.NotebookPageChanged AFTER SetFocus ', DbgSName(SrcEdit.EditorComponent),' Page=', FindPageWithEditor(SrcEdit)]);
|
||||||
end;
|
end;
|
||||||
UpdateStatusBar;
|
UpdateStatusBar;
|
||||||
UpdateActiveEditColors(TempEditor.EditorComponent);
|
UpdateActiveEditColors(SrcEdit.EditorComponent);
|
||||||
if (DebugBoss.State in [dsPause, dsRun]) and
|
if (DebugBoss.State in [dsPause, dsRun]) and
|
||||||
not TempEditor.HasExecutionMarks and
|
not SrcEdit.HasExecutionMarks and
|
||||||
(TempEditor.FileName <> '') then
|
(SrcEdit.FileName <> '') then
|
||||||
TempEditor.FillExecutionMarks;
|
SrcEdit.FillExecutionMarks;
|
||||||
DoActiveEditorChanged;
|
DoActiveEditorChanged;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user