Traditional Chinese Solaris User's Guide

Chapter 11 TTY Environment and Support

This chapter assumes you are familiar with the following concepts:

Refer to the termio(7I) man page for background information on STREAMS and TTY drivers.

This chapter discusses the following tops:

TTY Streams

The data path between a user's shell and the terminal is called a stream. The data on a stream contain characters and control information that affect data handling, such as the control sequences that precede a change in code set or communication protocols. Data entering the stream from the terminal is raw or unprocessed. Data is sequentially processed by STREAMS modules for appropriate use by the shell or an application.

STREAMS provides a way to modularize the processing on a line, allowing processing instructions to be grouped in functional modules. These modules can be added or removed from the line so that different environments can be provided to a terminal according to the user's needs.

Traditional STREAMS

The traditional STREAMS TTY environment contains a raw device driver, a line discipline module, and a stream head. The raw device driver provides an I/O interface between the kernel and the hardware. Because the driver is closest to the physical hardware, it provides basic communication protocols, baud rate switching, and other low level services. The line discipline module is a set of instructions or disciplines that transforms the raw data to processed data. This module includes handling the delete character, line kill character, and others. The stream head provides an interface between the user's process and the stream.

Traditional Chinese Solaris STREAMS

The Traditional Chinese Solaris Operating System uses the modular nature of STREAMS to support Traditional Chinese. In addition to the traditional TTY modules, this product implements code conversion in STREAMS. Chinese input is typically supplied by many existing Traditional Chinese TTYs and is not available in the Traditional Chinese Solaris TTY environment.

The Traditional Chinese Solaris Operating System enhances the traditional modules. Its line discipline handles proper cursor movement for wide characters as well as normal protocols. The Traditional Chinese Solaris software code conversion modules convert between two different character code formats, such as between BIG5 and EUC.

Code conversion depends on the appropriate flags or parameters being set. For example, if a BIG5 code terminal is being used, the input from the terminal is converted to EUC and the output to the terminal is converted to BIG5 code.

The major modules that can be pushed onto the stream are ldterm and big5euc.

TTY Utilities

ioctl (input/output control) calls are low-level routines for handling device input and output.

The termcap and terminfo databases are used by applications to configure their terminal display appropriately.

EUC ioctl Features

The Traditional Chinese Solaris Operating System uses ioctl STREAMS commands for general EUC handling. The following is a summary of these ioctl calls and their effects:

EUC_WGET

Get cswidth values from TTY stream

EUC_WSET

Set cswidth values for TTY stream

EUC_OXLOFF

Set code conversion to OFF

EUC_OXLON

Set code conversion to ON

Character code conversion to and from the terminal is controlled by EUC_OXLON and EUC_OXLOFF.

termcap and terminfo Databases

termcap and terminfo are the databases used to tailor the terminal characteristics for an application.

The following table lists extensions to the termcap database:

Table 11–1 ioctl Requests and Descriptions

Variable 

Description 

dv

Device type: language and code set 

ci

Init sequence for multiple code sets  

s0

Shift into code set 0 

s1

Shift into code set 1 

s2

Shift into code set 2 

s3

Shift into code set 3 

The following table lists extensions to terminfo. The s0-s3 string values are used as data announcement mechanisms for the respective code sets during terminal I/O.

Table 11–2 terminfo Variables and Descriptions

Variable 

Capname 

Tc 

Description 

device_type

devt

dv

Device type: language and code set  

code_set_init

csin

ci

Init sequence for multiple code sets  

set0_des_set

s0ds

s0

Shift into code set 0  

set1_des_set

s1ds

s1

Shift into code set 1  

set2_des_set

s2ds

s2

Shift into code set 2  

set3_des_set

s3ds

s3

Shift into code set 3  

TTY Commands

The two commands for configuring and using the TTY environment are setterm and /bin/stty. setterm is used primarily to build the TTY stream for a particular terminal type, pushing the necessary modules onto the stream. stty changes the behavior of the modules in the stream.

setterm Command

The setterm command is used to configure the TTY STREAMS environment. This command can inquire about and manipulate STREAMS modules for a particular TTY port. The setterm command enables users to tailor their TTY STREAMS environment using system-provided or user-provided STREAMS modules.

The setterm command uses a terminal device name that reflects the devt (device type) field in the terminfo database for configuring STREAMS modules for a TTY port. The device name is matched with an entry of the same name in the setterm configuration file, /usr/share/lib/setterm/zh_TW/conf.file. This entry contains detailed instructions on which modules to pop and push in order to properly configure the STREAMS environment.

The setterm command can also take the device type as a direct argument. The device type is similarly matched with an entry in /usr/share/lib/setterm/zh_TW/conf.file.

The setterm configuration file uses a special language for instructions on what actions to take. This language enables users to determine the names of modules on the STREAMS stack, to push or pop modules on the stack, and to do other operations. manipulates the STREAMS stack by making ioctl calls.

The Traditional Chinese Solaris Operating System provides special modules to enable or disable code conversion and to properly handle multibyte and wide characters. Pushing a module onto the stack enables the corresponding conversion. The default state for conversion is enabled.

For more information, see the setterm(3CURSES) man page.

/bin/stty Command

The -defeucw option to the /bin/stty command is used to modify STREAMS modules to reflect changes in the user's environment. The option does not work with a /usr/ucb version of stty, which has not been internationalized.

The following command queries the user's environment for information on EUC code set width and sets that information in the line discipline:


system% /bin/stty defeucw

For example, if the user has the environment variable LC_CTYPE set to locale, this option gets information on the number of bytes per character and the screen width per character for the code sets in the zh_TW environments. The option then sends this information to relevant modules in the stream.

TTY Setup Examples

The system administrator can add setterm in the startup script in /etc/rcn.d directory (where n is the run level) to run at the system boot time. Also, users can run the setterm command at login to configure the stream for their terminal, including the appropriate modules for Traditional Chinese input code conversion. The following examples using setterm can be run as commands typed at a system prompt or included in system files such as .cshrc, .login, and the startup script. Such commands can either explicitly set the device type or use the terminfo database.

Configuring STREAMS for Traditional Chinese Solaris Software

Use the following command to explicitly configure the STREAMS module for a BIG5 terminal use.


setterm -x big5

This usage is independent of terminfo.

You can use a VT-100 terminal, which is BIG5 compatible, on a system with an entry such as the following example in the terminfo database:


vt100-b|VT-100-compatible with Big-5 chars,
lines#40, .csin=E(BE)IE[?1h, csin=E(BE)I, devt=PACKBig5,
s0ds=E(H, s1ds=E$@, s2ds=E(H, use=cit600,

Use the following configuration command to reference the VT-100 entry:


setterm -t vt100-b

For setterm to work properly in this application, /usr/share/lib/setterm/zh_TW/conf.file must contain an entry that corresponds to the device type. An entry such as the following example instructs setterm to place the appropriate conversion modules in the TTY stream.


#
big5throw \
			popto zs|mcp|mti|ptem \
			push big5euc \
			push ldterm \
			push ttcompat \
			run {stty defeucw} \
			catch
#
GenericEUC|EUCthrow \
			popto zs|mcp|mti|ptem \
			push ldterm \
			push ttcompat \
			run {stty defeucw} \
			catch
#
ASCIIthrow \
			popto zs|mcp|mti|ptem \
			push ldterm \
			push ttcompat \
			catch
#

Once configured, conversion is enabled by default. Applications can also set features through ioctl() function calls.

Terminal Support

The Traditional Chinese Solaris Operating System supports BIG5 terminals. The terminals should have built-in Traditional Chinese fonts and input methods.

Installing a Terminal

If you have not added a terminal to your system, install the terminal in ASCII mode only.

How to Add Terminals Through the Serial Port Interface

You can use the serial ports option from the Admintool menu to configure the serial ports for terminals. Serial ports provide the easiest means to install a terminal.


Note –

A Chinese terminal that supports CNS 11643 is installed as you would install an ASCII terminal.


  1. Become superuser.


    system% su
    
  2. Type admintool.

    The admintool menu will appear.


    system# admintool
    
  3. Select the Serial Ports icon.

  4. Select Edit on the Serial Ports menu.

    Modify Service submenu appears.

  5. On the Modify Service submenu, select Enabled, Baud Rate 9600, and provide the terminal type.

    setting the terminal type and baud rate
  6. Under Expert Options, select Create utemp entry and enter the appropriate module in the Streams Modules field.


    Note –

    To install a terminal that supports BIG5 code for the Traditional Chinese Solaris Operating System, add big5euc to the Streams Modules field.


    create utemp entry and specify streams module

How to Add Terminals Through the Command Line

The following procedure is required to set up a terminal on ttya port through the command line.

  1. Determine the port monitor version number by typing the following command:


    # ttyadm -V
    

    The port monitor version number displays.

  2. Type the following commands, substituting the port monitor version number for ver.


    # pmadm -r -p zsmon -s ttya
    # sacadm -a -p zsmon -t ttymon -c /usr/lib/saf/ttymon -v ver
    

    For more information, see the pmadm(1M) and sacadm(1M) man pages.

  3. To add a login service, use the pmadm command that matches your terminal type.

    • For EUC terminals, use the following command.


      #pmadm -a -p zsmon -s ttya -i root -fu -v ver -m “ `ttyadm -S y \
        -T terminal_type -d /dev/ttya -l 9600 -m ldterm,ttcompat -s \
        /usr/bin/login`”
      
    • For BIG5 code terminals, use the STREAMS module big5euc in the ttyadm command.


      # pmadm -a -p zsmon -s ttya -i root -fu -v ver -m “`ttyadm -S y \ 
        -T terminal_type -d /dev/ttya -l 9600 -m big5euc,ldterm,ttcompat -s \
        /usr/bin/login`”
      

  4. Turn on the terminal.

    Familiarize yourself with the documentation that accompanies the terminal.

  5. Log in to the terminal.

  6. Check to see that the installation is correct.


    # setenv LANG locale
    # /bin/stty cs8 -istrip  defeucw
    

    Note –

    These values show that the operating system is set to communicate with the terminal in 8-bit no-parity mode. Make sure the terminal is set up in 8-bit no-parity mode. Refer to the terminal's setup manual for the proper way to set terminal options.


Setting a User's TTY

Do the following to verify that your TTY is set up properly.

  1. Type the /bin/stty command with the -a option.


    system% /bin/stty -a
    
  2. If the cs8, -istrip values are not listed, use the following command to set them.


    system% /bin/stty cs8 -istrip defeucw
    

    This is the last step in setting up a terminal.

How to Use a BIG5 TTY With an EUC Locale

  1. If you are using a BIG5 type terminal, you must run the following command as superuser to load the STREAMS module into the kernel.


    # modload /kernel/strmod/big5euc
    
  2. Type the following command.


    system% setterm -x big5