macro and placeholder in script mode

Aznoh
2012-09-21
2012-10-17
  • Aznoh
    Aznoh
    2012-09-21

    Hi,

    I'm not able to create placeholder (that mark text as descriptive text which
    can be selected by Ctrl+Left/Right) in script mode.

    When I trid:

    editor.insertText("<%description%>")
    

    or

    editor.write("<%description%>")
    

    it does not work, it only write it as a text string, char <% are not
    interpreted.

    In http://texstudio.svn.sourceforge.net/viewvc/texstudio/trunk/utilities/user
    manual_en.html#SECTION33c
    is command
    setPlaceHolder(int i) that I suppose to be able set placeholder, but it works
    only for navigation (it place cursor to placeholder with id i, that is in
    document.

    So, could you help me please, how to place placeholder in script mode?

     
  • Aznoh
    Aznoh
    2012-09-21

    Oh, sorry, bug in my post - please replace all "<%" to "%<".

     
  • You can use

    editorView.insertMacro("x%x");

    The editor object gives direct access to qcodeedit, while the %< %> is
    texstudio syntax, so the editor does not know it...

    (There would also be editor.addPlaceHolder, but it requires a
    Placeholder object, which can not be created by a script, yet.)

    On 09/21/2012 12:19 PM, SourceForge.net wrote:

     
  • Aznoh
    Aznoh
    2012-09-21

    Many thanks! It works:-)

     
  • Aznoh
    Aznoh
    2012-09-25

    Next one question - why "%|" does not work this way?

     
  • Well, it does work.

    But the script has a variable "cursor", and when it ends, the cursor is
    moved to the
    position set in that variable...

    On 09/25/2012 09:57 PM, SourceForge.net wrote: