Show More
@@ -334,15 +334,20 b' class LineFrontEndBase(FrontEndBase):' | |||
|
334 | 334 | self.execute(cleaned_buffer, raw_string=current_buffer) |
|
335 | 335 | return True |
|
336 | 336 | else: |
|
337 | # Start a new line. | |
|
337 | 338 | new_line_pos = -new_line_pos |
|
338 | 339 | lines = current_buffer.split('\n')[:-1] |
|
339 | 340 | prompt_less_lines = prompt_less_buffer.split('\n') |
|
341 | # Create the new line, with the continuation prompt, and the | |
|
342 | # same amount of indent than the line above it. | |
|
340 | 343 | new_line = self.continuation_prompt() + \ |
|
341 | 344 | self._get_indent_string('\n'.join( |
|
342 | 345 | prompt_less_lines[:new_line_pos-1])) |
|
343 | 346 | if len(lines) == 1: |
|
347 | # We are starting a first continuation line. Indent it. | |
|
344 | 348 | new_line += '\t' |
|
345 | 349 | elif current_buffer[:-1].split('\n')[-1].rstrip().endswith(':'): |
|
350 | # The last line ends with ":", autoindent the new line. | |
|
346 | 351 | new_line += '\t' |
|
347 | 352 | |
|
348 | 353 | if new_line_pos == 0: |
|
1 | NO CONTENT: file renamed from IPython/frontend/_process/__init__.py to IPython/frontend/process/__init__.py |
|
1 | NO CONTENT: file renamed from IPython/frontend/_process/killableprocess.py to IPython/frontend/process/killableprocess.py |
|
1 | NO CONTENT: file renamed from IPython/frontend/_process/pipedprocess.py to IPython/frontend/process/pipedprocess.py |
|
1 | NO CONTENT: file renamed from IPython/frontend/_process/winprocess.py to IPython/frontend/process/winprocess.py |
@@ -14,6 +14,7 b' __docformat__ = "restructuredtext en"' | |||
|
14 | 14 | |
|
15 | 15 | from IPython.frontend.linefrontendbase import LineFrontEndBase |
|
16 | 16 | from copy import deepcopy |
|
17 | import nose.tools as nt | |
|
17 | 18 | |
|
18 | 19 | class ConcreteLineFrontEnd(LineFrontEndBase): |
|
19 | 20 | """ A concrete class to test the LineFrontEndBase. |
@@ -29,10 +30,8 b' def test_is_complete():' | |||
|
29 | 30 | """ Tests line completion heuristic. |
|
30 | 31 | """ |
|
31 | 32 | frontend = ConcreteLineFrontEnd() |
|
32 | assert not frontend.is_complete('for x in \\') | |
|
33 | assert not frontend.is_complete('for x in (1, ):') | |
|
34 | assert frontend.is_complete('for x in (1, ):\n pass') | |
|
33 | yield nt.assert_true, not frontend.is_complete('for x in \\') | |
|
34 | yield nt.assert_true, not frontend.is_complete('for x in (1, ):') | |
|
35 | yield nt.assert_true, frontend.is_complete('for x in (1, ):\n pass') | |
|
35 | 36 | |
|
36 | 37 | |
|
37 | if __name__ == '__main__': | |
|
38 | test_is_complete() |
@@ -111,20 +111,20 b' def test_multiline():' | |||
|
111 | 111 | f.input_buffer += 'print 1' |
|
112 | 112 | f._on_enter() |
|
113 | 113 | out_value = f.out.getvalue() |
|
114 |
assert_equal |
|
|
114 | yield assert_equal, out_value, '' | |
|
115 | 115 | f._on_enter() |
|
116 | 116 | out_value = f.out.getvalue() |
|
117 |
assert_equal |
|
|
117 | yield assert_equal, out_value, '1\n' | |
|
118 | 118 | f = TestPrefilterFrontEnd() |
|
119 | 119 | f.input_buffer='(1 +' |
|
120 | 120 | f._on_enter() |
|
121 | 121 | f.input_buffer += '0)' |
|
122 | 122 | f._on_enter() |
|
123 | 123 | out_value = f.out.getvalue() |
|
124 |
assert_equal |
|
|
124 | yield assert_equal, out_value, '' | |
|
125 | 125 | f._on_enter() |
|
126 | 126 | out_value = f.out.getvalue() |
|
127 |
assert_equal |
|
|
127 | yield assert_equal, out_value, '1\n' | |
|
128 | 128 | |
|
129 | 129 | |
|
130 | 130 | @isolate_ipython0 |
@@ -137,13 +137,13 b' def test_capture():' | |||
|
137 | 137 | 'import os; out=os.fdopen(1, "w"); out.write("1") ; out.flush()' |
|
138 | 138 | f._on_enter() |
|
139 | 139 | out_value = f.out.getvalue() |
|
140 |
assert_equal |
|
|
140 | yield assert_equal, out_value, '1' | |
|
141 | 141 | f = TestPrefilterFrontEnd() |
|
142 | 142 | f.input_buffer = \ |
|
143 | 143 | 'import os; out=os.fdopen(2, "w"); out.write("1") ; out.flush()' |
|
144 | 144 | f._on_enter() |
|
145 | 145 | out_value = f.out.getvalue() |
|
146 |
assert_equal |
|
|
146 | yield assert_equal, out_value, '1' | |
|
147 | 147 | |
|
148 | 148 | |
|
149 | 149 | @isolate_ipython0 |
@@ -191,8 +191,8 b' def test_completion_simple():' | |||
|
191 | 191 | f.input_buffer = 'zz' |
|
192 | 192 | f.complete_current_input() |
|
193 | 193 | out_value = f.out.getvalue() |
|
194 |
assert_equal |
|
|
195 |
assert_equal |
|
|
194 | yield assert_equal, out_value, '\nzzza zzzb ' | |
|
195 | yield assert_equal, f.input_buffer, 'zzz' | |
|
196 | 196 | |
|
197 | 197 | |
|
198 | 198 | @isolate_ipython0 |
@@ -207,8 +207,8 b' def test_completion_parenthesis():' | |||
|
207 | 207 | f.input_buffer = 'map(zz' |
|
208 | 208 | f.complete_current_input() |
|
209 | 209 | out_value = f.out.getvalue() |
|
210 |
assert_equal |
|
|
211 |
assert_equal |
|
|
210 | yield assert_equal, out_value, '\nzzza zzzb ' | |
|
211 | yield assert_equal, f.input_buffer, 'map(zzz' | |
|
212 | 212 | |
|
213 | 213 | |
|
214 | 214 | @isolate_ipython0 |
@@ -16,7 +16,7 b' from cStringIO import StringIO' | |||
|
16 | 16 | from time import sleep |
|
17 | 17 | import sys |
|
18 | 18 | |
|
19 |
from IPython.frontend. |
|
|
19 | from IPython.frontend.process import PipedProcess | |
|
20 | 20 | from IPython.testing import decorators as testdec |
|
21 | 21 | |
|
22 | 22 |
@@ -65,7 +65,24 b' _DEFAULT_STYLE = {' | |||
|
65 | 65 | 'tripledouble' : 'fore:#7F0000', |
|
66 | 66 | 'class' : 'fore:#0000FF,bold,underline', |
|
67 | 67 | 'def' : 'fore:#007F7F,bold', |
|
68 | 'operator' : 'bold' | |
|
68 | 'operator' : 'bold', | |
|
69 | ||
|
70 | # Default colors | |
|
71 | 'trace' : '#FAFAF1', # Nice green | |
|
72 | 'stdout' : '#FDFFD3', # Nice yellow | |
|
73 | 'stderr' : '#FFF1F1', # Nice red | |
|
74 | ||
|
75 | # Default scintilla settings | |
|
76 | 'antialiasing' : True, | |
|
77 | 'carret_color' : 'BLACK', | |
|
78 | 'background_color' :'WHITE', | |
|
79 | ||
|
80 | #prompt definition | |
|
81 | 'prompt_in1' : \ | |
|
82 | '\n\x01\x1b[0;34m\x02In [\x01\x1b[1;34m\x02$number\x01\x1b[0;34m\x02]: \x01\x1b[0m\x02', | |
|
83 | ||
|
84 | 'prompt_out': \ | |
|
85 | '\x01\x1b[0;31m\x02Out[\x01\x1b[1;31m\x02$number\x01\x1b[0;31m\x02]: \x01\x1b[0m\x02', | |
|
69 | 86 | } |
|
70 | 87 | |
|
71 | 88 | # new style numbers |
@@ -88,6 +105,9 b" ANSI_STYLES = {'0;30': [0, 'BLACK'], '0;31': [1, 'RED']," | |||
|
88 | 105 | [13, 'MEDIUM VIOLET RED'], |
|
89 | 106 | '1;36': [14, 'LIGHT STEEL BLUE'], '1;37': [15, 'YELLOW']} |
|
90 | 107 | |
|
108 | # XXX: Maybe one day we should factor this code with ColorANSI. Right now | |
|
109 | # ColorANSI is hard to reuse and makes our code more complex. | |
|
110 | ||
|
91 | 111 | #we define platform specific fonts |
|
92 | 112 | if wx.Platform == '__WXMSW__': |
|
93 | 113 | FACES = { 'times': 'Times New Roman', |
@@ -274,35 +294,21 b' class ConsoleWidget(editwindow.EditWindow):' | |||
|
274 | 294 | |
|
275 | 295 | |
|
276 | 296 | def configure_scintilla(self): |
|
277 | ||
|
278 | p = self.style | |
|
279 |
|
|
|
280 | #First we define the special background colors | |
|
281 | if 'trace' in p: | |
|
282 | _COMPLETE_BUFFER_BG = p['trace'] | |
|
283 | else: | |
|
284 | _COMPLETE_BUFFER_BG = '#FAFAF1' # Nice green | |
|
285 | ||
|
286 | if 'stdout' in p: | |
|
287 | _INPUT_BUFFER_BG = p['stdout'] | |
|
288 | else: | |
|
289 | _INPUT_BUFFER_BG = '#FDFFD3' # Nice yellow | |
|
290 | ||
|
291 | if 'stderr' in p: | |
|
292 | _ERROR_BG = p['stderr'] | |
|
293 | else: | |
|
294 | _ERROR_BG = '#FFF1F1' # Nice red | |
|
297 | """ Set up all the styling option of the embedded scintilla | |
|
298 | widget. | |
|
299 | """ | |
|
300 | p = self.style.copy() | |
|
295 | 301 | |
|
296 | 302 | # Marker for complete buffer. |
|
297 | 303 | self.MarkerDefine(_COMPLETE_BUFFER_MARKER, stc.STC_MARK_BACKGROUND, |
|
298 |
background |
|
|
304 | background=p['trace']) | |
|
299 | 305 | |
|
300 | 306 | # Marker for current input buffer. |
|
301 | 307 | self.MarkerDefine(_INPUT_MARKER, stc.STC_MARK_BACKGROUND, |
|
302 |
background |
|
|
308 | background=p['stdout']) | |
|
303 | 309 | # Marker for tracebacks. |
|
304 | 310 | self.MarkerDefine(_ERROR_MARKER, stc.STC_MARK_BACKGROUND, |
|
305 |
background |
|
|
311 | background=p['stderr']) | |
|
306 | 312 | |
|
307 | 313 | self.SetEOLMode(stc.STC_EOL_LF) |
|
308 | 314 | |
@@ -326,10 +332,7 b' class ConsoleWidget(editwindow.EditWindow):' | |||
|
326 | 332 | self.SetWrapMode(stc.STC_WRAP_WORD) |
|
327 | 333 | self.SetBufferedDraw(True) |
|
328 | 334 | |
|
329 | if 'antialiasing' in p: | |
|
330 | 335 |
|
|
331 | else: | |
|
332 | self.SetUseAntiAliasing(True) | |
|
333 | 336 | |
|
334 | 337 | self.SetLayoutCache(stc.STC_CACHE_PAGE) |
|
335 | 338 | self.SetUndoCollection(False) |
@@ -357,15 +360,9 b' class ConsoleWidget(editwindow.EditWindow):' | |||
|
357 | 360 | |
|
358 | 361 | # styles |
|
359 | 362 | |
|
360 | if 'carret_color' in p: | |
|
361 | 363 |
|
|
362 | else: | |
|
363 | self.SetCaretForeground('BLACK') | |
|
364 | 364 | |
|
365 | if 'background_color' in p: | |
|
366 | 365 |
|
|
367 | else: | |
|
368 | background_color = 'WHITE' | |
|
369 | 366 | |
|
370 | 367 | if 'default' in p: |
|
371 | 368 | if 'back' not in p['default']: |
@@ -383,7 +380,6 b' class ConsoleWidget(editwindow.EditWindow):' | |||
|
383 | 380 | background_color, |
|
384 | 381 | self.faces['size'], self.faces['mono'])) |
|
385 | 382 | |
|
386 | #all styles = default one | |
|
387 | 383 | self.StyleClearAll() |
|
388 | 384 | |
|
389 | 385 | # XXX: two lines below are usefull if not using the lexer |
@@ -391,62 +387,35 b' class ConsoleWidget(editwindow.EditWindow):' | |||
|
391 | 387 | # self.StyleSetSpec(style[0], "bold,fore:%s" % style[1]) |
|
392 | 388 | |
|
393 | 389 | #prompt definition |
|
394 | if 'prompt_in1' in p: | |
|
395 | 390 |
|
|
396 | else: | |
|
397 | self.prompt_in1 = \ | |
|
398 | '\n\x01\x1b[0;34m\x02In [\x01\x1b[1;34m\x02$number\x01\x1b[0;34m\x02]: \x01\x1b[0m\x02' | |
|
399 | ||
|
400 | if 'prompt_out' in p: | |
|
401 | 391 |
|
|
402 | else: | |
|
403 | self.prompt_out = \ | |
|
404 | '\x01\x1b[0;31m\x02Out[\x01\x1b[1;31m\x02$number\x01\x1b[0;31m\x02]: \x01\x1b[0m\x02' | |
|
405 | 392 | |
|
406 | 393 | self.output_prompt_template = string.Template(self.prompt_out) |
|
407 | 394 | self.input_prompt_template = string.Template(self.prompt_in1) |
|
408 | 395 | |
|
409 | if 'stdout' in p: | |
|
410 | 396 |
|
|
411 | if 'stderr' in p: | |
|
412 | 397 |
|
|
413 | if 'trace' in p: | |
|
414 | 398 |
|
|
415 | if 'bracegood' in p: | |
|
416 | 399 |
|
|
417 | if 'bracebad' in p: | |
|
418 | 400 |
|
|
419 | if 'comment' in p: | |
|
420 | 401 |
|
|
421 | if 'number' in p: | |
|
422 | 402 |
|
|
423 | if 'string' in p: | |
|
424 | 403 |
|
|
425 | if 'char' in p: | |
|
426 | 404 |
|
|
427 | if 'keyword' in p: | |
|
428 | 405 |
|
|
429 | if 'keyword' in p: | |
|
430 | 406 |
|
|
431 | if 'triple' in p: | |
|
432 | 407 |
|
|
433 | if 'tripledouble' in p: | |
|
434 | 408 |
|
|
435 | if 'class' in p: | |
|
436 | 409 |
|
|
437 | if 'def' in p: | |
|
438 | 410 |
|
|
439 | if 'operator' in p: | |
|
440 | 411 |
|
|
441 | if 'comment' in p: | |
|
442 | 412 |
|
|
443 | 413 | |
|
444 | if 'edge_column' in p: | |
|
445 | 414 |
|
|
446 | 415 |
|
|
447 | 416 |
|
|
448 | 417 |
|
|
449 |
|
|
|
418 | self.SetEdgeColumn(edge_column) | |
|
450 | 419 | |
|
451 | 420 | |
|
452 | 421 | #-------------------------------------------------------------------------- |
@@ -32,7 +32,7 b' import wx' | |||
|
32 | 32 | from wx import stc |
|
33 | 33 | |
|
34 | 34 | # Ipython-specific imports. |
|
35 |
from IPython.frontend. |
|
|
35 | from IPython.frontend.process import PipedProcess | |
|
36 | 36 | from console_widget import ConsoleWidget, _COMPLETE_BUFFER_MARKER, \ |
|
37 | 37 | _ERROR_MARKER, _INPUT_MARKER |
|
38 | 38 | from IPython.frontend.prefilterfrontend import PrefilterFrontEnd |
@@ -507,8 +507,9 b' class WxController(ConsoleWidget, PrefilterFrontEnd):' | |||
|
507 | 507 | new_lines = [] |
|
508 | 508 | if self._input_state == 'readline': |
|
509 | 509 | position = self.GetCurrentPos() |
|
510 | continuation_prompt = self.continuation_prompt()[:-1] | |
|
510 | 511 | for line in self.input_buffer.split('\n'): |
|
511 |
if not line == |
|
|
512 | if not line == continuation_prompt: | |
|
512 | 513 | new_lines.append(line) |
|
513 | 514 | self.input_buffer = '\n'.join(new_lines) |
|
514 | 515 | self.GotoPos(position) |
@@ -528,9 +529,11 b' class WxController(ConsoleWidget, PrefilterFrontEnd):' | |||
|
528 | 529 | # input_buffer filters this out. |
|
529 | 530 | if sys.platform == 'win32': |
|
530 | 531 | self.input_buffer = self.input_buffer |
|
532 | old_prompt_num = self.current_prompt_pos | |
|
531 | 533 | has_executed = PrefilterFrontEnd._on_enter(self, |
|
532 | 534 | new_line_pos=new_line_pos) |
|
533 | if not has_executed: | |
|
535 | if old_prompt_num == self.current_prompt_pos: | |
|
536 | # No execution has happened | |
|
534 | 537 | self.GotoPos(self.GetLineEndPosition(current_line_num + 1)) |
|
535 | 538 | return has_executed |
|
536 | 539 |
@@ -109,7 +109,7 b' def find_packages():' | |||
|
109 | 109 | add_package(packages, 'gui') |
|
110 | 110 | add_package(packages, 'gui.wx') |
|
111 | 111 | add_package(packages, 'frontend', tests=True) |
|
112 |
add_package(packages, 'frontend. |
|
|
112 | add_package(packages, 'frontend.process') | |
|
113 | 113 | add_package(packages, 'frontend.wx') |
|
114 | 114 | add_package(packages, 'frontend.cocoa', tests=True) |
|
115 | 115 | add_package(packages, 'kernel', config=True, tests=True, scripts=True) |
General Comments 0
You need to be logged in to leave comments.
Login now