Merge pull request #1150 from keymanapp/developer-web-editor-find-error-by-offset

[Developer] Add FindErrorByOffset support for future use by JSON, XML editors
This commit is contained in:
Marc Durdin 2018-08-30 19:14:08 +10:00 • committed by GitHub
commit f2d300fee8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 11 deletions

View file

@ -849,24 +849,31 @@ begin
end;
function TframeTextEditor.OffsetToLine(Offset: Integer): Integer; // I4083
var
line: Integer;
begin
Result := 0;
// while (Result < memo.ParagraphCount) and (Offset > memo.PargrphOffset[Result]) do
// Inc(Result);
with TStringList.Create do
try
Text := Self.GetText;
line := 0;
while offset > 0 do
begin
Dec(offset, Strings[line].Length + 2);
Inc(line);
end;
finally
Free;
end;
Result := line;
end;
procedure TframeTextEditor.FindErrorByOffset(offset: Integer); // I4083
begin
ClearError;
{TODO: if offset <= 0 then Exit;
memo.SelStart := offset;
memo.SelCol := 0;
memo.ScrollInView;
FErrorPar := memo.SelLine;
UpdateParColour(FErrorPar, pcltError);}
FindError(OffsetToLine(offset));
end;
procedure TframeTextEditor.FireCommand(const commands: TStringList);

View file

@ -98,6 +98,14 @@ window.editorGlobalContext = {
context.loading = false;
};
context.setText = function (text) {
let range = editor.session.selection.getRange();
context.loading = true;
editor.session.setValue(text);
editor.session.selection.setSelectionRange(range);
context.loading = false;
};
/* Printing */
context.print = function () {