#include "form.priv.h"
-MODULE_ID("$Id: frm_driver.c,v 1.110 2014/02/10 00:42:48 tom Exp $")
+MODULE_ID("$Id: frm_driver.c,v 1.114 2014/07/26 20:46:51 tom Exp $")
/*----------------------------------------------------------------------------
This is the core module of the form library. It contains the majority
instead of a derived window because it contains invisible parts.
This is true for non-public fields and for scrollable fields. */
#define Has_Invisible_Parts(field) \
- (!((unsigned)(field)->opts & O_PUBLIC) || \
+ (!(Field_Has_Option(field, O_PUBLIC)) || \
Is_Scroll_Field(field))
/* Logic to decide whether or not a field needs justification */
#define Justification_Allowed(field) \
(((field)->just != NO_JUSTIFICATION) && \
(Single_Line_Field(field)) && \
- (((field)->dcols == (field)->cols) && \
- ((unsigned)(field)->opts & O_STATIC)))
+ ((Field_Has_Option(field, O_STATIC) && \
+ ((field)->dcols == (field)->cols)) || \
+ Field_Has_Option(field, O_DYNAMIC_JUSTIFY)))
/* Logic to determine whether or not a dynamic field may still grow */
#define Growable(field) ((field)->status & _MAY_GROW)
#define Field_Really_Appears(field) \
((field->form) &&\
(field->form->status & _POSTED) &&\
- ((unsigned)field->opts & O_VISIBLE) &&\
+ (Field_Has_Option(field, O_VISIBLE)) &&\
(field->page == field->form->curpage))
/* Logic to determine whether or not we are on the first position in the
field = form->current;
formwin = Get_Form_Window(form);
- if ((unsigned)field->opts & O_PUBLIC)
+ if (Field_Has_Option(field, O_PUBLIC))
{
if (Is_Scroll_Field(field))
{
if (len > 0)
{
- assert(win && (field->drows == 1) && (field->dcols == field->cols));
+ assert(win && (field->drows == 1));
- switch (field->just)
- {
- case JUSTIFY_LEFT:
- break;
- case JUSTIFY_CENTER:
- col = (field->cols - len) / 2;
- break;
- case JUSTIFY_RIGHT:
- col = field->cols - len;
- break;
- default:
- break;
- }
+ if (field->cols - len >= 0)
+ switch (field->just)
+ {
+ case JUSTIFY_LEFT:
+ break;
+ case JUSTIFY_CENTER:
+ col = (field->cols - len) / 2;
+ break;
+ case JUSTIFY_RIGHT:
+ col = field->cols - len;
+ break;
+ default:
+ break;
+ }
wmove(win, 0, col);
myADDNSTR(win, bp, len);
return E_SYSTEM_ERROR;
else
{
- if ((unsigned)field->opts & O_VISIBLE)
+ if (Field_Has_Option(field, O_VISIBLE))
{
Set_Field_Window_Attributes(field, win);
}
if (!bEraseFlag)
{
- if ((unsigned)field->opts & O_PUBLIC)
+ if (Field_Has_Option(field, O_PUBLIC))
{
if (Justification_Allowed(field))
Perform_Justification(field, win);
form->currow = form->curcol = form->toprow = form->begincol = 0;
werase(form->w);
- if (((unsigned)field->opts & O_PUBLIC) && Justification_Allowed(field))
+ if ((Field_Has_Option(field, O_PUBLIC)) && Justification_Allowed(field))
Undo_Justification(field, form->w);
else
Buffer_To_Window(field, form->w);
werase(form->w);
wmove(form->w, form->currow, form->curcol);
- if ((unsigned)field->opts & O_PUBLIC)
+ if (Field_Has_Option(field, O_PUBLIC))
{
if (Justification_Allowed(field))
Undo_Justification(field, form->w);
!(form->status & _POSTED))
{
if ((form->w) &&
- ((unsigned)field->opts & O_VISIBLE) &&
+ (Field_Has_Option(field, O_VISIBLE)) &&
(field->form->curpage == field->page))
{
_nc_Refresh_Current_Field(form);
- if ((unsigned)field->opts & O_PUBLIC)
+ if (Field_Has_Option(field, O_PUBLIC))
{
if (field->drows > field->rows)
{
Window_To_Buffer(form, field);
werase(form->w);
Perform_Justification(field, form->w);
- wsyncup(form->w);
+ if (Field_Has_Option(field, O_DYNAMIC_JUSTIFY) &&
+ (form->w->_parent == 0))
+ {
+ copywin(form->w,
+ Get_Form_Window(form),
+ 0,
+ 0,
+ field->frow,
+ field->fcol,
+ field->frow,
+ field->cols + field->fcol - 1,
+ 0);
+ wsyncup(Get_Form_Window(form));
+ }
+ else
+ {
+ wsyncup(form->w);
+ }
}
}
}
{
res = fct(form);
if (res == E_OK)
- SetStatus(form, _NEWTOP);
+ SetStatus(form->current, _NEWTOP);
}
return (res);
}
int result = E_REQUEST_DENIED;
bool Last_Row = ((field->drows - 1) == form->currow);
- if (((unsigned)field->opts & O_WRAP) && /* wrapping wanted */
+ if ((Field_Has_Option(field, O_WRAP)) && /* wrapping wanted */
(!Single_Line_Field(field)) && /* must be multi-line */
(There_Is_No_Room_For_A_Char_In_Line(form)) && /* line is full */
(!Last_Row || Growable(field))) /* there are more lines */
{
if (typ)
{
- if ((unsigned)field->opts & O_NULLOK)
+ if (Field_Has_Option(field, O_NULLOK))
{
FIELD_CELL *bp = field->buf;
Synchronize_Buffer(form);
if ((form->status & _FCHECK_REQUIRED) ||
- (!((unsigned)field->opts & O_PASSOK)))
+ (!(Field_Has_Option(field, O_PASSOK))))
{
if (!Check_Field(form, field->type, field, (TypeArgument *)(field->arg)))
return FALSE;
do
{
field = (field == last_on_page) ? first : field + 1;
- if (((unsigned)(*field)->opts & O_VISIBLE))
+ if (Field_Has_Option(*field, O_VISIBLE))
break;
}
while (proposed != (*field));
int result = E_REQUEST_DENIED;
T((T_CALLED("Data_Entry(%p,%s)"), (void *)form, _tracechtype((chtype)c)));
- if (((unsigned)field->opts & O_EDIT)
+ if ((Field_Has_Option(field, O_EDIT))
#if FIX_FORM_INACTIVE_BUG
- && ((unsigned)field->opts & O_ACTIVE)
+ && (Field_Has_Option(field, O_ACTIVE))
#endif
)
{
given[0] = c;
given[1] = 1;
setcchar(&temp_ch, given, 0, 0, (void *)0);
- if (((unsigned)field->opts & O_BLANK) &&
+ if ((Field_Has_Option(field, O_BLANK)) &&
First_Position_In_Current_Field(form) &&
!(form->status & _FCHECK_REQUIRED) &&
!(form->status & _WINDOW_MODIFIED))
((field->dcols - 1) == form->curcol));
form->status |= _WINDOW_MODIFIED;
- if (End_Of_Field && !Growable(field) && ((unsigned)field->opts & O_AUTOSKIP))
+ if (End_Of_Field && !Growable(field) && (Field_Has_Option(field, O_AUTOSKIP)))
result = Inter_Field_Navigation(FN_Next_Field, form);
else
{
int result = E_REQUEST_DENIED;
T((T_CALLED("Data_Entry(%p,%s)"), (void *)form, _tracechtype((chtype)c)));
- if (((unsigned)field->opts & O_EDIT)
+ if ((Field_Has_Option(field, O_EDIT))
#if FIX_FORM_INACTIVE_BUG
- && ((unsigned)field->opts & O_ACTIVE)
+ && (Field_Has_Option(field, O_ACTIVE))
#endif
)
{
- if (((unsigned)field->opts & O_BLANK) &&
+ if ((Field_Has_Option(field, O_BLANK)) &&
First_Position_In_Current_Field(form) &&
!(form->status & _FCHECK_REQUIRED) &&
!(form->status & _WINDOW_MODIFIED))
((field->dcols - 1) == form->curcol));
SetStatus(form, _WINDOW_MODIFIED);
- if (End_Of_Field && !Growable(field) && ((unsigned)field->opts & O_AUTOSKIP))
+ if (End_Of_Field && !Growable(field) && (Field_Has_Option(field, O_AUTOSKIP)))
result = Inter_Field_Navigation(FN_Next_Field, form);
else
{
const Binding_Info *BI = (Binding_Info *) 0;
int res = E_UNKNOWN_COMMAND;
- T((T_CALLED("form_driver(%p,%d)"), (void *)form, (int) c));
+ T((T_CALLED("form_driver(%p,%d)"), (void *)form, (int)c));
if (!form)
RETURN(E_BAD_ARGUMENT);
assert(form->page);
- if (c == FIRST_ACTIVE_MAGIC)
+ if (c == (wchar_t)FIRST_ACTIVE_MAGIC)
{
form->current = _nc_First_Active_Field(form);
RETURN(E_OK);