コード例 #1
0
ファイル: gui-bar-window.c プロジェクト: matsuu/weechat
void
gui_bar_window_calculate_pos_size (struct t_gui_bar_window *bar_window,
                                   struct t_gui_window *window)
{
    int x1, y1, x2, y2;
    int add_bottom, add_top, add_left, add_right;
    
    if (window)
    {
        x1 = window->win_x;
        y1 = window->win_y;
        x2 = x1 + window->win_width - 1;
        y2 = y1 + window->win_height - 1;
        add_bottom = gui_bar_window_get_size (bar_window->bar, window, GUI_BAR_POSITION_BOTTOM);
        add_top = gui_bar_window_get_size (bar_window->bar, window, GUI_BAR_POSITION_TOP);
        add_left = gui_bar_window_get_size (bar_window->bar, window, GUI_BAR_POSITION_LEFT);
        add_right = gui_bar_window_get_size (bar_window->bar, window, GUI_BAR_POSITION_RIGHT);
    }
    else
    {
        x1 = 0;
        y1 = 0;
        x2 = gui_window_get_width () - 1;
        y2 = gui_window_get_height () - 1;
        add_bottom = gui_bar_root_get_size (bar_window->bar, GUI_BAR_POSITION_BOTTOM);
        add_top = gui_bar_root_get_size (bar_window->bar, GUI_BAR_POSITION_TOP);
        add_left = gui_bar_root_get_size (bar_window->bar, GUI_BAR_POSITION_LEFT);
        add_right = gui_bar_root_get_size (bar_window->bar, GUI_BAR_POSITION_RIGHT);
    }
    
