5

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?

MattDMo
  • 100,794
  • 21
  • 241
  • 231
km6zla
  • 4,787
  • 2
  • 29
  • 51
  • It's a bit old but as i am researching for my sublime i found your post... Do you mean a new tab? i do my git in a toggleable new tab if that helps – Erik255 Jan 22 '14 at 13:30
  • Hey @Erik255 I am actually referring to a panel like what pops up when you try to do a find. I know that I can pop up a singe-line prompt at the bottom but I wanted to be able to create a multiline form. Let me know if you come up with a way to do this. – km6zla Jan 22 '14 at 17:06

1 Answers1

6

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.

Nery Jr
  • 3,849
  • 1
  • 26
  • 24
  • That does answer my question. I guess then that leads me to wonder if that panel can be skinned and if buttons can be added to it or if we are limited to text and no interaction. – km6zla Feb 07 '14 at 16:56
  • 2
    If you don't do steps 3 and 5 how do you write to the panel in step 4 without an edit variable? – Jon Sep 12 '14 at 17:58
  • Is there documentation for this sort thing in sublime ? – bigmadwolf Sep 14 '14 at 12:15
  • @Jon In ST3, you are supposed to create a TextCommand that does the editing and then run the command on the panel (which is a view). See https://www.sublimetext.com/docs/3/porting_guide.html – Gary Chang Nov 13 '14 at 02:42