Skip to content

Commit

Permalink
New setting: "Automatically scroll the Output Window"
Browse files Browse the repository at this point in the history
* Add a checkbox to the Miscellaneous tab of the Preferences dialog to
control whether FFGo should automatically scroll the FlightGear Output
Window to the end whenever new text is received from FlightGear's stdout
or stderr stream.

* New config file parameter AUTOSCROLL_FG_OUTPUT to store the checkbox
state between sessions.
  • Loading branch information
frougon committed Jan 3, 2016
1 parent 20a67ee commit c40c3c7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
5 changes: 4 additions & 1 deletion ffgo/config.py
Expand Up @@ -93,6 +93,7 @@ def __init__(self, master=None):
self.showFGOutput = IntVar()
self.showFGOutputInSeparateWindow = IntVar()
self.FGOutputGeometry = StringVar()
self.autoscrollFGOutput = IntVar()

self.keywords = {'--aircraft=': self.aircraft,
'--airport=': self.airport,
Expand Down Expand Up @@ -123,7 +124,8 @@ def __init__(self, master=None):
'SHOW_FG_OUTPUT=': self.showFGOutput,
'SHOW_FG_OUTPUT_IN_SEPARATE_WINDOW=':
self.showFGOutputInSeparateWindow,
'FG_OUTPUT_GEOMETRY=': self.FGOutputGeometry}
'FG_OUTPUT_GEOMETRY=': self.FGOutputGeometry,
'AUTOSCROLL_FG_OUTPUT=': self.autoscrollFGOutput}

# In order to avoid using a lot of memory, detailed airport data is
# only loaded on demand. Since this is quite slow, keep a cache of the
Expand Down Expand Up @@ -340,6 +342,7 @@ def update(self, path=None, ignoreFGVersionError=False, logFGVersion=True):
self.showFGOutput.set('1')
self.showFGOutputInSeparateWindow.set('0')
self.FGOutputGeometry.set('')
self.autoscrollFGOutput.set('1')
self.park.set('')
self.rwy.set('')
self.scenario.set('')
Expand Down
4 changes: 4 additions & 0 deletions ffgo/data/config/presets
Expand Up @@ -94,6 +94,10 @@
# - Window geometry specification for the
# Output Window. Set this only if you are not
# satisfied with the default window geometry.
# AUTOSCROLL_FG_OUTPUT=boolean - 0 or 1 (defaults to 1). Automatically scroll
# the Output Window to the end whenever new
# text is received from FlightGear's stdout or
# stderr stream.
#
# Any number of options can be selected, but to get FFGo ready to work,
# you only need:
Expand Down
19 changes: 18 additions & 1 deletion ffgo/gui/configwindow.py
Expand Up @@ -303,6 +303,10 @@ def initToolTipMessages(self):
When saving the configuration, don't store the main window size only,
but also its position (i.e., the offsets from the screen borders).
When this option is unchecked, only the main window size is stored.""")
self.tooltip_autoscrollFGOutput = _(
"Automatically scroll the FlightGear Output Window to the end "
"every time new text is received from FlightGear's stdout or "
"stderr stream.")

def quit(self):
"""Quit without saving."""
Expand Down Expand Up @@ -620,9 +624,22 @@ def widgetMisc(self):
self.MagneticFieldBinFind.pack(side='left')

# “Remember main windows position” checkbox
self.frame_rememberMainWinPos = Frame(self.frame_misc)
self.frame_rememberMainWinPos.pack(side='top', fill='x', expand=True)
self.rememberMainWinPos = Checkbutton(
self.frame_misc,
self.frame_rememberMainWinPos,
text=_('Remember the main window position'),
variable=self.config.saveWindowPosition)
ToolTip(self.rememberMainWinPos, self.tooltip_rememberMainWinPos)
self.rememberMainWinPos.pack(side='left', fill='x')

# “Automatically scroll the Output Window” checkbox
self.frame_autoscrollFGOutput = Frame(self.frame_misc)
self.frame_autoscrollFGOutput.pack(side='top', fill='x', expand=True)
self.autoscrollFGOutput = Checkbutton(
self.frame_autoscrollFGOutput,
text=_('Automatically scroll the Output Window'),
variable=self.config.autoscrollFGOutput)
ToolTip(self.autoscrollFGOutput, self.tooltip_autoscrollFGOutput,
autowrap=True)
self.autoscrollFGOutput.pack(side='left', fill='x')
4 changes: 3 additions & 1 deletion ffgo/gui/mainwindow.py
Expand Up @@ -1549,7 +1549,9 @@ def _updateFgfsProcessOutput(self, event, queue=None):
self.FGOutput.appendNoUnlock(line)

self.FGOutput.lock()
self.FGOutput.showEnd()

if self.config.autoscrollFGOutput.get():
self.FGOutput.showEnd()

def _onFgfsProcessTerminated(self, event, queue=None):
# There should be exactly one item in the queue now. Get it.
Expand Down

0 comments on commit c40c3c7

Please sign in to comment.