forked from endorphant/ttbp
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 util
|
||||
|
||||
__version__ = "0.9.1b"
|
||||
__version__ = "0.9.2b"
|
||||
__author__ = "endorphant <endorphant@tilde.town)"
|
||||
|
||||
## system globals
|
||||
|
@ -365,7 +365,7 @@ def main_menu():
|
|||
"review your feels",
|
||||
"check out your neighbors",
|
||||
"browse global feels",
|
||||
"scribble some graffiti\t(new!)",
|
||||
"scribble some graffiti",
|
||||
"change your settings",
|
||||
"send some feedback",
|
||||
"see credits",
|
||||
|
@ -574,6 +574,8 @@ def view_feels(townie):
|
|||
for entry in os.listdir(entryDir):
|
||||
filenames.append(os.path.join(entryDir, entry))
|
||||
metas = core.meta(filenames)
|
||||
metas.sort(key = lambda entry:entry[4])
|
||||
metas.reverse()
|
||||
|
||||
if len(filenames) > 0:
|
||||
entries = []
|
||||
|
@ -699,9 +701,12 @@ def list_entries(metas, entries, prompt):
|
|||
displays a list of entries for reading selection
|
||||
'''
|
||||
|
||||
'''
|
||||
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.menu_handler(entries, "pick an entry from the list, or type 'q' to go back: ", 10, RAINBOW)
|
||||
|
||||
if choice is not False:
|
||||
|
||||
|
@ -794,11 +799,7 @@ def select_editor():
|
|||
'''
|
||||
|
||||
util.print_menu(EDITORS, RAINBOW)
|
||||
|
||||
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:
|
||||
redraw("please pick a text editor!")
|
||||
|
@ -1059,6 +1060,15 @@ ver 0.9.1 features:
|
|||
* 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__':
|
||||
|
|
|
@ -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.sort(key = lambda filename:filename[4])
|
||||
meta.reverse()
|
||||
#meta.sort(key = lambda filename:filename[4])
|
||||
#meta.reverse()
|
||||
|
||||
return meta
|
||||
|
||||
|
|
|
@ -501,6 +501,8 @@ def view_feels(townie):
|
|||
for entry in os.listdir(entryDir):
|
||||
filenames.append(os.path.join(entryDir, entry))
|
||||
metas = core.meta(filenames)
|
||||
metas.sort(key = lambda entry:entry[4])
|
||||
metas.reverse()
|
||||
|
||||
if len(filenames) > 0:
|
||||
entries = []
|
||||
|
|
59
bin/util.py
59
bin/util.py
|
@ -31,6 +31,7 @@ import colorama
|
|||
|
||||
## misc globals
|
||||
BACKS = ['back', 'b', 'q']
|
||||
NAVS = ['u', 'd']
|
||||
|
||||
## color stuff
|
||||
colorama.init()
|
||||
|
@ -146,6 +147,61 @@ def genID(digits=5):
|
|||
|
||||
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):
|
||||
'''
|
||||
A pretty menu handler that takes an incoming lists of
|
||||
|
@ -183,6 +239,9 @@ def list_select(options, prompt):
|
|||
if choice in BACKS:
|
||||
return False
|
||||
|
||||
if choice in NAVS:
|
||||
return choice
|
||||
|
||||
try:
|
||||
ans = int(choice)
|
||||
except ValueError:
|
||||
|
|
Loading…
Reference in New Issue