Sublime Forum

Font size for Build Results window

#1

I found from googling that the font of the Build Result window in ST3 is inherited from the Plain Text syntax-specific settings. This is somewhat awkward. I would like to keep viewing plain text files wit normal font, and view build results with smaller font. Is there a possible workaround, to tweak font of the Build Results window independently of any specific file syntax?

A related point - is it possible to make spell checking (F6) not to be ever applied to Build Results window?

0 Likes

#2

There is indeed a way to change this; I guess technically I would call it a workaround since it doesn’t immediately apply to every build output and requires you to modify the sublime-build file for any build that you want to change.

One of the arguments that a sublime-build can take is syntax, which specifies what syntax to apply to the output view. The default value if that argument is not supplied is the Plain Text syntax. By supplying your own syntax to the build, you can apply your own syntax specific settings, which can be anything (including not only the font size but also spelling).

To do so, you would first create a file named Build Output.sublime-syntax in your User package with the following contents:

%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: Build Output
scope: text.plain.build
hidden: true
contexts:
  main: []

This creates a new syntax for use in our build output; it’s essentially the plain text syntax but with a different scope applied so that we can distinguish it as build output. The hidden: true hides the syntax from the command palette and menus; you can remove that if so desired.

With that in place, you can then create a file named Build Output.sublime-settings (i.e. it has to be named the same as the syntax file) and in that file apply any syntax specific settings that you want. For example:

{

    "font_size": 7,
    "spelling_selector": "-text.plain.build"
}

This alters the font size and also turns off spelling by excluding the build output top level scope (from the syntax definition) while inside the build output.

With that in place, you’re ready to roll. For any sublime-build you can include a syntax key and point it to this syntax, which will make that build use this syntax in the panel, applying the appropriate settings.

A simple example of that based on the above is:

{
    "shell_cmd": "dir",
    "syntax": "Packages/User/Build Output.sublime-syntax"
}

1 Like

Changing font size of the results screen
#3

For completeness I should also mention that technically speaking, you can use PackageResourceViewer to create an override on Default/exec.py and modify the default syntax to the one above. If you do that, then it automatically applies to any build that doesn’t specify it’s own syntax.

That’s a bit more invasive in that you run the potential risk of masking changes made to the base exec command if/when it gets updated in future Sublime Text builds. You can mitigate that by using my OverrideAudit package to warn you when that happens.

0 Likes

#4

Many thanks, OdatNurd! Your solutions works for me.

0 Likes

#5

Well, this method seems to fail for those sublime-builds which do not have the default exec value for their target option. Because, according to the docs,

If a value other than exec is specified, none of the options in exec Target Options will do anything.

E.g., I use LaTeXTools, and in LaTeX.sublime-build it has "target": "make_pdf". I wonder now if it’s possible to override this sublime-build such that the Build Output syntax was in effect for it too…

0 Likes

#6

Ah yes, indeed so. For custom build targets a more invasive solution may be required. The same general thing works (i.e. the appropriate syntax needs to be set in the panel and then everything else Just Works :tm:), but it may or may not be simplistic to get the syntax in there.

If the custom build uses exec internally to actually perform the build, then the override method I mentioned above would fix the problem, but if it invokes programs on its own then that won’t work.

0 Likes

#7

I just tried settings this up and I can’t get my syntax file automatically applied to the Build output. I even tried the more invasive approach, but it still renders the default syntax. I can successfully choose to apply the Build Output syntax to any window on-demand.

I am on Version 3.2.2, Build 3211
Here is what I have:
/Packages/User/Build Output.sublime-syntax

%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: Build Output
scope: text.plain.build
hidden: false
contexts:
  main: []

/Packages/User/Build Output.sublime-settings

{
    "font_size": 16,
    "spelling_selector": "-text.plain.build"
}

project.sublime-project

{
	"build_systems":
	[
		{
			"cmd":
			[
				"make",
				"test"
			],
			"name": "Make test",
			"selector": "source.python",
			"syntax": "Packages/User/Build Output.sublime-syntax",
			"working_dir": "$project_path"
		}
	]
...
}

Any ideas on where to debug this next? Any help is appreciated.

EDITED: fixed accidental sublime-settings and sublime-syntax swap, and removed target from project file, thanks @deathaxe for pointing these out.

0 Likes

#8

Did you swap the file extensions by accident?

According to your post you put syntax definition into Build Output.sublime-settings, while putting the settings into Build Output.sublime-syntax.

You shouldn’t need to define the target in your build system.

{
	"build_systems":
	[
		{
			"name": "Make test",
			"shell_cmd": ["make", "test"],
			"selector": "source.python",
			"syntax": "Packages/User/Build Output.sublime-syntax",
			"working_dir": "$project_path"
		}
	]
...
}
0 Likes

#9

I swap them by accident in the post. I fixed it above by editing. They were correct in real life life though :slight_smile: I removed the target, but it still doesn’t work :frowning:

0 Likes

#10

Works great on ST3210 on Windows.

Either another settings file or plugin may override syntax assignment?

0 Likes

#11

Thanks @deathaxe for pointing me towards looking at possible plugin conflicts. It turned out I was using the sublime-text-2-buildview plugin, which essentially hijack the build output window and placed it into a tab. After removing that, it’s all good!

1 Like