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

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...

#include "KeyboardTranslator.h"

Collaboration diagram for KeyboardTranslator::Entry:

Public Member Functions

 Entry ()
 Constructs a new entry for a keyboard translator. More...
 
Command command () const
 Returns the commands associated with this entry. More...
 
QString conditionToString () const
 Returns the key code and modifiers associated with this entry as a QKeySequence. More...
 
QByteArray escapedText (bool expandWildCards=false, Qt::KeyboardModifiers modifiers=Qt::NoModifier) const
 Returns the character sequence associated with this entry, with any non-printable characters replaced with escape sequences. More...
 
bool isNull () const
 Returns true if this entry is null. More...
 
int keyCode () const
 Returns the character code ( from the Qt::Key enum ) associated with this entry. More...
 
bool matches (int keyCode, Qt::KeyboardModifiers modifiers, States flags) const
 Returns true if this entry matches the given key sequence, specified as a combination of keyCode , modifiers and state. More...
 
Qt::KeyboardModifiers modifierMask () const
 Returns the keyboard modifiers which are valid in this entry. More...
 
Qt::KeyboardModifiers modifiers () const
 Returns a bitwise-OR of the enabled keyboard modifiers associated with this entry. More...
 
bool operator== (const Entry &rhs) const
 
QString resultToString (bool expandWildCards=false, Qt::KeyboardModifiers modifiers=Qt::NoModifier) const
 Returns this entry's result ( ie. More...
 
void setCommand (Command command)
 Sets the command associated with this entry. More...
 
void setKeyCode (int keyCode)
 Sets the character code associated with this entry. More...
 
void setModifierMask (Qt::KeyboardModifiers modifiers)
 See modifierMask() and modifiers() More...
 
void setModifiers (Qt::KeyboardModifiers modifiers)
 See modifiers() More...
 
void setState (States state)
 See state() More...
 
void setStateMask (States mask)
 See stateMask() More...
 
void setText (const QByteArray &text)
 Sets the character sequence associated with this entry. More...
 
States state () const
 Returns a bitwise-OR of the enabled state flags associated with this entry. More...
 
States stateMask () const
 Returns the state flags which are valid in this entry. More...
 
QByteArray text (bool expandWildCards=false, Qt::KeyboardModifiers modifiers=Qt::NoModifier) const
 Returns the character sequence associated with this entry, optionally replacing wildcard '*' characters with numbers to indicate the keyboard modifiers being pressed. More...
 

Private Member Functions

void insertModifier (QString &item, int modifier) const
 
void insertState (QString &item, int state) const
 
QByteArray unescape (const QByteArray &text) const
 

Private Attributes

Command _command
 
int _keyCode
 
Qt::KeyboardModifiers _modifierMask
 
Qt::KeyboardModifiers _modifiers
 
States _state
 
States _stateMask
 
QByteArray _text
 

Detailed Description

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

Definition at line 195 of file KeyboardTranslator.h.

Constructor & Destructor Documentation

◆ Entry()

KeyboardTranslator::Entry::Entry ( )

Constructs a new entry for a keyboard translator.

Definition at line 576 of file KeyboardTranslator.cpp.

Member Function Documentation

◆ command()

KeyboardTranslator::Command KeyboardTranslator::Entry::command ( void  ) const
inline

Returns the commands associated with this entry.

Definition at line 607 of file KeyboardTranslator.h.

Referenced by Vt102Emulation::sendKeyEvent(), and KeyboardTranslatorWriter::writeEntry().

◆ conditionToString()

QString KeyboardTranslator::Entry::conditionToString ( ) const

Returns the key code and modifiers associated with this entry as a QKeySequence.

Returns this entry's conditions ( ie. its key code, modifier and state criteria ) as a string.

Definition at line 782 of file KeyboardTranslator.cpp.

References KeyboardTranslator::AlternateScreenState, KeyboardTranslator::AnsiState, KeyboardTranslator::AnyModifierState, KeyboardTranslator::CursorKeysState, KeyboardTranslator::NewLineState, and result.

