##// END OF EJS Templates
Better handling of up/down arrows for CodeCells.
Brian Granger -
Show More
@@ -88,12 +88,22 b' Notebook.prototype.bind_events = function () {'
88 88 var that = this;
89 89 $(document).keydown(function (event) {
90 90 // console.log(event);
91 if (event.which == 38 && event.shiftKey) {
92 event.preventDefault();
93 that.select_prev();
94 } else if (event.which == 40 && event.shiftKey) {
95 event.preventDefault();
96 that.select_next();
91 if (event.which == 38) {
92 var cell = that.selected_cell();
93 if (cell instanceof CodeCell) {
94 if (cell.at_top()) {
95 event.preventDefault();
96 that.select_prev();
97 };
98 };
99 } else if (event.which == 40) {
100 var cell = that.selected_cell();
101 if (cell instanceof CodeCell) {
102 if (cell.at_bottom()) {
103 event.preventDefault();
104 that.select_next();
105 };
106 };
97 107 } else if (event.which == 13 && event.shiftKey) {
98 108 // The focus is not quite working here.
99 109 var cell = that.selected_cell();
@@ -782,6 +792,26 b' CodeCell.prototype.set_code = function (code) {'
782 792 };
783 793
784 794
795 CodeCell.prototype.at_top = function () {
796 var cursor = this.code_mirror.getCursor();
797 if (cursor.line === 0) {
798 return true;
799 } else {
800 return false;
801 }
802 };
803
804
805 CodeCell.prototype.at_bottom = function () {
806 var cursor = this.code_mirror.getCursor();
807 if (cursor.line === (this.code_mirror.lineCount()-1)) {
808 return true;
809 } else {
810 return false;
811 }
812 };
813
814
785 815 CodeCell.prototype.fromJSON = function (data) {
786 816 if (data.cell_type === 'code') {
787 817 this.set_code(data.code);
General Comments 0
You need to be logged in to leave comments. Login now