From 9b0db1508349407de77f97f64874b0971ca24e0b Mon Sep 17 00:00:00 2001 From: David Bolack Date: Fri, 17 May 2024 22:10:28 -0500 Subject: [PATCH 1/4] Add Jump To hotkeys This binds CTRL/META-J to brewJump and SHIFT-CTRL/META-J to sourceJump. --- client/homebrew/editor/editor.jsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index f5c1766a8..119658f8c 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -56,6 +56,7 @@ const Editor = createClass({ this.updateEditorSize(); this.highlightCustomMarkdown(); window.addEventListener('resize', this.updateEditorSize); + document.addEventListener('keydown', this.handleControlKeys); const editorTheme = window.localStorage.getItem(EDITOR_THEME_KEY); if(editorTheme) { @@ -79,6 +80,18 @@ const Editor = createClass({ }; }, + handleControlKeys : function(e){ + if(!(e.ctrlKey || e.metaKey)) return; + const J_KEY = 74; + if((!e.shiftKey) && (e.keyCode == J_KEY)) this.brewJump(); + if (e.shiftKey && (e.keyCode == J_KEY)) this.sourceJump(); + if( e.keyCode == J_KEY) { + e.stopPropagation(); + e.preventDefault(); + } + }, + + updateEditorSize : function() { if(this.refs.codeEditor) { let paneHeight = this.refs.main.parentNode.clientHeight; @@ -116,6 +129,7 @@ const Editor = createClass({ const codeMirror = this.refs.codeEditor.codeMirror; codeMirror.operation(()=>{ // Batch CodeMirror styling + //reset custom text styles const customHighlights = codeMirror.getAllMarks().filter((mark)=>!mark.__isFold); //Don't undo code folding for (let i=customHighlights.length - 1;i>=0;i--) customHighlights[i].clear(); From c0cc27a750fd3989541440a933d6db2f9030cba1 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Sun, 19 May 2024 11:12:19 -0500 Subject: [PATCH 2/4] Change Jump hotkeys to M ( move ) bindings. --- client/homebrew/editor/editor.jsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index 119658f8c..abe8c2f39 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -82,10 +82,11 @@ const Editor = createClass({ handleControlKeys : function(e){ if(!(e.ctrlKey || e.metaKey)) return; - const J_KEY = 74; - if((!e.shiftKey) && (e.keyCode == J_KEY)) this.brewJump(); - if (e.shiftKey && (e.keyCode == J_KEY)) this.sourceJump(); - if( e.keyCode == J_KEY) { + console.log(e); + const M_KEY = 77; + if((!e.shiftKey) && (e.keyCode == M_KEY)) this.brewJump(); + if (e.shiftKey && (e.keyCode == M_KEY)) this.sourceJump(); + if( e.keyCode == M_KEY) { e.stopPropagation(); e.preventDefault(); } From a48d9d295eccd4189883d7a3fd10a6572c9c4c60 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Sun, 2 Jun 2024 20:23:33 -0500 Subject: [PATCH 3/4] Try binging to ctrl-X and CTRL-Shift-X which seem to somehow be available... --- client/homebrew/editor/editor.jsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index abe8c2f39..a9b330fcd 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -56,6 +56,7 @@ const Editor = createClass({ this.updateEditorSize(); this.highlightCustomMarkdown(); window.addEventListener('resize', this.updateEditorSize); + document.getElementById('BrewRenderer').addEventListener('keydown', this.handleControlKeys); document.addEventListener('keydown', this.handleControlKeys); const editorTheme = window.localStorage.getItem(EDITOR_THEME_KEY); @@ -72,6 +73,10 @@ const Editor = createClass({ componentDidUpdate : function(prevProps, prevState, snapshot) { this.highlightCustomMarkdown(); + if(this.props.jumpSource) { + this.sourceJump(); + this.setState({sourceJump: false}); + } if(prevProps.moveBrew !== this.props.moveBrew) { this.brewJump(); }; @@ -83,10 +88,10 @@ const Editor = createClass({ handleControlKeys : function(e){ if(!(e.ctrlKey || e.metaKey)) return; console.log(e); - const M_KEY = 77; - if((!e.shiftKey) && (e.keyCode == M_KEY)) this.brewJump(); - if (e.shiftKey && (e.keyCode == M_KEY)) this.sourceJump(); - if( e.keyCode == M_KEY) { + const X_KEY = 88; + if((!e.shiftKey) && (e.keyCode == X_KEY)) this.brewJump(); + if (e.shiftKey && (e.keyCode == X_KEY)) this.sourceJump(); + if( e.keyCode == X_KEY) { e.stopPropagation(); e.preventDefault(); } From a3f146cd53ea665d658cf9616efd965aae17e449 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Wed, 19 Jun 2024 18:39:20 -0500 Subject: [PATCH 4/4] Change the last Boneheaded hot change to something better CTRL-SHIFT-LEFTARROW - Source Jump CTRL-SHIFT-RIGHTARROW - Brew Jump --- client/homebrew/editor/editor.jsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index a9b330fcd..f951563ee 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -88,10 +88,11 @@ const Editor = createClass({ handleControlKeys : function(e){ if(!(e.ctrlKey || e.metaKey)) return; console.log(e); - const X_KEY = 88; - if((!e.shiftKey) && (e.keyCode == X_KEY)) this.brewJump(); - if (e.shiftKey && (e.keyCode == X_KEY)) this.sourceJump(); - if( e.keyCode == X_KEY) { + const LEFTARROW_KEY = 37; + const RIGHTARROW_KEY = 39; + if (e.shiftKey && (e.keyCode == LEFTARROW_KEY)) this.brewJump(); + if (e.shiftKey && (e.keyCode == RIGHTARROW_KEY)) this.sourceJump(); + if ((e.keyCode == LEFTARROW_KEY) || (e.keyCode == RIGHTARROW_KEY)) { e.stopPropagation(); e.preventDefault(); }