##// END OF EJS Templates
Base of an as you type conpleter....
Base of an as you type conpleter. when invoking the completer, instead of having to chose/dismiss, you can continue typing, it will filter the result "as you type" and dismiss itself if ther is no match left. As it is now, it's only works with lowercase letters, I need to find a workaroud for this. for example if you type : * P-y-<tab>-S-o-m-e-t-h-i-n-g * it will propose PySide, but will dismiss when 'o' is pressed and pasting Pyso with a lower case 's'

File last commit:

r5479:0168dc21
r5507:6b2d9cce
Show More
cell.js
96 lines | 2.9 KiB | application/javascript | JavascriptLexer
Brian E. Granger
More review changes....
r4609 //----------------------------------------------------------------------------
// Copyright (C) 2008-2011 The IPython Development Team
//
// Distributed under the terms of the BSD License. The full license is in
// the file COPYING, distributed as part of this software.
//----------------------------------------------------------------------------
Brian E. Granger
Splitting notebook.js into muliple files for development ease.
r4349
//============================================================================
// Cell
//============================================================================
Brian E. Granger
Implemented module and namespace pattern in js notebook.
r4352 var IPython = (function (IPython) {
Brian E. Granger
Splitting notebook.js into muliple files for development ease.
r4349
Brian E. Granger
Implemented module and namespace pattern in js notebook.
r4352 var utils = IPython.utils;
Brian E. Granger
Splitting notebook.js into muliple files for development ease.
r4349
Brian E. Granger
Implemented module and namespace pattern in js notebook.
r4352 var Cell = function (notebook) {
this.notebook = notebook;
MinRK
add read-only view for notebooks...
r5200 this.read_only = false;
if (notebook){
this.read_only = notebook.read_only;
}
Brian E. Granger
Implemented module and namespace pattern in js notebook.
r4352 this.selected = false;
Brian E. Granger
Autoindentation fixed and enabled by default.
r4529 this.element = null;
Brian E. Granger
Implemented module and namespace pattern in js notebook.
r4352 this.create_element();
Brian E. Granger
Autoindentation fixed and enabled by default.
r4529 if (this.element !== null) {
this.set_autoindent(true);
Brian E. Granger
Implemented module and namespace pattern in js notebook.
r4352 this.element.data("cell", this);
this.bind_events();
}
this.cell_id = utils.uuid();
};
Cell.prototype.select = function () {
this.element.addClass('ui-widget-content ui-corner-all');
this.selected = true;
};
Cell.prototype.unselect = function () {
this.element.removeClass('ui-widget-content ui-corner-all');
this.selected = false;
};
Cell.prototype.bind_events = function () {
var that = this;
Stefan van der Walt
Clean up javascript based on js2-mode feedback.
r5479 var nb = that.notebook;
Brian E. Granger
Implemented module and namespace pattern in js notebook.
r4352 that.element.click(function (event) {
if (that.selected === false) {
nb.select(nb.find_cell_index(that));
Stefan van der Walt
Clean up javascript based on js2-mode feedback.
r5479 }
Brian E. Granger
Implemented module and namespace pattern in js notebook.
r4352 });
that.element.focusin(function (event) {
if (that.selected === false) {
nb.select(nb.find_cell_index(that));
Stefan van der Walt
Clean up javascript based on js2-mode feedback.
r5479 }
Brian E. Granger
Implemented module and namespace pattern in js notebook.
r4352 });
};
Brian E. Granger
Adding Cell.grow back to fix bug....
r4400 Cell.prototype.grow = function(element) {
// Grow the cell by hand. This is used upon reloading from JSON, when the
// autogrow handler is not called.
var dom = element.get(0);
var lines_count = 0;
// modified split rule from
// http://stackoverflow.com/questions/2035910/how-to-get-the-number-of-lines-in-a-textarea/2036424#2036424
var lines = dom.value.split(/\r|\r\n|\n/);
lines_count = lines.length;
if (lines_count >= 1) {
dom.rows = lines_count;
} else {
dom.rows = 1;
}
};
Brian E. Granger
Implemented module and namespace pattern in js notebook.
r4352
Brian E. Granger
Implemented smart autoindenting.
r4512 Cell.prototype.set_autoindent = function (state) {
if (state) {
this.code_mirror.setOption('tabMode', 'indent');
this.code_mirror.setOption('enterMode', 'indent');
} else {
this.code_mirror.setOption('tabMode', 'shift');
this.code_mirror.setOption('enterMode', 'flat');
}
};
Brian E. Granger
Implemented module and namespace pattern in js notebook.
r4352 // Subclasses must implement create_element.
Cell.prototype.create_element = function () {};
IPython.Cell = Cell;
return IPython;
}(IPython));
Brian E. Granger
Splitting notebook.js into muliple files for development ease.
r4349