• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • applications API Reference
  • KDE Home
  • Contact Us
 

Kate

  • kde-4.14
  • applications
  • kate
  • part
  • vimode
kateviglobal.h
Go to the documentation of this file.
1 /* This file is part of the KDE libraries and the Kate part.
2  *
3  * Copyright (C) 2008 Erlend Hamberg <ehamberg@gmail.com>
4  * Copyright (C) 2011 Svyatoslav Kuzmich <svatoslav1@gmail.com>
5  * Copyright (C) 2012 - 2013 Simon St James <kdedevel@etotheipiplusone.com>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public License
18  * along with this library; see the file COPYING.LIB. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef KATE_VI_GLOBAL_H_INCLUDED
24 #define KATE_VI_GLOBAL_H_INCLUDED
25 
26 #include <QMap>
27 #include <QHash>
28 #include <QList>
29 #include <QPair>
30 
31 #include "katevimodebase.h"
32 #include "kateviinputmodemanager.h"
33 #include "katepartprivate_export.h"
34 
35 class QString;
36 class QChar;
37 class KConfigGroup;
38 
39 
40 namespace KateVi {
41  const unsigned int EOL = 99999;
42 }
43 
44 typedef QPair<QString, OperationMode> KateViRegister;
45 
46 class KATEPART_TESTS_EXPORT KateViGlobal
47 {
48 public:
49  KateViGlobal();
50  ~KateViGlobal();
51 
52  void writeConfig( KConfigGroup &config ) const;
53  void readConfig( const KConfigGroup &config );
54  QString getRegisterContent( const QChar &reg ) const;
55  OperationMode getRegisterFlag( const QChar &reg ) const;
56  void addToNumberedRegister( const QString &text, OperationMode flag = CharWise );
57  void fillRegister( const QChar &reg, const QString &text, OperationMode flag = CharWise);
58  const QMap<QChar, KateViRegister>* getRegisters() const { return &m_registers; }
59 
60  enum MappingRecursion { Recursive, NonRecursive };
61  enum MappingMode { NormalModeMapping, VisualModeMapping, InsertModeMapping, CommandModeMapping };
62  void clearMappings( MappingMode mode );
63  void addMapping( MappingMode mode, const QString& from, const QString& to, MappingRecursion recursion );
64  void removeMapping(MappingMode mode, const QString& from);
65  const QString getMapping( MappingMode mode, const QString &from, bool decode = false ) const;
66  const QStringList getMappings( MappingMode mode, bool decode = false ) const;
67  bool isMappingRecursive(MappingMode mode, const QString& from) const;
72  static MappingMode mappingModeForCurrentViMode(KateView* view);
73 
74  QStringList searchHistory();
75  void clearSearchHistory();
76  void appendSearchHistoryItem(const QString& searchHistoryItem);
77 
78  QStringList commandHistory();
79  void clearCommandHistory();
80  void appendCommandHistoryItem(const QString& commandHistoryItem);
81 
82  QStringList replaceHistory();
83  void clearReplaceHistory();
84  void appendReplaceHistoryItem(const QString& replaceHistoryItem);
85 
86  void clearAllMacros();
87  void clearMacro(QChar macroRegister);
88  void storeMacro(QChar macroRegister, const QList<QKeyEvent> macroKeyEventLog, const QList<KateViInputModeManager::Completion> completions);
92  QString getMacro(QChar macroRegister);
93  QList< KateViInputModeManager::Completion > getMacroCompletions(QChar macroRegister);
94 
95 private:
96  // registers
97  QList<KateViRegister> m_numberedRegisters;
98  QMap<QChar, KateViRegister> m_registers;
99  QChar m_defaultRegister;
100  QString m_registerTemp;
101  KateViRegister getRegister( const QChar &reg ) const;
102 
103  // Mappings.
104  struct Mapping
105  {
106  Mapping(const QString& mappedKeyPresses, bool isRecursive)
107  : mappedKeyPresses(mappedKeyPresses), isRecursive(isRecursive)
108  {
109  }
110  Mapping(const Mapping& other)
111  : mappedKeyPresses(other.mappedKeyPresses), isRecursive(other.isRecursive)
112  {
113  }
114  Mapping()
115  : mappedKeyPresses(), isRecursive(false)
116  {
117  }
118  Mapping& operator=(const Mapping& other)
119  {
120  mappedKeyPresses = other.mappedKeyPresses;
121  isRecursive = other.isRecursive;
122  return *this;
123  }
124  QString mappedKeyPresses;
125  bool isRecursive;
126  };
127 
128  QHash <MappingMode, QHash<QString, Mapping> > m_mappingsForMode;
129 
130  void writeMappingsToConfig(KConfigGroup& config, const QString& mappingModeName, MappingMode mappingMode) const;
131  void readMappingsFromConfig(const KConfigGroup& config, const QString& mappingModeName, MappingMode mappingMode);
132  int readMacroCompletions(QChar macroRegister, const QStringList& encodedMacroCompletions, int macroCompletionIndex);
133  QString encodeMacroCompletionForConfig(const KateViInputModeManager::Completion& completionForMacro) const;
134  KateViInputModeManager::Completion decodeMacroCompletionFromConfig(const QString& encodedMacroCompletion);
135 
136  class History
137  {
138  public:
139  void appendItem(const QString& historyItem)
140  {
141  if (historyItem.isEmpty())
142  {
143  return;
144  }
145  const int HISTORY_SIZE_LIMIT = 100;
146  m_items.removeAll(historyItem);
147  if (m_items.size() == HISTORY_SIZE_LIMIT)
148  {
149  m_items.removeFirst();
150  }
151  m_items.append(historyItem);
152  }
153  QStringList items() const
154  {
155  return m_items;
156  }
157  void clear()
158  {
159  m_items.clear();
160  }
161  private:
162  QStringList m_items;
163  };
164 
165  History m_searchHistory;
166  History m_commandHistory;
167  History m_replaceHistory;
168 
169  QHash<QChar, QString > m_macroForRegister;
170  QHash<QChar, QList<KateViInputModeManager::Completion> > m_macroCompletionsForRegister;
171 };
172 
173 #endif
QList::clear
void clear()
CharWise
Definition: katevimodebase.h:50
katevimodebase.h
QChar
KateViGlobal::MappingRecursion
MappingRecursion
Definition: kateviglobal.h:60
QMap
KATEPART_TESTS_EXPORT
#define KATEPART_TESTS_EXPORT
Definition: katepartprivate_export.h:36
KateViGlobal::VisualModeMapping
Definition: kateviglobal.h:61
kateviinputmodemanager.h
QHash
KateViRegister
QPair< QString, OperationMode > KateViRegister
Definition: kateviglobal.h:44
katepartprivate_export.h
QString::isEmpty
bool isEmpty() const
KateViGlobal::getRegisters
const QMap< QChar, KateViRegister > * getRegisters() const
Definition: kateviglobal.h:58
QString
QList< QKeyEvent >
QStringList
QPair
KateView
Definition: kateview.h:77
KateViInputModeManager::Completion
Definition: kateviinputmodemanager.h:185
KateViGlobal
Definition: kateviglobal.h:46
KateViGlobal::Recursive
Definition: kateviglobal.h:60
KateVi::EOL
const unsigned int EOL
Definition: kateviglobal.h:41
OperationMode
OperationMode
Definition: katevimodebase.h:49
KateViGlobal::MappingMode
MappingMode
Definition: kateviglobal.h:61
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:56:59 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Kate

Skip menu "Kate"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

applications API Reference

Skip menu "applications API Reference"
  •   kate
  •       kate
  •   KTextEditor
  •   Kate
  • Konsole

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal