📄 153-155.html
字号:
<HTML>
<HEAD>
<TITLE>Linux Configuration and Installation:Installing and Configuring XFree86</TITLE>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<!--ISBN=1558285660//-->
<!--TITLE=Linux Configuration and Installation//-->
<!--AUTHOR=Patrick Volkerding//-->
<!--AUTHOR=Kevin Reichard//-->
<!--AUTHOR=Eric Foster//-->
<!--PUBLISHER=IDG Books Worldwide, Inc.//-->
<!--IMPRINT=M & T Books//-->
<!--CHAPTER=3//-->
<!--PAGES=153-155//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="148-153.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="155-157.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<P><FONT SIZE="+1"><B>X Resource Files</B></FONT></P>
<P>Another topic under X that is different from the Windows and Macintosh environments is <I>resource files</I>. You’ll find that X resource files are either the savior or bane of your existence. Like the Windows and Macintosh systems, resource files on X allow you to customize fonts, colors, and text messages, all without access to the application’s source code.</P>
<P>This concept is great. You can tell an application to use a more readable font, you can get rid of garish colors, you can even write Finnish messages in place of all the English ones, or you can fix up the English messages to something more to your liking.</P>
<P>X resource files provide a powerful mechanism to customize just about every X application. There are many locations—both within a resource file and on disk—to which you can place these resources files. Because many options conflict, it’s easy to get lost in all the details.</P>
<P>Stripped to its basics, an X resource file is an ASCII text file that specifies some option for a program or programs. Each line of the resource file specifies a resource to set and its value. For example, you can specify in an X resource file that all <B>xterm</B> programs should start up with the scrollbar turned on, which we’ll show how to do soon. You can also control fonts, colors, and a lot of the text displayed by most X programs.</P>
<P>To set up the scrollbar commands for <B>xterm</B> in a resource file, create a file named <B>XTerm</B> (note the capitalization) in your home directory. Both the file name, <B>XTerm</B>, and the location (your home directory) are essential. Put in the following lines:</P>
<!-- CODE SNIP //-->
<PRE>
XTerm*scrollBar: True
XTerm*saveLines: 1000
</PRE>
<!-- END CODE SNIP //-->
<P>These X resource commands tell <B>xterm</B> to use a scrollbar and to save 1000 lines in its scroll buffer. Save this file and start another <B>xterm</B> program. You should see a scrollbar.</P>
<P>For more on X resource files, see the book list in Appendix A.</P>
<P><FONT SIZE="+1"><B>Controlling Fonts and Colors</B></FONT></P>
<P>Like most options, you can control <B>xterm</B>’s choice of fonts and colors from both command-line parameters and X resource files. What we usually do is set up the options we always want in an X resource file and then use the command-line parameters only for options we rarely need.</P>
<P>Normally, we’re happy with <B>xterm</B>’s color defaults: black text on a white background. It’s the font we’d like to change. By default, <B>xterm</B> uses the font named <I>fixed</I>, a fixed-character-size font (as opposed to a proportional font). We find this font far too small, so we’d like to use a larger one.</P>
<P>For setting the font, you can use the <B>-font</B> command-line parameter or set the font resource. To do the latter, you can add the following line to the <B>XTerm</B> file you created:</P>
<!-- CODE SNIP //-->
<PRE>
XTerm*font: -*-courier-medium-r-normal--14-140-75-75-m-90-*
</PRE>
<!-- END CODE SNIP //-->
<P>This sets up a much more pleasing (to our eyes at least) and larger font for <B>xterm</B>.</P>
<P>To get a list of the available fonts, use the program <B>xlsfonts</B>, which will present you with a huge list. For <B>xterm</B>, you want a fixed-width font. The Courier fonts typically are fixed-width, as are the Lucida typewriter fonts. In the very long font names, the fixed-width fonts should have an <I>m</I> or <I>c,</I> as shown here, after the two 75s:</P>
<!-- CODE SNIP //-->
<PRE>
-adobe-courier-medium-r-normal--14-140-75-75-m-90-iso8859-1
</PRE>
<!-- END CODE SNIP //-->
<P>As usual, to test this, save the <B>XTerm</B> file and start another <B>xterm</B> program.</P>
<P>For our <B>XTerm</B> file, we set the following resources:</P>
<!-- CODE //-->
<PRE>
!
! XTerm resource file
!
XTerm*foreground: black
XTerm*cursorColor: black
XTerm*background: white
XTerm*scrollBar: True
XTerm*saveLines: 1000
XTerm*font: -*-courier-medium-r-normal--14-140-75-75-m-90-*
</PRE>
<!-- END CODE //-->
<P>Lines beginning with an exclamation mark (!) are comments. We list the most-used <B>xterm</B> command-line parameters in Table 3.15.</P>
<TABLE WIDTH="100%"><CAPTION><B>Table 3.15</B> Commonly Used Xterm Command-Line Parameters
<TR>
<TH WIDTH="30%" ALIGN="LEFT">Parameter
<TH WIDTH="70%" ALIGN="LEFT">Meaning
<TR>
<TH COLSPAN="2"><HR>
<TR>
<TD>-bg <I>color</I>
<TD>Sets background color; defaults to white
<TR>
<TD>-cr <I>color</I>
<TD>Sets color of text cursor; defaults to black
<TR>
<TD>-display <I>hostname</I>:0
<TD>Sets name of X display to which to connect
<TR>
<TD>-e <I>program</I> [<I>args</I>]
<TD>Runs program instead of shell
<TR>
<TD>-fg <I>color</I>
<TD>Sets foreground color; defaults to black
<TR>
<TD>-fn <I>fontname</I>
<TD>Uses the given font
<TR>
<TD>-font <I>fontname</I>
<TD>Uses the given font
<TR>
<TD>-geometry <I>geom</I>
<TD>Uses given size and location
<TR>
<TD>-ls
<TD>Turns shell into login shell
<TR>
<TD>-sb
<TD>Turns on scrollbar
<TR>
<TD COLSPAN="2"><HR>
</TABLE>
<P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="148-153.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="155-157.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -