本文整理汇总了Python中x84.bbs.gosub函数的典型用法代码示例。如果您正苦于以下问题:Python gosub函数的具体用法?Python gosub怎么用?Python gosub使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了gosub函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: main
def main():
""" Main menu entry point. """
from x84.default.common import display_banner
session, term = getsession(), getterminal()
text, width, height, dirty = u'', -1, -1, 2
menu_items = get_menu_items(session)
editor = get_line_editor(term, menu_items)
while True:
if dirty == 2:
# set syncterm font, if any
if syncterm_font and term.kind.startswith('ansi'):
echo(syncterm_setfont(syncterm_font))
if dirty:
session.activity = 'main menu'
top_margin = display_banner(art_file, encoding=art_encoding) + 1
echo(u'\r\n')
if width != term.width or height != term.height:
width, height = term.width, term.height
text = render_menu_entries(term, top_margin, menu_items)
echo(u''.join((text, display_prompt(term), editor.refresh())))
dirty = 0
event, data = session.read_events(('input', 'refresh'))
if event == 'refresh':
dirty = True
continue
elif event == 'input':
session.buffer_input(data, pushback=True)
# we must loop over inkey(0), we received a 'data'
# event, though there may be many keystrokes awaiting for our
# decoding -- or none at all (multibyte sequence not yet complete).
inp = term.inkey(0)
while inp:
if inp.code == term.KEY_ENTER:
# find matching menu item,
for item in menu_items:
if item.inp_key == editor.content.strip():
echo(term.normal + u'\r\n')
gosub(item.script, *item.args, **item.kwargs)
editor.content = u''
dirty = 2
break
else:
if editor.content:
# command not found, clear prompt.
echo(u''.join((
(u'\b' * len(editor.content)),
(u' ' * len(editor.content)),
(u'\b' * len(editor.content)),)))
editor.content = u''
echo(editor.refresh())
elif inp.is_sequence:
echo(editor.process_keystroke(inp.code))
else:
echo(editor.process_keystroke(inp))
inp = term.inkey(0)
开发者ID:tehmaze,项目名称:x84,代码行数:60,代码来源:main.py
示例2: process_keystroke
def process_keystroke(inp, key=None):
""" Process general keystroke and call routines. """
from x84.bbs import getsession, DBProxy, gosub, echo
session = getsession()
if inp is None:
return False
elif type(inp) is int:
return False
elif inp in (u't', u'T') and key is not None:
bbs = DBProxy('bbslist')[key]
gosub('telnet', bbs['address'], bbs['port'],)
elif inp in (u'a', u'A'):
add_bbs()
elif inp in (u'c', u'C') and key is not None:
add_comment(key)
elif inp in (u'r', u'R') and key is not None:
rate_bbs(key)
elif inp in (u'i', u'I') and key is not None:
echo(get_bbsinfo(key) + '\r\n')
elif inp in (u'v', u'V') and key is not None:
view_ansi(key)
elif inp in (u'd', u'D') and key is not None and (
'sysop' in session.user.groups):
del DBProxy('bbslist')[key]
else:
return False # unhandled
return True
开发者ID:jonny290,项目名称:yos-x84,代码行数:27,代码来源:bbslist.py
示例3: edit
def edit(sessions):
""" Prompt for node and gosub profile.py script for user of target session.
"""
from x84.bbs import gosub
(node, tgt_session) = get_node(sessions)
if node is not None:
gosub('profile', tgt_session['handle'])
return True
开发者ID:jonny290,项目名称:yos-x84,代码行数:8,代码来源:online.py
示例4: playback
def playback(sessions):
""" Prompt for node and gosub ttyplay script for ttyrec of target session.
"""
from x84.bbs import gosub
(node, tgt_session) = get_node(sessions)
if node is not None:
gosub('ttyplay', tgt_session['ttyrec'])
return True
开发者ID:jonny290,项目名称:yos-x84,代码行数:8,代码来源:online.py
示例5: chat
def chat(sessions):
"""
Prompt for node and page target session for chat.
Sysop will send session id of -1, indicating the chat is forced.
"""
from x84.bbs import gosub, getsession
(_, tgt_session) = get_node(sessions)
if tgt_session and tgt_session["sid"] != getsession().sid:
gosub("chat", dial=tgt_session["handle"], other_sid=tgt_session["sid"])
开发者ID:rostob,项目名称:x84,代码行数:10,代码来源:online.py
示例6: watch
def watch(sessions):
"""
Prompt for node and gosub ttyplay script for ttyrec of target session,
with 'peek' boolean set to True.
"""
from x84.bbs import gosub
(node, tgt_session) = get_node(sessions)
if node is not None:
gosub('ttyplay', tgt_session['ttyrec'], True)
return True
开发者ID:jonny290,项目名称:yos-x84,代码行数:10,代码来源:online.py
示例7: chat
def chat(sessions):
"""
Prompt for node and page target session for chat.
Sysop will send session id of -1, indicating the chat is forced.
"""
from x84.bbs import gosub, getsession
session = getsession()
(node, tgt_session) = get_node(sessions)
if tgt_session and tgt_session != session:
gosub('chat', dial=tgt_session['handle'],
other_sid=tgt_session['sid'])
开发者ID:tehmaze,项目名称:x84,代码行数:11,代码来源:online.py
示例8: sendmsg
def sendmsg(sessions):
"""
Prompt for node and gosub 'writemsg' with recipient set to target user.
"""
from x84.bbs import gosub, Msg
(node, tgt_session) = get_node(sessions)
if node is not None:
msg = Msg()
msg.recipient = tgt_session['handle']
msg.tags.add('private')
gosub('writemsg', msg)
return True
开发者ID:jonny290,项目名称:yos-x84,代码行数:12,代码来源:online.py
示例9: do_intro_art
def do_intro_art(term, session):
"""
Display random art file, prompt for quick login.
Bonus: allow chosing other artfiles with '<' and '>'.
"""
from x84.bbs import ini
show_intro_art = False
if ini.CFG.has_option('system', 'show_intro_art'):
show_intro_art = ini.CFG.getboolean('system', 'show_intro_art')
# set syncterm font, if any
if syncterm_font and term.kind.startswith('ansi'):
echo(syncterm_setfont(syncterm_font))
index = int(time.time()) % len(art_files)
dirty = True
echo(u'\r\n')
while True:
session.activity = 'top'
if session.poll_event('refresh') or dirty:
if show_intro_art:
display_intro(term, index)
else:
return True
display_prompt(term)
dirty = False
dirty = True
inp = LineEditor(1, colors={'highlight': term.normal}).read()
if inp is None or inp.lower() == u'y':
# escape/yes: quick login
return True
# issue #242 : set 'N' as default, by adding a check for an empty
# unicode string.
elif inp.lower() in (u'n', u'\r', u'\n', u''):
break
if len(inp) == 1:
echo(u'\b')
if inp == u'!':
echo(u'\r\n' * 3)
gosub('charset')
dirty = True
elif inp == u'<':
index -= 1
elif inp == u'>':
index += 1
else:
dirty = False
开发者ID:gofore,项目名称:x84,代码行数:48,代码来源:top.py
示例10: do_login
def do_login(term):
sep_ok = getattr(term, color_secondary)(u'::')
sep_bad = getattr(term, color_primary)(u'::')
colors = {'highlight': getattr(term, color_primary)}
for _ in range(login_max_attempts):
echo(u'\r\n\r\n{sep} Login: '.format(sep=sep_ok))
handle = LineEditor(username_max_length, colors=colors
).read() or u''
if handle.strip() == u'':
continue
# user says goodbye
if handle.lower() in bye_usernames:
return
# user applies for new account
if new_allowed and handle.lower() in new_usernames:
gosub(new_script)
display_banner(term)
continue
# user wants to reset password
if reset_allowed and handle.lower() == 'reset':
gosub(reset_script)
display_banner(term)
continue
# user wants to login anonymously
if anonymous_allowed and handle.lower() in anonymous_names:
user = User('anonymous')
else:
# authenticate password
echo(u'\r\n\r\n{sep} Password: '.format(sep=sep_ok))
password = LineEditor(password_max_length,
colors=colors,
hidden=hidden_char
).read() or u''
user = authenticate_user(handle, password)
if not user:
echo(u'\r\n\r\n{sep} Login failed.'.format(sep=sep_bad))
continue
goto(top_script, handle=user.handle)
echo(u'\r\n\r\n{sep} Too many authentication attempts.\r\n'
.format(sep=sep_bad))
开发者ID:gofore,项目名称:x84,代码行数:48,代码来源:matrix.py
示例11: prompt_body
def prompt_body(msg):
""" Prompt for 'body' of message, executing 'editor' script. """
from x84.bbs import echo, Selector, getterminal, getsession, gosub
term = getterminal()
session = getsession()
inp = Selector(yloc=term.height - 1,
xloc=term.width - 22,
width=20,
left=u'CONtiNUE', right=u'CANCEl')
# check for previously existing draft
if 0 != len(session.user.get('draft', u'')):
# XXX display age of message
inp = Selector(yloc=term.height - 1,
xloc=term.width - 22,
width=20,
left=u'REStORE', right=u'ERASE')
blurb = u'CONtiNUE PREViOUSlY SAVEd dRAft ?'
echo(u'\r\n\r\n')
echo(term.move(inp.yloc, inp.xloc - len(blurb)))
echo(term.bold_yellow(blurb))
selection = inp.read()
echo(term.move(inp.yloc, 0) + term.clear_eol)
if selection == u'REStORE':
msg.body = session.user['draft']
echo(u'\r\n\r\n')
session.user['draft'] = msg.body
if gosub('editor', 'draft'):
echo(u'\r\n\r\n' + term.normal)
msg.body = session.user.get('draft', u'')
del session.user['draft']
return 0 != len(msg.body.strip())
return False
开发者ID:donfanning,项目名称:x84,代码行数:34,代码来源:writemsg.py
示例12: chat
def chat(sessions):
"""
Prompt for node and page target session for chat.
Sysop will send session id of -1, indicating the chat is forced.
"""
from x84.bbs import gosub, getsession
session = getsession()
(node, tgt_session) = get_node(sessions)
if node is not None:
# page other user,
channel = tgt_session['sid']
sender = (session.user.handle
if not 'sysop' in session.user.groups else -1)
session.send_event('route', (
tgt_session['sid'], 'page', channel, sender))
gosub('chat', channel)
return True
开发者ID:jonny290,项目名称:yos-x84,代码行数:17,代码来源:online.py
示例13: main
def main():
""" Main procedure. """
# by default, nothing is done.
from x84.bbs import getsession, gosub
assert 'sysop' in getsession().user.groups
#return migrate_105lc()
#return nothing()
return gosub('test_keyboard_keys')
开发者ID:hick,项目名称:x84,代码行数:9,代码来源:debug.py
示例14: do_intro_art
def do_intro_art(term, session):
"""
Display random art file, prompt for quick login.
Bonus: allow chosing other artfiles with '<' and '>'.
"""
editor_colors = {'highlight': term.black_on_red}
# set syncterm font, if any
if syncterm_font and term._kind.startswith('ansi'):
echo(syncterm_setfont(syncterm_font))
index = int(time.time()) % len(art_files)
dirty = True
echo(u'\r\n')
while True:
session.activity = 'top'
if session.poll_event('refresh') or dirty:
display_intro(term, index)
display_prompt(term)
dirty = False
dirty = True
inp = LineEditor(1, colors=editor_colors).read()
if inp is None or inp.lower() == u'y':
# escape/yes: quick login
return True
elif inp.lower() == u'n':
break
if len(inp) == 1:
echo(u'\b')
if inp == u'!':
echo(u'\r\n' * 3)
gosub('charset')
dirty = True
elif inp == u'<':
index -= 1
elif inp == u'>':
index += 1
else:
dirty = False
开发者ID:ztaylor,项目名称:x84,代码行数:41,代码来源:top.py
示例15: main
def main():
""" Main procedure. """
from x84.bbs import getsession, getterminal, echo, getch, gosub
session, term = getsession(), getterminal()
lcallers, lcalls_txt = lc_retrieve()
lbr = None
dirty = True
handle = None
if (0 == term.number_of_colors
or session.user.get('expert', False)):
echo(redraw(None))
return dummy_pager(lcalls_txt.split('\n'))
while lbr is None or not lbr.quit:
if dirty or lbr is None or session.poll_event('refresh'):
session.activity = u'Viewing last callers'
lcallers, lcalls_txt = lc_retrieve()
pos = lbr.position if lbr is not None else (0, 0)
lbr = get_lightbar(lcallers, lcalls_txt)
if pos:
lbr.position = pos
echo(redraw(lbr))
echo(refresh_opts(lbr, handle))
sel = lbr.selection[0]
if sel != handle or dirty:
handle = sel
echo(refresh_opts(lbr, handle))
echo(lbr.pos(lbr.yloc + (lbr.height - 1)))
dirty = False
continue
inp = getch(1)
if inp is not None:
if inp in (u'v', u'V'):
view_plan(handle)
dirty = True
elif inp in (u'e', u'E') and 'sysop' in session.user.groups:
gosub('profile', handle)
dirty = True
else:
echo(lbr.process_keystroke(inp))
开发者ID:quastdog,项目名称:x84,代码行数:41,代码来源:lc.py
示例16: edit_description
def edit_description(filepath, db_desc):
""" Edit file description. """
from x84.bbs import gosub
new_desc = None
if filepath in db_desc:
new_desc = u'\r\n'.join([line.decode('cp437_art')
for line in db_desc[filepath]])
new_desc = gosub('editor', continue_draft=new_desc)
if not new_desc:
return
with db_desc:
db_desc[filepath] = new_desc.splitlines()
开发者ID:jquast,项目名称:x84,代码行数:12,代码来源:fbrowse.py
示例17: try_reset
def try_reset(user):
""" Prompt for password reset. """
from x84.bbs import echo, getch, gosub
prompt_reset = u'RESEt PASSWORD (bY E-MAil)? [yn]'
echo(prompt_reset)
while True:
inp = getch()
if inp in (u'y', u'Y'):
return gosub('pwreset', user.handle)
elif inp in (u'n', u'N'):
echo(u'\r\n\r\n')
return False
开发者ID:donfanning,项目名称:x84,代码行数:12,代码来源:matrix.py
示例18: main
def main(handle=None):
""" Main procedure. """
# pylint: disable=R0914,R0912,R0915
# Too many local variables
# Too many branches
# Too many statements
session, term = getsession(), getterminal()
session.activity = 'top'
# attempt to coerce encoding of terminal to match session.
coerce_terminal_encoding(term, session.encoding)
# fetch user record
user = get_user_record(handle)
# register call
login(session, user)
# display art and prompt for quick login
quick = do_intro_art(term, session)
echo(term.move_down() * 3)
# only display news if the account has not
# yet read the news since last update.
gosub('news', quick=True)
if not quick:
# display last 10 callers, if any
gosub('lc')
# one-liners
gosub('ol')
goto('main')
开发者ID:hick,项目名称:x84,代码行数:35,代码来源:top.py
示例19: main
def main():
session, term = getsession(), getterminal()
session.activity = u'bulletins menu'
dirty = True
while True:
if dirty or session.poll_event('refresh'):
echo(term.clear())
showansi('bulletinsmenu.ans')
echo(u'\r\n' + term.normal + term.white +
u' [' + term.blue + u'Select bulletin' + term.white + u']: ')
inp = getch()
dirty = True
if inp == u'1':
toplist('calls')
elif inp == u'2':
toplist('msgs')
elif inp == u'3':
gosub('textbrowse')
else: # any other key will return to main menu
return
开发者ID:carriercomm,项目名称:bulletins,代码行数:22,代码来源:bulletins.py
示例20: prompt_body
def prompt_body(term, msg, colors):
""" Prompt for and set 'body' of message by executing 'editor' script. """
with term.fullscreen():
content = gosub("editor", save_key=None, continue_draft=msg.body)
# set syncterm font, if any
if term.kind.startswith("ansi"):
echo(syncterm_setfont(syncterm_font))
echo(term.move(term.height, 0) + term.normal + u"\r\n")
if content and content.strip():
msg.body = content
return True
xpos = max(0, (term.width // 2) - (80 // 2))
echo(u"".join((term.move_x(xpos), colors["highlight"]("Message canceled."), term.clear_eol)))
term.inkey(1)
return False
开发者ID:gofore,项目名称:x84,代码行数:15,代码来源:msgarea.py
注:本文中的x84.bbs.gosub函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论