@@ -108,7 +108,7 @@ TfrmTextEditor = class(TExtForm)
108108
109109implementation
110110
111- uses main;
111+ uses main, Types ;
112112
113113{ $R *.lfm}
114114
@@ -381,13 +381,13 @@ procedure TfrmTextEditor.comboHighlighterSelect(Sender: TObject);
381381var
382382 Highlighters: TSynHighlighterList;
383383 i: Integer;
384- SelStart, SelLength: Integer ;
384+ SelBegin, SelEnd: TPoint ;
385385begin
386386 // Code highlighter selected
387387 if not comboHighlighter.Enabled then
388388 Exit;
389- SelStart := MemoText.SelStart ;
390- SelLength := MemoText.SelEnd - MemoText.SelStart ;
389+ SelBegin := MemoText.BlockBegin ;
390+ SelEnd := MemoText.BlockEnd ;
391391 MemoText.Highlighter := nil ;
392392 FHighlighter.Free;
393393 FHighlighter := nil ;
@@ -403,17 +403,17 @@ procedure TfrmTextEditor.comboHighlighterSelect(Sender: TObject);
403403 menuFormatCodeOnce.Enabled := Assigned(FHighlighter) and (FHighlighterFormatters.IndexOf(FHighlighter.ClassName) > -1 );
404404 if menuAlwaysFormatCode.Checked and menuFormatCodeOnce.Enabled then begin
405405 menuFormatCodeOnce.OnClick(Sender);
406- SelStart := 0 ;
407- SelLength := 0 ;
406+ SelBegin := Point( 1 , 1 ) ;
407+ SelEnd := SelBegin ;
408408 end ;
409409
410410 if Assigned(FHighlighter) then begin
411411 // Load custom highlighter settings from ini file, if exists:
412412 MemoText.Highlighter.LoadFromFile(AppSettings.DirnameHighlighters + MemoText.Highlighter.LanguageName + ' .ini' );
413413 end ;
414414
415- MemoText.SelStart := SelStart ;
416- MemoText.SelEnd := SelStart + SelLength ;
415+ MemoText.BlockBegin := SelBegin ;
416+ MemoText.BlockEnd := SelEnd ;
417417end ;
418418
419419procedure TfrmTextEditor.btnLoadTextClick (Sender: TObject);
@@ -468,15 +468,15 @@ procedure TfrmTextEditor.menuFormatCodeOnceClick(Sender: TObject);
468468 JsonParser := TJSONParser.Create(MemoText.Text, []);
469469 MemoText.Text := JsonParser.Parse.FormatJSON();
470470 JsonParser.Free;
471- MemoText.SelStart := 0 ;
472- MemoText.SelEnd := 0 ;
471+ MemoText.CaretXY := Point( 1 , 1 ) ;
472+ MemoText.ClearSelection ;
473473 end
474474 else if FHighlighter is TSynSQLSyn then begin
475475 // Prefer old internal formatter here, so the user does not run into request limits
476476 frmReformatter := TfrmReformatter.Create(Self);
477477 MemoText.Text := frmReformatter.FormatSqlInternal(MemoText.Text);
478- MemoText.SelStart := 0 ;
479- MemoText.SelEnd := 0 ;
478+ MemoText.CaretXY := Point( 1 , 1 ) ;
479+ MemoText.ClearSelection ;
480480 frmReformatter.Free;
481481 end
482482 else if FHighlighter is TSynXMLSyn then begin
@@ -492,8 +492,8 @@ procedure TfrmTextEditor.menuFormatCodeOnceClick(Sender: TObject);
492492 MemoText.BeginUpdate;
493493 MemoText.Text := OutStream.DataString; // show formatted XML
494494 MemoText.EndUpdate;
495- MemoText.SelStart := 0 ;
496- MemoText.SelEnd := 0 ;
495+ MemoText.CaretXY := Point( 1 , 1 ) ;
496+ MemoText.ClearSelection ;
497497 finally
498498 InStream.Free;
499499 OutStream.Free;
0 commit comments