Skip to content

Commit

Permalink
Определение координат строки
Browse files Browse the repository at this point in the history
  • Loading branch information
lintest committed Nov 11, 2021
1 parent 96c4fe0 commit f1500f9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vanessa-automation-editor",
"version": "1.3.3",
"version": "1.3.4",
"description": "Vanessa Automation Editor",
"homepage": "https://github.com/Pr-Mex/VAEditor/",
"private": true,
Expand Down
15 changes: 9 additions & 6 deletions src/vanessa-tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,23 +515,24 @@ export class VanessaTabs {
this.current?.editor.trigger(source, handlerId, payload);
}

public getСoordinates = (
public getCoordinates = (
lineNumber: number,
column: number,
) => {
if (!this.isCodeEditor) return undefined;
const editor = this.current.editor.editor;
const options = editor.getOptions();
const layoutInfo = options.get(monaco.editor.EditorOption.layoutInfo);
const height = options.get(monaco.editor.EditorOption.lineHeight);
const lineHeight = options.get(monaco.editor.EditorOption.lineHeight);
const top = editor.getTopForLineNumber(lineNumber)
- editor.getScrollTop() + this.domContainer.offsetHeight;
const left = editor.getOffsetForColumn(lineNumber, column)
+ layoutInfo.glyphMarginWidth
+ layoutInfo.lineNumbersWidth
+ layoutInfo.decorationsWidth
- editor.getScrollLeft();
return { left, top, height };
const rect = document.body.getBoundingClientRect();
return { left, top, lineHeight, windowWidth: rect.width, windowHeight: rect.height };
}

public getRectangle = (
Expand All @@ -545,15 +546,17 @@ export class VanessaTabs {
const x2 = Math.min(startColumn, endColumn);
const y1 = Math.min(startLineNumber, endLineNumber);
const y2 = Math.max(startLineNumber, endLineNumber);
const c1 = this.getСoordinates(y1, x1);
const c2 = this.getСoordinates(y2, x2);
const c1 = this.getCoordinates(y1, x1);
const c2 = this.getCoordinates(y2, x2);
return {
left: c1.left,
top: c1.top,
right: c2.left,
bottom: c2.top,
height: c2.top + c2.height - c1.top,
height: c2.top + c2.lineHeight - c1.top,
width: c2.left + c2.left,
windowWidth: c1.windowWidth,
windowHeight: c1.windowWidth,
};
}

Expand Down

0 comments on commit f1500f9

Please sign in to comment.