Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unpatch/Monkey patch CM #2906

Merged
merged 3 commits into from
Feb 13, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,44 +62,10 @@ Then don't forget to reintroduce ipython.css
IPython/frontend/html/notebook/static/codemirror/theme/ipython.css | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)

and

git show head^
commit 331a5f7fe85a6e894c35b64cd7987ed53f59ea57
Author: Matthias BUSSONNIER <bussonniermatthias@gmail.com>
Date: Wed Jul 25 12:41:13 2012 +0200

patch deletion in codemirror

diff --git a/IPython/frontend/html/notebook/static/codemirror/lib/codemirror.js b/IPython/frontend/html/notebook/static/codemirror/lib/codemirror.js
index 89401a9..a9dfdfe 100644
--- a/IPython/frontend/html/notebook/static/codemirror/lib/codemirror.js
+++ b/IPython/frontend/html/notebook/static/codemirror/lib/codemirror.js
@@ -2194,6 +2194,20 @@ var CodeMirror = (function() {
cm.indentLine(cm.getCursor().line);
},
toggleOverwrite: function(cm) {cm.toggleOverwrite();}
+ ,delSpaceToPrevTabStop : function(cm){
+ var from = cm.getCursor(true), to = cm.getCursor(false), sel = !posEq(from, to);
+ if (!posEq(from, to)) {cm.replaceRange("", from, to); return}
+ var cur = cm.getCursor(), line = cm.getLine(cur.line);
+ var tabsize = cm.getOption('tabSize');
+ var chToPrevTabStop = cur.ch-(Math.ceil(cur.ch/tabsize)-1)*tabsize;
+ var from = {ch:cur.ch-chToPrevTabStop,line:cur.line}
+ var select = cm.getRange(from,cur)
+ if( select.match(/^\ +$/) != null){
+ cm.replaceRange("",from,cur)
+ } else {
+ cm.deleteH(-1,"char")
+ }
+ }
};

var keyMap = CodeMirror.keyMap = {};

that you should be able to apply after updating codemirror with

git cherry-pick 271e17 39a602 331a5f
git cherry-pick 271e17 39a602

We'll turn this into a proper patchset if it ever gets more complicated than
this, but for now this note should be enough.
14 changes: 0 additions & 14 deletions IPython/frontend/html/notebook/static/codemirror/lib/codemirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -2194,20 +2194,6 @@ var CodeMirror = (function() {
cm.indentLine(cm.getCursor().line);
},
toggleOverwrite: function(cm) {cm.toggleOverwrite();}
,delSpaceToPrevTabStop : function(cm){
var from = cm.getCursor(true), to = cm.getCursor(false), sel = !posEq(from, to);
if (!posEq(from, to)) {cm.replaceRange("", from, to); return}
var cur = cm.getCursor(), line = cm.getLine(cur.line);
var tabsize = cm.getOption('tabSize');
var chToPrevTabStop = cur.ch-(Math.ceil(cur.ch/tabsize)-1)*tabsize;
var from = {ch:cur.ch-chToPrevTabStop,line:cur.line}
var select = cm.getRange(from,cur)
if( select.match(/^\ +$/) != null){
cm.replaceRange("",from,cur)
} else {
cm.deleteH(-1,"char")
}
}
};

var keyMap = CodeMirror.keyMap = {};
Expand Down
26 changes: 26 additions & 0 deletions IPython/frontend/html/notebook/static/js/codecell.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,32 @@
* @submodule CodeCell
*/


/* local util for codemirror */
var posEq = function(a, b) {return a.line == b.line && a.ch == b.ch;}

/**
*
* function to delete until previous non blanking space character
* or first multiple of 4 tabstop.
* @private
*/
CodeMirror.commands.delSpaceToPrevTabStop = function(cm){
var from = cm.getCursor(true), to = cm.getCursor(false), sel = !posEq(from, to);
if (!posEq(from, to)) {cm.replaceRange("", from, to); return}
var cur = cm.getCursor(), line = cm.getLine(cur.line);
var tabsize = cm.getOption('tabSize');
var chToPrevTabStop = cur.ch-(Math.ceil(cur.ch/tabsize)-1)*tabsize;
var from = {ch:cur.ch-chToPrevTabStop,line:cur.line}
var select = cm.getRange(from,cur)
if( select.match(/^\ +$/) != null){
cm.replaceRange("",from,cur)
} else {
cm.deleteH(-1,"char")
}
};


var IPython = (function (IPython) {
"use strict";

Expand Down