As discussed, o.a. for https://github.com/qownnotes/scripts/pull/57 it would be nice to have functionality exposed to scripting that enables to:
Goal in the toggle-checkbox script:
Hope this is clear, thanks in advance!
You will get this in the next release
Don't forget to bump the minimum version in your script 馃槈
You will get this in the next release
'this' === dropdown in settings?
Awesome! :raised_hands:
This issue is actually about being able to set/get the selected text in a note :wink:
lol, I totally thought you were talking about the select box feature
@sanderboom what beside current line is selected doesn't work yet?
reapply a selection
that will never work if the text in the note text edit was changed
You can read the selected text in the note text edit with http://docs.qownnotes.org/en/develop/scripting/README.html#read-the-selected-text-in-the-note-text-edit and overwrite it with http://docs.qownnotes.org/en/develop/scripting/README.html#write-text-to-the-note-text-edit, can't you?
script.noteTextEditSelectCurrentLine()There now is a new release, could you please test it and report if it works for you?
there now is a new scripting command script.noteTextEditSelectCurrentLine() to select the current line in the note text edit
Works grrreat :smiley:
Implemented the 2 new features right away: https://github.com/qownnotes/scripts/pull/58
reapply a selection
that will never work if the text in the note text edit was changed
Can you pass the start- and end-postiion of the selection? All we need then is a method to apply a selection from start- to end-position... Idea?
Can you pass the start- and end-postiion of the selection? All we need then is a method to apply a selection from start- to end-position... Idea?
those are just absolute positions (the Xth character) in the text edit. if you change the text those positions would change too :/
those are just absolute positions (the Xth character) in the text edit. if you change the text those positions would change too :/
I think I can work with that. I know what I change so I should be able to figure out what the new end position for the selection needs to be. The starting position will stay the same. Apply the new selection would be the last thing to do in the customAction.
The goal is to make the multiline-toggle as easy as the single-line: without manual reselecting:

What do you think?
So what scripting functionality would you need? An api to read the position of the current selection (e.g. https://doc.qt.io/qt-5/qtextcursor.html#selectionStart) and a method to set a selection (from / to).
Yes, get the selectionStart, get the selectionEnd and setSelection from/to would be perfect!
You will get those commands in the next release.
script.noteTextEditSetSelection(),script.noteTextEditSelectionStart() and script.noteTextEditSelectionEnd()There now is a new release, could you please test it and report if it works for you?
Strange, yay -Syyu --devel does not present the new version. I am building now from the snapshot download from the AUR directly.
The new functions work great. Didn't have to use the endPos at all, I just have startPos + new length :wink:
Apparently the .length is utf-8 proof :+1:

BTW, I do this: var resultText = lines.join('\n');, do I need to take Windoze users into account? How to know whether I should use \r\n instead?
Awesome!
do I need to take Windoze users into account
good question, most of the time I also just take \n into account...
Most helpful comment
You will get those commands in the next release.