📄 frm_driver.c
字号:
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; } returnCode(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; T((T_CALLED("_nc_Set_Current_Field(%p,%p)"), form, newfield)); if (!form || !newfield || !form->current || (newfield->form != form)) returnCode(E_BAD_ARGUMENT); if ((form->status & _IN_DRIVER)) returnCode(E_BAD_STATE); if (!(form->field)) returnCode(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) returnCode(E_SYSTEM_ERROR); form->current = field; if (form->w) delwin(form->w); form->w = new_window; form->status &= ~_WINDOW_MODIFIED; Set_Field_Window_Attributes(field, form->w); if (Has_Invisible_Parts(field)) { werase(form->w); Buffer_To_Window(field, form->w); } else { if (Justification_Allowed(field)) { werase(form->w); Undo_Justification(field, form->w); wsyncup(form->w); } } untouchwin(form->w); } form->currow = form->curcol = form->toprow = form->begincol = 0; returnCode(E_OK);}/*---------------------------------------------------------------------------- Intra-Field Navigation routines --------------------------------------------------------------------------*//*---------------------------------------------------------------------------| Facility : libnform| Function : static int IFN_Next_Character(FORM * form)|| Description : Move to the next character in the field. In a multi-line| field this wraps at the end of the line.|| Return Values : E_OK - success| E_REQUEST_DENIED - at the rightmost position+--------------------------------------------------------------------------*/static intIFN_Next_Character(FORM *form){ FIELD *field = form->current; int step = myWCWIDTH(form->w, form->currow, form->curcol); T((T_CALLED("IFN_Next_Character(%p)"), form)); if ((form->curcol += step) == field->dcols) { if ((++(form->currow)) == field->drows) {#if GROW_IF_NAVIGATE if (!Single_Line_Field(field) && Field_Grown(field, 1)) { form->curcol = 0; returnCode(E_OK); }#endif form->currow--;#if GROW_IF_NAVIGATE if (Single_Line_Field(field) && Field_Grown(field, 1)) returnCode(E_OK);#endif form->curcol -= step; returnCode(E_REQUEST_DENIED); } form->curcol = 0; } returnCode(E_OK);}/*---------------------------------------------------------------------------| Facility : libnform| Function : static int IFN_Previous_Character(FORM * form)|| Description : Move to the previous character in the field. In a| multi-line field this wraps and the beginning of the| line.|| Return Values : E_OK - success| E_REQUEST_DENIED - at the leftmost position+--------------------------------------------------------------------------*/static intIFN_Previous_Character(FORM *form){ int amount = myWCWIDTH(form->w, form->currow, form->curcol - 1); int oldcol = form->curcol; T((T_CALLED("IFN_Previous_Character(%p)"), form)); if ((form->curcol -= amount) < 0) { if ((--(form->currow)) < 0) { form->currow++; form->curcol = oldcol; returnCode(E_REQUEST_DENIED); } form->curcol = form->current->dcols - 1; } returnCode(E_OK);}/*---------------------------------------------------------------------------| Facility : libnform| Function : static int IFN_Next_Line(FORM * form)|| Description : Move to the beginning of the next line in the field|| Return Values : E_OK - success| E_REQUEST_DENIED - at the last line+--------------------------------------------------------------------------*/static intIFN_Next_Line(FORM *form){ FIELD *field = form->current; T((T_CALLED("IFN_Next_Line(%p)"), form)); if ((++(form->currow)) == field->drows) {#if GROW_IF_NAVIGATE if (!Single_Line_Field(field) && Field_Grown(field, 1)) returnCode(E_OK);#endif form->currow--; returnCode(E_REQUEST_DENIED); } form->curcol = 0; returnCode(E_OK);}/*---------------------------------------------------------------------------| Facility : libnform| Function : static int IFN_Previous_Line(FORM * form)|| Description : Move to the beginning of the previous line in the field|| Return Values : E_OK - success| E_REQUEST_DENIED - at the first line+--------------------------------------------------------------------------*/static intIFN_Previous_Line(FORM *form){ T((T_CALLED("IFN_Previous_Line(%p)"), form)); if ((--(form->currow)) < 0) { form->currow++; returnCode(E_REQUEST_DENIED); } form->curcol = 0; returnCode(E_OK);}/*---------------------------------------------------------------------------| Facility : libnform| Function : static int IFN_Next_Word(FORM * form)|| Description : Move to the beginning of the next word in the field.|| Return Values : E_OK - success| E_REQUEST_DENIED - there is no next word+--------------------------------------------------------------------------*/static intIFN_Next_Word(FORM *form){ FIELD *field = form->current; FIELD_CELL *bp = Address_Of_Current_Position_In_Buffer(form); FIELD_CELL *s; FIELD_CELL *t; T((T_CALLED("IFN_Next_Word(%p)"), form)); /* We really need access to the data, so we have to synchronize */ Synchronize_Buffer(form); /* Go to the first whitespace after the current position (including current position). This is then the starting point to look for the next non-blank data */ s = Get_First_Whitespace_Character(bp, Buffer_Length(field) - (int)(bp - field->buf)); /* Find the start of the next word */ t = Get_Start_Of_Data(s, Buffer_Length(field) - (int)(s - field->buf));#if !FRIENDLY_PREV_NEXT_WORD if (s == t) returnCode(E_REQUEST_DENIED); else#endif { Adjust_Cursor_Position(form, t); returnCode(E_OK); }}/*---------------------------------------------------------------------------| Facility : libnform| Function : static int IFN_Previous_Word(FORM * form)|| Description : Move to the beginning of the previous word in the field.|| Return Values : E_OK - success| E_REQUEST_DENIED - there is no previous word+--------------------------------------------------------------------------*/static intIFN_Previous_Word(FORM *form){ FIELD *field = form->current; FIELD_CELL *bp = Address_Of_Current_Position_In_Buffer(form); FIELD_CELL *s; FIELD_CELL *t; bool again = FALSE; T((T_CALLED("IFN_Previous_Word(%p)"), form)); /* We really need access to the data, so we have to synchronize */ Synchronize_Buffer(form); s = After_End_Of_Data(field->buf, (int)(bp - field->buf)); /* s points now right after the last non-blank in the buffer before bp. If bp was in a word, s equals bp. In this case we must find the last whitespace in the buffer before bp and repeat the game to really find the previous word! */ if (s == bp) again = TRUE; /* And next call now goes backward to look for the last whitespace before that, pointing right after this, so it points to the begin of the previous word. */ t = After_Last_Whitespace_Character(field->buf, (int)(s - field->buf));#if !FRIENDLY_PREV_NEXT_WORD if (s == t) returnCode(E_REQUEST_DENIED);#endif if (again) { /* and do it again, replacing bp by t */ s = After_End_Of_Data(field->buf, (int)(t - field->buf)); t = After_Last_Whitespace_Character(field->buf, (int)(s - field->buf));#if !FRIENDLY_PREV_NEXT_WORD if (s == t) returnCode(E_REQUEST_DENIED);#endif } Adjust_Cursor_Position(form, t); returnCode(E_OK);}/*---------------------------------------------------------------------------| Facility : libnform| Function : static int IFN_Beginning_Of_Field(FORM * form)|| Description : Place the cursor at the first non-pad character in| the field.|| Return Values : E_OK - success+--------------------------------------------------------------------------*/static intIFN_Beginning_Of_Field(FORM *form){ FIELD *field = form->current; T((T_CALLED("IFN_Beginning_Of_Field(%p)"), form)); Synchronize_Buffer(form); Adjust_Cursor_Position(form, Get_Start_Of_Data(field->buf, Buffer_Length(field))); returnCode(E_OK);}/*---------------------------------------------------------------------------| Facility : libnform| Function : static int IFN_End_Of_Field(FORM * form)|| Description : Place the cursor after the last non-pad character in| the field. If the field occupies the last position in| the buffer, the cursor is positioned on the last| character.|| Return Values : E_OK - success+--------------------------------------------------------------------------*/static intIFN_End_Of_Field(FORM *form){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -