Skip to content

Commit

Permalink
support skipping whole pages with page up/down
Browse files Browse the repository at this point in the history
  • Loading branch information
enkiv2 committed Jun 26, 2019
1 parent ffdc392 commit 5adcb61
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion fern
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ def drawPanelContents(toots, selectedIdx, skipSeen=False):
commandKeys={
"q":"quit",
"P":"prev", "N":"next", "p":"prev_unread", "n":"next_unread",
"KEY_PPAGE":"prev_page", "KEY_NPAGE":"next_page",
"O":"last_unread",
"T":"top", "F":"fetch",
"0":"skipto 0", "1":"skipto 1", "2":"skipto 2", "3":"skipto 3", "4":"skipto 4", "5":"skipto 5", "6":"skipto 6", "7":"skipto 7", "8":"skipto 8", "9":"skipto 9",
Expand All @@ -339,6 +340,7 @@ commandKeys={
":":"cmd"}
def execCommand(cmd):
global hlIdx, tlIdx, tl, currentTimeline, isCWOpen, seen_toots, tootbase, tb_dirty
tootsPerPage=int((ROWS-4)/4)
if cmd=="quit":
saveBase()
teardownCurses()
Expand All @@ -349,6 +351,10 @@ def execCommand(cmd):
while hlIdx+tlIdx>0 and tl[hlIdx+tlIdx]["id"] in seen_toots: hlIdx-=1
elif cmd=="next_unread":
while hlIdx+tlIdx<len(tl) and tl[hlIdx+tlIdx]["id"] in seen_toots: hlIdx+=1
elif cmd=="next_page":
tlIdx+=tootsPerPage
elif cmd=="prev_page":
tlIdx-=tootsPerPage
elif cmd=="top": (tlIdx, hlIdx)=[0]*2
elif cmd.find("skipto ")==0:
try: hlIdx=int(cmd.split()[1])
Expand Down Expand Up @@ -541,7 +547,6 @@ def execCommand(cmd):
statusMsg("Getting mentions... page "+str(page), False)
try: statuses=mastodon.fetch_next(statuses)
except: statuses=None
tootsPerPage=int((ROWS-4)/4)
if hlIdx+tlIdx<0:(hlIdx, tlIdx)=[0]*2
position=hlIdx+tlIdx
if(position>=len(tl) and position<len(tootbase.keys())):
Expand Down

0 comments on commit 5adcb61

Please sign in to comment.