    switch (CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_POSITION]))
    {
        case GUI_BAR_POSITION_BOTTOM:
            bar_window->x = x1 + add_left;
            bar_window->y = y2 - add_bottom - bar_window->current_size + 1;
            bar_window->width = x2 - x1 + 1 - add_left - add_right;
            bar_window->height = bar_window->current_size;
            break;
        case GUI_BAR_POSITION_TOP:
            bar_window->x = x1 + add_left;
            bar_window->y = y1 + add_top;
            bar_window->width = x2 - x1 + 1 - add_left - add_right;
            bar_window->height = bar_window->current_size;
            break;
        case GUI_BAR_POSITION_LEFT:
            bar_window->x = x1 + add_left;
            bar_window->y = y1 + add_top;
            bar_window->width = bar_window->current_size;
            bar_window->height = y2 - y1 + 1 - add_top - add_bottom;
            break;
        case GUI_BAR_POSITION_RIGHT:
            bar_window->x = x2 - add_right - bar_window->current_size + 1;
            bar_window->y = y1 + add_top;
            bar_window->width = bar_window->current_size;
            bar_window->height = y2 - y1 + 1 - add_top - add_bottom;
            break;
        case GUI_BAR_NUM_POSITIONS:
            break;
    }
}
コード例 #2
0
ファイル: gui-cursor.c プロジェクト: AlexTalker/weechat
void
gui_cursor_move_add_xy (int add_x, int add_y)
{
    if (!gui_cursor_mode)
        gui_cursor_mode_toggle ();

    gui_cursor_x += add_x;
    gui_cursor_y += add_y;

    if (gui_cursor_x < 0)
        gui_cursor_x = gui_window_get_width () - 1;
    else if (gui_cursor_x > gui_window_get_width () - 1)
        gui_cursor_x = 0;

    if (gui_cursor_y < 0)
        gui_cursor_y = gui_window_get_height () - 1;
    else if (gui_cursor_y > gui_window_get_height () - 1)
        gui_cursor_y = 0;

    gui_cursor_display_debug_info ();
    gui_window_move_cursor ();
}
コード例 #3
0
ファイル: plugin-api.c プロジェクト: haasn/weechat
const char *
plugin_api_info_get_internal (void *data, const char *info_name,
                              const char *arguments)
{
    time_t inactivity;
    static char value[32], version_number[32] = { '\0' };
    static char weechat_dir_absolute_path[PATH_MAX] = { '\0' };
    int rgb, limit;
    char *pos, *color;

    /* make C compiler happy */
    (void) data;

    if (!info_name)
        return NULL;

    if (string_strcasecmp (info_name, "version") == 0)
    {
        return version_get_version ();
    }
    else if (string_strcasecmp (info_name, "version_number") == 0)
    {
        if (!version_number[0])
        {
            snprintf (version_number, sizeof (version_number), "%d",
                      util_version_number (version_get_version ()));
        }
        return version_number;
    }
    else if (string_strcasecmp (info_name, "version_git") == 0)
    {
        return version_get_git ();
    }
    else if (string_strcasecmp (info_name, "date") == 0)
    {
        return version_get_compilation_date ();
    }
    else if (string_strcasecmp (info_name, "dir_separator") == 0)
    {
        return DIR_SEPARATOR;
    }
    else if (string_strcasecmp (info_name, "weechat_dir") == 0)
    {
        if (!weechat_dir_absolute_path[0])
        {
            if (!realpath (weechat_home, weechat_dir_absolute_path))
                return NULL;
        }
        return (weechat_dir_absolute_path[0]) ?
            weechat_dir_absolute_path : weechat_home;
    }
    else if (string_strcasecmp (info_name, "weechat_libdir") == 0)
    {
        return WEECHAT_LIBDIR;
    }
    else if (string_strcasecmp (info_name, "weechat_sharedir") == 0)
    {
        return WEECHAT_SHAREDIR;
    }
    else if (string_strcasecmp (info_name, "weechat_localedir") == 0)
    {
        return LOCALEDIR;
    }
    else if (string_strcasecmp (info_name, "weechat_site") == 0)
    {
        return WEECHAT_WEBSITE;
    }
    else if (string_strcasecmp (info_name, "weechat_site_download") == 0)
    {
        return WEECHAT_WEBSITE_DOWNLOAD;
    }
    else if (string_strcasecmp (info_name, "weechat_upgrading") == 0)
    {
        snprintf (value, sizeof (value), "%d", weechat_upgrading);
        return value;
    }
    else if (string_strcasecmp (info_name, "charset_terminal") == 0)
    {
        return weechat_local_charset;
    }
    else if (string_strcasecmp (info_name, "charset_internal") == 0)
    {
        return WEECHAT_INTERNAL_CHARSET;
    }
    else if (string_strcasecmp (info_name, "locale") == 0)
    {
        return setlocale (LC_MESSAGES, NULL);
    }
    else if (string_strcasecmp (info_name, "inactivity") == 0)
    {
        if (gui_key_last_activity_time == 0)
            inactivity = 0;
        else
            inactivity = time (NULL) - gui_key_last_activity_time;
        snprintf (value, sizeof (value), "%ld", (long int)inactivity);
        return value;
    }
    else if (string_strcasecmp (info_name, "filters_enabled") == 0)
    {
        snprintf (value, sizeof (value), "%d", gui_filters_enabled);
        return value;
    }
    else if (string_strcasecmp (info_name, "cursor_mode") == 0)
    {
        snprintf (value, sizeof (value), "%d", gui_cursor_mode);
        return value;
    }
    else if (string_strcasecmp (info_name, "term_width") == 0)
    {
        snprintf (value, sizeof (value), "%d", gui_window_get_width ());
        return value;
    }
    else if (string_strcasecmp (info_name, "term_height") == 0)
    {
        snprintf (value, sizeof (value), "%d", gui_window_get_height ());
        return value;
    }
    else if (string_strcasecmp (info_name, "color_ansi_regex") == 0)
    {
        return GUI_COLOR_REGEX_ANSI_DECODE;
    }
    else if (string_strcasecmp (info_name, "color_term2rgb") == 0)
    {
        if (arguments && arguments[0])
        {
            snprintf (value, sizeof (value),
                      "%d",
                      gui_color_convert_term_to_rgb (atoi (arguments)));
            return value;
        }
    }
    else if (string_strcasecmp (info_name, "color_rgb2term") == 0)
    {
        if (arguments && arguments[0])
        {
            limit = 256;
            pos = strchr (arguments, ',');
            if (pos)
            {
                color = string_strndup (arguments, pos - arguments);
                if (!color)
                    return NULL;
                rgb = atoi (color);
                limit = atoi (pos + 1);
                free (color);
            }
            else
                rgb = atoi (arguments);
            snprintf (value, sizeof (value),
                      "%d",
                      gui_color_convert_rgb_to_term (rgb, limit));
            return value;
        }
    }

    /* info not found */
    return NULL;
}
コード例 #4
0
ファイル: gui-cursor.c プロジェクト: AlexTalker/weechat
void
gui_cursor_move_area_add_xy (int add_x, int add_y)
{
    int x, y, width, height, area_found;
    struct t_gui_focus_info *focus_info_old, *focus_info_new;

    if (!gui_cursor_mode)
        gui_cursor_mode_toggle ();

    area_found = 0;

    x = gui_cursor_x;
    y = gui_cursor_y;
    width = gui_window_get_width ();
    height = gui_window_get_height ();

    focus_info_old = gui_focus_get_info (x, y);
    if (!focus_info_old)
        return;
    focus_info_new = NULL;

    if (add_x != 0)
        x += add_x;
    else
        y += add_y;

    while ((x >= 0) && (x < width) && (y >= 0) && (y < height))
    {
        focus_info_new = gui_focus_get_info (x, y);
        if (!focus_info_new)
        {
            gui_focus_free_info (focus_info_old);
            return;
        }
        if (((focus_info_new->window && focus_info_new->chat)
             || focus_info_new->bar_window)
            && ((focus_info_old->window != focus_info_new->window)
                || (focus_info_old->bar_window != focus_info_new->bar_window)))
        {
            area_found = 1;
            break;
        }

        if (add_x != 0)
            x += add_x;
        else
            y += add_y;
    }

    if (area_found)
    {
        if (focus_info_new->window && focus_info_new->chat)
        {
            x = (focus_info_new->window)->win_chat_x;
            y = (focus_info_new->window)->win_chat_y;
        }
        else if (focus_info_new->bar_window)
        {
            x = (focus_info_new->bar_window)->x;
            y = (focus_info_new->bar_window)->y;
        }
        else
            area_found = 0;
    }

    if (area_found)
    {
        gui_cursor_x = x;
        gui_cursor_y = y;
        gui_cursor_display_debug_info ();
        gui_window_move_cursor ();
    }

    gui_focus_free_info (focus_info_old);
    if (focus_info_new)
        gui_focus_free_info (focus_info_new);
}