ncurses menu adapts when window is resized
This commit is contained in:
parent
aad657b76b
commit
b63e04943a
14
gempost
14
gempost
|
@ -54,6 +54,7 @@ def menuFunction(menu = [], headerLine = "Use the arrow keys or j,k to make a se
|
||||||
|
|
||||||
highlight, highlight_prev = 0, 0 # variable that controls which entry is selected, variable that stores its previous value
|
highlight, highlight_prev = 0, 0 # variable that controls which entry is selected, variable that stores its previous value
|
||||||
while True:
|
while True:
|
||||||
|
sy, sx = stdscr.getmaxyx() # getting terminal dimensions again to adapt to window resize events while the menu is being displayed
|
||||||
stdscr.clear()
|
stdscr.clear()
|
||||||
|
|
||||||
if (highlight >= endOfPage): # incrementing page number
|
if (highlight >= endOfPage): # incrementing page number
|
||||||
|
@ -91,7 +92,13 @@ def menuFunction(menu = [], headerLine = "Use the arrow keys or j,k to make a se
|
||||||
|
|
||||||
for sno in range(len(imenu)):
|
for sno in range(len(imenu)):
|
||||||
if (sno == highlight):
|
if (sno == highlight):
|
||||||
entry = str(((pageLength)*(pageIndex-1)) + (sno+1)) + " - " + imenu[sno]
|
entry = str(((pageLength)*(pageIndex-1)) + (sno+1)) + " - " + imenu[sno] # the menu entry
|
||||||
|
|
||||||
|
"""
|
||||||
|
TODO:
|
||||||
|
- exit displaying an error if terminal too small
|
||||||
|
"""
|
||||||
|
|
||||||
stdscr.addstr(f"\n{entry}{' '*(sx - len(entry) - 1)}", curses.A_STANDOUT)
|
stdscr.addstr(f"\n{entry}{' '*(sx - len(entry) - 1)}", curses.A_STANDOUT)
|
||||||
else:
|
else:
|
||||||
stdscr.addstr(f"\n{((pageLength)*(pageIndex-1)) + (sno+1)} - {imenu[sno]}")
|
stdscr.addstr(f"\n{((pageLength)*(pageIndex-1)) + (sno+1)} - {imenu[sno]}")
|
||||||
|
@ -296,6 +303,11 @@ def manage(direct = ""):
|
||||||
print("\nCancelled.")
|
print("\nCancelled.")
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
"""
|
||||||
|
TODO:
|
||||||
|
- remove the following number input based interface with pressing keys for delete, edit and cancel
|
||||||
|
"""
|
||||||
|
|
||||||
print(f"\nYou have selected:\n\nTITLE: {postsList[which][1][:-1]}\nFILENAME: {postsList[which][0]}.gmi")
|
print(f"\nYou have selected:\n\nTITLE: {postsList[which][1][:-1]}\nFILENAME: {postsList[which][0]}.gmi")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue