Skip to content

Commit c8a40a7

Browse files
committed
library: Snap execution output to the bottom
1 parent dc1b0dd commit c8a40a7

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/gameeky/library/widgets/window.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class Window(Adw.ApplicationWindow):
4949

5050
source_buffer = Gtk.Template.Child()
5151
output_buffer = Gtk.Template.Child()
52+
output_view = Gtk.Template.Child()
5253
execute_button = Gtk.Template.Child()
5354
stop_button = Gtk.Template.Child()
5455
banner = Gtk.Template.Child()
@@ -60,6 +61,9 @@ def __init__(self, *args, **kargs) -> None:
6061
self._handler_id = self.source_buffer.connect(
6162
"changed", self.__on_source_changed
6263
)
64+
self._output_mark = self.output_buffer.create_mark(
65+
None, self.output_buffer.get_end_iter(), False
66+
)
6367

6468
Monitor.default().connect("changed", self.__on_monitor_changed)
6569

@@ -176,6 +180,7 @@ def __on_output(
176180
self._restore_ui()
177181
else:
178182
self.output_buffer.insert_at_cursor(data.decode("UTF-8") + "\n")
183+
self.output_view.scroll_to_mark(self._output_mark, 0.0, False, 0.0, 0.0)
179184
self._queue_read(stream)
180185

181186
def _restore_ui(self) -> None:

src/gameeky/library/widgets/window.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<property name="end-child">
1717
<object class="GtkScrolledWindow">
1818
<property name="child">
19-
<object class="GtkTextView">
19+
<object class="GtkTextView" id="output_view">
2020
<property name="buffer">
2121
<object class="GtkTextBuffer" id="output_buffer"/>
2222
</property>

0 commit comments

Comments
 (0)