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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top