Hello, I am having two problems with three C sursor screens I coded, using the curses library. The first problem is that a field will not highlight when I move the cursor to that field, even though I use the wattron command to highlight it. I can get the highlight command to work when I use mvwprintw, but it does not work when I use wmove. Below is a sample of code that does not highlight:
mvwprintw(win,yfmt,0,"Format: X.XXXXX");
wattron(win,A_STANDOUT);
if (onFloor == 1)
{
wmove(win,7,35);
wattron(win,A_STANDOUT);
onCeiling = 1;
onFloor = 0;
i = 1;
}
The field at yfmt,0 in mvwprintw command is highlighted, but the field at 7,35 in the wmove command is not hightlighted. I am not sure why the wattron does not work on wmove.
The other problem I am having is that values I read in from a file are not associated with the fields that represent them is the screen. I read in values from a file and print them in the screen with the following code:
ncard=166;
lnbeg=81*(ncard-1);
fseek(upd,lnbeg,0);
fgets(ppcard, 82, upd);
sscanf(ppcard, "%lf %lf", &tbl[0][0], &tbl[1][0]);
mvwaddstr(win,5,3,"Solvency Tax Trigger On Value:");
mvwaddstr(win,7,3,"Solvency Tax Trigger Off Value:");
wrefresh(win);
mvwprintw(win,5,35,"%5.3f",tbl[0][0]);
mvwprintw(win,7,35,"%5.3f",tbl[1][0]);
wrefresh(win);
When the cursor is moved to one of these two fields and the user retyoes the floating-point value in that field, the following function is called:
repl_num(); /* uses std scan to get new # */
The code in the repl_num function is:
void repl_num()
{
/*get user NUMERIC update*/
int k,n,xc,xmax,nread;
char ch;
echo();
/* clear current # */
wattroff(win,A_STANDOUT);
wmove(win,y,x);
for(k=x;k<xt;k++)
wprintw(win," ");
wattron(win,A_BLINK);
mvwprintw(win,yfmt,32,"HIT RETURN");
wattroff(win,A_BLINK);
wmove(win,y,x);
wrefresh(win);
/* get new # & check */
ungetch(key); /*1st digit echoed 1st when 2nd is typed*/
nread = wscanw(win,edfmt[i],&val);
mvwprintw(win,yfmt,32,"HIT RETURN"); /*turn off BLINK*/
if(nread==0)
{
wattron(win,A_STANDOUT);
nerrmsg("ERROR!");
return;
}
wmove(win,y,x);
/* check upper, lower size limits */
if(val>=vmax[i]) /* >= used so 1E3 out for 3 digits etc */
{
nerrmsg("TOO BIG!");
return;
}
if(val<vmin[i])
{
nerrmsg("TOO LOW!");
return;
}
tbl[i][j]=val;
/* clear, reprint rest of line in case user messed screen up with arrow keys
to clear 1 col (eg side row hdgs) set nqtrs to j+1 */
wattroff(win,A_STANDOUT);
for(k=j,xc=x;k<nqtrs;k++,xc+=xtab)
{
xmax=xc+xtab;
if(xmax>79) xmax=79;
wmove(win,y,xc);
for(n=xc; n<xmax; n++)
wprintw(win," ");
mvwprintw(win,y,xc,shofmt[i],tbl[i][k]);
}
wattron(win,A_STANDOUT);
for(xt=x; xt<80 && (ch=mvwinch(win,y,xt))!=' '; xt++)
mvwprintw(win,y,xt,"%c",ch);
wattroff(win,A_STANDOUT);
wmove(win,y,x-1);
wrefresh(win);
}
This should set the new value entered by the user to the variable that set that field, tbl[i][j]. I have verifled that the i and j values are correct for the field the user is typing in the new value. When the file is saved, I can see that the two tbl[i][j] values are still the original read-in values, not the new values typed in by the user. I do not see why the change is not associated with the variable used to set the field.
Any help with these two problems is greatly appreciated.