Referenced by KeyboardTranslatorWriter::writeEntry().

◆ escapedText()

QByteArray KeyboardTranslator::Entry::escapedText ( bool  expandWildCards = false,
Qt::KeyboardModifiers  modifiers = Qt::NoModifier 
) const

Returns the character sequence associated with this entry, with any non-printable characters replaced with escape sequences.

eg. \E for Escape, \t for tab, \n for new line.

Parameters
expandWildCardsSee text()
modifiersSee text()

Definition at line 630 of file KeyboardTranslator.cpp.

References i, number, result, and text.

◆ insertModifier()

void KeyboardTranslator::Entry::insertModifier ( QString &  item,
int  modifier 
) const
private

Definition at line 721 of file KeyboardTranslator.cpp.

◆ insertState()

void KeyboardTranslator::Entry::insertState ( QString &  item,
int  state 
) const
private

◆ isNull()

bool KeyboardTranslator::Entry::isNull ( ) const
inline

Returns true if this entry is null.

This is true for newly constructed entries which have no properties set.

Definition at line 598 of file KeyboardTranslator.h.

Referenced by KeyboardTranslator::replaceEntry().

◆ keyCode()

int KeyboardTranslator::Entry::keyCode ( ) const
inline

Returns the character code ( from the Qt::Key enum ) associated with this entry.

Definition at line 583 of file KeyboardTranslator.h.

References _keyCode.

Referenced by KeyboardTranslator::addEntry(), KeyboardTranslator::removeEntry(), and KeyboardTranslator::replaceEntry().

◆ matches()

bool KeyboardTranslator::Entry::matches ( int  keyCode,
Qt::KeyboardModifiers  modifiers,
States  flags 
) const

Returns true if this entry matches the given key sequence, specified as a combination of keyCode , modifiers and state.

Definition at line 597 of file KeyboardTranslator.cpp.

References KeyboardTranslator::AnyModifierState, and state.

◆ modifierMask()

Qt::KeyboardModifiers KeyboardTranslator::Entry::modifierMask ( ) const
inline

Returns the keyboard modifiers which are valid in this entry.

See modifiers()

Definition at line 596 of file KeyboardTranslator.h.

Referenced by Vt102Emulation::sendKeyEvent().

◆ modifiers()

Qt::KeyboardModifiers KeyboardTranslator::Entry::modifiers ( ) const
inline

Returns a bitwise-OR of the enabled keyboard modifiers associated with this entry.

If a modifier is set in modifierMask() but not in modifiers(), this means that the entry only matches when that modifier is NOT pressed.

If a modifier is not set in modifierMask() then the entry matches whether the modifier is pressed or not.

Definition at line 590 of file KeyboardTranslator.h.

Referenced by Vt102Emulation::sendKeyEvent().

◆ operator==()

bool KeyboardTranslator::Entry::operator== ( const Entry rhs) const

Definition at line 586 of file KeyboardTranslator.cpp.

References _command, _keyCode, _modifierMask, _modifiers, _state, _stateMask, and _text.

◆ resultToString()

QString KeyboardTranslator::Entry::resultToString ( bool  expandWildCards = false,
Qt::KeyboardModifiers  modifiers = Qt::NoModifier 
) const

◆ setCommand()

void KeyboardTranslator::Entry::setCommand ( Command  command)
inline

Sets the command associated with this entry.

Definition at line 603 of file KeyboardTranslator.h.

References command.

Referenced by KeyboardTranslatorReader::readNext().

◆ setKeyCode()

void KeyboardTranslator::Entry::setKeyCode ( int  keyCode)
inline

Sets the character code associated with this entry.

Definition at line 584 of file KeyboardTranslator.h.

Referenced by KeyboardTranslatorReader::readNext().

◆ setModifierMask()

void KeyboardTranslator::Entry::setModifierMask ( Qt::KeyboardModifiers  modifiers)
inline

See modifierMask() and modifiers()

Definition at line 592 of file KeyboardTranslator.h.

