diff --git a/nomadnet/NomadNetworkApp.py b/nomadnet/NomadNetworkApp.py index 31154a0..2df897a 100644 --- a/nomadnet/NomadNetworkApp.py +++ b/nomadnet/NomadNetworkApp.py @@ -936,6 +936,11 @@ class NomadNetworkApp: else: self.config["textui"]["sanitize_names"] = self.config["textui"].as_bool("sanitize_names") + if not "clipboard_copy" in self.config["textui"]: + self.config["textui"]["clipboard_copy"] = False + else: + self.config["textui"]["clipboard_copy"] = self.config["textui"].as_bool("clipboard_copy") + if not "animation_interval" in self.config["textui"]: self.config["textui"]["animation_interval"] = 1 else: @@ -980,12 +985,12 @@ class NomadNetworkApp: except Exception: value = None if value is not None and value >= 0: self.rrc_history_per_room_cap = value - + if option == "filter_loaded_history": try: value = self.config["rrc"].as_bool(option) except Exception: value = True self.rrc_filter_loaded_history = value - + if option == "ephemeral_notices": try: value = self.config["rrc"].as_float(option) except Exception: value = 0 @@ -995,12 +1000,12 @@ class NomadNetworkApp: try: value = self.config["rrc"].as_bool(option) except Exception: value = True self.rrc_ui_justify_msgs = value - + if option == "space_msgs": try: value = self.config["rrc"].as_bool(option) except Exception: value = False self.rrc_ui_space_msgs = value - + if option == "nick_colors": try: value = self.config["rrc"].as_bool(option) except Exception: value = True @@ -1024,12 +1029,12 @@ class NomadNetworkApp: try: value = self.config["rrc"].as_bool(option) except Exception: value = True self.rrc_ui_render_markdown = value - + if option == "render_micron": try: value = self.config["rrc"].as_bool(option) except Exception: value = True self.rrc_ui_render_micron = value - + if option == "show_gutters": try: value = self.config["rrc"].as_bool(option) except Exception: value = False @@ -1350,6 +1355,11 @@ hide_guide = no # announces. sanitize_names = yes +# You can enable clipboard features. This +# relies on your terminal supporting OSC52 +# escape sequences. +clipboard_copy = no + [rrc] # Maximum number of messages retained per diff --git a/nomadnet/ui/textui/Browser.py b/nomadnet/ui/textui/Browser.py index 29649ad..29becb8 100644 --- a/nomadnet/ui/textui/Browser.py +++ b/nomadnet/ui/textui/Browser.py @@ -35,7 +35,8 @@ class BrowserFrame(urwid.Frame): elif key == "ctrl g": nomadnet.NomadNetworkApp.get_shared_instance().ui.main_display.sub_displays.network_display.toggle_fullscreen() elif key == "ctrl y": - self.delegate.copy_url() + if self.delegate.app.config["textui"]["clipboard_copy"]: + self.delegate.copy_url() elif self.focus_position == "body": if key == "down" or key == "up": try: @@ -500,17 +501,24 @@ class Browser: return urwid.AttrMap(widget, "browser_controls") def make_control_widget(self): - lstr = self.g["node"]+" "+self.current_url() + clipboard_copy_enabled = self.app.config["textui"]["clipboard_copy"] copy_glyph = self.g.get("copy", "[C]") - lmax = self._content_cols()-len(copy_glyph)-len(copy_glyph)-1 + lstr = self.g["node"]+" "+self.current_url() + if clipboard_copy_enabled: + lmax = self._content_cols()-len(copy_glyph)-len(copy_glyph)-1 + else: + lmax = self._content_cols()-1 if len(lstr) > lmax: lstr = lstr[:lmax-1]+"…" url_text = urwid.Text(lstr) - copy_icon = ClickableIcon(copy_glyph, on_click=lambda: self.copy_url()) - copy_width = len(copy_glyph) + 2 - header_row = urwid.Columns([ - ("weight", 1, url_text), - (copy_width, urwid.Padding(copy_icon, left=1, right=1)), - ]) + if clipboard_copy_enabled: + copy_icon = ClickableIcon(copy_glyph, on_click=lambda: self.copy_url()) + copy_width = len(copy_glyph) + 2 + header_row = urwid.Columns([ + ("weight", 1, url_text), + (copy_width, urwid.Padding(copy_icon, left=1, right=1)), + ]) + else: + header_row = url_text return urwid.AttrMap(urwid.Pile([header_row, urwid.Divider(self.g["divider1"])]), "browser_controls") def make_request_failed_widget(self): diff --git a/nomadnet/ui/textui/Conversations.py b/nomadnet/ui/textui/Conversations.py index ed7944a..7900e98 100644 --- a/nomadnet/ui/textui/Conversations.py +++ b/nomadnet/ui/textui/Conversations.py @@ -2634,7 +2634,7 @@ class LXMessageWidget(urwid.WidgetWrap): content_text = message.get_content() - if content_text: + if content_text and app.config["textui"]["clipboard_copy"]: copy_glyph = g.get("copy", "[C]") check_glyph = g.get("check", "v").center(len(copy_glyph)) copy_icon = ClickableIcon(copy_glyph) diff --git a/nomadnet/ui/textui/Network.py b/nomadnet/ui/textui/Network.py index 17130e2..1e06007 100644 --- a/nomadnet/ui/textui/Network.py +++ b/nomadnet/ui/textui/Network.py @@ -16,7 +16,11 @@ class NetworkDisplayShortcuts(): self.app = app g = app.ui.glyphs - self.widget = urwid.AttrMap(urwid.Text("[C-l] Nodes/Announces [C-x] Remove [C-w] Disconnect [C-d] Back [C-f] Forward [C-r] Reload [C-u] URL [C-y] Copy [C-g] Fullscreen [C-s / C-b] Save Node"), "shortcutbar") + shortcut_text = "[C-l] Nodes/Announces [C-x] Remove [C-w] Disconnect [C-d] Back [C-f] Forward [C-r] Reload [C-u] URL " + if app.config["textui"]["clipboard_copy"]: + shortcut_text += "[C-y] Copy " + shortcut_text += "[C-g] Fullscreen [C-s / C-b] Save Node" + self.widget = urwid.AttrMap(urwid.Text(shortcut_text), "shortcutbar") class DialogLineBox(urwid.LineBox): def keypress(self, size, key):