##// END OF EJS Templates
Adding keyboard shortcut help dialog.
Brian E. Granger -
Show More
@@ -91,7 +91,7 b' span.section_row_buttons a {'
91 float: right;
91 float: right;
92 width: 170px;
92 width: 170px;
93 padding: 0px 5px;
93 padding: 0px 5px;
94 text-align: center;
94 text-align: left;
95 font-size: 85%;
95 font-size: 85%;
96 }
96 }
97
97
@@ -53,7 +53,7 b' var IPython = (function (IPython) {'
53 Notebook.prototype.bind_events = function () {
53 Notebook.prototype.bind_events = function () {
54 var that = this;
54 var that = this;
55 $(document).keydown(function (event) {
55 $(document).keydown(function (event) {
56 // console.log(event);
56 console.log(event);
57 if (event.which === 38) {
57 if (event.which === 38) {
58 var cell = that.selected_cell();
58 var cell = that.selected_cell();
59 if (cell.at_top()) {
59 if (cell.at_top()) {
@@ -87,7 +87,7 b' var IPython = (function (IPython) {'
87 that.control_key_active = false;
87 that.control_key_active = false;
88 return false;
88 return false;
89 } else if (event.which === 66 && that.control_key_active) {
89 } else if (event.which === 66 && that.control_key_active) {
90 // Insert code cell before selected = a
90 // Insert code cell before selected = b
91 that.insert_code_cell_before();
91 that.insert_code_cell_before();
92 that.control_key_active = false;
92 that.control_key_active = false;
93 return false;
93 return false;
@@ -131,6 +131,11 b' var IPython = (function (IPython) {'
131 that.select_next();
131 that.select_next();
132 that.control_key_active = false;
132 that.control_key_active = false;
133 return false;
133 return false;
134 } else if (event.which === 72 && that.control_key_active) {
135 // Show keyboard shortcuts = h
136 that.show_keyboard_shortcuts();
137 that.control_key_active = false;
138 return false;
134 } else if (that.control_key_active) {
139 } else if (that.control_key_active) {
135 that.control_key_active = false;
140 that.control_key_active = false;
136 return true;
141 return true;
@@ -177,6 +182,35 b' var IPython = (function (IPython) {'
177 };
182 };
178
183
179
184
185 Notebook.prototype.show_keyboard_shortcuts = function () {
186 console.log('showing');
187 var dialog = $('<div/>');
188 var shortcuts = [
189 {key: 'Shift-Enter', help: 'run cell'},
190 {key: 'Ctrl-Enter', help: 'run cell in terminal mode'},
191 {key: 'Ctrl-m d', help: 'delete cell'},
192 {key: 'Ctrl-m a', help: 'insert cell above'},
193 {key: 'Ctrl-m b', help: 'insert cell below'},
194 {key: 'Ctrl-m t', help: 'toggle output'},
195 {key: 'Ctrl-m s', help: 'save notebook'},
196 {key: 'Ctrl-m j', help: 'move cell down'},
197 {key: 'Ctrl-m k', help: 'move cell up'},
198 {key: 'Ctrl-m c', help: 'code cell'},
199 {key: 'Ctrl-m m', help: 'markdown cell'},
200 {key: 'Ctrl-m up', help: 'select previous'},
201 {key: 'Ctrl-m down', help: 'select next'},
202 {key: 'Ctrl-m h', help: 'display keyboard shortcuts'}
203 ];
204 for (var i=0; i<shortcuts.length; i++) {
205 dialog.append($('<div>').
206 append($('<span/>').addClass('shortcut_key').html(shortcuts[i].key+' : ')).
207 append($('<span/>').html(shortcuts[i].help))
208 );
209 };
210 dialog.dialog({title: 'Keyboard shortcuts'});
211 };
212
213
180 Notebook.prototype.scroll_to_bottom = function () {
214 Notebook.prototype.scroll_to_bottom = function () {
181 this.element.animate({scrollTop:this.element.get(0).scrollHeight}, 0);
215 this.element.animate({scrollTop:this.element.get(0).scrollHeight}, 0);
182 };
216 };
@@ -177,11 +177,15 b''
177 </div>
177 </div>
178 <div class="section_row">
178 <div class="section_row">
179 <span class="help_string">run selected cell</span>
179 <span class="help_string">run selected cell</span>
180 <span class="help_string_label">Shift-Enter |</span>
180 <span class="help_string_label">Shift-Enter :</span>
181 </div>
181 </div>
182 <div class="section_row">
182 <div class="section_row">
183 <span class="help_string">run in terminal mode</span>
183 <span class="help_string">run in terminal mode</span>
184 <span class="help_string_label">Ctrl-Enter |</span>
184 <span class="help_string_label">Ctrl-Enter :</span>
185 </div>
186 <div class="section_row">
187 <span class="help_string">show keyboard shortcuts</span>
188 <span class="help_string_label">Ctrl-m h :</span>
185 </div>
189 </div>
186 </div>
190 </div>
187 </div>
191 </div>
General Comments 0
You need to be logged in to leave comments. Login now