##// END OF EJS Templates
add dirty trick for readline import on OSX...
add dirty trick for readline import on OSX also made the libedit warning extremely loud, so people don't miss it. We still get reports of people never having noticed the warning, and getting confused when readline is broken on OSX. The reason for the dirty trick: pip installs to site-packages by default, but site-packages dirs always come *after* lib-dynload (and extras, etc.), which is where the system readline is installed. That means that a non-setuptools install (pip or setup.py install) *cannot* override any package that ships with OSX, including: numpy, readline, twisted, pyobjc without installing to a non-standard path (not even user site-packages via `--user`). The method for the dirty trick: 1. remove lib-dynload from sys.path before trying to import readline the first time 2. after import, restore lib-dynload to its place in sys.path 3. if import failed without lib-dynload, try it one more time

File last commit:

r4609:a661b7c0
r5206:387dcd6a
Show More
cell.js
93 lines | 2.8 KiB | application/javascript | JavascriptLexer
//----------------------------------------------------------------------------
// 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.
//----------------------------------------------------------------------------
//============================================================================
// Cell
//============================================================================
var IPython = (function (IPython) {
var utils = IPython.utils;
var Cell = function (notebook) {
this.notebook = notebook;
this.selected = false;
this.element = null;
this.create_element();
if (this.element !== null) {
this.set_autoindent(true);
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;
var nb = that.notebook
that.element.click(function (event) {
if (that.selected === false) {
nb.select(nb.find_cell_index(that));
};
});
that.element.focusin(function (event) {
if (that.selected === false) {
nb.select(nb.find_cell_index(that));
};
});
};
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;
}
};
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');
}
};
// Subclasses must implement create_element.
Cell.prototype.create_element = function () {};
IPython.Cell = Cell;
return IPython;
}(IPython));