##// END OF EJS Templates
refactor to improve cell switching in edit mode...
refactor to improve cell switching in edit mode This code was repeated in both CodeCell and TextCell, both of which are extensions of Cell, so this just unifies the logic in Cell. TextCell had logic here to check if the cell was rendered or not, but I don't believe it is possible to end up triggering such a code path. (Should that be required, I can always just add back these methods to TextCell, performing the .rendered==True check, and calling the Cell prior to this, code mirror at_top would only return true on if the cursor was at the first character of the top line. Now, pressing up arrow on any character on the top line will take you to the cell above. The same applies for the bottom line. Pressing down arrow would only go to the next cell if the cursor was at a location *after* the last character (something that is only possible to achieve in vim mode if the last line is empty, for example). Now, down arrow on any character of the last line will go to the next cell.

File last commit:

r8223:ea09ed9f
r15754:d60e793e
Show More
warn.py
67 lines | 1.9 KiB | text/x-python | PythonLexer
Brian Granger
Work to address the review comments on Fernando's branch....
r2498 # encoding: utf-8
"""
Utilities for warnings. Shoudn't we just use the built in warnings module.
"""
#-----------------------------------------------------------------------------
Matthias BUSSONNIER
update copyright to 2011/20xx-2011...
r5390 # Copyright (C) 2008-2011 The IPython Development Team
Brian Granger
Work to address the review comments on Fernando's branch....
r2498 #
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
Matthias BUSSONNIER
use print function in module with `print >>`
r7817 from __future__ import print_function
Brian Granger
Work to address the review comments on Fernando's branch....
r2498
import sys
MinRK
io.Term.cin/out/err replaced by io.stdin/out/err...
r3800 from IPython.utils import io
Brian Granger
Work to address the review comments on Fernando's branch....
r2498
#-----------------------------------------------------------------------------
# Code
#-----------------------------------------------------------------------------
def warn(msg,level=2,exit_val=1):
"""Standard warning printer. Gives formatting consistency.
MinRK
io.Term.cin/out/err replaced by io.stdin/out/err...
r3800 Output is sent to io.stderr (sys.stderr by default).
Brian Granger
Work to address the review comments on Fernando's branch....
r2498
Options:
-level(2): allows finer control:
0 -> Do nothing, dummy function.
1 -> Print message.
2 -> Print 'WARNING:' + message. (Default level).
3 -> Print 'ERROR:' + message.
4 -> Print 'FATAL ERROR:' + message and trigger a sys.exit(exit_val).
-exit_val (1): exit value returned by sys.exit() for a level 4
warning. Ignored for all other levels."""
if level>0:
header = ['','','WARNING: ','ERROR: ','FATAL ERROR: ']
Thomas Kluyver
Fix IPython.utils.warn API so messages are automatically displayed followed by a newline.
r8223 print(header[level], msg, sep='', file=io.stderr)
Brian Granger
Work to address the review comments on Fernando's branch....
r2498 if level == 4:
Matthias BUSSONNIER
use print function in module with `print >>`
r7817 print('Exiting.\n', file=io.stderr)
Brian Granger
Work to address the review comments on Fernando's branch....
r2498 sys.exit(exit_val)
def info(msg):
"""Equivalent to warn(msg,level=1)."""
warn(msg,level=1)
def error(msg):
"""Equivalent to warn(msg,level=3)."""
warn(msg,level=3)
def fatal(msg,exit_val=1):
"""Equivalent to warn(msg,exit_val=exit_val,level=4)."""
warn(msg,exit_val=exit_val,level=4)