The functions of the keyboard terminal handler

Source: Internet
Author: User
Tags delete key

In order to realize the machine interaction, it is also necessary to configure the corresponding keyboard terminal handler on the computer or terminal, which is responsible for receiving the characters entered by the user from the terminal and loopback it to the screen display, and the user can modify and delete the input information as needed. The following is a description of the functions of the keyboard terminal handler.

1. Character acceptance function

In order to implement inbound interaction, the keyboard terminal handler must be able to receive the characters entered by the user from the terminal and pass it to the user program. The character receive function is implemented mainly through the following two ways.

(1) Character-oriented approach. The driver receives only the characters entered from the terminal and transmits it to the user program without modification. It is usually a string of raw ASCII code.

(2) and the way to the line. The terminal handler temporarily registers the received characters in the buffer and edits the line characters. When a line terminator is received, the correct information for the line is handed to the command interpreter. In some computers, the keys are encoded (the key code), not the ASCII code, that is sent from the keyboard hardware. For example, when you enter a, the key code "30" is placed in the I/O Register, at which point the terminal handler must refer to a mapping rule to convert the key code to an ASCII code.

2. Character Buffering function

In order to be able to suspend the characters entered from the terminal to reduce the frequency of interrupt processor, in the terminal handler, you must also have character buffering function. Character buffering can be used in the following two ways.

(1) Special buffer mode. This means that the system sets a buffer for each terminal, a number of characters entered by the staging user, and the typical length of the buffer is about 200 characters. This method is more suitable for medium. User computers or terminals with very few multi-user machines. When the number of terminals is high, the number of buffers required may be large, and the utilization of each buffer is very low. For example, when there are 100 terminals, a 20KB buffer is required. Figure 1 shows the private buffering method.

(2) public buffering mode. The system does not have to set up a private buffer for each terminal, just set up a common buffer pool consisting of multiple buffers. Each of these buffers is the same size, such as 20 characters, and all the empty buffers are linked to an empty buffer chain. When the terminal has data input, you can first in the empty buffer chain to the empty buffer to receive input characters, when the buffer is full, then a blank buffer. This way, until all of the inputs are complete, and the link pointer is used to link the buffer of the input data into a single input chain. Whenever the characters in one buffer in the input chain are all passed to the user program, the buffer is removed from the input chain and then linked back into the empty buffer chain. Obviously, the use of public buffer pool can effectively improve the utilization of buffering. Figure 2 shows the public buffer pool method.

3. Loopback Display

Loopback display (echo) means that the terminal handler sends the character to the screen whenever the user enters a character from the keyboard. Echo can be achieved by hardware, the advantage is faster, but often cause trouble. If the user enters the password, in order to prevent the password to be stolen, obviously should not have the echo. In addition, the use of hardware to achieve ECHO is also a lack of flexibility, so in recent years, more software to achieve echo, so that users need to be able to return. Using software to achieve echo, but also easy to do character transformation, such as the keyboard input lowercase letters into uppercase. The driver should print in the correct position when the entered character is sent to the screen Echo, and return to the beginning of the next line when the cursor goes to the last position in the line. For example, you should automatically print the next character to the beginning of the next line when the number of characters entered exceeds 80 characters in a row.

4. Screen editing

Users sometimes need to modify the data (characters) entered from the keyboard, such as deleting (inserting) one or more characters. To do this, the terminal handler should also have screen editing capabilities, including the ability to provide several editing keys. The following are some of the most commonly used editing keys.

(1) Delete character keys. It allows you to delete the characters that you have just entered. In some systems is the use of the backspace bar (Backspace). When the user knocks on the key, the handler does not send the characters that have just been entered into the character queue, but rather moves the character queue out of one of its preceding characters.

(2) Delete one line of keys. This key is used to delete the line that you just entered.

(3) Insertion key (insert). Use this key to insert a character or line of text at the cursor.

(4) Move the cursor key. There are keys on the keyboard for moving the cursor up, down, left, and right.

(5) Roll Up (PageUp) or Move down (PageDown) keys.

5. Special character processing

The terminal handler must be able to handle some special characters in a timely manner, as follows.

(1) Break character. When an exception occurs in a program, the user can abort the current program by entering a break character. In many systems, the break key, the delete key, or the CTRL + C key are used as interrupt characters. The processing of interrupt characters is more complex. When the terminal handler receives the interrupt character entered by the user, a soft interrupt signal is sent to all processes on the terminal that requires the process to terminate, and the process terminates itself after receiving the soft interrupt signal.

(2) Stop roll up characters. After the user enters this character, the terminal handler should suspend the rolled up screen so that the user can observe the screen contents carefully. In some systems, it is the use of Ctrl+s key combination to stop the screen roll up.

(3) Restore the rolled up characters. Some systems use the CTRL+Q key combination to make the stop roll up screen back up. When the terminal handler receives the character, it restores the scrolling function of the screen.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.