QOwnNotes icon indicating copy to clipboard operation
QOwnNotes copied to clipboard

FEATURE: Re-number list with Ctrl-Space

Open schultzter opened this issue 3 years ago • 5 comments

Expected behaviour

I'm inspired by how Ctrl-Space reformats a table, I would like to propose a feature request to extend the auto-format capability to numbered lists. So when I press Ctrl-Space in a list it will renumber the list so all the items have sequential numbers.

I know the final rendered result will have sequential numbers but I use QOwnNotes more in the live preview mode then the final rendered results.

Thanks

Actual behaviour

Ctrl-Space does nothing in a list.

Steps to reproduce

Create a list with non-sequential numbered items, ex.:

1. item 1
2. item 2
4. item 3
5. item 4
9. item 5

Keep the cursor in the list and press Ctrl-Space but nothing happens!!!

Output from the debug section in the settings dialog

Expand

QOwnNotes Debug Information

General Info

Current Date: Wed Mar 16 18:05:40 2022 Version: 22.3.2 Build date: Mar 8 2022 Build number: 957 Platform: windows Operating System: Windows 10 Version 2009 Build architecture: x86_64 Current architecture: x86_64 Release: GitHub Actions Qt Version (build): 5.15.2 Qt Version (runtime): 5.15.2 Portable mode: no Settings path / key: \HKEY_CURRENT_USER\Software\PBE\QOwnNotes Application database path: C:\Users\redact\AppData\Roaming\PBE\QOwnNotes\QOwnNotes.sqlite Application arguments: C:\Users\redact\AppData\Local\Programs\QOwnNotes\QOwnNotes.exe Qt Debug: 0 Locale (system): en_CA Locale (interface): empty Primary screen resolution: 1366x768 Screen resolution(s): 1366x768, 1920x1080 Icon theme: breeze-qownnotes Notes in current note folder: 10 Calendar items: 0 Enabled scripts: 0

Relevant log output in the Log panel

Expand

schultzter avatar Mar 16 '22 22:03 schultzter

This sounds like a job for the scripting engine (if there isn't already a script in the script repository). https://www.qownnotes.org/scripting/

Let me know if you are interested in working on such a script, I could help you.

But keep in mind, even if you are reordering the ordered list it will no have any effect on the preview because in a browser the numbers of the <ol> items are decided by the browser.

pbek avatar Mar 17 '22 05:03 pbek

Good morning, and happy St Patrick day!

I found this in your docs, https://www.qownnotes.org/scripting/hooks.html#autocompletionhook, that is activated on Ctrl+Space but I'm not sure that's the correct starting point? Or do I have to define my own keyboard shortcut/menu item for my re-number script?

I also found in the code where you auto format a table on Ctrl+Space but I don't know QT library well enough so it looks a lot like magic (and I generally consider C/C++ to be wizardry so you probably don't want me submitting any PR 😁).

Thanks

-- Headed for the second star to the right and straight on 'til morning...

Eric Schultz

On Thu, Mar 17, 2022 at 1:02 AM Patrizio Bekerle @.***> wrote:

That sounds like a job for the scripting engine (if there isn't already a script in the script repository). https://www.qownnotes.org/scripting/

Let me know if you are interested in working on such a script, I could help you.

But keep in mind, even if you are reordering the ordered list it will no have any effect on the preview because in a browser the numbers of the

    items are decided by the browser.

    — Reply to this email directly, view it on GitHub https://github.com/pbek/QOwnNotes/issues/2495#issuecomment-1070328762, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAHRF7OLBNAPLMXK3TEHE3VAK4GHANCNFSM5Q5FSFRQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

    You are receiving this because you authored the thread.Message ID: @.***>

schultzter avatar Mar 17 '22 12:03 schultzter

Auto format table in code: bool Utils::Gui::autoFormatTableAtCursor(QPlainTextEdit *textEdit)

schultzter avatar Mar 17 '22 12:03 schultzter

I wouldn't use the auto-completion mechanic, because not everyone would like to have their lists reordered just because they use the auto-completion.

A custom action would make more sense... Speaking of which, did you look in the script repository? There already is https://github.com/qownnotes/scripts/blob/master/fix-list-numbers/fix-list-numbers.qml.

pbek avatar Mar 17 '22 12:03 pbek

Cool. That script does exactly what I was looking for!

On Thu., Mar. 17, 2022, 8:55 a.m. Patrizio Bekerle, < @.***> wrote:

I wouldn't use the auto-completion mechanic, because not everyone would like to have their lists reordered just because they use the auto-completion.

A custom action would make more sense... Speaking of which, did you look in the script repository? There already is https://github.com/qownnotes/scripts/blob/master/fix-list-numbers/fix-list-numbers.qml .

— Reply to this email directly, view it on GitHub https://github.com/pbek/QOwnNotes/issues/2495#issuecomment-1070892915, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAHRF4S5ETOVNQKOBLE6C3VAMTTDANCNFSM5Q5FSFRQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

schultzter avatar Mar 17 '22 15:03 schultzter