synmemo, style changes

This commit is contained in:
Basile Burg 2017-03-12 10:53:05 +01:00
parent 64526231f8
commit a00ae4ea65
No known key found for this signature in database
GPG Key ID: 1868039F415CB8CF
1 changed files with 67 additions and 59 deletions

View File

@ -531,8 +531,9 @@ var
i, start, prev: Integer; i, start, prev: Integer;
itm : TCEFoldCache; itm : TCEFoldCache;
begin begin
if fMemo.isNil then exit; if fMemo.isNil then
// exit;
fCaretPosition := fMemo.SelStart; fCaretPosition := fMemo.SelStart;
fSourceFilename := fMemo.fileName; fSourceFilename := fMemo.fileName;
fSelectionEnd := fMemo.SelEnd; fSelectionEnd := fMemo.SelEnd;
@ -563,13 +564,16 @@ var
i: integer; i: integer;
itm : TCEFoldCache; itm : TCEFoldCache;
begin begin
if fMemo.isNil then exit; if fMemo.isNil then
// exit;
if fFontSize > 0 then if fFontSize > 0 then
fMemo.Font.Size := fFontSize; fMemo.Font.Size := fFontSize;
// Currently collisions are not handled. // Currently collisions are not handled.
if fMemo.fileName <> fSourceFilename then exit; if fMemo.fileName <> fSourceFilename then
// exit;
for i := 0 to fFolds.Count-1 do for i := 0 to fFolds.Count-1 do
begin begin
itm := TCEFoldCache(fFolds.Items[i]); itm := TCEFoldCache(fFolds.Items[i]);
@ -577,7 +581,7 @@ begin
continue; continue;
fMemo.TextView.FoldAtLine(itm.lineIndex-1); fMemo.TextView.FoldAtLine(itm.lineIndex-1);
end; end;
//
fMemo.SelStart := fCaretPosition; fMemo.SelStart := fCaretPosition;
fMemo.SelEnd := fSelectionEnd; fMemo.SelEnd := fSelectionEnd;
end; end;
@ -590,9 +594,9 @@ var
chksm: Cardinal; chksm: Cardinal;
begin begin
tempn := fMemo.fileName; tempn := fMemo.fileName;
if tempn = fMemo.tempFilename then exit; if (tempn = fMemo.tempFilename) or (not tempn.fileExists) then
if not tempn.fileExists then exit; exit;
//
fname := getCoeditDocPath + 'editorcache' + DirectorySeparator; fname := getCoeditDocPath + 'editorcache' + DirectorySeparator;
ForceDirectories(fname); ForceDirectories(fname);
chksm := crc32(0, nil, 0); chksm := crc32(0, nil, 0);
@ -608,14 +612,16 @@ var
chksm: Cardinal; chksm: Cardinal;
begin begin
tempn := fMemo.fileName; tempn := fMemo.fileName;
if not tempn.fileExists then exit; if not tempn.fileExists then
// exit;
fname := getCoeditDocPath + 'editorcache' + DirectorySeparator; fname := getCoeditDocPath + 'editorcache' + DirectorySeparator;
chksm := crc32(0, nil, 0); chksm := crc32(0, nil, 0);
chksm := crc32(chksm, @tempn[1], tempn.length); chksm := crc32(chksm, @tempn[1], tempn.length);
fname := fname + format('%.8X.txt', [chksm]); fname := fname + format('%.8X.txt', [chksm]);
//
if not fname.fileExists then exit; if not fname.fileExists then
exit;
loadFromFile(fname); loadFromFile(fname);
end; end;
{$IFDEF DEBUG}{$R+}{$ENDIF} {$IFDEF DEBUG}{$R+}{$ENDIF}
@ -683,16 +689,16 @@ end;
constructor TCESynMemo.Create(aOwner: TComponent); constructor TCESynMemo.Create(aOwner: TComponent);
begin begin
inherited; inherited;
//
OnStatusChange:= @handleStatusChanged; OnStatusChange:= @handleStatusChanged;
fDefaultFontSize := 10; fDefaultFontSize := 10;
Font.Size:=10; Font.Size:=10;
SetDefaultCoeditKeystrokes(Self); // not called in inherited if owner = nil ! SetDefaultCoeditKeystrokes(Self); // not called in inherited if owner = nil !
fLexToks:= TLexTokenList.Create; fLexToks:= TLexTokenList.Create;
//
OnDragDrop:= @ddHandler.DragDrop; OnDragDrop:= @ddHandler.DragDrop;
OnDragOver:= @ddHandler.DragOver; OnDragOver:= @ddHandler.DragOver;
//
ShowHint := false; ShowHint := false;
InitHintWins; InitHintWins;
fDDocDelay := 200; fDDocDelay := 200;
@ -700,13 +706,13 @@ begin
fDDocTimer.AutoEnabled:=true; fDDocTimer.AutoEnabled:=true;
fDDocTimer.Interval := fDDocDelay; fDDocTimer.Interval := fDDocDelay;
fDDocTimer.OnTimer := @DDocTimerEvent; fDDocTimer.OnTimer := @DDocTimerEvent;
//
fAutoDotDelay := 20; fAutoDotDelay := 20;
fAutoDotTimer := TIdleTimer.Create(self); fAutoDotTimer := TIdleTimer.Create(self);
fAutoDotTimer.AutoEnabled:=true; fAutoDotTimer.AutoEnabled:=true;
fAutoDotTimer.Interval := fAutoDotDelay; fAutoDotTimer.Interval := fAutoDotDelay;
fAutoDotTimer.OnTimer := @AutoDotTimerEvent; fAutoDotTimer.OnTimer := @AutoDotTimerEvent;
//
Gutter.LineNumberPart.ShowOnlyLineNumbersMultiplesOf := 5; Gutter.LineNumberPart.ShowOnlyLineNumbersMultiplesOf := 5;
Gutter.LineNumberPart.MarkupInfo.Foreground := clWindowText; Gutter.LineNumberPart.MarkupInfo.Foreground := clWindowText;
Gutter.LineNumberPart.MarkupInfo.Background := clBtnFace; Gutter.LineNumberPart.MarkupInfo.Background := clBtnFace;
@ -714,12 +720,12 @@ begin
Gutter.SeparatorPart.LineWidth := 1; Gutter.SeparatorPart.LineWidth := 1;
Gutter.OnGutterClick:= @gutterClick; Gutter.OnGutterClick:= @gutterClick;
BracketMatchColor.Foreground:=clRed; BracketMatchColor.Foreground:=clRed;
//
fSyncEdit := TSynPluginSyncroEdit.Create(self); fSyncEdit := TSynPluginSyncroEdit.Create(self);
fSyncEdit.Editor := self; fSyncEdit.Editor := self;
fSyncEdit.CaseSensitive := true; fSyncEdit.CaseSensitive := true;
AssignPng(fSyncEdit.GutterGlyph, 'LINK_EDIT'); AssignPng(fSyncEdit.GutterGlyph, 'LINK_EDIT');
//
fCompletion := TSyncompletion.create(nil); fCompletion := TSyncompletion.create(nil);
fCompletion.ShowSizeDrag := true; fCompletion.ShowSizeDrag := true;
fCompletion.Editor := Self; fCompletion.Editor := Self;
@ -734,23 +740,23 @@ begin
fCompletion.LinesInWindow:=15; fCompletion.LinesInWindow:=15;
fCompletion.Width:= 250; fCompletion.Width:= 250;
fCallTipStrings:= TStringList.Create; fCallTipStrings:= TStringList.Create;
//
MouseLinkColor.Style:= [fsUnderline]; MouseLinkColor.Style:= [fsUnderline];
with MouseActions.Add do begin with MouseActions.Add do begin
Command := emcMouseLink; Command := emcMouseLink;
shift := [ssCtrl]; shift := [ssCtrl];
ShiftMask := [ssCtrl]; ShiftMask := [ssCtrl];
end; end;
//
fD2Highlighter := TSynD2Syn.create(self); fD2Highlighter := TSynD2Syn.create(self);
fTxtHighlighter := TSynTxtSyn.Create(self); fTxtHighlighter := TSynTxtSyn.Create(self);
Highlighter := fD2Highlighter; Highlighter := fD2Highlighter;
//
fTempFileName := GetTempDir(false) + 'temp_' + uniqueObjStr(self) + '.d'; fTempFileName := GetTempDir(false) + 'temp_' + uniqueObjStr(self) + '.d';
fFilename := '<new document>'; fFilename := '<new document>';
fModified := false; fModified := false;
TextBuffer.AddNotifyHandler(senrUndoRedoAdded, @changeNotify); TextBuffer.AddNotifyHandler(senrUndoRedoAdded, @changeNotify);
//
fImages := TImageList.Create(self); fImages := TImageList.Create(self);
fImages.AddResourceName(HINSTANCE, 'BULLET_RED'); fImages.AddResourceName(HINSTANCE, 'BULLET_RED');
fImages.AddResourceName(HINSTANCE, 'BULLET_GREEN'); fImages.AddResourceName(HINSTANCE, 'BULLET_GREEN');
@ -759,28 +765,28 @@ begin
fImages.AddResourceName(HINSTANCE, 'STEP'); fImages.AddResourceName(HINSTANCE, 'STEP');
fImages.AddResourceName(HINSTANCE, 'CAMERA_GO'); fImages.AddResourceName(HINSTANCE, 'CAMERA_GO');
fBreakPoints := TFPList.Create; fBreakPoints := TFPList.Create;
//
fPositions := TCESynMemoPositions.create(self); fPositions := TCESynMemoPositions.create(self);
fMultiDocSubject := TCEMultiDocSubject.create; fMultiDocSubject := TCEMultiDocSubject.create;
//
HighlightAllColor.Foreground := clNone; HighlightAllColor.Foreground := clNone;
HighlightAllColor.Background := clSilver; HighlightAllColor.Background := clSilver;
HighlightAllColor.BackAlpha := 70; HighlightAllColor.BackAlpha := 70;
IdentifierMatchOptions:= [caseSensitive]; IdentifierMatchOptions:= [caseSensitive];
//
LineHighlightColor.Background := color - $080808; LineHighlightColor.Background := color - $080808;
LineHighlightColor.Foreground := clNone; LineHighlightColor.Foreground := clNone;
//
//fIndentGuideMarkup:= TSynEditMarkupFoldColors.Create(self); //fIndentGuideMarkup:= TSynEditMarkupFoldColors.Create(self);
//MarkupManager.AddMarkUp(fIndentGuideMarkup); //MarkupManager.AddMarkUp(fIndentGuideMarkup);
//
fAutoCloseCurlyBrace:= autoCloseOnNewLineLexically; fAutoCloseCurlyBrace:= autoCloseOnNewLineLexically;
fAutoClosedPairs:= [autoCloseSquareBracket]; fAutoClosedPairs:= [autoCloseSquareBracket];
//
fDastWorxExename:= exeFullName('dastworx' + exeExt); fDastWorxExename:= exeFullName('dastworx' + exeExt);
//
fDebugger := EntitiesConnector.getSingleService('ICEDebugger') as ICEDebugger; fDebugger := EntitiesConnector.getSingleService('ICEDebugger') as ICEDebugger;
//
subjDocNew(TCEMultiDocSubject(fMultiDocSubject), self); subjDocNew(TCEMultiDocSubject(fMultiDocSubject), self);
EntitiesConnector.addObserver(self); EntitiesConnector.addObserver(self);
end; end;
@ -788,7 +794,7 @@ end;
destructor TCESynMemo.destroy; destructor TCESynMemo.destroy;
begin begin
saveCache; saveCache;
//
//fIndentGuideMarkup.Free; //fIndentGuideMarkup.Free;
EntitiesConnector.removeObserver(self); EntitiesConnector.removeObserver(self);
subjDocClosing(TCEMultiDocSubject(fMultiDocSubject), self); subjDocClosing(TCEMultiDocSubject(fMultiDocSubject), self);
@ -800,10 +806,10 @@ begin
fLexToks.Clear; fLexToks.Clear;
fLexToks.Free; fLexToks.Free;
fSortDialog.Free; fSortDialog.Free;
//
if fTempFileName.fileExists then if fTempFileName.fileExists then
sysutils.DeleteFile(fTempFileName); sysutils.DeleteFile(fTempFileName);
//
inherited; inherited;
end; end;
@ -812,7 +818,8 @@ var
old: Integer; old: Integer;
begin begin
old := Font.Size; old := Font.Size;
if value < 5 then value := 5; if value < 5 then
value := 5;
fDefaultFontSize:= value; fDefaultFontSize:= value;
if Font.Size = old then if Font.Size = old then
Font.Size := fDefaultFontSize; Font.Size := fDefaultFontSize;
@ -872,9 +879,10 @@ end;
{$REGION Custom editor commands and shortcuts ----------------------------------} {$REGION Custom editor commands and shortcuts ----------------------------------}
procedure SetDefaultCoeditKeystrokes(ed: TSynEdit); procedure SetDefaultCoeditKeystrokes(ed: TSynEdit);
begin begin
with ed do begin with ed do
begin
Keystrokes.Clear; Keystrokes.Clear;
//
AddKey(ecUp, VK_UP, [], 0, []); AddKey(ecUp, VK_UP, [], 0, []);
AddKey(ecSelUp, VK_UP, [ssShift], 0, []); AddKey(ecSelUp, VK_UP, [ssShift], 0, []);
AddKey(ecScrollUp, VK_UP, [ssCtrl], 0, []); AddKey(ecScrollUp, VK_UP, [ssCtrl], 0, []);
@ -1357,17 +1365,17 @@ begin
for i := fLexToks.Count-1 downto 2 do for i := fLexToks.Count-1 downto 2 do
begin begin
tok := PLexToken(fLexToks[i]); tok := PLexToken(fLexToks[i]);
//
if sel and ((tok^.position.Y < st.Y) if sel and ((tok^.position.Y < st.Y)
or (tok^.position.Y > nd.Y)) then or (tok^.position.Y > nd.Y)) then
continue; continue;
if ((tok^.Data <> 'all') and (tok^.Data <> 'none')) if ((tok^.Data <> 'all') and (tok^.Data <> 'none'))
or (tok^.kind <> ltkIdentifier) or (i < 2) then or (tok^.kind <> ltkIdentifier) or (i < 2) then
continue; continue;
//
tok1 := PLexToken(fLexToks[i-2]); tok1 := PLexToken(fLexToks[i-2]);
tok2 := PLexToken(fLexToks[i-1]); tok2 := PLexToken(fLexToks[i-1]);
//
if ((tok1^.kind = ltkKeyword) and (tok1^.data = 'version') if ((tok1^.kind = ltkKeyword) and (tok1^.data = 'version')
and (tok2^.kind = ltkSymbol) and (tok2^.data = '(')) then and (tok2^.kind = ltkSymbol) and (tok2^.data = '(')) then
begin begin
@ -1413,12 +1421,12 @@ begin
dlgOkInfo('Unknown, ambiguous or non-local symbol for "'+ old +'"'); dlgOkInfo('Unknown, ambiguous or non-local symbol for "'+ old +'"');
exit; exit;
end; end;
//
idt := 'new identifier for "' + old + '"'; idt := 'new identifier for "' + old + '"';
idt := InputBox('Local identifier renaming', idt, old); idt := InputBox('Local identifier renaming', idt, old);
if idt.isEmpty or idt.isBlank then if idt.isEmpty or idt.isBlank then
exit; exit;
//
for i:= high(locs) downto 0 do for i:= high(locs) downto 0 do
begin begin
loc := locs[i]; loc := locs[i];
@ -1908,10 +1916,9 @@ procedure TCESynMemo.showCallTips(const tips: string);
var var
pnt: TPoint; pnt: TPoint;
begin begin
if not fIsDSource and not alwaysAdvancedFeatures then if (not fIsDSource and not alwaysAdvancedFeatures) or tips.isEmpty then
exit; exit;
if tips.isEmpty then exit;
//
pnt := ClientToScreen(point(CaretXPix, CaretYPix)); pnt := ClientToScreen(point(CaretXPix, CaretYPix));
fCallTipWin.FontSize := Font.Size; fCallTipWin.FontSize := Font.Size;
fCallTipWin.HintRect := fCallTipWin.CalcHintRect(0, tips, nil); fCallTipWin.HintRect := fCallTipWin.CalcHintRect(0, tips, nil);
@ -1948,7 +1955,7 @@ begin
if not fIsDSource and not alwaysAdvancedFeatures then if not fIsDSource and not alwaysAdvancedFeatures then
exit; exit;
DcdWrapper.getDdocFromCursor(str); DcdWrapper.getDdocFromCursor(str);
//
if str.isNotEmpty then if str.isNotEmpty then
begin begin
fDDocWin.FontSize := Font.Size; fDDocWin.FontSize := Font.Size;
@ -1972,10 +1979,9 @@ end;
procedure TCESynMemo.DDocTimerEvent(sender: TObject); procedure TCESynMemo.DDocTimerEvent(sender: TObject);
begin begin
if not Visible then exit; if (not Visible) or (not isDSource) or (not fCanShowHint) then
if not isDSource then exit; exit;
//
if not fCanShowHint then exit;
showDDocs; showDDocs;
end; end;
{$ENDREGION --------------------------------------------------------------------} {$ENDREGION --------------------------------------------------------------------}
@ -1996,8 +2002,9 @@ var
i: integer; i: integer;
o: TObject; o: TObject;
begin begin
if not DcdWrapper.available then exit; if not DcdWrapper.available then
// exit;
fCompletion.Position := 0; fCompletion.Position := 0;
fCompletion.ItemList.Clear; fCompletion.ItemList.Clear;
DcdWrapper.getComplAtCursor(TStringList(fCompletion.ItemList)); DcdWrapper.getComplAtCursor(TStringList(fCompletion.ItemList));
@ -2062,8 +2069,9 @@ end;
procedure TCESynMemo.AutoDotTimerEvent(sender: TObject); procedure TCESynMemo.AutoDotTimerEvent(sender: TObject);
begin begin
if not fCanAutoDot then exit; if (not fCanAutoDot) or (fAutoDotDelay = 0) then
if fAutoDotDelay = 0 then exit; exit;
fCanAutoDot := false; fCanAutoDot := false;
fCompletion.Execute('', ClientToScreen(point(CaretXPix, CaretYPix + LineHeight))); fCompletion.Execute('', ClientToScreen(point(CaretXPix, CaretYPix + LineHeight)));
end; end;
@ -2221,7 +2229,7 @@ begin
fFilename := fname; fFilename := fname;
FileAge(fFilename, fFileDate); FileAge(fFilename, fFileDate);
ReadOnly := FileIsReadOnly(fFilename); ReadOnly := FileIsReadOnly(fFilename);
//
fModified := false; fModified := false;
if Showing then if Showing then
begin begin
@ -2419,7 +2427,7 @@ var
lne: string; lne: string;
i: integer; i: integer;
begin begin
//TODO-cCheck for changes made to option eoSpacesToTabs //TODO: Check for changes made to option eoSpacesToTabs
if not (eoTabsToSpaces in Options) then if not (eoTabsToSpaces in Options) then
exit; exit;
@ -2516,7 +2524,7 @@ begin
VK_OEM_PERIOD, VK_DECIMAL: fCanAutoDot := true; VK_OEM_PERIOD, VK_DECIMAL: fCanAutoDot := true;
end; end;
inherited; inherited;
//
if StaticEditorMacro.automatic then if StaticEditorMacro.automatic then
StaticEditorMacro.Execute; StaticEditorMacro.Execute;
end; end;