# -*- coding: utf-8 -*- # # Copyright (c) 2010 by Sebastien Helleu # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # # Display extended terminal colors (depends on current terminal settings). # (this script requires WeeChat 0.3.4 or newer) # # History: # # 2010-12-12, Sebastien Helleu : # version 0.1: initial release # import weechat SCRIPT_NAME = "colors" SCRIPT_AUTHOR = "Sebastien Helleu " SCRIPT_VERSION = "0.1" SCRIPT_LICENSE = "GPL3" SCRIPT_DESC = "Display extended terminal colors" def colors_display(buf): weechat.buffer_clear(buf) weechat.prnt(buf, "%s 000 (fixed color)" % weechat.color("0")) for line in range(0, 16): str_color = "" for col in range(0, 16): color = (col * 16) + line + 1; if color < 256: str_color += "%s %03d %s" % (weechat.color("%s" % color), color, weechat.color("reset")) else: str_color += " " weechat.prnt(buf, "%s│" % str_color) def colors_cmd(data, buffer, args): """ Callback for /colors command. """ colors_buffer = weechat.buffer_search("python", "colors") if colors_buffer == "": colors_buffer = weechat.buffer_new("colors", "", "", "", "") if colors_buffer != "": weechat.buffer_set(colors_buffer, "title", SCRIPT_NAME + " " + SCRIPT_VERSION) weechat.buffer_set(colors_buffer, "localvar_set_no_log", "1") weechat.buffer_set(colors_buffer, "time_for_each_line", "0") colors_display(colors_buffer) weechat.buffer_set(colors_buffer, "display", "1") return weechat.WEECHAT_RC_OK if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""): weechat.hook_command("colors", "Display extended terminal colors in a separate buffer", "", "", "", "colors_cmd", "")