def get_lightbar(lcallers, lcalls): """ Return UI element for browsing last callers, given ``lcallers`` as a list of handles, and parallel array ``lcalls`` as unicode string to display for last call of each handle. """ from x84.bbs import getterminal, Lightbar term = getterminal() width = min(50, max(10, term.width - 5)) height = max(4, min(term.height - 8, 35)) xloc = (term.width / 2) - (width / 2) yloc = term.height - height pager = Lightbar(height, width, yloc, xloc) pager.glyphs['left-vert'] = pager.glyphs['right-vert'] = u'' pager.colors['highlight'] = term.red_reverse pager.colors['border'] = term.yellow pager.xpadding, pager.ypadding = 2, 1 pager.alignment = 'center' pager.update([(lcallers[n], txt,) for (n, txt) in enumerate(lcalls.split('\n'))]) return pager
def lb_init(position=None, menu_index=None): """ Initialize Lightbar Main Menu """ from x84.bbs import getsession, getterminal, echo, showart, ini, Lightbar import os import logging logger = logging.getLogger() session, term = getsession(), getterminal() session.activity = u'Lightbar main menu' # set up lightbar pager, determine terminal dimensions term = getterminal() height = term.height - 11 lb_width = int(term.width * .4) lb_xloc = int(term.width * .3) lightbar = Lightbar(height, lb_width, (term.height - height - 1), lb_xloc) # Lightbar main menu entries entries = [ #('', '-----[COmMs]-----'), ('$', 'rEAD bUllETiNS'), ('n', 'latest nEWS'), ('p', 'pOSt A MSG'), ('r', 'rEAd All MSGS'), ('c', 'chAt'), ('i', 'iRC chAt'), #('', ' '), #('', '----[SeRVIcES]----'), ('l', 'lASt CAllS'), ('o', 'oNE liNERS'), ('b', 'bbS NEXUS'), ('f', 'WeAThER fORECASt'), ('t', 'tEtRiS'), ('w', "whO'S ONliNE"), #('', ' '), #('', '-----[SySTeM]-----'), ('!', 'ENCOdiNG'), ('s', 'sYS. iNfO'), ('u', 'uSER LiST'), ('e', 'edit PROfilE'), ] if ini.CFG.getboolean( 'dosemu', 'enabled') and (ini.CFG.get('dosemu', 'lord_path') != 'no'): entries.insert(0, ('#', 'PlAY lORd!')) # add sesame doors to menu if enabled if ini.CFG.has_section('sesame'): from ConfigParser import NoOptionError for door in ini.CFG.options('sesame'): if '_' in door: continue # .. but only if we have the binary if not os.path.exists(ini.CFG.get('sesame', door)): continue # .. and a key is configured try: key = ini.CFG.get('sesame', '{}_key'.format(door)) except NoOptionError: logger.error("no key configured for sesame door '{}'".format( door, )) else: logger.debug("added sesame door '{}' with key '{}'".format( door, key)) entries.insert(0, (key, 'PlAY {}'.format(door))) if 'sysop' in session.user.groups: entries += (('v', 'VidEO CASSEttE'), ) entries += (('g', 'gOOdbYE /lOGOff'), ) lightbar.update(entries) if menu_index is not None: lightbar.goto(menu_index) # set up some nice colors lightbar.colors['highlight'] = term.bold_cyan_reverse lightbar.colors['border'] = term.bold_blue lightbar.xpadding, lightbar.ypadding = 2, 1 lightbar.alignment = 'center' # set lightbar theme #lightbar.init_theme() ## re-select previous selection if position is not None: lightbar.position = position return (lightbar)
def lb_init(position=None, menu_index=None): """ Initialize Lightbar Main Menu """ from x84.bbs import getsession, getterminal, ini, Lightbar import os import logging logger = logging.getLogger() session, term = getsession(), getterminal() session.activity = u'Lightbar main menu' # set up lightbar pager, determine terminal dimensions term = getterminal() height = term.height - 11 lb_width = int(term.width * .4) lb_xloc = int(term.width * .3) lightbar = Lightbar(height, lb_width, (term.height - height - 1), lb_xloc) # Lightbar main menu entries entries = [ ('', '-----[COmMs]-----'), ('$', 'rEAD bUllETiNS'), ('n', 'latest nEWS'), ('hn', 'hACkEr nEWS'), # ('p', 'pOSt A MSG'), ('r', 'MEsSAgE ArEAs'), ('c', 'chAt'), ('i', 'iRC chAt'), ('', ' '), ('', '----[FIleS]----'), ('fb', 'FIle BrOWsEr'), ('', ' '), ('', '----[SeRVIcES]----'), ('l', 'lASt CAllS'), ('o', 'oNE liNERS'), ('b', 'bbS NEXUS'), ('f', 'WeAThER fORECASt'), ('t', 'tEtRiS'), ('v', "vOtINg BoOth"), ('w', "whO'S ONliNE"), ('', ' '), ('', '-----[SySTeM]-----'), ('!', 'ENCOdiNG'), ('kb', 'kEYbOaRd tESt'), ('s', 'sYS. iNfO'), ('u', 'uSER LiST'), ('e', 'edit PROfilE'), ] if ini.CFG.getboolean('dosemu', 'enabled') and ( ini.CFG.get('dosemu', 'lord_path') != 'no'): entries.insert(0, ('#', 'PlAY lORd!')) # add sesame doors to menu if enabled if ini.CFG.has_section('sesame'): from ConfigParser import NoOptionError for door in ini.CFG.options('sesame'): if '_' in door: continue # .. but only if we have the binary if not os.path.exists(ini.CFG.get('sesame', door)): continue # .. and a key is configured try: key = ini.CFG.get('sesame', '{}_key'.format(door)) except NoOptionError: logger.error("no key configured for sesame door '{}'".format( door, )) else: logger.debug("added sesame door '{}' with key '{}'".format( door, key )) entries.insert(0, (key, 'PlAY {}'.format(door))) if 'sysop' in session.user.groups: entries += (('v', 'VidEO CASSEttE'),) entries += (('g', 'gOOdbYE /lOGOff'),) lightbar.update(entries) if menu_index is not None: lightbar.goto(menu_index) # set up some nice colors lightbar.colors['highlight'] = term.bold_cyan_reverse lightbar.colors['border'] = term.bold_blue lightbar.xpadding, lightbar.ypadding = 2, 1 lightbar.alignment = 'center' # set lightbar theme # lightbar.init_theme() # re-select previous selection if position is not None: lightbar.position = position return (lightbar)