aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbenadha <benawiadha@gmail.com>2021-02-02 18:08:44 +0700
committerbenadha <benawiadha@gmail.com>2021-02-02 18:08:44 +0700
commit853b0ade469033c266c800ed2369bb21c94c59df (patch)
tree641432043bfb56e6f44d2ea61ebe66fa1d24edb7
parentb573a9b8defe30e7291b7f39ec372c5d2a15e947 (diff)
downloadepy-853b0ade469033c266c800ed2369bb21c94c59df.tar.gz
Cleaner doublespread
-rwxr-xr-xepy.py36
1 files changed, 24 insertions, 12 deletions
diff --git a/epy.py b/epy.py
index 0b96c4d..9190f26 100755
--- a/epy.py
+++ b/epy.py
@@ -59,6 +59,7 @@ CFG = {
"DictionaryClient": "auto",
"ShowProgressIndicator": True,
"PageScrollAnimation": True,
+ "StartWithDoubleSpread": False,
"TTSSpeed": 1,
"DarkColorFG": 252,
"DarkColorBG": 235,
@@ -92,7 +93,8 @@ CFG = {
"Quit": "q",
"Help": "?",
"SwitchColor": "c",
- "TTSToggle": "!"
+ "TTSToggle": "!",
+ "DoubleSpreadToggle": "D"
}
}
STATE = {
@@ -126,7 +128,7 @@ ALLPREVLETTERS = []
SUMALLLETTERS = 0
PROC_COUNTLETTERS = None
ANIMATE = None
-SPREAD = 2
+SPREAD = 1
class Epub:
@@ -1606,7 +1608,9 @@ def reader(ebook, index, width, y, pctg, sect):
k = 0 if SEARCHPATTERN is None else ord("/")
rows, cols = SCREEN.getmaxyx()
- if cols < 2 + 22 + 3 + 22 + 2:
+
+ mincols_doublespr = 2 + 22 + 3 + 22 + 2
+ if cols < mincols_doublespr:
SPREAD = 1
if SPREAD == 2:
width = (cols-7)//2
@@ -1699,6 +1703,15 @@ def reader(ebook, index, width, y, pctg, sect):
if totlines-y <= rows and index == len(contents)-1:
SPEAKING = False
continue
+ elif k in K["DoubleSpreadToggle"]:
+ if cols < mincols_doublespr:
+ k = text_win(lambda: (
+ "Screen is too small",
+ "Min: {} cols x {} rows".format(mincols_doublespr, 12),
+ {ord("D")}
+ ))()
+ SPREAD = (SPREAD % 2) + 1
+ return 0, width, 0, y/totlines, ""
elif k in K["ScrollUp"]:
if SPREAD == 2:
k = list(K["PageUp"])[0]
@@ -1996,20 +2009,18 @@ def reader(ebook, index, width, y, pctg, sect):
SCREEN.refresh()
if ANIMATE == "next":
pad.refresh(y, 0, 0, x+width-i, rows-1, x+width)
+ if SPREAD == 2 and y+rows < totlines:
+ pad.refresh(y+rows, 0, 0, cols-2-i, rows-1, cols-2)
elif ANIMATE == "prev":
pad.refresh(y, width-i-1, 0, x, rows-1, x+i)
+ if SPREAD == 2 and y+rows < totlines:
+ pad.refresh(y+rows, width-i-1, 0, cols-2-width, rows-1, cols-2-width+i)
else:
pad.refresh(y, 0, 0, x, rows-1, x+width)
+ if SPREAD == 2 and y+rows < totlines:
+ pad.refresh(y+rows, 0, 0, cols-2-width, rows-1, cols-2)
ANIMATE = None
- if SPREAD == 2:
- try:
- if y+rows < totlines:
- # sys.exit(f"{totlines}-{y+rows}")
- pad.refresh(y+rows, 0, 0, cols-2-width, rows-1, cols-2)
- except Exception as e:
- sys.exit(str(e))
-
LOCALSUMALLL = SUMALLLETTERS.value if MULTIPROC else SUMALLLETTERS
if SHOWPROGRESS and (cols-width-2)//2 > 3 and LOCALSUMALLL != 0:
PROGRESS = (ALLPREVLETTERS[index] + sum(LOCALPCTG[:y+rows-1])) / LOCALSUMALLL
@@ -2051,7 +2062,7 @@ def reader(ebook, index, width, y, pctg, sect):
def preread(stdscr, file):
- global COLORSUPPORT, SHOWPROGRESS, SCREEN
+ global COLORSUPPORT, SHOWPROGRESS, SCREEN, SPREAD
try:
curses.use_default_colors()
@@ -2099,6 +2110,7 @@ def preread(stdscr, file):
find_dict_client()
parse_keys()
SHOWPROGRESS = CFG["ShowProgressIndicator"]
+ SPREAD = 2 if CFG["StartWithDoubleSpread"] else 1
count_max_reading_pg(ebook)
sec = ""