SynEdit: fix commit 39095 #bfe4ef2227 - Delete last char in line

git-svn-id: trunk@39096 -
This commit is contained in:
martin 2012-10-15 22:50:28 +00:00
parent bfe4ef2227
commit efacf7ff55
3 changed files with 15 additions and 11 deletions

View File

@ -283,7 +283,7 @@ type
procedure FlushNotificationCache; virtual; abstract; procedure FlushNotificationCache; virtual; abstract;
public public
// Char bounds // 1 based (1 is the 1st char in the line) // Char bounds // 1 based (1 is the 1st char in the line)
function LogicPosAddChars(const ALine: String; ALogicalPos, ACount: integer): Integer; virtual; abstract; function LogicPosAddChars(const ALine: String; ALogicalPos, ACount: integer; AllowPastEOL: Boolean = False): Integer; virtual; abstract;
function LogicPosIsAtChar(const ALine: String; ALogicalPos: integer): Boolean; virtual; abstract; function LogicPosIsAtChar(const ALine: String; ALogicalPos: integer): Boolean; virtual; abstract;
function LogicPosAdjustToChar(const ALine: String; ALogicalPos: integer; function LogicPosAdjustToChar(const ALine: String; ALogicalPos: integer;
ANext: Boolean = False): Integer; virtual; abstract; ANext: Boolean = False): Integer; virtual; abstract;
@ -405,7 +405,7 @@ type
property NextLines: TSynEditStrings read fSynStrings write SetSynStrings; property NextLines: TSynEditStrings read fSynStrings write SetSynStrings;
public public
// Char bounds // 1 based (1 is the 1st char in the line) // Char bounds // 1 based (1 is the 1st char in the line)
function LogicPosAddChars(const ALine: String; ALogicalPos, ACount: integer): Integer; override; function LogicPosAddChars(const ALine: String; ALogicalPos, ACount: integer; AllowPastEOL: Boolean = False): Integer; override;
function LogicPosIsAtChar(const ALine: String; ALogicalPos: integer): Boolean; override; function LogicPosIsAtChar(const ALine: String; ALogicalPos: integer): Boolean; override;
function LogicPosAdjustToChar(const ALine: String; ALogicalPos: integer; function LogicPosAdjustToChar(const ALine: String; ALogicalPos: integer;
ANext: Boolean = False): Integer; override; ANext: Boolean = False): Integer; override;
@ -1281,8 +1281,8 @@ begin
fSynStrings.FlushNotificationCache; fSynStrings.FlushNotificationCache;
end; end;
function TSynEditStringsLinked.LogicPosAddChars(const ALine: String; ALogicalPos, function TSynEditStringsLinked.LogicPosAddChars(const ALine: String;
ACount: integer): Integer; ALogicalPos, ACount: integer; AllowPastEOL: Boolean): Integer;
begin begin
Result := fSynStrings.LogicPosAddChars(ALine, ALogicalPos, ACount); Result := fSynStrings.LogicPosAddChars(ALine, ALogicalPos, ACount);
end; end;

View File

@ -2497,7 +2497,7 @@ end;
function TCustomSynEdit.GetCharLen(const Line: string; CharStartPos: integer): integer; function TCustomSynEdit.GetCharLen(const Line: string; CharStartPos: integer): integer;
begin begin
Result := FLines.LogicPosAddChars(Line, CharStartPos, 1) - CharStartPos; Result := FLines.LogicPosAddChars(Line, CharStartPos, 1, True) - CharStartPos;
end; end;
function TCustomSynEdit.GetLogicalCaretXY: TPoint; function TCustomSynEdit.GetLogicalCaretXY: TPoint;

View File

@ -235,7 +235,7 @@ type
property Modified: Boolean read FModified write SetModified; property Modified: Boolean read FModified write SetModified;
public public
// Char bounds // 1 based (1 is the 1st char in the line) // Char bounds // 1 based (1 is the 1st char in the line)
function LogicPosAddChars(const ALine: String; ALogicalPos, ACount: integer): Integer; override; function LogicPosAddChars(const ALine: String; ALogicalPos, ACount: integer; AllowPastEOL: Boolean = False): Integer; override;
function LogicPosIsAtChar(const ALine: String; ALogicalPos: integer): Boolean; override; function LogicPosIsAtChar(const ALine: String; ALogicalPos: integer): Boolean; override;
function LogicPosAdjustToChar(const ALine: String; ALogicalPos: integer; function LogicPosAdjustToChar(const ALine: String; ALogicalPos: integer;
ANext: Boolean = False): Integer; override; ANext: Boolean = False): Integer; override;
@ -1056,7 +1056,7 @@ begin
end; end;
function TSynEditStringList.LogicPosAddChars(const ALine: String; ALogicalPos, function TSynEditStringList.LogicPosAddChars(const ALine: String; ALogicalPos,
ACount: integer): Integer; ACount: integer; AllowPastEOL: Boolean): Integer;
begin begin
// UTF8 handing of chars // UTF8 handing of chars
Result := ALogicalPos; Result := ALogicalPos;
@ -1070,10 +1070,14 @@ begin
if (ALine[Result] in [#0..#127, #192..#255]) and (not LogicPosIsCombining(ALine, Result)) then if (ALine[Result] in [#0..#127, #192..#255]) and (not LogicPosIsCombining(ALine, Result)) then
dec(ACount); dec(ACount);
end; end;
while (Result > 1) and if AllowPastEOL then
( (not(ALine[Result] in [#0..#127, #192..#255])) or LogicPosIsCombining(ALine, Result) ) Result := Result + ACount;
do
dec(Result); if (Result <= length(ALine)) then
while (Result > 1) and
( (not(ALine[Result] in [#0..#127, #192..#255])) or LogicPosIsCombining(ALine, Result) )
do
dec(Result);
end else begin end else begin
while (Result > 1) and (ACount < 0) do begin while (Result > 1) and (ACount < 0) do begin
dec(Result); dec(Result);