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

📄 frm_driver.c

📁 ncurses-5.4 需要的就来下把 一定会有用的哦
💻 C
📖 第 1 页 / 共 5 页
字号:
      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;  return(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 int IFN_Next_Character(FORM * form){  FIELD *field = form->current;    if ((++(form->curcol))==field->dcols)    {      if ((++(form->currow))==field->drows)	{#if GROW_IF_NAVIGATE	  if (!Single_Line_Field(field) && Field_Grown(field,1)) {	    form->curcol = 0;	    return(E_OK);	  }#endif	  form->currow--;#if GROW_IF_NAVIGATE	  if (Single_Line_Field(field) && Field_Grown(field,1))	    return(E_OK);#endif	  form->curcol--;	  return(E_REQUEST_DENIED);	}      form->curcol = 0;    }  return(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 int IFN_Previous_Character(FORM * form){  if ((--(form->curcol))<0)    {      if ((--(form->currow))<0)	{	  form->currow++;	  form->curcol++;	  return(E_REQUEST_DENIED);	}      form->curcol = form->current->dcols - 1;    }  return(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 int IFN_Next_Line(FORM * form){  FIELD *field = form->current;  if ((++(form->currow))==field->drows)    {#if GROW_IF_NAVIGATE      if (!Single_Line_Field(field) && Field_Grown(field,1))	return(E_OK);#endif      form->currow--;      return(E_REQUEST_DENIED);    }  form->curcol = 0;  return(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 int IFN_Previous_Line(FORM * form){  if ( (--(form->currow)) < 0 )    {      form->currow++;      return(E_REQUEST_DENIED);    }  form->curcol = 0;  return(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 int IFN_Next_Word(FORM * form){  FIELD *field = form->current;  char  *bp    = Address_Of_Current_Position_In_Buffer(form);  char  *s;  char  *t;  /* 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)     return(E_REQUEST_DENIED);  else#endif    {      Adjust_Cursor_Position(form,t);      return(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 int IFN_Previous_Word(FORM * form){  FIELD *field = form->current;  char  *bp    = Address_Of_Current_Position_In_Buffer(form);  char  *s;  char  *t;  bool  again = FALSE;  /* 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)     return(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) 	return(E_REQUEST_DENIED);#endif    }  Adjust_Cursor_Position(form,t);  return(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 int IFN_Beginning_Of_Field(FORM * form){  FIELD *field = form->current;  Synchronize_Buffer(form);  Adjust_Cursor_Position(form,		 Get_Start_Of_Data(field->buf,Buffer_Length(field)));  return(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 int IFN_End_Of_Field(FORM * form){  FIELD *field = form->current;  char *pos;  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);  return(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 int IFN_Beginning_Of_Line(FORM * form){  FIELD *field = form->current;  Synchronize_Buffer(form);  Adjust_Cursor_Position(form,		 Get_Start_Of_Data(Address_Of_Current_Row_In_Buffer(form),				   field->dcols));  return(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 int IFN_End_Of_Line(FORM * form){  FIELD *field = form->current;  char *pos;  char *bp;  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);  return(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 int IFN_Left_Character(FORM * form){  if ( (--(form->curcol)) < 0 )    {      form->curcol++;      return(E_REQUEST_DENIED);    }  return(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 int IFN_Right_Character(FORM * form){  if ( (++(form->curcol)) == form->current->dcols )    {#if GROW_IF_NAVIGATE      FIELD *field = form->current;      if (Single_Line_Field(field) && Field_Grown(field,1))	return(E_OK);#endif      --(form->curcol);      return(E_REQUEST_DENIED);    }  return(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 int IFN_Up_Character(FORM * form){  if ( (--(form->currow)) < 0 )    {      form->currow++;      return(E_REQUEST_DENIED);    }  return(E_OK);}/*---------------------------------------------------------------------------|   Facility      :  libnform  |   Function      :  static int IFN_Down_Character(FORM * form)|   |   Description   :  Move one line down. This doesn't cycle through the

⌨️ 快捷键说明

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