소스 검색

Add Set(Raw)MainSelText because SCI_REPLACESEL is also weird.

Martijn Laan 1 년 전
부모
커밋
768c9d14f5
2개의 변경된 파일20개의 추가작업 그리고 7개의 파일을 삭제
  1. 15 2
      Components/ScintEdit.pas
  2. 5 5
      Projects/Src/CompForm.pas

+ 15 - 2
Components/ScintEdit.pas

@@ -167,6 +167,8 @@ type
     procedure SetIndentationGuides(const Value: TScintIndentationGuides);
     procedure SetIndentationGuides(const Value: TScintIndentationGuides);
     procedure SetLineNumbers(const Value: Boolean);
     procedure SetLineNumbers(const Value: Boolean);
     procedure SetMainSelection(const Value: Integer);
     procedure SetMainSelection(const Value: Integer);
+    procedure SetMainSelText(const Value: String);
+    procedure SetRawMainSelText(const Value: TScintRawString);
     procedure SetRawSelText(const Value: TScintRawString);
     procedure SetRawSelText(const Value: TScintRawString);
     procedure SetRawText(const Value: TScintRawString);
     procedure SetRawText(const Value: TScintRawString);
     procedure SetReadOnly(const Value: Boolean);
     procedure SetReadOnly(const Value: Boolean);
@@ -340,9 +342,9 @@ type
     property Lines: TScintEditStrings read FLines;
     property Lines: TScintEditStrings read FLines;
     property LinesInWindow: Integer read GetLinesInWindow;
     property LinesInWindow: Integer read GetLinesInWindow;
     property MainSelection: Integer read GetMainSelection write SetMainSelection;
     property MainSelection: Integer read GetMainSelection write SetMainSelection;
-    property MainSelText: String read GetMainSelText;
+    property MainSelText: String read GetMainSelText write SetMainSelText;
     property Modified: Boolean read GetModified;
     property Modified: Boolean read GetModified;
-    property RawMainSelText: TScintRawString read GetRawMainSelText;
+    property RawMainSelText: TScintRawString read GetRawMainSelText write SetRawMainSelText;
     property RawSelText: TScintRawString read GetRawSelText write SetRawSelText;
     property RawSelText: TScintRawString read GetRawSelText write SetRawSelText;
     property RawText: TScintRawString read GetRawText write SetRawText;
     property RawText: TScintRawString read GetRawText write SetRawText;
     property RawTextLength: Integer read GetRawTextLength;
     property RawTextLength: Integer read GetRawTextLength;
@@ -1654,6 +1656,17 @@ begin
   Call(SCI_SETMAINSELECTION, Value, 0);
   Call(SCI_SETMAINSELECTION, Value, 0);
 end;
 end;
 
 
+procedure TScintEdit.SetMainSelText(const Value: String);
+begin
+  SetRawMainSelText(ConvertStringToRawString(Value));
+end;
+
+procedure TScintEdit.SetRawMainSelText(const Value: TScintRawString);
+begin
+  Call(SCI_TARGETFROMSELECTION, 0, 0);
+  Call(SCI_REPLACETARGETMINIMAL, Length(Value), LPARAM(PAnsiChar(Value)));
+end;
+
 procedure TScintEdit.SetRawSelText(const Value: TScintRawString);
 procedure TScintEdit.SetRawSelText(const Value: TScintRawString);
 { Replaces the main selection's text and *clears* additional selections }
 { Replaces the main selection's text and *clears* additional selections }
 begin
 begin

+ 5 - 5
Projects/Src/CompForm.pas

@@ -3352,7 +3352,7 @@ begin
   end
   end
   else begin
   else begin
     if FActiveMemo.MainSelTextEquals(FLastFindText, frMatchCase in FLastFindOptions) then
     if FActiveMemo.MainSelTextEquals(FLastFindText, frMatchCase in FLastFindOptions) then
-      FActiveMemo.SelText := FLastReplaceText;
+      FActiveMemo.MainSelText := FLastReplaceText;
     FindNext;
     FindNext;
   end;
   end;
 end;
 end;
@@ -3628,7 +3628,7 @@ procedure TCompileForm.TGenerateGUIDClick(Sender: TObject);
 begin
 begin
   if MsgBox('The generated GUID will be inserted into the editor at the cursor position. Continue?',
   if MsgBox('The generated GUID will be inserted into the editor at the cursor position. Continue?',
      SCompilerFormCaption, mbConfirmation, MB_YESNO) = IDYES then
      SCompilerFormCaption, mbConfirmation, MB_YESNO) = IDYES then
-    FActiveMemo.SelText := GenerateGuid;
+    FActiveMemo.MainSelText := GenerateGuid;
 end;
 end;
 
 
 procedure TCompileForm.TMsgBoxDesignerClick(Sender: TObject);
 procedure TCompileForm.TMsgBoxDesignerClick(Sender: TObject);
@@ -3641,7 +3641,7 @@ begin
   var MsgBoxForm := TMsgBoxDesignerForm.Create(Application);
   var MsgBoxForm := TMsgBoxDesignerForm.Create(Application);
   try
   try
     if MsgBoxForm.ShowModal = mrOk then
     if MsgBoxForm.ShowModal = mrOk then
-      FActiveMemo.SelText := MsgBoxForm.GetText(FOptions.TabWidth, FOptions.UseTabCharacter);
+      FActiveMemo.MainSelText := MsgBoxForm.GetText(FOptions.TabWidth, FOptions.UseTabCharacter);
   finally
   finally
     MsgBoxForm.Free;
     MsgBoxForm.Free;
   end;
   end;
@@ -3666,7 +3666,7 @@ begin
       var Text := RegistryDesignerForm.Text;
       var Text := RegistryDesignerForm.Text;
       if FMemosStyler.GetSectionFromLineState(FActiveMemo.Lines.State[FActiveMemo.CaretLine]) <> scRegistry then
       if FMemosStyler.GetSectionFromLineState(FActiveMemo.Lines.State[FActiveMemo.CaretLine]) <> scRegistry then
         Text := '[Registry]' + SNewLine + Text;
         Text := '[Registry]' + SNewLine + Text;
-      FActiveMemo.SelText := Text;
+      FActiveMemo.MainSelText := Text;
     end;
     end;
   finally
   finally
     RegistryDesignerForm.Free;
     RegistryDesignerForm.Free;
@@ -3683,7 +3683,7 @@ begin
       var Text := FilesDesignerForm.Text;
       var Text := FilesDesignerForm.Text;
       if FMemosStyler.GetSectionFromLineState(FActiveMemo.Lines.State[FActiveMemo.CaretLine]) <> scFiles then
       if FMemosStyler.GetSectionFromLineState(FActiveMemo.Lines.State[FActiveMemo.CaretLine]) <> scFiles then
         Text := '[Files]' + SNewLine + Text;
         Text := '[Files]' + SNewLine + Text;
-      FActiveMemo.SelText := Text;
+      FActiveMemo.MainSelText := Text;
     end;
     end;
   finally
   finally
     FilesDesignerForm.Free;
     FilesDesignerForm.Free;