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

Tag autocompletion #842

Closed
ludenticus opened this Issue Feb 1, 2018 · 28 comments

Comments

Projects
None yet
3 participants
@ludenticus
Contributor

ludenticus commented Feb 1, 2018

@Maboroshy's script for automatic tagging is simply great. One missing feature, though, is the autocompletion: you can save time if the editor show you a list of possibilities after writing the @. Besides, it would help avoiding similar tag entries (whenever you have, for instance singular and plural: @appointment and @appointments).

@pbek pbek added the question label Feb 1, 2018

@pbek

This comment has been minimized.

Owner

pbek commented Feb 1, 2018

Why don't you use the keyboard shortcut to add a tag to your note? The tag should be added to your note (as far as I remember). I guess the script could also add the tag to the current cursor position.

@Maboroshy

This comment has been minimized.

Contributor

Maboroshy commented Feb 1, 2018

I'm flattered but it's mostly @pbek's work and mainly under the hood of QON to make such script possible. I've just added a few tweaks.
Autocompletion is quite a heavy feature to implement, especially with scripting. I have no idea how to implement something as this as a script without reinventing half of Qt in progress.

@pbek

This comment has been minimized.

Owner

pbek commented Feb 1, 2018

There already is a autocomplete feature in QON that looks for words already used in the current note. There would be an api needed to tweak the list of strings and an other api to do a sub-string search of tags, but I'm not sure if it's worth the effort. I guess it would be nice to have an auto-completer api...

@pbek pbek added enhancement and removed question labels Feb 2, 2018

@pbek

This comment has been minimized.

Owner

pbek commented Feb 2, 2018

I'll create that functionality in the scripting api.

@Maboroshy

This comment has been minimized.

Contributor

Maboroshy commented Feb 2, 2018

That would be a big step forward for in-text tagging.

It would also be very useful for notes that have some repetitive text blocks. If user could save such text blocks to completer, and enter them by typing just a few letters (even if they are not present in note yet) it will be a valuable unique feature.

Apart from saving stuff from the internet I use QON to manage my job todo list. If I could type all those endless "call", "write email", "send message", "examine" with just a few letters QON will be much more productive for me.

@pbek

This comment has been minimized.

Owner

pbek commented Feb 3, 2018

18.02.0

  • there now is a new scripting hook autocompletionHook() to return a list of
    strings to be added to the autocompletion list when the autocompletion is
    invoked by pressing Ctrl + Space
    (for #842)
  • there now is a new scripting function script.noteTextEditCurrentWord() to
    read the current word in the note text edit (for #842)
  • there now is a new scripting function script.searchTagsByName() to
    fetches all tags by doing a substring search on the name field
    (for #842)
  • the script @tag tagging in note text was updated to use autocompletion
    (for #842)

@pbek pbek added this to the 18.02.0 milestone Feb 3, 2018

@pbek

This comment has been minimized.

Owner

pbek commented Feb 3, 2018

There now is a new release, could you please test it and report if it works for you (especially the autocompletion in the @tag tagging in note text script)?

@ludenticus

This comment has been minimized.

Contributor

ludenticus commented Feb 3, 2018

As usual, Patrizio rules!

However, there is one minor issue: @tag_one is autocompleted as @tag one

@pbek

This comment has been minimized.

Owner

pbek commented Feb 4, 2018

Thanks, it was quite some work. :)

At what character did you start to autocomplete and you have a tag tag one in your tag panel?

@ludenticus

This comment has been minimized.

Contributor

ludenticus commented Feb 4, 2018

As I use QON for my study notes, I have a fairly long list of tags; most tags are one word, but then I have some tags with two or even three words. For instance: @history, @history_of_ideas and @conceptual_history. So, I'd usually write three or four characters, such as @hist, press Ctrl + space and the three aforementioned tags will be displayed. If I'd try it with only one character or two, the list overflows the screen. Once I select a tag with more than one word, it will be printed without underscores.

@pbek

This comment has been minimized.

Owner

pbek commented Feb 4, 2018

Can't reproduce that. When I autocomplete my tag two_words it writes exactly two_words.
Any log-output (please turn on debug logging)?

@pbek

This comment has been minimized.

Owner

pbek commented Feb 4, 2018

the list overflows the screen

I guess @Maboroshy could fix that in the script ;)

@ludenticus

This comment has been minimized.

Contributor

ludenticus commented Feb 4, 2018

If I have the @two_words already written in the note, then it will pop out twice: once with underscores, once without. Of course, the only reason to write again one such tag is by mistake. For instance: http://tinypic.com/r/2samjqf/9.

Debug info for this autocompletion:

noteTextEditAutoComplete  - 'text':  "Steph"
noteTextEditAutoComplete  - 'resultList':  ("Stephen_King")

However, if I choose a two word tag not previously written in the note, then the debug info is different: It shows only the first sentence, but not the second one. There is no 'resultList'. Like this:

noteTextEditAutoComplete  - 'text':  "histo"
@pbek

This comment has been minimized.

Owner

pbek commented Feb 4, 2018

If I have the @two_words already written in the note, then it will pop out twice:

that's ok

  • once because the built-in note text auto-completer found it
  • once because the script said so

once with underscores, once without.

I can't reproduce that and I don't know why it should show up without underscores... unless you really have a tag without underscores. So... Do you?
Tags are still stored in the tag database and can have spaces...

It shows only the first sentence

what sentence?

@ludenticus

This comment has been minimized.

Contributor

ludenticus commented Feb 4, 2018

It shows only the first sentence

I meant, that the debug didn't show a 'resultList': ("history_of_ideas").

My two–word tags are always with underscores.

@pbek

This comment has been minimized.

Owner

pbek commented Feb 4, 2018

It would be interesting to see the content of your notes.sqlite database from your notes folder, where the tags are stored...

@Maboroshy

This comment has been minimized.

Contributor

Maboroshy commented Feb 4, 2018

I guess @Maboroshy could fix that in the script ;)

I'll look into it. There's some to _ missing. The question is where to put it.

Is it possible to have more control over the completion menu pop-up? I think the following can greatly improve completion usability:

  1. The menu should pop-up under the current line, not at the center of it;
  2. Typing should be possible when pop-up show up. Typing should update the menu, or hide it if user input comes out of dictionary;
  3. Some strings should trigger menu without need for a key shortcut after defined number of characters. For example in-text tag marker should instantly trigger menu narrowing items as user types;
  4. A constant completion assisted input mode would be handy, like in kwrite.
@pbek

This comment has been minimized.

Owner

pbek commented Feb 4, 2018

  1. The menu should pop-up under the current line, not at the center of it;

It was tricky, but I think I now could compensate all offsets.

2 to 4

I've no idea if and how that could be done.

@pbek

This comment has been minimized.

Owner

pbek commented Feb 4, 2018

18.02.1

  • fixed autocompleter user interface offset, especially in the distraction free mode
@Maboroshy

This comment has been minimized.

Contributor

Maboroshy commented Feb 4, 2018

I've no idea if and how that could be done.

Kwrite does it, so it's possible. If I understand correctly completion QMenu steals focus and all the input from QTextEdit. I'd start from implementing keyPressEvent() for QMenu so it would accept only Up, Down or Enter and hide QMenu on any other key while ignoring event at the same time, so QTextEdit could receive it. Haven't tried it though. If after new character the input is still in range QMenu pops-up again.

@pbek

This comment has been minimized.

Owner

pbek commented Feb 4, 2018

This sounds promising: https://doc.qt.io/qt-5/qtwidgets-tools-customcompleter-example.html
But it would mean a complete re-implementation...

@Maboroshy

This comment has been minimized.

Contributor

Maboroshy commented Feb 4, 2018

Oh, it's a link from my first post here.

@Maboroshy

This comment has been minimized.

Contributor

Maboroshy commented Feb 5, 2018

I've updated the script for correct conversion of tags with spaces.

@ludenticus

This comment has been minimized.

Contributor

ludenticus commented Feb 5, 2018

@Maboroshy

Script version 0.0.7 works as inteded with two–word tags (@tag_one), but it produces spaces whenever the tag has more than one underscore: @tag_one_two will be autocompleted as @tag_one two

@Maboroshy

This comment has been minimized.

Contributor

Maboroshy commented Feb 6, 2018

Thanks for reporting. It's a known bug in my head :) - the difference of replace syntax in Python an QML/JS I always forget. Will fix soon.

@Maboroshy

This comment has been minimized.

Contributor

Maboroshy commented Feb 6, 2018

I fixed the script.

@pbek pbek modified the milestones: 18.02.0, 18.02.1 Feb 12, 2018

@pbek

This comment has been minimized.

Owner

pbek commented Feb 12, 2018

There now is a new release, could you please test it and report if it works for you?

@pbek

This comment has been minimized.

Owner

pbek commented Feb 13, 2018

I will close this issue until there is more information.

@pbek pbek closed this Feb 13, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment