Libraries
Keybd Source Code
 previous   up   next 

Types
keyboard_file
Interface type describing keyboard files.

keyboard_file

const type: keyboard_file

Interface type describing keyboard files. This interface is implemented with console_keybd_file and graph_keybd_file.


Variable Summary
console_keybd_file
CONSOLE_KEYBOARD
Keyboard file describing the console keyboard.
graph_keybd_file
GRAPH_KEYBOARD
Keyboard file describing the graphic keyboard.
keyboard_file
KEYBOARD
Variable describing the keyboard.

Function Summary
boolean
buttonPressed (in keyboard_file: keybd, in char: button)
Determine if a given button is currently pressed.
integer
clickedXPos (in keyboard_file: keybd)
X position of the mouse cursor when a button was pressed.
integer
clickedYPos (in keyboard_file: keybd)
Y position of the mouse cursor when a button was pressed.
char
getc (in console_keybd_file: keybd)
Read a character from the console keyboard file.
string
gets (in console_keybd_file: keybd, in integer: maxLength)
Read a string with maximum length from the console keyboard file.
boolean
inputReady (in console_keybd_file: keybd)
Determine if at least one character can be read without blocking.
string
getwd (inout console_keybd_file: keybd)
Read a word from the console keyboard file.
string
getln (inout console_keybd_file: keybd)
Read a line from the console keyboard file.
char
getc (in graph_keybd_file: keybd)
Read a character from the graphic keyboard or mouse.
string
gets (in graph_keybd_file: keybd, in integer: maxLength)
Read a string with maximum length from the graphic keyboard file.
boolean
buttonPressed (in graph_keybd_file: keybd, in char: button)
Determine if a given button is currently pressed.
integer
clickedXPos (in graph_keybd_file: keybd)
X position of the mouse cursor when a button was pressed.
integer
clickedYPos (in graph_keybd_file: keybd)
Y position of the mouse cursor when a button was pressed.
boolean
inputReady (in graph_keybd_file: keybd)
Determine if at least one character can be read without blocking.
string
getwd (inout graph_keybd_file: keybd)
Read a word from the graphic keyboard file.
string
getln (inout graph_keybd_file: keybd)
Read a line from the graphic keyboard file.
char
getc (inout file: inFile, NO_WAIT)
Read a char from inFile or return KEY_NONE if reading would wait (block).

Variable Detail

CONSOLE_KEYBOARD

var console_keybd_file: CONSOLE_KEYBOARD

Keyboard file describing the console keyboard. The console keyboard belongs to a text/console window. Characters typed at the keyboard are queued (first in first out) and can be read directly, without the need to press ENTER or RETURN. There is also no possibility to correct a key, once it is pressed. Additionally KEYBOARD does not echo the characters.


GRAPH_KEYBOARD

var graph_keybd_file: GRAPH_KEYBOARD

Keyboard file describing the graphic keyboard. The graphic keyboard belongs to a graphic window. Characters typed at the keyboard are queued (first in first out) and can be read directly, without the need to press ENTER or RETURN. There is also no possibility to correct a key, once it is pressed. Additionally KEYBOARD does not echo the characters.


KEYBOARD

var keyboard_file: KEYBOARD

Variable describing the keyboard. Characters typed at the keyboard are queued (first in first out) and can be read directly, without the need to press ENTER or RETURN. There is also no possibility to correct a key, once it is pressed. Additionally KEYBOARD does not echo the characters. KEYBOARD delivers cursor keys and function keys as single characters (e.g. KEY_LEFT or KEY_F1). This variable is initialized with CONSOLE_KEYBOARD. If a program wants to work with the graphic keyboard, the following assignment is necessary:

KEYBOARD := GRAPH_KEYBOARD;

Function Detail

buttonPressed

const func boolean: buttonPressed (in keyboard_file: keybd, in char: button)

Determine if a given button is currently pressed. This function can determine if the last key read by getc from the graphic keyboard is still pressed:

buttonPressed(KEYBOARD, KEY_MOUSE1)

