Odd it worked for me. Here is what I tested with.
[code]import sublime, sublime_plugin
from subprocess import *
class man(sublime_plugin.TextCommand):
def run(self, edit):
#Set some global to work whit in
#other functions
global aedit
global window
global view
#Get the windows and the view
aedit=edit
window = self.view.window()
view = self.view
#if the selection is empty, ask for the page
if view.sel()[0].empty():
window.show_input_panel("Man search :", "", self.input_ret,None,None)
else:
#if search is not empty
word = view.substr(view.sel()[0])
self.man_search(aedit,word)
def input_ret(self,text):
#if an text is set, search it
if text:
self.man_search(aedit,text)
def man_search(self,edit,to_search):
text = "{}".format(to_search)
#Open the man panel
man_panel = window.get_output_panel("man")
print(man_panel)
#Wait that the panel is ready
while man_panel.is_loading():
pass
#print the search in console
print("searching in man: {}".format(text))
#Command to send
man_command="man","-P","cat","-7","-a", text]
#Open the pipe and redirect stdout to the pipe
pipe = Popen(man_command,stdout=PIPE,stderr=STDOUT)
(in_pipe,out_pipe) = pipe.communicate()
#insert text in the man panel
man_panel.run_command("simple_insert", {"content": in_pipe.decode("utf-8")})
#Show the panel
window.run_command("show_panel",{"panel":"output.man"})
class SimpleInsertCommand(sublime_plugin.TextCommand):
def run(self, edit, content):
print(self.view)
self.view.insert(edit, 0, content)
[/code]