From 5ab9dc6129bb816b040a13cfdad833a0526b0f90 Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Wed, 10 Apr 2019 02:04:59 +0200
Subject: [PATCH] More comments and refactoring.

---
 new/example_client.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/new/example_client.py b/new/example_client.py
index 5443546..44b0993 100755
--- a/new/example_client.py
+++ b/new/example_client.py
@@ -585,9 +585,12 @@ class TUI:
             curses.init_pair(3, curses.COLOR_BLACK, curses.COLOR_BLUE)
             curses.init_pair(4, curses.COLOR_BLACK, curses.COLOR_YELLOW)
 
+        # Basic curses initialization work.
         setup_screen(stdscr)
         curses.curs_set(False)  # hide cursor
         init_colors()
+
+        # With screen initialized, set up widgets with their curses windows.
         edit_widget = TextLineWidget('SEND:', self, (0, 0), (1, 20))
         edit_line_widget = EditWidget(self, (0, 6), (1, 14), ['edit'])
         edit_widget.children += [edit_line_widget]
@@ -605,10 +608,12 @@ class TUI:
                        descriptor_widget, map_widget, inventory_widget,
                        pickable_items_widget]
         popup_widget = PopUpWidget(self, (0, 0), (1, 1), visible=False)
-        write_mode = False
+
+        # Ensure initial window state before loop starts.
         for w in top_widgets:
             w.ensure_freshness(True)
         self.socket.send('GET_GAMESTATE')
+        write_mode = False
         while True:
 
             # Draw screen.
-- 
2.30.2