KorAP / Kalamar

:octopus: Mojolicious-based Frontend for KorAP
BSD 2-Clause "Simplified" License
7 stars 2 forks source link

Plugin: fetch info about Cursor position and marked area. #228

Closed Bodmo closed 3 days ago

Bodmo commented 1 week ago

It would be nice if the Plugin-System could allow plugins to fetch the current cursor position and eventually the marked text area(s) on the Kalamar query line, too.

This info would idealy be fetched through the 'get/QueryForm' interface that is already in use. The returned object would return 2 new properties named 'cursor' and 'marked', as e.g.:

{ ... cursor: 4, marked: [5,8,10,12] }

Notice: the Kalamar query line allows for more than 1 marked areas, so the value of 'marked' should be an array of value pairs, where the value pairs indicate the start and end pos. of a marked area.

Akron commented 6 days ago

I just recognized that multiple selections are officially not supported for input fields and text areas in HTML5. So I guess we have to stick to:

{
  selected:[4,4]
}

(nothing selected, cursor at offset 4). and

{
  selected:[4,7]
}

(selection ranges from offset 4 to 7).

Bodmo commented 6 days ago

no problem for me.

Akron commented 4 days ago

I added a fix in Gerrit (9051).

Bodmo commented 4 days ago

yes, it works correctly. I just noticed that we have to keep in mind that the selection range [a b] means: the characters starting at a till the last character before b. E.g. if "bin" is selected in the Query "ich bin hier" the selection is [4 7]. Another probably more intuitive schema would have been [4 6] = selection from position 4 to pos. 6 (including 6) and for the cursor position without selection [4 -1].