##// END OF EJS Templates
Work on shortcuts and examples notebook.
Brian E. Granger -
Show More
@@ -550,8 +550,10 b' var IPython = (function (IPython) {'
550 if (typeof(data) === 'function') {
550 if (typeof(data) === 'function') {
551 data = {help: '', help_index: '', handler: data}
551 data = {help: '', help_index: '', handler: data}
552 }
552 }
553 data.help_index = data.help_index || '';
554 data.help = data.help || '';
553 if (data.help_index === '') {
555 if (data.help_index === '') {
554 data.help_index = 'zz',
556 data.help_index = 'zz';
555 }
557 }
556 shortcut = this.normalize_shortcut(shortcut);
558 shortcut = this.normalize_shortcut(shortcut);
557 this._shortcuts[shortcut] = data;
559 this._shortcuts[shortcut] = data;
@@ -12,17 +12,17 b''
12 "level": 1,
12 "level": 1,
13 "metadata": {},
13 "metadata": {},
14 "source": [
14 "source": [
15 "User Experience"
15 "User Interface"
16 ]
16 ]
17 },
17 },
18 {
18 {
19 "cell_type": "markdown",
19 "cell_type": "markdown",
20 "metadata": {},
20 "metadata": {},
21 "source": [
21 "source": [
22 "This notebook describes the user experience of the IPython Notebook. This includes both mouse and keyboard based navigation and interaction.\n",
22 "This notebook describes the user interface of the IPython Notebook. This includes both mouse and keyboard based navigation and interaction.\n",
23 "\n",
23 "\n",
24 "<div class=\"alert\" style=\"margin: 10px\">\n",
24 "<div class=\"alert\" style=\"margin: 10px\">\n",
25 "As of IPython 2.0, the user experience has changed significantly. Because of this we highly recommend existing users to review this information after upgrading to IPython 2.0. All new users of IPython should review this information as well.\n",
25 "As of IPython 2.0, the user interface has changed significantly. Because of this we highly recommend existing users to review this information after upgrading to IPython 2.0. All new users of IPython should review this information as well.\n",
26 "</div>"
26 "</div>"
27 ]
27 ]
28 },
28 },
@@ -38,7 +38,7 b''
38 "cell_type": "markdown",
38 "cell_type": "markdown",
39 "metadata": {},
39 "metadata": {},
40 "source": [
40 "source": [
41 "Starting with IPython 2.0, the IPython Notebook has a modal user experience. This means that the keyboard does different things depending on which mode the Notebook is in. There are two modes: edit mode and command mode."
41 "Starting with IPython 2.0, the IPython Notebook has a modal user interface. This means that the keyboard does different things depending on which mode the Notebook is in. There are two modes: edit mode and command mode."
42 ]
42 ]
43 },
43 },
44 {
44 {
@@ -138,7 +138,7 b''
138 "cell_type": "markdown",
138 "cell_type": "markdown",
139 "metadata": {},
139 "metadata": {},
140 "source": [
140 "source": [
141 "The modal user experience of the IPython Notebook has been optimized for efficient keyboard usage. This is made possible by having two different sets of keyboard shortcuts: one set that is active in edit mode and another in command mode.\n",
141 "The modal user interface of the IPython Notebook has been optimized for efficient keyboard usage. This is made possible by having two different sets of keyboard shortcuts: one set that is active in edit mode and another in command mode.\n",
142 "\n",
142 "\n",
143 "The most important keyboard shortcuts are `enter`, which enters edit mode, and `esc`, which enters command mode.\n",
143 "The most important keyboard shortcuts are `enter`, which enters edit mode, and `esc`, which enters command mode.\n",
144 "\n",
144 "\n",
@@ -146,6 +146,13 b''
146 ]
146 ]
147 },
147 },
148 {
148 {
149 "cell_type": "markdown",
150 "metadata": {},
151 "source": [
152 "The `display_edit_shortcuts()` function used here is defined in the [Utilities section](#Utilities) at the bottom of this notebook."
153 ]
154 },
155 {
149 "cell_type": "code",
156 "cell_type": "code",
150 "collapsed": false,
157 "collapsed": false,
151 "input": [
158 "input": [
@@ -259,7 +266,7 b''
259 "\n",
266 "\n",
260 "IPython.keyboard_manager.command_shortcuts.add_shortcut('r', {\n",
267 "IPython.keyboard_manager.command_shortcuts.add_shortcut('r', {\n",
261 " help : 'run cell',\n",
268 " help : 'run cell',\n",
262 " help_index : 'bd',\n",
269 " help_index : 'zz',\n",
263 " handler : function (event) {\n",
270 " handler : function (event) {\n",
264 " IPython.notebook.execute_cell();\n",
271 " IPython.notebook.execute_cell();\n",
265 " return false;\n",
272 " return false;\n",
@@ -274,7 +281,7 b''
274 "\n",
281 "\n",
275 "IPython.keyboard_manager.command_shortcuts.add_shortcut('r', {\n",
282 "IPython.keyboard_manager.command_shortcuts.add_shortcut('r', {\n",
276 " help : 'run cell',\n",
283 " help : 'run cell',\n",
277 " help_index : 'bd',\n",
284 " help_index : 'aa',\n",
278 " handler : function (event) {\n",
285 " handler : function (event) {\n",
279 " IPython.notebook.execute_cell();\n",
286 " IPython.notebook.execute_cell();\n",
280 " return false;\n",
287 " return false;\n",
@@ -284,11 +291,11 b''
284 "metadata": {},
291 "metadata": {},
285 "output_type": "display_data",
292 "output_type": "display_data",
286 "text": [
293 "text": [
287 "<IPython.core.display.Javascript at 0x10e441390>"
294 "<IPython.core.display.Javascript at 0x1019ba990>"
288 ]
295 ]
289 }
296 }
290 ],
297 ],
291 "prompt_number": 17
298 "prompt_number": 6
292 },
299 },
293 {
300 {
294 "cell_type": "markdown",
301 "cell_type": "markdown",
@@ -296,10 +303,46 b''
296 "source": [
303 "source": [
297 "There are a couple of points to mention about this API:\n",
304 "There are a couple of points to mention about this API:\n",
298 "\n",
305 "\n",
299 "* The `help_index` field is used to sort the shortcuts in the Keyboard Shortcuts help dialog.\n",
306 "* The `help_index` field is used to sort the shortcuts in the Keyboard Shortcuts help dialog. It defaults to `zz`.\n",
300 "* When a handler returns `false` it indicates that the event should stop propagating and the default action should not be performed. For further details about the `event` object or event handling, see the jQuery docs.\n",
307 "* When a handler returns `false` it indicates that the event should stop propagating and the default action should not be performed. For further details about the `event` object or event handling, see the jQuery docs.\n",
301 "* If you don't need a `help` or `help_index` field, you can simply pass a function as the second argument to `add_shortcut`.\n",
308 "* If you don't need a `help` or `help_index` field, you can simply pass a function as the second argument to `add_shortcut`."
309 ]
310 },
311 {
312 "cell_type": "code",
313 "collapsed": false,
314 "input": [
315 "%%javascript\n",
302 "\n",
316 "\n",
317 "IPython.keyboard_manager.command_shortcuts.add_shortcut('r', function (event) {\n",
318 " IPython.notebook.execute_cell();\n",
319 " return false;\n",
320 "});"
321 ],
322 "language": "python",
323 "metadata": {},
324 "outputs": [
325 {
326 "javascript": [
327 "\n",
328 "IPython.keyboard_manager.command_shortcuts.add_shortcut('r', function (event) {\n",
329 " IPython.notebook.execute_cell();\n",
330 " return false;\n",
331 "});"
332 ],
333 "metadata": {},
334 "output_type": "display_data",
335 "text": [
336 "<IPython.core.display.Javascript at 0x1019baf90>"
337 ]
338 }
339 ],
340 "prompt_number": 11
341 },
342 {
343 "cell_type": "markdown",
344 "metadata": {},
345 "source": [
303 "Likewise, to remove a shortcut, use `remove_shortcut`:"
346 "Likewise, to remove a shortcut, use `remove_shortcut`:"
304 ]
347 ]
305 },
348 },
@@ -322,11 +365,11 b''
322 "metadata": {},
365 "metadata": {},
323 "output_type": "display_data",
366 "output_type": "display_data",
324 "text": [
367 "text": [
325 "<IPython.core.display.Javascript at 0x10e441250>"
368 "<IPython.core.display.Javascript at 0x1019ba950>"
326 ]
369 ]
327 }
370 }
328 ],
371 ],
329 "prompt_number": 18
372 "prompt_number": 8
330 },
373 },
331 {
374 {
332 "cell_type": "markdown",
375 "cell_type": "markdown",
@@ -369,7 +412,7 b''
369 "language": "python",
412 "language": "python",
370 "metadata": {},
413 "metadata": {},
371 "outputs": [],
414 "outputs": [],
372 "prompt_number": 12
415 "prompt_number": 2
373 }
416 }
374 ],
417 ],
375 "metadata": {}
418 "metadata": {}
General Comments 0
You need to be logged in to leave comments. Login now