mirror of
https://github.com/markqvist/NomadNet.git
synced 2026-11-20 06:56:21 -05:00
Fixed anchors not updating scroll position
This commit is contained in:
parent
66f72ead0f
commit
f8c57e675e
3 changed files with 21 additions and 14 deletions
|
|
@ -342,6 +342,7 @@ class Browser:
|
|||
|
||||
try:
|
||||
scrollable = self.browser_body.original_widget.original_widget
|
||||
scrollable.anchor_cursor_update = True
|
||||
scrollable.set_scrollpos(self._rows_above(int(target_idx), cols))
|
||||
except Exception as e:
|
||||
RNS.log("Anchor jump failed: "+str(e), RNS.LOG_ERROR)
|
||||
|
|
|
|||
|
|
@ -227,6 +227,7 @@ class GuideDisplay():
|
|||
pile = urwid.Pile(new_content)
|
||||
self._content_attrmaps = new_content
|
||||
self._content_scrollable = Scrollable(pile)
|
||||
pile.automove_cursor_on_scroll = True
|
||||
content = urwid.LineBox(urwid.AttrMap(ScrollBar(self._content_scrollable, thumb_char="\u2503", trough_char=" "), "scrollbar"))
|
||||
|
||||
self.columns.contents[1] = (content, options)
|
||||
|
|
@ -255,6 +256,8 @@ class GuideDisplay():
|
|||
return
|
||||
row_offset = _rows_above(attrmaps, target_idx, cols)
|
||||
try:
|
||||
scrollable.force_cursor_update = True
|
||||
scrollable.anchor_cursor_update = True
|
||||
scrollable.set_scrollpos(int(row_offset))
|
||||
except Exception:
|
||||
pass
|
||||
|
|
@ -1346,19 +1349,19 @@ With micron you can easily create structured documents and pages with formatting
|
|||
|
||||
>Table of Contents
|
||||
|
||||
`F44f`_`[A Few Demo Outputs`#a-few-demo-outputs]`_`f
|
||||
`F44f`_`[Micron Tags`#micron-tags]`_`f
|
||||
`F44f`_`[High Level Stuff`#high-level-stuff]`_`f
|
||||
`F44f`_`[Colors`#colors]`_`f
|
||||
`F44f`_`[Page Foreground and Background Colors`#page-foreground-and-background-colors]`_`f
|
||||
`F44f`_`[Links`#links]`_`f
|
||||
`F44f`_`[Anchors`#anchors]`_`f
|
||||
`F44f`_`[Tables`#tables]`_`f
|
||||
`F44f`_`[Fields & Requests`#fields-requests]`_`f
|
||||
`F44f`_`[Comments`#comments]`_`f
|
||||
`F44f`_`[Partials`#partials]`_`f
|
||||
`F44f`_`[Literals`#literals]`_`f
|
||||
`F44f`_`[Closing Remarks`#closing-remarks]`_`f
|
||||
`F79d`_`[A Few Demo Outputs`#a-few-demo-outputs]`_`f
|
||||
`F79d`_`[Micron Tags`#micron-tags]`_`f
|
||||
`F79d`_`[High Level Stuff`#high-level-stuff]`_`f
|
||||
`F79d`_`[Colors`#colors]`_`f
|
||||
`F79d`_`[Page Foreground and Background Colors`#page-foreground-and-background-colors]`_`f
|
||||
`F79d`_`[Links`#links]`_`f
|
||||
`F79d`_`[Anchors`#anchors]`_`f
|
||||
`F79d`_`[Tables`#tables]`_`f
|
||||
`F79d`_`[Fields & Requests`#fields-requests]`_`f
|
||||
`F79d`_`[Comments`#comments]`_`f
|
||||
`F79d`_`[Partials`#partials]`_`f
|
||||
`F79d`_`[Literals`#literals]`_`f
|
||||
`F79d`_`[Closing Remarks`#closing-remarks]`_`f
|
||||
|
||||
>>Recommendations and Requirements
|
||||
|
||||
|
|
|
|||
5
nomadnet/vendor/Scrollable.py
vendored
5
nomadnet/vendor/Scrollable.py
vendored
|
|
@ -53,6 +53,7 @@ class Scrollable(urwid.WidgetDecoration):
|
|||
self._rows_max_cached = 0
|
||||
self.force_forward_keypress = force_forward_keypress
|
||||
self.force_cursor_update = False
|
||||
self.anchor_cursor_update = False
|
||||
self.cursor_update_forced_at = 0
|
||||
super().__init__(widget)
|
||||
|
||||
|
|
@ -108,9 +109,11 @@ class Scrollable(urwid.WidgetDecoration):
|
|||
# Trimmed canvas contains the cursor, e.g. in an Edit widget
|
||||
self._forward_keypress = True
|
||||
else:
|
||||
force_check = self.force_cursor_update and (time.time()-self.cursor_update_forced_at < 0.25)
|
||||
force_check = self.force_cursor_update and (time.time()-self.cursor_update_forced_at < 0.25)
|
||||
force_check |= self.anchor_cursor_update
|
||||
if canv_full.cursor is not None or force_check:
|
||||
self.force_cursor_update = False
|
||||
self.anchor_cursor_update = False
|
||||
# Full canvas contains the cursor, but scrolled out of view
|
||||
self._forward_keypress = False
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue