X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=form%2Ffld_current.c;h=264007ef59f391524576c3c2612c6de88492f7b9;hp=7c3a90af511d97a1c0fddacbf6236ad493183ca2;hb=d6c65d287166c3105ece4a5e3f3ec7af5a5f26a3;hpb=55ccd2b959766810cf7db8d1c4462f338ce0afc8 diff --git a/form/fld_current.c b/form/fld_current.c index 7c3a90af..264007ef 100644 --- a/form/fld_current.c +++ b/form/fld_current.c @@ -1,5 +1,6 @@ /**************************************************************************** - * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. * + * Copyright 2020 Thomas E. Dickey * + * Copyright 1998-2010,2016 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 * @@ -32,7 +33,7 @@ #include "form.priv.h" -MODULE_ID("$Id: fld_current.c,v 1.11 2004/12/25 22:40:13 tom Exp $") +MODULE_ID("$Id: fld_current.c,v 1.16 2020/05/24 01:40:20 anonymous.maarten Exp $") /*--------------------------------------------------------------------------- | Facility : libnform @@ -47,12 +48,12 @@ MODULE_ID("$Id: fld_current.c,v 1.11 2004/12/25 22:40:13 tom Exp $") | E_INVALID_FIELD - current field can't be left | E_SYSTEM_ERROR - system error +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) +FORM_EXPORT(int) set_current_field(FORM *form, FIELD *field) { int err = E_OK; - T((T_CALLED("set_current_field(%p,%p)"), form, field)); + T((T_CALLED("set_current_field(%p,%p)"), (void *)form, (void *)field)); if (form == 0 || field == 0) { RETURN(E_BAD_ARGUMENT); @@ -76,7 +77,7 @@ set_current_field(FORM *form, FIELD *field) { if (form->current != field) { - if (!_nc_Internal_Validation(form)) + if (form->current && !_nc_Internal_Validation(form)) { err = E_INVALID_FIELD; } @@ -102,6 +103,32 @@ set_current_field(FORM *form, FIELD *field) RETURN(err); } +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : int unfocus_current_field(FORM * form) +| +| Description : Removes focus from the current field. +| +| Return Values : E_OK - success +| E_BAD_ARGUMENT - invalid form pointer +| E_REQUEST_DENIED - there is no current field to unfocus ++--------------------------------------------------------------------------*/ +FORM_EXPORT(int) +unfocus_current_field(FORM *const form) +{ + T((T_CALLED("unfocus_current_field(%p)"), (const void *)form)); + if (form == 0) + { + RETURN(E_BAD_ARGUMENT); + } + else if (form->current == 0) + { + RETURN(E_REQUEST_DENIED); + } + _nc_Unset_Current_Field(form); + RETURN(E_OK); +} + /*--------------------------------------------------------------------------- | Facility : libnform | Function : FIELD *current_field(const FORM * form) @@ -110,10 +137,10 @@ set_current_field(FORM *form, FIELD *field) | | Return Values : Pointer to the current field. +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(FIELD *) +FORM_EXPORT(FIELD *) current_field(const FORM *form) { - T((T_CALLED("current_field(%p)"), form)); + T((T_CALLED("current_field(%p)"), (const void *)form)); returnField(Normalize_Form(form)->current); } @@ -127,10 +154,10 @@ current_field(const FORM *form) | Return Values : >= 0 : field index | -1 : fieldpointer invalid or field not connected +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) +FORM_EXPORT(int) field_index(const FIELD *field) { - T((T_CALLED("field_index(%p)"), field)); + T((T_CALLED("field_index(%p)"), (const void *)field)); returnCode((field != 0 && field->form != 0) ? (int)field->index : -1); }