/****************************************************************************
- * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2012,2013 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
#include "form.priv.h"
-MODULE_ID("$Id: frm_driver.c,v 1.93 2009/10/24 23:23:32 tom Exp $")
+MODULE_ID("$Id: frm_driver.c,v 1.106 2013/08/25 00:02:15 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) \
- (!((field)->opts & O_PUBLIC) || \
+ (!((unsigned)(field)->opts & O_PUBLIC) || \
Is_Scroll_Field(field))
/* Logic to decide whether or not a field needs justification */
(((field)->just != NO_JUSTIFICATION) && \
(Single_Line_Field(field)) && \
(((field)->dcols == (field)->cols) && \
- ((field)->opts & O_STATIC)) )
+ ((unsigned)(field)->opts & O_STATIC)))
/* Logic to determine whether or not a dynamic field may still grow */
#define Growable(field) ((field)->status & _MAY_GROW)
/* Macro to set the attributes for a fields window */
#define Set_Field_Window_Attributes(field,win) \
-( wbkgdset((win),(chtype)((field)->pad | (field)->back)), \
- (void) wattrset((win),(field)->fore) )
+( wbkgdset((win),(chtype)((chtype)((field)->pad) | (field)->back)), \
+ (void) wattrset((win), (int)(field)->fore) )
/* Logic to decide whether or not a field really appears on the form */
#define Field_Really_Appears(field) \
((field->form) &&\
(field->form->status & _POSTED) &&\
- (field->opts & O_VISIBLE) &&\
+ ((unsigned)field->opts & O_VISIBLE) &&\
(field->page == field->form->curpage))
/* Logic to determine whether or not we are on the first position in the
/*---------------------------------------------------------------------------
| Facility : libnform
-| Function : static void Window_To_Buffer(
+| Function : void _nc_get_fieldbuffer(
| WINDOW * win,
-| FIELD * field)
+| FIELD * field,
+| FIELD_CELL * buf)
|
| Description : Copy the content of the window into the buffer.
| The multiple lines of a window are simply
|
| Return Values : -
+--------------------------------------------------------------------------*/
-static void
-Window_To_Buffer(WINDOW *win, FIELD *field)
+NCURSES_EXPORT(void)
+_nc_get_fieldbuffer(FORM *form, FIELD *field, FIELD_CELL *buf)
{
int pad;
int len = 0;
FIELD_CELL *p;
int row, height;
+ WINDOW *win;
- assert(win && field && field->buf);
+ assert(form && field && buf);
+
+ win = form->w;
+ assert(win);
pad = field->pad;
- p = field->buf;
+ p = buf;
height = getmaxy(win);
for (row = 0; (row < height) && (row < field->drows); row++)
}
}
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static void Window_To_Buffer(
+| FORM * form,
+| FIELD * field)
+|
+| Description : Copy the content of the window into the buffer.
+| The multiple lines of a window are simply
+| concatenated into the buffer. Pad characters in
+| the window will be replaced by blanks in the buffer.
+|
+| Return Values : -
++--------------------------------------------------------------------------*/
+static void
+Window_To_Buffer(FORM *form, FIELD *field)
+{
+ _nc_get_fieldbuffer(form, field, field->buf);
+}
+
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void Synchronize_Buffer(FORM * form)
{
if (form->status & _WINDOW_MODIFIED)
{
- form->status &= ~_WINDOW_MODIFIED;
- form->status |= _FCHECK_REQUIRED;
- Window_To_Buffer(form->w, form->current);
+ ClrStatus(form, _WINDOW_MODIFIED);
+ SetStatus(form, _FCHECK_REQUIRED);
+ Window_To_Buffer(form, form->current);
wmove(form->w, form->currow, form->curcol);
}
}
growth = Minimum(field->maxgrow - field->dcols, growth);
field->dcols += growth;
if (field->dcols == field->maxgrow)
- field->status &= ~_MAY_GROW;
+ ClrStatus(field, _MAY_GROW);
}
else
{
growth = Minimum(field->maxgrow - field->drows, growth);
field->drows += growth;
if (field->drows == field->maxgrow)
- field->status &= ~_MAY_GROW;
+ ClrStatus(field, _MAY_GROW);
}
/* drows, dcols changed, so we get really the new buffer length */
new_buflen = Buffer_Length(field);
field->drows = old_drows;
if ((single_line_field && (field->dcols != field->maxgrow)) ||
(!single_line_field && (field->drows != field->maxgrow)))
- field->status |= _MAY_GROW;
+ SetStatus(field, _MAY_GROW);
}
else
{
(field->dcols != field->maxgrow)) ||
(!single_line_field &&
(field->drows != field->maxgrow)))
- field->status |= _MAY_GROW;
+ SetStatus(field, _MAY_GROW);
free(newbuf);
}
}
field = form->current;
formwin = Get_Form_Window(form);
- if (field->opts & O_PUBLIC)
+ if ((unsigned)field->opts & O_PUBLIC)
{
if (Is_Scroll_Field(field))
{
if (form->currow < form->toprow)
{
form->toprow = form->currow;
- field->status |= _NEWTOP;
+ SetStatus(field, _NEWTOP);
}
if (form->currow >= row_after_bottom)
{
form->toprow = form->currow - field->rows + 1;
- field->status |= _NEWTOP;
+ SetStatus(field, _NEWTOP);
}
if (field->status & _NEWTOP)
{
/* means we have to copy whole range */
first_modified_row = form->toprow;
first_unmodified_row = first_modified_row + field->rows;
- field->status &= ~_NEWTOP;
+ ClrStatus(field, _NEWTOP);
}
else
{
/*---------------------------------------------------------------------------
| Facility : libnform
-| Function : static bool Check_Char(
+| Function : static bool Check_Char(FORM *form,
+| FIELD *field,
| FIELDTYPE * typ,
| int ch,
| TypeArgument *argp)
| FALSE - Character is invalid
+--------------------------------------------------------------------------*/
static bool
-Check_Char(FIELDTYPE *typ, int ch, TypeArgument *argp)
+Check_Char(FORM *form,
+ FIELD *field,
+ FIELDTYPE *typ,
+ int ch,
+ TypeArgument *argp)
{
if (typ)
{
{
assert(argp);
return (
- Check_Char(typ->left, ch, argp->left) ||
- Check_Char(typ->right, ch, argp->right));
+ Check_Char(form, field, typ->left, ch, argp->left) ||
+ Check_Char(form, field, typ->right, ch, argp->right));
}
else
{
+#if NCURSES_INTEROP_FUNCS
+ if (typ->charcheck.occheck)
+ {
+ if (typ->status & _GENERIC)
+ return typ->charcheck.gccheck(ch, form, field, (void *)argp);
+ else
+ return typ->charcheck.occheck(ch, (void *)argp);
+ }
+#else
if (typ->ccheck)
return typ->ccheck(ch, (void *)argp);
+#endif
}
}
return (!iscntrl(UChar(ch)) ? TRUE : FALSE);
return E_SYSTEM_ERROR;
else
{
- if (field->opts & O_VISIBLE)
+ if ((unsigned)field->opts & O_VISIBLE)
{
Set_Field_Window_Attributes(field, win);
}
else
{
- (void)wattrset(win, WINDOW_ATTRS(fwin));
+ (void)wattrset(win, (int)WINDOW_ATTRS(fwin));
}
werase(win);
}
if (!bEraseFlag)
{
- if (field->opts & O_PUBLIC)
+ if ((unsigned)field->opts & O_PUBLIC)
{
if (Justification_Allowed(field))
Perform_Justification(field, win);
else
Buffer_To_Window(field, win);
}
- field->status &= ~_NEWTOP;
+ ClrStatus(field, _NEWTOP);
}
wsyncup(win);
delwin(win);
form->currow = form->curcol = form->toprow = form->begincol = 0;
werase(form->w);
- if ((field->opts & O_PUBLIC) && Justification_Allowed(field))
+ if (((unsigned)field->opts & O_PUBLIC) && Justification_Allowed(field))
Undo_Justification(field, form->w);
else
Buffer_To_Window(field, form->w);
- field->status |= _NEWTOP;
+ SetStatus(field, _NEWTOP);
res = _nc_Refresh_Current_Field(form);
}
else
res = Display_Field(field);
}
- field->status |= _CHANGED;
+ SetStatus(field, _CHANGED);
return (res);
}
return (E_SYSTEM_ERROR);
for (linked_field = field->link;
- linked_field != field;
+ (linked_field != field) && (linked_field != 0);
linked_field = linked_field->link)
{
if (((syncres = Synchronize_Field(linked_field)) != E_OK) &&
werase(form->w);
wmove(form->w, form->currow, form->curcol);
- if (field->opts & O_PUBLIC)
+ if ((unsigned)field->opts & O_PUBLIC)
{
if (Justification_Allowed(field))
Undo_Justification(field, form->w);
field->rows - 1, field->cols - 1, 0);
wsyncup(formwin);
Buffer_To_Window(field, form->w);
- field->status |= _NEWTOP; /* fake refresh to paint all */
+ SetStatus(field, _NEWTOP); /* fake refresh to paint all */
_nc_Refresh_Current_Field(form);
}
}
if (form)
{
- if (form->current == field)
- {
- field->opts = oldopts;
- returnCode(E_CURRENT);
- }
-
if (form->status & _POSTED)
{
- if ((form->curpage == field->page))
+ if (form->current == field)
+ {
+ field->opts = oldopts;
+ returnCode(E_CURRENT);
+ }
+ if (form->curpage == field->page)
{
- if (changed_opts & O_VISIBLE)
+ if ((unsigned)changed_opts & O_VISIBLE)
{
- if (newopts & O_VISIBLE)
+ if ((unsigned)newopts & O_VISIBLE)
res = Display_Field(field);
else
res = Erase_Field(field);
}
else
{
- if ((changed_opts & O_PUBLIC) &&
- (newopts & O_VISIBLE))
+ if (((unsigned)changed_opts & O_PUBLIC) &&
+ ((unsigned)newopts & O_VISIBLE))
res = Display_Field(field);
}
}
}
}
- if (changed_opts & O_STATIC)
+ if ((unsigned)changed_opts & O_STATIC)
{
bool single_line_field = Single_Line_Field(field);
int res2 = E_OK;
- if (newopts & O_STATIC)
+ if ((unsigned)newopts & O_STATIC)
{
/* the field becomes now static */
- field->status &= ~_MAY_GROW;
+ ClrStatus(field, _MAY_GROW);
/* if actually we have no hidden columns, justification may
occur again */
if (single_line_field &&
(single_line_field && (field->dcols < field->maxgrow)) ||
(!single_line_field && (field->drows < field->maxgrow)))
{
- field->status |= _MAY_GROW;
+ SetStatus(field, _MAY_GROW);
/* a field with justification now changes its behavior,
so we must redisplay it */
if (single_line_field &&
!(form->status & _POSTED))
{
if ((form->w) &&
- (field->opts & O_VISIBLE) &&
+ ((unsigned)field->opts & O_VISIBLE) &&
(field->form->curpage == field->page))
{
_nc_Refresh_Current_Field(form);
- if (field->opts & O_PUBLIC)
+ if ((unsigned)field->opts & O_PUBLIC)
{
if (field->drows > field->rows)
{
if (form->toprow == 0)
- field->status &= ~_NEWTOP;
+ ClrStatus(field, _NEWTOP);
else
- field->status |= _NEWTOP;
+ SetStatus(field, _NEWTOP);
}
else
{
if (Justification_Allowed(field))
{
- Window_To_Buffer(form->w, field);
+ Window_To_Buffer(form, field);
werase(form->w);
Perform_Justification(field, form->w);
wsyncup(form->w);
delwin(form->w);
form->w = new_window;
- form->status &= ~_WINDOW_MODIFIED;
+ ClrStatus(form, _WINDOW_MODIFIED);
Set_Field_Window_Attributes(field, form->w);
if (Has_Invisible_Parts(field))
{
res = fct(form);
if (res == E_OK)
- form->current->status |= _NEWTOP;
+ SetStatus(form, _NEWTOP);
}
return (res);
}
int result = E_REQUEST_DENIED;
bool Last_Row = ((field->drows - 1) == form->currow);
- if ((field->opts & O_WRAP) && /* wrapping wanted */
+ if (((unsigned)field->opts & 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 */
return E_SYSTEM_ERROR;
}
bp = Address_Of_Current_Row_In_Buffer(form);
- Window_To_Buffer(form->w, field);
+ Window_To_Buffer(form, field);
split = After_Last_Whitespace_Character(bp, field->dcols);
/* split points to the first character of the sequence to be brought
on the next line */
if (result != E_OK)
{
DeleteChar(form);
- Window_To_Buffer(form->w, field);
+ Window_To_Buffer(form, field);
result = E_REQUEST_DENIED;
}
}
editable fields.
*/
if ((fct == FE_Delete_Previous) &&
- (form->opts & O_BS_OVERLOAD) &&
+ ((unsigned)form->opts & O_BS_OVERLOAD) &&
First_Position_In_Current_Field(form))
{
res = Inter_Field_Navigation(FN_Previous_Field, form);
{
if (fct == FE_New_Line)
{
- if ((form->opts & O_NL_OVERLOAD) &&
+ if (((unsigned)form->opts & O_NL_OVERLOAD) &&
First_Position_In_Current_Field(form))
{
res = Inter_Field_Navigation(FN_Next_Field, form);
else
{
/* From now on, everything must be editable */
- if (form->current->opts & O_EDIT)
+ if ((unsigned)form->current->opts & O_EDIT)
{
res = fct(form);
if (res == E_OK)
- form->status |= _WINDOW_MODIFIED;
+ SetStatus(form, _WINDOW_MODIFIED);
}
}
}
if (Last_Row &&
(!(Growable(field) && !Single_Line_Field(field))))
{
- if (!(form->opts & O_NL_OVERLOAD))
+ if (!((unsigned)form->opts & O_NL_OVERLOAD))
returnCode(E_REQUEST_DENIED);
wmove(form->w, form->currow, form->curcol);
wclrtoeol(form->w);
handled in the generic routine. The reason is,
that FN_Next_Field may fail, but the form is
definitively changed */
- form->status |= _WINDOW_MODIFIED;
+ SetStatus(form, _WINDOW_MODIFIED);
returnCode(Inter_Field_Navigation(FN_Next_Field, form));
}
else
wclrtoeol(form->w);
form->currow++;
form->curcol = 0;
- form->status |= _WINDOW_MODIFIED;
+ SetStatus(form, _WINDOW_MODIFIED);
returnCode(E_OK);
}
}
if (Last_Row &&
!(Growable(field) && !Single_Line_Field(field)))
{
- if (!(form->opts & O_NL_OVERLOAD))
+ if (!((unsigned)form->opts & O_NL_OVERLOAD))
returnCode(E_REQUEST_DENIED);
returnCode(Inter_Field_Navigation(FN_Next_Field, form));
}
wmove(form->w, form->currow, form->curcol);
winsertln(form->w);
myADDNSTR(form->w, bp, (int)(t - bp));
- form->status |= _WINDOW_MODIFIED;
+ SetStatus(form, _WINDOW_MODIFIED);
returnCode(E_OK);
}
}
int result = E_REQUEST_DENIED;
T((T_CALLED("FE_Insert_Character(%p)"), (void *)form));
- if (Check_Char(field->type, (int)C_BLANK, (TypeArgument *)(field->arg)))
+ if (Check_Char(form, field, field->type, (int)C_BLANK,
+ (TypeArgument *)(field->arg)))
{
bool There_Is_Room = Is_There_Room_For_A_Char_In_Line(form);
int result = E_REQUEST_DENIED;
T((T_CALLED("FE_Insert_Line(%p)"), (void *)form));
- if (Check_Char(field->type, (int)C_BLANK, (TypeArgument *)(field->arg)))
+ if (Check_Char(form, field,
+ field->type, (int)C_BLANK, (TypeArgument *)(field->arg)))
{
bool Maybe_Done = (form->currow != (field->drows - 1)) &&
Is_There_Room_For_A_Line(form);
EM_Overlay_Mode(FORM *form)
{
T((T_CALLED("EM_Overlay_Mode(%p)"), (void *)form));
- form->status |= _OVLMODE;
+ SetStatus(form, _OVLMODE);
returnCode(E_OK);
}
EM_Insert_Mode(FORM *form)
{
T((T_CALLED("EM_Insert_Mode(%p)"), (void *)form));
- form->status &= ~_OVLMODE;
+ ClrStatus(form, _OVLMODE);
returnCode(E_OK);
}
/*---------------------------------------------------------------------------
| Facility : libnform
-| Function : static bool Next_Choice(
+| Function : static bool Next_Choice(FORM * form,
| FIELDTYPE * typ,
| FIELD * field,
| TypeArgument *argp)
| FALSE - couldn't retrieve next choice
+--------------------------------------------------------------------------*/
static bool
-Next_Choice(FIELDTYPE *typ, FIELD *field, TypeArgument *argp)
+Next_Choice(FORM *form, FIELDTYPE *typ, FIELD *field, TypeArgument *argp)
{
if (!typ || !(typ->status & _HAS_CHOICE))
return FALSE;
{
assert(argp);
return (
- Next_Choice(typ->left, field, argp->left) ||
- Next_Choice(typ->right, field, argp->right));
+ Next_Choice(form, typ->left, field, argp->left) ||
+ Next_Choice(form, typ->right, field, argp->right));
}
else
{
+#if NCURSES_INTEROP_FUNCS
+ assert(typ->enum_next.onext);
+ if (typ->status & _GENERIC)
+ return typ->enum_next.gnext(form, field, (void *)argp);
+ else
+ return typ->enum_next.onext(field, (void *)argp);
+#else
assert(typ->next);
return typ->next(field, (void *)argp);
+#endif
}
}
/*---------------------------------------------------------------------------
| Facility : libnform
-| Function : static bool Previous_Choice(
+| Function : static bool Previous_Choice(FORM * form,
| FIELDTYPE * typ,
| FIELD * field,
| TypeArgument *argp)
| FALSE - couldn't retrieve previous choice
+--------------------------------------------------------------------------*/
static bool
-Previous_Choice(FIELDTYPE *typ, FIELD *field, TypeArgument *argp)
+Previous_Choice(FORM *form, FIELDTYPE *typ, FIELD *field, TypeArgument *argp)
{
if (!typ || !(typ->status & _HAS_CHOICE))
return FALSE;
{
assert(argp);
return (
- Previous_Choice(typ->left, field, argp->left) ||
- Previous_Choice(typ->right, field, argp->right));
+ Previous_Choice(form, typ->left, field, argp->left) ||
+ Previous_Choice(form, typ->right, field, argp->right));
}
else
{
+#if NCURSES_INTEROP_FUNCS
+ assert(typ->enum_prev.oprev);
+ if (typ->status & _GENERIC)
+ return typ->enum_prev.gprev(form, field, (void *)argp);
+ else
+ return typ->enum_prev.oprev(field, (void *)argp);
+#else
assert(typ->prev);
return typ->prev(field, (void *)argp);
+#endif
}
}
/*----------------------------------------------------------------------------
T((T_CALLED("CR_Next_Choice(%p)"), (void *)form));
Synchronize_Buffer(form);
- returnCode((Next_Choice(field->type, field, (TypeArgument *)(field->arg)))
+ returnCode((Next_Choice(form, field->type, field, (TypeArgument *)(field->arg)))
? E_OK
: E_REQUEST_DENIED);
}
T((T_CALLED("CR_Previous_Choice(%p)"), (void *)form));
Synchronize_Buffer(form);
- returnCode((Previous_Choice(field->type, field, (TypeArgument *)(field->arg)))
+ returnCode((Previous_Choice(form, field->type, field, (TypeArgument *)(field->arg)))
? E_OK
: E_REQUEST_DENIED);
}
/*---------------------------------------------------------------------------
| Facility : libnform
-| Function : static bool Check_Field(
+| Function : static bool Check_Field(FORM* form,
| FIELDTYPE * typ,
| FIELD * field,
| TypeArgument * argp)
| FALSE - field is invalid.
+--------------------------------------------------------------------------*/
static bool
-Check_Field(FIELDTYPE *typ, FIELD *field, TypeArgument *argp)
+Check_Field(FORM *form, FIELDTYPE *typ, FIELD *field, TypeArgument *argp)
{
if (typ)
{
- if (field->opts & O_NULLOK)
+ if ((unsigned)field->opts & O_NULLOK)
{
FIELD_CELL *bp = field->buf;
{
assert(argp);
return (
- Check_Field(typ->left, field, argp->left) ||
- Check_Field(typ->right, field, argp->right));
+ Check_Field(form, typ->left, field, argp->left) ||
+ Check_Field(form, typ->right, field, argp->right));
}
else
{
+#if NCURSES_INTEROP_FUNCS
+ if (typ->fieldcheck.ofcheck)
+ {
+ if (typ->status & _GENERIC)
+ return typ->fieldcheck.gfcheck(form, field, (void *)argp);
+ else
+ return typ->fieldcheck.ofcheck(field, (void *)argp);
+ }
+#else
if (typ->fcheck)
return typ->fcheck(field, (void *)argp);
+#endif
}
}
return TRUE;
Synchronize_Buffer(form);
if ((form->status & _FCHECK_REQUIRED) ||
- (!(field->opts & O_PASSOK)))
+ (!((unsigned)field->opts & O_PASSOK)))
{
- if (!Check_Field(field->type, field, (TypeArgument *)(field->arg)))
+ if (!Check_Field(form, field->type, field, (TypeArgument *)(field->arg)))
return FALSE;
- form->status &= ~_FCHECK_REQUIRED;
- field->status |= _CHANGED;
+ ClrStatus(form, _FCHECK_REQUIRED);
+ SetStatus(field, _CHANGED);
Synchronize_Linked_Fields(field);
}
return TRUE;
do
{
field = (field == last_on_page) ? first : field + 1;
- if (((*field)->opts & O_VISIBLE))
+ if (((unsigned)(*field)->opts & O_VISIBLE))
break;
}
while (proposed != (*field));
proposed = *field;
- if ((proposed == *last_on_page) && !(proposed->opts & O_VISIBLE))
+ if ((proposed == *last_on_page) &&
+ !((unsigned)proposed->opts & O_VISIBLE))
{
/* This means, there is also no visible field on the page.
So we propose the first one and hope the very best...
FIELD *last_field, *field_on_page;
werase(Get_Form_Window(form));
- form->curpage = page;
+ form->curpage = (short)page;
last_field = field_on_page = form->field[form->page[page].smin];
do
{
- if (field_on_page->opts & O_VISIBLE)
+ if ((unsigned)field_on_page->opts & O_VISIBLE)
if ((res = Display_Field(field_on_page)) != E_OK)
return (res);
field_on_page = field_on_page->snext;
int result = E_REQUEST_DENIED;
T((T_CALLED("Data_Entry(%p,%s)"), (void *)form, _tracechtype((chtype)c)));
- if ((field->opts & O_EDIT)
+ if (((unsigned)field->opts & O_EDIT)
#if FIX_FORM_INACTIVE_BUG
- && (field->opts & O_ACTIVE)
+ && ((unsigned)field->opts & O_ACTIVE)
#endif
)
{
- if ((field->opts & O_BLANK) &&
+ if (((unsigned)field->opts & O_BLANK) &&
First_Position_In_Current_Field(form) &&
!(form->status & _FCHECK_REQUIRED) &&
!(form->status & _WINDOW_MODIFIED))
bool End_Of_Field = (((field->drows - 1) == form->currow) &&
((field->dcols - 1) == form->curcol));
- form->status |= _WINDOW_MODIFIED;
- if (End_Of_Field && !Growable(field) && (field->opts & O_AUTOSKIP))
+ SetStatus(form, _WINDOW_MODIFIED);
+ if (End_Of_Field && !Growable(field) && ((unsigned)field->opts & O_AUTOSKIP))
result = Inter_Field_Navigation(FN_Next_Field, form);
else
{
if ((c >= MIN_FORM_COMMAND && c <= MAX_FORM_COMMAND) &&
((bindings[c - MIN_FORM_COMMAND].keycode & Key_Mask) == c))
- BI = &(bindings[c - MIN_FORM_COMMAND]);
+ {
+ TR(TRACE_CALLS, ("form_request %s", form_request_name(c)));
+ BI = &(bindings[c - MIN_FORM_COMMAND]);
+ }
if (BI)
{
NULL /* Choice Request is generic */
};
size_t nMethods = (sizeof(Generic_Methods) / sizeof(Generic_Methods[0]));
- size_t method = (BI->keycode >> ID_Shft) & 0xffff; /* see ID_Mask */
+ size_t method = (size_t) ((BI->keycode >> ID_Shft) & 0xffff); /* see ID_Mask */
if ((method >= nMethods) || !(BI->cmd))
res = E_SYSTEM_ERROR;
Generic_Method fct = Generic_Methods[method];
if (fct)
- res = fct(BI->cmd, form);
+ {
+ res = fct(BI->cmd, form);
+ }
else
- res = (BI->cmd) (form);
+ {
+ res = (BI->cmd) (form);
+ }
}
}
#ifdef NCURSES_MOUSE_VERSION
else if (KEY_MOUSE == c)
{
MEVENT event;
- WINDOW *win = form->win ? form->win : stdscr;
+ WINDOW *win = form->win ? form->win : StdScreen(Get_Form_Screen(form));
WINDOW *sub = form->sub ? form->sub : win;
getmouse(&event);
if (!iscntrl(UChar(c)))
#else
if (isprint(UChar(c)) &&
- Check_Char(form->current->type, c,
+ Check_Char(form, form->current, form->current->type, c,
(TypeArgument *)(form->current->arg)))
#endif
res = Data_Entry(form, c);
{
FIELD_CELL *p;
int res = E_OK;
- unsigned int i;
- unsigned int len;
+ int i;
+ int len;
#if USE_WIDEC_SUPPORT
FIELD_CELL *widevalue = 0;
/* for a growable field we must assume zero terminated strings, because
somehow we have to detect the length of what should be copied.
*/
- unsigned int vlen = strlen(value);
+ int vlen = (int)strlen(value);
if (vlen > len)
{
* field->cols))))
RETURN(E_SYSTEM_ERROR);
+#if !USE_WIDEC_SUPPORT
len = vlen;
+#endif
}
}
* and other special cases that we really do not want to handle here.
*/
#if NCURSES_EXT_FUNCS
- if (wresize(field->working, field->drows, field->dcols) == ERR)
+ if (wresize(field->working, 1, Buffer_Length(field) + 1) == ERR)
#endif
{
delwin(field->working);
- field->working = newpad(field->drows, field->dcols);
+ field->working = newpad(1, Buffer_Length(field) + 1);
}
len = Buffer_Length(field);
wclear(field->working);
- mvwaddstr(field->working, 0, 0, value);
+ (void)mvwaddstr(field->working, 0, 0, value);
if ((widevalue = typeCalloc(FIELD_CELL, len + 1)) == 0)
{
}
else
{
- for (i = 0; i < (unsigned)field->drows; ++i)
+ for (i = 0; i < field->drows; ++i)
{
- mvwin_wchnstr(field->working, i, 0,
- widevalue + (i * field->dcols),
- field->dcols);
+ (void)mvwin_wchnstr(field->working, 0, (int)i * field->dcols,
+ widevalue + ((int)i * field->dcols),
+ field->dcols);
}
for (i = 0; i < len; ++i)
{
{
#if USE_WIDEC_SUPPORT
FIELD_CELL *data = Address_Of_Nth_Buffer(field, buffer);
- unsigned need = 0;
+ size_t need = 0;
int size = Buffer_Length(field);
int n;
/* determine the number of bytes needed to store the expanded string */
for (n = 0; n < size; ++n)
{
- if (!isWidecExt(data[n]))
+ if (!isWidecExt(data[n]) && data[n].chars[0] != L'\0')
{
mbstate_t state;
size_t next;
init_mb(state);
next = _nc_wcrtomb(0, data[n].chars[0], &state);
- if (!isEILSEQ(next))
+ if (next > 0)
need += next;
}
}
free(field->expanded[buffer]);
field->expanded[buffer] = typeMalloc(char, need + 1);
- /* expand the multibyte data */
+ /*
+ * Expand the multibyte data.
+ *
+ * It may also be multi-column data. In that case, the data for a row
+ * may be null-padded to align to the dcols/drows layout (or it may
+ * contain embedded wide-character extensions). Change the null-padding
+ * to blanks as needed.
+ */
if ((result = field->expanded[buffer]) != 0)
{
wclear(field->working);
- mvwadd_wchnstr(field->working, 0, 0, data, size);
- mvwinnstr(field->working, 0, 0, result, (int)need);
+ wmove(field->working, 0, 0);
+ for (n = 0; n < size; ++n)
+ {
+ if (!isWidecExt(data[n]) && data[n].chars[0] != L'\0')
+ wadd_wch(field->working, &data[n]);
+ }
+ wmove(field->working, 0, 0);
+ winnstr(field->working, result, (int)need);
}
#else
result = Address_Of_Nth_Buffer(field, buffer);
{
result[need] = wch;
}
- passed += status;
+ passed += (size_t) status;
++need;
}
else
break;
result = typeCalloc(wchar_t, need);
- *lengthp = need;
+ *lengthp = (int)need;
if (result == 0)
break;
}