Skip to content

Commit

Permalink
[pyqgis-console] a better attribute name
Browse files Browse the repository at this point in the history
  • Loading branch information
slarosa authored and nyalldawson committed Oct 4, 2020
1 parent 7463121 commit f724793
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions python/console/console_sci.py
Expand Up @@ -65,8 +65,9 @@ def __init__(self, parent=None):
self.setMarginLineNumbers(0, False) # NO linenumbers for the input line

self.buffer = []
self.continuationLine = False

self.displayPrompt(self.buffer)
self.displayPrompt(self.continuationLine)

for line in _init_commands:
self.runsource(line)
Expand Down Expand Up @@ -212,15 +213,15 @@ def move_cursor_to_start(self):
self.setCursorPosition(0, 0)
self.ensureCursorVisible()
self.ensureLineVisible(0)
self.displayPrompt(self.buffer)
self.displayPrompt(self.continuationLine)

def move_cursor_to_end(self):
"""Move cursor to end of text"""
line, index = self.get_end_pos()
self.setCursorPosition(line, index)
self.ensureCursorVisible()
self.ensureLineVisible(line)
self.displayPrompt(self.buffer)
self.displayPrompt(self.continuationLine)

def is_cursor_on_last_line(self):
"""Return True if cursor is on the last line"""
Expand Down Expand Up @@ -417,7 +418,7 @@ def keyPressEvent(self, e):
self.setCursorPosition(line, index + 7)
QsciScintilla.keyPressEvent(self, e)

self.displayPrompt(self.buffer)
self.displayPrompt(self.continuationLine)

def contextMenuEvent(self, e):
menu = QMenu(self)
Expand Down Expand Up @@ -538,14 +539,16 @@ def runCommand(self, cmd):
self.buffer.append(cmd)
src = "\n".join(self.buffer)
more = self.runsource(src)
self.continuationLine = True
if not more:
self.continuationLine = False
self.buffer = []

# prevents to commands with more lines to break the console
# in the case they have a eol different from '\n'
self.setText('')
self.move_cursor_to_end()
self.displayPrompt(more)
self.displayPrompt(self.continuationLine)

def write(self, txt):
sys.stderr.write(txt)
Expand All @@ -554,7 +557,7 @@ def writeCMD(self, txt):
if sys.stdout:
sys.stdout.fire_keyboard_interrupt = False
if len(txt) > 0:
prompt = "... " if self.buffer else ">>> "
prompt = "... " if self.continuationLine else ">>> "
sys.stdout.write(prompt + txt + '\n')

def runsource(self, source, filename='<input>', symbol='single'):
Expand Down

0 comments on commit f724793

Please sign in to comment.