Referenced by KeyboardTranslatorReader::readNext().

◆ setModifiers()

void KeyboardTranslator::Entry::setModifiers ( Qt::KeyboardModifiers  modifiers)
inline

See modifiers()

Definition at line 586 of file KeyboardTranslator.h.

Referenced by KeyboardTranslatorReader::readNext().

◆ setState()

void KeyboardTranslator::Entry::setState ( States  state)
inline

See state()

Definition at line 638 of file KeyboardTranslator.h.

References state.

Referenced by KeyboardTranslatorReader::readNext().

◆ setStateMask()

void KeyboardTranslator::Entry::setStateMask ( States  mask)
inline

See stateMask()

Definition at line 644 of file KeyboardTranslator.h.

Referenced by KeyboardTranslatorReader::readNext().

◆ setText()

void KeyboardTranslator::Entry::setText ( const QByteArray &  text)
inline

Sets the character sequence associated with this entry.

Definition at line 609 of file KeyboardTranslator.h.

Referenced by KeyboardTranslatorReader::readNext().

◆ state()

KeyboardTranslator::States KeyboardTranslator::Entry::state ( void  ) const
inline

Returns a bitwise-OR of the enabled state flags associated with this entry.

If flag is set in stateMask() but not in state(), this means that the entry only matches when the terminal is NOT in that state.

If a state is not set in stateMask() then the entry matches whether the terminal is in that state or not.

Definition at line 642 of file KeyboardTranslator.h.

Referenced by Vt102Emulation::sendKeyEvent().

◆ stateMask()

KeyboardTranslator::States KeyboardTranslator::Entry::stateMask ( ) const
inline

Returns the state flags which are valid in this entry.

See state()

Definition at line 648 of file KeyboardTranslator.h.

Referenced by Vt102Emulation::sendKeyEvent().

◆ text()

QByteArray KeyboardTranslator::Entry::text ( bool  expandWildCards = false,
Qt::KeyboardModifiers  modifiers = Qt::NoModifier 
) const
inline

Returns the character sequence associated with this entry, optionally replacing wildcard '*' characters with numbers to indicate the keyboard modifiers being pressed.

TODO: The numbers used to replace '*' characters are taken from the Konsole/KDE 3 code. Document them.

Parameters
expandWildCardsSpecifies whether wild cards (occurrences of the '*' character) in the entry should be replaced with a number to indicate the modifier keys being pressed.
modifiersThe keyboard modifiers being pressed.

Definition at line 617 of file KeyboardTranslator.h.

References i, and oneOrZero().

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

◆ unescape()

QByteArray KeyboardTranslator::Entry::unescape ( const QByteArray &  text) const
private

Definition at line 667 of file KeyboardTranslator.cpp.

References i, input, result, and strlen().

Member Data Documentation

◆ _command

Command KeyboardTranslator::Entry::_command
private

Definition at line 328 of file KeyboardTranslator.h.

Referenced by operator==().

◆ _keyCode

int KeyboardTranslator::Entry::_keyCode
private

Definition at line 322 of file KeyboardTranslator.h.

Referenced by keyCode(), and operator==().

◆ _modifierMask

Qt::KeyboardModifiers KeyboardTranslator::Entry::_modifierMask
private

Definition at line 324 of file KeyboardTranslator.h.

Referenced by operator==().

◆ _modifiers

Qt::KeyboardModifiers KeyboardTranslator::Entry::_modifiers
private

Definition at line 323 of file KeyboardTranslator.h.

Referenced by operator==().

◆ _state

States KeyboardTranslator::Entry::_state
private

Definition at line 325 of file KeyboardTranslator.h.

Referenced by operator==().

◆ _stateMask

States KeyboardTranslator::Entry::_stateMask
private

Definition at line 326 of file KeyboardTranslator.h.

Referenced by operator==().

◆ _text

QByteArray KeyboardTranslator::Entry::_text
private

Definition at line 329 of file KeyboardTranslator.h.

Referenced by operator==().


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