本文整理汇总了Python中line.Line.backspace方法的典型用法代码示例。如果您正苦于以下问题:Python Line.backspace方法的具体用法?Python Line.backspace怎么用?Python Line.backspace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类line.Line
的用法示例。
在下文中一共展示了Line.backspace方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from line import Line [as 别名]
# 或者: from line.Line import backspace [as 别名]
#.........这里部分代码省略.........
def _limits(self):
return self.screen.getmaxyx()
def _draw_line(self, linenum, line):
self.screen.move(linenum,0)
offset = 0
if line.timestamp:
self.screen.attrset(self.theme.color_pair('time'))
self.screen.addnstr(line.timestamp, self.width)
offset += len(line.timestamp)
self.screen.attrset(self.theme.color_pair(line.attr))
if line.data:
self.screen.addnstr(line.data, self.width)
offset += len(line.data)
pad_count = self.width - offset - 1
while pad_count > 0:
self.screen.addch(' ')
pad_count -= 1
def _draw_chat(self):
pair = self.theme.color_pair('chat')
self.screen.bkgdset(' ', pair)
def _goto_input(self):
self.screen.move(self.height-1, self.input_line.width())
def _draw_topic(self):
self._draw_line(0, self.topic)
def _draw_status(self):
self._draw_line(self.height-2, self.status)
def _draw_lines(self):
i = 1
for line in self.lines[-self.height:]:
self._draw_line(i, line)
i = i+1
def _draw_input(self):
self._draw_line(self.height-1, self.input_line)
def draw(self):
self._draw_topic()
self._draw_status()
self._draw_lines()
self._draw_input()
self._goto_input()
self.screen.refresh()
def add_line(self, line):
self.lines.append(line)
self.screen.scroll()
self._draw_line(self.height-3, line)
self._draw_input()
self.screen.refresh()
def on_currenttopic(self, connection, event):
topic = event.arguments()[1]
self.topic = Line('topic', topic.strip(), False)
self._draw_topic()
self._goto_input()
def on_connect(self, connection, event):
if irclib.is_channel(self.room):
connection.join(self.room)
who = event.source()[0:event.source().find("!")]
self.status = Line('status', "[%s] [%s]" % (who, self.room))
self._draw_status()
self._goto_input()
self.add_line(Line('chat', "Connected", timestamp=True))
def on_pubmsg(self, connection, event):
who = event.source()[0:event.source().find("!")]
msg = who + "> " + " ".join(event.arguments())
self.add_line(Line('chat', msg, timestamp=True))
def on_motd(self, connection, event):
self.add_line(Line('chat', " ".join(event.arguments()), timestamp=False))
def run(self):
while 1:
ch = self.screen.getch()
if ch != -1:
if ch == ord('\n'):
msg = self.input_line.data
self.add_line(Line('chat', msg, timestamp=True))
self.server.privmsg(self.room, msg)
self.input_line.clear_data()
self._draw_input()
elif ch == 127: #backspace
self.input_line.backspace()
self._draw_input()
elif isprint(ch):
self.input_line.add_ch(chr(ch))
self.irc.process_once()