diff --git a/Components/ScintEdit.pas b/Components/ScintEdit.pas index 47ac88d85..303d9d7fd 100644 --- a/Components/ScintEdit.pas +++ b/Components/ScintEdit.pas @@ -21,6 +21,7 @@ interface StyleNumberUnusedBits = 8-StyleNumberBits; { 3 bits of a byte are unused } type + TScintChangeHistory = (schDisabled, schMarkers, schIndicators); TScintEditAutoCompleteSelectionEvent = TNotifyEvent; TScintEditChangeInfo = record Inserting: Boolean; @@ -87,7 +88,7 @@ TScintEdit = class(TWinControl) FAcceptDroppedFiles: Boolean; FAutoCompleteFontName: String; FAutoCompleteFontSize: Integer; - FChangeHistory: Boolean; + FChangeHistory: TScintChangeHistory; FCodePage: Integer; FDirectPtr: Pointer; FDirectStatusFunction: SciFnDirectStatus; @@ -151,7 +152,7 @@ TScintEdit = class(TWinControl) procedure SetCaretLine(const Value: Integer); procedure SetCaretPosition(const Value: Integer); procedure SetCaretVirtualSpace(const Value: Integer); - procedure SetChangeHistory(const Value: Boolean); + procedure SetChangeHistory(const Value: TScintChangeHistory); procedure SetFillSelectionToEdge(const Value: Boolean); procedure SetIndentationGuides(const Value: TScintIndentationGuides); procedure SetLineNumbers(const Value: Boolean); @@ -264,6 +265,7 @@ TScintEdit = class(TWinControl) function IsPositionInViewVertically(const Pos: Integer): Boolean; procedure PasteFromClipboard; function RawSelTextEquals(const S: TScintRawString; const MatchCase: Boolean): Boolean; + class function RawStringIsBlank(const S: TScintRawString): Boolean; procedure Redo; procedure RemoveAdditionalSelections; function ReplaceRawTextRange(const StartPos, EndPos: Integer; @@ -337,7 +339,7 @@ TScintEdit = class(TWinControl) write SetAutoCompleteFontName; property AutoCompleteFontSize: Integer read FAutoCompleteFontSize write SetAutoCompleteFontSize default 0; - property ChangeHistory: Boolean read FChangeHistory write SetChangeHistory default False; + property ChangeHistory: TScintChangeHistory read FChangeHistory write SetChangeHistory default schDisabled; property CodePage: Integer read FCodePage write SetCodePage default CP_UTF8; property Color; property FillSelectionToEdge: Boolean read FFillSelectionToEdge write SetFillSelectionToEdge @@ -475,21 +477,11 @@ TScintPixmap = class property Pixmap: Pointer read GetPixmap; end; -function ScintRawStringIsBlank(const S: TScintRawString): Boolean; - implementation uses ShellAPI, RTLConsts, UITypes, GraphUtil; -function ScintRawStringIsBlank(const S: TScintRawString): Boolean; -begin - for var I := 1 to Length(S) do - if not(S[I] in [#9, ' ']) then - Exit(False); - Result := True; -end; - { TScintEdit } const @@ -546,9 +538,9 @@ procedure TScintEdit.ApplyOptions; Call(SCI_SETVIRTUALSPACEOPTIONS, Flags, 0); Call(SCI_SETWRAPMODE, Ord(FWordWrap), 0); Call(SCI_SETINDENTATIONGUIDES, IndentationGuides[FIndentationGuides], 0); - { If FChangeHistory is True then next call to ClearUndo will enable change - history and else we should disable it now } - if not FChangeHistory then + { If FChangeHistory is not schDisabled then next call to ClearUndo will enable + change history and else we should disable it now } + if FChangeHistory = schDisabled then Call(SCI_SETCHANGEHISTORY, SC_CHANGE_HISTORY_DISABLED, 0); end; @@ -558,7 +550,6 @@ procedure TScintEdit.BeginUndoAction; end; function TScintEdit.Call(Msg: Cardinal; WParam: Longint; LParam: Longint): Longint; - begin HandleNeeded; if FDirectPtr = nil then @@ -649,9 +640,14 @@ procedure TScintEdit.ClearUndo(const ClearChangeHistory: Boolean); SetSavePoint; Call(SCI_EMPTYUNDOBUFFER, 0, 0); - if ClearChangeHistory and FChangeHistory then begin + if ClearChangeHistory and (FChangeHistory <> schDisabled) then begin Call(SCI_SETCHANGEHISTORY, SC_CHANGE_HISTORY_DISABLED, 0); - Call(SCI_SETCHANGEHISTORY, SC_CHANGE_HISTORY_ENABLED or SC_CHANGE_HISTORY_MARKERS, 0); + var Flags := SC_CHANGE_HISTORY_ENABLED; + if FChangeHistory = schMarkers then + Flags := Flags or SC_CHANGE_HISTORY_MARKERS + else + Flags := Flags or SC_CHANGE_HISTORY_INDICATORS; + Call(SCI_SETCHANGEHISTORY, Flags, 0); end; end; @@ -726,7 +722,7 @@ procedure TScintEdit.CreateWnd; Call(SCI_SETMODEVENTMASK, SC_MOD_INSERTTEXT or SC_MOD_DELETETEXT, 0); Call(SCI_SETCARETPERIOD, GetCaretBlinkTime, 0); Call(SCI_SETSCROLLWIDTHTRACKING, 1, 0); - { The default popup menu conflicts with the VCL's PopupMenu on Delphi 3 } + { The default popup menu conflicts with the VCL's PopupMenu } Call(SCI_USEPOPUP, 0, 0); SetDefaultWordChars; ApplyOptions; @@ -815,7 +811,7 @@ function TScintEdit.FormatRange(const Draw: Boolean; procedure TScintEdit.ForwardMessage(const Message: TMessage); begin if HandleAllocated then - SendMessage(Handle, Message.Msg, Message.WParam, Message.LParam); + CallWindowProc(DefWndProc, Handle, Message.Msg, Message.WParam, Message.LParam); end; function TScintEdit.GetAutoCompleteActive: Boolean; @@ -1270,6 +1266,14 @@ function TScintEdit.RawSelTextEquals(const S: TScintRawString; end; end; +class function TScintEdit.RawStringIsBlank(const S: TScintRawString): Boolean; +begin + for var I := 1 to Length(S) do + if not(S[I] in [#9, ' ']) then + Exit(False); + Result := True; +end; + procedure TScintEdit.Redo; begin Call(SCI_REDO, 0, 0); @@ -1315,7 +1319,6 @@ procedure TScintEdit.ScrollCaretIntoView; Call(SCI_SCROLLCARET, 0, 0); end; - procedure TScintEdit.SelectAllOccurrences(const Options: TScintFindOptions); { At the moment this does not automatically expand folds, unlike VSCode. Also see SelectNextOccurrence. } @@ -1456,7 +1459,7 @@ procedure TScintEdit.SetCaretVirtualSpace(const Value: Integer); end; end; -procedure TScintEdit.SetChangeHistory(const Value: Boolean); +procedure TScintEdit.SetChangeHistory(const Value: TScintChangeHistory); begin if FChangeHistory <> Value then begin FChangeHistory := Value; diff --git a/Projects/Src/CompForm.pas b/Projects/Src/CompForm.pas index b484e2b60..4c5dbaeac 100644 --- a/Projects/Src/CompForm.pas +++ b/Projects/Src/CompForm.pas @@ -704,7 +704,7 @@ function TCompileForm.InitializeMemoBase(const Memo: TCompScintEdit; const Popup function TCompileForm.InitializeFileMemo(const Memo: TCompScintFileEdit; const PopupMenu: TPopupMenu): TCompScintFileEdit; begin InitializeMemoBase(Memo, PopupMenu); - Memo.ChangeHistory := True; + Memo.ChangeHistory := schMarkers; Memo.CompilerFileIndex := UnknownCompilerFileIndex; Memo.ErrorLine := -1; Memo.StepLine := -1; @@ -3332,7 +3332,7 @@ procedure TCompileForm.UpdateOccurrenceIndicators(const AMemo: TCompScintEdit); const TextToFind: TScintRawString; const Options: TScintFindOptions; const SelectionRanges, IndicatorRanges: TScintRangeList); begin - if ScintRawStringIsBlank(TextToFind) then + if TScintEdit.RawStringIsBlank(TextToFind) then Exit; var StartPos := 0; @@ -4568,7 +4568,7 @@ procedure TCompileForm.MemoCharAdded(Sender: TObject; Ch: AnsiChar); function LineIsBlank(const Line: Integer): Boolean; begin var S := FActiveMemo.Lines.RawLines[Line]; - Result := ScintRawStringIsBlank(S); + Result := TScintEdit.RawStringIsBlank(S); end; var diff --git a/Projects/Src/CompScintEdit.pas b/Projects/Src/CompScintEdit.pas index e50b0872c..b11ac4e43 100644 --- a/Projects/Src/CompScintEdit.pas +++ b/Projects/Src/CompScintEdit.pas @@ -319,7 +319,7 @@ procedure TCompScintEdit.UpdateMarginsAndSquigglyWidths(const IconMarkersWidth, Call(SCI_SETMARGINWIDTHN, mmIcons, IconMarkersWidth); var ChangeHistoryWidth: Integer; - if ChangeHistory then + if ChangeHistory <> schDisabled then ChangeHistoryWidth := BaseChangeHistoryWidth else ChangeHistoryWidth := 0; { Current this is just the preprocessor output memo } diff --git a/whatsnew.htm b/whatsnew.htm index f1b8f4a05..6084c6d69 100644 --- a/whatsnew.htm +++ b/whatsnew.htm @@ -44,7 +44,7 @@
  • Left, Right, etc. navigation with rectangular selection is now allowed.
  • When autocompleting with multiple selections present, the autocompleted text now goes into each selection.
  • -

    Other changes:

    +

    Other editor changes:

    +

    Other changes:

    +