在 NetBSD 版本在 1.4 之前,使用者只有兩種螢幕與鍵盤的驅動程式可選, pccons (只支援 i386)和 pcvt。 在 1.4 版以後,新的 wscons 平台驅動程式出現了,被用以取代兩 個先前的驅動程式(仍然被支援。)
Wscons 是 NetBSD 新的終端機驅動程式。它提供虛擬的終端機,支援 多國語言的鍵盤,滑鼠的處理,等等。wscons 的能力可依不同平台的 特性而有所改變(wscons 並不支援所有的平台):i386 版提供非常 多樣性的特徵。
在安裝過程結束之後,wscons 被預設為啟動而不需額外的工作。在 1.4 版,虛擬終端機並沒有預設為執行:想要使用它們,請看 Chapter 4。其餘的段落描述了 wscons 在核心設定檔中的 選項。
如果你編譯了個人化的核心,要使用 wscons 你必須設定相關的選項並 並取消 pcvt 和 pccons 的選項(它們並不能同時被設定。)例如,
#pc0 at isa? port 0x60 irq 1 # pccons generic PC console driver
#vt0 at isa? port 0x60 irq 1 # PCVT console driver
在核心設定檔你也可以一個國外式的鍵盤。例如,使用義大利式鍵盤 成為預設值:
options PCKBD_LAYOUT="KB_IT"
Note: 義大利式鍵盤的配置並不是理想的寫程式工具。要修改請看 Chapter 4。
預先配置的虛擬終端機數目被以下的選項所控制
options WSDISPLAY_DEFAULTSCREENS=4
藉由修改 /etc/wscons.conf 檔中相關的設定, 可以增加其他的終端機:註解記號 (#) 必須從包含 "screen x" 的每一行的開頭加以移除。在以下的例子中,是將第五個虛擬終端機 增加到預先配置的四個之後:
# screens to create
# idx screen emul
#screen 0 - vt100
screen 1 - vt100
screen 2 - vt100
screen 3 - vt100
screen 4 - -
#screen 4 80x25bf vt100
#screen 5 80x50 vt100
rc.wscons script 將為被註解的每一行轉送給 wsconscfg 指令:每一行都被當成參數使用。 idx 行變成 index 參數, screen 行變成 -t type 參數 (被用來定義螢幕的型態:行與列數,顏色數,...)而 emul 行變成 -e emul 參數, 用來定義終端機模擬。例如:
screen 3 - vt100
becomes a call to:
wsconscfg -e vt100 3
Note: 這可能會導致一個(無害的)衝突,在核心所預先配置的終端機和 經由 /etc/wscons.conf 所配置的終端機之間。 如果在開機時,系統嘗試配置一個已經被配置的螢幕,則會出現以 訊息:
wsconscfg: WSDISPLAYIO_ADDSCREEN: Device busy解決方法就是在 /etc/wscons.conf 相關的 行中加上註解符號。
虛擬終端機必須也在 /etc/ttys 中 做相關的設定。例如:
console "/usr/libexec/getty Pc" pc3 off secure
ttyE0 "/usr/libexec/getty Pc" vt220 on secure
ttyE1 "/usr/libexec/getty Pc" vt220 on secure
ttyE2 "/usr/libexec/getty Pc" vt220 on secure
ttyE3 "/usr/libexec/getty Pc" vt220 off secure
...
這一行
ttyE3 "/usr/libexec/getty Pc" vt220 off secure
在 /etc/ttys 中是被 X server 用來尋找尚未 被使用的終端機的。要使用不同於號碼 4 的螢幕, vtn 的參數必須傳給 X server。 (n 是一個用來使螢幕能被 X 所使用的 關鍵數字。)
例如,"screen 7" 可以在 /etc/wscons.conf 中被設定而且 X 也能 從 "vt8" 中被啟動。若使用 xdm 則必須編輯 /usr/X11R6/lib/X11/xdm/Xserver。 例如:
:0 local /usr/X11R6/bin/X +kb dpms -bpp 16 dpms vt8
對 xdm3d 而言,路徑是不同的: /usr/X11R6/share/xdm3d/Xservers。
50 行的文字模式在 NetBSD 1.4.1 版時開始被使用。這個模式可以 在 /etc/wscons.conf 中設定。底下這行必 需移除註解:
font ibm - 8 ibm /usr/share/pcvt/fonts/vt220l.808
以下數行必須被修改:
#screen 0 80x50 vt100
screen 1 80x50 vt100
screen 2 80x50 vt100
screen 3 80x50 vt100
screen 4 80x50 vt100
screen 5 80x50 vt100
screen 6 80x50 vt100
screen 7 80x50 vt100
這個設定建立了八個螢幕,可以藉由組合鍵 Ctrl-Alt-Fn 來切換(在此 n 表示從 1 到 8);所使用的裝置為 ttyE0..ttyE7。要使它們顯示登入提示符號, /etc/ttys 必須修改:
ttyE0 "/usr/libexec/getty Pc" vt220 on secure
ttyE1 "/usr/libexec/getty Pc" vt220 on secure
ttyE2 "/usr/libexec/getty Pc" vt220 on secure
ttyE3 "/usr/libexec/getty Pc" vt220 on secure
ttyE4 "/usr/libexec/getty Pc" vt220 on secure
ttyE5 "/usr/libexec/getty Pc" vt220 on secure
ttyE6 "/usr/libexec/getty Pc" vt220 on secure
ttyE7 "/usr/libexec/getty Pc" vt220 on secure
screen 0 的 80x25 的設定是不能被修改的,因為要保證我們 至少有一個工作螢幕。
這是一個在 i386 開機片中能找到的終端機驅動程式。它並不能提供 虛擬的終端機和設定的工具程式而沒有討論的空間。
Pcvt 是 VT220 終端機型態的模擬者而且比起簡單的 pccons,有許多 進接的功能。它支援外國式的鍵盤和虛擬終端機(使用 Ctrl-Alt-F1..F8 或 F9..F12 功能鍵。)要設定 pcvt,底這幾行必須 從核心設定檔中移除註解。
# Enable only one of the following lines
#pc0 at isa? port 0x60 irq 1
vt0 at isa? port 0x60 irq 1
# Options for PCVT console driver
#options FAT_CURSOR
options PCVT_NETBSD=132
options PCVT_NSCREENS=3
若要使用外國式鍵盤,你必須在開機時啟動它;這也是修正終端機 的必要選項。例如:
/usr/local/bin/kcon -m i2
TERM=pcvt25; export TERM
/etc/ttys 必須做適當的修改。 例如:
#console "/usr/libexec/getty Pc" pcvt25 on secure
ttyv0 "/usr/libexec/getty Pc" pcvt25 on secure
Pcvt 義大利式鍵盤: i2 鍵盤的定義並不正確而且 /sys/arch/i386/isa/pcvt/Util/keycap/keycap.src 也必須修改。有個在 NetBSD 1.3.3 測試過的設定。
i2|italy142|Italian 142 mapping:\ :A8={:A9=[:A10=]:A11=}:\ :A12=`:A13=~:\ :A17=@:A18=#:\ :tc=italy141:
要設定使用外國式鍵盤(以義大利式鍵盤為例)必須在開機時被載入, 以 /etc/rc.local 為例:
KCONP=/usr/local/bin
SCONP=/usr/local/bin
LDFNP=/usr/local/bin
ISPCP=/usr/sbin
CURSP=/usr/local/bin
set_keybd=YES
#------------------------------------------------------
# if desired, setup keyboard for italian keyboard layout
#------------------------------------------------------
if [ X${set_keybd} = X"YES" -a -x $KCONP/kcon ]
then
echo
echo 'switching to italian keyboard layout'
$KCONP/kcon -m i2
fi
echo '.'
/etc/ttys 必須被修改:
#console "/usr/libexec/getty Pc" pcvt25 on secure
ttyv0 "/usr/libexec/getty Pc" pcvt25 on secure
ttyv1 "/usr/libexec/getty Pc" pcvt25 on secure
ttyv2 "/usr/libexec/getty Pc" pcvt25 on secure
pcvt 的工具程式必須被編譯及安裝。
cd /sys/arch/i386/isa/pcvt/Util
make
make install
使用 pcvt,你可以改變螢幕的行與列數。以下的 script 範例 可以被用來在兩個不同的設定中,做切換的工作:
#!/bin/sh
# Set the screen to # lines
case $1 in
25)
/usr/local/bin/scon -s 25
/usr/local/bin/cursor -s13 -e14
;;
28)
/usr/local/bin/loadfont -c1 -f
/usr/share/misc/pcvtfonts/vt220l.814
/usr/local/bin/loadfont -c2 -f
/usr/share/misc/pcvtfonts/vt220h.814
/usr/local/bin/scon -s 28
/usr/local/bin/cursor -s12 -e14
;;
40)
/usr/local/bin/loadfont -c3 -f
/usr/share/misc/pcvtfonts/vt220l.810
/usr/local/bin/loadfont -c4 -f
/usr/share/misc/pcvtfonts/vt220h.810
/usr/local/bin/scon -s 40
/usr/local/bin/cursor -s8 -e10
;;
50)
/usr/local/bin/loadfont -c5 -i
/usr/share/misc/pcvtfonts/vt220l.808
/usr/local/bin/loadfont -c6 -i
/usr/share/misc/pcvtfonts/vt220h.808
/usr/local/bin/scon -s 50
/usr/local/bin/cursor -s6 -e8
;;
*)
echo "Invalid # of lines (25/28/40/50)"
;;
esac