The function can determine if num-lock, shift-lock or scroll-lock is currently active:

buttonPressed(KEYBOARD, KEY_SHIFT_LOCK_ON)

If a button is pressed together with a modifier key (SHIFT, CTRL, ALT) getc returns a character like KEY_CTL_MOUSE1. But no character constants are defined for combinations with two modifier keys (there is no KEY_SFT_CTL_MOUSE1). With buttonPressed it is possible to recogize if two modifier key are combined with a key. E.g.:

aKey := getc(KEYBOARD);
if (aKey = KEY_CTL_MOUSE1 and buttonPressed(KEYBOARD, KEY_SHIFT)) or
   (akey = KEY_SFT_MOUSE1 and buttonPressed(KEYBOARD, KEY_CONTROL)) then
  ...

Note that buttonPressed does not actually read something so using buttonPressed alone will not work. Instead buttonPressed must be combined with getc, which does the reading.

command := getc(KEYBOARD);
if command = KEY_MOUSE1 then
  while buttonPressed(KEYBOARD, KEY_MOUSE1) do
    ... do something as long as KEY_MOUSE1 is pressed ...
  end while;
  # KEY_MOUSE1 has been released.
end if;
Returns:
TRUE if button is currently pressed, FALSE otherwise.

clickedXPos

const func integer: clickedXPos (in keyboard_file: keybd)

X position of the mouse cursor when a button was pressed. The functions clickedXPos and clickedYPos can be used to determine which position was "clicked".

Returns:
the X position of the mouse cursor at the time when the last button was pressed.

clickedYPos

const func integer: clickedYPos (in keyboard_file: keybd)

Y position of the mouse cursor when a button was pressed. The functions clickedXPos and clickedYPos can be used to determine which position was "clicked".

Returns:
the Y position of the mouse cursor at the time when the last button was pressed.

getc

const func char: getc (in console_keybd_file: keybd)

Read a character from the console keyboard file. The function works synchronous. This means that it might wait (block) until a key has been pressed. The function returns a normal Unicode character or a special code (which may be or may not be a Unicode character) for cursor- and function-keys. Character constants are defined for various keys such as KEY_CTL_J for newline and KEY_ESC for the ESCAPE key. If a button is pressed together with a modifier key (SHIFT, CTRL, ALT) getc returns a character like KEY_CTL_A or KEY_ALT_A. No character constants are defined for combinations with two modifier keys (there is no KEY_SFT_CTL_A).

Returns:
the character read.

gets

const func string: gets (in console_keybd_file: keybd, in integer: maxLength)

Read a string with maximum length from the console keyboard file.

Returns:
the string read.
Raises:
RANGE_ERROR - The parameter maxLength is negative.

inputReady

const func boolean: inputReady (in console_keybd_file: keybd)

Determine if at least one character can be read without blocking. Blocking means that getc would wait until a key has been pressed.

Returns:
TRUE if a character is available at the console keyboard file FALSE otherwise.

getwd

const func string: getwd (inout console_keybd_file: keybd)

Read a word from the console keyboard file. Before reading the word it skips spaces and tabs. The function accepts words ending with " ", "\t", "\n", "\r\n" or EOF. The word ending characters are not copied into the string. That means that the "\r" of a "\r\n" sequence is silently removed. When the function is left keybd.bufferChar contains ' ', '\t', '\n' or EOF.

Returns:
the word read.

getln

const func string: getln (inout console_keybd_file: keybd)

Read a line from the console keyboard file. The function accepts lines ending with "\n", "\r\n" or EOF. The line ending characters are not copied into the string. That means that the "\r" of a "\r\n" sequence is silently removed. When the function is left keybd.bufferChar contains '\n' or EOF.

Returns:
the line read.

getc

const func char: getc (in graph_keybd_file: keybd)

