##// END OF EJS Templates
Add %guiref to give a quick reference to the GUI console.
Fernando Perez -
Show More
@@ -281,17 +281,200 b' The following magic functions are currently available:'
281
281
282 """
282 """
283
283
284 gui_reference = """\
285 ===============================
286 The IPython graphical console
287 ===============================
288
289 This console is designed to emulate in many aspects the look, feel and workflow
290 typical of a terminal environment, but it adds support for a number of
291 enhancements that are simply not possible in a real terminal, such as inline
292 syntax highlighting, true multiline editing, inline graphics and much more.
293
294 This quick reference document contains the basic information you'll need to
295 know to make the most efficient use of it. For the various command line
296 options available at startup, type ``--help`` at the command line.
297
298
299 Multiline editing
300 =================
301
302 The graphical console is capable of true multiline editing, but it also tries
303 to behave intuitively like a terminal when possible. If you are used to
304 IPyhton's old terminal behavior, you should find the transition painless, and
305 once you learn a few basic keybindings it will be a much more efficient
306 environment.
307
308 For single expressions or indented blocks, the console behaves almost like the
309 terminal IPython: single expressions are immediately evaluated *if the cursor
310 is at the end of the line*, and indented blocks are evaluated once a single
311 blank line is entered::
312
313 In [1]: print "Hello IPython!" # Enter was pressed at the end of the line
314 Hello IPython!
315
316 In [2]: for i in range(10):
317 ...: print i,
318 ...:
319 0 1 2 3 4 5 6 7 8 9
320
321 If you have a single expression and you go back to edit something in the
322 beginning, hitting ``Enter`` will split the line (like a text editor) instead
323 of executing it. To execute, you can either go to the end of the line to hit
324 ``Enter``, or hit ``Shift-Enter`` anywhere, which is the 'force execution'
325 keybinding.
326
327 If you want to enter more than one expression in a single input block
328 (something not possible in the terminal), you can use ``Control-Enter`` at the
329 end of your first line instead of ``Enter``. At that point the console goes
330 into 'cell mode' and even if your inputs are not indented, it will continue
331 accepting arbitrarily many lines until either you enter an extra blank line or
332 you hit ``Shift-Enter`` (the key binding that forces execution). When a
333 multiline cell is entered, IPython analyzes it and executes its code producing
334 an ``Out[n]`` prompt only for the last expression in it, while the rest of the
335 cell is executed as if it was a script. A few examples should clarify this::
336
337
338 In [3]: x=1 # Hit C-Enter here
339 ...: y=2 # from now on, regular Enter is sufficient
340 ...: z=3
341 ...: x**2 # This does *not* produce an Out[] value
342 ...: x+y+z # Only the last expression does
343 ...:
344 Out[3]: 6
345
346 The behavior where an extra blank line forces execution is only active if you
347 are actually typing at the keyboard each line, and is meant to make it mimic
348 the IPython terminal behavior. If you paste a long chunk of input (for example
349 a long script copied form an editor or web browser), it can contain arbitrarily
350 many intermediate blank lines and they won't cause any problems. You can then
351 make it execute by appending a blank line *at the end* or hitting
352 ``Shift-Enter`` anywhere within the cell.
353
354 With the up arrow key, you can retrieve previous blocks of input that contain
355 multiple lines. You can move inside of it like you would in any text editor.
356 When you want it executed, the simplest thing to do is to hit the force
357 execution key, ``Shift-Enter`` (though you can also navigate to the end and
358 append a blank line by using ``Enter`` twice).
359
360 If you've edited a multiline cell and accidentally navigate out of it with the
361 up or down arrow keys, IPython will clear the cell and replace it with the
362 contents of the one above or below that you navigated to. If this was an
363 accident and you want to retrieve the cell you were editing, use the Undo
364 keybinding, ``Control-z``.
365
366
367 Key bindings
368 ============
369
370 The IPython console supports most of the basic Emacs line-oriented
371 keybindings, in addition to some of its own.
372
373 The keybinding prefixes mean:
374
375 C : Control
376 S : Shift
377 M : Meta (typically the Alt key)
378
379 The keybindings themselves are:
380
381 Enter : insert new line (may cause execution, see above).
382 C-Enter : force new line, *never* causes execution.
383 S-Enter : *force* execution regardless of where cursor is, no newline added.
384 C-c : copy highlighted text to clipboard (prompts are automatically stripped).
385 C-v : paste text from clipboard.
386 C-z : undo (retrieves lost text if you move out of a cell with the arrows).
387 C-o : move to 'other' area, between pager and terminal.
388 C-l : clear terminal.
389 C-a : go to beginning of line.
390 C-e : go to end of line.
391 C-k : kill from cursor to the end of the line.
392 C-y : yank (paste)
393 C-p : previous line (like up arrow)
394 C-n : next line (like down arrow)
395 C-f : forward (like right arrow)
396 C-b : back (like left arrow)
397 C-d : delete next character.
398 M-d : delete next word.
399 M-Backspace : delete previous word.
400 C-. : forced restart of the kernel (a confirmation dialog appears).
401
402
403 The IPython pager
404 =================
405
406 IPython will show long blocks of text from many sources using a builtin pager.
407 You can control where this pager appears with the ``--paging`` command-line
408 flag:
409
410 - default: it is overlaid on top of the main terminal. You must quit the pager
411 to get back to the terminal (similar to how a kkk pager such as ``less``
412 works).
413
414 - vertical: the console is made double-tall, and the pager appears on the
415 bottom area when needed. You can view its contents while using the terminal.
416
417 - horizontal: the console is made double-wide, and the pager appears on the
418 right area when needed. You can view its contents while using the terminal.
419
420 If you use the vertical or horizontal paging modes, you can navigate between
421 terminal and pager as follows:
422
423 - Tab key: goes from pager to terminal (but not the other way around).
424 - Control-o: goes from one to another always.
425 - Mouse: click on either.
426
427 In all cases, the ``q`` or ``Escape`` keys quit the pager.
428
429
430 Running subprocesses
431 ====================
432
433 The graphical IPython console uses the ``pexpect`` module to run subprocesses
434 when you type ``!command``. This has a number of advantages (true asynchronous
435 output from subprocesses as well as very robust termination of rogue
436 subprocesses with Control-C), as well as some limitations. The main limitation
437 is that you can *not* interact back with the subprocess, so anything that
438 invokes a pager or expects you to type input into it will block and hang (you
439 can kill it with Control-C).
440
441 We have provided as magics ``%less`` (aliased to ``%more``), ``%clear`` to
442 clear the terminal, and ``%man`` on Linux/OSX to cover the most common commands
443 you'd want to call in your subshell, but you need to be aware of this
444 limitation.
445
446
447 Inline matplotlib graphics
448 ==========================
449
450 The IPython console is capable of displaying matplotlib figures inline, in SVG
451 format. If started with the ``--pylab inline`` flag, then all figures are
452 rendered inline automatically. If started with ``--pylab`` or ``--pylab
453 <your backend>``, then a GUI backend will be used, but the ``paste()`` function
454 is added to the global and ``plt`` namespaces. You can paste any figure that
455 is currently open in a window with this function; type ``paste?`` for
456 additional details."""
457
284 quick_guide = """\
458 quick_guide = """\
285 ? -> Introduction and overview of IPython's features.
459 ? -> Introduction and overview of IPython's features.
286 %quickref -> Quick reference.
460 %quickref -> Quick reference.
287 help -> Python's own help system.
461 help -> Python's own help system.
288 object? -> Details about 'object'. ?object also works, ?? prints more."""
462 object? -> Details about 'object', use 'object??' for extra details.
463 """
464
465 gui_note = """\
466 %guiref -> A brief reference about the graphical user interface.
467 """
289
468
290 default_banner_parts = [
469 default_banner_parts = [
291 'Python %s' % (sys.version.split('\n')[0],),
470 'Python %s\n' % (sys.version.split('\n')[0],),
292 'Type "copyright", "credits" or "license" for more information.\n',
471 'Type "copyright", "credits" or "license" for more information.\n\n',
293 'IPython %s -- An enhanced Interactive Python.' % (release.version,),
472 'IPython %s -- An enhanced Interactive Python.\n' % (release.version,),
294 quick_guide
473 quick_guide
295 ]
474 ]
296
475
297 default_banner = '\n'.join(default_banner_parts)
476 default_gui_banner_parts = default_banner_parts + [gui_note]
477
478 default_banner = ''.join(default_banner_parts)
479
480 default_gui_banner = ''.join(default_gui_banner_parts)
@@ -21,7 +21,7 b' from PyQt4 import QtCore, QtGui'
21 # Local imports
21 # Local imports
22 from IPython.core.inputsplitter import IPythonInputSplitter, \
22 from IPython.core.inputsplitter import IPythonInputSplitter, \
23 transform_ipy_prompt
23 transform_ipy_prompt
24 from IPython.core.usage import default_banner
24 from IPython.core.usage import default_gui_banner
25 from IPython.utils.traitlets import Bool, Str
25 from IPython.utils.traitlets import Bool, Str
26 from frontend_widget import FrontendWidget
26 from frontend_widget import FrontendWidget
27
27
@@ -248,7 +248,7 b' class IPythonWidget(FrontendWidget):'
248 def _get_banner(self):
248 def _get_banner(self):
249 """ Reimplemented to return IPython's default banner.
249 """ Reimplemented to return IPython's default banner.
250 """
250 """
251 return default_banner + '\n'
251 return default_gui_banner
252
252
253 def _process_execute_error(self, msg):
253 def _process_execute_error(self, msg):
254 """ Reimplemented for IPython-style traceback formatting.
254 """ Reimplemented for IPython-style traceback formatting.
@@ -164,11 +164,11 b' class TerminalInteractiveShell(InteractiveShell):'
164 self.write(banner)
164 self.write(banner)
165
165
166 def compute_banner(self):
166 def compute_banner(self):
167 self.banner = self.banner1 + '\n'
167 self.banner = self.banner1
168 if self.profile:
168 if self.profile:
169 self.banner += '\nIPython profile: %s\n' % self.profile
169 self.banner += '\nIPython profile: %s\n' % self.profile
170 if self.banner2:
170 if self.banner2:
171 self.banner += '\n' + self.banner2 + '\n'
171 self.banner += '\n' + self.banner2
172
172
173 def init_usage(self, usage=None):
173 def init_usage(self, usage=None):
174 if usage is None:
174 if usage is None:
@@ -532,4 +532,14 b' class ZMQInteractiveShell(InteractiveShell):'
532 """Find the man page for the given command and display in pager."""
532 """Find the man page for the given command and display in pager."""
533 page.page(self.shell.getoutput('man %s' % arg_s, split=False))
533 page.page(self.shell.getoutput('man %s' % arg_s, split=False))
534
534
535 # FIXME: this is specific to the GUI, so we should let the gui app load
536 # magics at startup that are only for the gui. Once the gui app has proper
537 # profile and configuration management, we can have it initialize a kernel
538 # with a special config file that provides these.
539 def magic_guiref(self, arg_s):
540 """Show a basic reference about the GUI console."""
541 from IPython.core.usage import gui_reference
542 page.page(gui_reference)
543
544
535 InteractiveShellABC.register(ZMQInteractiveShell)
545 InteractiveShellABC.register(ZMQInteractiveShell)
General Comments 0
You need to be logged in to leave comments. Login now