src/iup_text.c
int iupEditCallActionCb(Ihandle* ih, IFnis cb, const char* insert_value, int start, int end, void *mask, int nc, int remove_dir, int utf8)
{
  char *new_value, *value;
  int ret = -1, /* normal processing */
      key = 0;

  if (!cb && !mask)
    return ret;

  value = IupGetAttribute(ih, "VALUE");  /* it will return a non NULL internal buffer */

  if (!insert_value)
  {
    new_value = value;
    iupStrRemove(new_value, start, end, remove_dir, utf8);
  }
  else
  {
    if (value[0]==0)
      new_value = iupStrDup(insert_value);
    else
      new_value = iupStrInsert(value, insert_value, start, end, utf8);
  }

  if (insert_value && insert_value[0]!=0 && insert_value[1]==0)
    key = insert_value[0];

  if (!new_value)
    return ret;

  if (nc && (int)strlen(new_value) > nc)
  {
    if (new_value != value) free(new_value);
    return 0; /* abort */
  }

  if (mask && iupMaskCheck((Imask*)mask, new_value)==0)
  {
    IFns cb = (IFns)IupGetCallback(ih, "MASKFAIL_CB");
    if (cb) cb(ih, new_value);
    if (new_value != value) free(new_value);
    return 0; /* abort */
  }

  if (cb)
  {
    int cb_ret = cb(ih, key, (char*)new_value);
    if (cb_ret==IUP_IGNORE)
      ret = 0; /* abort */
    else if (cb_ret==IUP_CLOSE)
    {
      IupExitLoop();
      ret = 0; /* abort */
    }
    else if (cb_ret!=0 && key!=0 && 
             cb_ret != IUP_DEFAULT && cb_ret != IUP_CONTINUE)  
      ret = cb_ret; /* replace key */
  }

  if (new_value != value) free(new_value);
  return ret;
}
/* Used by List and Text, implemented in Text
   Can NOT use ih->data 
*/
Used by List and Text, implemented in Text
Can NOT use ih->data
Used by List and Text implemented in Text Can NOT use ih - > data
int iupEditCallActionCb(Ihandle* ih, IFnis cb, const char* insert_value, int start, int end, void *mask, int nc, int remove_dir, int utf8)
{
  char *new_value, *value;
  int ret = -1, 
      key = 0;
  if (!cb && !mask)
    return ret;
  value = IupGetAttribute(ih, "VALUE");  
  if (!insert_value)
  {
    new_value = value;
    iupStrRemove(new_value, start, end, remove_dir, utf8);
  }
  else
  {
    if (value[0]==0)
      new_value = iupStrDup(insert_value);
    else
      new_value = iupStrInsert(value, insert_value, start, end, utf8);
  }
  if (insert_value && insert_value[0]!=0 && insert_value[1]==0)
    key = insert_value[0];
  if (!new_value)
    return ret;
  if (nc && (int)strlen(new_value) > nc)
  {
    if (new_value != value) free(new_value);
    return 0; 
  }
  if (mask && iupMaskCheck((Imask*)mask, new_value)==0)
  {
    IFns cb = (IFns)IupGetCallback(ih, "MASKFAIL_CB");
    if (cb) cb(ih, new_value);
    if (new_value != value) free(new_value);
    return 0; 
  }
  if (cb)
  {
    int cb_ret = cb(ih, key, (char*)new_value);
    if (cb_ret==IUP_IGNORE)
      ret = 0; 
    else if (cb_ret==IUP_CLOSE)
    {
      IupExitLoop();
      ret = 0; 
    }
    else if (cb_ret!=0 && key!=0 && 
             cb_ret != IUP_DEFAULT && cb_ret != IUP_CONTINUE)  
      ret = cb_ret; 
  }
  if (new_value != value) free(new_value);
  return ret;
}
int iupEditCallActionCb ( Ihandle * ih , IFnis cb , const char * insert_value , int start , int end , void * mask , int nc , int remove_dir , int utf8 ) { char * new_value , * value ; int ret = -1 , key = 0 ; if ( ! cb && ! mask ) return ret ; value = IupGetAttribute ( ih , " " ) ; if ( ! insert_value ) { new_value = value ; iupStrRemove ( new_value , start , end , remove_dir , utf8 ) ; } else { if ( value [ 0 ] == 0 ) new_value = iupStrDup ( insert_value ) ; else new_value = iupStrInsert ( value , insert_value , start , end , utf8 ) ; } if ( insert_value && insert_value [ 0 ] != 0 && insert_value [ 1 ] == 0 ) key = insert_value [ 0 ] ; if ( ! new_value ) return ret ; if ( nc && ( int ) strlen ( new_value ) > nc ) { if ( new_value != value ) free ( new_value ) ; return 0 ; } if ( mask && iupMaskCheck ( ( Imask * ) mask , new_value ) == 0 ) { IFns cb = ( IFns ) IupGetCallback ( ih , " " ) ; if ( cb ) cb ( ih , new_value ) ; if ( new_value != value ) free ( new_value ) ; return 0 ; } if ( cb ) { int cb_ret = cb ( ih , key , ( char * ) new_value ) ; if ( cb_ret == IUP_IGNORE ) ret = 0 ; else if ( cb_ret == IUP_CLOSE ) { IupExitLoop ( ) ; ret = 0 ; } else if ( cb_ret != 0 && key != 0 && cb_ret != IUP_DEFAULT && cb_ret != IUP_CONTINUE ) ret = cb_ret ; } if ( new_value != value ) free ( new_value ) ; return ret ; }
Used by List and Text, implemented in Text
Can NOT use ih->data
Used by List and Text implemented in Text Can NOT use ih - > data
/* normal processing */ /* it will return a non NULL internal buffer */ /* abort */ /* abort */ /* abort */ /* abort */ /* replace key */