[ZeroBrane Studio] Re: Two plugin API questions...

  • From: Paul K <paul@xxxxxxxxxxxxx>
  • To: "zerobrane@xxxxxxxxxxxxx" <zerobrane@xxxxxxxxxxxxx>
  • Date: Sun, 8 Oct 2017 10:12:58 -0700

Hi Paul,

I am writing a small plugin for ZBS and I am wondering how to get info from
the current document. How, for a necessary example, would I get the line
number of where the caret is in the current document?

You can get all this information using the api that the editor
component itself provides; see the Editor API section in the
documentation: https://studio.zerobrane.com/doc-plugin#editor-api. The
other APIs are listed in the documentation as well:
https://studio.zerobrane.com/doc-plugin#plugin-guidelines.

Specifically, to get the current line you can use
ide:GetEditor():GetCurLine(), which returns both the content of the
line and its number (starting from 0). Looking at how other plugins or
the IDE itself does this will also help with figuring out what methods
to use. You can test these methods in the local console, so this
provides an easy way to see what methods are available and what
results they return. Just keep in mind that line numbers are 0-based
in the editor.

Paul.

Other related posts: