Esempio n. 1
0
def maze_get_size(args: str = "") -> Tuple[int, int]:
    """Get maze size with args, defaulting to current maze or window size."""
    global maze
    width: int = 0
    height: int = 0
    if args in ("d", "default"):
        args = ""
    elif maze:
        width, height = maze.width, maze.height
    if args:
        # size given by user
        try:
            items = args.split()
            if len(items) > 1:
                width, height = int(items[0]), int(items[1])
            else:
                width, height = int(args), int(args)
            width = max(width, 2)
            height = max(height, 2)
        except ValueError:
            width, height = 0, 0
    if not width or not height:
        # automatic size with size of window
        win_width: int = weechat.window_get_integer(weechat.current_window(),
                                                    "win_chat_width") - 1
        win_height: int = weechat.window_get_integer(weechat.current_window(),
                                                     "win_chat_height") - 1
        size: int = min(win_width, win_height)
        width, height = size, size
    return width, height
Esempio n. 2
0
def count_lines(ptr_window, ptr_buffer):
    global filter_status

    hdata_buf = weechat.hdata_get("buffer")
    hdata_lines = weechat.hdata_get("lines")
    lines = weechat.hdata_pointer(hdata_buf, ptr_buffer, "lines")  # own_lines, mixed_lines
    lines_count = weechat.hdata_integer(hdata_lines, lines, "lines_count")

    hdata_window = weechat.hdata_get("window")
    hdata_winscroll = weechat.hdata_get("window_scroll")
    window_scroll = weechat.hdata_pointer(hdata_window, ptr_window, "scroll")
    lines_after = weechat.hdata_integer(hdata_winscroll, window_scroll, "lines_after")
    window_height = weechat.window_get_integer(weechat.current_window(), "win_chat_height")

    filtered = 0
    filtered_before = 0
    filtered_after = 0
    # if filter is disabled, don't count.
    if (OPTIONS["count_filtered_lines"].lower() == "off") and filter_status == 1:
        filtered, filtered_before, filtered_after = count_filtered_lines(ptr_buffer, lines_count, lines_after)
        lines_count = lines_count - filtered
    #        lines_after = lines_after - filtered_after

    if lines_count > window_height:
        differential = lines_count - window_height
        percent = max(int(round(100.0 * (differential - lines_after) / differential)), 0)
    else:
        percent = 100

    # get current position
    current_line = lines_count - lines_after

    return lines_after, lines_count, percent, current_line, filtered, filtered_before, filtered_after
Esempio n. 3
0
def cb_line_numbers(data, item, window):
    """Fill the line numbers bar item."""
    bar_height = weechat.window_get_integer(window, "win_chat_height")
    content = ""
    for i in range(1, bar_height + 1):
        content += "%s \n" % i
    return content
Esempio n. 4
0
def cb_line_numbers(data, item, window):
    """Fill the line numbers bar item."""
    bar_height = weechat.window_get_integer(window, "win_chat_height")
    content = ""
    for i in range(1, bar_height + 1):
        content += "%s \n" % i
    return content
Esempio n. 5
0
def count_lines(winpointer, bufpointer):

    hdata_buf = weechat.hdata_get('buffer')
    hdata_lines = weechat.hdata_get('lines')
    lines = weechat.hdata_pointer(hdata_buf, bufpointer,
                                  'lines')  # own_lines, mixed_lines
    lines_count = weechat.hdata_integer(hdata_lines, lines, 'lines_count')

    hdata_window = weechat.hdata_get('window')
    hdata_winscroll = weechat.hdata_get('window_scroll')
    window_scroll = weechat.hdata_pointer(hdata_window, winpointer, 'scroll')
    lines_after = weechat.hdata_integer(hdata_winscroll, window_scroll,
                                        'lines_after')
    window_height = weechat.window_get_integer(weechat.current_window(),
                                               'win_chat_height')

    if lines_count > window_height:
        differential = lines_count - window_height
        percent = max(
            int(round(100. * (differential - lines_after) / differential)), 0)
    else:
        percent = 100
    #weechat.prnt('', " : lines_count "+str(lines_count)+" window_height "+str(window_height)+" lines after "+str(lines_after))
    current_line = lines_count - lines_after
    return lines_after, lines_count, percent, current_line