Read a character from the graphic keyboard or mouse. The function works synchronous. This means that it might wait (block) until a key has been pressed. The function returns a normal Unicode character or a special code (which may be or may not be a Unicode character) for cursor-, function- and mouse-keys. Character constants are defined for various keys such as KEY_CTL_J for newline and KEY_MOUSE1 for the first mouse key. If a button is pressed together with a modifier key (SHIFT, CTRL, ALT) getc returns a character like KEY_CTL_MOUSE1. No character constants are defined for combinations with two modifier keys (there is no KEY_SFT_CTL_MOUSE1). The function buttonPressed can be used to read such combinations.

Returns:
the character read.

gets

const func string: gets (in graph_keybd_file: keybd, in integer: maxLength)

Read a string with maximum length from the graphic keyboard file.

Returns:
the string read.
Raises:
RANGE_ERROR - The parameter maxLength is negative.

buttonPressed

const func boolean: buttonPressed (in graph_keybd_file: keybd, in char: button)

Determine if a given button is currently pressed. This function can determine if the last key read by getc from the graphic keyboard is still pressed:

buttonPressed(KEYBOARD, KEY_MOUSE1)

The function can determine if num-lock, shift-lock or scroll-lock is currently active:

buttonPressed(KEYBOARD, KEY_SHIFT_LOCK_ON)

If a button is pressed together with a modifier key (SHIFT, CTRL, ALT) getc returns a character like KEY_CTL_MOUSE1. But no character constants are defined for combinations with two modifier keys (there is no KEY_SFT_CTL_MOUSE1). With buttonPressed it is possible to recogize if two modifier key are combined with a key. E.g.:

aKey := getc(KEYBOARD);
if (aKey = KEY_CTL_MOUSE1 and buttonPressed(KEYBOARD, KEY_SHIFT)) or
   (akey = KEY_SFT_MOUSE1 and buttonPressed(KEYBOARD, KEY_CONTROL)) then
  ...

Note that buttonPressed does not actually read something so using buttonPressed alone will not work. Instead buttonPressed must be combined with getc, which does the reading.

command := getc(KEYBOARD);
if command = KEY_MOUSE1 then
  while buttonPressed(KEYBOARD, KEY_MOUSE1) do
    ... do something as long as KEY_MOUSE1 is pressed ...
  end while;
  # KEY_MOUSE1 has been released.
end if;
Returns:
TRUE if button is currently pressed, FALSE otherwise.

clickedXPos

const func integer: clickedXPos (in graph_keybd_file: keybd)

X position of the mouse cursor when a button was pressed. The functions clickedXPos and clickedYPos can be used to determine which position was "clicked".

Returns:
the X position of the mouse cursor at the time when the last button was pressed.

clickedYPos

const func integer: clickedYPos (in graph_keybd_file: keybd)

Y position of the mouse cursor when a button was pressed. The functions clickedXPos and clickedYPos can be used to determine which position was "clicked".

Returns:
the Y position of the mouse cursor at the time when the last button was pressed.

inputReady

const func boolean: inputReady (in graph_keybd_file: keybd)

Determine if at least one character can be read without blocking. Blocking means that getc would wait until a key has been pressed.

Returns:
TRUE if a character is available at the graphic keyboard file FALSE otherwise.

getwd

const func string: getwd (inout graph_keybd_file: keybd)

Read a word from the graphic keyboard file. Before reading the word it skips spaces and tabs. The function accepts words ending with " ", "\t", "\n", "\r\n" or EOF. The word ending characters are not copied into the string. That means that the "\r" of a "\r\n" sequence is silently removed. When the function is left keybd.bufferChar contains ' ', '\t', '\n' or EOF.

Returns:
the word read.

getln

const func string: getln (inout graph_keybd_file: keybd)

Read a line from the graphic keyboard file. The function accepts lines ending with "\n", "\r\n" or EOF. The line ending characters are not copied into the string. That means that the "\r" of a "\r\n" sequence is silently removed. When the function is left keybd.bufferChar contains '\n' or EOF.

Returns:
the line read.

getc

const func char: getc (inout file: inFile, NO_WAIT)

Read a char from inFile or return KEY_NONE if reading would wait (block). This function never waits until a character is received (it does not block).

Returns:
the char read from inFile, or KEY_NONE IF no char is available.


 previous   up   next