qulogic/libgnt

propagate from branch 'im.pidgin.pidgin' (head 14dbc1ec48341dc906ef71636358e7cd3d9a5867)
to branch 'im.pidgin.pidgin.next.minor' (head 0c1214b42880b740bdf19a3650873427eb76a6d5)
  • +5 -2
    gntentry.c
  • +11 -4
    gnttextview.c
  • --- a/gntentry.c Mon Oct 12 05:08:37 2009 +0000
    +++ b/gntentry.c Sat Oct 31 17:52:54 2009 +0000
    @@ -1044,8 +1044,11 @@
    snprintf(entry->start, len + 1, "%s", text);
    entry->end = entry->start + len;
    - entry->scroll = entry->start + scroll;
    - entry->cursor = entry->end - cursor;
    + if ((entry->scroll = entry->start + scroll) > entry->end)
    + entry->scroll = entry->end;
    +
    + if ((entry->cursor = entry->end - cursor) > entry->end)
    + entry->cursor = entry->end;
    if (GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(entry), GNT_WIDGET_MAPPED))
    entry_redraw(GNT_WIDGET(entry));
    --- a/gnttextview.c Mon Oct 12 05:08:37 2009 +0000
    +++ b/gnttextview.c Sat Oct 31 17:52:54 2009 +0000
    @@ -67,6 +67,12 @@
    static void reset_text_view(GntTextView *view);
    +static gboolean
    +text_view_contains(GntTextView *view, const char *str)
    +{
    + return (str >= view->string->str && str < view->string->str + view->string->len);
    +}
    +
    static void
    gnt_text_view_draw(GntWidget *widget)
    {
    @@ -109,7 +115,7 @@
    char back = *end;
    chtype fl = seg->flags;
    *end = '\0';
    - if (select_start < view->string->str + seg->start && select_end > view->string->str + seg->end) {
    + if (select_start && select_start < view->string->str + seg->start && select_end > view->string->str + seg->end) {
    fl |= A_REVERSE;
    wattrset(widget->window, fl);
    wprintw(widget->window, "%s", (view->string->str + seg->start));
    @@ -326,9 +332,10 @@
    select_start = gnt_text_view_get_p(GNT_TEXT_VIEW(widget), x - widget->priv.x, y - widget->priv.y);
    g_timeout_add(500, too_slow, NULL);
    } else if (event == GNT_MOUSE_UP) {
    - if (select_start) {
    + GntTextView *view = GNT_TEXT_VIEW(widget);
    + if (text_view_contains(view, select_start)) {
    GString *clip;
    - select_end = gnt_text_view_get_p(GNT_TEXT_VIEW(widget), x - widget->priv.x, y - widget->priv.y);
    + select_end = gnt_text_view_get_p(view, x - widget->priv.x, y - widget->priv.y);
    if (select_end < select_start) {
    gchar *t = select_start;
    select_start = select_end;
    @@ -336,7 +343,7 @@
    }
    if (select_start == select_end) {
    if (double_click) {
    - clip = select_word_text(GNT_TEXT_VIEW(widget), select_start);
    + clip = select_word_text(view, select_start);
    double_click = FALSE;
    } else {
    double_click = TRUE;