Starting work on select/focus logic.

Brian E. Granger 13 years ago
parent ae9cc41a45
commit 2181a29be7

@ -39,6 +39,7 @@ var IPython = (function (IPython) {
this.placeholder = options.placeholder || '';
this.read_only = options.cm_config.readOnly;
this.selected = false;
this.focused = false;
this.metadata = {};
// load this from metadata later ?
this.user_highlight = 'auto';
@ -136,7 +137,7 @@ var IPython = (function (IPython) {
};
/**
* should be triggerd when cell is selected
* handle cell level logic when a cell is selected
* @method select
*/
Cell.prototype.select = function () {
@ -144,9 +145,8 @@ var IPython = (function (IPython) {
this.selected = true;
};
/**
* should be triggerd when cell is unselected
* handle cell level logic when a cell is unselected
* @method unselect
*/
Cell.prototype.unselect = function () {
@ -154,6 +154,24 @@ var IPython = (function (IPython) {
this.selected = false;
};
/**
* handle cell level logic when a cell is focused
* @method focus
*/
Cell.prototype.focus = function () {
this.element.addClass('focused');
this.focused = true;
};
/**
* handle cell level logic when a cell is unfocused
* @method unfocus
*/
Cell.prototype.unfocus = function () {
this.element.removeClass('focused');
this.focused = false;
};
/**
* should be overritten by subclass
* @method get_text

@ -306,13 +306,18 @@ var IPython = (function (IPython) {
CodeCell.prototype.select = function () {
IPython.Cell.prototype.select.apply(this);
this.code_mirror.refresh();
this.code_mirror.focus();
this.auto_highlight();
// We used to need an additional refresh() after the focus, but
// it appears that this has been fixed in CM. This bug would show
// up on FF when a newly loaded markdown cell was edited.
};
CodeCell.prototype.focus = function () {
IPython.Cell.prototype.focus.apply(this);
this.code_mirror.focus();
};
CodeCell.prototype.unfocus = function () {
IPython.Cell.prototype.focus.apply(this);
this.code_mirror.blur();
};
CodeCell.prototype.select_all = function () {
var start = {line: 0, ch: 0};

Loading…
Cancel
Save