get current cursor info

I am developing a content filtering function. The content is displayed in a CodeMirror, and the filtered results are displayed in another codeMirrror. When the user clicks the content of the displayed result codeMirrror and triggers a button click operation, I expect to get the line where the cursor is currently located The content or location of the number, how do I get this in