How to console the row and column in time when cursor locate in the editor? Is there an official explanation? #4621
-
I have a monaco-editor demo as below: 1、The function I want to implement is to click the mouse in the editor, and then print the row and column in time(such as in the snapshot: print out: 2、 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
What do you mean by "console the row and column in time"? 🤔 |
Beta Was this translation helpful? Give feedback.
-
i mean print the line number and the index number at the line.
…---- Replied Message ----
| From | Remy ***@***.***> |
| Date | 07/30/2024 02:30 |
| To | ***@***.***> |
| Cc | ***@***.***>***@***.***> |
| Subject | Re: [microsoft/monaco-editor] How to console the row and column in time when cursor locate in the editor? Is there an official explanation? (Discussion #4621) |
The function I want to implement is to click the mouse in the editor, and then console the row and column in time.
What do you mean by "console the row and column in time"? 🤔
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
@liaodalin19903 Perhaps this snippet of code may be of help to you then. const value = `function hello() {
alert('Hello world!');
}`;
const editor = monaco.editor.create(
document.getElementById("container"), {
value,
language: "javascript",
automaticLayout: true,
});
editor.onDidChangeCursorPosition((e) => {
document.getElementById("console").textContent = JSON.stringify(e.position);
}); <div id="container" style="height: 100%">
<div id="console">Console</div>
</div> |
Beta Was this translation helpful? Give feedback.
@liaodalin19903 Perhaps this snippet of code may be of help to you then.