Tab stops in code templates and inserted fragments in Author Mode?

Are you missing a feature? Request its implementation here.
ttasovac
Posts: 82
Joined: Fri Dec 19, 2003 6:02 pm

Tab stops in code templates and inserted fragments in Author Mode?

Post by ttasovac »

Hi. I was wondering if you would consider introducing tab stops in code templates (unless I've missed them in the documentation).

Tab stops are the mechanism that other text editors (such as Atom, VS Code etc.) use to help the user move the cursor to the next specific place in the template by pressing the TAB key.

Why are tabstops useful?

When you have a code template or an insertFragment action with nested elements, such as this:

Code: Select all

<entry xmlns="http://www.tei-c.org/ns/1.0">
 <form type="lemma">
   <orth>${1}</orth>
 </form>
  <gramGrp>
    <gram type="pos">${2}</gram>
  </gramGrp>
  <sense>
    <def>${3}</def>
    <cit type="example">
      <quote>${4}</quote>
      <bibl>${5}</bibl>
    </cit>
  </sense>
</entry>

you want the user in the Author Mode to move the caret easily from ${1} to ${2} etc. with the tab. At the moment, to get from orth to gram above, it takes three tabs, because in oXygen tabs only move you to the next node. Some frameworks, like TEI, can get quite verbose with nested nodes, and not all nodes should take content, so ideally you would want to be able to help the user to navigate the structure as simply and as efficiently as possible.

Some implementations get additional cool features such as tab stops combined with placeholders, choices etc. (see for instance https://github.com/jonschlinkert/tabstops) ...

What do you think?

All best,
Toma
alex_jitianu
Posts: 1008
Joined: Wed Nov 16, 2005 11:11 am

Re: Tab stops in code templates and inserted fragments in Author Mode?

Post by alex_jitianu »

Hello,

Unfortunately, you can't do this right now. We only have the ${caret} variable for controlling the initial position. I've added your vote for this feature and increase its priority.

Some thoughts on the matter, considering we are talking about the Author mode only.
1. I believe the navigation is not how you desire because some of the elements in the sample fragment have a mixed model (text+elements). If you insert the fragment like the one below the tab navigation is as expected (I think):

Code: Select all

    <entry xmlns="http://www.tei-c.org/ns/1.0">
        <form type="lemma"><orth>${1}</orth></form>
        <gramGrp><gram type="pos">${2}</gram></gramGrp>
        <sense><def>${3}</def><cit type="example">
            <quote>${4}</quote>
            <bibl>${5}</bibl>
          </cit></sense>
      </entry>
2. I believe you can use our API to implement this use case:
- intercept the fragment insertion and convert the markers to pseudo classes associated with the elements. Of course, you can store the information into other data structures, perhaps using positions to mitigate document changes.
- intercept the TAB event AuthorActionEventHandler and use the previous recorded information to decide where to move the caret.
If you decide to try the API approach and you bump into any difficulties, just let me know and I'll try to help.

Best regards,
Alex
ttasovac
Posts: 82
Joined: Fri Dec 19, 2003 6:02 pm

Re: Tab stops in code templates and inserted fragments in Author Mode?

Post by ttasovac »

Hey Alex. You were absolutely right. When I rewrote the fragment to be inserted without any text nodes between the elements, the TAB navigation worked for me as expected. Many thanks!

I still think the tab stops would be useful to have for other use cases, so many thanks for noting my vote on that as well.

All best,
Toma
Post Reply