##// END OF EJS Templates
jshint on codecell
MinRK -
Show More
@@ -17,7 +17,7
17 17
18 18
19 19 /* local util for codemirror */
20 var posEq = function(a, b) {return a.line == b.line && a.ch == b.ch;}
20 var posEq = function(a, b) {return a.line == b.line && a.ch == b.ch;};
21 21
22 22 /**
23 23 *
@@ -27,16 +27,16 var posEq = function(a, b) {return a.line == b.line && a.ch == b.ch;}
27 27 */
28 28 CodeMirror.commands.delSpaceToPrevTabStop = function(cm){
29 29 var from = cm.getCursor(true), to = cm.getCursor(false), sel = !posEq(from, to);
30 if (!posEq(from, to)) {cm.replaceRange("", from, to); return}
30 if (!posEq(from, to)) { cm.replaceRange("", from, to); return; }
31 31 var cur = cm.getCursor(), line = cm.getLine(cur.line);
32 32 var tabsize = cm.getOption('tabSize');
33 33 var chToPrevTabStop = cur.ch-(Math.ceil(cur.ch/tabsize)-1)*tabsize;
34 var from = {ch:cur.ch-chToPrevTabStop,line:cur.line}
35 var select = cm.getRange(from,cur)
36 if( select.match(/^\ +$/) != null){
37 cm.replaceRange("",from,cur)
34 from = {ch:cur.ch-chToPrevTabStop,line:cur.line};
35 var select = cm.getRange(from,cur);
36 if( select.match(/^\ +$/) !== null){
37 cm.replaceRange("",from,cur);
38 38 } else {
39 cm.deleteH(-1,"char")
39 cm.deleteH(-1,"char");
40 40 }
41 41 };
42 42
@@ -104,7 +104,7 var IPython = (function (IPython) {
104 104 * @method auto_highlight
105 105 */
106 106 CodeCell.prototype.auto_highlight = function () {
107 this._auto_highlight(IPython.config.cell_magic_highlight)
107 this._auto_highlight(IPython.config.cell_magic_highlight);
108 108 };
109 109
110 110 /** @method create_element */
@@ -117,7 +117,7 var IPython = (function (IPython) {
117 117 this.celltoolbar = new IPython.CellToolbar(this);
118 118
119 119 var input = $('<div></div>').addClass('input');
120 var vbox = $('<div/>').addClass('vbox box-flex1')
120 var vbox = $('<div/>').addClass('vbox box-flex1');
121 121 input.append($('<div/>').addClass('prompt input_prompt'));
122 122 vbox.append(this.celltoolbar.element);
123 123 var input_area = $('<div/>').addClass('input_area');
@@ -152,7 +152,7 var IPython = (function (IPython) {
152 152 // they are sent, and remove tooltip if any, except for tab again
153 153 if (event.type === 'keydown' && event.which != key.TAB ) {
154 154 IPython.tooltip.remove_and_cancel_tooltip();
155 };
155 }
156 156
157 157 var cur = editor.getCursor();
158 158 if (event.keyCode === key.ENTER){
@@ -177,7 +177,7 var IPython = (function (IPython) {
177 177 return false;
178 178 } else {
179 179 return true;
180 };
180 }
181 181 } else if (event.which === key.ESC) {
182 182 return IPython.tooltip.remove_and_cancel_tooltip(true);
183 183 } else if (event.which === key.DOWNARROW && event.type === 'keydown') {
@@ -188,7 +188,7 var IPython = (function (IPython) {
188 188 return false;
189 189 } else {
190 190 return true;
191 };
191 }
192 192 } else if (event.keyCode === key.TAB && event.type == 'keydown' && event.shiftKey) {
193 193 if (editor.somethingSelected()){
194 194 var anchor = editor.getCursor("anchor");
@@ -203,7 +203,7 var IPython = (function (IPython) {
203 203 } else if (event.keyCode === key.TAB && event.type == 'keydown') {
204 204 // Tab completion.
205 205 //Do not trim here because of tooltip
206 if (editor.somethingSelected()){return false}
206 if (editor.somethingSelected()) { return false; }
207 207 var pre_cursor = editor.getRange({line:cur.line,ch:0},cur);
208 208 if (pre_cursor.trim() === "") {
209 209 // Don't autocomplete if the part of the line before the cursor
@@ -219,12 +219,12 var IPython = (function (IPython) {
219 219 event.stop();
220 220 this.completer.startCompletion();
221 221 return true;
222 };
222 }
223 223 } else {
224 224 // keypress/keyup also trigger on TAB press, and we don't want to
225 225 // use those to disable tab completion.
226 226 return false;
227 };
227 }
228 228 return false;
229 229 };
230 230
@@ -233,7 +233,7 var IPython = (function (IPython) {
233 233
234 234 CodeCell.prototype.set_kernel = function (kernel) {
235 235 this.kernel = kernel;
236 }
236 };
237 237
238 238 /**
239 239 * Execute current code cell to the kernel
@@ -258,7 +258,7 var IPython = (function (IPython) {
258 258 clear_output : $.proxy(this.output_area.handle_clear_output, this.output_area),
259 259 },
260 260 input : $.proxy(this._handle_input_request, this)
261 }
261 };
262 262
263 263 this.last_msg_id = this.kernel.execute(this.get_text(), callbacks, {silent: false, store_history: true});
264 264 };
@@ -271,16 +271,16 var IPython = (function (IPython) {
271 271 this.set_input_prompt(msg.content.execution_count);
272 272 this.element.removeClass("running");
273 273 $([IPython.events]).trigger('set_dirty.Notebook', {value: true});
274 }
274 };
275 275
276 276 /**
277 277 * @method _handle_set_next_input
278 278 * @private
279 279 */
280 280 CodeCell.prototype._handle_set_next_input = function (payload) {
281 var data = {'cell': this, 'text': payload.text}
281 var data = {'cell': this, 'text': payload.text};
282 282 $([IPython.events]).trigger('set_next_input.Notebook', data);
283 }
283 };
284 284
285 285 /**
286 286 * @method _handle_input_request
@@ -288,7 +288,7 var IPython = (function (IPython) {
288 288 */
289 289 CodeCell.prototype._handle_input_request = function (msg) {
290 290 this.output_area.append_raw_input(msg);
291 }
291 };
292 292
293 293
294 294 // Basic cell manipulation.
@@ -338,21 +338,23 var IPython = (function (IPython) {
338 338
339 339 CodeCell.input_prompt_classical = function (prompt_value, lines_number) {
340 340 var ns = prompt_value || "&nbsp;";
341 return 'In&nbsp;[' + ns + ']:'
341 return 'In&nbsp;[' + ns + ']:';
342 342 };
343 343
344 344 CodeCell.input_prompt_continuation = function (prompt_value, lines_number) {
345 345 var html = [CodeCell.input_prompt_classical(prompt_value, lines_number)];
346 for(var i=1; i < lines_number; i++){html.push(['...:'])};
347 return html.join('</br>')
346 for(var i=1; i < lines_number; i++) {
347 html.push(['...:']);
348 }
349 return html.join('<br/>');
348 350 };
349 351
350 352 CodeCell.input_prompt_function = CodeCell.input_prompt_classical;
351 353
352 354
353 355 CodeCell.prototype.set_input_prompt = function (number) {
354 var nline = 1
355 if( this.code_mirror != undefined) {
356 var nline = 1;
357 if (this.code_mirror !== undefined) {
356 358 nline = this.code_mirror.lineCount();
357 359 }
358 360 this.input_prompt_number = number;
@@ -417,16 +419,16 var IPython = (function (IPython) {
417 419 this.set_input_prompt(data.prompt_number);
418 420 } else {
419 421 this.set_input_prompt();
420 };
422 }
421 423 this.output_area.fromJSON(data.outputs);
422 424 if (data.collapsed !== undefined) {
423 425 if (data.collapsed) {
424 426 this.collapse();
425 427 } else {
426 428 this.expand();
427 };
428 };
429 };
429 }
430 }
431 }
430 432 };
431 433
432 434
@@ -436,7 +438,7 var IPython = (function (IPython) {
436 438 data.cell_type = 'code';
437 439 if (this.input_prompt_number) {
438 440 data.prompt_number = this.input_prompt_number;
439 };
441 }
440 442 var outputs = this.output_area.toJSON();
441 443 data.outputs = outputs;
442 444 data.language = 'python';
General Comments 0
You need to be logged in to leave comments. Login now