RK

Section: User Commands (1)
Index Return to Main Contents
 

NAME

rk - The Reactive Keyboard  

SYNOPSIS

rk [- options]  

DESCRIPTION

The Reactive Keyboard is a general purpose command line editor with the addition of predictive text generation. It interfaces with a standard shell and allows simple editing of input lines. It will also predict new input lines based on previous input.

 

PREDICTIVE TEXT GENERATION

The Reactive Keyboard (rk) accelerates typewritten communication with a computer system by predicting what the user is going to type next. To enable it to make predictions, a model of previously-entered text is created and maintained adaptively. (The modeling technique was developed for use in text compression, and in fact forms the basis of one of the most effective existing compression methods.) This generally contains a large number of recurring selection element sequences (n-grams), with associated occurrence frequencies. The current context, recent selections, is used to look up likely continuations.

The basic idea is to order context-conditioned candidate strings, which are predicted by the model, according to popularity and display them for selection. Each prediction starts with a different ASCII character, so that the entire character set can always be accessed. Displayed options are actually concatenations of several predicted characters. With the standard keyboard interface the user can cycle through these predictions and accept all or part of any one. Accepted predictions appear to the computer system as though the user had typed them himself.

Obviously predictions are not always correct, but they are correct often enough to form the basis of a useful communication device. Since they are created adaptively, based on what the user has already typed in this session or in previous ones, the system conforms to whatever kind of text is being entered. Prediction accuracy improves continually as user history accumulates.

Present implementations have proved most useful in enhancing the command interface to the UNIX operating system by predicting commands, arguments, and filenames; and for the entry of free text. Although designed as a general purpose computer interface, the Reactive Keyboard also has great potential to enhance the ease and rate of communication for physically limited people.

 

TECHNICAL DESCRIPTION

The Reactive Keyboard opens a shell on a pseudo terminal (pty). Any input typed by the user is sent to the standard input of the shell. Any output from the shell is simply sent to the screen. The advantage of this setup is that programs do not need to do anything special to work with rk.

The Reactive Keyboard automatically switches off when a program is competing for control of the pty. Programs like screen editors for example will cause rk to shut off. Other programs can be run with rk turned off with the ``run-tty-program'' function.

 

OPTIONS

-b <buffers>
The number of buffers used by rk to save previous commands used by previous_line. Default: 60.

-e <eol length>
The maximum length of predictions at the end of the line. Default: 40.

-f <count>
The maximum frequency count for any given context. Default: 128.

-i <inline length>
The maximum length of predictions in the middle of the line. Default: 8.

-k <keys file>
The file to read key bindings from. Default:$HOME/.rk.keys.FP

-n <number of nodes>
The amount of memory to allocate initially to speed up creation of nodes. After this memory is used up, more will be allocated, but this will be slower. Default: 64*1024 nodes.

-o <model order>
This argument controls how deep a tree will be built by rk in order to make predictions. As k increases, the accuracy of predictions increases, but the speed decreases. Default: 8.

-p <prime file>
The file used to prime the Reactive Keyboard. Default: $HOME/.rk.log_file.

-s <startup amount>
The maximum number of characters to be read from the prime file at startup. Default: 16*1024.

-z <zero freq>
The zero frequency file name. See Zero Frequency below. This argument defaults to $HOME/.rk.zero_freq if it is not present.

-A
When you accept a predicted word, rk usually accepts all characters up to a space. If the -A option is present, the space is also accepted.

-E
rk normally never displays predictions in the middle of a line. If the -E option is present rk will display predictions no matter where the cursor is.

-L
By default, predictions made at the end of a line are longer than those made in the middle of a line. The -L option disables this feature.

-N
Normally, predictions stop at the end of a line. The -N option causes rk to continue making predictions past the end of the line, allowing several commands to be predicted at once.

-P
The -P option disables display of predictions. If the -P option is present, the predictions are still made, and rk still reads all input, but the predictions are not displayed.

-S
Normally, when rk predicts a line, it shows the whole line up to and including the return (^J) at the end. If the -S option is present, the return at the end of the line is not displayed.
-g
Normally, rk opens a login shell. This means the users .login will be run and it is possible to quit rk by typing "logout". The -g option causes rk to open a normal shell and not run the users .login.

-h
The -h option causes a short description of the command line arguments to be printed.

-l
The -l option turns on lisp mode, and allows ()'s to be matched.

-m
If the -m option is present, the normal startup messages will be skipped.

-v
The -v option prints the current version of the Reactive Keyboard.

 

EXAMPLES

rk -gmP Silently open a shell with the line editor enabled, but the predictions turned off.

rk -h Just print help for the command line arguments.

rk -o5 Run the predictions, but make the order of the model only 5 instead of 8.

rk -z cfreq -p cprimefile Loads the file cfreq into the zero frequency table and primes the prediction mechanism with the file cprimefile. Using these two arguments, it is possible to set up different environments for prediction. In the above example, cfreq could have been created using a large C source file as input and cprimefile could be another large C source file. With these inputs, the input of C programs will be simplified as rk will predict common variable names and keywords.

 

BINDABLE EDITING COMMANDS

 

Selection Control

accept_forward_char
Accept the next predicted character.

accept_forward_word
Accept the next predicted word.

accept_to_end_of_line
Accept the whole predicted line.

next_pred
Show next alternative prediction.

previous_pred
Show the previous alternative prediction.

 

Display Control

clear_display
Clear the screen and redraw the current edit line.

toggle_add_space_mode
When you accept a predicted word, rk usually accepts all characters up to a space. If add_space_mode is true, the space is also accepted.

toggle_eol_longer_mode
By default, predictions made at the end of a line are longer than those made in the middle of a line. If eol_longer_mode is turned off this feature is disabled.

toggle_eol_only_mode
rk normally never displays predictions in the middle of a line. If eol_only_mode is true rk will display predictions no matter where the cursor is.

toggle_nl_truncate_mode
Normally, predictions stop at the end of a line. If nl_truncate_mode is false, rk continues making predictions past the end of the line, allowing several commands to be predicted at once.

toggle_pred_mode
IF pred_mode is false, display of predictions is disabled. The predictions are still made, and rk still reads all input, but the predictions are not displayed.

toggle_show_eol_mode
Normally, when rk predicts a line, it shows the whole line up to and including the return (^J) at the end. If the show_eol_mode is false, the return at the end of the line is not displayed.
 

Model Control

prime_from_file
Prime the predictions from a file.

show_free_nodes
Show memory usage information for debugging.

 

Error Control (editing)

backspace_char
Backspace a single character.

backspace_word
Backspace a single word.

backward_char
Go backwards a single character.

backward_paren
Go backwards to a matching parenthesis ``(''.

backward_word
Go backwards a single word.

beginning_of_line
Move to the beginning of the line.

capitalize_word
Capitalize this word.

close_paren
Close and show matching parenthesis. This only has a visible effect if lisp_mode is on.

dash_to_ul_word
Convert -'s to _'s in this word.

delete_char
Delete a single character.

delete_region_to_killbuffer
Delete marked region to killbuffer.

delete_word
Delete a single word.

discard_current_edit_line
Delete this line and forget it.

discard_rest_of_line
Delete rest of line to killbuffer.

end_of_line
Move to the end of the line.

file_completion
Expand pathname from the current prefix.

finish_editing_line
Enter this line.

forward_char
Go forward a single character.

forward_paren
Move to matching close parenthesis ``)''.

forward_word
Go forward a single word.

increment_universal_argument
Do the next command 4^(presses) times. For example, assume increment_universal_argument is bound to ^U and forward_char is bound top ^F. If the user types ^U^U^F the cursor will move forward 4^2 or 16 spaces.

insert_interrupt_char
Send an interrupt character. This usually kills the current process.

insert_quit_char
Send a quit character. This usually kills the current process and causes a core image to be dumped.

insert_start_char
Send a start character. This usually continues output stopped by insert_stop_char.

insert_stop_char
Send a stop character. This usually pauses output from a program.

insert_suspend_char
Send a suspend character. This usually stops a process.

lowercase_word
Lowercase this word.

next_line
Show the next line buffer.

open_paren
Open and show matching parenthesis. This only has a visible effect if lisp_mode is on.

previous_line
Show the previous line buffer.

quote_char
Literally insert the next character.

self_insert
Literally insert the current character.

set_mark
Set mark at the current cursor position.

show_mark
Show the position of the current mark.

toggle_lisp_mode
When lisp mode is turned on, rk will automatically match parenthesis.

twiddle_chars
Exchange previous two characters.

ul_to_dash_word
Convert _'s to -'s in this word.

uppercase_word
Uppercase this word.

yank_from_kill_buffer
Insert text stored in killbuffer.

 

Panic Control

describe_arguments
Show the current command line arguments.

describe_bindings
Show the current key bindings. This is usually bound to Esc-?.

show_version
Show the current version number and date.

 

Other

BOGUS, bogus or null
Null routine, beeps terminal bell. If you want to unbind a key, bind it to this command.

command_completion
Expand a command using $PATH.

run_mesg
Run the mesg command.

run_ruptime
Run the ruptime command.

run_talk
Run the talk command.

run_tty_program
Run a program with rk turned off.

run_write
Run the write command.

 

CHANGING KEY BINDINGS

On startup, rk looks for the file $HOME/.rk.keys or a file specified by the -k option. If it exists, rk reads new key bindings from it. Bindings consist of a function name followed by a key to bind to in double quotes ("). Control characters may be imbedded in this string by the ^ character, so ^A is Control-A. The \ character works the same way as the \ character in termcap entries:
\\E is Escape
\\n is newline
\\r is carrige return
\\t is tab
\\\\ is a single \\
\\^ is a single ^

If you leave off the quotes, the corresponding entry is read from the termcap file. See the manual entry for termcap for a list of these capabilities.

For example, a file like this:

accept_forward_word "^N"
describe_bindings "^[?"
toggle_lisp_mode k1

would bind Control-N to accept_forward_word, Escape-? to describe_bindings and Function key F1 to toggle_lisp_mode

 

DEFAULT BINDINGS

The default bindings are as follows (Note ^[p means Esc-p):

accept_forward_char^Q
accept_forward_word^W
accept_to_end_of_line^S
backspace_char^H
backspace_word^G or ^[h
backward_char^B or kl
backward_paren^[(
backward_word^[b
beginning_of_line^A
capitalize_word^[c
clear_display^L
close_paren)
command_completion^\
dash_to_ul_word^[_
delete_char^D
delete_region_to_killbuffer^[k
delete_word^[d
describe_arguments^[C
describe_bindings^[?
discard_current_edit_line^[^[
discard_rest_of_line^K
end_of_line^E
file_completion^C
finish_editing_line^J or ^M
forward_char^F or kr
forward_paren^[)
forward_word^[f
increment_universal_argument^U
insert_interrupt_char^?
insert_quit_char^[Q
insert_start_char^_
insert_stop_char^^
insert_suspend_char^Z
lowercase_word^[l
next_line^N or kd
next_pred^R
open_paren(
previous_line^P,^[= or ku
previous_pred^O
prime_from_file^[g
quote_char^V
run_mesg^[m
run_ruptime^[z
run_talk^[t
run_tty_program^[r
run_write^[w
set_mark^space
show_free_nodes^[q
show_mark^X
show_version^[v
toggle_add_space_mode^[space
toggle_eol_longer_mode^[F
toggle_eol_only_mode^[E or ^[e
toggle_lisp_mode^[L
toggle_nl_truncate_mode^[N
toggle_pred_mode^[P or^[p
toggle_show_eol_mode^[S
twiddle_chars^T
ul_to_dash_word^[-
uppercase_word^[u
yank_from_kill_buffer^Y

 

ZERO FREQUENCY FILE

When the current input has never been encountered before, rk is forced to consult it's zero frequency data. If it exists, the file $HOME/.rk.zero_freq is read at startup. If not, rk uses a default zero frequency table. The program "freq" will create zero frequency files for you. Simply run "freq < input_data > output_file" and the frequency's of characters in the file input_data will be used to generate the file output_file.

 

ADDING A NEW EDITING FUNCTION

If you want to add a new function to The Reactive Keyboard you need to add the function name, address and description in the parse_keys.c file and the function declaration in functions.h

 

FILES

freq
A program to generate zero frequency files.
.rk.logfile
The default file to use to prime the prediction mechanism and store all of the users input.

.rk.keys
The default key bindings file. See Key Bindings above.

.rk.zero_freq
The default zero frequency file. See Zero Frequency above.

 

AUTHORS (WHO TO BLAME)


  Mark James   (Key Bindings, Command Line arguments, General Maintainence)
  John Darragh (Reactive Keyboard)
  Dan Freedman (Input Line Editor)
  Doug Taylor  (File Completion)

 

SEE ALSO

csh(1),termcap(5)

Darragh, J.J. (1988) ``Adaptive Predictive Text Generation And The Reactive Keyboard'' Research Report 88/343/05, Computer Science Department, University of Calgary

 

KNOWN BUGS

On some terminals, rk has problems with displaying predictions at the right edge of the screen. If the terminal wraps some highlighted text may be left on the previous line.

The line editor doesn't do enough checking on the size of the input. If the user types too much input before hitting return, rk will crash.

File completion reads a character to see if it should show a different completion. This is completely incompatible with the key bindings code. Since file completion only reads one character it is impossible to bind file completion to a multi-character key like ESC-[-A. At the moment, the key bindings code does not make a special case for file completion so it is impossible to bind file completion to a different key without changing the source. This will hopefully be fixed in future versions.

File completion also makes some fairly liberal assumptions about the current working directory. It is fairly simple to trick it into thinking it is in a different directory than it really is.

 

WISH LIST

It would be nice to be able to add teleportation or time travel, but I unfortunately do not have time to implement these features.

It should not be too difficult to allow bindings to be changed at run time.

 

BUG REPORTS

Send any bug reports or fixes to jamesm@cpsc.ucalgary.ca.


 

Index

NAME
SYNOPSIS
DESCRIPTION
PREDICTIVE TEXT GENERATION
TECHNICAL DESCRIPTION
OPTIONS
EXAMPLES
BINDABLE EDITING COMMANDS
Selection Control
Display Control
Model Control
Error Control (editing)
Panic Control
Other
CHANGING KEY BINDINGS
DEFAULT BINDINGS
ZERO FREQUENCY FILE
ADDING A NEW EDITING FUNCTION
FILES
AUTHORS (WHO TO BLAME)
SEE ALSO
KNOWN BUGS
WISH LIST
BUG REPORTS

This document was created by man2html, using the manual pages.
Time: 06:15:31 GMT, December 12, 2024