When trying to get a subst() from the console view I’m getting an empty output. Has anyone accessed console content with python API?
Access console from python
Sorry, I think I was using find_output_panel('console') but apparently this returns None.
The view associated to the build output can be obtained with window.find_output_panel("exec").
No worries, I doubt the console is supported at the moment… To give some background I’ve been trying to access logged commands as the current command_history in API is too limited.
why not just create a http://www.sublimetext.com/docs/3/api_reference.html#sublime_plugin.EventListener and listen for on_post_window_command and on_post_text_command and create your own log?
if you really need to access the console, your best bet is redirecting stdout.
Cheers, I’ll give it a shot.
Yup this was exactly I was looking for.
Again, many thanks for pointing that out!
I ran into the same wall and tested it properly on Windows (builds 4200 and 4215). Short version: there is no API for the console text. find_output_panel("console") returns None because the console is not an output panel (Will confirmed this in sublimehq/sublime_text#2929; the open request is #2984). Redirecting stdout only catches what is printed after the hook, and only in that plugin host, so on Sublime 4 a hook in a 3.8 plugin misses everything the 3.3 plugins print, tracebacks included. The one thing that gave me the full console on Windows was copying it with real keyboard input (click in the console, Ctrl+A, Ctrl+C, read the clipboard), with a unique marker line printed first to prove the copy really is the console.
Details, what failed, and the pitfalls (including crashes when raising a background window): https://gist.github.com/dpc00/899e257d4eb79575c1be2d6e354f2950
