From 0e0b2fa192f3848461b23502843b0c0149750fa4 Mon Sep 17 00:00:00 2001 From: paul Date: Wed, 21 Mar 2012 04:11:51 +0000 Subject: [PATCH] ideintf, ide: add InsertLine method git-svn-id: trunk@36186 - --- ide/sourceeditor.pp | 13 +++++++++++++ ideintf/srceditorintf.pas | 1 + 2 files changed, 14 insertions(+) diff --git a/ide/sourceeditor.pp b/ide/sourceeditor.pp index 5b5723bb25..9ec67310e3 100644 --- a/ide/sourceeditor.pp +++ b/ide/sourceeditor.pp @@ -377,6 +377,7 @@ type function SelectionAvailable: boolean; override; function GetText(OnlySelection: boolean): string; override; procedure SelectText(const StartPos, EndPos: TPoint); override; + procedure InsertLine(StartLine: Integer; const NewText: String; aKeepMarks: Boolean = False); override; procedure ReplaceLines(StartLine, EndLine: integer; const NewText: string; aKeepMarks: Boolean = False); override; procedure EncloseSelection; procedure UpperCaseSelection; @@ -4271,6 +4272,18 @@ Begin FEditor.BlockEnd := EndPos; end; +procedure TSourceEditor.InsertLine(StartLine: Integer; const NewText: String; + aKeepMarks: Boolean); +const + MarksMode: array[Boolean] of TSynMarksAdjustMode = (smaMoveUp, smaKeep); +begin + if not ReadOnly then + FEditor.SetTextBetweenPoints( + Point(1, StartLine), + Point(1, StartLine), + NewText + LineEnding, [], scamEnd, MarksMode[aKeepMarks]); +end; + procedure TSourceEditor.ReplaceLines(StartLine, EndLine: integer; const NewText: string; aKeepMarks: Boolean = False); const diff --git a/ideintf/srceditorintf.pas b/ideintf/srceditorintf.pas index 0a6a150c9f..64dfa3699f 100644 --- a/ideintf/srceditorintf.pas +++ b/ideintf/srceditorintf.pas @@ -116,6 +116,7 @@ type function GetText(OnlySelection: boolean): string; virtual; abstract; procedure SelectText(LineNum, CharStart, LineNum2, CharEnd: Integer); procedure SelectText(const StartPos, EndPos: TPoint); virtual; abstract; + procedure InsertLine(StartLine: Integer; const NewText: String; aKeepMarks: Boolean = False); virtual; abstract; procedure ReplaceLines(StartLine, EndLine: integer; const NewText: string; aKeepMarks: Boolean = False); virtual; abstract; procedure ReplaceText(const StartPos, EndPos: TPoint; const NewText: string); procedure AskReplace(Sender: TObject; const ASearch, AReplace: string;