mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2026-03-13 09:24:25 +08:00
Issue #136: adjust code for displaying cursor position to the new SynMemo approach
This commit is contained in:
@@ -289,7 +289,6 @@ type
|
||||
function IsInt(Str: String): Boolean;
|
||||
function IsFloat(Str: String): Boolean;
|
||||
function ScanLineBreaks(Text: String): TLineBreaks;
|
||||
function CountLineBreaks(Text: String; LineBreak: TLineBreaks=lbsWindows): Cardinal;
|
||||
function fixNewlines(txt: String): String;
|
||||
function GetShellFolder(FolderId: TGUID): String;
|
||||
function ValidFilename(Str: String): String;
|
||||
@@ -744,28 +743,6 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
function CountLineBreaks(Text: String; LineBreak: TLineBreaks=lbsWindows): Cardinal;
|
||||
var
|
||||
Offset: Integer;
|
||||
BreakStr: String;
|
||||
begin
|
||||
// Count number of given line breaks in text
|
||||
Result := 0;
|
||||
case LineBreak of
|
||||
lbsWindows: BreakStr := CRLF;
|
||||
lbsUnix: BreakStr := LB_UNIX;
|
||||
lbsMac: BreakStr := LB_MAC;
|
||||
lbsWide: BreakStr := LB_WIDE;
|
||||
else Exit;
|
||||
end;
|
||||
Offset := PosEx(BreakStr, Text, 1);
|
||||
while Offset <> 0 do begin
|
||||
Inc(Result);
|
||||
Offset := PosEx(BreakStr, Text, Offset + Length(BreakStr));
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
{***
|
||||
Unify CR's and LF's to CRLF
|
||||
|
||||
|
||||
@@ -141,23 +141,16 @@ end;
|
||||
|
||||
procedure TfrmTextEditor.TimerMemoChangeTimer(Sender: TObject);
|
||||
var
|
||||
Lines: Cardinal;
|
||||
TextLen: Integer;
|
||||
MaxLen, CursorPos: String;
|
||||
begin
|
||||
// Timer based onchange handler, so we don't scan the whole text on every typed character
|
||||
TimerMemoChange.Enabled := False;
|
||||
TextLen := Length(MemoText.Text);
|
||||
if FMaxLength = 0 then
|
||||
MaxLen := '?'
|
||||
else
|
||||
MaxLen := FormatNumber(FMaxLength);
|
||||
if TextLen = 0 then
|
||||
Lines := 0
|
||||
else
|
||||
Lines := CountLineBreaks(MemoText.Text) + 1;
|
||||
CursorPos := 'x:z'; //FormatNumber(MemoText.CaretPos.Y+1) + ' : ' + FormatNumber(MemoText.CaretPos.X+1);
|
||||
lblTextLength.Caption := f_('%s characters (max: %s), %s lines, cursor at %s', [FormatNumber(TextLen), MaxLen, FormatNumber(Lines), CursorPos]);
|
||||
CursorPos := MemoText.CaretY.ToString + ':' + MemoText.CaretX.ToString;
|
||||
lblTextLength.Caption := f_('%s characters (max: %s), %s lines, cursor at %s', [FormatNumber(MemoText.GetTextLen), MaxLen, FormatNumber(MemoText.Lines.Count), CursorPos]);
|
||||
end;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user