Sublime Forum

Is there a way to adjust output console's result?

#1

Hello.

Does anyone knows how i can adjust the output console’s result a little bit more to the right side?
Is there any file which i can edit? I don’t know maybe there’s a margin or something like that…

This is how it is currently:

And this is i’d like to get:

Thanks in advance!

0 Likes

#2

I don’t know in general. If you just want to do this for a specific result of an exec command, you can apply a custom syntax to the result by defining a ‘syntax’ element to the args dictionary passed to the exec command. Then you can have custom syntax settings for that syntax where you set the margin setting.

For build systems, I don’t know if they can also get a ‘syntax’ argument. I assume they just pass the arguments to the exec command.

1 Like

#3

According to this post:

You can define syntax highlighting for the output panel using Packages/Default/Plain text.tmLanguage and then apply a theme to format that output text.

1 Like

#5

Thank you for the response and I’m sorry for the delay, I have had a problem with my linux and I’m still fixing it.

Ok, I don’t get it very well, I found this xml file but I don’t know what I should to do.
Can you explain me please?

Actually, I’m new on sublime text, so I saw the post that you pointed, but with my current experience, I still can’t get that, sorry about it.

Thank you.

0 Likes

#6

Sorry I think I wasn’t been clear about my issue.

I don’t wanna change syntax highlight, I just wanna insert a kind of margin or space where console’s output result begin. The console’s output text shows up very near to the left side of sublime text GUI and that’s cutting up the exec result.

As you guys can see:

I inserted manually a space here to gave you guys an idea of how i’d like to get it:

Thank you!

0 Likes

#7

There is the “margin” setting for a view, as gotten from view.settings().get(“margin”), this is what you’d want to change in the panel view, but I have no idea how.

0 Likes

#8

Thank you I gonna try to find that.

0 Likes

#9

you can apply it for all widgets in Widget.sublime-settings

0 Likes

#10

Thank you.

I found this json file, and this is what I have.

{
"rulers": [],
"translate_tabs_to_spaces": false,
"gutter": false,
"margin": 1,
"syntax": "Packages/Text/Plain text.tmLanguage",
"is_widget": true,
"word_wrap": false,
"auto_match_enabled": false,
"scroll_past_end": false,
"draw_indent_guides": false,
"draw_centered": false,
"auto_complete": false,
"match_selection": false

}

I changed margin element and it set the regex search bar only, I I’ll keep searching and trying.
Do you know if is there a console element I should insert to do that?

0 Likes

#11

I just tried changing widget margin and it worked for me. What theme are you using? The Widget.sublime-settings you have to edit is the one of your active theme, it should stay in the same folder.

0 Likes

#12

I’m using spacegray eighties theme, and I tried changing Widget - Spacegray Eighties.sublime-settings inserting a margin element, and it also doesn’t affected output panel. It’s weird…

Take a look:

`{
"color_scheme": "Packages/Theme - Spacegray/widgets/Widget - Spacegray Eighties.stTheme",
"draw_shadows": false,
// Margin I have inserted
"margin": 6

}`

I’m also using Anaconda plugin, and I found this:

/*
    Theme to use in the output panel.

    Uncomment the line below to override the default tests runner
    output, by default the theme is PythonConsoleDark.hidden-tmTheme
    NOTE: The file specified here **MUST** exists in `Packages/Anaconda`
*/
// "test_runner_theme": "PythonConsoleDark.hidden-tmTheme",

Maybe I should to do that, putting base16-eighties.dark.tmTheme in Packages/Anaconda and to try to override that in anaconda settings file.

I’ll try.

Thank you!

0 Likes

#13

There’s a bit of confusion between themes and color schemes. tmTheme files are actually a color scheme. Themes are the ones with the extension “sublime-theme”.

I tried to do what you said you did with your theme, modified Widget - Spacegray Eighties.sublime-settings and it worked for the console, but not for the build panel. I think because it’s not considered a widget, and I think you need a plugin to do this.

1 Like

#15

Try this:

import sublime
import sublime_plugin

class BuildOutputListener(sublime_plugin.EventListener):

    def on_activated(self, view):

        if view == view.window().find_output_panel("exec"):
            view.settings().set('margin', 15)

It should set the margin to 15 when you build and click on the build panel the first time, then it should stay like that until you close ST.

1 Like

#16

You can also do this if you want to open the build view in a normal view after clicking on the build panel:

import sublime
import sublime_plugin


class BuildToView(sublime_plugin.TextCommand):

    def run(self, edit):

        w = sublime.active_window()
        v = w.find_output_panel("exec")
        content = v.substr(sublime.Region(0, v.size()))
        build_view = w.new_file()
        build_view.set_scratch(True)
        build_view.set_name("### Build results ###")
        build_view.insert(edit, 0, content)
        scheme = 'Packages/Anaconda/PythonConsoleDark.hidden-tmTheme'
        build_view.settings().set('color_scheme', scheme)


class BuildOutputListener(sublime_plugin.EventListener):

    def on_activated(self, view):

        if view == view.window().find_output_panel("exec"):
            view.window().run_command('build_to_view')
            view.settings().set('margin', 5)

You can change the color scheme of the build view by editing the line:

scheme = 'Packages/Anaconda/PythonConsoleDark.hidden-tmTheme'

1 Like

#17

It worked like a charm! Thank you!

Actually I also used your code idea, and inserted this line in exec.py:

`self.output_view.settings().set("margin", 10)`

It’s just to I don’t needed clicking on the build panel all the time.
If you have any other suggestion of how I can do that like plugin, it will be welcome.

Thanks for your patience.

0 Likes

#18

You can do this (a variant of the above):

    import sublime
    import sublime_plugin


    class BuildToView(sublime_plugin.TextCommand):

        def run(self, edit):

            w = sublime.active_window()
            v = w.find_output_panel("exec")
            content = v.substr(sublime.Region(0, v.size()))
            build_view = w.new_file()
            build_view.set_scratch(True)
            build_view.set_name("### Build results ###")
            build_view.insert(edit, 0, content)
            scheme = 'Packages/Anaconda/PythonConsoleDark.hidden-tmTheme'
            build_view.settings().set('color_scheme', scheme)


    class BuildOutputListener(sublime_plugin.EventListener):

        def set_margin(self, window):
            if window:
                v = window.find_output_panel("exec")
                if v:
                    v.settings().set('margin', 5)

        def on_text_command(self, view, command_name, args):

            if view == view.window().find_output_panel("exec"):
                if command_name == "drag_select" and 'by' in args and \
                        args['by'] == 'words':
                    view.window().run_command('build_to_view')

        def on_window_command(self, window, command_name, args):

            if command_name == "build":
                sublime.set_timeout_async(lambda: self.set_margin(window))

This detects the build command and sets the margin. Double click on the panel calls the command of the other post(if you like it, otherwise delete def on_text_command.

2 Likes

Can you guys enable to set the console output with different color for build and run etc?
#19

It’s worked!

Thanks again for your help.

That’s gonna help me two times cause I’m studying Python, I hope to improve soon and got Python better.

See ya.

0 Likes