1#! /usr/bin/python3
2
3import pexpect
4import unittest
5import re
6import os
7import subprocess
8import signal
9import time
10
11keytab = {
12	"<home>": "\033[1~",
13	"<s-home>": "\033[1;2H",
14	"<c-home>": "\033[1;5H",
15	"<end>": "\033[4~",
16	"<s-end>": "\033[1;2F",
17	"<c-end>": "\033[1;5F",
18	"<ins>": "\033[2~",
19	"<s-ins>": "\033[2;2~",
20	"<c-ins>": "\033[2;5~",
21	"<del>": "\033[3~",
22	"<s-del>": "\033[3;2~",
23	"<c-del>": "\033[3;5~",
24	"<pgup>": "\033[5~",
25	"<c-pgup>": "\033[5;5~",
26	"<pgdown>": "\033[6~",
27	"<c-pgdown>": "\033[6;5~",
28	"<backspace>": "",
29	"<tab>": "\t",
30	"<cr>": "\r",
31	"<lf>": "\n",
32	"<left>": "\033[D",
33	"<s-left>": "\033[1;2D",
34	"<aleft>": "\033OD",
35	"<right>": "\033[C",
36	"<s-right>": "\033[1;2C",
37	"<aright>": "\033OC",
38	"<up>": "\033[A",
39	"<s-up>": "\033[1;2A",
40	"<aup>": "\033OA",
41	"<down>": "\033[B",
42	"<s-down>": "\033[1;2B",
43	"<adown>": "\033OB",
44	"<c-left>": "\033[1;5D",
45	"<c-right>": "\033[1;5C",
46	"<c-up>": "\033[1;5A",
47	"<c-down>": "\033[1;5B",
48	"<m-left>": "\033[1;3D",
49	"<m-right>": "\033[1;3C",
50	"<m-up>": "\033[1;3A",
51	"<m-down>": "\033[1;3B",
52	"<c-a>": "",
53	"<c-b>": "",
54	"<c-c>": "",
55	"<c-d>": "",
56	"<c-e>": "",
57	"<c-f>": "",
58	"<c-k>": "",
59	"<c-l>": "",
60	"<c-n>": "",
61	"<c-p>": "",
62	"<c-r>": "",
63	"<c-s>": "",
64	"<c-t>": "",
65	"<c-u>": "",
66	"<c-v>": "",
67	"<c-w>": "",
68	"<c-y>": "",
69	"<c-z>": "",
70	"<m-b>": "\033b",
71	"<m-c>": "\033c",
72	"<m-d>": "\033d",
73	"<m-f>": "\033f",
74	"<m-l>": "\033l",
75	"<m-n>": "\033n",
76	"<m-p>": "\033p",
77	"<m-u>": "\033u",
78	"<m-y>": "\033y",
79	"<m-.>": "\033.",
80	"<m-backspace>": "\033\177",
81	"<f1>": "\033OP",
82	"<f2>": "\033OQ",
83	"<f3>": "\033OR",
84	"<f4>": "\033OS",
85	"<f5>": "\033[15~",
86	"<f6>": "\033[17~",
87	"<f7>": "\033[18~",
88	"<f8>": "\033[19~",
89	"<f9>": "\033[20~",
90	"<f10>": "\033[21~",
91	"<f11>": "\033[23~",
92	"<f12>": "\033[24~",
93	"<s-f1>": "\033[1;2P",
94	"<s-f2>": "\033[1;2Q",
95	"<s-f3>": "\033[1;2R",
96	"<s-f4>": "\033[1;2S",
97	"<s-f5>": "\033[15;2~",
98	"<s-f6>": "\033[17;2~",
99	"<s-f7>": "\033[18;2~",
100	"<s-f8>": "\033[19;2~",
101	"<s-f9>": "\033[20;2~",
102	"<s-f10>": "\033[21;2~",
103	"<s-f11>": "\033[23;2~",
104	"<s-f12>": "\033[24;2~",
105	"<c-f1>": "\033[1;5P",
106	"<c-f2>": "\033[1;5Q",
107	"<c-f3>": "\033[1;5R",
108	"<c-f4>": "\033[1;5S",
109	"<c-f5>": "\033[15;5~",
110	"<c-f6>": "\033[17;5~",
111	"<c-f7>": "\033[18;5~",
112	"<c-f8>": "\033[19;5~",
113	"<c-f9>": "\033[20;5~",
114	"<c-f10>": "\033[21;5~",
115	"<c-f11>": "\033[23;5~",
116	"<c-f12>": "\033[24;5~",
117	"<s-tab>": "\033[Z",
118	"<paste-pfx>": "\033[200~",
119	"<paste-sfx>": "\033[201~"
120}
121
122termseq = {
123	"\x1bc": "<RIS>",
124	"\x1b[0m": "<rst>",
125	"\x1b[H": "<mvhm>",
126	"\x1b[2J": "<clr>",
127	"\x1b[J": "<ceos>",
128	"\x1b[0;22;30m": "<black>",
129	"\x1b[0;22;31m": "<red>",
130	"\x1b[0;22;32m": "<green>",
131	"\x1b[0;22;33m": "<brown>",
132	"\x1b[0;22;34m": "<blue>",
133	"\x1b[0;22;35m": "<magenta>",
134	"\x1b[0;22;36m": "<cyan>",
135	"\x1b[0;22;37m": "<lightgray>",
136	"\x1b[0;1;30m": "<gray>",
137	"\x1b[0;1;31m": "<brightred>",
138	"\x1b[0;1;32m": "<brightgreen>",
139	"\x1b[0;1;33m": "<yellow>",
140	"\x1b[0;1;34m": "<brightblue>",
141	"\x1b[0;1;35m": "<brightmagenta>",
142	"\x1b[0;1;36m": "<brightcyan>",
143	"\x1b[0;1;37m": "<white>",
144	"\x1b[1;32m": "<brightgreen>",
145	"\x1b[101;1;33m": "<err>",
146	"\x07": "<bell>",
147	"\x1b[2~": "<ins-key>",
148	"\x1b[?2004h": "<paste-on>",
149	"\x1b[?2004l": "<paste-off>"
150}
151colRe = re.compile( "\\x1b\\[(\\d+)G" )
152upRe = re.compile( "\\x1b\\[(\\d+)A" )
153downRe = re.compile( "\\x1b\\[(\\d+)B" )
154
155def sym_to_raw( str_ ):
156	for sym, seq in keytab.items():
157		if isinstance( str_, Rapid ):
158			str_ = Rapid( str_.replace( sym, seq ) )
159		else:
160			str_ = str_.replace( sym, seq )
161	return str_
162
163def seq_to_sym( str_ ):
164	for seq, sym in termseq.items():
165		str_ = str_.replace( seq, sym )
166	str_ = colRe.sub( "<c\\1>", str_ )
167	str_ = upRe.sub( "<u\\1>", str_ )
168	str_ = downRe.sub( "<d\\1>", str_ )
169	return str_
170
171_words_ = [
172	"ada", "algol"
173	"bash", "basic",
174	"clojure", "cobol", "csharp",
175	"eiffel", "erlang",
176	"forth", "fortran", "fsharp",
177	"go", "groovy",
178	"haskell", "huginn",
179	"java", "javascript", "julia",
180	"kotlin",
181	"lisp", "lua",
182	"modula",
183	"nemerle",
184	"ocaml",
185	"perl", "php", "prolog", "python",
186	"rebol", "ruby", "rust",
187	"scala", "scheme", "sql", "swift",
188	"typescript"
189]
190
191def skip( test_ ):
192	return "SKIP" in os.environ and os.environ["SKIP"].find( test_ ) >= 0
193
194verbosity = None
195
196class Rapid( str ): pass
197
198def rapid( item ):
199	if isinstance( item, str ):
200		r = Rapid( item )
201		return r
202	return list( map( Rapid, item ) )
203
204class ReplxxTests( unittest.TestCase ):
205	_prompt_ = "\033\\[1;32mreplxx\033\\[0m> "
206	_cxxSample_ = "./build/debug/replxx-example-cxx-api"
207	_cSample_ = "./build/debug/replxx-example-c-api"
208	_end_ = "\r\nExiting Replxx\r\n"
209	def send_str( self_, str_, intraKeyDelay_ ):
210		if isinstance(str_, Rapid):
211			self_._replxx.send( str_ )
212			return
213		for char in str_:
214			self_._replxx.send( char )
215			time.sleep( intraKeyDelay_ )
216
217	def check_scenario(
218		self_, seq_, expected_,
219		history = "one\ntwo\nthree\n",
220		term = "xterm",
221		command = _cxxSample_,
222		dimensions = ( 25, 80 ),
223		prompt = _prompt_,
224		end = _prompt_ + _end_,
225		encoding = "utf-8",
226		pause = 0.25,
227		intraKeyDelay = 0.002
228	):
229		with open( "replxx_history.txt", "wb" ) as f:
230			f.write( history.encode( encoding ) )
231			f.close()
232		os.environ["TERM"] = term
233		if isinstance( command, str ):
234			command = command.replace( "\n", "~" )
235		if verbosity >= 2:
236			print( "\nTERM: {}, SIZE: {}, CMD: {}".format( term, dimensions, command ) )
237		prompt = prompt.replace( "\n", "\r\n" ).replace( "\r\r", "\r" )
238		end = end.replace( "\n", "\r\n" ).replace( "\r\r", "\r" )
239		if isinstance( command, str ):
240			self_._replxx = pexpect.spawn( command, maxread = 1, encoding = encoding, dimensions = dimensions )
241		else:
242			self_._replxx = pexpect.spawn( command[0], args = command[1:], maxread = 1, encoding = encoding, dimensions = dimensions )
243		self_._replxx.expect( prompt )
244		self_.maxDiff = None
245		if isinstance( seq_, str ):
246			if isinstance( seq_, Rapid ):
247				seqs = rapid( seq_.split( "<c-z>" ) )
248			else:
249				seqs = seq_.split( "<c-z>" )
250			for seq in seqs:
251				last = seq is seqs[-1]
252				if not last:
253					seq += "<c-z>"
254				self_.send_str( sym_to_raw( seq ), intraKeyDelay )
255				if not last:
256					time.sleep( pause )
257					self_._replxx.kill( signal.SIGCONT )
258		else:
259			for seq in seq_:
260				last = seq is seq_[-1]
261				self_.send_str( sym_to_raw( seq ), intraKeyDelay )
262				if not last:
263					time.sleep( pause )
264		self_._replxx.expect( end )
265		if isinstance( expected_, str ):
266			self_.assertSequenceEqual( seq_to_sym( self_._replxx.before ), expected_ )
267		else:
268			try:
269				self_.assertIn( seq_to_sym( self_._replxx.before ), expected_ )
270			except:
271				self_.assertSequenceEqual( seq_to_sym( self_._replxx.before ), "" )
272	def test_unicode( self_ ):
273		self_.check_scenario(
274			"<up><cr><c-d>",
275			"<c9>aóą Ϩ ��  ��  <rst><ceos><c21>"
276			"<c9>aóą Ϩ ��  ��  <rst><ceos><c21>\r\n"
277			"aóą Ϩ ��  ��  \r\n",
278			"aóą Ϩ ��  ��  \n"
279		)
280		self_.check_scenario(
281			"aóą Ϩ ��  ��  <cr><c-d>",
282			"<c9>a<rst><ceos><c10><c9>aó<rst><ceos><c11><c9>aóą<rst><ceos><c12><c9>aóą "
283			"<rst><ceos><c13><c9>aóą Ϩ<rst><ceos><c14><c9>aóą Ϩ "
284			"<rst><ceos><c15><c9>aóą Ϩ ��<rst><ceos><c16><c9>aóą Ϩ �� "
285			"<rst><ceos><c17><c9>aóą Ϩ ��  "
286			"<rst><ceos><c18><c9>aóą Ϩ ��  ��<rst><ceos><c19><c9>aóą Ϩ ��  �� "
287			"<rst><ceos><c20><c9>aóą Ϩ ��  ��  "
288			"<rst><ceos><c21><c9>aóą Ϩ ��  ��  <rst><ceos><c21>\r\n"
289			"aóą Ϩ ��  ��  \r\n"
290		)
291	@unittest.skipIf( skip( "8bit_encoding" ), "broken platform" )
292	def test_8bit_encoding( self_ ):
293		LC_CTYPE = "LC_CTYPE"
294		exists = LC_CTYPE in os.environ
295		lcCtype = None
296		if exists:
297			lcCtype = os.environ[LC_CTYPE]
298		os.environ[LC_CTYPE] = "pl_PL.ISO-8859-2"
299		self_.check_scenario(
300			"<aup><cr><c-d>",
301			"<c9>text ~ó~<rst><ceos><c17><c9>text ~ó~<rst><ceos><c17>\r\ntext ~ó~\r\n",
302			"text ~ó~\n",
303			encoding = "iso-8859-2"
304		)
305		if exists:
306			os.environ[LC_CTYPE] = lcCtype
307		else:
308			del os.environ[LC_CTYPE]
309	def test_bad_term( self_ ):
310		self_.check_scenario(
311			"a line of text<cr><c-d>",
312			"a line of text\r\na line of text\r\n",
313			term = "dumb"
314		)
315	def test_ctrl_c( self_ ):
316		self_.check_scenario(
317			"abc<c-c><c-d>",
318			"<c9>a<rst><ceos><c10><c9>ab<rst><ceos><c11><c9>abc<rst><ceos><c12><c9>abc<rst><ceos><c12>^C\r"
319			"\r\n"
320		)
321	def test_ctrl_z( self_ ):
322		self_.check_scenario(
323			"<up><c-z><cr><c-d>",
324			"<c9>three<rst><ceos><c14><brightgreen>replxx<rst>> "
325			"<c9>three<rst><ceos><c14><c9>three<rst><ceos><c14>\r\n"
326			"three\r\n"
327		)
328		self_.check_scenario(
329			"<c-r>w<c-z><cr><c-d>",
330			"<c1><ceos><c1><ceos>(reverse-i-search)`': "
331			"<c23><c1><ceos>(reverse-i-search)`w': "
332			"two<c25><c1><ceos>(reverse-i-search)`w': "
333			"two<c25><c1><ceos><brightgreen>replxx<rst>> "
334			"two<c10><c9><ceos><c12>\r\n"
335			"two\r\n"
336		)
337	def test_ctrl_l( self_ ):
338		self_.check_scenario(
339			"<cr><cr><cr><c-l><c-d>",
340			"<c9><ceos><c9>\r\n"
341			"<brightgreen>replxx<rst>> <c9><ceos><c9>\r\n"
342			"<brightgreen>replxx<rst>> <c9><ceos><c9>\r\n"
343			"<brightgreen>replxx<rst>> <RIS><mvhm><clr><rst><brightgreen>replxx<rst>> "
344			"<c9><rst><ceos><c9>",
345			end = "\r\nExiting Replxx\r\n"
346		)
347		self_.check_scenario(
348			"<cr><up><c-left><c-l><cr><c-d>",
349			"<c9><ceos><c9>\r\n"
350			"<brightgreen>replxx<rst>> <c9>first "
351			"second<rst><ceos><c21><c9>first "
352			"second<rst><ceos><c15><RIS><mvhm><clr><rst><brightgreen>replxx<rst>> "
353			"<c9>first second<rst><ceos><c15><c9>first second<rst><ceos><c21>\r\n"
354			"first second\r\n",
355			"first second\n"
356		)
357	def test_backspace( self_ ):
358		self_.check_scenario(
359			"<up><c-a><m-f><c-right><backspace><backspace><backspace><backspace><cr><c-d>",
360			"<c9>one two three<rst><ceos><c22><c9>one two "
361			"three<rst><ceos><c9><c9>one two three<rst><ceos><c12><c9>one two "
362			"three<rst><ceos><c16><c9>one tw three<rst><ceos><c15><c9>one t "
363			"three<rst><ceos><c14><c9>one  three<rst><ceos><c13><c9>one "
364			"three<rst><ceos><c12><c9>one three<rst><ceos><c18>\r\n"
365			"one three\r\n",
366			"one two three\n"
367		)
368	def test_delete( self_ ):
369		self_.check_scenario(
370			"<up><m-b><c-left><del><c-d><del><c-d><cr><c-d>",
371			"<c9>one two three<rst><ceos><c22><c9>one two "
372			"three<rst><ceos><c17><c9>one two three<rst><ceos><c13><c9>one wo "
373			"three<rst><ceos><c13><c9>one o three<rst><ceos><c13><c9>one  "
374			"three<rst><ceos><c13><c9>one three<rst><ceos><c13><c9>one three<rst><ceos><c18>\r\n"
375			"one three\r\n",
376			"one two three\n"
377		)
378	def test_home_key( self_ ):
379		self_.check_scenario(
380			"abc<home>z<cr><c-d>",
381			"<c9>a<rst><ceos><c10><c9>ab<rst><ceos><c11><c9>abc<rst><ceos><c12><c9>abc<rst><ceos><c9><c9>zabc<rst><ceos><c10><c9>zabc<rst><ceos><c13>\r\n"
382			"zabc\r\n"
383		)
384	def test_end_key( self_ ):
385		self_.check_scenario(
386			"abc<home>z<end>q<cr><c-d>",
387			"<c9>a<rst><ceos><c10><c9>ab<rst><ceos><c11><c9>abc<rst><ceos><c12><c9>abc<rst><ceos><c9><c9>zabc<rst><ceos><c10><c9>zabc<rst><ceos><c13><c9>zabcq<rst><ceos><c14><c9>zabcq<rst><ceos><c14>\r\n"
388			"zabcq\r\n"
389		)
390	def test_left_key( self_ ):
391		self_.check_scenario(
392			"abc<left>x<aleft><left>y<cr><c-d>",
393			"<c9>a<rst><ceos><c10><c9>ab<rst><ceos><c11><c9>abc<rst><ceos><c12><c9>abc<rst><ceos><c11><c9>abxc<rst><ceos><c12><c9>abxc<rst><ceos><c11><c9>abxc<rst><ceos><c10><c9>aybxc<rst><ceos><c11><c9>aybxc<rst><ceos><c14>\r\n"
394			"aybxc\r\n"
395		)
396	def test_right_key( self_ ):
397		self_.check_scenario(
398			"abc<home><right>x<aright>y<cr><c-d>",
399			"<c9>a<rst><ceos><c10><c9>ab<rst><ceos><c11><c9>abc<rst><ceos><c12><c9>abc<rst><ceos><c9><c9>abc<rst><ceos><c10><c9>axbc<rst><ceos><c11><c9>axbc<rst><ceos><c12><c9>axbyc<rst><ceos><c13><c9>axbyc<rst><ceos><c14>\r\n"
400			"axbyc\r\n"
401		)
402	def test_prev_word_key( self_ ):
403		self_.check_scenario(
404			"abc def ghi<c-left><m-left>x<cr><c-d>",
405			"<c9>a<rst><ceos><c10><c9>ab<rst><ceos><c11><c9>abc<rst><ceos><c12><c9>abc "
406			"<rst><ceos><c13><c9>abc d<rst><ceos><c14><c9>abc "
407			"de<rst><ceos><c15><c9>abc def<rst><ceos><c16><c9>abc "
408			"def <rst><ceos><c17><c9>abc def "
409			"g<rst><ceos><c18><c9>abc def gh<rst><ceos><c19><c9>abc "
410			"def ghi<rst><ceos><c20><c9>abc def ghi<rst><ceos><c17><c9>abc def "
411			"ghi<rst><ceos><c13><c9>abc xdef ghi<rst><ceos><c14><c9>abc xdef "
412			"ghi<rst><ceos><c21>\r\n"
413			"abc xdef ghi\r\n"
414		)
415	def test_next_word_key( self_ ):
416		self_.check_scenario(
417			"abc def ghi<home><c-right><m-right>x<cr><c-d>",
418			"<c9>a<rst><ceos><c10><c9>ab<rst><ceos><c11><c9>abc<rst><ceos><c12><c9>abc "
419			"<rst><ceos><c13><c9>abc d<rst><ceos><c14><c9>abc "
420			"de<rst><ceos><c15><c9>abc def<rst><ceos><c16><c9>abc "
421			"def <rst><ceos><c17><c9>abc def "
422			"g<rst><ceos><c18><c9>abc def gh<rst><ceos><c19><c9>abc "
423			"def ghi<rst><ceos><c20><c9>abc def ghi<rst><ceos><c9><c9>abc def "
424			"ghi<rst><ceos><c12><c9>abc def ghi<rst><ceos><c16><c9>abc defx "
425			"ghi<rst><ceos><c17><c9>abc defx ghi<rst><ceos><c21>\r\n"
426			"abc defx ghi\r\n"
427		)
428	def test_hint_show( self_ ):
429		self_.check_scenario(
430			"co\r<c-d>",
431			"<c9>c<rst><ceos><c10><c9>co<rst><ceos>\r\n"
432			"        <gray>color_black<rst>\r\n"
433			"        <gray>color_red<rst>\r\n"
434			"        <gray>color_green<rst><u3><c11><c9>co<rst><ceos><c11>\r\n"
435			"co\r\n"
436		)
437		self_.check_scenario(
438			"<up><cr><c-d>",
439			"<c9>zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz "
440			"<brightgreen>color_brightgreen<rst><ceos><c15><u3><c9>zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz "
441			"<brightgreen>color_brightgreen<rst><ceos><c15>\r\n"
442			"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz color_brightgreen\r\n",
443			"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz color_brightgreen\n",
444			dimensions = ( 64, 16 )
445		)
446	def test_hint_scroll_down( self_ ):
447		self_.check_scenario(
448			"co<c-down><c-down><tab><cr><c-d>",
449			"<c9>c<rst><ceos><c10><c9>co<rst><ceos>\r\n"
450			"        <gray>color_black<rst>\r\n"
451			"        <gray>color_red<rst>\r\n"
452			"        "
453			"<gray>color_green<rst><u3><c11><c9>co<rst><ceos><gray>lor_black<rst>\r\n"
454			"        <gray>color_red<rst>\r\n"
455			"        <gray>color_green<rst>\r\n"
456			"        "
457			"<gray>color_brown<rst><u3><c11><c9>co<rst><ceos><gray>lor_red<rst>\r\n"
458			"        <gray>color_green<rst>\r\n"
459			"        <gray>color_brown<rst>\r\n"
460			"        "
461			"<gray>color_blue<rst><u3><c11><c9><red>color_red<rst><ceos><c18><c9><red>color_red<rst><ceos><c18>\r\n"
462			"color_red\r\n"
463		)
464	def test_hint_scroll_up( self_ ):
465		self_.check_scenario(
466			"co<c-up><c-up><tab><cr><c-d>",
467			"<c9>c<rst><ceos><c10><c9>co<rst><ceos>\r\n"
468			"        <gray>color_black<rst>\r\n"
469			"        <gray>color_red<rst>\r\n"
470			"        "
471			"<gray>color_green<rst><u3><c11><c9>co<rst><ceos><gray>lor_normal<rst>\r\n"
472			"        <gray>co\r\n"
473			"        <gray>color_black<rst>\r\n"
474			"        "
475			"<gray>color_red<rst><u3><c11><c9>co<rst><ceos><gray>lor_white<rst>\r\n"
476			"        <gray>color_normal<rst>\r\n"
477			"        <gray>co\r\n"
478			"        "
479			"<gray>color_black<rst><u3><c11><c9><white>color_white<rst><ceos><c20><c9><white>color_white<rst><ceos><c20>\r\n"
480			"color_white\r\n"
481		)
482	def test_history( self_ ):
483		self_.check_scenario(
484			"<up><up><up><up><down><down><down><down>four<cr><c-d>",
485			"<c9>three<rst><ceos><c14><c9>two<rst><ceos><c12><c9>one<rst><ceos><c12><c9>two<rst><ceos><c12><c9>three<rst><ceos><c14><c9><rst><ceos><c9><c9>f<rst><ceos><c10><c9>fo<rst><ceos><c11><c9>fou<rst><ceos><c12><c9>four<rst><ceos><c13><c9>four<rst><ceos><c13>\r\n"
486			"four\r\n"
487		)
488		with open( "replxx_history.txt", "rb" ) as f:
489			data = f.read().decode()
490			self_.assertSequenceEqual( data[:-33], "### 0000-00-00 00:00:00.000\none\n### 0000-00-00 00:00:00.000\ntwo\n### 0000-00-00 00:00:00.000\nthree\n" )
491			self_.assertSequenceEqual( data[-5:], "four\n" )
492	def test_paren_matching( self_ ):
493		self_.check_scenario(
494			"ab(cd)ef<left><left><left><left><left><left><left><cr><c-d>",
495			"<c9>a<rst><ceos><c10><c9>ab<rst><ceos><c11><c9>ab<brightmagenta>(<rst><ceos><c12><c9>ab<brightmagenta>(<rst>c<rst><ceos><c13><c9>ab<brightmagenta>(<rst>cd<rst><ceos><c14><c9>ab<brightmagenta>(<rst>cd<brightmagenta>)<rst><ceos><c15><c9>ab<brightmagenta>(<rst>cd<brightmagenta>)<rst>e<rst><ceos><c16><c9>ab<brightmagenta>(<rst>cd<brightmagenta>)<rst>ef<rst><ceos><c17><c9>ab<brightmagenta>(<rst>cd<brightmagenta>)<rst>ef<rst><ceos><c16><c9>ab<brightmagenta>(<rst>cd<brightmagenta>)<rst>ef<rst><ceos><c15><c9>ab<brightred>(<rst>cd<brightmagenta>)<rst>ef<rst><ceos><c14><c9>ab<brightmagenta>(<rst>cd<brightmagenta>)<rst>ef<rst><ceos><c13><c9>ab<brightmagenta>(<rst>cd<brightmagenta>)<rst>ef<rst><ceos><c12><c9>ab<brightmagenta>(<rst>cd<brightred>)<rst>ef<rst><ceos><c11><c9>ab<brightmagenta>(<rst>cd<brightmagenta>)<rst>ef<rst><ceos><c10><c9>ab<brightmagenta>(<rst>cd<brightmagenta>)<rst>ef<rst><ceos><c17>\r\n"
496			"ab(cd)ef\r\n"
497		)
498	def test_paren_not_matched( self_ ):
499		self_.check_scenario(
500			"a(b[c)d<left><left><left><left><left><left><left><cr><c-d>",
501			"<c9>a<rst><ceos><c10><c9>a<brightmagenta>(<rst><ceos><c11><c9>a<brightmagenta>(<rst>b<rst><ceos><c12><c9>a<brightmagenta>(<rst>b<brightmagenta>[<rst><ceos><c13><c9>a<brightmagenta>(<rst>b<brightmagenta>[<rst>c<rst><ceos><c14><c9>a<brightmagenta>(<rst>b<brightmagenta>[<rst>c<brightmagenta>)<rst><ceos><c15><c9>a<brightmagenta>(<rst>b<brightmagenta>[<rst>c<brightmagenta>)<rst>d<rst><ceos><c16><c9>a<brightmagenta>(<rst>b<brightmagenta>[<rst>c<brightmagenta>)<rst>d<rst><ceos><c15><c9>a<err>(<rst>b<brightmagenta>[<rst>c<brightmagenta>)<rst>d<rst><ceos><c14><c9>a<brightmagenta>(<rst>b<brightmagenta>[<rst>c<brightmagenta>)<rst>d<rst><ceos><c13><c9>a<brightmagenta>(<rst>b<brightmagenta>[<rst>c<brightmagenta>)<rst>d<rst><ceos><c12><c9>a<brightmagenta>(<rst>b<brightmagenta>[<rst>c<brightmagenta>)<rst>d<rst><ceos><c11><c9>a<brightmagenta>(<rst>b<brightmagenta>[<rst>c<err>)<rst>d<rst><ceos><c10><c9>a<brightmagenta>(<rst>b<brightmagenta>[<rst>c<brightmagenta>)<rst>d<rst><ceos><c9><c9>a<brightmagenta>(<rst>b<brightmagenta>[<rst>c<brightmagenta>)<rst>d<rst><ceos><c16>\r\n"
502			"a(b[c)d\r\n"
503		)
504	def test_tab_completion( self_ ):
505		self_.check_scenario(
506			"co<tab><tab>bri<tab>b<tab><cr><c-d>",
507			"<c9>c<rst><ceos><c10><c9>co<rst><ceos>\r\n"
508			"        <gray>color_black<rst>\r\n"
509			"        <gray>color_red<rst>\r\n"
510			"        <gray>color_green<rst><u3><c11><c9>color_<rst><ceos>\r\n"
511			"        <gray>color_black<rst>\r\n"
512			"        <gray>color_red<rst>\r\n"
513			"        <gray>color_green<rst><u3><c15><c9>color_<rst><ceos><c15>\r\n"
514			"<brightmagenta>color_<rst>black          "
515			"<brightmagenta>color_<rst>cyan           "
516			"<brightmagenta>color_<rst>brightblue\r\n"
517			"<brightmagenta>color_<rst><red>red<rst>            "
518			"<brightmagenta>color_<rst>lightgray      "
519			"<brightmagenta>color_<rst>brightmagenta\r\n"
520			"<brightmagenta>color_<rst>green          "
521			"<brightmagenta>color_<rst>gray           "
522			"<brightmagenta>color_<rst>brightcyan\r\n"
523			"<brightmagenta>color_<rst>brown          "
524			"<brightmagenta>color_<rst><brightred>brightred<rst>      <brightmagenta>color_<rst>white\r\n"
525			"<brightmagenta>color_<rst>blue           "
526			"<brightmagenta>color_<rst>brightgreen    <brightmagenta>color_<rst>normal\r\n"
527			"<brightmagenta>color_<rst>magenta        <brightmagenta>color_<rst>yellow\r\n"
528			"<brightgreen>replxx<rst>> <c9>color_<rst><ceos>\r\n"
529			"        <gray>color_black<rst>\r\n"
530			"        <gray>color_red<rst>\r\n"
531			"        <gray>color_green<rst><u3><c15><c9>color_b<rst><ceos>\r\n"
532			"        <gray>color_black<rst>\r\n"
533			"        <gray>color_brown<rst>\r\n"
534			"        <gray>color_blue<rst><u3><c16><c9>color_br<rst><ceos>\r\n"
535			"        <gray>color_brown<rst>\r\n"
536			"        <gray>color_brightred<rst>\r\n"
537			"        "
538			"<gray>color_brightgreen<rst><u3><c17><c9>color_bri<rst><ceos>\r\n"
539			"        <gray>color_brightred<rst>\r\n"
540			"        <gray>color_brightgreen<rst>\r\n"
541			"        "
542			"<gray>color_brightblue<rst><u3><c18><c9>color_bright<rst><ceos>\r\n"
543			"        <gray>color_brightred<rst>\r\n"
544			"        <gray>color_brightgreen<rst>\r\n"
545			"        "
546			"<gray>color_brightblue<rst><u3><c21><c9>color_brightb<rst><ceos><green>lue<rst><c22><c9><brightblue>color_brightblue<rst><ceos><c25><c9><brightblue>color_brightblue<rst><ceos><c25>\r\n"
547			"color_brightblue\r\n"
548		)
549		self_.check_scenario(
550			"<tab><tab>n<cr><c-d>",
551			"<bell><bell><c9>n<rst><ceos><c10><c9>n<rst><ceos><c10>\r\nn\r\n",
552			dimensions = ( 4, 32 ),
553			command = [ ReplxxTests._cSample_, "q1", "e0" ]
554		)
555		self_.check_scenario(
556			"<tab><tab>n<cr><c-d>",
557			"<c9><ceos><c9>\r\n"
558			"db\r\n"
559			"hello\r\n"
560			"hallo\r\n"
561			"--More--<bell>\r"
562			"\t\t\t\t\r"
563			"<brightgreen>replxx<rst>> "
564			"<c9><rst><ceos><c9><c9><rst><ceos><c9>\r\n",
565			dimensions = ( 4, 24 ),
566			command = ReplxxTests._cSample_ + " q1 e1"
567		)
568		self_.check_scenario(
569			"<up><home>co<tab><cr><c-d>",
570			"<c9>abcd<brightmagenta>()<rst><ceos><c15>"
571			"<c9>abcd<brightmagenta>()<rst><ceos><c9>"
572			"<c9>cabcd<brightmagenta>()<rst><ceos><c10>"
573			"<c9>coabcd<brightmagenta>()<rst><ceos><c11>"
574			"<c9>color_abcd<brightmagenta>()<rst><ceos><c15>"
575			"<c9>color_abcd<brightmagenta>()<rst><ceos><c21>\r\n"
576			"color_abcd()\r\n",
577			"abcd()\n"
578		)
579	def test_completion_shorter_result( self_ ):
580		self_.check_scenario(
581			"<up><tab><cr><c-d>",
582			"<c9>\\pi<rst><ceos><c12><c9>π<rst><ceos><c10><c9>π<rst><ceos><c10>\r\n"
583			"π\r\n",
584			"\\pi\n"
585		)
586	def test_completion_pager( self_ ):
587		cmd = ReplxxTests._cSample_ + " q1 x" + ",".join( _words_ )
588		self_.check_scenario(
589			"<tab>py<cr><c-d>",
590			"<c9><ceos><c9>\r\n"
591			"ada         groovy      perl\r\n"
592			"algolbash   haskell     php\r\n"
593			"basic       huginn      prolog\r\n"
594			"clojure     java        python\r\n"
595			"cobol       javascript  rebol\r\n"
596			"csharp      julia       ruby\r\n"
597			"eiffel      kotlin      rust\r\n"
598			"erlang      lisp        scala\r\n"
599			"forth       lua         scheme\r\n"
600			"--More--<bell>\r"
601			"\t\t\t\t\r"
602			"fortran     modula      sql\r\n"
603			"fsharp      nemerle     swift\r\n"
604			"go          ocaml       typescript\r\n"
605			"<brightgreen>replxx<rst>> "
606			"<c9><rst><ceos><c9><c9><rst><ceos><c9>\r\n",
607			dimensions = ( 10, 40 ),
608			command = cmd
609		)
610		self_.check_scenario(
611			"<tab><cr><cr><cr><cr><c-d>",
612			"<c9><ceos><c9>\r\n"
613			"ada         groovy      perl\r\n"
614			"algolbash   haskell     php\r\n"
615			"basic       huginn      prolog\r\n"
616			"clojure     java        python\r\n"
617			"cobol       javascript  rebol\r\n"
618			"csharp      julia       ruby\r\n"
619			"eiffel      kotlin      rust\r\n"
620			"erlang      lisp        scala\r\n"
621			"forth       lua         scheme\r\n"
622			"--More--\r"
623			"\t\t\t\t\r"
624			"fortran     modula      sql\r\n"
625			"--More--\r"
626			"\t\t\t\t\r"
627			"fsharp      nemerle     swift\r\n"
628			"--More--\r"
629			"\t\t\t\t\r"
630			"go          ocaml       typescript\r\n"
631			"<brightgreen>replxx<rst>> "
632			"<c9><rst><ceos><c9><c9><rst><ceos><c9>\r\n",
633			dimensions = ( 10, 40 ),
634			command = cmd
635		)
636		self_.check_scenario(
637			"<tab><c-c><cr><c-d>",
638			"<c9><ceos><c9>\r\n"
639			"ada         kotlin\r\n"
640			"algolbash   lisp\r\n"
641			"basic       lua\r\n"
642			"clojure     modula\r\n"
643			"cobol       nemerle\r\n"
644			"csharp      ocaml\r\n"
645			"eiffel      perl\r\n"
646			"--More--^C\r\n"
647			"<brightgreen>replxx<rst>> "
648			"<c9><rst><ceos><c9><c9><rst><ceos><c9>\r\n",
649			dimensions = ( 8, 32 ),
650			command = cmd
651		)
652		self_.check_scenario(
653			"<tab>q<cr><c-d>",
654			"<c9><ceos><c9>\r\n"
655			"ada         kotlin\r\n"
656			"algolbash   lisp\r\n"
657			"basic       lua\r\n"
658			"clojure     modula\r\n"
659			"cobol       nemerle\r\n"
660			"csharp      ocaml\r\n"
661			"eiffel      perl\r\n"
662			"--More--\r"
663			"\t\t\t\t\r"
664			"<brightgreen>replxx<rst>> "
665			"<c9><rst><ceos><c9><c9><rst><ceos><c9>\r\n",
666			dimensions = ( 8, 32 ),
667			command = cmd
668		)
669	def test_double_tab_completion( self_ ):
670		cmd = ReplxxTests._cSample_ + " d1 q1 x" + ",".join( _words_ )
671		self_.check_scenario(
672			"fo<tab><tab>r<tab><cr><c-d>",
673			"<c9>f<rst><ceos>\r\n"
674			"        <gray>forth<rst>\r\n"
675			"        <gray>fortran<rst>\r\n"
676			"        <gray>fsharp<rst><u3><c10><c9>fo<rst><ceos>\r\n"
677			"        <gray>forth<rst>\r\n"
678			"        <gray>fortran<rst><u2><c11><c9>fort<rst><ceos>\r\n"
679			"        <gray>forth<rst>\r\n"
680			"        "
681			"<gray>fortran<rst><u2><c13><c9>fortr<rst><ceos><gray>an<rst><c14><c9>fortran<rst><ceos><c16><c9>fortran<rst><ceos><c16>\r\n"
682			"fortran\r\n",
683			command = cmd
684		)
685	def test_beep_on_ambiguous_completion( self_ ):
686		cmd = ReplxxTests._cSample_ + " b1 d1 q1 x" + ",".join( _words_ )
687		self_.check_scenario(
688			"fo<tab><tab>r<tab><cr><c-d>",
689			"<c9>f<rst><ceos>\r\n"
690			"        <gray>forth<rst>\r\n"
691			"        <gray>fortran<rst>\r\n"
692			"        <gray>fsharp<rst><u3><c10><c9>fo<rst><ceos>\r\n"
693			"        <gray>forth<rst>\r\n"
694			"        <gray>fortran<rst><u2><c11><bell><c9>fort<rst><ceos>\r\n"
695			"        <gray>forth<rst>\r\n"
696			"        "
697			"<gray>fortran<rst><u2><c13><bell><c9>fortr<rst><ceos><gray>an<rst><c14><c9>fortran<rst><ceos><c16><c9>fortran<rst><ceos><c16>\r\n"
698			"fortran\r\n",
699			command = cmd
700		)
701	def test_history_search_backward( self_ ):
702		self_.check_scenario(
703			"<c-r>repl<c-r><cr><c-d>",
704			"<c1><ceos><c1><ceos>(reverse-i-search)`': "
705			"<c23><c1><ceos>(reverse-i-search)`r': echo repl "
706			"golf<c29><c1><ceos>(reverse-i-search)`re': echo repl "
707			"golf<c30><c1><ceos>(reverse-i-search)`rep': echo repl "
708			"golf<c31><c1><ceos>(reverse-i-search)`repl': echo repl "
709			"golf<c32><c1><ceos>(reverse-i-search)`repl': charlie repl "
710			"delta<c35><c1><ceos><brightgreen>replxx<rst>> charlie repl "
711			"delta<c17><c9><ceos><c27>\r\n"
712			"charlie repl delta\r\n",
713			"some command\n"
714			"alfa repl bravo\n"
715			"other request\n"
716			"charlie repl delta\n"
717			"misc input\n"
718			"echo repl golf\n"
719			"final thoughts\n"
720		)
721		self_.check_scenario(
722			"<c-r>for<backspace><backspace>s<cr><c-d>",
723			"<c1><ceos><c1><ceos>(reverse-i-search)`': "
724			"<c23><c1><ceos>(reverse-i-search)`f': "
725			"swift<c27><c1><ceos>(reverse-i-search)`fo': "
726			"fortran<c25><c1><ceos>(reverse-i-search)`for': "
727			"fortran<c26><c1><ceos>(reverse-i-search)`fo': "
728			"fortran<c25><c1><ceos>(reverse-i-search)`f': "
729			"swift<c27><c1><ceos>(reverse-i-search)`fs': "
730			"fsharp<c25><c1><ceos><brightgreen>replxx<rst>> "
731			"fsharp<c9><c9><ceos><c15>\r\n"
732			"fsharp\r\n",
733			"\n".join( _words_ ) + "\n"
734		)
735		self_.check_scenario(
736			"<c-r>mod<c-l><cr><c-d>",
737			"<c1><ceos><c1><ceos>(reverse-i-search)`': "
738			"<c23><c1><ceos>(reverse-i-search)`m': "
739			"scheme<c28><c1><ceos>(reverse-i-search)`mo': "
740			"modula<c25><c1><ceos>(reverse-i-search)`mod': "
741			"modula<c26><c1><ceos><brightgreen>replxx<rst>> "
742			"<c9><RIS><mvhm><clr><rst><brightgreen>replxx<rst>> "
743			"<c9><rst><ceos><c9><c9><rst><ceos><c9>\r\n",
744			"\n".join( _words_ ) + "\n"
745		)
746	def test_history_search_forward( self_ ):
747		self_.check_scenario(
748			"<c-s>repl<c-s><cr><c-d>",
749			"<c1><ceos><c1><ceos>(i-search)`': <c15><bell><c1><ceos>(i-search)`r': "
750			"<c16><bell><c1><ceos>(i-search)`re': <c17><bell><c1><ceos>(i-search)`rep': "
751			"<c18><bell><c1><ceos>(i-search)`repl': "
752			"<c19><bell><c1><ceos>(i-search)`repl': "
753			"<c19><c1><ceos><brightgreen>replxx<rst>> <c9><c9><ceos><c9>\r\n",
754			"charlie repl delta\r\n",
755			"some command\n"
756			"alfa repl bravo\n"
757			"other request\n"
758			"charlie repl delta\n"
759			"misc input\n"
760			"echo repl golf\n"
761			"final thoughts\n"
762		)
763		self_.check_scenario(
764			"<pgup><c-s>repl<c-s><cr><c-d>",
765			"<c9>final thoughts<rst><ceos><c23><c1><ceos><c1><ceos>(i-search)`': final "
766			"thoughts<c29><c1><ceos>(i-search)`r': echo repl "
767			"golf<c21><c1><ceos>(i-search)`re': echo repl "
768			"golf<c22><c1><ceos>(i-search)`rep': echo repl "
769			"golf<c23><c1><ceos>(i-search)`repl': echo repl "
770			"golf<c24><c1><ceos>(i-search)`repl': alfa repl "
771			"bravo<c24><c1><ceos><brightgreen>replxx<rst>> alfa repl bravo<c14><c9>final "
772			"thoughts<rst><ceos><c24>\r\n"
773			"alfa repl bravo\r\n",
774			"final thoughts\n"
775			"echo repl golf\n"
776			"misc input\n"
777			"charlie repl delta\n"
778			"other request\n"
779			"alfa repl bravo\n"
780			"some command\n"
781			"charlie repl delta\r\n",
782		)
783		self_.check_scenario(
784			"<c-s>for<backspace><backspace>s<cr><c-d>",
785			"<c1><ceos><c1><ceos>(i-search)`': <c15><bell><c1><ceos>(i-search)`f': "
786			"<c16><bell><c1><ceos>(i-search)`fo': <c17><bell><c1><ceos>(i-search)`for': "
787			"<c18><bell><c1><ceos>(i-search)`fo': <c17><bell><c1><ceos>(i-search)`f': "
788			"<c16><bell><c1><ceos>(i-search)`fs': "
789			"<c17><c1><ceos><brightgreen>replxx<rst>> <c9><c9><ceos><c9>\r\n",
790			"\n".join( _words_[::-1] ) + "\n"
791		)
792		self_.check_scenario(
793			"<pgup><c-s>for<backspace><backspace>s<cr><c-d>",
794			"<c9>typescript<rst><ceos><c19><c1><ceos><c1><ceos>(i-search)`': "
795			"typescript<c25><c1><ceos>(i-search)`f': swift<c19><c1><ceos>(i-search)`fo': "
796			"fortran<c17><c1><ceos>(i-search)`for': fortran<c18><c1><ceos>(i-search)`fo': "
797			"fortran<c17><c1><ceos>(i-search)`f': swift<c19><c1><ceos>(i-search)`fs': "
798			"fsharp<c17><c1><ceos><brightgreen>replxx<rst>> "
799			"fsharp<c9><c9>typescript<rst><ceos><c15>\r\n"
800			"fsharp\r\n",
801			"\n".join( _words_[::-1] ) + "\n"
802		)
803		self_.check_scenario(
804			"<c-s>mod<c-l><cr><c-d>",
805			"<c1><ceos><c1><ceos>(i-search)`': <c15><bell><c1><ceos>(i-search)`m': "
806			"<c16><bell><c1><ceos>(i-search)`mo': <c17><bell><c1><ceos>(i-search)`mod': "
807			"<c18><c1><ceos><brightgreen>replxx<rst>> "
808			"<c9><RIS><mvhm><clr><rst><brightgreen>replxx<rst>> "
809			"<c9><rst><ceos><c9><c9><rst><ceos><c9>\r\n",
810			"\n".join( _words_[::-1] ) + "\n"
811		)
812		self_.check_scenario(
813			"<pgup><c-s>mod<c-l><cr><c-d>",
814			"<c9>typescript<rst><ceos><c19><c1><ceos><c1><ceos>(i-search)`': "
815			"typescript<c25><c1><ceos>(i-search)`m': scheme<c20><c1><ceos>(i-search)`mo': "
816			"modula<c17><c1><ceos>(i-search)`mod': "
817			"modula<c18><c1><ceos><brightgreen>replxx<rst>> "
818			"typescript<c19><RIS><mvhm><clr><rst><brightgreen>replxx<rst>> "
819			"<c9>typescript<rst><ceos><c19><c9>typescript<rst><ceos><c19>\r\n"
820			"typescript\r\n",
821			"\n".join( _words_[::-1] ) + "\n"
822		)
823	def test_history_search_backward_position( self_ ):
824		self_.check_scenario(
825			"<c-r>req<up><cr><c-d>",
826			"<c1><ceos><c1><ceos>(reverse-i-search)`': "
827			"<c23><c1><ceos>(reverse-i-search)`r': echo repl "
828			"golf<c29><c1><ceos>(reverse-i-search)`re': echo repl "
829			"golf<c30><c1><ceos>(reverse-i-search)`req': other "
830			"request<c32><c1><ceos><brightgreen>replxx<rst>> other request<c15><c9>alfa "
831			"repl bravo<rst><ceos><c24><c9>alfa repl bravo<rst><ceos><c24>\r\n"
832			"alfa repl bravo\r\n",
833			"some command\n"
834			"alfa repl bravo\n"
835			"other request\n"
836			"charlie repl delta\n"
837			"misc input\n"
838			"echo repl golf\n"
839			"final thoughts\n"
840		)
841	def test_history_search_overlong_line( self_ ):
842		self_.check_scenario(
843			"<c-r>lo<cr><c-d>",
844			"<c1><ceos><c1><ceos>(reverse-i-search)`': "
845			"<c23><c1><ceos>(reverse-i-search)`l': some very long line of text, much "
846			"longer then a witdth of a terminal, "
847			"seriously<c37><u1><c1><ceos>(reverse-i-search)`lo': some very long line of "
848			"text, much longer then a witdth of a terminal, "
849			"seriously<u1><c59><c1><ceos><brightgreen>replxx<rst>> some very long line of "
850			"text, much longer then a witdth of a terminal, "
851			"seriously<u1><c43><c9><ceos><c24>\r\n"
852			"some very long line of text, much longer then a witdth of a terminal, "
853			"seriously\r\n",
854			"fake\nsome very long line of text, much longer then a witdth of a terminal, seriously\nanother fake",
855			dimensions = ( 24, 64 )
856		)
857	def test_history_prefix_search_backward( self_ ):
858		self_.check_scenario(
859			"repl<m-p><m-p><cr><c-d>",
860			"<c9>r<rst><ceos><c10><c9>re<rst><ceos><c11><c9>rep<rst><ceos><c12><c9>repl<rst><ceos><c13><c9>repl_echo "
861			"golf<rst><ceos><c23><c9>repl_charlie "
862			"delta<rst><ceos><c27><c9>repl_charlie delta<rst><ceos><c27>\r\n"
863			"repl_charlie delta\r\n",
864			"some command\n"
865			"repl_alfa bravo\n"
866			"other request\n"
867			"repl_charlie delta\n"
868			"misc input\n"
869			"repl_echo golf\n"
870			"final thoughts\n"
871		)
872	def test_history_prefix_search_backward_position( self_ ):
873		self_.check_scenario(
874			"repl<m-p><up><cr><c-d>",
875			"<c9>r<rst><ceos><c10><c9>re<rst><ceos><c11><c9>rep<rst><ceos><c12><c9>repl<rst><ceos><c13><c9>repl_echo "
876			"golf<rst><ceos><c23><c9>misc input<rst><ceos><c19><c9>misc "
877			"input<rst><ceos><c19>\r\n"
878			"misc input\r\n",
879			"some command\n"
880			"repl_alfa bravo\n"
881			"other request\n"
882			"repl_charlie delta\n"
883			"misc input\n"
884			"repl_echo golf\n"
885			"final thoughts\n"
886		)
887	def test_history_listing( self_ ):
888		self_.check_scenario(
889			"<up><cr><c-d>",
890			"<c9><brightmagenta>.history<rst><ceos><c17><c9><brightmagenta>.history<rst><ceos><c17>\r\n"
891			"   0: some command\r\n"
892			"   1: repl_alfa bravo\r\n"
893			"   2: other request\r\n"
894			"   3: repl_charlie delta\r\n"
895			"   4: misc input\r\n"
896			"   5: repl_echo golf\r\n"
897			"   6: .history\r\n",
898			"some command\n"
899			"repl_alfa bravo\n"
900			"other request\n"
901			"repl_charlie delta\n"
902			"misc input\n"
903			"repl_echo golf\n"
904			".history\n"
905		)
906		self_.check_scenario(
907			"<up><cr><c-d>",
908			"<c9>/history<rst><ceos><c17><c9>/history<rst><ceos><c17>\r\n"
909			"   0: some command\r\n"
910			"   1: repl_alfa bravo\r\n"
911			"   2: other request\r\n"
912			"   3: repl_charlie delta\r\n"
913			"   4: misc input\r\n"
914			"   5: repl_echo golf\r\n"
915			"   6: /history\r\n"
916			"/history\r\n",
917			"some command\n"
918			"repl_alfa bravo\n"
919			"other request\n"
920			"repl_charlie delta\n"
921			"misc input\n"
922			"repl_echo golf\n"
923			"/history\n",
924			command = ReplxxTests._cSample_ + " q1"
925		)
926	def test_history_browse( self_ ):
927		self_.check_scenario(
928			"<up><aup><pgup><down><up><up><adown><pgdown><up><down><down><up><cr><c-d>",
929			"<c9>twelve<rst><ceos><c15>"
930			"<c9>eleven<rst><ceos><c15>"
931			"<c9>one<rst><ceos><c12>"
932			"<c9>two<rst><ceos><c12>"
933			"<c9>one<rst><ceos><c12>"
934			"<c9>two<rst><ceos><c12>"
935			"<c9><rst><ceos><c9>"
936			"<c9>twelve<rst><ceos><c15>"
937			"<c9><rst><ceos><c9>"
938			"<c9>twelve<rst><ceos><c15>"
939			"<c9>twelve<rst><ceos><c15>\r\n"
940			"twelve\r\n",
941			"one\n"
942			"two\n"
943			"three\n"
944			"four\n"
945			"five\n"
946			"six\n"
947			"seven\n"
948			"eight\n"
949			"nine\n"
950			"ten\n"
951			"eleven\n"
952			"twelve\n"
953		)
954	def test_history_max_size( self_ ):
955		self_.check_scenario(
956			"<pgup><pgdown>a<cr><pgup><cr><c-d>",
957			"<c9>three<rst><ceos><c14><c9><rst><ceos><c9><c9>a<rst><ceos><c10><c9>a<rst><ceos><c10>\r\n"
958			"a\r\n"
959			"<brightgreen>replxx<rst>> "
960			"<c9>four<rst><ceos><c13><c9>four<rst><ceos><c13>\r\n"
961			"four\r\n",
962			"one\n"
963			"two\n"
964			"three\n"
965			"four\n"
966			"five\n",
967			command = ReplxxTests._cSample_ + " q1 s3"
968		)
969	def test_history_unique( self_ ):
970		self_.check_scenario(
971			"a<cr>b<cr>a<cr>b<cr><up><up><up><cr><c-d>",
972			"<c9>a<rst><ceos><c10><c9>a<rst><ceos><c10>\r\n"
973			"a\r\n"
974			"<brightgreen>replxx<rst>> <c9>b<rst><ceos><c10><c9>b<rst><ceos><c10>\r\n"
975			"b\r\n"
976			"<brightgreen>replxx<rst>> <c9>a<rst><ceos><c10><c9>a<rst><ceos><c10>\r\n"
977			"a\r\n"
978			"<brightgreen>replxx<rst>> <c9>b<rst><ceos><c10><c9>b<rst><ceos><c10>\r\n"
979			"b\r\n"
980			"<brightgreen>replxx<rst>> "
981			"<c9>b<rst><ceos><c10><c9>a<rst><ceos><c10><c9>c<rst><ceos><c10><c9>c<rst><ceos><c10>\r\n"
982			"c\r\n",
983			"a\nb\nc\n",
984			command = ReplxxTests._cSample_ + " u1 q1"
985		)
986		self_.check_scenario(
987			"a<cr>b<cr>a<cr>b<cr><up><up><up><cr><c-d>",
988			"<c9>a<rst><ceos><c10><c9>a<rst><ceos><c10>\r\n"
989			"a\r\n"
990			"<brightgreen>replxx<rst>> <c9>b<rst><ceos><c10><c9>b<rst><ceos><c10>\r\n"
991			"b\r\n"
992			"<brightgreen>replxx<rst>> <c9>a<rst><ceos><c10><c9>a<rst><ceos><c10>\r\n"
993			"a\r\n"
994			"<brightgreen>replxx<rst>> <c9>b<rst><ceos><c10><c9>b<rst><ceos><c10>\r\n"
995			"b\r\n"
996			"<brightgreen>replxx<rst>> "
997			"<c9>b<rst><ceos><c10><c9>a<rst><ceos><c10><c9>b<rst><ceos><c10><c9>b<rst><ceos><c10>\r\n"
998			"b\r\n",
999			"a\nb\nc\n",
1000			command = ReplxxTests._cSample_ + " u0 q1"
1001		)
1002		self_.check_scenario(
1003			rapid( "/history\n/unique\n/history\n<c-d>" ),
1004			"<c9>/<rst><ceos><c10><c9>/history<rst><ceos><c17>\r\n"
1005			"   0: a\r\n"
1006			"   1: b\r\n"
1007			"   2: c\r\n"
1008			"   3: b\r\n"
1009			"   4: c\r\n"
1010			"   5: d\r\n"
1011			"   6: a\r\n"
1012			"   7: c\r\n"
1013			"   8: c\r\n"
1014			"   9: a\r\n"
1015			"/history\r\n"
1016			"<brightgreen>replxx<rst>> <c9>/unique<rst><ceos><c16>\r\n"
1017			"/unique\r\n"
1018			"<brightgreen>replxx<rst>> <c9>/history<rst><ceos><c17>\r\n"
1019			"   0: b\r\n"
1020			"   1: d\r\n"
1021			"   2: c\r\n"
1022			"   3: a\r\n"
1023			"   4: /history\r\n"
1024			"   5: /unique\r\n"
1025			"/history\r\n",
1026			"a\nb\nc\nb\nc\nd\na\nc\nc\na\n",
1027			command = ReplxxTests._cSample_ + " u0 q1"
1028		)
1029	def test_history_recall_most_recent( self_ ):
1030		self_.check_scenario(
1031			"<pgup><down><cr><down><cr><c-d>",
1032			"<c9>aaaa<rst><ceos><c13><c9>bbbb<rst><ceos><c13><c9>bbbb<rst><ceos><c13>\r\n"
1033			"bbbb\r\n"
1034			"<brightgreen>replxx<rst>> "
1035			"<c9>cccc<rst><ceos><c13><c9>cccc<rst><ceos><c13>\r\n"
1036			"cccc\r\n",
1037			"aaaa\nbbbb\ncccc\ndddd\n"
1038		)
1039	def test_history_abort_incremental_history_search_position( self_ ):
1040		self_.check_scenario(
1041			"<up><up><c-r>cc<c-c><up><cr><c-d>",
1042			"<c9>hhhh<rst><ceos><c13><c9>gggg<rst><ceos><c13><c1><ceos><c1><ceos>(reverse-i-search)`': "
1043			"gggg<c27><c1><ceos>(reverse-i-search)`c': "
1044			"cccc<c27><c1><ceos>(reverse-i-search)`cc': "
1045			"cccc<c27><c1><ceos><brightgreen>replxx<rst>> "
1046			"gggg<c13><c9>gggg<rst><ceos><c13><c9>ffff<rst><ceos><c13><c9>ffff<rst><ceos><c13>\r\n"
1047			"ffff\r\n",
1048			"aaaa\nbbbb\ncccc\ndddd\neeee\nffff\ngggg\nhhhh\n"
1049		)
1050	def test_capitalize( self_ ):
1051		self_.check_scenario(
1052			"<up><home><right><m-c><m-c><right><right><m-c><m-c><m-c><cr><c-d>",
1053			"<c9>abc defg ijklmn zzxq<rst><ceos><c29><c9>abc defg ijklmn "
1054			"zzxq<rst><ceos><c9><c9>abc defg ijklmn zzxq<rst><ceos><c10><c9>aBc defg "
1055			"ijklmn zzxq<rst><ceos><c12><c9>aBc Defg ijklmn zzxq<rst><ceos><c17><c9>aBc "
1056			"Defg ijklmn zzxq<rst><ceos><c18><c9>aBc Defg ijklmn "
1057			"zzxq<rst><ceos><c19><c9>aBc Defg iJklmn zzxq<rst><ceos><c24><c9>aBc Defg "
1058			"iJklmn Zzxq<rst><ceos><c29><c9>aBc Defg iJklmn Zzxq<rst><ceos><c29>\r\n"
1059			"aBc Defg iJklmn Zzxq\r\n",
1060			"abc defg ijklmn zzxq\n"
1061		)
1062	def test_make_upper_case( self_ ):
1063		self_.check_scenario(
1064			"<up><home><right><right><right><m-u><m-u><right><m-u><cr><c-d>",
1065			"<c9>abcdefg hijklmno pqrstuvw<rst><ceos><c34><c9>abcdefg "
1066			"hijklmno pqrstuvw<rst><ceos><c9><c9>abcdefg hijklmno "
1067			"pqrstuvw<rst><ceos><c10><c9>abcdefg hijklmno "
1068			"pqrstuvw<rst><ceos><c11><c9>abcdefg hijklmno "
1069			"pqrstuvw<rst><ceos><c12><c9>abcDEFG hijklmno "
1070			"pqrstuvw<rst><ceos><c16><c9>abcDEFG HIJKLMNO "
1071			"pqrstuvw<rst><ceos><c25><c9>abcDEFG HIJKLMNO "
1072			"pqrstuvw<rst><ceos><c26><c9>abcDEFG HIJKLMNO "
1073			"PQRSTUVW<rst><ceos><c34><c9>abcDEFG HIJKLMNO "
1074			"PQRSTUVW<rst><ceos><c34>\r\n"
1075			"abcDEFG HIJKLMNO PQRSTUVW\r\n",
1076			"abcdefg hijklmno pqrstuvw\n"
1077		)
1078	def test_make_lower_case( self_ ):
1079		self_.check_scenario(
1080			"<up><home><right><right><right><m-l><m-l><right><m-l><cr><c-d>",
1081			"<c9>ABCDEFG HIJKLMNO PQRSTUVW<rst><ceos><c34><c9>ABCDEFG "
1082			"HIJKLMNO PQRSTUVW<rst><ceos><c9><c9>ABCDEFG HIJKLMNO "
1083			"PQRSTUVW<rst><ceos><c10><c9>ABCDEFG HIJKLMNO "
1084			"PQRSTUVW<rst><ceos><c11><c9>ABCDEFG HIJKLMNO "
1085			"PQRSTUVW<rst><ceos><c12><c9>ABCdefg HIJKLMNO "
1086			"PQRSTUVW<rst><ceos><c16><c9>ABCdefg hijklmno "
1087			"PQRSTUVW<rst><ceos><c25><c9>ABCdefg hijklmno "
1088			"PQRSTUVW<rst><ceos><c26><c9>ABCdefg hijklmno "
1089			"pqrstuvw<rst><ceos><c34><c9>ABCdefg hijklmno "
1090			"pqrstuvw<rst><ceos><c34>\r\n"
1091			"ABCdefg hijklmno pqrstuvw\r\n",
1092			"ABCDEFG HIJKLMNO PQRSTUVW\n"
1093		)
1094	def test_transpose( self_ ):
1095		self_.check_scenario(
1096			"<up><home><c-t><right><c-t><c-t><c-t><c-t><c-t><cr><c-d>",
1097			"<c9>abcd<rst><ceos><c13>"
1098			"<c9>abcd<rst><ceos><c9>"
1099			"<c9>abcd<rst><ceos><c10>"
1100			"<c9>bacd<rst><ceos><c11>"
1101			"<c9>bcad<rst><ceos><c12>"
1102			"<c9>bcda<rst><ceos><c13>"
1103			"<c9>bcad<rst><ceos><c13>"
1104			"<c9>bcda<rst><ceos><c13>"
1105			"<c9>bcda<rst><ceos><c13>\r\n"
1106			"bcda\r\n",
1107			"abcd\n"
1108		)
1109	def test_kill_to_beginning_of_line( self_ ):
1110		self_.check_scenario(
1111			"<up><home><c-right><c-right><right><c-u><end><c-y><cr><c-d>",
1112			"<c9><brightblue>+<rst>abc defg<brightblue>--<rst>ijklmn "
1113			"zzxq<brightblue>+<rst><ceos><c32><c9><brightblue>+<rst>abc "
1114			"defg<brightblue>--<rst>ijklmn "
1115			"zzxq<brightblue>+<rst><ceos><c9><c9><brightblue>+<rst>abc "
1116			"defg<brightblue>--<rst>ijklmn "
1117			"zzxq<brightblue>+<rst><ceos><c13><c9><brightblue>+<rst>abc "
1118			"defg<brightblue>--<rst>ijklmn "
1119			"zzxq<brightblue>+<rst><ceos><c18><c9><brightblue>+<rst>abc "
1120			"defg<brightblue>--<rst>ijklmn "
1121			"zzxq<brightblue>+<rst><ceos><c19><c9><brightblue>-<rst>ijklmn "
1122			"zzxq<brightblue>+<rst><ceos><c9><c9><brightblue>-<rst>ijklmn "
1123			"zzxq<brightblue>+<rst><ceos><c22><c9><brightblue>-<rst>ijklmn "
1124			"zzxq<brightblue>++<rst>abc "
1125			"defg<brightblue>-<rst><ceos><c32><c9><brightblue>-<rst>ijklmn "
1126			"zzxq<brightblue>++<rst>abc defg<brightblue>-<rst><ceos><c32>\r\n"
1127			"-ijklmn zzxq++abc defg-\r\n",
1128			"+abc defg--ijklmn zzxq+\n"
1129		)
1130	def test_kill_to_end_of_line( self_ ):
1131		self_.check_scenario(
1132			"<up><home><c-right><c-right><right><c-k><home><c-y><cr><c-d>",
1133			"<c9><brightblue>+<rst>abc defg<brightblue>--<rst>ijklmn "
1134			"zzxq<brightblue>+<rst><ceos><c32><c9><brightblue>+<rst>abc "
1135			"defg<brightblue>--<rst>ijklmn "
1136			"zzxq<brightblue>+<rst><ceos><c9><c9><brightblue>+<rst>abc "
1137			"defg<brightblue>--<rst>ijklmn "
1138			"zzxq<brightblue>+<rst><ceos><c13><c9><brightblue>+<rst>abc "
1139			"defg<brightblue>--<rst>ijklmn "
1140			"zzxq<brightblue>+<rst><ceos><c18><c9><brightblue>+<rst>abc "
1141			"defg<brightblue>--<rst>ijklmn "
1142			"zzxq<brightblue>+<rst><ceos><c19><c9><brightblue>+<rst>abc "
1143			"defg<brightblue>-<rst><ceos><c19><c9><brightblue>+<rst>abc "
1144			"defg<brightblue>-<rst><ceos><c9><c9><brightblue>-<rst>ijklmn "
1145			"zzxq<brightblue>++<rst>abc "
1146			"defg<brightblue>-<rst><ceos><c22><c9><brightblue>-<rst>ijklmn "
1147			"zzxq<brightblue>++<rst>abc defg<brightblue>-<rst><ceos><c32>\r\n"
1148			"-ijklmn zzxq++abc defg-\r\n",
1149			"+abc defg--ijklmn zzxq+\n"
1150		)
1151	def test_kill_next_word( self_ ):
1152		self_.check_scenario(
1153			"<up><home><c-right><m-d><c-right><c-y><cr><c-d>",
1154			"<c9>alpha charlie bravo delta<rst><ceos><c34><c9>alpha "
1155			"charlie bravo delta<rst><ceos><c9><c9>alpha charlie bravo "
1156			"delta<rst><ceos><c14><c9>alpha bravo delta<rst><ceos><c14><c9>alpha bravo "
1157			"delta<rst><ceos><c20><c9>alpha bravo charlie delta<rst><ceos><c28><c9>alpha "
1158			"bravo charlie delta<rst><ceos><c34>\r\n"
1159			"alpha bravo charlie delta\r\n",
1160			"alpha charlie bravo delta\n"
1161		)
1162	def test_kill_prev_word_to_white_space( self_ ):
1163		self_.check_scenario(
1164			"<up><c-left><c-w><c-left><c-y><cr><c-d>",
1165			"<c9>alpha charlie bravo delta<rst><ceos><c34><c9>alpha "
1166			"charlie bravo delta<rst><ceos><c29><c9>alpha charlie "
1167			"delta<rst><ceos><c23><c9>alpha charlie delta<rst><ceos><c15><c9>alpha bravo "
1168			"charlie delta<rst><ceos><c21><c9>alpha bravo charlie delta<rst><ceos><c34>\r\n"
1169			"alpha bravo charlie delta\r\n",
1170			"alpha charlie bravo delta\n"
1171		)
1172	def test_kill_prev_word( self_ ):
1173		self_.check_scenario(
1174			"<up><c-left><m-backspace><c-left><c-y><cr><c-d>",
1175			"<c9>alpha<brightmagenta>.<rst>charlie "
1176			"bravo<brightmagenta>.<rst>delta<rst><ceos><c34><c9>alpha<brightmagenta>.<rst>charlie "
1177			"bravo<brightmagenta>.<rst>delta<rst><ceos><c29><c9>alpha<brightmagenta>.<rst>charlie "
1178			"delta<rst><ceos><c23><c9>alpha<brightmagenta>.<rst>charlie "
1179			"delta<rst><ceos><c15><c9>alpha<brightmagenta>.<rst>bravo<brightmagenta>.<rst>charlie "
1180			"delta<rst><ceos><c21><c9>alpha<brightmagenta>.<rst>bravo<brightmagenta>.<rst>charlie "
1181			"delta<rst><ceos><c34>\r\n"
1182			"alpha.bravo.charlie delta\r\n",
1183			"alpha.charlie bravo.delta\n"
1184		)
1185	def test_kill_ring( self_ ):
1186		self_.check_scenario(
1187			"<up><c-w><backspace><c-w><backspace><c-w><backspace><c-u><c-y><m-y><m-y><m-y> <c-y><m-y><m-y><m-y> <c-y><m-y><m-y><m-y> <c-y><m-y><m-y><m-y><cr><c-d>",
1188			"<c9>delta charlie bravo alpha<rst><ceos><c34><c9>delta "
1189			"charlie bravo <rst><ceos><c29><c9>delta charlie "
1190			"bravo<rst><ceos><c28><c9>delta charlie "
1191			"<rst><ceos><c23><c9>delta "
1192			"charlie<rst><ceos><c22><c9>delta "
1193			"<rst><ceos><c15>"
1194			"<c9>delta<rst><ceos><c14>"
1195			"<c9><rst><ceos><c9>"
1196			"<c9>delta<rst><ceos><c14>"
1197			"<c9>charlie<rst><ceos><c16>"
1198			"<c9>bravo<rst><ceos><c14>"
1199			"<c9>alpha<rst><ceos><c14>"
1200			"<c9>alpha "
1201			"<rst><ceos><c15><c9>alpha "
1202			"alpha<rst><ceos><c20><c9>alpha "
1203			"delta<rst><ceos><c20><c9>alpha "
1204			"charlie<rst><ceos><c22><c9>alpha "
1205			"bravo<rst><ceos><c20><c9>alpha bravo "
1206			"<rst><ceos><c21><c9>alpha bravo "
1207			"bravo<rst><ceos><c26><c9>alpha bravo "
1208			"alpha<rst><ceos><c26><c9>alpha bravo "
1209			"delta<rst><ceos><c26><c9>alpha bravo "
1210			"charlie<rst><ceos><c28><c9>alpha bravo charlie "
1211			"<rst><ceos><c29><c9>alpha bravo charlie "
1212			"charlie<rst><ceos><c36><c9>alpha bravo charlie "
1213			"bravo<rst><ceos><c34><c9>alpha bravo charlie "
1214			"alpha<rst><ceos><c34><c9>alpha bravo charlie "
1215			"delta<rst><ceos><c34><c9>alpha bravo charlie delta<rst><ceos><c34>\r\n"
1216			"alpha bravo charlie delta\r\n",
1217			"delta charlie bravo alpha\n"
1218		)
1219		self_.check_scenario(
1220			"<up><c-w><c-w><backspace><c-a><c-y> <cr><c-d>",
1221			"<c9>charlie delta alpha bravo<rst><ceos><c34><c9>charlie "
1222			"delta alpha <rst><ceos><c29><c9>charlie delta "
1223			"<rst><ceos><c23><c9>charlie "
1224			"delta<rst><ceos><c22><c9>charlie delta<rst><ceos><c9><c9>alpha "
1225			"bravocharlie delta<rst><ceos><c20><c9>alpha bravo charlie "
1226			"delta<rst><ceos><c21><c9>alpha bravo charlie delta<rst><ceos><c34>\r\n"
1227			"alpha bravo charlie delta\r\n",
1228			"charlie delta alpha bravo\n"
1229		)
1230		self_.check_scenario(
1231			"<up><home><m-d><m-d><del><c-e> <c-y><cr><c-d>",
1232			"<c9>charlie delta alpha bravo<rst><ceos><c34><c9>charlie "
1233			"delta alpha bravo<rst><ceos><c9><c9> delta alpha bravo<rst><ceos><c9><c9> "
1234			"alpha bravo<rst><ceos><c9><c9>alpha bravo<rst><ceos><c9><c9>alpha "
1235			"bravo<rst><ceos><c20><c9>alpha bravo "
1236			"<rst><ceos><c21><c9>alpha bravo charlie "
1237			"delta<rst><ceos><c34><c9>alpha bravo charlie delta<rst><ceos><c34>\r\n"
1238			"alpha bravo charlie delta\r\n",
1239			"charlie delta alpha bravo\n"
1240		)
1241		self_.check_scenario(
1242			"<up><c-w><backspace><c-w><backspace><c-w><backspace><c-w><backspace><c-w><backspace>"
1243			"<c-w><backspace><c-w><backspace><c-w><backspace><c-w><backspace><c-w><backspace>"
1244			"<c-w><c-y><m-y><m-y><m-y><m-y><m-y><m-y><m-y><m-y><m-y><m-y><cr><c-d>",
1245			"<c9>a b c d e f g h i j k<rst><ceos><c30><c9>a b c d e f g "
1246			"h i j <rst><ceos><c29><c9>a b c d e f g h i "
1247			"j<rst><ceos><c28><c9>a b c d e f g h i "
1248			"<rst><ceos><c27><c9>a b c d e f g h "
1249			"i<rst><ceos><c26><c9>a b c d e f g h "
1250			"<rst><ceos><c25><c9>a b c d e f g "
1251			"h<rst><ceos><c24><c9>a b c d e f g "
1252			"<rst><ceos><c23><c9>a b c d e f g<rst><ceos><c22><c9>a "
1253			"b c d e f <rst><ceos><c21><c9>a b c d e "
1254			"f<rst><ceos><c20><c9>a b c d e <rst><ceos><c19><c9>a b "
1255			"c d e<rst><ceos><c18><c9>a b c d <rst><ceos><c17><c9>a "
1256			"b c d<rst><ceos><c16><c9>a b c <rst><ceos><c15><c9>a b "
1257			"c<rst><ceos><c14><c9>a b <rst><ceos><c13><c9>a "
1258			"b<rst><ceos><c12><c9>a "
1259			"<rst><ceos><c11>"
1260			"<c9>a<rst><ceos><c10>"
1261			"<c9><rst><ceos><c9>"
1262			"<c9>a<rst><ceos><c10>"
1263			"<c9>b<rst><ceos><c10>"
1264			"<c9>c<rst><ceos><c10>"
1265			"<c9>d<rst><ceos><c10>"
1266			"<c9>e<rst><ceos><c10>"
1267			"<c9>f<rst><ceos><c10>"
1268			"<c9>g<rst><ceos><c10>"
1269			"<c9>h<rst><ceos><c10>"
1270			"<c9>i<rst><ceos><c10>"
1271			"<c9>j<rst><ceos><c10>"
1272			"<c9>a<rst><ceos><c10>"
1273			"<c9>a<rst><ceos><c10>\r\n"
1274			"a\r\n",
1275			"a b c d e f g h i j k\n"
1276		)
1277	def test_yank_last_arg( self_ ):
1278		self_.check_scenario(
1279			"0123<left><left><m-.><m-.><m-.><cr><c-d>",
1280			"<c9><yellow>0<rst><ceos><c10>"
1281			"<c9><yellow>01<rst><ceos><c11>"
1282			"<c9><yellow>012<rst><ceos><c12>"
1283			"<c9><yellow>0123<rst><ceos><c13>"
1284			"<c9><yellow>0123<rst><ceos><c12>"
1285			"<c9><yellow>0123<rst><ceos><c11>"
1286			"<c9><yellow>01<rst>cat<yellow>23<rst><ceos><c14>"
1287			"<c9><yellow>01<rst>trillion<yellow>23<rst><ceos><c19>"
1288			"<c9><yellow>01<rst>twelve<yellow>23<rst><ceos><c17>"
1289			"<c9><yellow>01<rst>twelve<yellow>23<rst><ceos><c19>\r\n"
1290			"01twelve23\r\n",
1291			"one two three\nten eleven twelve\nmillion trillion\ndog cat\n"
1292		)
1293		self_.check_scenario(
1294			"<up><up><up> <m-.><m-.><cr><c-d>",
1295			"<c9>dog cat<rst><ceos><c16><c9>million trillion<rst><ceos><c25><c9>ten "
1296			"eleven twelve<rst><ceos><c26><c9>ten eleven twelve <rst><ceos><c27><c9>ten "
1297			"eleven twelve cat<rst><ceos><c30><c9>ten eleven twelve "
1298			"trillion<rst><ceos><c35><c9>ten eleven twelve trillion<rst><ceos><c35>\r\n"
1299			"ten eleven twelve trillion\r\n",
1300			"one two three\nten eleven twelve\nmillion trillion\ndog cat\n"
1301		)
1302	def test_tab_completion_cutoff( self_ ):
1303		self_.check_scenario(
1304			"<tab>n<tab>y<cr><c-d>",
1305			"<c9><rst><ceos><c9>\r\n"
1306			"Display all 9 possibilities? (y or n)\r\n"
1307			"<brightgreen>replxx<rst>> "
1308			"<c9><rst><ceos><c9><c9><rst><ceos><c9>\r\n"
1309			"Display all 9 possibilities? (y or n)<ceos>\r\n"
1310			"db            hallo         hansekogge    quetzalcoatl  power\r\n"
1311			"hello         hans          seamann       quit\r\n"
1312			"<brightgreen>replxx<rst>> "
1313			"<c9><rst><ceos><c9><c9><rst><ceos><c9>\r\n",
1314			command = ReplxxTests._cSample_ + " q1 c3"
1315		)
1316		self_.check_scenario(
1317			"<tab>n<cr><c-d>",
1318			"<c9><rst><ceos><c9>\r\n"
1319			"Display all 9 possibilities? (y or n)\r\n"
1320			"<brightgreen>replxx<rst>> "
1321			"<c9><rst><ceos><c9><c9><rst><ceos><c9>\r\n",
1322			command = ReplxxTests._cSample_ + " q1 c3"
1323		)
1324		self_.check_scenario(
1325			"<tab><c-c><cr><c-d>",
1326			"<c9><rst><ceos><c9>\r\n"
1327			"Display all 9 possibilities? (y or n)^C\r\n"
1328			"<brightgreen>replxx<rst>> "
1329			"<c9><rst><ceos><c9><c9><rst><ceos><c9>\r\n",
1330			command = ReplxxTests._cSample_ + " q1 c3"
1331		)
1332		self_.check_scenario(
1333			["<tab>", "<c-c><cr><c-d>"],
1334			"<c9><rst><ceos><c9>\r\n"
1335			"Display all 9 possibilities? (y or n)^C\r\n"
1336			"<brightgreen>replxx<rst>> "
1337			"<c9><rst><ceos><c9><c9><rst><ceos><c9>\r\n",
1338			command = ReplxxTests._cSample_ + " q1 c3 H200"
1339		)
1340	def test_preload( self_ ):
1341		self_.check_scenario(
1342			"<cr><c-d>",
1343			"<c9>Alice has a cat.<rst><ceos><c25>"
1344			"<c9>Alice has a cat.<rst><ceos><c25>\r\n"
1345			"Alice has a cat.\r\n",
1346			command = ReplxxTests._cSample_ + " q1 'iAlice has a cat.'"
1347		)
1348		self_.check_scenario(
1349			"<cr><c-d>",
1350			"<c9>Cat  eats  mice. "
1351			"<rst><ceos><c26><c9>Cat  eats  mice. "
1352			"<rst><ceos><c26>\r\n"
1353			"Cat  eats  mice. "
1354			"\r\n",
1355			command = ReplxxTests._cSample_ + " q1 'iCat\teats\tmice.\r\n'"
1356		)
1357		self_.check_scenario(
1358			"<cr><c-d>",
1359			"<c9>Cat  eats  mice. "
1360			"<rst><ceos><c26><c9>Cat  eats  mice. "
1361			"<rst><ceos><c26>\r\n"
1362			"Cat  eats  mice. "
1363			"\r\n",
1364			command = ReplxxTests._cSample_ + " q1 'iCat\teats\tmice.\r\n\r\n\n\n'"
1365		)
1366		self_.check_scenario(
1367			"<cr><c-d>",
1368			"<c9>M Alice has a cat.<rst><ceos><c27>"
1369			"<c9>M Alice has a cat.<rst><ceos><c27>\r\n"
1370			"M Alice has a cat.\r\n",
1371			command = ReplxxTests._cSample_ + " q1 'iMAlice has a cat.'"
1372		)
1373		self_.check_scenario(
1374			"<cr><c-d>",
1375			"<c9>M  Alice has a cat.<rst><ceos><c28>"
1376			"<c9>M  Alice has a cat.<rst><ceos><c28>\r\n"
1377			"M  Alice has a cat.\r\n",
1378			command = ReplxxTests._cSample_ + " q1 'iM\t\t\t\tAlice has a cat.'"
1379		)
1380	def test_prompt( self_ ):
1381		prompt = "date: now\nrepl> "
1382		self_.check_scenario(
1383			"<up><cr><up><up><cr><c-d>",
1384			"<c7>three<rst><ceos><c12><c7>three<rst><ceos><c12>\r\n"
1385			"three\r\n"
1386			"date: now\r\n"
1387			"repl> "
1388			"<c7>three<rst><ceos><c12><c7>two<rst><ceos><c10><c7>two<rst><ceos><c10>\r\n"
1389			"two\r\n",
1390			command = ReplxxTests._cSample_ + " q1 'p{}'".format( prompt ),
1391			prompt = prompt,
1392			end = prompt + ReplxxTests._end_
1393		)
1394		prompt = "repl>\n"
1395		self_.check_scenario(
1396			"a<cr><c-d>",
1397			"<c1>a<rst><ceos><c2><c1>a<rst><ceos><c2>\r\na\r\n",
1398			command = ReplxxTests._cSample_ + " q1 'p{}'".format( prompt ),
1399			prompt = prompt,
1400			end = prompt + ReplxxTests._end_
1401		)
1402	def test_long_line( self_ ):
1403		self_.check_scenario(
1404			"<up><c-left>~<c-left>~<c-left>~<c-left>~<c-left>~<c-left>~<c-left>~<c-left>~<c-left>~<c-left>~<c-left>~<c-left>~<c-left><cr><c-d>",
1405			"<c9>ada clojure eiffel fortran groovy java kotlin modula perl python "
1406			"rust sql<rst><ceos><c2><u2><c9>ada clojure eiffel fortran groovy "
1407			"java kotlin modula perl python rust sql<rst><ceos><u1><c39><u1><c9>ada "
1408			"clojure eiffel fortran groovy java kotlin modula perl python rust "
1409			"~sql<rst><ceos><u1><c40><u1><c9>ada clojure eiffel fortran groovy java "
1410			"kotlin modula perl python rust ~sql<rst><ceos><u1><c34><u1><c9>ada clojure "
1411			"eiffel fortran groovy java kotlin modula perl python ~rust "
1412			"~sql<rst><ceos><u1><c35><u1><c9>ada clojure eiffel fortran groovy java "
1413			"kotlin modula perl python ~rust ~sql<rst><ceos><u1><c27><u1><c9>ada clojure "
1414			"eiffel fortran groovy java kotlin modula perl ~python ~rust "
1415			"~sql<rst><ceos><u1><c28><u1><c9>ada clojure eiffel fortran groovy java "
1416			"kotlin modula perl ~python ~rust ~sql<rst><ceos><u1><c22><u1><c9>ada clojure "
1417			"eiffel fortran groovy java kotlin modula ~perl ~python ~rust "
1418			"~sql<rst><ceos><u1><c23><u1><c9>ada clojure eiffel fortran groovy java "
1419			"kotlin modula ~perl ~python ~rust ~sql<rst><ceos><u1><c15><u1><c9>ada "
1420			"clojure eiffel fortran groovy java kotlin ~modula ~perl ~python ~rust "
1421			"~sql<rst><ceos><u1><c16><u1><c9>ada clojure eiffel fortran groovy java "
1422			"kotlin ~modula ~perl ~python ~rust ~sql<rst><ceos><u1><c8><u1><c9>ada "
1423			"clojure eiffel fortran groovy java ~kotlin ~modula ~perl ~python ~rust "
1424			"~sql<rst><ceos><u1><c9><u1><c9>ada clojure eiffel fortran groovy java "
1425			"~kotlin ~modula ~perl ~python ~rust ~sql<rst><ceos><u1><c3><u1><c9>ada "
1426			"clojure eiffel fortran groovy ~java ~kotlin ~modula ~perl ~python ~rust "
1427			"~sql<rst><ceos><u1><c4><u1><c9>ada clojure eiffel fortran groovy ~java "
1428			"~kotlin ~modula ~perl ~python ~rust ~sql<rst><ceos><u2><c36><c9>ada clojure "
1429			"eiffel fortran ~groovy ~java ~kotlin ~modula ~perl ~python ~rust "
1430			"~sql<rst><ceos><u2><c37><c9>ada clojure eiffel fortran ~groovy ~java ~kotlin "
1431			"~modula ~perl ~python ~rust ~sql<rst><ceos><u2><c28><c9>ada clojure eiffel "
1432			"~fortran ~groovy ~java ~kotlin ~modula ~perl ~python ~rust "
1433			"~sql<rst><ceos><u2><c29><c9>ada clojure eiffel ~fortran ~groovy ~java "
1434			"~kotlin ~modula ~perl ~python ~rust ~sql<rst><ceos><u2><c21><c9>ada clojure "
1435			"~eiffel ~fortran ~groovy ~java ~kotlin ~modula ~perl ~python ~rust "
1436			"~sql<rst><ceos><u2><c22><c9>ada clojure ~eiffel ~fortran ~groovy ~java "
1437			"~kotlin ~modula ~perl ~python ~rust ~sql<rst><ceos><u2><c13><c9>ada ~clojure "
1438			"~eiffel ~fortran ~groovy ~java ~kotlin ~modula ~perl ~python ~rust "
1439			"~sql<rst><ceos><u2><c14><c9>ada ~clojure ~eiffel ~fortran ~groovy ~java "
1440			"~kotlin ~modula ~perl ~python ~rust ~sql<rst><ceos><u2><c9><c9>~ada ~clojure "
1441			"~eiffel ~fortran ~groovy ~java ~kotlin ~modula ~perl ~python ~rust "
1442			"~sql<rst><ceos><u2><c10><c9>~ada ~clojure ~eiffel ~fortran ~groovy ~java "
1443			"~kotlin ~modula ~perl ~python ~rust ~sql<rst><ceos><u2><c9><c9>~ada ~clojure "
1444			"~eiffel ~fortran ~groovy ~java ~kotlin ~modula ~perl ~python ~rust "
1445			"~sql<rst><ceos><c14>\r\n"
1446			"~ada ~clojure ~eiffel ~fortran ~groovy ~java ~kotlin ~modula ~perl ~python "
1447			"~rust ~sql\r\n",
1448			" ".join( _words_[::3] ) + "\n",
1449			dimensions = ( 10, 40 )
1450		)
1451	def test_colors( self_ ):
1452		self_.check_scenario(
1453			"<up><cr><c-d>",
1454			"<c9><black>color_black<rst> <red>color_red<rst> "
1455			"<green>color_green<rst> <brown>color_brown<rst> <blue>color_blue<rst> "
1456			"<magenta>color_magenta<rst> <cyan>color_cyan<rst> "
1457			"<lightgray>color_lightgray<rst> <gray>color_gray<rst> "
1458			"<brightred>color_brightred<rst> <brightgreen>color_brightgreen<rst> "
1459			"<yellow>color_yellow<rst> <brightblue>color_brightblue<rst> "
1460			"<brightmagenta>color_brightmagenta<rst> <brightcyan>color_brightcyan<rst> "
1461			"<white>color_white<rst><ceos><c70><u2><c9><black>color_black<rst> "
1462			"<red>color_red<rst> <green>color_green<rst> <brown>color_brown<rst> "
1463			"<blue>color_blue<rst> <magenta>color_magenta<rst> <cyan>color_cyan<rst> "
1464			"<lightgray>color_lightgray<rst> <gray>color_gray<rst> "
1465			"<brightred>color_brightred<rst> <brightgreen>color_brightgreen<rst> "
1466			"<yellow>color_yellow<rst> <brightblue>color_brightblue<rst> "
1467			"<brightmagenta>color_brightmagenta<rst> <brightcyan>color_brightcyan<rst> "
1468			"<white>color_white<rst><ceos><c70>\r\n"
1469			"color_black color_red color_green color_brown color_blue color_magenta "
1470			"color_cyan color_lightgray color_gray color_brightred color_brightgreen "
1471			"color_yellow color_brightblue color_brightmagenta color_brightcyan "
1472			"color_white\r\n",
1473			"color_black color_red color_green color_brown color_blue color_magenta color_cyan color_lightgray"
1474			" color_gray color_brightred color_brightgreen color_yellow color_brightblue color_brightmagenta color_brightcyan color_white\n"
1475		)
1476	def test_word_break_characters( self_ ):
1477		self_.check_scenario(
1478			"<up><c-left>x<c-left><c-left>x<c-left><c-left>x<c-left><c-left>x<c-left><c-left>x<c-left><c-left>x<cr><c-d>",
1479			"<c9>one_two three-four five_six "
1480			"seven-eight<rst><ceos><c48><c9>one_two three-four five_six "
1481			"seven-eight<rst><ceos><c43><c9>one_two three-four five_six "
1482			"seven-xeight<rst><ceos><c44><c9>one_two three-four five_six "
1483			"seven-xeight<rst><ceos><c43><c9>one_two three-four five_six "
1484			"seven-xeight<rst><ceos><c37><c9>one_two three-four five_six "
1485			"xseven-xeight<rst><ceos><c38><c9>one_two three-four five_six "
1486			"xseven-xeight<rst><ceos><c37><c9>one_two three-four five_six "
1487			"xseven-xeight<rst><ceos><c28><c9>one_two three-four xfive_six "
1488			"xseven-xeight<rst><ceos><c29><c9>one_two three-four xfive_six "
1489			"xseven-xeight<rst><ceos><c28><c9>one_two three-four xfive_six "
1490			"xseven-xeight<rst><ceos><c23><c9>one_two three-xfour xfive_six "
1491			"xseven-xeight<rst><ceos><c24><c9>one_two three-xfour xfive_six "
1492			"xseven-xeight<rst><ceos><c23><c9>one_two three-xfour xfive_six "
1493			"xseven-xeight<rst><ceos><c17><c9>one_two xthree-xfour xfive_six "
1494			"xseven-xeight<rst><ceos><c18><c9>one_two xthree-xfour xfive_six "
1495			"xseven-xeight<rst><ceos><c17><c9>one_two xthree-xfour xfive_six "
1496			"xseven-xeight<rst><ceos><c9><c9>xone_two xthree-xfour xfive_six "
1497			"xseven-xeight<rst><ceos><c10><c9>xone_two xthree-xfour xfive_six "
1498			"xseven-xeight<rst><ceos><c54>\r\n"
1499			"xone_two xthree-xfour xfive_six xseven-xeight\r\n",
1500			"one_two three-four five_six seven-eight\n",
1501			command = ReplxxTests._cSample_ + " q1 'w \t-'"
1502		)
1503		self_.check_scenario(
1504			"<up><c-left>x<c-left><c-left>x<c-left><c-left>x<c-left><c-left>x<c-left><c-left>x<c-left><c-left>x<cr><c-d>",
1505			"<c9>one_two three-four five_six "
1506			"seven-eight<rst><ceos><c48><c9>one_two three-four five_six "
1507			"seven-eight<rst><ceos><c37><c9>one_two three-four five_six "
1508			"xseven-eight<rst><ceos><c38><c9>one_two three-four five_six "
1509			"xseven-eight<rst><ceos><c37><c9>one_two three-four five_six "
1510			"xseven-eight<rst><ceos><c33><c9>one_two three-four five_xsix "
1511			"xseven-eight<rst><ceos><c34><c9>one_two three-four five_xsix "
1512			"xseven-eight<rst><ceos><c33><c9>one_two three-four five_xsix "
1513			"xseven-eight<rst><ceos><c28><c9>one_two three-four xfive_xsix "
1514			"xseven-eight<rst><ceos><c29><c9>one_two three-four xfive_xsix "
1515			"xseven-eight<rst><ceos><c28><c9>one_two three-four xfive_xsix "
1516			"xseven-eight<rst><ceos><c17><c9>one_two xthree-four xfive_xsix "
1517			"xseven-eight<rst><ceos><c18><c9>one_two xthree-four xfive_xsix "
1518			"xseven-eight<rst><ceos><c17><c9>one_two xthree-four xfive_xsix "
1519			"xseven-eight<rst><ceos><c13><c9>one_xtwo xthree-four xfive_xsix "
1520			"xseven-eight<rst><ceos><c14><c9>one_xtwo xthree-four xfive_xsix "
1521			"xseven-eight<rst><ceos><c13><c9>one_xtwo xthree-four xfive_xsix "
1522			"xseven-eight<rst><ceos><c9><c9>xone_xtwo xthree-four xfive_xsix "
1523			"xseven-eight<rst><ceos><c10><c9>xone_xtwo xthree-four xfive_xsix "
1524			"xseven-eight<rst><ceos><c54>\r\n"
1525			"xone_xtwo xthree-four xfive_xsix xseven-eight\r\n",
1526			"one_two three-four five_six seven-eight\n",
1527			command = ReplxxTests._cSample_ + " q1 'w \t_'"
1528		)
1529	def test_no_color( self_ ):
1530		self_.check_scenario(
1531			"<up> X<cr><c-d>",
1532			"<c9>color_black color_red color_green color_brown color_blue "
1533			"color_magenta color_cyan color_lightgray color_gray color_brightred "
1534			"color_brightgreen color_yellow color_brightblue color_brightmagenta "
1535			"color_brightcyan color_white<ceos><c70><u2><c9>color_black color_red "
1536			"color_green color_brown color_blue color_magenta color_cyan color_lightgray "
1537			"color_gray color_brightred color_brightgreen color_yellow color_brightblue "
1538			"color_brightmagenta color_brightcyan color_white "
1539			"<ceos><c71><u2><c9>color_black color_red color_green color_brown color_blue "
1540			"color_magenta color_cyan color_lightgray color_gray color_brightred "
1541			"color_brightgreen color_yellow color_brightblue color_brightmagenta "
1542			"color_brightcyan color_white X<ceos><c72><u2><c9>color_black color_red "
1543			"color_green color_brown color_blue color_magenta color_cyan color_lightgray "
1544			"color_gray color_brightred color_brightgreen color_yellow color_brightblue "
1545			"color_brightmagenta color_brightcyan color_white X<ceos><c72>\r\n"
1546			"color_black color_red color_green color_brown color_blue color_magenta "
1547			"color_cyan color_lightgray color_gray color_brightred color_brightgreen "
1548			"color_yellow color_brightblue color_brightmagenta color_brightcyan "
1549			"color_white X\r\n",
1550			"color_black color_red color_green color_brown color_blue color_magenta color_cyan color_lightgray"
1551			" color_gray color_brightred color_brightgreen color_yellow color_brightblue color_brightmagenta color_brightcyan color_white\n",
1552			command = ReplxxTests._cSample_ + " q1 m1"
1553		)
1554	def test_backspace_long_line_on_small_term( self_ ):
1555		self_.check_scenario(
1556			"<cr><cr><cr><up><backspace><backspace><backspace><backspace><backspace><backspace><backspace><backspace><cr><c-d>",
1557			"<c9><ceos><c9>\r\n"
1558			"<brightgreen>replxx<rst>> <c9><ceos><c9>\r\n"
1559			"<brightgreen>replxx<rst>> <c9><ceos><c9>\r\n"
1560			"<brightgreen>replxx<rst>> "
1561			"<c9>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<rst><ceos><c14><u1><c9>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<rst><ceos><c13><u1><c9>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<rst><ceos><c12><u1><c9>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<rst><ceos><c11><u1><c9>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<rst><ceos><c10><u1><c9>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<rst><ceos><c9><u1><c9>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<rst><ceos><c8><u1><c9>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<rst><ceos><c7><u1><c9>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<rst><ceos><c6><u1><c9>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<rst><ceos><c6>\r\n"
1562			"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n",
1563			"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n",
1564			dimensions = ( 10, 40 )
1565		)
1566		self_.check_scenario(
1567			"<cr><cr><cr><up><backspace><backspace><backspace><backspace><backspace><backspace><cr><c-d>",
1568			"<c9><ceos><c9>\r\n"
1569			"<brightgreen>replxx<rst>> <c9><ceos><c9>\r\n"
1570			"<brightgreen>replxx<rst>> <c9><ceos><c9>\r\n"
1571			"<brightgreen>replxx<rst>> <c9>a qu ite lo ng li ne of sh ort wo rds wi "
1572			"ll te st cu rs or mo ve me nt<rst><ceos><c39><u1><c9>a qu ite lo "
1573			"ng li ne of sh ort wo rds wi ll te st cu rs or mo ve me "
1574			"n<rst><ceos><c38><u1><c9>a qu ite lo ng li ne of sh ort wo rds wi "
1575			"ll te st cu rs or mo ve me <rst><ceos><c37><u1><c9>a qu ite lo ng "
1576			"li ne of sh ort wo rds wi ll te st cu rs or mo ve "
1577			"me<rst><ceos><c36><u1><c9>a qu ite lo ng li ne of sh ort wo rds "
1578			"wi ll te st cu rs or mo ve m<rst><ceos><c35><u1><c9>a qu ite lo "
1579			"ng li ne of sh ort wo rds wi ll te st cu rs or mo ve "
1580			"<rst><ceos><c34><u1><c9>a qu ite lo ng li ne of sh ort wo rds wi "
1581			"ll te st cu rs or mo ve<rst><ceos><c33><u1><c9>a qu ite lo ng li "
1582			"ne of sh ort wo rds wi ll te st cu rs or mo ve<rst><ceos><c33>\r\n"
1583			"a qu ite lo ng li ne of sh ort wo rds wi ll te st cu rs or mo ve\r\n",
1584			"a qu ite lo ng li ne of sh ort wo rds wi ll te st cu rs or mo ve me nt\n",
1585			dimensions = ( 10, 40 )
1586		)
1587	def test_reverse_history_search_on_max_match( self_ ):
1588		self_.check_scenario(
1589			"<up><c-r><cr><c-d>",
1590			"<c9>aaaaaaaaaaaaaaaaaaaaa<rst><ceos><c30><c1><ceos><c1><ceos>(reverse-i-search)`': "
1591			"aaaaaaaaaaaaaaaaaaaaa<c44><c1><ceos><brightgreen>replxx<rst>> "
1592			"aaaaaaaaaaaaaaaaaaaaa<c30><c9>aaaaaaaaaaaaaaaaaaaaa<rst><ceos><c30>\r\n"
1593			"aaaaaaaaaaaaaaaaaaaaa\r\n",
1594			"aaaaaaaaaaaaaaaaaaaaa\n"
1595		)
1596	def test_no_terminal( self_ ):
1597		res = subprocess.run( [ ReplxxTests._cSample_, "q1" ], input = b"replxx FTW!\n", stdout = subprocess.PIPE, stderr = subprocess.PIPE )
1598		self_.assertSequenceEqual( res.stdout, b"starting...\nreplxx FTW!\n\nExiting Replxx\n" )
1599	def test_async_print( self_ ):
1600		self_.check_scenario(
1601			[ "a", "b", "c", "d", "e", "f<cr><c-d>" ], [
1602				"<c1><ceos>0\r\n"
1603				"<brightgreen>replxx<rst>> "
1604				"<c9><ceos><c9><c9>a<rst><ceos><c10><c9>ab<rst><ceos><c11><c1><ceos>1\r\n"
1605				"<brightgreen>replxx<rst>> "
1606				"<c9>ab<rst><ceos><c11><c9>abc<rst><ceos><c12><c9>abcd<rst><ceos><c13><c1><ceos>2\r\n"
1607				"<brightgreen>replxx<rst>> "
1608				"<c9>abcd<rst><ceos><c13><c9>abcde<rst><ceos><c14><c9>abcdef<rst><ceos><c15><c9>abcdef<rst><ceos><c15>\r\n"
1609				"abcdef\r\n",
1610				"<c1><ceos>0\r\n"
1611				"<brightgreen>replxx<rst>> "
1612				"<c9>a<rst><ceos><c10><c9>ab<rst><ceos><c11><c1><ceos>1\r\n"
1613				"<brightgreen>replxx<rst>> "
1614				"<c9>ab<rst><ceos><c11><c9>abc<rst><ceos><c12><c9>abcd<rst><ceos><c13><c1><ceos>2\r\n"
1615				"<brightgreen>replxx<rst>> "
1616				"<c9>abcd<rst><ceos><c13><c9>abcde<rst><ceos><c14><c9>abcdef<rst><ceos><c15><c9>abcdef<rst><ceos><c15>\r\n"
1617				"abcdef\r\n",
1618			],
1619			command = [ ReplxxTests._cxxSample_, "" ],
1620			pause = 0.5
1621		)
1622		self_.check_scenario(
1623			[ "<up>", "a", "b", "c", "d", "e", "f<cr><c-d>" ], [
1624				"<c1><ceos>0\r\n"
1625				"<brightgreen>replxx<rst>> <c9><ceos><c9><c9>a very long line of "
1626				"user input, wider then current terminal, the line is wrapped: "
1627				"<rst><ceos><c11><u2><c9>a very long line of user input, wider then current "
1628				"terminal, the line is wrapped: a<rst><ceos><c12><u2><c1><ceos>1\r\n"
1629				"<brightgreen>replxx<rst>> \r\n"
1630				"\r\n"
1631				"<u2><c9>a very long line of user input, wider then current terminal, "
1632				"the line is wrapped: a<rst><ceos><c12><u2><c9>a very long line of user "
1633				"input, wider then current terminal, the line is wrapped: "
1634				"ab<rst><ceos><c13><u2><c9>a very long line of user input, wider then current "
1635				"terminal, the line is wrapped: abc<rst><ceos><c14><u2><c1><ceos>2\r\n"
1636				"<brightgreen>replxx<rst>> \r\n"
1637				"\r\n"
1638				"<u2><c9>a very long line of user input, wider then current terminal, "
1639				"the line is wrapped: abc<rst><ceos><c14><u2><c9>a very long line of user "
1640				"input, wider then current terminal, the line is wrapped: "
1641				"abcd<rst><ceos><c15><u2><c9>a very long line of user input, wider then "
1642				"current terminal, the line is wrapped: abcde<rst><ceos><c16><u2><c1><ceos>3\r\n"
1643				"<brightgreen>replxx<rst>> \r\n"
1644				"\r\n"
1645				"<u2><c9>a very long line of user input, wider then current terminal, "
1646				"the line is wrapped: abcde<rst><ceos><c16><u2><c9>a very long line of user "
1647				"input, wider then current terminal, the line is wrapped: "
1648				"abcdef<rst><ceos><c17><u2><c9>a very long line of user input, wider then "
1649				"current terminal, the line is wrapped: abcdef<rst><ceos><c17>\r\n"
1650				"a very long line of user input, wider then current terminal, the line is "
1651				"wrapped: abcdef\r\n",
1652				"<c1><ceos>0\r\n"
1653				"<brightgreen>replxx<rst>> <c9><ceos><c9><c9>a very long line of user input, "
1654				"wider then current terminal, the line is wrapped: <rst><ceos><c11><u2><c9>a "
1655				"very long line of user input, wider then current terminal, the line is "
1656				"wrapped: a<rst><ceos><c12><u2><c1><ceos>1\r\n"
1657				"<brightgreen>replxx<rst>> \r\n"
1658				"\r\n"
1659				"<u2><c9>a very long line of user input, wider then current terminal, the "
1660				"line is wrapped: a<rst><ceos><c12><u2><c9>a very long line of user input, "
1661				"wider then current terminal, the line is wrapped: "
1662				"ab<rst><ceos><c13><u2><c9>a very long line of user input, wider then current "
1663				"terminal, the line is wrapped: abc<rst><ceos><c14><u2><c1><ceos>2\r\n"
1664				"<brightgreen>replxx<rst>> \r\n"
1665				"\r\n"
1666				"<u2><c9>a very long line of user input, wider then current terminal, the "
1667				"line is wrapped: abc<rst><ceos><c14><u2><c9>a very long line of user input, "
1668				"wider then current terminal, the line is wrapped: "
1669				"abcd<rst><ceos><c15><u2><c1><ceos>3\r\n"
1670				"<brightgreen>replxx<rst>> \r\n"
1671				"\r\n"
1672				"<u2><c9>a very long line of user input, wider then current terminal, the "
1673				"line is wrapped: abcd<rst><ceos><c15><u2><c9>a very long line of user input, "
1674				"wider then current terminal, the line is wrapped: "
1675				"abcde<rst><ceos><c16><u2><c9>a very long line of user input, wider then "
1676				"current terminal, the line is wrapped: abcdef<rst><ceos><c17><u2><c9>a very "
1677				"long line of user input, wider then current terminal, the line is wrapped: "
1678				"abcdef<rst><ceos><c17>\r\n"
1679				"a very long line of user input, wider then current terminal, the line is "
1680				"wrapped: abcdef\r\n",
1681				"<c1><ceos>0\r\n"
1682				"<brightgreen>replxx<rst>> <c9>a very long line of user input, wider then "
1683				"current terminal, the line is wrapped: <rst><ceos><c11><u2><c9>a very long "
1684				"line of user input, wider then current terminal, the line is wrapped: "
1685				"a<rst><ceos><c12><u2><c1><ceos>1\r\n"
1686				"<brightgreen>replxx<rst>> \r\n"
1687				"\r\n"
1688				"<u2><c9>a very long line of user input, wider then current terminal, the "
1689				"line is wrapped: a<rst><ceos><c12><u2><c9>a very long line of user input, "
1690				"wider then current terminal, the line is wrapped: "
1691				"ab<rst><ceos><c13><u2><c9>a very long line of user input, wider then current "
1692				"terminal, the line is wrapped: abc<rst><ceos><c14><u2><c1><ceos>2\r\n"
1693				"<brightgreen>replxx<rst>> \r\n"
1694				"\r\n"
1695				"<u2><c9>a very long line of user input, wider then current terminal, the "
1696				"line is wrapped: abc<rst><ceos><c14><u2><c9>a very long line of user input, "
1697				"wider then current terminal, the line is wrapped: "
1698				"abcd<rst><ceos><c15><u2><c1><ceos>3\r\n"
1699				"<brightgreen>replxx<rst>> \r\n"
1700				"\r\n"
1701				"<u2><c9>a very long line of user input, wider then current terminal, the "
1702				"line is wrapped: abcd<rst><ceos><c15><u2><c9>a very long line of user input, "
1703				"wider then current terminal, the line is wrapped: "
1704				"abcde<rst><ceos><c16><u2><c9>a very long line of user input, wider then "
1705				"current terminal, the line is wrapped: abcdef<rst><ceos><c17><u2><c9>a very "
1706				"long line of user input, wider then current terminal, the line is wrapped: "
1707				"abcdef<rst><ceos><c17>\r\n"
1708				"a very long line of user input, wider then current terminal, the line is "
1709				"wrapped: abcdef\r\n"
1710			],
1711			"a very long line of user input, wider then current terminal, the line is wrapped: \n",
1712			command = [ ReplxxTests._cxxSample_, "" ],
1713			dimensions = ( 10, 40 ),
1714			pause = 0.5
1715		)
1716	def test_async_emulate_key_press( self_ ):
1717		self_.check_scenario(
1718			[ "a", "b", "c", "d", "e", "f<cr><c-d>" ], [
1719				"<c9><yellow>1<rst><ceos><c10><c9><yellow>1<rst>a"
1720				"<rst><ceos><c11><c9><yellow>1<rst>ab<rst><ceos><c12><c9><yellow>1<rst>ab"
1721				"<yellow>2<rst><ceos><c13><c9><yellow>1<rst>ab<yellow>2"
1722				"<rst>c<rst><ceos><c14><c9><yellow>1<rst>ab<yellow>2"
1723				"<rst>cd<rst><ceos><c15><c9><yellow>1<rst>ab<yellow>2<rst>cd<yellow>3"
1724				"<rst><ceos><c16><c9><yellow>1<rst>ab<yellow>2<rst>cd<yellow>3<rst>e"
1725				"<rst><ceos><c17><c9><yellow>1<rst>ab<yellow>2<rst>cd<yellow>3<rst>ef"
1726				"<rst><ceos><c18><c9><yellow>1<rst>ab<yellow>2<rst>cd<yellow>3<rst>ef<rst><ceos><c18>\r\n"
1727				"1ab2cd3ef\r\n",
1728				"<c9><yellow>1<rst>a<rst><ceos><c11><c9><yellow>1<rst>ab"
1729				"<rst><ceos><c12><c9><yellow>1<rst>ab<yellow>2<rst><ceos><c13><c9><yellow>1<rst>ab"
1730				"<yellow>2<rst>c<rst><ceos><c14><c9><yellow>1<rst>ab<yellow>2<rst>cd<rst><ceos><c15>"
1731				"<c9><yellow>1<rst>ab<yellow>2<rst>cd<yellow>3<rst><ceos><c16><c9><yellow>1<rst>ab"
1732				"<yellow>2<rst>cd<yellow>3<rst>e<rst><ceos><c17><c9><yellow>1<rst>ab<yellow>2<rst>cd"
1733				"<yellow>3<rst>ef<rst><ceos><c18><c9><yellow>1<rst>ab<yellow>2<rst>cd<yellow>3<rst>ef<rst><ceos><c18>\r\n"
1734				"1ab2cd3ef\r\n"
1735			],
1736			command = [ ReplxxTests._cxxSample_, "123456" ],
1737			pause = 0.5
1738		)
1739	def test_special_keys( self_ ):
1740		self_.check_scenario(
1741			"<f1><f2><f3><f4><f5><f6><f7><f8><f9><f10><f11><f12>"
1742			"<s-f1><s-f2><s-f3><s-f4><s-f5><s-f6><s-f7><s-f8><s-f9><s-f10><s-f11><s-f12>"
1743			"<c-f1><c-f2><c-f3><c-f4><c-f5><c-f6><c-f7><c-f8><c-f9><c-f10><c-f11><c-f12>"
1744			"<s-tab><s-left><s-right><s-up><s-down>"
1745			"<s-home><s-end><c-home><c-end><c-pgup><c-pgdown>"
1746			"<cr><c-d>",
1747			"<c1><ceos><F1>\r\n"
1748			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><F2>\r\n"
1749			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><F3>\r\n"
1750			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><F4>\r\n"
1751			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><F5>\r\n"
1752			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><F6>\r\n"
1753			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><F7>\r\n"
1754			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><F8>\r\n"
1755			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><F9>\r\n"
1756			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><F10>\r\n"
1757			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><F11>\r\n"
1758			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><F12>\r\n"
1759			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-F1>\r\n"
1760			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-F2>\r\n"
1761			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-F3>\r\n"
1762			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-F4>\r\n"
1763			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-F5>\r\n"
1764			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-F6>\r\n"
1765			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-F7>\r\n"
1766			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-F8>\r\n"
1767			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-F9>\r\n"
1768			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-F10>\r\n"
1769			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-F11>\r\n"
1770			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-F12>\r\n"
1771			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><C-F1>\r\n"
1772			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><C-F2>\r\n"
1773			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><C-F3>\r\n"
1774			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><C-F4>\r\n"
1775			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><C-F5>\r\n"
1776			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><C-F6>\r\n"
1777			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><C-F7>\r\n"
1778			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><C-F8>\r\n"
1779			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><C-F9>\r\n"
1780			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><C-F10>\r\n"
1781			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><C-F11>\r\n"
1782			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><C-F12>\r\n"
1783			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-Tab>\r\n"
1784			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-Left>\r\n"
1785			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-Right>\r\n"
1786			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-Up>\r\n"
1787			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-Down>\r\n"
1788			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-Home>\r\n"
1789			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-End>\r\n"
1790			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><C-Home>\r\n"
1791			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><C-End>\r\n"
1792			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><C-PgUp>\r\n"
1793			"<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><C-PgDn>\r\n"
1794			"<brightgreen>replxx<rst>> <c9><ceos><c9><c9><ceos><c9>\r\n"
1795		)
1796	def test_overwrite_mode( self_ ):
1797		self_.check_scenario(
1798			"<up><home><right><right>XYZ<ins>012<ins>345<cr><c-d>",
1799			"<c9>abcdefgh<rst><ceos><c17><c9>abcdefgh<rst><ceos><c9>"
1800			"<c9>abcdefgh<rst><ceos><c10><c9>abcdefgh<rst><ceos><c11>"
1801			"<c9>abXcdefgh<rst><ceos><c12><c9>abXYcdefgh<rst><ceos><c13>"
1802			"<c9>abXYZcdefgh<rst><ceos><c14><c9>abXYZ<yellow>0<rst>defgh<rst><ceos><c15>"
1803			"<c9>abXYZ<yellow>01<rst>efgh<rst><ceos><c16><c9>abXYZ<yellow>012<rst>fgh<rst><ceos><c17>"
1804			"<c9>abXYZ<yellow>0123<rst>fgh<rst><ceos><c18><c9>abXYZ<yellow>01234<rst>fgh<rst><ceos><c19>"
1805			"<c9>abXYZ<yellow>012345<rst>fgh<rst><ceos><c20><c9>abXYZ<yellow>012345<rst>fgh<rst><ceos><c23>\r\n"
1806			"abXYZ012345fgh\r\n",
1807			"abcdefgh\n"
1808		)
1809	def test_verbatim_insert( self_ ):
1810		self_.check_scenario(
1811			["<c-v>", rapid( "<ins>" ), "<cr><c-d>"],
1812			"<c9>^[<brightmagenta>[<yellow>2<rst>~<rst><ceos><c14><c9>^[<brightmagenta>[<yellow>2<rst>~<rst><ceos><c14>\r\n"
1813			"<ins-key>\r\n"
1814		)
1815	def test_hint_delay( self_ ):
1816		self_.check_scenario(
1817			["han", "<cr><c-d>"],
1818			"<c9>h<rst><ceos><c10><c9>ha<rst><ceos><c11><c9>han<rst><ceos><c12><c9>han<rst><ceos>\r\n"
1819			"        <gray>hans<rst>\r\n"
1820			"        <gray>hansekogge<rst><u2><c12><c9>han<rst><ceos><c12>\r\n"
1821			"han\r\n",
1822			command = [ ReplxxTests._cSample_, "q1", "H200" ]
1823		)
1824	def test_complete_next( self_ ):
1825		self_.check_scenario(
1826			"<up><c-n><c-n><c-p><c-p><c-p><cr><c-d>",
1827			"<c9>color_<rst><ceos>\r\n"
1828			"        <gray>color_black<rst>\r\n"
1829			"        <gray>color_red<rst>\r\n"
1830			"        "
1831			"<gray>color_green<rst><u3><c15><c9><black>color_black<rst><ceos><c20>"
1832			"<c9><red>color_red<rst><ceos><c18><c9><black>color_black<rst><ceos><c20><c9>color_<rst><ceos>\r\n"
1833
1834			"        <gray>color_black<rst>\r\n"
1835			"        <gray>color_red<rst>\r\n"
1836			"        "
1837			"<gray>color_green<rst><u3><c15><c9><lightgray>color_normal<rst><ceos><c21><c9><lightgray>color_normal<rst><ceos><c21>\r\n"
1838			"color_normal\r\n",
1839			"color_\n"
1840		)
1841		self_.check_scenario(
1842			"l<c-n><c-n><c-p><c-p><cr><c-d>",
1843			"<c9>l<rst><ceos>\r\n"
1844			"        <gray>lc_ctype<rst>\r\n"
1845			"        <gray>lc_time<rst>\r\n"
1846			"        <gray>lc_messages<rst><u3><c10><c9>lc_<rst><ceos>\r\n"
1847			"        <gray>lc_ctype<rst>\r\n"
1848			"        <gray>lc_time<rst>\r\n"
1849			"        "
1850			"<gray>lc_messages<rst><u3><c12><c9>lc_ctype<rst><ceos><c17><c9>lc_time<rst><ceos><c16><c9>lc_ctype<rst><ceos><c17><c9>lc_<rst><ceos>\r\n"
1851			"        <gray>lc_ctype<rst>\r\n"
1852			"        <gray>lc_time<rst>\r\n"
1853			"        <gray>lc_messages<rst><u3><c12><c9>lc_<rst><ceos><c12>\r\n"
1854			"lc_\r\n",
1855			command = [ ReplxxTests._cSample_, "xlc_ctype,lc_time,lc_messages,zoom", "I1", "q1" ]
1856		)
1857		self_.check_scenario(
1858			"l<c-n><c-n><c-p><c-p><cr><c-d>",
1859			"<c9>l<rst><ceos>\r\n"
1860			"        <gray>lc_ctype<rst>\r\n"
1861			"        <gray>lc_time<rst>\r\n"
1862			"        <gray>lc_messages<rst><u3><c10><c9>lc_<rst><ceos>\r\n"
1863			"        <gray>lc_ctype<rst>\r\n"
1864			"        <gray>lc_time<rst>\r\n"
1865			"        "
1866			"<gray>lc_messages<rst><u3><c12><c9>lc_ctype<rst><ceos><c17><c9>lc_<rst><ceos>\r\n"
1867			"        <gray>lc_ctype<rst>\r\n"
1868			"        <gray>lc_time<rst>\r\n"
1869			"        "
1870			"<gray>lc_messages<rst><u3><c12><c9>lc_messages<rst><ceos><c20><c9>lc_messages<rst><ceos><c20>\r\n"
1871			"lc_messages\r\n",
1872			command = [ ReplxxTests._cSample_, "xlc_ctype,lc_time,lc_messages,zoom", "I0", "q1" ]
1873		)
1874	def test_disabled_handlers( self_ ):
1875		self_.check_scenario(
1876			"<up><left><backspace>4<cr><c-d>",
1877			"<c9>(+ 1 2)<rst><ceos><c16><c9><brightred>(<rst>+ 1 "
1878			"2)<rst><ceos><c15><c9><brightred>(<rst>+ 1 "
1879			")<rst><ceos><c14><c9><brightred>(<rst>+ 1 "
1880			"4)<rst><ceos><c15><c9><brightred>(<rst>+ 1 4)<rst><ceos><c16>\r\n"
1881			"thanks for the input: (+ 1 4)\r\n",
1882			"(+ 1 2)\r\n",
1883			command = [ ReplxxTests._cSample_, "N", "S" ]
1884		)
1885	def test_state_manipulation( self_ ):
1886		self_.check_scenario(
1887			"<up><f2>~<cr><c-d>",
1888			"<c9>replxx<rst><ceos><c15><c9>REPLXX<rst><ceos><c12><c9>REP~LXX<rst><ceos><c13><c9>REP~LXX<rst><ceos><c16>\r\n"
1889			"REP~LXX\r\n",
1890			"replxx\n",
1891			command = [ ReplxxTests._cSample_, "q1" ]
1892		)
1893	def test_modify_callback( self_ ):
1894		self_.check_scenario(
1895			"<up><home><right><right>*<cr><c-d>",
1896			"<c9>abcd<brightmagenta>12<rst><ceos><c15><c9>abcd<brightmagenta>12<rst><ceos><c9>"
1897			"<c9>abcd<brightmagenta>12<rst><ceos><c10><c9>abcd<brightmagenta>12<rst><ceos><c11>"
1898			"<c9>ababcd<brightmagenta>12<rst>cd<brightmagenta>12<rst><ceos><c15>"
1899			"<c9>ababcd<brightmagenta>12<rst>cd<brightmagenta>12<rst><ceos><c21>\r\n"
1900			"ababcd12cd12\r\n",
1901			"abcd12\n",
1902			command = [ ReplxxTests._cSample_, "q1", "M1" ]
1903		)
1904	def test_paste( self_ ):
1905		self_.check_scenario(
1906			rapid( "abcdef<cr><c-d>" ),
1907			"<c9>a<rst><ceos><c10><c9>abcdef<rst><ceos><c15>\r\nabcdef\r\n"
1908		)
1909	def test_history_merge( self_ ):
1910		with open( "replxx_history_alt.txt", "w" ) as f:
1911			f.write(
1912				"### 0000-00-00 00:00:00.001\n"
1913				"one\n"
1914				"### 0000-00-00 00:00:00.003\n"
1915				"three\n"
1916				"### 0000-00-00 00:00:00.005\n"
1917				"other\n"
1918				"### 0000-00-00 00:00:00.009\n"
1919				"same\n"
1920				"### 0000-00-00 00:00:00.017\n"
1921				"seven\n"
1922			)
1923			f.close()
1924		self_.check_scenario(
1925			"<up><cr><c-d>",
1926			"<c9><brightmagenta>.<rst>merge<rst><ceos><c15><c9><brightmagenta>.<rst>merge<rst><ceos><c15>\r\n",
1927			"### 0000-00-00 00:00:00.002\n"
1928			"two\n"
1929			"### 0000-00-00 00:00:00.004\n"
1930			"four\n"
1931			"### 0000-00-00 00:00:00.006\n"
1932			"same\n"
1933			"### 0000-00-00 00:00:00.008\n"
1934			"other\n"
1935			"### 0000-00-00 00:00:00.018\n"
1936			".merge\n"
1937		)
1938		with open( "replxx_history_alt.txt", "r" ) as f:
1939			data = f.read()
1940			expected = (
1941				"### 0000-00-00 00:00:00.001\n"
1942				"one\n"
1943				"### 0000-00-00 00:00:00.002\n"
1944				"two\n"
1945				"### 0000-00-00 00:00:00.003\n"
1946				"three\n"
1947				"### 0000-00-00 00:00:00.004\n"
1948				"four\n"
1949				"### 0000-00-00 00:00:00.008\n"
1950				"other\n"
1951				"### 0000-00-00 00:00:00.009\n"
1952				"same\n"
1953				"### 0000-00-00 00:00:00.017\n"
1954				"seven\n"
1955				"### "
1956			)
1957			self_.assertSequenceEqual( data[:-31], expected )
1958			self_.assertSequenceEqual( data[-7:], ".merge\n" )
1959	def test_history_save( self_ ):
1960		with open( "replxx_history_alt.txt", "w" ) as f:
1961			f.write(
1962				"### 0000-00-00 00:00:00.001\n"
1963				"one\n"
1964				"### 0000-00-00 00:00:00.003\n"
1965				"three\n"
1966				"### 3000-00-00 00:00:00.005\n"
1967				"other\n"
1968				"### 3000-00-00 00:00:00.009\n"
1969				"same\n"
1970				"### 3000-00-00 00:00:00.017\n"
1971				"seven\n"
1972			)
1973			f.close()
1974		self_.check_scenario(
1975			"zoom<cr>.save<cr><up><cr><c-d>",
1976			"<c9>z<rst><ceos><c10><c9>zo<rst><ceos><c11><c9>zoo<rst><ceos><c12><c9>zoom<rst><ceos><c13><c9>zoom<rst><ceos><c13>\r\n"
1977			"zoom\r\n"
1978			"<brightgreen>replxx<rst>> "
1979			"<c9><brightmagenta>.<rst><ceos><c10><c9><brightmagenta>.<rst>s<rst><ceos><c11><c9><brightmagenta>.<rst>sa<rst><ceos><c12><c9><brightmagenta>.<rst>sav<rst><ceos><c13><c9><brightmagenta>.<rst>save<rst><ceos><c14><c9><brightmagenta>.<rst>save<rst><ceos><c14>\r\n"
1980			"<brightgreen>replxx<rst>> "
1981			"<c9>zoom<rst><ceos><c13><c9>zoom<rst><ceos><c13>\r\n"
1982			"zoom\r\n"
1983		)
1984	def test_bracketed_paste( self_ ):
1985		self_.check_scenario(
1986			"a0<paste-pfx>b1c2d3e<paste-sfx>4f<cr><c-d>",
1987			"<c9>a<rst><ceos><c10>"
1988			"<c9>a<brightmagenta>0<rst><ceos><c11>"
1989			"<c9>a<brightmagenta>0<rst>b<brightmagenta>1<rst>c<brightmagenta>2<rst>d<brightmagenta>3<rst>e<rst><ceos><c18>"
1990			"<c9>a<brightmagenta>0<rst>b<brightmagenta>1<rst>c<brightmagenta>2<rst>d<brightmagenta>3<rst>e<brightmagenta>4<rst><ceos><c19>"
1991			"<c9>a<brightmagenta>0<rst>b<brightmagenta>1<rst>c<brightmagenta>2<rst>d<brightmagenta>3<rst>e<brightmagenta>4<rst>f<rst><ceos><c20>"
1992			"<c9>a<brightmagenta>0<rst>b<brightmagenta>1<rst>c<brightmagenta>2<rst>d<brightmagenta>3<rst>e<brightmagenta>4<rst>f<rst><ceos><c20>\r\n"
1993			"a0b1c2d3e4f\r\n",
1994			command = [ ReplxxTests._cSample_, "q1" ]
1995		)
1996		self_.check_scenario(
1997			"a0<paste-pfx>b1c2d3e<paste-sfx>4f<cr><c-d>",
1998			"<c9>a<rst><ceos><c10>"
1999			"<c9>a<brightmagenta>0<rst><ceos><c11>"
2000			"<c9>a<brightmagenta>0<rst>b<brightmagenta>1<rst>c<brightmagenta>2<rst>d<brightmagenta>3<rst>e<rst><ceos><c18>"
2001			"<c9>a<brightmagenta>0<rst>b<brightmagenta>1<rst>c<brightmagenta>2<rst>d<brightmagenta>3<rst>e<brightmagenta>4<rst><ceos><c19>"
2002			"<c9>a<brightmagenta>0<rst>b<brightmagenta>1<rst>c<brightmagenta>2<rst>d<brightmagenta>3<rst>e<brightmagenta>4<rst>f<rst><ceos><c20>"
2003			"<c9>a<brightmagenta>0<rst>b<brightmagenta>1<rst>c<brightmagenta>2<rst>d<brightmagenta>3<rst>e<brightmagenta>4<rst>f<rst><ceos><c20>\r\n"
2004			"a0b1c2d3e4f\r\n",
2005			command = [ ReplxxTests._cSample_, "q1", "B" ]
2006		)
2007		self_.check_scenario(
2008			"a0<left><paste-pfx>/eb<paste-sfx><cr><paste-pfx>/db<paste-sfx><cr><paste-pfx>x<paste-sfx><cr><c-d>",
2009			"<c9>a<rst><ceos><c10><c9>a<brightmagenta>0<rst><ceos><c11><c9>a<brightmagenta>0<rst><ceos><c10>"
2010			"<c9>a/eb<brightmagenta>0<rst><ceos><c13><c9>a/eb<brightmagenta>0<rst><ceos><c14>\r\n"
2011			"a/eb0\r\n"
2012			"<brightgreen>replxx<rst>> <c9>/db<rst><ceos><c12><c9>/db<rst><ceos><c12>\r\n"
2013			"/db\r\n"
2014			"<brightgreen>replxx<rst>> <c9>x<rst><ceos><c10><c9>x<rst><ceos><c10>\r\n"
2015			"x\r\n",
2016			command = [ ReplxxTests._cSample_, "q1" ]
2017		)
2018
2019def parseArgs( self, func, argv ):
2020	global verbosity
2021	res = func( self, argv )
2022	verbosity = self.verbosity
2023	return res
2024
2025if __name__ == "__main__":
2026	pa = unittest.TestProgram.parseArgs
2027	unittest.TestProgram.parseArgs = lambda self, argv: parseArgs( self, pa, argv )
2028	unittest.main()
2029
2030