8#include "katepartdebug.h"
10#include <KConfigGroup>
12#include <QApplication>
15using namespace KateVi;
27 for (
int i = 0; i < names.
size(); i++) {
28 if (!names.
at(i).isEmpty()) {
29 set(names.
at(i).at(0), contents.
at(i), (OperationMode)(flags.
at(i)));
36 if (m_registers.empty()) {
43 for (
const auto &[name, reg] : m_registers) {
44 if (reg.first.length() <= 1000) {
46 contents << reg.
first;
47 flags << int(reg.second);
49 qCDebug(LOG_KTE) <<
"Did not save contents of register " <<
name <<
": contents too long (" << reg.
first.
length() <<
" characters)";
54 config.
writeEntry(
"ViRegisterContents", contents);
58void Registers::setInsertStopped(
const QString &text)
60 set(InsertStoppedRegister, text);
63void Registers::set(
const QChar ®,
const QString &text, OperationMode flag)
65 if (reg == BlackHoleRegister) {
69 if (reg == PrependNumberedRegister || (reg >= FirstNumberedRegister && reg <= LastNumberedRegister)) {
70 setNumberedRegister(reg, text, flag);
71 }
else if (reg == SystemClipboardRegister) {
73 }
else if (reg == SystemSelectionRegister) {
77 if (reg != lowercase_reg) {
78 m_registers[lowercase_reg].first.append(text);
80 m_registers.insert_or_assign(lowercase_reg, Register(text, flag));
84 if (reg == ZeroRegister || reg == PrependNumberedRegister || reg == SmallDeleteRegister) {
91 return getRegister(reg).first;
94OperationMode Registers::getFlag(
const QChar ®)
const
96 return getRegister(reg).second;
99Registers::Register Registers::getRegister(
const QChar ®)
const
102 QChar _reg = (reg != UnnamedRegister ? reg : m_default);
104 if (_reg >= FirstNumberedRegister && _reg <= LastNumberedRegister) {
106 if (m_numbered.
size() > index) {
107 regPair = m_numbered.
at(index);
109 }
else if (_reg == PrependNumberedRegister) {
111 regPair = m_numbered.
front();
113 }
else if (_reg == SystemClipboardRegister) {
115 regPair = Register(regContent, CharWise);
116 }
else if (_reg == SystemSelectionRegister) {
118 regPair = Register(regContent, CharWise);
121 auto it = m_registers.find(lowercase_reg);
122 if (it != m_registers.end()) {
130void Registers::setNumberedRegister(
const QChar ®,
const QString &text, OperationMode flag)
133 if (reg == PrependNumberedRegister || index > m_numbered.
size()) {
134 if (m_numbered.
size() == 9) {
139 m_numbered.
prepend(Register(text, flag));
141 m_numbered[index].
first = text;
142 m_numbered[index].second = flag;
void writeEntry(const char *key, const char *value, WriteConfigFlags pFlags=Normal)
QString readEntry(const char *key, const char *aDefault=nullptr) const
QString name(StandardAction id)
int digitValue(char32_t ucs4)
char32_t toLower(char32_t ucs4)
void setText(const QString &text, Mode mode)
QString text(Mode mode) const const
const_reference at(qsizetype i) const const
bool isEmpty() const const
void prepend(parameter_type value)
qsizetype size() const const
QString first(qsizetype n) const const
qsizetype length() const const