##// END OF EJS Templates
Merge pull request #2728 from Carreau/shifttab...
Bussonnier Matthias -
r8971:99339d10 merge
parent child Browse files
Show More
@@ -37,7 +37,6 b' var IPython = (function (IPython) {'
37 this.kernel = kernel || null;
37 this.kernel = kernel || null;
38 this.code_mirror = null;
38 this.code_mirror = null;
39 this.input_prompt_number = null;
39 this.input_prompt_number = null;
40 this.tooltip_on_tab = true;
41 this.collapsed = false;
40 this.collapsed = false;
42 this.default_mode = 'python';
41 this.default_mode = 'python';
43 IPython.Cell.apply(this, arguments);
42 IPython.Cell.apply(this, arguments);
@@ -48,7 +47,6 b' var IPython = (function (IPython) {'
48 );
47 );
49 };
48 };
50
49
51
52 CodeCell.prototype = new IPython.Cell();
50 CodeCell.prototype = new IPython.Cell();
53
51
54 /**
52 /**
@@ -142,6 +140,17 b' var IPython = (function (IPython) {'
142 } else {
140 } else {
143 return true;
141 return true;
144 };
142 };
143 } else if (event.keyCode === key.TAB && event.type == 'keydown' && event.shiftKey) {
144 if (editor.somethingSelected()){
145 var anchor = editor.getCursor("anchor");
146 var head = editor.getCursor("head");
147 if( anchor.line != head.line){
148 return false;
149 }
150 }
151 IPython.tooltip.request(that);
152 event.stop();
153 return true;
145 } else if (event.keyCode === key.TAB && event.type == 'keydown') {
154 } else if (event.keyCode === key.TAB && event.type == 'keydown') {
146 // Tab completion.
155 // Tab completion.
147 //Do not trim here because of tooltip
156 //Do not trim here because of tooltip
@@ -151,7 +160,7 b' var IPython = (function (IPython) {'
151 // Don't autocomplete if the part of the line before the cursor
160 // Don't autocomplete if the part of the line before the cursor
152 // is empty. In this case, let CodeMirror handle indentation.
161 // is empty. In this case, let CodeMirror handle indentation.
153 return false;
162 return false;
154 } else if ((pre_cursor.substr(-1) === "("|| pre_cursor.substr(-1) === " ") && that.tooltip_on_tab ) {
163 } else if ((pre_cursor.substr(-1) === "("|| pre_cursor.substr(-1) === " ") && IPython.config.tooltip_on_tab ) {
155 IPython.tooltip.request(that);
164 IPython.tooltip.request(that);
156 // Prevent the event from bubbling up.
165 // Prevent the event from bubbling up.
157 event.stop();
166 event.stop();
@@ -22,7 +22,7 b' var IPython = (function (IPython) {'
22 * @static
22 * @static
23 *
23 *
24 **/
24 **/
25 var config = {
25 var default_config = {
26 /**
26 /**
27 * Dictionary of object to autodetect highlight mode for code cell.
27 * Dictionary of object to autodetect highlight mode for code cell.
28 * Item of the dictionnary should take the form :
28 * Item of the dictionnary should take the form :
@@ -63,10 +63,14 b' var IPython = (function (IPython) {'
63 */
63 */
64 raw_cell_highlight : {
64 raw_cell_highlight : {
65 'diff' :{'reg':[/^diff/]}
65 'diff' :{'reg':[/^diff/]}
66 }
66 },
67
68 tooltip_on_tab : true,
67 };
69 };
68
70
69 IPython.config = config;
71 // use the same method to merge user configuration
72 IPython.config = {};
73 $.extend(IPython.config, default_config);
70
74
71 return IPython;
75 return IPython;
72
76
@@ -228,6 +228,10 b' var IPython = (function (IPython) {'
228 ch: 0
228 ch: 0
229 }, cursor).trim();
229 }, cursor).trim();
230
230
231 if(editor.somethingSelected()){
232 text = editor.getSelection();
233 }
234
231 // need a permanent handel to code_mirror for future auto recall
235 // need a permanent handel to code_mirror for future auto recall
232 this.code_mirror = editor;
236 this.code_mirror = editor;
233
237
@@ -288,7 +292,15 b' var IPython = (function (IPython) {'
288 var w = $(this.code_mirror.getScrollerElement()).width();
292 var w = $(this.code_mirror.getScrollerElement()).width();
289 // ofset of the editor
293 // ofset of the editor
290 var o = $(this.code_mirror.getScrollerElement()).offset();
294 var o = $(this.code_mirror.getScrollerElement()).offset();
291 var pos = this.code_mirror.cursorCoords();
295
296 // whatever anchor/head order but arrow at mid x selection
297 var anchor = this.code_mirror.cursorCoords(false);
298 var head = this.code_mirror.cursorCoords(true);
299 var pos = {};
300 pos.y = head.y
301 pos.yBot = head.yBot
302 pos.x = (head.x+anchor.x)/2;
303
292 var xinit = pos.x;
304 var xinit = pos.x;
293 var xinter = o.left + (xinit - o.left) / w * (w - 450);
305 var xinter = o.left + (xinit - o.left) / w * (w - 450);
294 var posarrowleft = xinit - xinter;
306 var posarrowleft = xinit - xinter;
General Comments 0
You need to be logged in to leave comments. Login now