Esempio n. 6
0
def count_lines(ptr_window,ptr_buffer):
    global filter_status

    hdata_buf = weechat.hdata_get('buffer')
    hdata_lines = weechat.hdata_get('lines')
    lines = weechat.hdata_pointer(hdata_buf, ptr_buffer, 'lines') # own_lines, mixed_lines
    lines_count = weechat.hdata_integer(hdata_lines, lines, 'lines_count')

    hdata_window = weechat.hdata_get('window')
    hdata_winscroll = weechat.hdata_get('window_scroll')
    window_scroll = weechat.hdata_pointer(hdata_window, ptr_window, 'scroll')
    lines_after = weechat.hdata_integer(hdata_winscroll, window_scroll, 'lines_after')
    window_height = weechat.window_get_integer(weechat.current_window(), 'win_chat_height')

    filtered = 0
    filtered_before = 0
    filtered_after = 0
    # if filter is disabled, don't count.
    if (OPTIONS['count_filtered_lines'].lower() == 'off') and filter_status == 1:
        filtered, filtered_before,filtered_after = count_filtered_lines(ptr_buffer,lines_count,lines_after)
        lines_count = lines_count - filtered
#        lines_after = lines_after - filtered_after

    if lines_count > window_height:
        differential = lines_count - window_height
        percent = max(int(round(100. * (differential - lines_after) / differential)), 0)
    else:
        percent = 100

    # get current position
    current_line = lines_count - lines_after

    return lines_after,lines_count,percent,current_line, filtered, filtered_before, filtered_after
Esempio n. 7
0
def samegame_adjust_zoom():
    """Choose zoom according to size of window."""
    global samegame, samegame_settings
    samegame["zoom"] = -1
    if samegame_settings["zoom"]:
        try:
            samegame["zoom"] = int(samegame_settings["zoom"])
        except:
            samegame["zoom"] = -1
    if samegame["zoom"] < 0:
        width = weechat.window_get_integer(weechat.current_window(), "win_chat_width")
        height = weechat.window_get_integer(weechat.current_window(), "win_chat_height")
        for i in range(10, -1, -1):
            if width >= samegame["size"][0] * ((i + 1) * 2) + 2 and height >= (samegame["size"][1] * (i + 1)) + 3:
                samegame["zoom"] = i
                break
    if samegame["zoom"] < 0:
        samegame["zoom"] = 0
Esempio n. 8
0
def floodit_adjust_zoom():
    """Choose zoom according to size of window."""
    global floodit, floodit_settings
    floodit['zoom'] = -1
    if floodit_settings['zoom']:
        try:
            floodit['zoom'] = int(floodit_settings['zoom'])
        except:
            floodit['zoom'] = -1
    if floodit['zoom'] < 0:
        width = weechat.window_get_integer(weechat.current_window(), 'win_chat_width')
        height = weechat.window_get_integer(weechat.current_window(), 'win_chat_height')
        for i in range(10, -1, -1):
            if width >= floodit['size'] * ((i + 1) * 2) and height >= (floodit['size'] * (i + 1)) + i + 2:
                floodit['zoom'] = i
                break
    if floodit['zoom'] < 0:
        floodit['zoom'] = 0
Esempio n. 9
0
def scroll_stats():
    if timer_ptr:
        stop_timer()
    window_size = weechat.window_get_integer(weechat.current_window(), 'win_width')
    string = ''
    for key in streams_dict.keys():
        string += key.decode('utf-8').lstrip('/') + ' => '
        for subkey, value in streams_dict[key].items():
            string += '%s: %s, ' % (subkey.decode('utf-8'), value.decode('utf-8'))
Esempio n. 10
0
def refresh():
    width = weechat.window_get_integer(weechat.current_window(),
                                       'win_chat_width')
    string = option_values['marker']

    marker = string + ' ' * (width -
                             (len(string.decode('utf-8')) * 2)) + string

    config = weechat.config_get('weechat.look.read_marker_string')
    weechat.config_option_set(config, marker, 0)
Esempio n. 11
0
def minimal_bar_item(data, item, window):
    if not window:
        window = w.current_window()
    ptr_buffer = w.window_get_pointer(window, "buffer")
    if ptr_buffer == "" or ptr_buffer == w.current_buffer():
        return ""
    length = w.window_get_integer(window, 'win_width') - w.buffer_get_integer(
        ptr_buffer, 'input_length')
    s = length * " "
    return s
Esempio n. 12
0
def minesweeper_adjust_zoom():
    """Choose zoom according to size of window."""
    global minesweeper, minesweeper_settings
    minesweeper['zoom'] = -1
    if minesweeper_settings['zoom']:
        try:
            minesweeper['zoom'] = int(minesweeper_settings['zoom'])
        except:
            minesweeper['zoom'] = -1
        if minesweeper['zoom'] > 1:
            minesweeper['zoom'] = 1
    if minesweeper['zoom'] < 0:
        width = weechat.window_get_integer(weechat.current_window(), 'win_chat_width')
        height = weechat.window_get_integer(weechat.current_window(), 'win_chat_height')
        minesweeper['zoom'] = 0
        if width >= minesweeper['size'] * 6 and height >= 1 + (minesweeper['size'] * 3) + 2:
            minesweeper['zoom'] = 1
    if minesweeper['zoom'] < 0:
        minesweeper['zoom'] = 0
Esempio n. 13
0
def input_modifier_cb(data, modifier, modifier_data, string):
    """Modifier that will add help on command line (for display only)."""
    global cmdhelp_settings
    line = weechat.string_remove_color(string, '')
    if line == '':
        return string
    command = ''
    arguments = ''
    if weechat.string_input_for_buffer(line) != '':
        return string
    items = line.split(' ', 1)
    if len(items) > 0:
        command = items[0]
        if len(command) < 2:
            return string
        if len(items) > 1:
            arguments = items[1]
    if command[1:].lower() in cmdhelp_settings['ignore_commands'].split(','):
        return string
    current_buffer = weechat.current_buffer()
    current_window = weechat.current_window()
    plugin = weechat.buffer_get_pointer(current_buffer, 'plugin')
    msg_help = (get_help_command(plugin, command[1:], arguments) or
                get_list_commands(plugin, command[1:], arguments))
    if not msg_help:
        if cmdhelp_settings['display_no_help'] != 'on':
            return string
        msg_help = weechat.color(cmdhelp_settings['color_no_help'])
        if command:
            msg_help += 'No help for command %s' % command
        else:
            msg_help += 'No help'

    if cmdhelp_settings['right_align'] == 'on':
        win_width = weechat.window_get_integer(current_window, 'win_width')
        input_length = weechat.buffer_get_integer(current_buffer,
                                                  'input_length')
        help_length = len(weechat.string_remove_color(msg_help, ""))
        min_space = int(cmdhelp_settings['space'])
        padding = int(cmdhelp_settings['right_padding'])
        space = win_width - input_length - help_length - padding
        if space < min_space:
            space = min_space
    else:
        space = int(cmdhelp_settings['space'])

    color_delimiters = cmdhelp_settings['color_delimiters']
    return '%s%s%s%s%s%s%s' % (string,
                               space * ' ',
                               weechat.color(color_delimiters),
                               cmdhelp_settings['prefix'],
                               msg_help,
                               weechat.color(color_delimiters),
                               cmdhelp_settings['suffix'])
Esempio n. 14
0
def win_scroll_screen(data, buffer, args):
    screens = float(args)

    win = w.current_window()

    chat_height = w.window_get_integer(win, 'win_chat_height')
    if screens < 0:
        scrolling = w.window_get_integer(win, 'scrolling')
        if scrolling == 0:  # no idea why but this is needed
            scroll = int(chat_height * screens) - (chat_height - 3)
        else:
            scroll = int(chat_height * screens)
    else:
        scroll = int(chat_height * screens)

        lines_after = w.window_get_integer(win, 'lines_after')
        if scroll >= lines_after:
            return w.command(buffer, "/window scroll_bottom")

    return w.command(buffer, "/window scroll {:+d}".format(scroll))
Esempio n. 15
0
def scroll_stats():
    if timer_ptr:
        stop_timer()
    window_size = weechat.window_get_integer(weechat.current_window(),
                                             'win_width')
    string = ''
    for key in streams_dict.keys():
        string += key.decode('utf-8').lstrip('/') + ' => '
        for subkey, value in streams_dict[key].items():
            string += '%s: %s, ' % (subkey.decode('utf-8'),
                                    value.decode('utf-8'))
Esempio n. 16
0
def win_scroll_screen(data, buffer, args):
  screens = float(args)

  win = w.current_window()

  chat_height = w.window_get_integer(win, 'win_chat_height')
  if screens < 0:
    scrolling = w.window_get_integer(win, 'scrolling')
    if scrolling == 0: # no idea why but this is needed
      scroll = int(chat_height * screens) - (chat_height - 3)
    else:
      scroll = int(chat_height * screens)
  else:
    scroll = int(chat_height * screens)

    lines_after = w.window_get_integer(win, 'lines_after')
    if scroll >= lines_after:
      return w.command(buffer, "/window scroll_bottom")

  return w.command(buffer, "/window scroll {:+d}".format(scroll))
