diff --git a/src/resources/docs/shortcuts_en.md b/src/resources/docs/shortcuts_en.md index ddc24c40..cf245590 100644 --- a/src/resources/docs/shortcuts_en.md +++ b/src/resources/docs/shortcuts_en.md @@ -35,9 +35,9 @@ Scroll up half screen. Scroll down half screen. - `gg`/`G` Jump to the beginning or end of the note. (Case Sensitive). -- `Ctrl + +/-` +- `Ctrl + +/-` Zoom in/out the page. -- `Ctrl+Wheel` +- `Ctrl+Wheel` Zoom in/out the page through the mouse scroll. - `Ctrl+0` Recover the page zoom factor to 100%. @@ -58,12 +58,15 @@ Recover the page zoom factor to 100%. ### Edit Mode - `Ctrl+S` Save current changes. -- `Ctrl + +/-` +- `Ctrl + +/-` Zoom in/out the page. -- `Ctrl+Wheel` +- `Ctrl+Wheel` Zoom in/out the page through the mouse scroll. - `Ctrl+0` Recover the page zoom factor to 100%. +- `Ctrl+J/K` +Scroll page down/up without changing cursor. + #### Text Editing - `Ctrl+B` @@ -72,8 +75,8 @@ Insert bold. Press `Ctrl+B` again to exit. Current selected text will be changed Insert italic. Press `Ctrl+I` again to exit. Current selected text will be changed to italic if exists. - `Ctrl+D` Insert strikethrought. Press `Ctrl+D` again to exit. Current selected text will be changed to strikethrough if exists. -- `Ctrl+K` -Insert inline code. Press `Ctrl+K` again to exit. Current selected text will be changed to inline code if exists. +- `Ctrl+;` +Insert inline code. Press `Ctrl+;` again to exit. Current selected text will be changed to inline code if exists. - `Ctrl+M` Insert fenced code block. Press `Ctrl+M` again to exit. Current selected text will be wrapped into a code block if exists. - `Ctrl+L` @@ -213,9 +216,9 @@ Popup the attachments list of current note. - `X` Close current tab. - `J` -Jump to next tab. +Jump to the next tab. - `K` -Jump to last tab. +Jump to the previous tab. - `1` - `9` Number key 1 to 9 will jump to the tabs with corresponding sequence number. - `0` diff --git a/src/resources/docs/shortcuts_zh.md b/src/resources/docs/shortcuts_zh.md index 3be805ea..ae518798 100644 --- a/src/resources/docs/shortcuts_zh.md +++ b/src/resources/docs/shortcuts_zh.md @@ -35,9 +35,9 @@ 向下滚动半屏。 - `gg`/`G` 跳转到笔记的开始或结尾。(区分大小写)。 -- `Ctrl + +/-` +- `Ctrl + +/-` 放大/缩小页面。 -- `Ctrl+Wheel` +- `Ctrl+Wheel` 鼠标滚轮实现放大/缩小页面。 - `Ctrl+0` 恢复页面大小为100%。 @@ -58,12 +58,14 @@ ### 编辑模式 - `Ctrl+S` 保存当前更改。 -- `Ctrl + +/-` +- `Ctrl + +/-` 放大/缩小页面。 -- `Ctrl+Wheel` +- `Ctrl+Wheel` 鼠标滚轮实现放大/缩小页面。 - `Ctrl+0` 恢复页面大小为100%。 +- `Ctrl+J/K` +向下/向上滚动页面,不会改变光标。 #### 文本编辑 - `Ctrl+B` @@ -72,8 +74,8 @@ 插入斜体;再次按`Ctrl+I`退出。如果已经选择文本,则将当前选择文本改为斜体。 - `Ctrl+D` 插入删除线;再次按`Ctrl+D`退出。如果已经选择文本,则将当前选择文本改为删除线。 -- `Ctrl+K` -插入行内代码;再次按`Ctrl+K`退出。如果已经选择文本,则将当前选择文本改为行内代码。 +- `Ctrl+;` +插入行内代码;再次按`Ctrl+;`退出。如果已经选择文本,则将当前选择文本改为行内代码。 - `Ctrl+M` 插入代码块;再次按`Ctrl+M`退出。如果已经选择文本,则将当前选择文本嵌入到代码块中。 - `Ctrl+L` diff --git a/src/resources/icons/bold.svg b/src/resources/icons/bold.svg index 43af6765..e950b379 100644 --- a/src/resources/icons/bold.svg +++ b/src/resources/icons/bold.svg @@ -2,6 +2,6 @@ Layer 1 - B + B diff --git a/src/resources/icons/code_block.svg b/src/resources/icons/code_block.svg index 2f8ce405..4bebd6b2 100644 --- a/src/resources/icons/code_block.svg +++ b/src/resources/icons/code_block.svg @@ -1,6 +1,6 @@ Layer 1 - # + # diff --git a/src/resources/icons/heading.svg b/src/resources/icons/heading.svg index d6c3f9d7..0c07c6f1 100644 --- a/src/resources/icons/heading.svg +++ b/src/resources/icons/heading.svg @@ -2,6 +2,6 @@ Layer 1 - H + H diff --git a/src/resources/icons/inline_code.svg b/src/resources/icons/inline_code.svg index ea166774..f2db1336 100644 --- a/src/resources/icons/inline_code.svg +++ b/src/resources/icons/inline_code.svg @@ -2,6 +2,6 @@ Layer 1 - K + C diff --git a/src/resources/icons/italic.svg b/src/resources/icons/italic.svg index da96923d..114e2093 100644 --- a/src/resources/icons/italic.svg +++ b/src/resources/icons/italic.svg @@ -2,6 +2,6 @@ Layer 1 - I + I - \ No newline at end of file + diff --git a/src/resources/icons/strikethrough.svg b/src/resources/icons/strikethrough.svg index d44defe2..131bb3ea 100644 --- a/src/resources/icons/strikethrough.svg +++ b/src/resources/icons/strikethrough.svg @@ -2,7 +2,7 @@ Layer 1 - D + S diff --git a/src/resources/markdown_template.js b/src/resources/markdown_template.js index 74f543f8..eea1e644 100644 --- a/src/resources/markdown_template.js +++ b/src/resources/markdown_template.js @@ -305,6 +305,7 @@ document.onkeydown = function(e) { shift = !!e.shiftKey; ctrl = !!e.ctrlKey; meta = !!e.metaKey; + var isCtrl = VOS == 'mac' ? e.metaKey : e.ctrlKey; switch (key) { // Skip Ctrl, Shift, Alt, Supper. case 16: @@ -349,7 +350,7 @@ document.onkeydown = function(e) { } case 74: // J - if (!ctrl && !shift && !meta) { + if (!shift && (!ctrl || isCtrl) && (!meta || isCtrl)) { window.scrollBy(0, 100); break; } @@ -358,7 +359,7 @@ document.onkeydown = function(e) { break; case 75: // K - if (!ctrl && !shift && !meta) { + if (!shift && (!ctrl || isCtrl) && (!meta || isCtrl)) { window.scrollBy(0, -100); break; } diff --git a/src/resources/vnote.ini b/src/resources/vnote.ini index f5c814dc..54c6576a 100644 --- a/src/resources/vnote.ini +++ b/src/resources/vnote.ini @@ -93,7 +93,7 @@ enable_smart_im_in_vim_mode=true ; Display an area besides the editor area to show line number ; 0 - None, 1 - Absolute, 2 - Relative, 3 - CodeBlock -editor_line_number=0 +editor_line_number=1 ; Whether minimize to system tray when closing the app ; -1: uninitialized, prompt user for the behavior diff --git a/src/utils/vvim.cpp b/src/utils/vvim.cpp index 38e89572..d979f17d 100644 --- a/src/utils/vvim.cpp +++ b/src/utils/vvim.cpp @@ -777,6 +777,12 @@ bool VVim::handleKeyPressEvent(int key, int modifiers, int *p_autoIndentPos) processCommand(m_tokens); } + } else if (VUtils::isControlModifierForVim(modifiers)) { + if (key == Qt::Key_J || key == Qt::Key_K) { + // Let it be handled outside. + resetState(); + goto exit; + } } break; diff --git a/src/vmainwindow.cpp b/src/vmainwindow.cpp index 865c21d4..6ced84a1 100644 --- a/src/vmainwindow.cpp +++ b/src/vmainwindow.cpp @@ -535,7 +535,7 @@ QToolBar *VMainWindow::initEditToolBar(QSize p_iconSize) m_editToolBar->addAction(strikethroughAct); QAction *inlineCodeAct = new QAction(VIconUtils::toolButtonIcon(":/resources/icons/inline_code.svg"), - tr("Inline Code\t%1").arg(VUtils::getShortcutText("Ctrl+K")), + tr("Inline Code\t%1").arg(VUtils::getShortcutText("Ctrl+;")), this); inlineCodeAct->setStatusTip(tr("Insert inline-code text or change selected text to inline-coded")); connect(inlineCodeAct, &QAction::triggered, diff --git a/src/vmdeditoperations.cpp b/src/vmdeditoperations.cpp index e565702e..ca58e989 100644 --- a/src/vmdeditoperations.cpp +++ b/src/vmdeditoperations.cpp @@ -12,6 +12,8 @@ #include #include #include +#include + #include "vmdeditoperations.h" #include "dialog/vinsertimagedialog.h" #include "dialog/vselectdialog.h" @@ -333,7 +335,7 @@ bool VMdEditOperations::handleKeyPressEvent(QKeyEvent *p_event) break; } - case Qt::Key_K: + case Qt::Key_Semicolon: { if (modifiers == Qt::ControlModifier) { decorateInlineCode(); @@ -403,6 +405,32 @@ bool VMdEditOperations::handleKeyPressEvent(QKeyEvent *p_event) break; } + case Qt::Key_J: + { + if (VUtils::isControlModifierForVim(modifiers)) { + // Scroll down without changing cursor. + QScrollBar *vbar = m_editor->verticalScrollBarW(); + if (vbar && (vbar->minimum() != vbar->maximum())) { + vbar->triggerAction(QAbstractSlider::SliderSingleStepAdd); + } + } + + break; + } + + case Qt::Key_K: + { + if (VUtils::isControlModifierForVim(modifiers)) { + // Scroll up without changing cursor. + QScrollBar *vbar = m_editor->verticalScrollBarW(); + if (vbar && (vbar->minimum() != vbar->maximum())) { + vbar->triggerAction(QAbstractSlider::SliderSingleStepSub); + } + } + + break; + } + default: break; }