fix: display issue when changing show_timestamps value
This commit is contained in:
parent
b1b2ef860f
commit
56bab71192
7 changed files with 33 additions and 16 deletions
|
@ -347,6 +347,7 @@ class Core:
|
|||
('plugins_dir', self.plugin_manager.on_plugins_dir_change),
|
||||
('request_message_receipts',
|
||||
self.on_request_receipts_config_change),
|
||||
('show_timestamps', self.on_show_timestamps_changed),
|
||||
('theme', self.on_theme_config_change),
|
||||
('themes_dir', theming.update_themes_dir),
|
||||
('use_bookmarks_method', self.on_bookmarks_method_config_change),
|
||||
|
@ -404,6 +405,12 @@ class Core:
|
|||
"""
|
||||
self.call_for_resize()
|
||||
|
||||
def on_show_timestamps_changed(self, option, value):
|
||||
"""
|
||||
Called when the show_timestamps option changes
|
||||
"""
|
||||
self.call_for_resize(ui_config_changed=True)
|
||||
|
||||
def on_bookmarks_method_config_change(self, option, value):
|
||||
"""
|
||||
Called when the use_bookmarks_method option changes
|
||||
|
@ -1577,7 +1584,7 @@ class Core:
|
|||
self.information('Unable to write in the config file', 'Error')
|
||||
self.call_for_resize()
|
||||
|
||||
def resize_global_information_win(self):
|
||||
def resize_global_information_win(self, ui_config_changed: bool = False):
|
||||
"""
|
||||
Resize the global_information_win only once at each resize.
|
||||
"""
|
||||
|
@ -1588,7 +1595,8 @@ class Core:
|
|||
height = (tabs.Tab.height - 1 - self.information_win_size -
|
||||
tabs.Tab.tab_win_height())
|
||||
self.information_win.resize(self.information_win_size, tabs.Tab.width,
|
||||
height, 0)
|
||||
height, 0, self.information_buffer,
|
||||
force=ui_config_changed)
|
||||
|
||||
def resize_global_info_bar(self):
|
||||
"""
|
||||
|
@ -1619,7 +1627,7 @@ class Core:
|
|||
self.stdscr.clear()
|
||||
self.refresh_window()
|
||||
|
||||
def call_for_resize(self):
|
||||
def call_for_resize(self, ui_config_changed: bool = False):
|
||||
"""
|
||||
Called when we want to resize the screen
|
||||
"""
|
||||
|
@ -1642,8 +1650,9 @@ class Core:
|
|||
scr = self.stdscr
|
||||
tabs.Tab.initial_resize(scr)
|
||||
self.resize_global_info_bar()
|
||||
self.resize_global_information_win()
|
||||
self.resize_global_information_win(ui_config_changed)
|
||||
for tab in self.tabs:
|
||||
tab.ui_config_changed = True
|
||||
if config.getbool('lazy_resize'):
|
||||
tab.need_resize = True
|
||||
else:
|
||||
|
|
|
@ -124,12 +124,14 @@ class Tab:
|
|||
plugin_commands: Dict[str, Command] = {}
|
||||
plugin_keys: Dict[str, Callable] = {}
|
||||
# Placeholder values, set on resize
|
||||
height = 1
|
||||
width = 1
|
||||
height: int = 1
|
||||
width: int = 1
|
||||
core: Core
|
||||
input: Optional[windows.Input]
|
||||
key_func: Dict[str, Callable[[], Any]]
|
||||
commands: Dict[str, Command]
|
||||
need_resize: bool
|
||||
ui_config_changed: bool
|
||||
|
||||
def __init__(self, core: Core):
|
||||
self.core = core
|
||||
|
@ -142,6 +144,7 @@ class Tab:
|
|||
self._prev_state = None
|
||||
|
||||
self.need_resize = False
|
||||
self.ui_config_changed = False
|
||||
self.key_func = {} # each tab should add their keys in there
|
||||
# and use them in on_input
|
||||
self.commands = {} # and their own commands
|
||||
|
|
|
@ -252,8 +252,10 @@ class ConversationTab(OneToOneTab):
|
|||
|
||||
self.text_win.resize(
|
||||
self.height - 2 - bar_height - info_win_height - tab_win_height,
|
||||
self.width, bar_height, 0)
|
||||
self.text_win.rebuild_everything(self._text_buffer)
|
||||
self.width, bar_height, 0, self._text_buffer,
|
||||
force=self.ui_config_changed
|
||||
)
|
||||
self.ui_config_changed = False
|
||||
if display_bar:
|
||||
self.upper_bar.resize(1, self.width, 0, 0)
|
||||
self.get_info_header().resize(
|
||||
|
|
|
@ -1268,8 +1268,8 @@ class MucTab(ChatTab):
|
|||
|
||||
self.text_win.resize(
|
||||
self.height - 3 - info_win_height - tab_win_height, text_width, 1,
|
||||
0)
|
||||
self.text_win.rebuild_everything(self._text_buffer)
|
||||
0, self._text_buffer, force=self.ui_config_changed)
|
||||
self.ui_config_changed = False
|
||||
self.info_header.resize(
|
||||
1, self.width, self.height - 2 - info_win_height - tab_win_height,
|
||||
0)
|
||||
|
@ -1314,7 +1314,7 @@ class MucTab(ChatTab):
|
|||
Tab.tab_win_height(), 1, 1, 9 * (self.width // 10))
|
||||
self.text_win.resize(
|
||||
self.height - 3 - self.core.information_win_size -
|
||||
Tab.tab_win_height(), text_width, 1, 0)
|
||||
Tab.tab_win_height(), text_width, 1, 0, self._text_buffer)
|
||||
self.info_header.resize(
|
||||
1, self.width, self.height - 2 - self.core.information_win_size -
|
||||
Tab.tab_win_height(), 0)
|
||||
|
|
|
@ -214,8 +214,8 @@ class PrivateTab(OneToOneTab):
|
|||
|
||||
self.text_win.resize(
|
||||
self.height - 2 - info_win_height - tab_win_height, self.width, 0,
|
||||
0)
|
||||
self.text_win.rebuild_everything(self._text_buffer)
|
||||
0, self._text_buffer, force=self.ui_config_changed)
|
||||
self.ui_config_changed = False
|
||||
self.info_header.resize(
|
||||
1, self.width, self.height - 2 - info_win_height - tab_win_height,
|
||||
0)
|
||||
|
|
|
@ -434,7 +434,9 @@ class RosterInfoTab(Tab):
|
|||
roster_width)
|
||||
self.information_win.resize(
|
||||
self.height - 1 - tab_win_height - contact_win_h, info_width,
|
||||
0, roster_width + 1, self.core.information_buffer)
|
||||
0, roster_width + 1, self.core.information_buffer,
|
||||
force=self.ui_config_changed)
|
||||
self.ui_config_changed = False
|
||||
if display_contact_win:
|
||||
y = self.height - tab_win_height - contact_win_h - 1
|
||||
avatar_width = contact_win_h * 2
|
||||
|
|
|
@ -146,14 +146,15 @@ class TextWin(Win):
|
|||
"""
|
||||
self.addstr_colored(txt, y, x)
|
||||
|
||||
def resize(self, height: int, width: int, y: int, x: int, room: TextBuffer=None) -> None:
|
||||
def resize(self, height: int, width: int, y: int, x: int,
|
||||
room: Optional[TextBuffer] = None, force: bool = False) -> None:
|
||||
old_width: Optional[int]
|
||||
if hasattr(self, 'width'):
|
||||
old_width = self.width
|
||||
else:
|
||||
old_width = None
|
||||
self._resize(height, width, y, x)
|
||||
if room and self.width != old_width:
|
||||
if room and (self.width != old_width or force):
|
||||
self.rebuild_everything(room)
|
||||
|
||||
# reposition the scrolling after resize
|
||||
|
|
Loading…
Reference in a new issue