KTextEditor

keyparser.h
1/*
2 SPDX-FileCopyrightText: 2008 Erlend Hamberg <ehamberg@gmail.com>
3 SPDX-FileCopyrightText: 2008 Evgeniy Ivanov <powerfox@kde.ru>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#ifndef KATEVI_KEY_PARSER_H
9#define KATEVI_KEY_PARSER_H
10
11#include <QChar>
12#include <QHash>
13#include <QString>
14#include <ktexteditor_export.h>
15
16class QKeyEvent;
17
18namespace KateVi
19{
20
21class KeyEvent;
22
23/**
24 * for encoding keypresses w/ modifiers into an internal QChar representation and back again to a
25 * descriptive text string
26 */
28{
29private:
30 KeyParser();
31
32public:
33 KTEXTEDITOR_EXPORT static KeyParser *self();
35 {
36 m_instance = nullptr;
37 }
38 KeyParser(const KeyParser &) = delete;
39 KeyParser &operator=(const KeyParser &) = delete;
40
41 KTEXTEDITOR_EXPORT const QString encodeKeySequence(const QString &keys) const;
42 KTEXTEDITOR_EXPORT const QString decodeKeySequence(const QString &keys) const;
43 QString qt2vi(int key) const;
44 KTEXTEDITOR_EXPORT int vi2qt(const QString &keypress) const;
45 int encoded2qt(const QString &keypress) const;
46 KTEXTEDITOR_EXPORT const QChar KeyEventToQChar(const QKeyEvent &keyEvent);
47 const QChar KeyEventToQChar(const KeyEvent &keyEvent);
48
49private:
50 void initKeyTables();
51 const QChar KeyEventToQChar(int keyCode, const QString &text, Qt::KeyboardModifiers mods) const;
52
53 QHash<int, QString> m_qt2katevi;
54 QHash<QString, int> m_katevi2qt;
55 QHash<QString, int> m_nameToKeyCode;
56 QHash<int, QString> m_keyCodeToName;
57
58 static KeyParser *m_instance;
59};
60
61}
62
63#endif /* KATEVI_KEY_PARSER_H */
QEvent wrapper for copying/storing key events.
Definition keyevent.h:19
for encoding keypresses w/ modifiers into an internal QChar representation and back again to a descri...
Definition keyparser.h:28
typedef KeyboardModifiers
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:56:00 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.