removed redundant sort on file listing; sort on file lists should now
only be called on the specific incantation. wrote a preliminary list scroller on beta only.master
parent
2003af31f8
commit
281d8cda06
24
bin/_ttbp.py
24
bin/_ttbp.py
|
@ -45,7 +45,7 @@ import chatter
|
||||||
import inflect
|
import inflect
|
||||||
import util
|
import util
|
||||||
|
|
||||||
__version__ = "0.9.1b"
|
__version__ = "0.9.2b"
|
||||||
__author__ = "endorphant <endorphant@tilde.town)"
|
__author__ = "endorphant <endorphant@tilde.town)"
|
||||||
|
|
||||||
## system globals
|
## system globals
|
||||||
|
@ -365,7 +365,7 @@ def main_menu():
|
||||||
"review your feels",
|
"review your feels",
|
||||||
"check out your neighbors",
|
"check out your neighbors",
|
||||||
"browse global feels",
|
"browse global feels",
|
||||||
"scribble some graffiti\t(new!)",
|
"scribble some graffiti",
|
||||||
"change your settings",
|
"change your settings",
|
||||||
"send some feedback",
|
"send some feedback",
|
||||||
"see credits",
|
"see credits",
|
||||||
|
@ -574,6 +574,8 @@ def view_feels(townie):
|
||||||
for entry in os.listdir(entryDir):
|
for entry in os.listdir(entryDir):
|
||||||
filenames.append(os.path.join(entryDir, entry))
|
filenames.append(os.path.join(entryDir, entry))
|
||||||
metas = core.meta(filenames)
|
metas = core.meta(filenames)
|
||||||
|
metas.sort(key = lambda entry:entry[4])
|
||||||
|
metas.reverse()
|
||||||
|
|
||||||
if len(filenames) > 0:
|
if len(filenames) > 0:
|
||||||
entries = []
|
entries = []
|
||||||
|
@ -699,9 +701,12 @@ def list_entries(metas, entries, prompt):
|
||||||
displays a list of entries for reading selection
|
displays a list of entries for reading selection
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
'''
|
||||||
util.print_menu(entries, RAINBOW)
|
util.print_menu(entries, RAINBOW)
|
||||||
|
|
||||||
choice = util.list_select(entries, "pick an entry from the list, or type 'back' or 'q' to go back: ")
|
choice = util.list_select(entries, "pick an entry from the list, or type 'back' or 'q' to go back: ")
|
||||||
|
'''
|
||||||
|
|
||||||
|
choice = util.menu_handler(entries, "pick an entry from the list, or type 'q' to go back: ", 10, RAINBOW)
|
||||||
|
|
||||||
if choice is not False:
|
if choice is not False:
|
||||||
|
|
||||||
|
@ -794,11 +799,7 @@ def select_editor():
|
||||||
'''
|
'''
|
||||||
|
|
||||||
util.print_menu(EDITORS, RAINBOW)
|
util.print_menu(EDITORS, RAINBOW)
|
||||||
|
|
||||||
choice = util.list_select(EDITORS, "pick your favorite text editor: ")
|
choice = util.list_select(EDITORS, "pick your favorite text editor: ")
|
||||||
#choice = raw_input("\npick your favorite text editor: ")
|
|
||||||
#while choice not in ['0', '1', '2', '3', '4', '5']:
|
|
||||||
# choice = raw_input("\nplease pick a number from the list: ")
|
|
||||||
|
|
||||||
if choice is False:
|
if choice is False:
|
||||||
redraw("please pick a text editor!")
|
redraw("please pick a text editor!")
|
||||||
|
@ -1059,6 +1060,15 @@ ver 0.9.1 features:
|
||||||
* graffiti wall
|
* graffiti wall
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
if userVersion[0:5] < "0.9.2":
|
||||||
|
# version 0.9.2 patch notes
|
||||||
|
print("""
|
||||||
|
ver 0.9.2 features:
|
||||||
|
* paginated entry view
|
||||||
|
* expanded menu for viewing your own feels (further
|
||||||
|
features to be implemented)
|
||||||
|
""")
|
||||||
|
|
||||||
#####
|
#####
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -5,5 +5,5 @@
|
||||||
| |___ |___ |___ | [__ |___ |\ | | __ | |\ | |___ |
|
| |___ |___ |___ | [__ |___ |\ | | __ | |\ | |___ |
|
||||||
| | |___ |___ |___ ___] |___ | \| |__] | | \| |___ |
|
| | |___ |___ |___ ___] |___ | \| |__] | | \| |___ |
|
||||||
| |
|
| |
|
||||||
| ver 0.9.1 (almost stable) |
|
| ver 0.9.2 (almost stable) |
|
||||||
|__________________________________________________________|
|
|__________________________________________________________|
|
||||||
|
|
|
@ -300,8 +300,8 @@ def meta(entries = FILES):
|
||||||
|
|
||||||
meta.append([filename, mtime, wc, timestamp, date, author])
|
meta.append([filename, mtime, wc, timestamp, date, author])
|
||||||
|
|
||||||
meta.sort(key = lambda filename:filename[4])
|
#meta.sort(key = lambda filename:filename[4])
|
||||||
meta.reverse()
|
#meta.reverse()
|
||||||
|
|
||||||
return meta
|
return meta
|
||||||
|
|
||||||
|
|
|
@ -501,6 +501,8 @@ def view_feels(townie):
|
||||||
for entry in os.listdir(entryDir):
|
for entry in os.listdir(entryDir):
|
||||||
filenames.append(os.path.join(entryDir, entry))
|
filenames.append(os.path.join(entryDir, entry))
|
||||||
metas = core.meta(filenames)
|
metas = core.meta(filenames)
|
||||||
|
metas.sort(key = lambda entry:entry[4])
|
||||||
|
metas.reverse()
|
||||||
|
|
||||||
if len(filenames) > 0:
|
if len(filenames) > 0:
|
||||||
entries = []
|
entries = []
|
||||||
|
|
59
bin/util.py
59
bin/util.py
|
@ -31,6 +31,7 @@ import colorama
|
||||||
|
|
||||||
## misc globals
|
## misc globals
|
||||||
BACKS = ['back', 'b', 'q']
|
BACKS = ['back', 'b', 'q']
|
||||||
|
NAVS = ['u', 'd']
|
||||||
|
|
||||||
## color stuff
|
## color stuff
|
||||||
colorama.init()
|
colorama.init()
|
||||||
|
@ -146,6 +147,61 @@ def genID(digits=5):
|
||||||
|
|
||||||
return id
|
return id
|
||||||
|
|
||||||
|
def menu_handler(options, prompt, pagify=10, rainbow=False):
|
||||||
|
'''
|
||||||
|
This menu handler takes an incoming list of options, pagifies to a
|
||||||
|
pre-set value, and queries via the prompt. Calls print_menu() and
|
||||||
|
list_select() as helpers.
|
||||||
|
'''
|
||||||
|
|
||||||
|
optCount = len(options)
|
||||||
|
page = 0
|
||||||
|
total = optCount / pagify
|
||||||
|
|
||||||
|
# don't display empty pages
|
||||||
|
if optCount % pagify == 0:
|
||||||
|
total = total - 1
|
||||||
|
|
||||||
|
if total < 2:
|
||||||
|
print_menu(options, rainbow)
|
||||||
|
return list_select(options, prompt)
|
||||||
|
|
||||||
|
else:
|
||||||
|
return page_helper(options, prompt, pagify, rainbow, page, total)
|
||||||
|
|
||||||
|
|
||||||
|
def page_helper(options, prompt, pagify, rainbow, page, total):
|
||||||
|
'''
|
||||||
|
A helper to process pagination.
|
||||||
|
'''
|
||||||
|
|
||||||
|
## make short list
|
||||||
|
x = 0 + page * pagify
|
||||||
|
y = x + pagify
|
||||||
|
optPage = options[x:y]
|
||||||
|
|
||||||
|
print_menu(optPage, prompt)
|
||||||
|
print("\n\t( page {page} of {total}; type 'u' or 'd' to scroll up and down )").format(page=page+1, total=total+1)
|
||||||
|
|
||||||
|
ans = list_select(optPage, prompt)
|
||||||
|
|
||||||
|
if ans in NAVS:
|
||||||
|
if ans == 'u':
|
||||||
|
if page == 0:
|
||||||
|
print("can't scroll up anymore!")
|
||||||
|
else:
|
||||||
|
page = page - 1
|
||||||
|
else:
|
||||||
|
if page == total:
|
||||||
|
print("can't scroll down anymore!")
|
||||||
|
else:
|
||||||
|
page = page + 1
|
||||||
|
|
||||||
|
print("")
|
||||||
|
return page_helper(options, prompt, pagify, rainbow, page, total)
|
||||||
|
|
||||||
|
return ans
|
||||||
|
|
||||||
def print_menu(menu, rainbow=False):
|
def print_menu(menu, rainbow=False):
|
||||||
'''
|
'''
|
||||||
A pretty menu handler that takes an incoming lists of
|
A pretty menu handler that takes an incoming lists of
|
||||||
|
@ -183,6 +239,9 @@ def list_select(options, prompt):
|
||||||
if choice in BACKS:
|
if choice in BACKS:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
if choice in NAVS:
|
||||||
|
return choice
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ans = int(choice)
|
ans = int(choice)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
|
Loading…
Reference in New Issue