From 0ed4e09b826f01e1f8a708986c15ae02ae615942 Mon Sep 17 00:00:00 2001
From: Mark Qvist <mark@unsigned.io>
Date: Mon, 15 Jan 2024 19:40:01 +0100
Subject: [PATCH] Updated nomadnet to use Urwid 2.4.2

---
 nomadnet/ui/textui/Guide.py   | 7 +++----
 nomadnet/ui/textui/Main.py    | 3 +++
 nomadnet/vendor/Scrollable.py | 6 +++---
 setup.py                      | 2 +-
 4 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/nomadnet/ui/textui/Guide.py b/nomadnet/ui/textui/Guide.py
index e0935c7..95cf5bf 100644
--- a/nomadnet/ui/textui/Guide.py
+++ b/nomadnet/ui/textui/Guide.py
@@ -163,9 +163,8 @@ class GuideDisplay():
             entry.display_topic(entry.display_topic, entry.topic_name)
 
     def set_content_widgets(self, new_content):
-        options = self.columns.options(width_type="weight", width_amount=1-GuideDisplay.list_width)
+        options = self.columns.options(width_type="weight", width_amount=1-GuideDisplay.list_width, box_widget=True)
         pile = urwid.Pile(new_content)
-        #content = urwid.LineBox(urwid.Filler(pile, "top"))
         content = urwid.LineBox(urwid.AttrMap(ScrollBar(Scrollable(pile), thumb_char="\u2503", trough_char=" "), "scrollbar"))
 
         self.columns.contents[1] = (content, options)
@@ -398,7 +397,7 @@ You're currently located in the guide section of the program. I'm sorry I had to
 
 To get the most out of Nomad Network, you will need a terminal that supports UTF-8 and at least 256 colors, ideally true-color. If your terminal supports true-color, you can go to the `![ Config ]`! menu item, launch the editor and change the configuration.
 
-It is recommended to use a terminal size of at least 122x32. Nomad Network will work with smaller terminal sizes, but the interface might feel a bit cramped.
+It is recommended to use a terminal size of at least 135x32. Nomad Network will work with smaller terminal sizes, but the interface might feel a bit cramped.
 
 If you don't already have a Nerd Font installed (see https://www.nerdfonts.com/), I also highly recommend to do so, since it will greatly expand the amount of glyphs, icons and graphics that Nomad Network can use. Once you have your terminal set up with a Nerd Font, go to the `![ Config ]`! menu item and enable Nerd Fonts in the configuration instead of normal unicode glyphs.
 
@@ -1156,7 +1155,7 @@ To display literal content, for example source-code, or blocks of text that shou
 `=
 '''
 TOPIC_MARKUP += TOPIC_MARKUP.replace("`=", "\\`=") + "[ micron source for document goes here, we don't want infinite recursion now, do we? ]\n\\`="
-TOPIC_MARKUP += "\n`=\n\n>Closing Remarks\n\nIf you made it all the way here, you should be well equipped to write documents, pages and applications using micron and Nomad Network. Thank you for staying with me.\n\n`c\U0001F332\n"
+TOPIC_MARKUP += "\n`=\n\n>Closing Remarks\n\nIf you made it all the way here, you should be well equipped to write documents, pages and applications using micron and Nomad Network. Thank you for staying with me.\n"
 
 
 TOPICS = {
diff --git a/nomadnet/ui/textui/Main.py b/nomadnet/ui/textui/Main.py
index 45584d5..ee03ea5 100644
--- a/nomadnet/ui/textui/Main.py
+++ b/nomadnet/ui/textui/Main.py
@@ -116,6 +116,7 @@ class MainDisplay():
 
     def show_log(self, user_data):
         self.sub_displays.active_display = self.sub_displays.log_display
+        self.sub_displays.log_display.show()
         self.update_active_sub_display()
 
     def show_guide(self, user_data):
@@ -125,6 +126,8 @@ class MainDisplay():
     def update_active_sub_display(self):
         self.frame.contents["body"] = (self.sub_displays.active().widget, None)
         self.update_active_shortcuts()
+        if self.sub_displays.active_display != self.sub_displays.log_display:
+            self.sub_displays.log_display.kill()
 
     def update_active_shortcuts(self):
         self.frame.contents["footer"] = (self.sub_displays.active().shortcuts().widget, None)
diff --git a/nomadnet/vendor/Scrollable.py b/nomadnet/vendor/Scrollable.py
index eb0d2fa..eedb1ab 100644
--- a/nomadnet/vendor/Scrollable.py
+++ b/nomadnet/vendor/Scrollable.py
@@ -268,10 +268,10 @@ class Scrollable(urwid.WidgetDecoration):
     def _get_original_widget_size(self, size):
         ow = self._original_widget
         sizing = ow.sizing()
-        if FIXED in sizing:
-            return ()
-        elif FLOW in sizing:
+        if FLOW in sizing:
             return (size[0],)
+        elif FIXED in sizing:
+            return ()
 
     def get_scrollpos(self, size=None, focus=False):
         """Current scrolling position
diff --git a/setup.py b/setup.py
index e627c09..b3614a0 100644
--- a/setup.py
+++ b/setup.py
@@ -30,6 +30,6 @@ setuptools.setup(
     entry_points= {
         'console_scripts': ['nomadnet=nomadnet.nomadnet:main']
     },
-    install_requires=["rns>=0.7.0", "lxmf>=0.3.8", "urwid==2.1.2", "qrcode"],
+    install_requires=["rns>=0.7.0", "lxmf>=0.3.8", "urwid>=2.4.2", "qrcode"],
     python_requires=">=3.6",
 )