Esempio n. 17
0
def floodit_adjust_zoom():
    """Choose zoom according to size of window."""
    global floodit, floodit_settings
    floodit['zoom'] = -1
    if floodit_settings['zoom']:
        try:
            floodit['zoom'] = int(floodit_settings['zoom'])
        except:
            floodit['zoom'] = -1
    if floodit['zoom'] < 0:
        width = weechat.window_get_integer(weechat.current_window(),
                                           'win_chat_width')
        height = weechat.window_get_integer(weechat.current_window(),
                                            'win_chat_height')
        for i in range(10, -1, -1):
            if width >= floodit['size'] * (
                (i + 1) * 2) and height >= (floodit['size'] * (i + 1)) + i + 2:
                floodit['zoom'] = i
                break
    if floodit['zoom'] < 0:
        floodit['zoom'] = 0
Esempio n. 18
0
def scroll_topic_cb(data_ptr, buffer_ptr, args):
    # enciende el scroll
    window_size = weechat.window_get_integer(weechat.current_window(), 'win_width')
    texto = u'\x03c12' + 'Texto de prueba'
    display_vect = [' '] * window_size
    texto_vect = []
    for character in texto:
        texto_vect += [character]
    global display_fin
    display_fin = display_vect + texto_vect
    timer_ptr = weechat.hook_timer(300, 0, len(display_fin), 'scroll_cb', '')
    return weechat.WEECHAT_RC_OK
Esempio n. 19
0
def input_modifier_cb(data, modifier, modifier_data, string):
    """Modifier that will add help on command line (for display only)."""
    global cmdhelp_settings
    line = weechat.string_remove_color(string, '')
    if line == '':
        return string
    command = ''
    arguments = ''
    if weechat.string_input_for_buffer(line) != '':
        return string
    items = line.split(' ', 1)
    if len(items) > 0:
        command = items[0]
        if len(command) < 2:
            return string
        if len(items) > 1:
            arguments = items[1]
    if command[1:].lower() in cmdhelp_settings['ignore_commands'].split(','):
        return string
    current_buffer = weechat.current_buffer()
    current_window = weechat.current_window()
    plugin = weechat.buffer_get_pointer(current_buffer, 'plugin')
    msg_help = get_help_command(plugin, command[1:],
                                arguments) or get_list_commands(
                                    plugin, command[1:], arguments)
    if not msg_help:
        if cmdhelp_settings['display_no_help'] != 'on':
            return string
        msg_help = weechat.color(cmdhelp_settings['color_no_help'])
        if command:
            msg_help += 'No help for command %s' % command
        else:
            msg_help += 'No help'

    if cmdhelp_settings['right_align'] == 'on':
        win_width = weechat.window_get_integer(current_window, 'win_width')
        input_length = weechat.buffer_get_integer(current_buffer,
                                                  'input_length')
        help_length = len(weechat.string_remove_color(msg_help, ""))
        min_space = int(cmdhelp_settings['space'])
        padding = int(cmdhelp_settings['right_padding'])
        space = win_width - input_length - help_length - padding
        if space < min_space:
            space = min_space
    else:
        space = int(cmdhelp_settings['space'])

    color_delimiters = cmdhelp_settings['color_delimiters']
    return '%s%s%s%s%s%s%s' % (
        string, space * ' ',
        weechat.color(color_delimiters), cmdhelp_settings['prefix'], msg_help,
        weechat.color(color_delimiters), cmdhelp_settings['suffix'])
Esempio n. 20
0
def minesweeper_adjust_zoom():
    """Choose zoom according to size of window."""
    global minesweeper, minesweeper_settings
    minesweeper['zoom'] = -1
    if minesweeper_settings['zoom']:
        try:
            minesweeper['zoom'] = int(minesweeper_settings['zoom'])
        except:
            minesweeper['zoom'] = -1
        if minesweeper['zoom'] > 1:
            minesweeper['zoom'] = 1
    if minesweeper['zoom'] < 0:
        width = weechat.window_get_integer(weechat.current_window(),
                                           'win_chat_width')
        height = weechat.window_get_integer(weechat.current_window(),
                                            'win_chat_height')
        minesweeper['zoom'] = 0
        if width >= minesweeper['size'] * 6 and height >= 1 + (
                minesweeper['size'] * 3) + 2:
            minesweeper['zoom'] = 1
    if minesweeper['zoom'] < 0:
        minesweeper['zoom'] = 0
Esempio n. 21
0
def samegame_adjust_zoom():
    """Choose zoom according to size of window."""
    global samegame, samegame_settings
    samegame['zoom'] = -1
    if samegame_settings['zoom']:
        try:
            samegame['zoom'] = int(samegame_settings['zoom'])
        except:
            samegame['zoom'] = -1
    if samegame['zoom'] < 0:
        width = weechat.window_get_integer(weechat.current_window(),
                                           'win_chat_width')
        height = weechat.window_get_integer(weechat.current_window(),
                                            'win_chat_height')
        for i in range(10, -1, -1):
            if width >= samegame['size'][0] * (
                (i + 1) * 2) + 2 and height >= (samegame['size'][1] *
                                                (i + 1)) + 3:
                samegame['zoom'] = i
                break
    if samegame['zoom'] < 0:
        samegame['zoom'] = 0
Esempio n. 22
0
def unfocused_bar_item (data, item, window):
    '''Item constructor'''
    # window empty? root bar!
    if not window:
        window = w.current_window()

    ptr_buffer = w.window_get_pointer(window, "buffer")
    if ptr_buffer == "" or ptr_buffer == w.current_buffer():
        return ""

    length = w.window_get_integer(window, 'win_width') - w.buffer_get_integer(ptr_buffer, 'input_length')
    s = length * inputtape_char
    return s
Esempio n. 23
0
def scroll_topic_cb(data_ptr, buffer_ptr, args):
    # enciende el scroll
    window_size = weechat.window_get_integer(weechat.current_window(),
                                             'win_width')
    texto = u'\x03c12' + 'Texto de prueba'
    display_vect = [' '] * window_size
    texto_vect = []
    for character in texto:
        texto_vect += [character]
    global display_fin
    display_fin = display_vect + texto_vect
    timer_ptr = weechat.hook_timer(300, 0, len(display_fin), 'scroll_cb', '')
    return weechat.WEECHAT_RC_OK
Esempio n. 24
0
def unfocused_bar_item(data, item, window):
    '''Item constructor'''
    # window empty? root bar!
    if not window:
        window = w.current_window()

    ptr_buffer = w.window_get_pointer(window, "buffer")
    if ptr_buffer == "" or ptr_buffer == w.current_buffer():
        return ""

    length = w.window_get_integer(window, 'win_width') - w.buffer_get_integer(
        ptr_buffer, 'input_length')
    s = length * inputtape_char
    return s
Esempio n. 25
0
def timer_cb(data, remaining_calls):
    global indent
    current_time = int(time.time())
    interval = int(weechat.config_get_plugin('modulo_interval')) * 60
    if (current_time % interval) == 0:
        infolist = weechat.infolist_get("buffer", "", "")
        if infolist:
            # set static width, assumes balanced window widths
            if indent < 0:
                if weechat.config_get_plugin('center') == '0':
                    indent = 0
                else:
                    # centering = (window width - prefix width - (vertical separator + date)) / 2 - rounding adjustment
                    indent = (weechat.window_get_integer(weechat.current_window (), "win_width") - int(weechat.string_eval_expression("${weechat.look.prefix_align_min}", {}, {}, {})) - 14) / 2 - 1
            while weechat.infolist_next(infolist):
                buffer = weechat.infolist_pointer(infolist, 'pointer')
                prnt_timestamp(buffer, current_time, indent)
            weechat.infolist_free(infolist)
    return weechat.WEECHAT_RC_OK
Esempio n. 26
0
def count_lines(ptr_window, ptr_buffer):
    global filter_status

    hdata_buf = weechat.hdata_get('buffer')
    hdata_lines = weechat.hdata_get('lines')
    lines = weechat.hdata_pointer(hdata_buf, ptr_buffer,
                                  'lines')  # own_lines, mixed_lines
    lines_count = weechat.hdata_integer(hdata_lines, lines, 'lines_count')

    hdata_window = weechat.hdata_get('window')
    hdata_winscroll = weechat.hdata_get('window_scroll')
    window_scroll = weechat.hdata_pointer(hdata_window, ptr_window, 'scroll')
    lines_after = weechat.hdata_integer(hdata_winscroll, window_scroll,
                                        'lines_after')
    window_height = weechat.window_get_integer(weechat.current_window(),
                                               'win_chat_height')

    filtered = 0
    filtered_before = 0
    filtered_after = 0
    # if filter is disabled, don't count.
    if (OPTIONS['count_filtered_lines'].lower()
            == 'off') and filter_status == 1:
        filtered, filtered_before, filtered_after = count_filtered_lines(
            ptr_buffer, lines_count, lines_after)
        lines_count = lines_count - filtered


