|
@@ -47,7 +47,11 @@ type
|
|
PLine = ^TLine;
|
|
PLine = ^TLine;
|
|
TLine = object(TCustomLine)
|
|
TLine = object(TCustomLine)
|
|
public { internal use only! }
|
|
public { internal use only! }
|
|
- Text : PString;
|
|
|
|
|
|
+{$if sizeof(sw_astring)>8}
|
|
|
|
+ Text : PString; { ShortString version }
|
|
|
|
+{$else}
|
|
|
|
+ Text : sw_AString; { AnsiString version }
|
|
|
|
+{$endif}
|
|
DefaultEditorInfo : PEditorLineInfo;
|
|
DefaultEditorInfo : PEditorLineInfo;
|
|
EditorInfos : PEditorLineInfoCollection;
|
|
EditorInfos : PEditorLineInfoCollection;
|
|
Flags : longint;
|
|
Flags : longint;
|
|
@@ -55,9 +59,9 @@ type
|
|
procedure AddEditorInfo(Index: sw_integer; AEditor: PCustomCodeEditor); virtual;
|
|
procedure AddEditorInfo(Index: sw_integer; AEditor: PCustomCodeEditor); virtual;
|
|
procedure RemoveEditorInfo(AEditor: PCustomCodeEditor); virtual;
|
|
procedure RemoveEditorInfo(AEditor: PCustomCodeEditor); virtual;
|
|
public
|
|
public
|
|
- constructor Init(AOwner: PCustomCodeEditorCore; const AText: string; AFlags: longint);
|
|
|
|
- function GetText: string; virtual;
|
|
|
|
- procedure SetText(const AText: string); virtual;
|
|
|
|
|
|
+ constructor Init(AOwner: PCustomCodeEditorCore; const AText: sw_AString; AFlags: longint);
|
|
|
|
+ function GetText: sw_AString; virtual;
|
|
|
|
+ procedure SetText(const AText: sw_AString); virtual;
|
|
function GetEditorInfo(Editor: PCustomCodeEditor): PEditorLineInfo; virtual;
|
|
function GetEditorInfo(Editor: PCustomCodeEditor): PEditorLineInfo; virtual;
|
|
function GetFlags: longint; virtual;
|
|
function GetFlags: longint; virtual;
|
|
procedure SetFlags(AFlags: longint); virtual;
|
|
procedure SetFlags(AFlags: longint); virtual;
|
|
@@ -98,26 +102,26 @@ type
|
|
protected
|
|
protected
|
|
{ Text & info storage abstraction }
|
|
{ Text & info storage abstraction }
|
|
procedure ISetLineFlagState(Binding: PEditorBinding; LineNo: sw_integer; Flag: longint; ASet: boolean); virtual;
|
|
procedure ISetLineFlagState(Binding: PEditorBinding; LineNo: sw_integer; Flag: longint; ASet: boolean); virtual;
|
|
- procedure IGetDisplayTextFormat(Binding: PEditorBinding; LineNo: sw_integer;var DT,DF:string); virtual;
|
|
|
|
- function IGetLineFormat(Binding: PEditorBinding; LineNo: sw_integer): string; virtual;
|
|
|
|
- procedure ISetLineFormat(Binding: PEditorBinding; LineNo: sw_integer;const S: string); virtual;
|
|
|
|
|
|
+ procedure IGetDisplayTextFormat(Binding: PEditorBinding; LineNo: sw_integer;var DT,DF:sw_astring); virtual;
|
|
|
|
+ function IGetLineFormat(Binding: PEditorBinding; LineNo: sw_integer): sw_astring; virtual;
|
|
|
|
+ procedure ISetLineFormat(Binding: PEditorBinding; LineNo: sw_integer;const S: sw_astring); virtual;
|
|
public
|
|
public
|
|
{ Text & info storage abstraction }
|
|
{ Text & info storage abstraction }
|
|
function GetLineCount: sw_integer; virtual;
|
|
function GetLineCount: sw_integer; virtual;
|
|
function GetLine(LineNo: sw_integer): PCustomLine; virtual;
|
|
function GetLine(LineNo: sw_integer): PCustomLine; virtual;
|
|
- function GetLineText(LineNo: sw_integer): string; virtual;
|
|
|
|
- procedure SetDisplayText(I: sw_integer;const S: string); virtual;
|
|
|
|
- function GetDisplayText(I: sw_integer): string; virtual;
|
|
|
|
- procedure SetLineText(I: sw_integer;const S: string); virtual;
|
|
|
|
|
|
+ function GetLineText(LineNo: sw_integer): sw_AString; virtual;
|
|
|
|
+ procedure SetDisplayText(I: sw_integer;const S: sw_astring); virtual;
|
|
|
|
+ function GetDisplayText(I: sw_integer): sw_astring; virtual;
|
|
|
|
+ procedure SetLineText(I: sw_integer;const S: sw_AString); virtual;
|
|
procedure DeleteAllLines; virtual;
|
|
procedure DeleteAllLines; virtual;
|
|
procedure DeleteLine(I: sw_integer); virtual;
|
|
procedure DeleteLine(I: sw_integer); virtual;
|
|
- function InsertLine(LineNo: sw_integer; const S: string): PCustomLine; virtual;
|
|
|
|
- procedure AddLine(const S: string); virtual;
|
|
|
|
|
|
+ function InsertLine(LineNo: sw_integer; const S: sw_AString): PCustomLine; virtual;
|
|
|
|
+ procedure AddLine(const S: sw_AString); virtual;
|
|
procedure GetContent(ALines: PUnsortedStringCollection); virtual;
|
|
procedure GetContent(ALines: PUnsortedStringCollection); virtual;
|
|
procedure SetContent(ALines: PUnsortedStringCollection); virtual;
|
|
procedure SetContent(ALines: PUnsortedStringCollection); virtual;
|
|
public
|
|
public
|
|
{ Undo info storage }
|
|
{ Undo info storage }
|
|
- procedure AddAction(AAction: byte; AStartPos, AEndPos: TPoint; AText: string;AFlags : longint); virtual;
|
|
|
|
|
|
+ procedure AddAction(AAction: byte; AStartPos, AEndPos: TPoint; AText: sw_astring;AFlags : longint); virtual;
|
|
procedure AddGroupedAction(AAction : byte); virtual;
|
|
procedure AddGroupedAction(AAction : byte); virtual;
|
|
procedure CloseGroupedAction(AAction : byte); virtual;
|
|
procedure CloseGroupedAction(AAction : byte); virtual;
|
|
function GetUndoActionCount: sw_integer; virtual;
|
|
function GetUndoActionCount: sw_integer; virtual;
|
|
@@ -180,17 +184,17 @@ type
|
|
function GetLine(LineNo: sw_integer): PCustomLine; virtual;
|
|
function GetLine(LineNo: sw_integer): PCustomLine; virtual;
|
|
function CharIdxToLinePos(Line,CharIdx: sw_integer): sw_integer; virtual;
|
|
function CharIdxToLinePos(Line,CharIdx: sw_integer): sw_integer; virtual;
|
|
function LinePosToCharIdx(Line,X: sw_integer): sw_integer; virtual;
|
|
function LinePosToCharIdx(Line,X: sw_integer): sw_integer; virtual;
|
|
- function GetLineText(I: sw_integer): string; virtual;
|
|
|
|
- procedure SetDisplayText(I: sw_integer;const S: string); virtual;
|
|
|
|
- function GetDisplayText(I: sw_integer): string; virtual;
|
|
|
|
- procedure SetLineText(I: sw_integer;const S: string); virtual;
|
|
|
|
- procedure GetDisplayTextFormat(I: sw_integer;var DT,DF:string); virtual;
|
|
|
|
- function GetLineFormat(I: sw_integer): string; virtual;
|
|
|
|
- procedure SetLineFormat(I: sw_integer;const S: string); virtual;
|
|
|
|
|
|
+ function GetLineText(I: sw_integer): sw_AString; virtual;
|
|
|
|
+ procedure SetDisplayText(I: sw_integer;const S: sw_astring); virtual;
|
|
|
|
+ function GetDisplayText(I: sw_integer): sw_astring; virtual;
|
|
|
|
+ procedure SetLineText(I: sw_integer;const S: sw_AString); virtual;
|
|
|
|
+ procedure GetDisplayTextFormat(I: sw_integer;var DT,DF:sw_astring); virtual;
|
|
|
|
+ function GetLineFormat(I: sw_integer): sw_astring; virtual;
|
|
|
|
+ procedure SetLineFormat(I: sw_integer;const S: sw_astring); virtual;
|
|
procedure DeleteAllLines; virtual;
|
|
procedure DeleteAllLines; virtual;
|
|
procedure DeleteLine(I: sw_integer); virtual;
|
|
procedure DeleteLine(I: sw_integer); virtual;
|
|
- function InsertLine(LineNo: sw_integer; const S: string): PCustomLine; virtual;
|
|
|
|
- procedure AddLine(const S: string); virtual;
|
|
|
|
|
|
+ function InsertLine(LineNo: sw_integer; const S: sw_astring): PCustomLine; virtual;
|
|
|
|
+ procedure AddLine(const S: sw_astring); virtual;
|
|
function GetErrorMessage: string; virtual;
|
|
function GetErrorMessage: string; virtual;
|
|
procedure SetErrorMessage(const S: string); virtual;
|
|
procedure SetErrorMessage(const S: string); virtual;
|
|
procedure GetContent(ALines: PUnsortedStringCollection); virtual;
|
|
procedure GetContent(ALines: PUnsortedStringCollection); virtual;
|
|
@@ -211,7 +215,7 @@ type
|
|
{a}function UpdateAttrsRange(FromLine, ToLine: sw_integer; Attrs: byte): sw_integer; virtual;
|
|
{a}function UpdateAttrsRange(FromLine, ToLine: sw_integer; Attrs: byte): sw_integer; virtual;
|
|
public
|
|
public
|
|
{ Undo info storage }
|
|
{ Undo info storage }
|
|
- procedure AddAction(AAction: byte; AStartPos, AEndPos: TPoint; AText: string;AFlags : longint); virtual;
|
|
|
|
|
|
+ procedure AddAction(AAction: byte; AStartPos, AEndPos: TPoint; AText: sw_astring;AFlags : longint); virtual;
|
|
procedure AddGroupedAction(AAction : byte); virtual;
|
|
procedure AddGroupedAction(AAction : byte); virtual;
|
|
procedure CloseGroupedAction(AAction : byte); virtual;
|
|
procedure CloseGroupedAction(AAction : byte); virtual;
|
|
function GetUndoActionCount: sw_integer; virtual;
|
|
function GetUndoActionCount: sw_integer; virtual;
|
|
@@ -290,7 +294,7 @@ const
|
|
);
|
|
);
|
|
{$endif}
|
|
{$endif}
|
|
|
|
|
|
-constructor TLine.Init(AOwner: PCustomCodeEditorCore; const AText: string; AFlags: longint);
|
|
|
|
|
|
+constructor TLine.Init(AOwner: PCustomCodeEditorCore; const AText: sw_AString; AFlags: longint);
|
|
begin
|
|
begin
|
|
inherited Init(AText,AFlags);
|
|
inherited Init(AText,AFlags);
|
|
// New(EditorInfos, Init(10,10));
|
|
// New(EditorInfos, Init(10,10));
|
|
@@ -321,14 +325,22 @@ begin
|
|
EditorInfos^.Free(E);
|
|
EditorInfos^.Free(E);
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TLine.GetText: string;
|
|
|
|
|
|
+function TLine.GetText: sw_AString;
|
|
begin
|
|
begin
|
|
|
|
+{$if sizeof(sw_astring)>8}
|
|
GetText:=GetStr(Text);
|
|
GetText:=GetStr(Text);
|
|
|
|
+{$else}
|
|
|
|
+ GetText:=Text;
|
|
|
|
+{$endif}
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TLine.SetText(const AText: string);
|
|
|
|
|
|
+procedure TLine.SetText(const AText: sw_AString);
|
|
begin
|
|
begin
|
|
|
|
+{$if sizeof(sw_astring)>8}
|
|
SetStr(Text,AText);
|
|
SetStr(Text,AText);
|
|
|
|
+{$else}
|
|
|
|
+ Text:=AText;
|
|
|
|
+{$endif}
|
|
end;
|
|
end;
|
|
|
|
|
|
function TLine.GetEditorInfo(Editor: PCustomCodeEditor): PEditorLineInfo;
|
|
function TLine.GetEditorInfo(Editor: PCustomCodeEditor): PEditorLineInfo;
|
|
@@ -357,9 +369,14 @@ end;
|
|
|
|
|
|
destructor TLine.Done;
|
|
destructor TLine.Done;
|
|
begin
|
|
begin
|
|
|
|
+{$if sizeof(sw_astring)>8}
|
|
|
|
+ { ShortString version }
|
|
if Assigned(Text) then
|
|
if Assigned(Text) then
|
|
DisposeStr(Text);
|
|
DisposeStr(Text);
|
|
Text:=nil;
|
|
Text:=nil;
|
|
|
|
+{$else}
|
|
|
|
+ Text:=''; { AnsiString version }
|
|
|
|
+{$endif}
|
|
if Assigned(EditorInfos) then
|
|
if Assigned(EditorInfos) then
|
|
Dispose(EditorInfos, Done);
|
|
Dispose(EditorInfos, Done);
|
|
EditorInfos:=nil;
|
|
EditorInfos:=nil;
|
|
@@ -477,7 +494,7 @@ procedure TCodeEditorCore.GetContent(ALines: PUnsortedStringCollection);
|
|
procedure AddIt(P: PCustomLine);
|
|
procedure AddIt(P: PCustomLine);
|
|
begin
|
|
begin
|
|
if Assigned(P) then
|
|
if Assigned(P) then
|
|
- ALines^.Insert(NewStr(P^.GetText));
|
|
|
|
|
|
+ ALines^.Insert(NewStr(P^.GetText)); { Note: AnsiString to ShortString convertion }
|
|
end;
|
|
end;
|
|
begin
|
|
begin
|
|
if Assigned(Lines) then
|
|
if Assigned(Lines) then
|
|
@@ -487,7 +504,7 @@ end;
|
|
procedure TCodeEditorCore.SetContent(ALines: PUnsortedStringCollection);
|
|
procedure TCodeEditorCore.SetContent(ALines: PUnsortedStringCollection);
|
|
procedure AddIt(P: PString);
|
|
procedure AddIt(P: PString);
|
|
begin
|
|
begin
|
|
- AddLine(GetStr(P));
|
|
|
|
|
|
+ AddLine(GetStr(P)); { Note: ShortString to AnsiString convertion }
|
|
end;
|
|
end;
|
|
begin
|
|
begin
|
|
DeleteAllLines;
|
|
DeleteAllLines;
|
|
@@ -523,7 +540,7 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TCodeEditorCore.GetLineText(LineNo: sw_integer): string;
|
|
|
|
|
|
+function TCodeEditorCore.GetLineText(LineNo: sw_integer): sw_AString;
|
|
var
|
|
var
|
|
L : PCustomLine;
|
|
L : PCustomLine;
|
|
begin
|
|
begin
|
|
@@ -549,7 +566,7 @@ begin
|
|
Lines^.AtInsert(Idx,Line);
|
|
Lines^.AtInsert(Idx,Line);
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TCodeEditorCore.SetLineText(I: sw_integer;const S: string);
|
|
|
|
|
|
+procedure TCodeEditorCore.SetLineText(I: sw_integer;const S: sw_AString);
|
|
var
|
|
var
|
|
L : PCustomLine;
|
|
L : PCustomLine;
|
|
AddCount : Sw_Integer;
|
|
AddCount : Sw_Integer;
|
|
@@ -567,12 +584,12 @@ begin
|
|
ContentsChanged;
|
|
ContentsChanged;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TCodeEditorCore.GetDisplayText(I: sw_integer): string;
|
|
|
|
|
|
+function TCodeEditorCore.GetDisplayText(I: sw_integer): sw_astring;
|
|
begin
|
|
begin
|
|
GetDisplayText:=ExtractTabs(GetLineText(I),GetTabSize);
|
|
GetDisplayText:=ExtractTabs(GetLineText(I),GetTabSize);
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TCodeEditorCore.SetDisplayText(I: sw_integer;const S: string);
|
|
|
|
|
|
+procedure TCodeEditorCore.SetDisplayText(I: sw_integer;const S: sw_astring);
|
|
begin
|
|
begin
|
|
{ I disagree here
|
|
{ I disagree here
|
|
I don't want the editor to change the position of the tabs
|
|
I don't want the editor to change the position of the tabs
|
|
@@ -584,7 +601,7 @@ begin
|
|
SetLineText(I,S);
|
|
SetLineText(I,S);
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TCodeEditorCore.IGetDisplayTextFormat(Binding: PEditorBinding; LineNo: sw_integer;var DT,DF:string);
|
|
|
|
|
|
+procedure TCodeEditorCore.IGetDisplayTextFormat(Binding: PEditorBinding; LineNo: sw_integer;var DT,DF:sw_astring);
|
|
var
|
|
var
|
|
L : PCustomLine;
|
|
L : PCustomLine;
|
|
P,PAdd : SW_Integer;
|
|
P,PAdd : SW_Integer;
|
|
@@ -606,18 +623,18 @@ begin
|
|
begin
|
|
begin
|
|
PAdd:=TabSize-((p-1) mod TabSize);
|
|
PAdd:=TabSize-((p-1) mod TabSize);
|
|
if DF<>'' then
|
|
if DF<>'' then
|
|
- DF:=copy(DF,1,P-1)+CharStr(DF[p],PAdd)+copy(DF,P+1,High(DF));
|
|
|
|
- DT:=copy(DT,1,P-1)+CharStr(' ',PAdd)+copy(DT,P+1,High(DF));
|
|
|
|
|
|
+ DF:=copy(DF,1,P-1)+CharStr(DF[p],PAdd)+copy(DF,P+1,Length(DF));
|
|
|
|
+ DT:=copy(DT,1,P-1)+CharStr(' ',PAdd)+copy(DT,P+1,Length(DT));
|
|
inc(P,PAdd-1);
|
|
inc(P,PAdd-1);
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TCodeEditorCore.IGetLineFormat(Binding: PEditorBinding; LineNo: sw_integer): string;
|
|
|
|
|
|
+function TCodeEditorCore.IGetLineFormat(Binding: PEditorBinding; LineNo: sw_integer): sw_astring;
|
|
var P: PCustomLine;
|
|
var P: PCustomLine;
|
|
LI: PEditorLineInfo;
|
|
LI: PEditorLineInfo;
|
|
- S: string;
|
|
|
|
|
|
+ S: sw_astring;
|
|
begin
|
|
begin
|
|
if (0<=LineNo) and (LineNo<GetLineCount) then
|
|
if (0<=LineNo) and (LineNo<GetLineCount) then
|
|
P:=GetLine(LineNo)
|
|
P:=GetLine(LineNo)
|
|
@@ -629,7 +646,7 @@ begin
|
|
IGetLineFormat:=S;
|
|
IGetLineFormat:=S;
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TCodeEditorCore.ISetLineFormat(Binding: PEditorBinding; LineNo: sw_integer;const S: string);
|
|
|
|
|
|
+procedure TCodeEditorCore.ISetLineFormat(Binding: PEditorBinding; LineNo: sw_integer;const S: sw_astring);
|
|
var P: PCustomLine;
|
|
var P: PCustomLine;
|
|
LI: PEditorLineInfo;
|
|
LI: PEditorLineInfo;
|
|
begin
|
|
begin
|
|
@@ -662,7 +679,7 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TCodeEditorCore.InsertLine(LineNo: sw_integer; const S: string): PCustomLine;
|
|
|
|
|
|
+function TCodeEditorCore.InsertLine(LineNo: sw_integer; const S: sw_AString): PCustomLine;
|
|
var L: PLine;
|
|
var L: PLine;
|
|
begin
|
|
begin
|
|
L:=New(PLine, Init(@Self,S,0));
|
|
L:=New(PLine, Init(@Self,S,0));
|
|
@@ -670,16 +687,16 @@ begin
|
|
InsertLine:=L;
|
|
InsertLine:=L;
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TCodeEditorCore.AddLine(const S: string);
|
|
|
|
|
|
+procedure TCodeEditorCore.AddLine(const S: sw_AString);
|
|
begin
|
|
begin
|
|
LinesInsert(-1,New(PLine, Init(@Self,S,0)));
|
|
LinesInsert(-1,New(PLine, Init(@Self,S,0)));
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TCodeEditorCore.AddAction(AAction: byte; AStartPos, AEndPos: TPoint; AText: string;AFlags : longint);
|
|
|
|
|
|
+procedure TCodeEditorCore.AddAction(AAction: byte; AStartPos, AEndPos: TPoint; AText: sw_astring;AFlags : longint);
|
|
var
|
|
var
|
|
ActionIntegrated : boolean;
|
|
ActionIntegrated : boolean;
|
|
pa : PEditorAction;
|
|
pa : PEditorAction;
|
|
- S : String;
|
|
|
|
|
|
+ S : Sw_AString;
|
|
begin
|
|
begin
|
|
if (UndoList=nil) or (not StoreUndo) then Exit;
|
|
if (UndoList=nil) or (not StoreUndo) then Exit;
|
|
ActionIntegrated:=false;
|
|
ActionIntegrated:=false;
|
|
@@ -700,14 +717,12 @@ begin
|
|
then
|
|
then
|
|
begin
|
|
begin
|
|
pa^.EndPos:=AEndPos;
|
|
pa^.EndPos:=AEndPos;
|
|
- S:=GetStr(pa^.text);
|
|
|
|
- if S<>'' then
|
|
|
|
- DisposeStr(pa^.text);
|
|
|
|
|
|
+ S:=pa^.GetText;
|
|
if (AAction=eaDeleteText) and
|
|
if (AAction=eaDeleteText) and
|
|
(AStartPos.X>AEndPos.X) then
|
|
(AStartPos.X>AEndPos.X) then
|
|
- pa^.text:=NewStr(AText+S)
|
|
|
|
|
|
+ pa^.SetText(AText+S)
|
|
else
|
|
else
|
|
- pa^.text:=NewStr(S+AText);
|
|
|
|
|
|
+ pa^.SetText(S+AText);
|
|
ActionIntegrated:=true;
|
|
ActionIntegrated:=true;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
@@ -1008,37 +1023,37 @@ begin
|
|
LinePosToCharIdx:=Core^.LinePosToCharIdx(Line,X);
|
|
LinePosToCharIdx:=Core^.LinePosToCharIdx(Line,X);
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TCodeEditor.GetLineText(I: sw_integer): string;
|
|
|
|
|
|
+function TCodeEditor.GetLineText(I: sw_integer): sw_astring;
|
|
begin
|
|
begin
|
|
GetLineText:=Core^.GetLineText(I);
|
|
GetLineText:=Core^.GetLineText(I);
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TCodeEditor.SetDisplayText(I: sw_integer;const S: string);
|
|
|
|
|
|
+procedure TCodeEditor.SetDisplayText(I: sw_integer;const S: sw_astring);
|
|
begin
|
|
begin
|
|
Core^.SetDisplayText(I,S);
|
|
Core^.SetDisplayText(I,S);
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TCodeEditor.GetDisplayText(I: sw_integer): string;
|
|
|
|
|
|
+function TCodeEditor.GetDisplayText(I: sw_integer): sw_astring;
|
|
begin
|
|
begin
|
|
GetDisplayText:=Core^.GetDisplayText(I);
|
|
GetDisplayText:=Core^.GetDisplayText(I);
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TCodeEditor.SetLineText(I: sw_integer;const S: string);
|
|
|
|
|
|
+procedure TCodeEditor.SetLineText(I: sw_integer;const S: sw_AString);
|
|
begin
|
|
begin
|
|
Core^.SetLineText(I,S);
|
|
Core^.SetLineText(I,S);
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TCodeEditor.GetDisplayTextFormat(I: sw_integer;var DT,DF:string);
|
|
|
|
|
|
+procedure TCodeEditor.GetDisplayTextFormat(I: sw_integer;var DT,DF:sw_astring);
|
|
begin
|
|
begin
|
|
Core^.GetDisplayTextFormat(@Self,I,DT,DF);
|
|
Core^.GetDisplayTextFormat(@Self,I,DT,DF);
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TCodeEditor.GetLineFormat(I: sw_integer): string;
|
|
|
|
|
|
+function TCodeEditor.GetLineFormat(I: sw_integer): sw_astring;
|
|
begin
|
|
begin
|
|
GetLineFormat:=Core^.GetLineFormat(@Self,I);
|
|
GetLineFormat:=Core^.GetLineFormat(@Self,I);
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TCodeEditor.SetLineFormat(I: sw_integer;const S: string);
|
|
|
|
|
|
+procedure TCodeEditor.SetLineFormat(I: sw_integer;const S: sw_astring);
|
|
begin
|
|
begin
|
|
Core^.SetLineFormat(@Self,I,S);
|
|
Core^.SetLineFormat(@Self,I,S);
|
|
end;
|
|
end;
|
|
@@ -1053,12 +1068,12 @@ begin
|
|
Core^.DeleteLine(I);
|
|
Core^.DeleteLine(I);
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TCodeEditor.InsertLine(LineNo: sw_integer; const S: string): PCustomLine;
|
|
|
|
|
|
+function TCodeEditor.InsertLine(LineNo: sw_integer; const S: sw_astring): PCustomLine;
|
|
begin
|
|
begin
|
|
InsertLine:=Core^.InsertLine(LineNo,S);
|
|
InsertLine:=Core^.InsertLine(LineNo,S);
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TCodeEditor.AddLine(const S: string);
|
|
|
|
|
|
+procedure TCodeEditor.AddLine(const S: sw_astring);
|
|
begin
|
|
begin
|
|
Core^.AddLine(S);
|
|
Core^.AddLine(S);
|
|
end;
|
|
end;
|
|
@@ -1283,7 +1298,7 @@ var
|
|
UndoTime : longint;
|
|
UndoTime : longint;
|
|
WasInserting,WasAutoBrackets,IsGrouped,HadefNoIndent : boolean;
|
|
WasInserting,WasAutoBrackets,IsGrouped,HadefNoIndent : boolean;
|
|
MaxY,MinY : sw_integer;
|
|
MaxY,MinY : sw_integer;
|
|
- Line : String;
|
|
|
|
|
|
+ Line, uText : Sw_AString;
|
|
|
|
|
|
procedure SetMinMax(y : sw_integer);
|
|
procedure SetMinMax(y : sw_integer);
|
|
begin
|
|
begin
|
|
@@ -1321,6 +1336,7 @@ begin
|
|
begin
|
|
begin
|
|
if not IsGrouped then
|
|
if not IsGrouped then
|
|
UndoTime:=TimeStamp;
|
|
UndoTime:=TimeStamp;
|
|
|
|
+ uText:=GetText;
|
|
case action of
|
|
case action of
|
|
eaMoveCursor :
|
|
eaMoveCursor :
|
|
begin
|
|
begin
|
|
@@ -1330,9 +1346,8 @@ begin
|
|
eaInsertText :
|
|
eaInsertText :
|
|
begin
|
|
begin
|
|
SetCurPtr(StartPos.X,StartPos.Y);
|
|
SetCurPtr(StartPos.X,StartPos.Y);
|
|
- if assigned(text) then
|
|
|
|
- for Temp := 1 to length(Text^) do
|
|
|
|
- DelChar;
|
|
|
|
|
|
+ for Temp := 1 to length(uText) do
|
|
|
|
+ DelChar;
|
|
SetMinMax(StartPos.Y);
|
|
SetMinMax(StartPos.Y);
|
|
end;
|
|
end;
|
|
eaDeleteText :
|
|
eaDeleteText :
|
|
@@ -1343,9 +1358,8 @@ begin
|
|
SetInsertMode(true);
|
|
SetInsertMode(true);
|
|
WasAutoBrackets:=GetAutoBrackets;
|
|
WasAutoBrackets:=GetAutoBrackets;
|
|
SetAutoBrackets(false);
|
|
SetAutoBrackets(false);
|
|
- if assigned(text) then
|
|
|
|
- for Temp := 1 to length(Text^) do
|
|
|
|
- AddChar(Text^[Temp]);
|
|
|
|
|
|
+ for Temp := 1 to length(uText) do
|
|
|
|
+ AddChar(uText[Temp]);
|
|
SetAutoBrackets(WasAutoBrackets);
|
|
SetAutoBrackets(WasAutoBrackets);
|
|
SetInsertMode(WasInserting);
|
|
SetInsertMode(WasInserting);
|
|
SetMinMax(EndPos.Y);
|
|
SetMinMax(EndPos.Y);
|
|
@@ -1359,15 +1373,14 @@ begin
|
|
SetInsertMode(false);
|
|
SetInsertMode(false);
|
|
WasAutoBrackets:=GetAutoBrackets;
|
|
WasAutoBrackets:=GetAutoBrackets;
|
|
SetAutoBrackets(false);
|
|
SetAutoBrackets(false);
|
|
- if assigned(text) then
|
|
|
|
- for Temp := 1 to length(Text^) do
|
|
|
|
- begin
|
|
|
|
- AddChar(Text^[Temp]);
|
|
|
|
- if StartPos.X+Temp>Length(Line) then
|
|
|
|
- Text^[Temp]:=' '
|
|
|
|
- else
|
|
|
|
- Text^[Temp]:=Line[StartPos.X+Temp];
|
|
|
|
- end;
|
|
|
|
|
|
+ for Temp := 1 to length(uText) do
|
|
|
|
+ begin
|
|
|
|
+ AddChar(uText[Temp]);
|
|
|
|
+ if StartPos.X+Temp>Length(Line) then
|
|
|
|
+ uText[Temp]:=' '
|
|
|
|
+ else
|
|
|
|
+ uText[Temp]:=Line[StartPos.X+Temp];
|
|
|
|
+ end;
|
|
SetAutoBrackets(WasAutoBrackets);
|
|
SetAutoBrackets(WasAutoBrackets);
|
|
SetInsertMode(WasInserting);
|
|
SetInsertMode(WasInserting);
|
|
SetMinMax(EndPos.Y);
|
|
SetMinMax(EndPos.Y);
|
|
@@ -1378,7 +1391,7 @@ begin
|
|
SetCurPtr(EndPos.X,EndPos.Y);
|
|
SetCurPtr(EndPos.X,EndPos.Y);
|
|
Line:=Copy(GetDisplayText(StartPos.Y),1,StartPos.X);
|
|
Line:=Copy(GetDisplayText(StartPos.Y),1,StartPos.X);
|
|
If Length(Line)<StartPos.X then
|
|
If Length(Line)<StartPos.X then
|
|
- Line:=Line+CharStr(' ',StartPos.X-length(Line))+GetStr(Text);
|
|
|
|
|
|
+ Line:=Line+CharStr(' ',StartPos.X-length(Line))+uText;
|
|
SetDisplayText(StartPos.Y,Line+Copy(GetDisplayText(EndPos.Y),EndPos.X+1,255));
|
|
SetDisplayText(StartPos.Y,Line+Copy(GetDisplayText(EndPos.Y),EndPos.X+1,255));
|
|
SetMinMax(EndPos.Y);
|
|
SetMinMax(EndPos.Y);
|
|
SetCurPtr(0,EndPos.Y);
|
|
SetCurPtr(0,EndPos.Y);
|
|
@@ -1392,7 +1405,7 @@ begin
|
|
WasInserting:=GetInsertMode;
|
|
WasInserting:=GetInsertMode;
|
|
SetInsertMode(true);
|
|
SetInsertMode(true);
|
|
SetFlags(GetFlags or efNoIndent);
|
|
SetFlags(GetFlags or efNoIndent);
|
|
- InsertLine(StartPos.Y,GetStr(Text));
|
|
|
|
|
|
+ InsertLine(StartPos.Y,uText);
|
|
SetInsertMode(WasInserting);
|
|
SetInsertMode(WasInserting);
|
|
if not HadefNoIndent then
|
|
if not HadefNoIndent then
|
|
SetFlags(GetFlags and not efNoIndent);
|
|
SetFlags(GetFlags and not efNoIndent);
|
|
@@ -1455,7 +1468,7 @@ var
|
|
Temp,Idx,i,Last,Count : Longint;
|
|
Temp,Idx,i,Last,Count : Longint;
|
|
StoredFlags : longint;
|
|
StoredFlags : longint;
|
|
WasInserting,WasAutoBrackets,IsGrouped,ShouldInsertText : boolean;
|
|
WasInserting,WasAutoBrackets,IsGrouped,ShouldInsertText : boolean;
|
|
- Line : String;
|
|
|
|
|
|
+ Line,uText : sw_aString;
|
|
MaxY,MinY : sw_integer;
|
|
MaxY,MinY : sw_integer;
|
|
procedure SetMinMax(y : sw_integer);
|
|
procedure SetMinMax(y : sw_integer);
|
|
begin
|
|
begin
|
|
@@ -1490,6 +1503,7 @@ begin
|
|
for Idx:=Last downto Last-Count+1 do
|
|
for Idx:=Last downto Last-Count+1 do
|
|
with Core^.RedoList^.At(Idx)^ do
|
|
with Core^.RedoList^.At(Idx)^ do
|
|
begin
|
|
begin
|
|
|
|
+ uText:=GetText;
|
|
case action of
|
|
case action of
|
|
eaMoveCursor :
|
|
eaMoveCursor :
|
|
begin
|
|
begin
|
|
@@ -1499,13 +1513,13 @@ begin
|
|
eaInsertText :
|
|
eaInsertText :
|
|
begin
|
|
begin
|
|
SetCurPtr(startpos.x,startpos.y);
|
|
SetCurPtr(startpos.x,startpos.y);
|
|
- InsertText(GetStr(Text));
|
|
|
|
|
|
+ InsertText(uText);
|
|
SetMinMax(StartPos.Y);
|
|
SetMinMax(StartPos.Y);
|
|
end;
|
|
end;
|
|
eaDeleteText :
|
|
eaDeleteText :
|
|
begin
|
|
begin
|
|
SetCurPtr(EndPos.X,EndPos.Y);
|
|
SetCurPtr(EndPos.X,EndPos.Y);
|
|
- for Temp := 1 to length(GetStr(Text)) do
|
|
|
|
|
|
+ for Temp := 1 to length(uText) do
|
|
DelChar;
|
|
DelChar;
|
|
SetMinMax(EndPos.Y);
|
|
SetMinMax(EndPos.Y);
|
|
end;
|
|
end;
|
|
@@ -1517,15 +1531,14 @@ begin
|
|
SetInsertMode(false);
|
|
SetInsertMode(false);
|
|
WasAutoBrackets:=GetAutoBrackets;
|
|
WasAutoBrackets:=GetAutoBrackets;
|
|
SetAutoBrackets(false);
|
|
SetAutoBrackets(false);
|
|
- if assigned(text) then
|
|
|
|
- for Temp := 1 to length(Text^) do
|
|
|
|
- begin
|
|
|
|
- AddChar(Text^[Temp]);
|
|
|
|
- if StartPos.X+Temp>Length(Line) then
|
|
|
|
- Text^[Temp]:=' '
|
|
|
|
- else
|
|
|
|
- Text^[Temp]:=Line[StartPos.X+Temp];
|
|
|
|
- end;
|
|
|
|
|
|
+ for Temp := 1 to length(uText) do
|
|
|
|
+ begin
|
|
|
|
+ AddChar(uText[Temp]);
|
|
|
|
+ if StartPos.X+Temp>Length(Line) then
|
|
|
|
+ uText[Temp]:=' '
|
|
|
|
+ else
|
|
|
|
+ uText[Temp]:=Line[StartPos.X+Temp];
|
|
|
|
+ end;
|
|
SetAutoBrackets(WasAutoBrackets);
|
|
SetAutoBrackets(WasAutoBrackets);
|
|
SetInsertMode(WasInserting);
|
|
SetInsertMode(WasInserting);
|
|
SetCurPtr(EndPos.X,EndPos.Y);
|
|
SetCurPtr(EndPos.X,EndPos.Y);
|
|
@@ -1538,7 +1551,7 @@ begin
|
|
SetFlags(Flags);
|
|
SetFlags(Flags);
|
|
InsertNewLine;
|
|
InsertNewLine;
|
|
SetCurPtr(0,EndPos.Y);
|
|
SetCurPtr(0,EndPos.Y);
|
|
- Line:=GetStr(Text);
|
|
|
|
|
|
+ Line:=uText;
|
|
ShouldInsertText:=false;
|
|
ShouldInsertText:=false;
|
|
for I:=1 to Length(Line) do
|
|
for I:=1 to Length(Line) do
|
|
if Line[I]<>' ' then
|
|
if Line[I]<>' ' then
|
|
@@ -1557,7 +1570,7 @@ begin
|
|
if EndPos.Y=StartPos.Y-1 then
|
|
if EndPos.Y=StartPos.Y-1 then
|
|
SetDisplayText(EndPos.Y,RExpand(
|
|
SetDisplayText(EndPos.Y,RExpand(
|
|
copy(GetDisplayText(EndPos.Y),1,EndPos.X),EndPos.X)
|
|
copy(GetDisplayText(EndPos.Y),1,EndPos.X),EndPos.X)
|
|
- +GetStr(Text));
|
|
|
|
|
|
+ +uText);
|
|
SetCurPtr(EndPos.X,EndPos.Y);
|
|
SetCurPtr(EndPos.X,EndPos.Y);
|
|
SetMinMax(StartPos.Y);
|
|
SetMinMax(StartPos.Y);
|
|
SetMinMax(EndPos.Y);
|
|
SetMinMax(EndPos.Y);
|
|
@@ -1722,7 +1735,7 @@ begin
|
|
UpdateAttrsRange:=Core^.UpdateAttrsRange(FromLine,ToLine,Attrs);
|
|
UpdateAttrsRange:=Core^.UpdateAttrsRange(FromLine,ToLine,Attrs);
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TCodeEditor.AddAction(AAction: byte; AStartPos, AEndPos: TPoint; AText: string;AFlags : longint);
|
|
|
|
|
|
+procedure TCodeEditor.AddAction(AAction: byte; AStartPos, AEndPos: TPoint; AText: sw_astring;AFlags : longint);
|
|
begin
|
|
begin
|
|
Core^.AddAction(AAction,AStartPos,AEndPos,AText,AFlags);
|
|
Core^.AddAction(AAction,AStartPos,AEndPos,AText,AFlags);
|
|
end;
|
|
end;
|