New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: scripting methods for cusor operation #2533
Comments
Since you have access to the note text you could calculate pretty any position by counting how many characters each line has, can't you? |
@pbek Just find two methods that are probably related, I can select current line with |
let lineList = noteText.split("\n");
// First line
lineList[0];
// Second line
lineList[1]; |
And then you could count the characters in each line... |
@pbek Thank you, I did manage to achieve that. Is there a way to move cursor to next/previous word or block? |
You could try to split the lines by word boundary |
This issue is stale because it has been open for 30 days with no activity. |
This issue was closed because it has been inactive for 14 days since being marked as stale. |
I've always wanted to write a script to regester custom actions for cursor movement. In the scripting document, I found two methods QOwnNotes provides with regards to cursor position or movement:
noteTextEditSetCursorPosition(int position)
andnoteTextEditCursorPosition()
.With these two methods, I can move cursor forward or backward by 1 (or a certain number) character like this:
script.noteTextEditSetCursorPosition(currentPosition + 1);
But I couldn't figure out how to move cursor to next line or previous line, just as the simple
up arrow
anddown arrow
keys do, probably an extra API for getting current line number is necessary. Or even more, how to move cursor to next/previous word or block.I know the cursor moving keymap is available in Vim mode, but I'd like to just have some shortcuts for cursor moving without having to switch to full Vim mode.
I there a way to implement these cursor moving actions just with the API currently provided by QOwnNotes that I missed out? If so, could you give me some advises how to do that? If not, it would be very nice to have some extra scripting methods for cursor movement in QOwnNotes, I think this will offer a lot of flexibility for custom cursor operation.
Thank you in advance for your help:)
The text was updated successfully, but these errors were encountered: