简体   繁体   English

如何在pharo或squeak中更改CommandShell窗口中的字体?

[英]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. 在Pharo和Squeak中,如果已安装,则可以键入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. 它将打开一个命令窗口,它基本上就像一个“bash shell”或“终端窗口”,但它使用的是近似微观尺寸的默认字体。 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. 我发现smalltalk中的一般方法是浏览类的实现,看看你是否可以找到你可以对类说的东西,告诉它你想要什么,或者你可以修改类的一些方法让它回答一些问题不同于其他一些类,造成了预期的效果。 Something like anInstanceOfCommandShell someViewOrControllerThingy setDefaultFont:blahblahblah or something like that. anInstanceOfCommandShell someViewOrControllerThingy setDefaultFont:blahblahblah东西。

It seems a CommandShell uses a ShellWindowMorph and that it accepts a setFont message. 似乎CommandShell使用ShellWindowMorph并且它接受setFont消息。 I'm rather new in Smalltalk and Squeak, and have no idea what to do next. 我是Smalltalk和Squeak的新人,不知道下一步该做什么。

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. 我正在使用Pharo 2.0,但如果有人知道如何在Squeak中做到这一点,我相信它会大致相同。

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. 请注意,我已经找到了pharo的设置,并且常规设置更改会影响主要脚本窗口,但不会以任何方式影响特殊的CommandShellTranscript或其内容。

在此输入图像描述

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.
...

You may override the ShellWindowMorph default #textStyle by the following one: 您可以通过以下方法覆盖ShellWindowMorph默认#textStyle:

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. 该窗口应该有一种直接从shell菜单(右上角的箭头)或设置浏览器设置字体的方法。 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. 您可以通过将“Halo”菜单置于您感兴趣的变形上(Alt + Shift +左键单击MS Windows下)并选择红色图标来修改任何变形属性。 Then select Debug -> Explore morph and set the text style directly from the Explorer: 然后选择Debug - > Explore morph并直接从Explorer中设置文本样式:

self textMorph setTextStyle: TextStyle default

ShellWindowMorph uses the system-wide DefaultFixedTextStyle. ShellWindowMorph使用系统范围的DefaultFixedTextStyle。

In Squeak, you could change it like this: 在Squeak中,您可以像这样更改它:

TextConstants
    at: #DefaultFixedTextStyle
    put: (TextStyle fontArray: {StrikeFont fromUser}).

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM