bug-ncurses
[Top][All Lists]
Advanced

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

ncurses 5.7 set_field_back problem


From: Pablo Cazallas Gonzÿffffe1lez
Subject: ncurses 5.7 set_field_back problem
Date: Thu, 1 Dec 2011 08:21:48 +0000 (GMT)

Hi all,

I have a problem while developing with ncurses 5.7, exactly with the "set_field_back" method, it is:

When trying to set the video attribute of a field to A_BLINK, if its buffer is longer than 13 bytes and it is empty, the method doesn't work well, but it still returns E_OK.

When doing the same, if the buffer is not longer than 13 bytes, it works fine.

Here is a sample code 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();
}

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

Could anyone tell me some tip or kind of to fix it? I am getting almost crazy with this issue.

Thanks in advance and kind regards,
Pablo Cazallas.

reply via email to

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