forked from qt-creator/qt-creator
fakevim: Fixed pasting from clipboard
Paste from clipboard if register is "" and 'clipboard' contains 'unnamedplus' (otherwise from selection if available and 'clipboard' contains 'unnamed'). Also correctly parse 'clipboard' option to string list. Change-Id: Ic78cd2953789c0402f515973ed2eb48fc3e72154 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -1144,6 +1144,7 @@ public:
|
|||||||
void setRegisterContents(int reg, const QString &contents);
|
void setRegisterContents(int reg, const QString &contents);
|
||||||
RangeMode registerRangeMode(int reg) const;
|
RangeMode registerRangeMode(int reg) const;
|
||||||
void setRegisterRangeMode(int reg, RangeMode mode);
|
void setRegisterRangeMode(int reg, RangeMode mode);
|
||||||
|
void getRegisterType(int reg, bool *isClipboard, bool *isSelection) const;
|
||||||
|
|
||||||
void recordJump();
|
void recordJump();
|
||||||
QVector<CursorPosition> m_jumpListUndo;
|
QVector<CursorPosition> m_jumpListUndo;
|
||||||
@@ -5372,17 +5373,9 @@ RangeMode FakeVimHandler::Private::registerRangeMode(int reg) const
|
|||||||
|
|
||||||
void FakeVimHandler::Private::setRegisterContents(int reg, const QString &contents)
|
void FakeVimHandler::Private::setRegisterContents(int reg, const QString &contents)
|
||||||
{
|
{
|
||||||
bool copyToClipboard = false;
|
bool copyToClipboard;
|
||||||
bool copyToSelection = false;
|
bool copyToSelection;
|
||||||
if (reg == '"') {
|
getRegisterType(reg, ©ToClipboard, ©ToSelection);
|
||||||
QStringList list = config(ConfigClipboard).toStringList();
|
|
||||||
copyToClipboard = list.contains(QString("unnamedplus"));
|
|
||||||
copyToSelection = list.contains(QString("unnamed"));
|
|
||||||
} else if (reg == '+') {
|
|
||||||
copyToClipboard = true;
|
|
||||||
} else if (reg == '*') {
|
|
||||||
copyToSelection = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (copyToClipboard || copyToSelection) {
|
if (copyToClipboard || copyToSelection) {
|
||||||
QClipboard *clipboard = QApplication::clipboard();
|
QClipboard *clipboard = QApplication::clipboard();
|
||||||
@@ -5398,18 +5391,43 @@ void FakeVimHandler::Private::setRegisterContents(int reg, const QString &conten
|
|||||||
|
|
||||||
QString FakeVimHandler::Private::registerContents(int reg) const
|
QString FakeVimHandler::Private::registerContents(int reg) const
|
||||||
{
|
{
|
||||||
if (reg == '+')
|
bool copyFromClipboard;
|
||||||
return QApplication::clipboard()->text(QClipboard::Clipboard);
|
bool copyFromSelection;
|
||||||
|
getRegisterType(reg, ©FromClipboard, ©FromSelection);
|
||||||
|
|
||||||
if (reg == '*') {
|
if (copyFromClipboard || copyFromSelection) {
|
||||||
QClipboard *clipboard = QApplication::clipboard();
|
QClipboard *clipboard = QApplication::clipboard();
|
||||||
return clipboard->text(clipboard->supportsSelection() ?
|
bool hasSelection = clipboard->supportsSelection();
|
||||||
QClipboard::Selection : QClipboard::Clipboard);
|
if (copyFromClipboard || (copyFromSelection && !hasSelection))
|
||||||
|
return clipboard->text(QClipboard::Clipboard);
|
||||||
|
if (copyFromSelection && hasSelection)
|
||||||
|
return clipboard->text(QClipboard::Selection);
|
||||||
}
|
}
|
||||||
|
|
||||||
return g.registers[reg].contents;
|
return g.registers[reg].contents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FakeVimHandler::Private::getRegisterType(int reg, bool *isClipboard, bool *isSelection) const
|
||||||
|
{
|
||||||
|
bool clipboard = false;
|
||||||
|
bool selection = false;
|
||||||
|
|
||||||
|
if (reg == '"') {
|
||||||
|
QStringList list = config(ConfigClipboard).toString().split(',');
|
||||||
|
clipboard = list.contains(QString("unnamedplus"));
|
||||||
|
selection = list.contains(QString("unnamed"));
|
||||||
|
} else if (reg == '+') {
|
||||||
|
clipboard = true;
|
||||||
|
} else if (reg == '*') {
|
||||||
|
selection = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isClipboard != 0)
|
||||||
|
*isClipboard = clipboard;
|
||||||
|
if (isSelection != 0)
|
||||||
|
*isSelection = selection;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// FakeVimHandler
|
// FakeVimHandler
|
||||||
|
|||||||
Reference in New Issue
Block a user