summary refs log tree commit diff stats
path: root/test
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-02-18 21:58:37 +0100
committerhut <hut@lavabit.com>2010-03-09 14:40:22 +0100
commitea3b13663ea3bbf42cd3472750ee7e00e9093ca4 (patch)
tree6dfc99b936a28d6e47c473c9a100cb97fb003c6e /test
parent13ecffe7ffa5c80cd69d55419f230c97d06ab23e (diff)
downloadranger-ea3b13663ea3bbf42cd3472750ee7e00e9093ca4.tar.gz
keyparser: allow passive actions (for hints, show bookmarks)
Diffstat (limited to 'test')
-rw-r--r--test/tc_newkeys.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/tc_newkeys.py b/test/tc_newkeys.py
index 0922029e..697bfdcb 100644
--- a/test/tc_newkeys.py
+++ b/test/tc_newkeys.py
@@ -38,6 +38,36 @@ class PressTestCase(TestCase):
 
 class Test(PressTestCase):
 	"""The test cases"""
+	def test_passive_action(self):
+		km = KeyMap()
+		directions = KeyMap()
+		kb = KeyBuffer(km, directions)
+		def n(value):
+			"""return n or value"""
+			def fnc(arg=None):
+				if arg is None or arg.n is None:
+					return value
+				return arg.n
+			return fnc
+
+		km.add(n(5), 'ppp')
+		km.add(n(8), 'pp<psv>')
+		km.add(n(2), 'pp<dir>')
+		directions.add('j', dir=Direction(down=1))
+
+		press = self._mkpress(kb, km)
+		self.assertEqual(5, press('ppp'))
+		self.assertEqual(3, press('3ppp'))
+
+		self.assertEqual(2, press('ppj'))
+
+		kb.clear()
+		match = kb.simulate_press('pp')
+		args = CommandArgs(0, 0, kb)
+		self.assert_(match)
+		self.assert_(match.function)
+		self.assertEqual(8, match.function(args))
+
 	def test_translate_keys(self):
 		def test(string, *args):
 			if not args:
on.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
#!/usr/bin/python
"""Generate pydoc documentation and move it to the doc directory.
THIS WILL DELETE ALL EXISTING HTML FILES IN THAT DIRECTORY, so don't
store important content there."""

import pydoc, os, sys
if __name__ == '__main__':
	docdir = 'doc/pydoc'
	os.chdir(sys.path[0])
	try: os.mkdir(docdir)
	except: pass


	for fname in os.listdir(docdir):
		if fname.endswith('.html'):
			os.remove(os.path.join(docdir, fname))

	pydoc.writedocs('.')
	pydoc.writedoc('curses')
	pydoc.writedoc('curses.ascii')
	pydoc.writedoc('os')
	pydoc.writedoc('os.path')
	pydoc.writedoc('sys')

	for fname in os.listdir('.'):
		if fname.endswith('.html'):
			os.rename(fname, os.path.join(docdir, fname))