aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbenadha <benawiadha@gmail.com>2022-01-07 20:52:23 +0700
committerbenadha <benawiadha@gmail.com>2022-01-07 20:52:23 +0700
commitc41b07d3e94e50a9b826de31fe8d602ccd7dc766 (patch)
treeb140631f884568af30010f2ce32933f106a3a1a8
parenta6004cbac697bc6d82edcf69d69f86750d3da606 (diff)
downloadepy-c41b07d3e94e50a9b826de31fe8d602ccd7dc766.tar.gz
Always calculate reading_progress whenever possible, just not always shown
-rwxr-xr-xepy.py24
1 files changed, 13 insertions, 11 deletions
diff --git a/epy.py b/epy.py
index feb24ba..88e95c1 100755
--- a/epy.py
+++ b/epy.py
@@ -2143,7 +2143,8 @@ class Reader:
self.page_animation: Optional[Direction] = None
# show reading progress
- self.show_reading_progress = self.setting.ShowProgressIndicator
+ self.show_reading_progress: bool = self.setting.ShowProgressIndicator
+ self.reading_progress: Optional[float] = None # calculate after count_letters()
# search storage
self.search_data: Optional[SearchData] = None
@@ -3441,19 +3442,20 @@ class Reader:
self._process_counting_letter.close()
self._process_counting_letter = None
- if (
- self.show_reading_progress
- and (cols - reading_state.textwidth - 2) // 2 > 3
- and self.letters_count
- ):
- reading_progress = (
+ # reading progress
+ if self.letters_count:
+ self.reading_progress = (
self.letters_count.cumulative[reading_state.content_index]
+ sum(LOCALPCTG[: reading_state.row + (rows * self.spread) - 1])
) / self.letters_count.all
- reading_progress_str = "{}%".format(int(reading_progress * 100))
- self.screen.addstr(
- 0, cols - len(reading_progress_str), reading_progress_str
- )
+ if (
+ self.show_reading_progress
+ and (cols - reading_state.textwidth - 2) // 2 > 3
+ ):
+ reading_progress_str = "{}%".format(int(self.reading_progress * 100))
+ self.screen.addstr(
+ 0, cols - len(reading_progress_str), reading_progress_str
+ )
self.screen.refresh()
except curses.error: