Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sublime Text (3) plugin define new panel

I see a lot of calls to this show_panel function with an args object like this:

{
    "keys": ["ctrl+shift+f"],
    "command": "show_panel",
    "args": {"panel": "find_in_files"}
}

I cannot find where the show_panel function is defined and am beginning to think that it is not exposed. Is it possible to define a new panel?

like image 380
km6zla Avatar asked Nov 27 '13 01:11

km6zla


People also ask

How do I edit a build in Sublime Text 3?

sublime-build , and it will now be accessible in the build system menu. Select it, hit Ctrl B to build, and then hit Ctrl Shift B to run the resulting program. Or you can use a Build and Run option and call it by hitting Ctrl B , then selecting that option.

How do I display output in Sublime Text?

In order for taking input and receiving output from a code, we need to manually set up our input and output files. Step 1: From the top menu, select View->Layout->Columns :3 or press Shift+Alt+3. Step 2: Now select View->Groups->Max columns: 2. Step 3: Now you can view three files simultaneously in sublime text.


Video Answer


1 Answers

Yes. It's possible.
In Sublime Text 2, basically what you need is:

  1. Create an output panel: window.get_output_panel("paneltest"), this return a <sublime.View object>
  2. Enable edition: <sublime.View object>.set_read_only(False)
  3. Open buffer editor: <sublime.View object>.begin_edit(), this return a <sublime.Edit object>
  4. Write to view you want: <sublime.View object>.insert(edit, pt.size(), "Writing...")
  5. Close buffer editor: <sublime.View object>.end_edit()
  6. Disable edition: <sublime.View object>.set_read_only(True)
  7. Show your panel: window.run_command("show_panel", {"panel": "output.paneltest"})

To test, enter lines above one by one on Console View in Sublime:

pt = window.get_output_panel("paneltest")
pt.set_read_only(False)
edit = pt.begin_edit()
pt.insert(edit, pt.size(), "Writing...")
pt.end_edit(edit)
window.run_command("show_panel", {"panel": "output.paneltest"})

In Sublime Text 3, don't execute steps 3 and 5.

like image 168
Nery Jr Avatar answered Oct 22 '22 04:10

Nery Jr