##// 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:

r11970:f7cdf1ff
r15754:d60e793e
Show More
test_kill_ring.py
87 lines | 2.3 KiB | text/x-python | PythonLexer
epatters
Add Emacs-style kill ring to Qt console....
r3767 # Standard library imports
import unittest
# System library imports
Thomas Kluyver
Remove unused imports in IPython.qt
r11131 from IPython.external.qt import QtGui
epatters
Add Emacs-style kill ring to Qt console....
r3767
# Local imports
Fernando Perez
Fix all remaining imports that used `IPython.frontend`.
r11024 from IPython.qt.console.kill_ring import KillRing, QtKillRing
Paul Ivanov
skip tests when display variable is not set
r11970 import IPython.testing.decorators as dec
epatters
Add Emacs-style kill ring to Qt console....
r3767
Paul Ivanov
skip tests when display variable is not set
r11970 setup = dec.skip_file_no_x11(__name__)
epatters
Add Emacs-style kill ring to Qt console....
r3767
class TestKillRing(unittest.TestCase):
@classmethod
def setUpClass(cls):
""" Create the application for the test case.
"""
Puneeth Chaganti
TST: QApplication doesn't quit early enough with PySide....
r6574 cls._app = QtGui.QApplication.instance()
if cls._app is None:
cls._app = QtGui.QApplication([])
epatters
Add Emacs-style kill ring to Qt console....
r3767 cls._app.setQuitOnLastWindowClosed(False)
@classmethod
def tearDownClass(cls):
""" Exit the application.
"""
QtGui.QApplication.quit()
def test_generic(self):
""" Does the generic kill ring work?
"""
ring = KillRing()
Bradley M. Froehle
s/assert_/assertTrue/
r7876 self.assertTrue(ring.yank() is None)
self.assertTrue(ring.rotate() is None)
epatters
Add Emacs-style kill ring to Qt console....
r3767
ring.kill('foo')
self.assertEqual(ring.yank(), 'foo')
Bradley M. Froehle
s/assert_/assertTrue/
r7876 self.assertTrue(ring.rotate() is None)
epatters
Add Emacs-style kill ring to Qt console....
r3767 self.assertEqual(ring.yank(), 'foo')
ring.kill('bar')
self.assertEqual(ring.yank(), 'bar')
self.assertEqual(ring.rotate(), 'foo')
ring.clear()
Bradley M. Froehle
s/assert_/assertTrue/
r7876 self.assertTrue(ring.yank() is None)
self.assertTrue(ring.rotate() is None)
epatters
Add Emacs-style kill ring to Qt console....
r3767
def test_qt_basic(self):
""" Does the Qt kill ring work?
"""
text_edit = QtGui.QPlainTextEdit()
ring = QtKillRing(text_edit)
ring.kill('foo')
ring.kill('bar')
ring.yank()
ring.rotate()
ring.yank()
self.assertEqual(text_edit.toPlainText(), 'foobar')
text_edit.clear()
ring.kill('baz')
ring.yank()
ring.rotate()
ring.rotate()
ring.rotate()
self.assertEqual(text_edit.toPlainText(), 'foo')
def test_qt_cursor(self):
""" Does the Qt kill ring maintain state with cursor movement?
"""
text_edit = QtGui.QPlainTextEdit()
ring = QtKillRing(text_edit)
ring.kill('foo')
ring.kill('bar')
ring.yank()
text_edit.moveCursor(QtGui.QTextCursor.Left)
ring.rotate()
self.assertEqual(text_edit.toPlainText(), 'bar')
if __name__ == '__main__':
import nose
nose.main()