?? frm_driver.c
字號(hào):
| FIELDTYPE * typ,| int ch,| TypeArgument *argp)| | Description : Perform a single character check for character ch| according to the fieldtype instance. || Return Values : TRUE - Character is valid| FALSE - Character is invalid+--------------------------------------------------------------------------*/static bool Check_Char(FIELDTYPE * typ, int ch, TypeArgument *argp){ if (typ) { if (typ->status & _LINKED_TYPE) { assert(argp); return( Check_Char(typ->left ,ch,argp->left ) || Check_Char(typ->right,ch,argp->right) ); } else { if (typ->ccheck) return typ->ccheck(ch,(void *)argp); } } return (isprint((unsigned char)ch) ? TRUE : FALSE);}/*---------------------------------------------------------------------------| Facility : libnform | Function : static int Display_Or_Erase_Field(| FIELD * field,| bool bEraseFlag)| | Description : Create a subwindow for the field and display the| buffer contents (apply justification if required)| or simply erase the field.|| Return Values : E_OK - on success| E_SYSTEM_ERROR - some error (typical no memory)+--------------------------------------------------------------------------*/static int Display_Or_Erase_Field(FIELD * field, bool bEraseFlag){ WINDOW *win; WINDOW *fwin; if (!field) return E_SYSTEM_ERROR; fwin = Get_Form_Window(field->form); win = derwin(fwin, field->rows,field->cols,field->frow,field->fcol); if (!win) return E_SYSTEM_ERROR; else { if (field->opts & O_VISIBLE) Set_Field_Window_Attributes(field,win); else wattrset(win,getattrs(fwin)); werase(win); } if (!bEraseFlag) { if (field->opts & O_PUBLIC) { if (Justification_Allowed(field)) Perform_Justification(field,win); else Buffer_To_Window(field,win); } field->status &= ~_NEWTOP; } wsyncup(win); delwin(win); return E_OK;}/* Macros to preset the bEraseFlag */#define Display_Field(field) Display_Or_Erase_Field(field,FALSE)#define Erase_Field(field) Display_Or_Erase_Field(field,TRUE)/*---------------------------------------------------------------------------| Facility : libnform | Function : static int Synchronize_Field(FIELD * field)| | Description : Synchronize the windows content with the value in| the buffer.|| Return Values : E_OK - success| E_BAD_ARGUMENT - invalid field pointer | E_SYSTEM_ERROR - some severe basic error+--------------------------------------------------------------------------*/static int Synchronize_Field(FIELD * field){ FORM *form; int res = E_OK; if (!field) return(E_BAD_ARGUMENT); if (((form=field->form) != (FORM *)0) && Field_Really_Appears(field)) { if (field == form->current) { form->currow = form->curcol = form->toprow = form->begincol = 0; werase(form->w); if ( (field->opts & O_PUBLIC) && Justification_Allowed(field) ) Undo_Justification( field, form->w ); else Buffer_To_Window( field, form->w ); field->status |= _NEWTOP; res = _nc_Refresh_Current_Field( form ); } else res = Display_Field( field ); } field->status |= _CHANGED; return(res);}/*---------------------------------------------------------------------------| Facility : libnform | Function : static int Synchronize_Linked_Fields(FIELD * field)| | Description : Propagate the Synchronize_Field function to all linked| fields. The first error that occurs in the sequence| of updates is the return value.|| Return Values : E_OK - success| E_BAD_ARGUMENT - invalid field pointer | E_SYSTEM_ERROR - some severe basic error+--------------------------------------------------------------------------*/static int Synchronize_Linked_Fields(FIELD * field){ FIELD *linked_field; int res = E_OK; int syncres; if (!field) return(E_BAD_ARGUMENT); if (!field->link) return(E_SYSTEM_ERROR); for(linked_field = field->link; linked_field!= field; linked_field = linked_field->link ) { if (((syncres=Synchronize_Field(linked_field)) != E_OK) && (res==E_OK)) res = syncres; } return(res);}/*---------------------------------------------------------------------------| Facility : libnform | Function : int _nc_Synchronize_Attributes(FIELD * field)| | Description : If a fields visual attributes have changed, this| routine is called to propagate those changes to the| screen. || Return Values : E_OK - success| E_BAD_ARGUMENT - invalid field pointer| E_SYSTEM_ERROR - some severe basic error+--------------------------------------------------------------------------*/NCURSES_EXPORT(int)_nc_Synchronize_Attributes (FIELD * field){ FORM *form; int res = E_OK; WINDOW *formwin; if (!field) return(E_BAD_ARGUMENT); if (((form=field->form) != (FORM *)0) && Field_Really_Appears(field)) { if (form->current==field) { Synchronize_Buffer(form); Set_Field_Window_Attributes(field,form->w); werase(form->w); if (field->opts & O_PUBLIC) { if (Justification_Allowed(field)) Undo_Justification(field,form->w); else Buffer_To_Window(field,form->w); } else { formwin = Get_Form_Window(form); copywin(form->w,formwin, 0,0, field->frow,field->fcol, field->rows-1,field->cols-1,0); wsyncup(formwin); Buffer_To_Window(field,form->w); field->status |= _NEWTOP; /* fake refresh to paint all */ _nc_Refresh_Current_Field(form); } } else { res = Display_Field(field); } } return(res);}/*---------------------------------------------------------------------------| Facility : libnform | Function : int _nc_Synchronize_Options(FIELD * field,| Field_Options newopts)| | Description : If a fields options have changed, this routine is| called to propagate these changes to the screen and| to really change the behavior of the field.|| Return Values : E_OK - success| E_BAD_ARGUMENT - invalid field pointer | E_SYSTEM_ERROR - some severe basic error+--------------------------------------------------------------------------*/NCURSES_EXPORT(int)_nc_Synchronize_Options(FIELD *field, Field_Options newopts){ Field_Options oldopts; Field_Options changed_opts; FORM *form; int res = E_OK; if (!field) return(E_BAD_ARGUMENT); oldopts = field->opts; changed_opts = oldopts ^ newopts; field->opts = newopts; form = field->form; if (form) { if (form->current == field) { field->opts = oldopts; return(E_CURRENT); } if (form->status & _POSTED) { if ((form->curpage == field->page)) { if (changed_opts & O_VISIBLE) { if (newopts & O_VISIBLE) res = Display_Field(field); else res = Erase_Field(field); } else { if ((changed_opts & O_PUBLIC) && (newopts & O_VISIBLE)) res = Display_Field(field); } } } } if (changed_opts & O_STATIC) { bool single_line_field = Single_Line_Field(field); int res2 = E_OK; if (newopts & O_STATIC) { /* the field becomes now static */ field->status &= ~_MAY_GROW; /* if actually we have no hidden columns, justification may occur again */ if (single_line_field && (field->cols == field->dcols) && (field->just != NO_JUSTIFICATION) && Field_Really_Appears(field)) { res2 = Display_Field(field); } } else { /* field is no longer static */ if ((field->maxgrow==0) || ( single_line_field && (field->dcols < field->maxgrow)) || (!single_line_field && (field->drows < field->maxgrow))) { field->status |= _MAY_GROW; /* a field with justification now changes its behavior, so we must redisplay it */ if (single_line_field && (field->just != NO_JUSTIFICATION) && Field_Really_Appears(field)) { res2 = Display_Field(field); } } } if (res2 != E_OK) res = res2; } return(res);}/*---------------------------------------------------------------------------| Facility : libnform | Function : int _nc_Set_Current_Field(FORM * form,| FIELD * newfield)| | Description : Make the newfield the new current field.|| Return Values : E_OK - success| E_BAD_ARGUMENT - invalid form or field pointer | E_SYSTEM_ERROR - some severe basic error+--------------------------------------------------------------------------*/NCURSES_EXPORT(int)_nc_Set_Current_Field(FORM *form, FIELD *newfield){ FIELD *field; WINDOW *new_window; if (!form || !newfield || !form->current || (newfield->form!=form)) return(E_BAD_ARGUMENT); if ( (form->status & _IN_DRIVER) ) return(E_BAD_STATE); if (!(form->field)) return(E_NOT_CONNECTED); field = form->current; if ((field!=newfield) || !(form->status & _POSTED)) { if ((form->w) && (field->opts & O_VISIBLE) && (field->form->curpage == field->page)) { _nc_Refresh_Current_Field(form); if (field->opts & O_PUBLIC) { if (field->drows > field->rows) { if (form->toprow==0) field->status &= ~_NEWTOP; else field->status |= _NEWTOP; } else { if (Justification_Allowed(field)) { Window_To_Buffer(form->w,field); werase(form->w); Perform_Justification(field,form->w); wsyncup(form->w); } } } delwin(form->w); form->w = (WINDOW *)0; } field = newfield; if (Has_Invisible_Parts(field)) new_window = newpad(field->drows,field->dcols); else new_window = derwin(Get_Form_Window(form), field->rows,field->cols,field->frow,field->fcol); if (!new_window) return(E_SYSTEM_ERROR);
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -