示例#1
0
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:]
示例#2
0
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:]
示例#3
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
示例#4
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
示例#5
0
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)
示例#6
0
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)
示例#7
0
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()
示例#8
0
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()