def cmd_clear(main_window, argv): """ /clear [<markup>] """ if len(argv) == 2 and argv[1] == "markup": for tab in tabs.tree_to_list(main_window.servers): tab.reset_status() main_window.update_divider() else: del main_window.body.body[0:]
def _match_channel(word): global _main_window tablist = tabs.tree_to_list(_main_window.servers) # find all matching tabs matches = [tab.name for tab in tablist if tab and tab.name[:len(word)].lower() == word.lower()] if matches: _raise_position(matches, CHANNEL_TYPE) return matches[_current["position"]] return None
def _match_channel(word): global _main_window tablist = tabs.tree_to_list(_main_window.servers) # find all matching tabs matches = [ tab.name for tab in tablist if tab and tab.name[:len(word)].lower() == word.lower() ] if matches: _raise_position(matches, CHANNEL_TYPE) return matches[_current["position"]] return None
def sushi_nick(time, server, old, new): """ old == "" => new == current nick """ stab = main_window.find_server(server) if not stab: print_error("missing stab '%s'" % server) return if not old or old == stab.get_nick(): stab.set_nick(new) if main_window.current_tab in tabs.tree_to_list([stab]): main_window.update_divider() msg = format_message("actions", "nick", { "nick": old, "new_nick": new }, own=True, highlight=False) current_server_tab_print(server, msg) else: # print status message in channel tab old = connection.parse_from(old)[0] new = connection.parse_from(new)[0] msg = format_message("actions", "nick", { "nick": old, "new_nick": new }, own=False, highlight=False) msg.markup_cb = color_nick_markup_cb msg.markup_cb_kwargs = {"values": ["nick", "new_nick"]} for tab in stab.children: if type(tab) == tabs.Channel and tab.nicklist.has_nick(old): tab.nicklist.rename_nick(old, new) print_tab(tab, msg)
def sushi_nick(time, server, old, new): """ old == "" => new == current nick """ stab = main_window.find_server(server) if not stab: print_error("missing stab '%s'" % server) return if not old or old == stab.get_nick(): stab.set_nick(new) if main_window.current_tab in tabs.tree_to_list([stab]): main_window.update_divider() msg = format_message("actions", "nick", {"nick": old, "new_nick": new}, own = True, highlight = False) current_server_tab_print(server, msg) else: # print status message in channel tab old = connection.parse_from(old)[0] new = connection.parse_from(new)[0] msg = format_message("actions", "nick", {"nick": old, "new_nick": new}, own = False, highlight = False) msg.markup_cb = color_nick_markup_cb msg.markup_cb_kwargs = {"values":["nick","new_nick"]} for tab in stab.children: if type(tab) == tabs.Channel and tab.nicklist.has_nick(old): tab.nicklist.rename_nick(old,new) print_tab(tab, msg)
def print_tab(dest_tab, msg, msgtype="informative"): if not main_window: raise ValueError, "No main_window found." tablist = tabs.tree_to_list(main_window.servers) try: i = tablist.index(dest_tab) except ValueError: print_error("print_tab to invalid destinaton '%s'." % dest_tab) return else: if isinstance(msg, FormattedMessage): markup = msg.markup() msgtype = msg.category if isinstance(markup, tuple): # ("...",[(color,pos),...]) new_markup = helper.markup.tuple_to_list(markup) textItem = urwid.Text(new_markup) elif isinstance(markup, list): # [(color,text),...] textItem = urwid.Text(markup) else: textItem = urwid.Text(markup) else: textItem = urwid.Text(msg) tablist[i].output_walker.append(textItem) if main_window.current_tab != dest_tab: dest_tab.add_status(msgtype) main_window.update_divider() else: main_window.body.scroll_to_bottom()
def print_tab(dest_tab, msg, msgtype="informative"): if not main_window: raise ValueError, "No main_window found." tablist = tabs.tree_to_list(main_window.servers) try: i = tablist.index(dest_tab) except ValueError: print_error("print_tab to invalid destinaton '%s'." % dest_tab) return else: if isinstance(msg, FormattedMessage): markup = msg.markup() msgtype = msg.category if isinstance(markup,tuple): # ("...",[(color,pos),...]) new_markup = helper.markup.tuple_to_list(markup) textItem = urwid.Text(new_markup) elif isinstance(markup,list): # [(color,text),...] textItem = urwid.Text(markup) else: textItem = urwid.Text(markup) else: textItem = urwid.Text(msg) tablist[i].output_walker.append(textItem) if main_window.current_tab != dest_tab: dest_tab.add_status(msgtype) main_window.update_divider() else: main_window.body.scroll_to_bottom()