bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: set_field_back A_BLINK problem


From: Pablo Cazallas Gonzÿffffe1lez
Subject: Re: set_field_back A_BLINK problem
Date: Mon, 28 Nov 2011 12:57:28 +0000 (GMT)

Hi again,

When trying to blink a field, if its buffer is longer than 13 bytes (not being filled with any data) the routine "set_field_back" doesn't work, but it still returns E_OK.

When doing the same with a field buffer not longer than 13 bytes, it works fine.

Here is an example test program that demonstrates it:
==============================================================

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <menu.h>
#include <form.h>
#include <panel.h>
#include <ncurses.h>

void initNCURSES();
void endNCURSES();


int main(int argc, char *argv[])
{
    /**
    *** Variables
    **/
    WINDOW *win;
    FORM *form;
    FIELD *campo[3];
    PANEL *panel;
    int doWork = 1;
    int tecla = -1;
   
    /**
    *** Initializes NCURSES
    **/
    initNCURSES();
   
    /**
    *** Window creation
    **/
    win = newwin(7, 55, 6, 15);
   
    /**
    *** This field blinks without any problem
    **/
    campo[0] = new_field(1, 13, 2, 19, 0, 0);
    set_field_back(campo[0], A_BLINK);
    field_opts_off(campo[0], O_BLANK);
   
    /**
    *** This field does not blink, it seems there is any kind of issue
    *** changing a field to A_BLINK attribute if it is longer than 13 bytes
    **/
    campo[1] = new_field(1, 34, 3, 19, 0, 0);
    set_field_back(campo[1], A_BLINK);
    field_opts_off(campo[1], O_BLANK);
   
    /**
    *** Last field (NULL) of the form
    **/
    campo[2] = NULL;
   
   
    /**
    *** Prints form
    **/
    form = new_form(campo);
    set_form_win(form, win);
    set_form_sub(form, derwin(win, 1, 34, LINES, COLS));
    post_form(form);
   
    /**
    *** Prints box
    **/
    box(win, 0, 0);   
    wattron(win, A_REVERSE);
    mvwprintw(win, 0, 2, " TITLE WIN...");
    wattroff(win, A_REVERSE);

    /**
    *** Prints literals
    **/
    mvwprintw(win, 2, 1, "Blinking.......: ");
    mvwprintw(win, 3, 1, "Not blinking...: ");
    mvwprintw(win, 4, 1, "                      PF10.- END ");
    keypad(win, TRUE);
   
    /**
    *** Shows panel
    **/
    panel = new_panel(win);
    update_panels();
    doupdate();
    wrefresh(win);


    form_driver(form, REQ_FIRST_FIELD);

    /**
    *** Key handling loop
    **/
    while(doWork)
    {
        tecla = wgetch(win);
        switch(tecla)
        {  
            case KEY_F(10):
                doWork = 0;
                break;
       
            case KEY_LEFT:
                form_driver(form, REQ_PREV_CHAR);
                break;
               
            case KEY_RIGHT:
                form_driver(form, REQ_NEXT_CHAR);
                break;
               
            case KEY_BACKSPACE:
                form_driver(form, REQ_DEL_PREV);
                break;
               
            case 9:
                form_driver(form, REQ_NEXT_FIELD);
                break;
           
            default:
                form_driver(form, REQ_OVL_MODE);
                form_driver(form, tecla);
                break;
        } /* switch */
    }
   
    /**
    *** Free form
    **/
    free_form(form);
    form = NULL;

    /**
    *** Free fields
    **/
    free_field(campo[0]);
    campo[0] = NULL;
    free_field(campo[1]);
    campo[1] = NULL;
    free_field(campo[2]);
    campo[2] = NULL;
       
    hide_panel(panel);

    /**
    *** Clean Screen
    **/
    wclear(win);
    delwin(win);
    win = NULL;
    refresh();
   
    /**
    *** Ends NCURSES
    **/
    endNCURSES();
   
   
    /**
    *** Main return
    **/
    return 0;
}

void initNCURSES()
{
    setlocale(LC_ALL, "");
    initscr();
    cbreak();
    keypad(stdscr, TRUE);
    nodelay(stdscr, FALSE);
    nonl();
    noecho();
    curs_set(FALSE);
    refresh();
}

void endNCURSES()
{
    curs_set(TRUE);
    clear();
    echo();
    refresh();
    endwin();
}

==============================================================

I'm getting almost crazy with this issue, so any help or suggestion will be appreciated.

Thanks again, and regards,
Pablo.


LRU #493328



--- El vie, 25/11/11, Thomas Dickey <address@hidden> escribió:

De: Thomas Dickey <address@hidden>
Asunto: Re: set_field_back A_BLINK problem
Para: "Pablo Cazallas Gonz?ffffe1lez" <address@hidden>
CC: address@hidden
Fecha: viernes, 25 de noviembre, 2011 13:37

On Thu, Nov 24, 2011 at 08:01:28AM +0000, Pablo Cazallas Gonz?ffffe1lez wrote:
> I'm sorry, I didn't explain the problem so well...
>
> The terminal that I am using blinks, I'm totally sure.
> What I tried to mean is that changing the attribute of the most of the form's fields to A_BLINK works, but it doesn't work for some of them when the field buffer is empty at the moment of the change.
>
> It is a form with 6 fields, the first four of them blink when I change the attribute, but the last two don't.
>
> If I set the attribute to another different than A_BLINK, set_field_back() changes it as well.

Reviewing the (form library) code, I don't see anything that would make
its behavior like that.  It stores the video attributes for a field in
one place, keeps all of the bits.  A quick check here modifying
test/demo_forms shows all of the fields blinking (after modifying the
call to set_field_back).

Can you reproduce the problem with a test program that we can discuss?

>
> Any idea about how to fix it?
>
> Thanks a lot and regards,
> Pablo.
> LRU #493328
>
>
>
> --- El mi?, 23/11/11, Thomas Dickey <address@hidden> escribi?:
>
> De: Thomas Dickey <address@hidden>
> Asunto: Re: set_field_back A_BLINK problem
> Para: "Pablo Cazallas Gonz?ffffe1lez" <address@hidden>
> CC: address@hidden
> Fecha: mi?rcoles, 23 de noviembre, 2011 17:46
>
> On Wed, Nov 23, 2011 at 03:05:32PM +0000, Pablo Cazallas Gonz?ffffe1lez wrote:
> > Hi,
> >
> > I am developing with ncurses 5.7 in ANSI-C a form application.
> >
> > When I try to change the background of a field to A_BLINK, it doesn't work.
> > And if I set it with A_REVERSE it works.
> >
> > The cursor is never in the field that I try to change.
> >
> > Is it a bug in the library? How can I fix it?
>
> no.? It's a common limitation.
> In general, terminal backgrounds don't blink.
>
> --
> Thomas E. Dickey <address@hidden>
> http://invisible-island.net
> ftp://invisible-island.net

--
Thomas E. Dickey <address@hidden>
http://invisible-island.net
ftp://invisible-island.net

reply via email to

[Prev in Thread] Current Thread [Next in Thread]