prepared code to get symb documentation at mouse position

This commit is contained in:
Basile Burg 2015-01-04 04:56:32 +01:00
parent ea33425ffd
commit 1ecb859698
3 changed files with 51 additions and 1 deletions

View File

@ -222,6 +222,11 @@ type
*)
procedure ensureNoPipeIfWait(aProcess: TProcess);
(**
* Returns the length of the line ending in aFilename;
*)
function getLineEndingLength(const aFilename: string): byte;
implementation
{$IFDEF LINUX}
@ -825,6 +830,35 @@ begin
aProcess.Options := aProcess.Options + [poNewConsole];
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;
initialization
RegisterClasses([TMRUList, TMRUFileList]);
dExtList := TStringList.Create;

View File

@ -250,7 +250,7 @@ begin
fClient.Parameters.Clear;
fClient.Parameters.Add('-d');
fClient.Parameters.Add('-c');
fClient.Parameters.Add(intToStr(fDoc.SelStart-1));
fClient.Parameters.Add(intToStr(fDoc.MouseStart -1));
fClient.Parameters.Add(fDoc.tempFilename);
fClient.Execute;
//

View File

@ -76,6 +76,8 @@ type
fMultiDocSubject: TCECustomSubject;
fStoredFontSize: Integer;
fPositions: TCESynMemoPositions;
fMousePos: TPoint;
function getMouseStart: Integer;
procedure changeNotify(Sender: TObject);
procedure identifierToD2Syn;
procedure saveCache;
@ -108,6 +110,8 @@ type
property isDSource: boolean read fIsDSource;
property isProjectSource: boolean read fIsConfig;
property TextView;
//
property MouseStart: Integer read getMouseStart;
end;
var
@ -510,11 +514,23 @@ begin
StaticEditorMacro.Execute;
end;
function TCESynMemo.getMouseStart: Integer;
var
i, le: Integer;
begin
result := 0;
le := getLineEndingLength(fFilename);
for i:= 0 to fMousePos.y-2 do
result += length(Lines.Strings[i]) + le;
result += fMousePos.x;
end;
procedure TCESynMemo.MouseMove(Shift: TShiftState; X, Y: Integer);
begin
inherited;
if ssLeft in Shift then
identifierToD2Syn;
fMousePos := PixelsToRowColumn(Point(X,Y));
end;
procedure TCESynMemo.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y:Integer);