GNU Octave  8.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
KeyboardTranslator Class Reference

A convertor which maps between key sequences pressed by the user and the character strings which should be sent to the terminal and commands which should be invoked when those character sequences are pressed. More...

#include "KeyboardTranslator.h"

Collaboration diagram for KeyboardTranslator:

Classes

class  Entry
 Represents an association between a key sequence pressed by the user and the character sequence and commands associated with it for a particular KeyboardTranslator. More...
 

Public Types

enum  Command {
  NoCommand = 0 , SendCommand = 1 , ScrollPageUpCommand = 2 , ScrollPageDownCommand = 4 ,
  ScrollLineUpCommand = 8 , ScrollLineDownCommand = 16 , ScrollLockCommand = 32 , EraseCommand = 64
}
 This enum describes commands which are associated with particular key sequences. More...
 
enum  State {
  NoState = 0 , NewLineState = 1 , AnsiState = 2 , CursorKeysState = 4 ,
  AlternateScreenState = 8 , AnyModifierState = 16
}
 The meaning of a particular key sequence may depend upon the state which the terminal emulation is in. More...
 

Public Member Functions

 KeyboardTranslator (const QString &name)
 Constructs a new keyboard translator with the given name. More...
 
void addEntry (const Entry &entry)
 Adds an entry to this keyboard translator's table. More...
 
QString description () const
 Returns the descriptive name of this keyboard translator. More...
 
QList< Entryentries () const
 Returns a list of all entries in the translator. More...
 
Entry findEntry (int keyCode, Qt::KeyboardModifiers modifiers, States state=NoState) const
 Looks for an entry in this keyboard translator which matches the given key code, keyboard modifiers and state flags. More...
 
QString name () const
 Returns the name of this keyboard translator. More...
 
void removeEntry (const Entry &entry)
 Removes an entry from the table. More...
 
void replaceEntry (const Entry &existing, const Entry &replacement)
 Replaces an entry in the translator. More...
 
void setDescription (const QString &description)
 Sets the descriptive name of this keyboard translator. More...
 
void setName (const QString &name)
 Sets the name of this keyboard translator. More...
 

Private Attributes

QString _description
 
QMultiHash< int, Entry_entries
 
QString _name
 

Detailed Description

A convertor which maps between key sequences pressed by the user and the character strings which should be sent to the terminal and commands which should be invoked when those character sequences are pressed.

Konsole supports multiple keyboard translators, allowing the user to specify the character sequences which are sent to the terminal when particular key sequences are pressed.

A key sequence is defined as a key code, associated keyboard modifiers (Shift,Ctrl,Alt,Meta etc.) and state flags which indicate the state which the terminal must be in for the key sequence to apply.

Definition at line 129 of file KeyboardTranslator.h.

Member Enumeration Documentation

◆ Command

This enum describes commands which are associated with particular key sequences.

Enumerator
NoCommand 

Indicates that no command is associated with this command sequence.

SendCommand 

TODO Document me.

ScrollPageUpCommand 

Scroll the terminal display up one page.

ScrollPageDownCommand 

Scroll the terminal display down one page.

ScrollLineUpCommand 

Scroll the terminal display up one line.

ScrollLineDownCommand 

Scroll the terminal display down one line.

ScrollLockCommand 

Toggles scroll lock mode.

EraseCommand 

Echos the operating system specific erase character.

Definition at line 170 of file KeyboardTranslator.h.

◆ State

The meaning of a particular key sequence may depend upon the state which the terminal emulation is in.

Therefore findEntry() may return a different Entry depending upon the state flags supplied.

This enum describes the states which may be associated with with a particular entry in the keyboard translation entry.

Enumerator
NoState 

Indicates that no special state is active.

NewLineState 

TODO More documentation.

AnsiState 

Indicates that the terminal is in 'Ansi' mode.

TODO: More documentation

CursorKeysState 

TODO More documentation.

AlternateScreenState 

Indicates that the alternate screen ( typically used by interactive programs such as screen or vim ) is active.

AnyModifierState 

Indicates that any of the modifier keys is active.

Definition at line 140 of file KeyboardTranslator.h.

Constructor & Destructor Documentation

◆ KeyboardTranslator()

KeyboardTranslator::KeyboardTranslator ( const QString &  name)

Constructs a new keyboard translator with the given name.

Definition at line 802 of file KeyboardTranslator.cpp.

Member Function Documentation

◆ addEntry()

void KeyboardTranslator::addEntry ( const Entry entry)

Adds an entry to this keyboard translator's table.

Entries can be looked up according to their key sequence using findEntry()

Definition at line 829 of file KeyboardTranslator.cpp.

References _entries, and KeyboardTranslator::Entry::keyCode().

Referenced by KeyboardTranslatorManager::loadTranslator().

◆ description()

QString KeyboardTranslator::description ( ) const

Returns the descriptive name of this keyboard translator.

Definition at line 811 of file KeyboardTranslator.cpp.

References _description.

Referenced by KeyboardTranslatorManager::saveTranslator(), and setDescription().

◆ entries()

QList< KeyboardTranslator::Entry > KeyboardTranslator::entries ( ) const

Returns a list of all entries in the translator.

Definition at line 824 of file KeyboardTranslator.cpp.

References _entries.

Referenced by KeyboardTranslatorManager::saveTranslator().

◆ findEntry()

KeyboardTranslator::Entry KeyboardTranslator::findEntry ( int  keyCode,
Qt::KeyboardModifiers  modifiers,
States  state = NoState 
) const

Looks for an entry in this keyboard translator which matches the given key code, keyboard modifiers and state flags.

Returns the matching entry if found or a null Entry otherwise ( ie. entry.isNull() will return true )

Parameters
keyCodeA key code from the Qt::Key enum
modifiersA combination of modifiers
stateOptional flags which specify the current state of the terminal

Definition at line 844 of file KeyboardTranslator.cpp.

References _entries, next, and state.

Referenced by Vt102Emulation::getErase(), and Vt102Emulation::sendKeyEvent().

◆ name()

QString KeyboardTranslator::name ( void  ) const

Returns the name of this keyboard translator.

Definition at line 819 of file KeyboardTranslator.cpp.

References _name.

Referenced by KeyboardTranslatorManager::addTranslator(), Emulation::keyBindings(), and setName().

◆ removeEntry()

void KeyboardTranslator::removeEntry ( const Entry entry)

Removes an entry from the table.

Definition at line 840 of file KeyboardTranslator.cpp.

References _entries, and KeyboardTranslator::Entry::keyCode().

◆ replaceEntry()

void KeyboardTranslator::replaceEntry ( const Entry existing,
const Entry replacement 
)

Replaces an entry in the translator.

If the existing entry is null, then this is equivalent to calling addEntry(replacement)

Definition at line 834 of file KeyboardTranslator.cpp.

References _entries, KeyboardTranslator::Entry::isNull(), and KeyboardTranslator::Entry::keyCode().

◆ setDescription()

void KeyboardTranslator::setDescription ( const QString &  description)

Sets the descriptive name of this keyboard translator.

Definition at line 807 of file KeyboardTranslator.cpp.

References _description, and description().

Referenced by KeyboardTranslatorManager::loadTranslator().

◆ setName()

void KeyboardTranslator::setName ( const QString &  name)

Sets the name of this keyboard translator.

Definition at line 815 of file KeyboardTranslator.cpp.

References _name, and name().

Member Data Documentation

◆ _description

QString KeyboardTranslator::_description
private

Definition at line 391 of file KeyboardTranslator.h.

Referenced by description(), and setDescription().

◆ _entries

QMultiHash<int,Entry> KeyboardTranslator::_entries
private

Definition at line 387 of file KeyboardTranslator.h.

Referenced by addEntry(), entries(), findEntry(), removeEntry(), and replaceEntry().

◆ _name

QString KeyboardTranslator::_name
private

Definition at line 390 of file KeyboardTranslator.h.

Referenced by name(), and setName().


The documentation for this class was generated from the following files: