##// END OF EJS Templates
Pressing Enter now always executes when the input buffer has one line.
epatters -
Show More
@@ -306,9 +306,8 b' once you learn a few basic keybindings it will be a much more efficient'
306 environment.
306 environment.
307
307
308 For single expressions or indented blocks, the console behaves almost like the
308 For single expressions or indented blocks, the console behaves almost like the
309 terminal IPython: single expressions are immediately evaluated *if the cursor
309 terminal IPython: single expressions are immediately evaluated, and indented
310 is at the end of the line*, and indented blocks are evaluated once a single
310 blocks are evaluated once a single blank line is entered::
311 blank line is entered::
312
311
313 In [1]: print "Hello IPython!" # Enter was pressed at the end of the line
312 In [1]: print "Hello IPython!" # Enter was pressed at the end of the line
314 Hello IPython!
313 Hello IPython!
@@ -318,12 +317,6 b' blank line is entered::'
318 ...:
317 ...:
319 0 1 2 3 4 5 6 7 8 9
318 0 1 2 3 4 5 6 7 8 9
320
319
321 If you have a single expression and you go back to edit something in the
322 beginning, hitting ``Enter`` will split the line (like a text editor) instead
323 of executing it. To execute, you can either go to the end of the line to hit
324 ``Enter``, or hit ``Shift-Enter`` anywhere, which is the 'force execution'
325 keybinding.
326
327 If you want to enter more than one expression in a single input block
320 If you want to enter more than one expression in a single input block
328 (something not possible in the terminal), you can use ``Control-Enter`` at the
321 (something not possible in the terminal), you can use ``Control-Enter`` at the
329 end of your first line instead of ``Enter``. At that point the console goes
322 end of your first line instead of ``Enter``. At that point the console goes
@@ -806,13 +806,16 b' class ConsoleWidget(Configurable, QtGui.QWidget):'
806 if self._reading_callback:
806 if self._reading_callback:
807 self._reading_callback()
807 self._reading_callback()
808
808
809 # If there is only whitespace after the cursor, execute.
809 # If the input buffer is a single line or there is only
810 # Otherwise, split the line with a continuation prompt.
810 # whitespace after the cursor, execute. Otherwise, split the
811 # line with a continuation prompt.
811 elif not self._executing:
812 elif not self._executing:
812 cursor.movePosition(QtGui.QTextCursor.End,
813 cursor.movePosition(QtGui.QTextCursor.End,
813 QtGui.QTextCursor.KeepAnchor)
814 QtGui.QTextCursor.KeepAnchor)
814 at_end = cursor.selectedText().trimmed().isEmpty()
815 at_end = cursor.selectedText().trimmed().isEmpty()
815 if (at_end or shift_down) and not ctrl_down:
816 single_line = (self._get_end_cursor().blockNumber() ==
817 self._get_prompt_cursor().blockNumber())
818 if (at_end or shift_down or single_line) and not ctrl_down:
816 self.execute(interactive = not shift_down)
819 self.execute(interactive = not shift_down)
817 else:
820 else:
818 # Do this inside an edit block for clean undo/redo.
821 # Do this inside an edit block for clean undo/redo.
General Comments 0
You need to be logged in to leave comments. Login now