##// END OF EJS Templates
Refactor line num. toggle into proper function, access via C-m-l....
Fernando Perez -
Show More
@@ -90,12 +90,7 b' var IPython = (function (IPython) {'
90 } else if (event.keyCode === 76 && event.ctrlKey && event.shiftKey
90 } else if (event.keyCode === 76 && event.ctrlKey && event.shiftKey
91 && event.type == 'keydown') {
91 && event.type == 'keydown') {
92 // toggle line numbers with Ctrl-Shift-L
92 // toggle line numbers with Ctrl-Shift-L
93 if (this.code_mirror.getOption('lineNumbers') == false) {
93 this.toggle_line_numbers()
94 this.code_mirror.setOption('lineNumbers', true);
95 } else {
96 this.code_mirror.setOption('lineNumbers', false);
97 }
98 this.code_mirror.refresh()
99 }
94 }
100 else {
95 else {
101 // keypress/keyup also trigger on TAB press, and we don't want to
96 // keypress/keyup also trigger on TAB press, and we don't want to
@@ -188,6 +183,14 b' var IPython = (function (IPython) {'
188 select.focus();
183 select.focus();
189 };
184 };
190
185
186 CodeCell.prototype.toggle_line_numbers = function () {
187 if (this.code_mirror.getOption('lineNumbers') == false) {
188 this.code_mirror.setOption('lineNumbers', true);
189 } else {
190 this.code_mirror.setOption('lineNumbers', false);
191 }
192 this.code_mirror.refresh()
193 };
191
194
192 CodeCell.prototype.select = function () {
195 CodeCell.prototype.select = function () {
193 IPython.Cell.prototype.select.apply(this);
196 IPython.Cell.prototype.select.apply(this);
@@ -140,6 +140,11 b' var IPython = (function (IPython) {'
140 IPython.notebook.kernel.interrupt();
140 IPython.notebook.kernel.interrupt();
141 that.control_key_active = false;
141 that.control_key_active = false;
142 return false;
142 return false;
143 } else if (event.which === 76 && that.control_key_active) {
144 // Toggle line numbers = l
145 that.cell_toggle_line_numbers();
146 that.control_key_active = false;
147 return false;
143 } else if (event.which === 190 && that.control_key_active) {
148 } else if (event.which === 190 && that.control_key_active) {
144 // Restart kernel = . # matches qt console
149 // Restart kernel = . # matches qt console
145 IPython.notebook.restart_kernel();
150 IPython.notebook.restart_kernel();
@@ -195,12 +200,12 b' var IPython = (function (IPython) {'
195 var dialog = $('<div/>');
200 var dialog = $('<div/>');
196 var shortcuts = [
201 var shortcuts = [
197 {key: 'Shift-Enter', help: 'run cell'},
202 {key: 'Shift-Enter', help: 'run cell'},
198 {key: 'Ctrl-Enter', help: 'run cell in terminal mode'},
203 {key: 'Ctrl-Enter', help: 'run cell in-place'},
199 {key: 'Ctrl-Shift-L', help: 'toggle line numbering'},
200 {key: 'Ctrl-m d', help: 'delete cell'},
204 {key: 'Ctrl-m d', help: 'delete cell'},
201 {key: 'Ctrl-m a', help: 'insert cell above'},
205 {key: 'Ctrl-m a', help: 'insert cell above'},
202 {key: 'Ctrl-m b', help: 'insert cell below'},
206 {key: 'Ctrl-m b', help: 'insert cell below'},
203 {key: 'Ctrl-m t', help: 'toggle output'},
207 {key: 'Ctrl-m t', help: 'toggle output'},
208 {key: 'Ctrl-m l', help: 'toggle line numbers'},
204 {key: 'Ctrl-m s', help: 'save notebook'},
209 {key: 'Ctrl-m s', help: 'save notebook'},
205 {key: 'Ctrl-m j', help: 'move cell down'},
210 {key: 'Ctrl-m j', help: 'move cell down'},
206 {key: 'Ctrl-m k', help: 'move cell up'},
211 {key: 'Ctrl-m k', help: 'move cell up'},
@@ -210,7 +215,7 b' var IPython = (function (IPython) {'
210 {key: 'Ctrl-m n', help: 'select next'},
215 {key: 'Ctrl-m n', help: 'select next'},
211 {key: 'Ctrl-m i', help: 'interrupt kernel'},
216 {key: 'Ctrl-m i', help: 'interrupt kernel'},
212 {key: 'Ctrl-m .', help: 'restart kernel'},
217 {key: 'Ctrl-m .', help: 'restart kernel'},
213 {key: 'Ctrl-m h', help: 'display keyboard shortcuts'}
218 {key: 'Ctrl-m h', help: 'show keyboard shortcuts'}
214 ];
219 ];
215 for (var i=0; i<shortcuts.length; i++) {
220 for (var i=0; i<shortcuts.length; i++) {
216 dialog.append($('<div>').
221 dialog.append($('<div>').
@@ -615,6 +620,11 b' var IPython = (function (IPython) {'
615 this.dirty = true;
620 this.dirty = true;
616 };
621 };
617
622
623 // Other cell functions: line numbers, ...
624
625 Notebook.prototype.cell_toggle_line_numbers = function() {
626 this.selected_cell().toggle_line_numbers()
627 };
618
628
619 // Kernel related things
629 // Kernel related things
620
630
@@ -176,7 +176,7 b''
176 <div class="section_content">
176 <div class="section_content">
177 <div class="section_row">
177 <div class="section_row">
178 <span id="int_restart" class="section_row_buttons">
178 <span id="int_restart" class="section_row_buttons">
179 <button id="int_kernel">Interrupt</button>
179 <button id="int_kernel"><u>I</u>nterrupt</button>
180 <button id="restart_kernel">Restart</button>
180 <button id="restart_kernel">Restart</button>
181 </span>
181 </span>
182 <span class="section_row_header">Actions</span>
182 <span class="section_row_header">Actions</span>
@@ -217,7 +217,7 b''
217 <span class="help_string_label">Shift-Enter :</span>
217 <span class="help_string_label">Shift-Enter :</span>
218 </div>
218 </div>
219 <div class="section_row">
219 <div class="section_row">
220 <span class="help_string">run in terminal mode</span>
220 <span class="help_string">run selected cell in-place</span>
221 <span class="help_string_label">Ctrl-Enter :</span>
221 <span class="help_string_label">Ctrl-Enter :</span>
222 </div>
222 </div>
223 <div class="section_row">
223 <div class="section_row">
General Comments 0
You need to be logged in to leave comments. Login now