4

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.
...
2
  • BTW in the shell window you may evaluate Smalltalk expressions like ProtoObject withAllSubclasses size and hit <enter> as in the Python IDLE for example.
    – Hernán
    Commented Mar 19, 2013 at 2:54
  • It's a nifty hybrid approach.
    – Warren P
    Commented Mar 20, 2013 at 0:26

2 Answers 2

5

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
1
  • This works and feels good to me because it feels like the default textStyle answered by this object was something that was from the old world (Squeak) which isn't surfaced in the "font/appearance" settings anywhere in Pharo.
    – Warren P
    Commented Mar 20, 2013 at 16:58
3

ShellWindowMorph uses the system-wide DefaultFixedTextStyle.

In Squeak, you could change it like this:

TextConstants
    at: #DefaultFixedTextStyle
    put: (TextStyle fontArray: {StrikeFont fromUser}).
1
  • Stylistically this is probably better than modifying the code to drop the reference to the DefaultFixedTextStyle, I guess?
    – Warren P
    Commented Mar 20, 2013 at 1:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.