24 #ifndef KEYBOARDTRANSLATOR_H 25 #define KEYBOARDTRANSLATOR_H 28 #include <QtCore/QHash> 29 #include <QtCore/QList> 30 #include <QKeySequence> 31 #include <QtCore/QMetaType> 32 #include <QtCore/QVarLengthArray> 35 #if QT_VERSION >= 0x050100 36 # define K_GLOBAL_STATIC Q_GLOBAL_STATIC 58 # define K_GLOBAL_STATIC_STRUCT_NAME(NAME) 60 #if QT_VERSION < 0x040400 61 # define Q_BASIC_ATOMIC_INITIALIZER Q_ATOMIC_INIT 62 # define testAndSetOrdered testAndSet 65 #define K_GLOBAL_STATIC(TYPE, NAME) K_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ()) 67 #define K_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS) \ 68 static QBasicAtomicPointer<TYPE > _k_static_##NAME = Q_BASIC_ATOMIC_INITIALIZER(0); \ 69 static bool _k_static_##NAME##_destroyed; \ 70 static struct K_GLOBAL_STATIC_STRUCT_NAME(NAME) \ 74 return _k_static_##NAME##_destroyed; \ 76 inline operator TYPE*() \ 78 return operator->(); \ 80 inline TYPE *operator->() \ 82 if (!_k_static_##NAME) { \ 83 if (isDestroyed()) { \ 84 qFatal("Fatal Error: Accessed global static '%s *%s()' after destruction. " \ 85 "Defined at %s:%d", #TYPE, #NAME, __FILE__, __LINE__); \ 87 TYPE *x = new TYPE ARGS; \ 88 if (!_k_static_##NAME.testAndSetOrdered(0, x) \ 89 && _k_static_##NAME != x ) { \ 92 static CleanUpGlobalStatic cleanUpObject = { destroy }; \ 95 return _k_static_##NAME; \ 97 inline TYPE &operator*() \ 99 return *operator->(); \ 101 static void destroy() \ 103 _k_static_##NAME##_destroyed = true; \ 104 TYPE *x = _k_static_##NAME; \ 105 _k_static_##NAME = 0; \ 164 Q_DECLARE_FLAGS(States,
State)
188 Q_DECLARE_FLAGS(Commands,
Command)
226 QByteArray
text(
bool expandWildCards =
false,
227 Qt::KeyboardModifiers modifiers = Qt::NoModifier)
const;
230 void setText(
const QByteArray&
text);
241 QByteArray escapedText(
bool expandWildCards =
false,
242 Qt::KeyboardModifiers modifiers = Qt::NoModifier)
const;
247 void setKeyCode(
int keyCode);
257 Qt::KeyboardModifiers modifiers()
const;
260 Qt::KeyboardModifiers modifierMask()
const;
263 void setModifiers( Qt::KeyboardModifiers modifiers );
265 void setModifierMask( Qt::KeyboardModifiers modifiers );
275 States
state()
const;
278 States stateMask()
const;
281 void setState( States
state );
283 void setStateMask( States mask );
295 QString conditionToString()
const;
304 QString resultToString(
bool expandWildCards =
false,
305 Qt::KeyboardModifiers modifiers = Qt::NoModifier)
const;
311 bool matches(
int keyCode ,
312 Qt::KeyboardModifiers modifiers ,
313 States flags )
const;
318 void insertModifier( QString& item ,
int modifier )
const;
319 void insertState( QString& item ,
int state )
const;
320 QByteArray unescape(
const QByteArray&
text)
const;
338 QString
name()
const;
361 Qt::KeyboardModifiers modifiers ,
392 Q_DECLARE_OPERATORS_FOR_FLAGS(KeyboardTranslator::States)
393 Q_DECLARE_OPERATORS_FOR_FLAGS(KeyboardTranslator::Commands)
433 QString description()
const;
471 bool decodeSequence(
const QString& ,
473 Qt::KeyboardModifiers& modifiers,
474 Qt::KeyboardModifiers& modifierMask,
475 KeyboardTranslator::States&
state,
476 KeyboardTranslator::States& stateFlags);
478 static bool parseAsModifier(
const QString& item , Qt::KeyboardModifier& modifier);
480 static bool parseAsKeyCode(
const QString& item ,
int& keyCode);
588 _modifiers = modifier;
594 _modifierMask = mask;
600 return ( *
this ==
Entry() );
611 _text = unescape(
text);
615 return value ? 1 : 0;
619 QByteArray expandedText = _text;
623 int modifierValue = 1;
624 modifierValue +=
oneOrZero(modifiers & Qt::ShiftModifier);
625 modifierValue +=
oneOrZero(modifiers & Qt::AltModifier) << 1;
626 modifierValue +=
oneOrZero(modifiers & Qt::ControlModifier) << 2;
628 for (
int i=0;
i<_text.length();
i++)
630 if (expandedText[
i] ==
'*')
631 expandedText[
i] =
'0' + modifierValue;
646 _stateMask = stateMask;
651 #endif // KEYBOARDTRANSLATOR_H void setKeyCode(int keyCode)
Sets the character code associated with this entry.
QHash< int, Entry > _entries
Scroll the terminal display up one page.
~KeyboardTranslatorManager()
static const char * defaultTranslatorText
Command command() const
Returns the commands associated with this entry.
Command
This enum describes commands which are associated with particular key sequences.
Echos the operating system specific erase character.
Qt::KeyboardModifiers _modifierMask
void writeHeader(const QString &description)
Writes the header for the keyboard translator.
States stateMask() const
Returns the state flags which are valid in this entry.
void addTranslator(KeyboardTranslator *translator)
Adds a new translator.
QString findTranslatorPath(const QString &name)
void setModifiers(Qt::KeyboardModifiers modifiers)
See modifiers()
Indicates that no special state is active.
bool isNull() const
Returns true if this entry is null.
bool deleteTranslator(const QString &name)
Deletes a translator.
int keyCode() const
Returns the character code ( from the Qt::Key enum ) associated with this entry.
to define functions rather than attempting to enter them directly on the command line The block of commands is executed as soon as you exit the editor To avoid executing any simply delete all the lines from the buffer before leaving the editor When invoked with no edit the previously executed command
State
The meaning of a particular key sequence may depend upon the state which the terminal emulation is in...
QString description() const
Returns the descriptive name of this keyboard translator.
Qt::KeyboardModifiers modifierMask() const
Returns the keyboard modifiers which are valid in this entry.
const KeyboardTranslator * findTranslator(const QString &name)
Returns the keyboard translator with the given name or 0 if no translator with that name exists...
void writeEntry(const KeyboardTranslator::Entry &entry)
Writes a translator entry.
nd deftypefn *std::string name
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 a...
Qt::KeyboardModifiers modifiers() const
Returns a bitwise-OR of the enabled keyboard modifiers associated with this entry.
void setText(const QByteArray &text)
Sets the character sequence associated with this entry.
KeyboardTranslatorWriter(QIODevice *destination)
Constructs a new writer which saves data into destination.
KeyboardTranslator(const QString &name)
Constructs a new keyboard translator with the given name.
QList< QString > allTranslators()
Returns a list of the names of available keyboard translators.
Manages the keyboard translations available for use by terminal sessions, see KeyboardTranslator.
Indicates that the alternate screen ( typically used by interactive programs such as screen or vim ) ...
Indicates that the terminal is in 'Ansi' mode.
bool saveTranslator(const KeyboardTranslator *translator)
void setStateMask(States mask)
See stateMask()
void setDescription(const QString &description)
Sets the descriptive name of this keyboard translator.
static KeyboardTranslatorManager * instance()
Returns the global KeyboardTranslatorManager instance.
Indicates that no command is associated with this command sequence.
Scroll the terminal display up one line.
void setCommand(Command command)
Sets the command associated with this entry.
void setName(const QString &name)
Sets the name of this keyboard translator.
States state() const
Returns a bitwise-OR of the enabled state flags associated with this entry.
const KeyboardTranslator * defaultTranslator()
Returns the default translator for Konsole.
A convertor which maps between key sequences pressed by the user and the character strings which shou...
void setModifierMask(Qt::KeyboardModifiers modifiers)
See modifierMask() and modifiers()
KeyboardTranslator * loadTranslator(const QString &name)
Scroll the terminal display down one line.
Parses the contents of a Keyboard Translator (.keytab) file and returns the entries found in it...
With real return the complex result
bool operator==(const dim_vector &a, const dim_vector &b)
static uint32_t state[624]
void setState(States state)
See state()
OCTAVE_EXPORT octave_value_list the first data row corresponds to an index of zero The a spreadsheet style form such as the file is read until end of file is reached The such as text
KeyboardTranslator::Entry _nextEntry
void replaceEntry(const Entry &existing, const Entry &replacement)
Replaces an entry in the translator.
Represents an association between a key sequence pressed by the user and the character sequence and c...
~KeyboardTranslatorWriter()
Writes a keyboard translation to disk.
KeyboardTranslatorManager()
Constructs a new KeyboardTranslatorManager and loads the list of available keyboard translations...
Indicates that any of the modifier keys is active.
QByteArray text(bool expandWildCards=false, Qt::KeyboardModifiers modifiers=Qt::NoModifier) const
Returns the character sequence associated with this entry, optionally replacing wildcard '*' characte...
QList< Entry > entries() const
Returns a list of all entries in the translator.
Scroll the terminal display down one page.
QHash< QString, KeyboardTranslator * > _translators
void(* CleanUpFunction)()
void removeEntry(const Entry &entry)
Removes an entry from the table.
Toggles scroll lock mode.
Qt::KeyboardModifiers _modifiers
nd group nd example For each display the value
QString name() const
Returns the name of this keyboard translator.
void addEntry(const Entry &entry)
Adds an entry to this keyboard translator's table.