From 605e63b345860ed22f749b3cd11503a7784cdd14 Mon Sep 17 00:00:00 2001 From: Jaimos Skriletz Date: Sat, 5 Oct 2024 18:57:34 -0600 Subject: [PATCH] Change key bindings for folding in PGCodeMirror. By default code mirror uses Shift-Ctrl-F for find/replace and Shift-Ctrl-G for find previous. These key bindings were overwritten when folding was added. This changes the fold binding to Shift-Ctrl-[, fold all to Ctrl-Alt-[ and unfold all to Ctrl-Alt-[, so they no longer interfere with the find replace key bindings. --- htdocs/js/PGCodeMirror/pgeditor.js | 10 ++++------ templates/HelpFiles/InstructorPGProblemEditor.html.ep | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/htdocs/js/PGCodeMirror/pgeditor.js b/htdocs/js/PGCodeMirror/pgeditor.js index 286cf45247..f9d314c79c 100644 --- a/htdocs/js/PGCodeMirror/pgeditor.js +++ b/htdocs/js/PGCodeMirror/pgeditor.js @@ -78,12 +78,10 @@ lineWrapping: true, extraKeys: { Tab: (cm) => cm.execCommand('insertSoftTab'), - 'Shift-Ctrl-F': (cm) => cm.foldCode(cm.getCursor(), { scanUp: true }), - 'Shift-Cmd-F': (cm) => cm.foldCode(cm.getCursor(), { scanUp: true }), - 'Shift-Ctrl-A': (cm) => CodeMirror.commands.foldAll(cm), - 'Shift-Cmd-A': (cm) => CodeMirror.commands.foldAll(cm), - 'Shift-Ctrl-G': (cm) => CodeMirror.commands.unfoldAll(cm), - 'Shift-Cmd-G': (cm) => CodeMirror.commands.unfoldAll(cm) + 'Shift-Ctrl-[': (cm) => cm.foldCode(cm.getCursor(), { scanUp: true }), + 'Shift-Cmd-[': (cm) => cm.foldCode(cm.getCursor(), { scanUp: true }), + 'Ctrl-Alt-[': (cm) => CodeMirror.commands.foldAll(cm), + 'Ctrl-Alt-]': (cm) => CodeMirror.commands.unfoldAll(cm) }, highlightSelectionMatches: { annotateScrollbar: true }, matchBrackets: true, diff --git a/templates/HelpFiles/InstructorPGProblemEditor.html.ep b/templates/HelpFiles/InstructorPGProblemEditor.html.ep index c28751e7ee..1fbe46cc96 100644 --- a/templates/HelpFiles/InstructorPGProblemEditor.html.ep +++ b/templates/HelpFiles/InstructorPGProblemEditor.html.ep @@ -76,8 +76,8 @@
<%= maketext('This is where you edit the text of the problem template. Type Ctrl-Enter while this ' . 'window has focus to re-render the problem. Code folding is enabled either by clicking on ' - . 'the triangles in the gutter next to line numbers or using the shortcut Shift-Ctrl-F. Folding ' - . 'all regions can be accomplished with Shift-Ctrl-A and unfold all regions with Shift-Ctrl-G. ' + . 'the triangles in the gutter next to line numbers or using the shortcut Shift-Ctrl-~[. Folding ' + . 'all regions can be accomplished with Ctrl-Alt-~[ and unfold all regions with Ctrl-Alt-~]. ' . 'Comments can be toggled with Ctrl-/.') =%>
<%= maketext('Text Editor Options') %>