Search code examples
smalltalkpharosqueak

How can I change the font in a CommandShell window in pharo or squeak?


In Pharo and Squeak, if it's installed you can type CommandShell open. and it will open a command window which is basically like a "bash shell" or "terminal window", but it is using a nearly microscopic sized default font. I can't seem to figure out how to change it.

I figured out that the general approach in smalltalk is to browse the implementation of a class and see if you can find out something you could say to the class to tell it what you want, or some way you could modify the class so it answers something different to some other class, causing the desired effect. Something like anInstanceOfCommandShell someViewOrControllerThingy setDefaultFont:blahblahblah or something like that.

It seems a CommandShell uses a ShellWindowMorph and that it accepts a setFont message. I'm rather new in Smalltalk and Squeak, and have no idea what to do next.

I'm using Pharo 2.0 but if someone knows how to do it in Squeak I'm sure it would be about the same.

Note that I've found the settings of pharo and that the regular settings changes affect the main transcript window, but do not affect the special CommandShellTranscript or its contents in any way.

enter image description here

The code I use to change the rest of the fonts programmatically was this answer from another question. which says to do this:

|font codeFont|

font := LogicalFont familyName: 'Consolas' pointSize: 10.
codeFont := LogicalFont familyName: 'Consolas' pointSize: 9.
StandardFonts listFont: codeFont.
...

Solution

  • You may override the ShellWindowMorph default #textStyle by the following one:

    textStyle
        " Answer a font for the text morph"
    
        ^ TextStyle default
    

    The window should have a way to set the font directly from the shell menu (the top right arrow) or from the Settings Browser. You may modify any morph property by bringing the "Halo" menu over the morph you are interested (Alt+Shift+Left Click under MS Windows) and select the red icon. Then select Debug -> Explore morph and set the text style directly from the Explorer:

    self textMorph setTextStyle: TextStyle default