I wish to make a Sublime Text 2 plugin which will display information in an area at the bottom of the screen, just like the console does. However in this area I wish to display my own text from my Plugin, not related to the console.
Here is a screenshot of a window with the console open.
How can this be done?
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.
Type 'Terminus' and select it. Wait for it to Complete installation and Restart sublime text. And save it. Note: The above code is for Linux users for Windows users you have to enter “cmd.exe” in place of “bash”, also here we kept the shortcut key as “alt+1” you can use your own key.
Sublime is quite alive, and as stated previously, has some alpha testing going on. Any large project has old bugs going back a long way.
Use Ctrl + ' to open the console. When Ctrl + ` is pressed, Sublime Text does not receive anything.
Basically, what you need is
self.window.get_output_panel("textarea")
self.window.run_command("show_panel", {"panel": "output.textarea"})
A simple example is shown below. And you can refer to exec command in the default package: C:\Users\lhuang\AppData\Roaming\Sublime Text 2\Packages\Default\exec.py
.
class ShowTextAreaCommand(sublime_plugin.WindowCommand):
def run(self):
self.output_view = self.window.get_output_panel("textarea")
self.window.run_command("show_panel", {"panel": "output.textarea"})
self.output_view.set_read_only(False)
edit = self.output_view.begin_edit()
self.output_view.insert(edit, self.output_view.size(), "Hello, World!")
self.output_view.end_edit(edit)
self.output_view.set_read_only(True)
And if you're going after Sublime Text 3, where begin_edit() and end_edit() are depreciated:
class ShowTextAreaCommand(sublime_plugin.WindowCommand):
def run(self):
self.output_view = self.window.get_output_panel("textarea")
self.window.run_command("show_panel", {"panel": "output.textarea"})
self.output_view.set_read_only(False)
# edit = self.output_view.begin_edit()
# self.output_view.insert(edit, self.output_view.size(), "Hello, World!")
self.output_view.run_command("append", {"characters": "Hello, World!"})
# self.output_view.end_edit(edit)
self.output_view.set_read_only(True)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With