mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
vim-mode: add vim_exemption_keys config for Ctrl+C/V
Add vim_exemption_keys config to control the behaviors of Ctrl+C and Ctrl+V in Vim mode.
This commit is contained in:
parent
32aa68dc78
commit
c2973d9e23
@ -162,9 +162,14 @@ backup_directory=.
|
|||||||
; String which is appended to a file name to make the name of the backup file
|
; String which is appended to a file name to make the name of the backup file
|
||||||
backup_extension=.vswp
|
backup_extension=.vswp
|
||||||
|
|
||||||
; Enable back file
|
; Enable backup file
|
||||||
enable_backup_file=true
|
enable_backup_file=true
|
||||||
|
|
||||||
|
; Skipped keys in Vim mode
|
||||||
|
; c: Ctrl+C
|
||||||
|
; v: Ctrl+V
|
||||||
|
vim_exemption_keys=cv
|
||||||
|
|
||||||
[web]
|
[web]
|
||||||
; Location and configuration for Mathjax
|
; Location and configuration for Mathjax
|
||||||
mathjax_javascript=https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_CHTML
|
mathjax_javascript=https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_CHTML
|
||||||
|
@ -1367,6 +1367,12 @@ bool VVim::handleKeyPressEvent(int key, int modifiers, int *p_autoIndentPos)
|
|||||||
expandSelectionToWholeLines(cursor);
|
expandSelectionToWholeLines(cursor);
|
||||||
m_editor->setTextCursorW(cursor);
|
m_editor->setTextCursorW(cursor);
|
||||||
}
|
}
|
||||||
|
} else if (VUtils::isControlModifierForVim(modifiers)) {
|
||||||
|
if (g_config->getVimExemptionKeys().contains('v')) {
|
||||||
|
// Let it be handled outside.
|
||||||
|
resetState();
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -1642,6 +1648,12 @@ bool VVim::handleKeyPressEvent(int key, int modifiers, int *p_autoIndentPos)
|
|||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
} else if (VUtils::isControlModifierForVim(modifiers)) {
|
||||||
|
if (g_config->getVimExemptionKeys().contains('c')) {
|
||||||
|
// Let it be handled outside.
|
||||||
|
resetState();
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -280,6 +280,9 @@ void VConfigManager::initialize()
|
|||||||
|
|
||||||
m_enableBackupFile = getConfigFromSettings("global",
|
m_enableBackupFile = getConfigFromSettings("global",
|
||||||
"enable_backup_file").toBool();
|
"enable_backup_file").toBool();
|
||||||
|
|
||||||
|
m_vimExemptionKeys = getConfigFromSettings("global",
|
||||||
|
"vim_exemption_keys").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VConfigManager::initSettings()
|
void VConfigManager::initSettings()
|
||||||
|
@ -387,6 +387,8 @@ public:
|
|||||||
// Get defined external editors.
|
// Get defined external editors.
|
||||||
QVector<QPair<QString, QString>> getExternalEditors() const;
|
QVector<QPair<QString, QString>> getExternalEditors() const;
|
||||||
|
|
||||||
|
const QString &getVimExemptionKeys() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Look up a config from user and default settings.
|
// Look up a config from user and default settings.
|
||||||
QVariant getConfigFromSettings(const QString §ion, const QString &key) const;
|
QVariant getConfigFromSettings(const QString §ion, const QString &key) const;
|
||||||
@ -730,6 +732,11 @@ private:
|
|||||||
// Whether enable backup file.
|
// Whether enable backup file.
|
||||||
bool m_enableBackupFile;
|
bool m_enableBackupFile;
|
||||||
|
|
||||||
|
// Skipped keys in Vim mode.
|
||||||
|
// c: Ctrl+C
|
||||||
|
// v: Ctrl+V
|
||||||
|
QString m_vimExemptionKeys;
|
||||||
|
|
||||||
// The name of the config file in each directory, obsolete.
|
// The name of the config file in each directory, obsolete.
|
||||||
// Use c_dirConfigFile instead.
|
// Use c_dirConfigFile instead.
|
||||||
static const QString c_obsoleteDirConfigFile;
|
static const QString c_obsoleteDirConfigFile;
|
||||||
@ -1826,4 +1833,9 @@ inline bool VConfigManager::getEnableBackupFile() const
|
|||||||
return m_enableBackupFile;
|
return m_enableBackupFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline const QString &VConfigManager::getVimExemptionKeys() const
|
||||||
|
{
|
||||||
|
return m_vimExemptionKeys;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // VCONFIGMANAGER_H
|
#endif // VCONFIGMANAGER_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user