本文整理汇总了Python中x84.bbs.session.getterminal函数的典型用法代码示例。如果您正苦于以下问题:Python getterminal函数的具体用法?Python getterminal怎么用?Python getterminal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getterminal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: backspace
def backspace(self):
"""
Remove character from end of content buffer,
scroll as necessary.
"""
if 0 == len(self.content):
return u''
from x84.bbs.session import getterminal
term = getterminal()
rstr = u''
# measured backspace erases over double-wide
len_toss = term.length(self.content[-1])
len_move = len(self.content[-1])
self.content = self.content[:-1]
if (self.is_scrolled and (self._horiz_pos < self.scroll_amt)):
# shift left,
self._horiz_shift -= self.scroll_amt
self._horiz_pos += self.scroll_amt
rstr += self.refresh()
else:
rstr += u''.join((
self.fixate(0),
u'\b' * len_toss,
u' ' * len_move,
u'\b' * len_move,))
self._horiz_pos -= 1
return rstr
开发者ID:hick,项目名称:x84,代码行数:28,代码来源:editor.py
示例2: process_keystroke
def process_keystroke(self, keystroke):
"""
Process the keystroke received by run method and return terminal
sequence suitable for refreshing when that keystroke modifies the
window.
"""
from x84.bbs.session import getterminal
term = getterminal()
self.moved = False
rstr = u''
if keystroke in self.keyset['refresh']:
rstr += self.refresh()
elif keystroke in self.keyset['up']:
rstr += self.move_up()
elif keystroke in self.keyset['down']:
rstr += self.move_down()
elif keystroke in self.keyset['home']:
rstr += self.move_home()
elif keystroke in self.keyset['end']:
rstr += self.move_end()
elif keystroke in self.keyset['pgup']:
rstr += self.move_pgup()
elif keystroke in self.keyset['pgdown']:
rstr += self.move_pgdown()
elif keystroke in self.keyset['exit']:
self._quit = True
else:
logger = logging.getLogger()
logger.debug('unhandled, %r', keystroke)
return rstr
开发者ID:donfanning,项目名称:x84,代码行数:30,代码来源:pager.py
示例3: __init__
def __init__(self, cmd='/bin/uname', args=(), env=None, cp437=False):
"""
Class initializer.
:param str cmd: full path of command to execute.
:param tuple args: command arguments as tuple.
:param bool cp437: When true, forces decoding of external program as
codepage 437. This is the most common encoding used
by DOS doors.
:param dict env: Environment variables to extend to the sub-process.
You should more than likely specify values for TERM,
PATH, HOME, and LANG.
"""
self._session, self._term = getsession(), getterminal()
self.cmd = cmd
if isinstance(args, tuple):
self.args = (self.cmd,) + args
elif isinstance(args, list):
self.args = [self.cmd, ] + args
else:
raise ValueError('args must be tuple or list')
self.log = logging.getLogger(__name__)
self.env = (env or {}).copy()
self.env.update(
{'LANG': env.get('LANG', 'en_US.UTF-8'),
'TERM': env.get('TERM', self._term.kind),
'PATH': env.get('PATH', get_ini('door', 'path')),
'HOME': env.get('HOME', os.getenv('HOME')),
'LINES': str(self._term.height),
'COLUMNS': str(self._term.width),
})
self.cp437 = cp437
self._utf8_decoder = codecs.getincrementaldecoder('utf8')()
开发者ID:adammendoza,项目名称:x84,代码行数:35,代码来源:door.py
示例4: eol
def eol(self):
"""
Return True when no more input can be accepted (end of line).
"""
from x84.bbs.session import getterminal
term = getterminal()
return term.length(self.content) >= self.max_length
开发者ID:hick,项目名称:x84,代码行数:7,代码来源:editor.py
示例5: __init__
def __init__(self, *args, **kwargs):
"""
Class constructor.
:param int width: width of window.
:param int yloc: y-location of window.
:param int xloc: x-location of window.
:param int max_length: maximum length of input (may be larger than width).
:param dict colors: color theme, only key value of ``highlight`` is used.
:param dict glyphs: bordering window character glyphs.
:param dict keyset: command keys, global ``PC_KEYSET`` is used by default.
"""
self._term = getterminal()
self._horiz_shift = 0
self._horiz_pos = 0
# self._enable_scrolling = False
self._horiz_lastshift = 0
self._scroll_pct = kwargs.pop('scroll_pct', 25.0)
self._margin_pct = kwargs.pop('margin_pct', 10.0)
self._carriage_returned = False
self._max_length = kwargs.pop('max_length', 0)
self._quit = False
self._bell = False
self.content = kwargs.pop('content', u'')
self._input_length = self._term.length(self.content)
# there are some flaws about how a 'height' of a window must be
# '3', even though we only want 1; we must also offset (y, x) by
# 1 and width by 2: issue #161.
kwargs['height'] = 3
self.init_keystrokes(keyset=kwargs.pop('keyset', PC_KEYSET.copy()))
AnsiWindow.__init__(self, *args, **kwargs)
开发者ID:tehmaze,项目名称:x84,代码行数:31,代码来源:editor.py
示例6: __init__
def __init__(self, height, width, yloc, xloc, colors=None, glyphs=None):
"""
Class constructor for base windowing class.
:param int width: width of window.
:param int height: height of window.
:param int yloc: y-location of window.
:param int xloc: x-location of window.
:param dict colors: color theme, only key value of ``highlight`` is used.
:param dict glyphs: bordering window character glyphs.
"""
self.height = height
self.width = width
self.yloc = yloc
self.xloc = xloc
self.init_theme(colors, glyphs)
self._xpadding = 1
self._ypadding = 1
self._alignment = 'left'
self._moved = False
if not self.isinview():
# https://github.com/jquast/x84/issues/161
warnings.warn(
'AnsiWindow(height={self.height}, width={self.width}, '
'yloc={self.yloc}, xloc={self.xloc}) not in viewport '
'Terminal(height={term.height}, width={term.width})'
.format(self=self, term=getterminal()), FutureWarning)
开发者ID:tehmaze,项目名称:x84,代码行数:29,代码来源:ansiwin.py
示例7: pos
def pos(self, yloc=None, xloc=None):
"""
Returns terminal sequence to move cursor to window-relative position.
"""
term = getterminal()
return term.move((yloc if yloc is not None else 0) + self.yloc,
(xloc if xloc is not None else 0) + self.xloc)
开发者ID:donfanning,项目名称:x84,代码行数:7,代码来源:ansiwin.py
示例8: isinview
def isinview(self):
""" Whether this window is in bounds of terminal dimensions. """
term = getterminal()
return (self.xloc >= 0
and self.xloc + self.width <= term.width
and self.yloc >= 0
and self.yloc + self.height <= term.height)
开发者ID:tehmaze,项目名称:x84,代码行数:7,代码来源:ansiwin.py
示例9: encode_pipe
def encode_pipe(ucs):
"""
encode_pipe(ucs) -> unicode
Return new unicode terminal sequence, replacing EMCA-48 ANSI
color sequences with their pipe-equivalent values.
"""
# TODO: Support all kinds of terminal color sequences,
# such as kermit or avatar or some such .. something non-emca
outp = u''
nxt = 0
term = getterminal()
ANSI_COLOR = re.compile(r'\033\[(\d{2,3})m')
for idx in range(0, len(ucs)):
if idx == nxt:
# at sequence, point beyond it,
match = ANSI_COLOR.match(ucs[idx:])
if match:
#nxt = idx + measure_length(ucs[idx:], term)
nxt = idx + len(match.group(0))
# http://wiki.mysticbbs.com/mci_codes
value = int(match.group(1)) - 30
if value >= 0 and value <= 60:
outp += u'|%02d' % (value,)
if nxt <= idx:
# append non-sequence to outp,
outp += ucs[idx]
# point beyond next sequence, if any,
# otherwise point to next character
nxt = idx + 1 #measure_length(ucs[idx:], term) + 1
return outp
开发者ID:donfanning,项目名称:x84,代码行数:31,代码来源:output.py
示例10: ansiwrap
def ansiwrap(ucs, width=70, **kwargs):
"""Wrap a single paragraph of Unicode Ansi sequences,
returning a list of wrapped lines.
"""
warnings.warn('ansiwrap() deprecated, getterminal() now'
'supplies an equivalent .wrap() API')
return getterminal().wrap(text=ucs, width=width, **kwargs)
开发者ID:donfanning,项目名称:x84,代码行数:7,代码来源:output.py
示例11: init_theme
def init_theme(self, colors=None, glyphs=None):
AnsiWindow.init_theme(self, colors, glyphs)
if 'highlight' not in self.colors:
from x84.bbs.session import getterminal
term = getterminal()
self.colors['highlight'] = term.yellow_reverse
if 'strip' not in self.glyphs:
self.glyphs['strip'] = u'$ '
开发者ID:hick,项目名称:x84,代码行数:8,代码来源:editor.py
示例12: init_theme
def init_theme(self, colors=None, glyphs=None):
from x84.bbs.session import getterminal
term = getterminal()
colors = colors or {
'selected': term.reverse_yellow,
'unselected': term.bold_black,
}
AnsiWindow.init_theme(self, colors=colors, glyphs=glyphs)
开发者ID:hick,项目名称:x84,代码行数:8,代码来源:selector.py
示例13: footer
def footer(self, ansi_text):
"""
Returns sequence that positions and displays unicode sequence
'ansi_text' at the bottom edge of the window.
"""
term = getterminal()
xloc = self.width / 2 - min(term.length(ansi_text) / 2, self.width / 2)
return self.pos(max(0, self.height - 1), max(0, xloc)) + ansi_text
开发者ID:donfanning,项目名称:x84,代码行数:8,代码来源:ansiwin.py
示例14: init_theme
def init_theme(self, colors=None, glyphs=None):
"""
Initialize color['highlight'].
"""
from x84.bbs.session import getterminal
colors = colors or {'highlight': getterminal().reverse_yellow}
glyphs = glyphs or {'strip': u' $'}
AnsiWindow.init_theme(self, colors, glyphs)
开发者ID:hick,项目名称:x84,代码行数:8,代码来源:lightbar.py
示例15: init_theme
def init_theme(self):
"""
Initialize color['highlight'].
"""
from x84.bbs.session import getterminal
self.colors['highlight'] = getterminal().reverse_green
self.glyphs['strip'] = u' $' # indicates content was stripped
AnsiWindow.init_theme(self)
开发者ID:donfanning,项目名称:x84,代码行数:8,代码来源:lightbar.py
示例16: title
def title(self, ansi_text):
"""
Returns sequence that positions and displays unicode sequence
'ansi_text' at the title location of the window.
"""
term = getterminal()
xloc = self.width / 2 - min(term.length(ansi_text) / 2, self.width / 2)
return self.pos(0, max(0, xloc)) + ansi_text
开发者ID:donfanning,项目名称:x84,代码行数:8,代码来源:ansiwin.py
示例17: isinview
def isinview(self):
"""
Returns True if window is in view of the terminal window.
"""
term = getterminal()
return (self.xloc >= 0
and self.xloc + self.width <= term.width
and self.yloc >= 0
and self.yloc + self.height <= term.height)
开发者ID:donfanning,项目名称:x84,代码行数:9,代码来源:ansiwin.py
示例18: init_theme
def init_theme(self):
"""
Initialize colors['selected'] and colors['unselected'].
"""
from x84.bbs.session import getterminal
term = getterminal()
AnsiWindow.init_theme(self)
self.colors['selected'] = term.reverse
self.colors['unselected'] = term.normal
开发者ID:donfanning,项目名称:x84,代码行数:9,代码来源:selector.py
示例19: fixate
def fixate(self, x_adjust=0):
"""
Return terminal sequence suitable for placing cursor at current
position in window. Set x_adjust to -1 to position cursor 'on'
the last character, or 0 for 'after' (default).
"""
from x84.bbs.session import getterminal
xpos = self._xpadding + self._horiz_pos + x_adjust
return self.pos(1, xpos) + getterminal().cursor_visible
开发者ID:sweenzor,项目名称:x84,代码行数:10,代码来源:editor.py
示例20: init_keystrokes
def init_keystrokes(self, keyset):
""" Sets keyboard keys for various editing keystrokes. """
from x84.bbs.session import getterminal
self.keyset = keyset
term = getterminal()
self.keyset['refresh'].append(term.KEY_REFRESH)
self.keyset['left'].append(term.KEY_LEFT)
self.keyset['right'].append(term.KEY_RIGHT)
self.keyset['enter'].append(term.KEY_ENTER)
self.keyset['exit'].append(term.KEY_ESCAPE)
开发者ID:jquast,项目名称:x84,代码行数:10,代码来源:selector.py
注:本文中的x84.bbs.session.getterminal函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论