Exemple #1
0
def count_filtered_lines(ptr_buffer, lines_count, lines_after):
    filtered_before = 0
    filtered_after = 0
    filtered = 0

    lines = weechat.hdata_pointer(weechat.hdata_get("buffer"), ptr_buffer, "own_lines")
    counter = 0
    current_position = lines_count - lines_after

    if lines:
        line = weechat.hdata_pointer(weechat.hdata_get("lines"), lines, "first_line")
        hdata_line = weechat.hdata_get("line")
        hdata_line_data = weechat.hdata_get("line_data")

        while line:
            data = weechat.hdata_pointer(hdata_line, line, "data")
            if data:
                #                message = weechat.hdata_string(hdata_line_data, data, 'message')
                displayed = weechat.hdata_char(hdata_line_data, data, "displayed")
                if displayed == 0:
                    #                    weechat.prnt('','%d - %s - %s' % (counter, displayed, message))
                    if counter < current_position:
                        filtered_before += 1
                    else:
                        filtered_after += 1
            counter += 1
            line = weechat.hdata_move(hdata_line, line, 1)

    filtered = filtered_before + filtered_after
    return filtered, filtered_before, filtered_after
Exemple #2
0
def count_filtered_lines(ptr_buffer, lines_count, lines_after):
    filtered_before = 0
    filtered_after = 0
    filtered = 0

    lines = weechat.hdata_pointer(weechat.hdata_get('buffer'), ptr_buffer,
                                  'own_lines')
    counter = 0
    current_position = lines_count - lines_after

    if lines:
        line = weechat.hdata_pointer(weechat.hdata_get('lines'), lines,
                                     'first_line')
        hdata_line = weechat.hdata_get('line')
        hdata_line_data = weechat.hdata_get('line_data')

        while line:
            data = weechat.hdata_pointer(hdata_line, line, 'data')
            if data:
                #                message = weechat.hdata_string(hdata_line_data, data, 'message')
                displayed = weechat.hdata_char(hdata_line_data, data,
                                               'displayed')
                if displayed == 0:
                    #                    weechat.prnt('','%d - %s - %s' % (counter, displayed, message))
                    if counter < current_position:
                        filtered_before += 1
                    else:
                        filtered_after += 1
            counter += 1
            line = weechat.hdata_move(hdata_line, line, 1)

    filtered = filtered_before + filtered_after
    return filtered, filtered_before, filtered_after
Exemple #3
0
def get_time_from_line(ptr_buffer):
    lines = weechat.hdata_pointer(weechat.hdata_get('buffer'), ptr_buffer, 'own_lines')

    if lines:
        line = weechat.hdata_pointer(weechat.hdata_get('lines'), lines, 'last_line')
        last_read_line = weechat.hdata_pointer(weechat.hdata_get('lines'), lines, 'last_read_line')
        # last line already read?
        while line != last_read_line:
            hdata_line = weechat.hdata_get('line')
            hdata_line_data = weechat.hdata_get('line_data')

            data = weechat.hdata_pointer(hdata_line, line, 'data')

            date_last_line = weechat.hdata_time(hdata_line_data, data, 'date')
            displayed = weechat.hdata_char(hdata_line_data, data, 'displayed')
            # message hidden?
            if not displayed and OPTIONS['ignore_hidden'].lower() == 'on':
                prev_line = weechat.hdata_pointer(hdata_line, line, 'prev_line')
                line = prev_line
                continue

            # buffer empty?
            if not date_last_line:
                return 0

            get_current_ticks = time.time()

            time_gone = get_current_ticks - date_last_line
            if int(OPTIONS['time']) < time_gone:
                return 1
            else:
                return 0
    return 0