#        lines_after = lines_after - filtered_after

    if lines_count > window_height:
        differential = lines_count - window_height
        percent = max(
            int(round(100. * (differential - lines_after) / differential)), 0)
    else:
        percent = 100

    # get current position
    current_line = lines_count - lines_after

    return lines_after, lines_count, percent, current_line, filtered, filtered_before, filtered_after
Esempio n. 27
0
def count_lines(winpointer, bufpointer):

    hdata_buf = weechat.hdata_get("buffer")
    hdata_lines = weechat.hdata_get("lines")
    lines = weechat.hdata_pointer(hdata_buf, bufpointer, "lines")  # own_lines, mixed_lines
    lines_count = weechat.hdata_integer(hdata_lines, lines, "lines_count")

    hdata_window = weechat.hdata_get("window")
    hdata_winscroll = weechat.hdata_get("window_scroll")
    window_scroll = weechat.hdata_pointer(hdata_window, winpointer, "scroll")
    lines_after = weechat.hdata_integer(hdata_winscroll, window_scroll, "lines_after")
    window_height = weechat.window_get_integer(weechat.current_window(), "win_chat_height")

    if lines_count > window_height:
        differential = lines_count - window_height
        percent = max(int(round(100.0 * (differential - lines_after) / differential)), 0)
    else:
        percent = 100
    # weechat.prnt('', " : lines_count "+str(lines_count)+" window_height "+str(window_height)+" lines after "+str(lines_after))
    current_line = lines_count - lines_after
    return lines_after, lines_count, percent, current_line
Esempio n. 28
0
def timer_cb(data, remaining_calls):
    global indent
    current_time = int(time.time())
    interval = int(weechat.config_get_plugin('modulo_interval')) * 60
    if (current_time % interval) == 0:
        timestamp = clock(current_time)
        clocked = []
        infolist = weechat.infolist_get('window', '', '')
        if infolist:
            prefix = int(
                weechat.string_eval_expression(
                    "${weechat.look.prefix_align_min}", {}, {}, {}))
            if weechat.config_get_plugin('offset_prefix') == '0':
                offset = (prefix + 3) / 2  # including prefix separator
            else:
                offset = 0
            while weechat.infolist_next(infolist):
                if weechat.config_get_plugin('center') == '0':
                    indent = 0
                else:
                    # centering = (window width - prefix width - prefix separator - buffertape date) / 2 - offset - rounding adjustment
                    window = weechat.infolist_pointer(infolist, 'pointer')
                    indent = (weechat.window_get_integer(window, 'win_width') -
                              prefix - 2 - 11) / 2 - offset - 1
                buffer = weechat.window_get_pointer(window, 'buffer')
                if not buffer in clocked:
                    clocked.append(buffer)
                    weechat.prnt(buffer, ' ' * indent + timestamp)
        infolist = weechat.infolist_get('buffer', '', '')
        if infolist:
            while weechat.infolist_next(infolist):
                buffer = weechat.infolist_pointer(infolist, 'pointer')
                if not buffer in clocked:
                    clocked.append(buffer)
                    weechat.prnt(buffer, timestamp)
            weechat.infolist_free(infolist)
        del clocked
    return weechat.WEECHAT_RC_OK
Esempio n. 29
0
def timer_cb(data, remaining_calls):
    global indent
    current_time = int(time.time())
    interval = int(weechat.config_get_plugin('modulo_interval')) * 60
    if (current_time % interval) == 0:
        infolist = weechat.infolist_get("buffer", "", "")
        if infolist:
            # set static width, assumes balanced window widths
            if indent < 0:
                if weechat.config_get_plugin('center') == '0':
                    indent = 0
                else:
                    # centering = (window width - prefix width - (vertical separator + date)) / 2 - rounding adjustment
                    indent = (weechat.window_get_integer(
                        weechat.current_window(), "win_width") - int(
                            weechat.string_eval_expression(
                                "${weechat.look.prefix_align_min}", {}, {},
                                {})) - 14) / 2 - 1
            while weechat.infolist_next(infolist):
                buffer = weechat.infolist_pointer(infolist, 'pointer')
                prnt_timestamp(buffer, current_time, indent)
            weechat.infolist_free(infolist)
    return weechat.WEECHAT_RC_OK