⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frm_driver.c

📁 ncurses 库 可能有用酒用 没用就算了 我觉得还可以用
💻 C
📖 第 1 页 / 共 5 页
字号:
  FIELD *field = form->current;  FIELD_CELL *pos;  T((T_CALLED("IFN_End_Of_Field(%p)"), form));  Synchronize_Buffer(form);  pos = After_End_Of_Data(field->buf, Buffer_Length(field));  if (pos == (field->buf + Buffer_Length(field)))    pos--;  Adjust_Cursor_Position(form, pos);  returnCode(E_OK);}/*---------------------------------------------------------------------------|   Facility      :  libnform|   Function      :  static int IFN_Beginning_Of_Line(FORM * form)||   Description   :  Place the cursor on the first non-pad character in|                    the current line of the field.||   Return Values :  E_OK         - success+--------------------------------------------------------------------------*/static intIFN_Beginning_Of_Line(FORM *form){  FIELD *field = form->current;  T((T_CALLED("IFN_Beginning_Of_Line(%p)"), form));  Synchronize_Buffer(form);  Adjust_Cursor_Position(form,			 Get_Start_Of_Data(Address_Of_Current_Row_In_Buffer(form),					   field->dcols));  returnCode(E_OK);}/*---------------------------------------------------------------------------|   Facility      :  libnform|   Function      :  static int IFN_End_Of_Line(FORM * form)||   Description   :  Place the cursor after the last non-pad character in the|                    current line of the field. If the field occupies the|                    last column in the line, the cursor is positioned on the|                    last character of the line.||   Return Values :  E_OK        - success+--------------------------------------------------------------------------*/static intIFN_End_Of_Line(FORM *form){  FIELD *field = form->current;  FIELD_CELL *pos;  FIELD_CELL *bp;  T((T_CALLED("IFN_End_Of_Line(%p)"), form));  Synchronize_Buffer(form);  bp = Address_Of_Current_Row_In_Buffer(form);  pos = After_End_Of_Data(bp, field->dcols);  if (pos == (bp + field->dcols))    pos--;  Adjust_Cursor_Position(form, pos);  returnCode(E_OK);}/*---------------------------------------------------------------------------|   Facility      :  libnform|   Function      :  static int IFN_Left_Character(FORM * form)||   Description   :  Move one character to the left in the current line.|                    This doesn't cycle.||   Return Values :  E_OK             - success|                    E_REQUEST_DENIED - already in first column+--------------------------------------------------------------------------*/static intIFN_Left_Character(FORM *form){  int amount = myWCWIDTH(form->w, form->currow, form->curcol - 1);  int oldcol = form->curcol;  T((T_CALLED("IFN_Left_Character(%p)"), form));  if ((form->curcol -= amount) < 0)    {      form->curcol = oldcol;      returnCode(E_REQUEST_DENIED);    }  returnCode(E_OK);}/*---------------------------------------------------------------------------|   Facility      :  libnform|   Function      :  static int IFN_Right_Character(FORM * form)||   Description   :  Move one character to the right in the current line.|                    This doesn't cycle.||   Return Values :  E_OK              - success|                    E_REQUEST_DENIED  - already in last column+--------------------------------------------------------------------------*/static intIFN_Right_Character(FORM *form){  int amount = myWCWIDTH(form->w, form->currow, form->curcol);  int oldcol = form->curcol;  T((T_CALLED("IFN_Right_Character(%p)"), form));  if ((form->curcol += amount) >= form->current->dcols)    {#if GROW_IF_NAVIGATE      FIELD *field = form->current;      if (Single_Line_Field(field) && Field_Grown(field, 1))	returnCode(E_OK);#endif      form->curcol = oldcol;      returnCode(E_REQUEST_DENIED);    }  returnCode(E_OK);}/*---------------------------------------------------------------------------|   Facility      :  libnform|   Function      :  static int IFN_Up_Character(FORM * form)||   Description   :  Move one line up. This doesn't cycle through the lines|                    of the field.||   Return Values :  E_OK              - success|                    E_REQUEST_DENIED  - already in last column+--------------------------------------------------------------------------*/static intIFN_Up_Character(FORM *form){  T((T_CALLED("IFN_Up_Character(%p)"), form));  if ((--(form->currow)) < 0)    {      form->currow++;      returnCode(E_REQUEST_DENIED);    }  returnCode(E_OK);}/*---------------------------------------------------------------------------|   Facility      :  libnform|   Function      :  static int IFN_Down_Character(FORM * form)||   Description   :  Move one line down. This doesn't cycle through the|                    lines of the field.||   Return Values :  E_OK              - success|                    E_REQUEST_DENIED  - already in last column+--------------------------------------------------------------------------*/static intIFN_Down_Character(FORM *form){  FIELD *field = form->current;  T((T_CALLED("IFN_Down_Character(%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);    }  returnCode(E_OK);}/*----------------------------------------------------------------------------  END of Intra-Field Navigation routines  --------------------------------------------------------------------------*//*----------------------------------------------------------------------------  Vertical scrolling helper routines  --------------------------------------------------------------------------*//*---------------------------------------------------------------------------|   Facility      :  libnform|   Function      :  static int VSC_Generic(FORM *form, int nlines)||   Description   :  Scroll multi-line field forward (nlines>0) or|                    backward (nlines<0) this many lines.||   Return Values :  E_OK              - success|                    E_REQUEST_DENIED  - can't scroll+--------------------------------------------------------------------------*/static intVSC_Generic(FORM *form, int nlines){  FIELD *field = form->current;  int res = E_REQUEST_DENIED;  int rows_to_go = (nlines > 0 ? nlines : -nlines);  if (nlines > 0)    {      if ((rows_to_go + form->toprow) > (field->drows - field->rows))	rows_to_go = (field->drows - field->rows - form->toprow);      if (rows_to_go > 0)	{	  form->currow += rows_to_go;	  form->toprow += rows_to_go;	  res = E_OK;	}    }  else    {      if (rows_to_go > form->toprow)	rows_to_go = form->toprow;      if (rows_to_go > 0)	{	  form->currow -= rows_to_go;	  form->toprow -= rows_to_go;	  res = E_OK;	}    }  return (res);}/*----------------------------------------------------------------------------  End of Vertical scrolling helper routines  --------------------------------------------------------------------------*//*----------------------------------------------------------------------------  Vertical scrolling routines  --------------------------------------------------------------------------*//*---------------------------------------------------------------------------|   Facility      :  libnform|   Function      :  static int Vertical_Scrolling(|                                           int (* const fct) (FORM *),|                                           FORM * form)||   Description   :  Performs the generic vertical scrolling routines.|                    This has to check for a multi-line field and to set|                    the _NEWTOP flag if scrolling really occurred.||   Return Values :  Propagated error code from low-level driver calls+--------------------------------------------------------------------------*/static intVertical_Scrolling(int (*const fct) (FORM *), FORM *form){  int res = E_REQUEST_DENIED;  if (!Single_Line_Field(form->current))    {      res = fct(form);      if (res == E_OK)	form->current->status |= _NEWTOP;    }  return (res);}/*---------------------------------------------------------------------------|   Facility      :  libnform|   Function      :  static int VSC_Scroll_Line_Forward(FORM * form)||   Description   :  Scroll multi-line field forward a line||   Return Values :  E_OK                - success|                    E_REQUEST_DENIED    - no data ahead+--------------------------------------------------------------------------*/static intVSC_Scroll_Line_Forward(FORM *form){  T((T_CALLED("VSC_Scroll_Line_Forward(%p)"), form));  returnCode(VSC_Generic(form, 1));}/*---------------------------------------------------------------------------|   Facility      :  libnform|   Function      :  static int VSC_Scroll_Line_Backward(FORM * form)||   Description   :  Scroll multi-line field backward a line||   Return Values :  E_OK                - success|                    E_REQUEST_DENIED    - no data behind+--------------------------------------------------------------------------*/static intVSC_Scroll_Line_Backward(FORM *form){  T((T_CALLED("VSC_Scroll_Line_Backward(%p)"), form));  returnCode(VSC_Generic(form, -1));}/*---------------------------------------------------------------------------|   Facility      :  libnform|   Function      :  static int VSC_Scroll_Page_Forward(FORM * form)||   Description   :  Scroll a multi-line field forward a page||   Return Values :  E_OK              - success|                    E_REQUEST_DENIED  - no data ahead+--------------------------------------------------------------------------*/static intVSC_Scroll_Page_Forward(FORM *form){  T((T_CALLED("VSC_Scroll_Page_Forward(%p)"), form));  returnCode(VSC_Generic(form, form->current->rows));}/*---------------------------------------------------------------------------|   Facility      :  libnform|   Function      :  static int VSC_Scroll_Half_Page_Forward(FORM * form)||   Description   :  Scroll a multi-line field forward half a page||   Return Values :  E_OK              - success|                    E_REQUEST_DENIED  - no data ahead+--------------------------------------------------------------------------*/static intVSC_Scroll_Half_Page_Forward(FORM *form){  T((T_CALLED("VSC_Scroll_Half_Page_Forward(%p)"), form));  returnCode(VSC_Generic(form, (form->current->rows + 1) / 2));}/*---------------------------------------------------------------------------|   Facility      :  libnform|   Function      :  static int VSC_Scroll_Page_Backward(FORM * form)||   Description   :  Scroll a multi-line field backward a page||   Return Values :  E_OK              - success|                    E_REQUEST_DENIED  - no data behind+--------------------------------------------------------------------------*/static intVSC_Scroll_Page_Backward(FORM *form){  T((T_CALLED("VSC_Scroll_Page_Backward(%p)"), form));  returnCode(VSC_Generic(form, -(form->current->rows)));}/*---------------------------------------------------------------------------|   Facility      :  libnform|   Function      :  static int VSC_Scroll_Half_Page_Backward(FORM * form)||   Description   :  Scroll a multi-line field backward half a page||   Return Values :  E_OK              - success|                    E_REQUEST_DENIED  - no data behind+--------------------------------------------------------------------------*/static intVSC_Scroll_Half_Page_Backward(FORM *form){  T((T_CALLED("VSC_Scroll_Half_Page_Backward(%p)"), form));  returnCode(VSC_Generic(form, -((form->current->rows + 1) / 2)));}/*----------------------------------------------------------------------------  End of Vertical scrolling routines  --------------------------------------------------------------------------*//*----------------------------------------------------------------------------  Horizontal scrolling helper routines  --------------------------------------------------------------------------*//*---------------------------------------------------------------------------|   Facility      :  libnform|   Function      :  static int HSC_Generic(FORM *form, int ncolumns)||   Description   :  Scroll single-line field forward (ncolumns>0) or|                    backward (ncolumns<0) this many columns.||   Return Values :  E_OK              - success|                    E_REQUEST_DENIED  - can't scroll+--------------------------------------------------------------------------*/static intHSC_Generic(FORM *form, int ncolumns){  FIELD *field = form->current;  int res = E_REQUEST_DENIED;  int cols_to_go = (ncolumns > 0 ? ncolumns : -ncolumns);  if (ncolumns > 0)    {      if ((cols_to_go + form->begincol) > (field->dcols - field->cols))	cols_to_go = field->dcols - field->cols - form->begincol;      if (cols_to_go > 0)	{	  form->curcol += cols_to_go;	  form->begincol += cols_to_go;	  res = E_OK;	}    }  else    {      if (cols_to_go > form->begincol)	cols_to_go = form->begincol;      if (cols_to_go > 0)	{	  form->curcol -= cols_to_go;	  form->begincol -= cols_to_go;	  res = E_OK;	}    }  return (res);}/*----------------------------------------------------------------------------  End of Horizontal scrolling helper routines  --------------------------------------------------------------------------*//*----------------------------------------------------------------------------  Horizontal scrolling routines  --------------------------------------------------------------------------*//*---------------------------------------------------------------------------|   Facility      :  libnform|   Function      :  static int Horizontal_Scrolling(|                                          int (* const fct) (FORM *),|                                          FORM * form)||   Description   :  Performs the generic horizontal scrolling routines.|                    This has to check for a single-line field.||   Return Values :  Propagated error code from low

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -