From 2c325dceeff317133fa023a7212c76316a3bac75 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Tue, 17 Mar 2015 04:01:53 +0100 Subject: [PATCH] bdm --- src/ce_common.pas | 56 +++++++++++++++++++++++----------------------- src/ce_editor.pas | 4 ++-- src/ce_synmemo.pas | 9 ++++++-- 3 files changed, 37 insertions(+), 32 deletions(-) diff --git a/src/ce_common.pas b/src/ce_common.pas index dabc51e0..704807f3 100644 --- a/src/ce_common.pas +++ b/src/ce_common.pas @@ -207,7 +207,7 @@ type (** * Returns the length of the line ending in aFilename; *) - //function getLineEndingLength(const aFilename: string): byte; + function getLineEndingLength(const aFilename: string): byte; function getSysLineEndLen: byte; @@ -760,33 +760,33 @@ end; // TODO-cbugfix: confirm that DCD location info are based on system Line ending and not the one existing in a specific file -//function getLineEndingLength(const aFilename: string): byte; -//var -// value: char; -// le: string; -//begin -// value := #0; -// le := LineEnding; -// result := length(le); -// if not fileExists(aFilename) then -// exit; -// with TMemoryStream.Create do -// try -// LoadFromFile(aFilename); -// while true do -// begin -// if Position = Size then -// exit; -// read(value,1); -// if value = #10 then -// exit(1); -// if value = #13 then -// exit(2); -// end; -// finally -// Free; -// end; -//end; +function getLineEndingLength(const aFilename: string): byte; +var + value: char; + le: string; +begin + value := #0; + le := LineEnding; + result := length(le); + if not fileExists(aFilename) then + exit; + with TMemoryStream.Create do + try + LoadFromFile(aFilename); + while true do + begin + if Position = Size then + exit; + read(value,1); + if value = #10 then + exit(1); + if value = #13 then + exit(2); + end; + finally + Free; + end; +end; function getSysLineEndLen: byte; begin diff --git a/src/ce_editor.pas b/src/ce_editor.pas index 41d031a7..ac20f583 100644 --- a/src/ce_editor.pas +++ b/src/ce_editor.pas @@ -378,8 +378,8 @@ begin // note: SelStart only matches srcpos if the target file has the same line ending // as the operating system: the pos has to be found manually. sum := 0; - //len := getLineEndingLength(fDoc.fileName); - len := getSysLineEndLen; + len := getLineEndingLength(fDoc.fileName); + //len := getSysLineEndLen; for i := 0 to fDoc.Lines.Count-1 do begin linelen := length(fDoc.Lines.Strings[i]); diff --git a/src/ce_synmemo.pas b/src/ce_synmemo.pas index 64751295..99a7b781 100644 --- a/src/ce_synmemo.pas +++ b/src/ce_synmemo.pas @@ -621,9 +621,14 @@ var begin result := 0; //len := getLineEndingLength(fFilename); + len := getSysLineEndLen; + + for i:= 0 to fMousePos.y-2 do - result += length(Lines.Strings[i]) + getSysLineEndLen; + result += length(Lines.Strings[i]) + len; result += fMousePos.x; + + //getMessageDisplay.message(format('%d - %d : %d',[fMousePos.x, fMousePos.y, result]),nil,amcMisc,amkBub); end; procedure TCESynMemo.MouseMove(Shift: TShiftState; X, Y: Integer); @@ -641,7 +646,7 @@ begin ((dy < 0) and (dy > -5) or (dy > 0) and (dy < 5)) then fCanShowHint:=true; fOldMousePos := Point(X, Y); - fMousePos := PixelsToRowColumn(fOldMousePos, []); + fMousePos := PixelsToRowColumn(fOldMousePos); if ssLeft in Shift then identifierToD2Syn; end;