Ejemplo n.º 1
0
BOOLEAN
data_ahead(FORM *f)
{
	static char	buf[ MAX_BUF ];
	char		*bptr = buf;
	WINDOW		*w = W(f);
	FIELD		*c = C(f);
	int		ret = FALSE;
	int		pad = Pad(c);
	int		cols = c->cols;
	int		dcols;
	int		drows;
	int		flag = cols > MAX_BUF - 1;
	int		start;
	int		chunk;

	if (flag)
		bptr = malloc(cols + 1);

	if (OneRow(c)) {
		dcols = c->dcols;
		start = B(f) + cols;

		while (start < dcols) {
			chunk = MIN(cols, dcols - start);
			(void) wmove(w, 0, start);
			(void) winnstr(w, bptr, chunk);

			if (bptr != _data_ahead(bptr, pad, chunk)) {
				ret = (TRUE);
				break;
			}

			start += cols;
		}
	} else {	/* else multi-line field */
		drows = c->drows;
		start = T(f) + c->rows;

		while (start < drows) {
			(void) wmove(w, start++, 0);
			(void) winnstr(w, bptr, cols);

			if (bptr != _data_ahead(bptr, pad, cols)) {
				ret = TRUE;
				break;
			}
		}
	}

	if (flag)
		(void) free(bptr);

	(void) wmove(w, Y(f), X(f));
	return (ret);
}
Ejemplo n.º 2
0
/*
 * Log the most recently-written line to our logfile
 */
static void
log_last_line(WINDOW *win)
{
    FILE *fp;
    int y, x, n;
    char temp[256];

    if ((fp = fopen(MY_LOGFILE, "a")) != 0) {
	int need = sizeof(temp) - 1;
	if (need > COLS)
	    need = COLS;
	getyx(win, y, x);
	wmove(win, y - 1, 0);
	n = winnstr(win, temp, need);
	while (n-- > 0) {
	    if (isspace(UChar(temp[n])))
		temp[n] = '\0';
	    else
		break;
	}
	wmove(win, y, x);
	fprintf(fp, "%s\n", temp);
	fclose(fp);
    }
}
Ejemplo n.º 3
0
int
mvwinnstr(WINDOW *win, int y, int x, char *str, int n)
{
	if (wmove(win, y, x) == ERR)
		return ERR;

	return winnstr(win, str, n);
}
Ejemplo n.º 4
0
int mvwinnstr(WINDOW *win, int y, int x, char *str, int n)
{
    PDC_LOG(("mvwinnstr() - called: y %d x %d n %d \n", y, x, n));

    if (wmove(win, y, x) == ERR)
        return ERR;

    return winnstr(win, str, n);
}
Ejemplo n.º 5
0
int mvinstr(int y, int x, char *str)
{
    PDC_LOG(("mvinstr() - called: y %d x %d \n", y, x));

    if (move(y, x) == ERR)
        return ERR;

    return (ERR == winnstr(stdscr, str, stdscr->_maxx)) ? ERR : OK;
}
Ejemplo n.º 6
0
int mvinnstr(int y, int x, char *str, int n)
{
    PDC_LOG(("mvinnstr() - called: y %d x %d n %d \n", y, x, n));

    if (move(y, x) == ERR)
        return ERR;

    return winnstr(stdscr, str, n);
}
Ejemplo n.º 7
0
int mvwinstr(WINDOW *win, int y, int x, char *str)
{
    PDC_LOG(("mvwinstr() - called: y %d x %d \n", y, x));

    if (wmove(win, y, x) == ERR)
        return ERR;

    return (ERR == winnstr(win, str, win->_maxx)) ? ERR : OK;
}
Ejemplo n.º 8
0
/*
 * Perform an editing function for the field.
 */
static bool performEdit(CDKFSLIDER *widget, chtype input)
{
   bool result = FALSE;
   bool modify = TRUE;
   int base = widget->fieldWidth;
   int need = formattedSize(widget, widget->current);
   char *temp = (char *)malloc(need + 5);
   char *data = temp;
   char test;
   int col = need - widget->fieldEdit;
   double value;
#define SCANF_FMT "%lg%c"

   if (temp != 0)
   {
      int adj = (col < 0) ? (-col) : 0;
      if (adj)
      {
	 memset(temp, ' ', adj);
	 temp += adj;
      }
      wmove(widget->fieldWin, 0, base);
      winnstr(widget->fieldWin, temp, need);
      strcpy(temp + need, " ");
      if (isChar(input))	/* replace the char at the cursor */
      {
	 temp[col] = CharOf(input);
      }
      else if (input == KEY_BACKSPACE)	/* delete the char before the cursor */
      {
	 modify = removeChar(temp, col - 1);
      }
      else if (input == KEY_DC)	/* delete the char at the cursor */
      {
	 modify = removeChar(temp, col);
      }
      else
      {
	 modify = FALSE;
      }
      if (modify
       && sscanf(temp, SCANF_FMT, &value, &test) == 2
       && test == ' '
       && value >= widget->low
       && value <= widget->high)
      {
	 setCDKFSliderValue(widget, value);
	 result = TRUE;
      }
      free(data);
   }
   return result;
}
Ejemplo n.º 9
0
/* Get a string of characters from a curses window */
SCM
gucu_winnstr (SCM win, SCM n)
{
  SCM s_str;
  int c_n;
  int ret;

  /* -1 indicates that up to an entire line is requested */
  c_n = scm_to_int (n);
  if (c_n == -1)
    {
      int y, x;
      getmaxyx (_scm_to_window (win), y, x);
      c_n = x;
    }
#ifdef HAVE_NCURSESW
  {
    wchar_t *c_wstr;
    c_wstr = (wchar_t *) scm_malloc (sizeof (wchar_t) * (c_n + 1));
    ret = winnwstr (_scm_to_window (win), c_wstr, c_n);
    if (ret != ERR)
      {
	c_wstr[c_n] = 0;
	s_str = _scm_sstring_from_wstring (c_wstr);
      }
    else
      abort ();
  }
#else
  {
    char *c_str;
    c_str = (char *) scm_malloc (sizeof (char) * (c_n + 1));
    ret = winnstr (_scm_to_window (win), c_str, c_n + 1);
    if (ret != ERR)
      {
	c_str[c_n] = 0;
	s_str = scm_from_locale_string (c_str);
	free (c_str);
      }
    else
      abort ();
  }
#endif

  return s_str;
}
Ejemplo n.º 10
0
/*
 * Perform an editing function for the field.
 */
static bool performEdit(CDKUSCALE *widget, chtype input)
{
    bool result = FALSE;
    bool modify = TRUE;
    int base = 0;
    int need  = widget->fieldWidth;
    char *temp = (char *)malloc(need + 2);
    char test;
    int col = need - widget->fieldEdit - 1;
    unsigned value;
#define SCANF_FMT "%u%c"

    if (temp != 0)
    {
        wmove(widget->fieldWin, 0, base);
        winnstr(widget->fieldWin, temp, need);
        strcpy(temp + need, " ");
        if (isChar(input))	/* replace the char at the cursor */
        {
            temp[col] = CharOf(input);
        }
        else if (input == KEY_BACKSPACE)	/* delete the char before the cursor */
        {
            modify = removeChar(temp, col - 1);
        }
        else if (input == KEY_DC)	/* delete the char at the cursor */
        {
            modify = removeChar(temp, col);
        }
        else
        {
            modify = FALSE;
        }
        if (modify
                && sscanf(temp, SCANF_FMT, &value, &test) == 2
                && test == ' '
                && value >= widget->low
                && value <= widget->high)
        {
            setCDKUScaleValue(widget, value);
            result = TRUE;
        }
        free(temp);
    }
    return result;
}
Ejemplo n.º 11
0
int innstr(char *str, int n)
{
    PDC_LOG(("innstr() - called: n %d \n", n));

    return winnstr(stdscr, str, n);
}
Ejemplo n.º 12
0
NCURSES_EXPORT(int) (mvwinnstr) (WINDOW * a1, int a2, int a3, char * a4, int z)
{
	return (wmove(a1,a2,a3) == (-1) ? (-1) : winnstr(a1,a4,z)) ;
}
Ejemplo n.º 13
0
/*---------------------------------------------------------------------------
|   Facility      :  libnform  
|   Function      :  bool data_ahead(const FORM *form)
|   
|   Description   :  Check for off-screen data ahead. This is more difficult
|                    because a dynamic field has a variable end. 
|
|   Return Values :  TRUE   - there are off-screen data ahead
|                    FALSE  - there are no off-screen data ahead
+--------------------------------------------------------------------------*/
bool data_ahead(const FORM *form)
{
  bool result = FALSE;

  if (form && (form->status & _POSTED) && form->current)
    {
      static char buffer[SMALL_BUFFER_SIZE + 1];
      FIELD *field;
      bool large_buffer;
      bool cursor_moved = FALSE;
      char *bp;
      char *found_content;
      int pos;

      field = form->current;
      assert(form->w != 0);

      large_buffer = (field->cols > SMALL_BUFFER_SIZE);
      if (large_buffer)
	bp = (char *)malloc((size_t)(field->cols) + 1);
      else
	bp = buffer;

      assert(bp != 0);
      
      if (Single_Line_Field(field))
	{
	  int check_len;

	  pos = form->begincol + field->cols;
	  while (pos < field->dcols)
	    {
	      check_len = field->dcols - pos;
	      if ( check_len >= field->cols )
		check_len = field->cols;
	      cursor_moved = TRUE;
	      wmove(form->w,0,pos);
	      winnstr(form->w,bp,check_len);
	      found_content = 
		After_Last_Non_Pad_Position(bp,check_len,field->pad);
	      if (found_content==bp)
		  pos += field->cols;		  
	      else
		{
		  result = TRUE;
		  break;
		}
	    }
	}
      else
	{
	  pos = form->toprow + field->rows;
	  while (pos < field->drows)
	    {
	      cursor_moved = TRUE;
	      wmove(form->w,pos,0);
	      pos++;
	      winnstr(form->w,bp,field->cols);
	      found_content = 
		After_Last_Non_Pad_Position(bp,field->cols,field->pad);
	      if (found_content!=bp)
		{
		  result = TRUE;
		  break;
		}
	    }
	}

      if (large_buffer)
	free(bp);

      if (cursor_moved)
	wmove(form->w,form->currow,form->curcol);
    }
  return(result);
}
Ejemplo n.º 14
0
int
mvwinnstr(WINDOW *win, int y, int x, char *s, int n)
{
	return (wmove(win, y, x) == ERR ? ERR : winnstr(win, s, n));
}
Ejemplo n.º 15
0
int
innstr(char *str, int n)
{
	return winnstr(stdscr, str, n);
}
Ejemplo n.º 16
0
int
winstr(WINDOW *win, char *str)
{

	return winnstr(win, str, -1);
}
Ejemplo n.º 17
0
NCURSES_EXPORT(int) (winstr) (WINDOW * a1, char * z)
{
	T((T_CALLED("winstr(%p,%s)"), (const void *)a1, _nc_visbuf2(1,z))); returnCode(winnstr(a1, z, -1));
}
Ejemplo n.º 18
0
NCURSES_EXPORT(int) (mvwinstr) (WINDOW * a1, int a2, int a3, char * z)
{
	T((T_CALLED("mvwinstr(%p,%d,%d,%s)"), (const void *)a1, a2, a3, _nc_visbuf2(3,z))); returnCode((wmove(a1,a2,a3) == (-1) ? (-1) : winnstr(a1, z, -1)));
}
Ejemplo n.º 19
0
int instr(char *str)
{
    PDC_LOG(("instr() - called: string=\"%s\"\n", str));

    return (ERR == winnstr(stdscr, str, stdscr->_maxx)) ? ERR : OK;
}
Ejemplo n.º 20
0
NCURSES_EXPORT(int) (mvinnstr) (int a1, int a2, char * a3, int z)
{
	return (wmove(stdscr,a1,a2) == (-1) ? (-1) : winnstr(stdscr,a3,z)) ;
}
Ejemplo n.º 21
0
NCURSES_EXPORT(int) (instr) (char * z)
{
	T((T_CALLED("instr(%s)"), _nc_visbuf2(0,z))); returnCode(winnstr(stdscr, z, -1));
}
Ejemplo n.º 22
0
int winstr(WINDOW *win, char *str)
{
    PDC_LOG(("winstr() - called: \n"));

    return (ERR == winnstr(win, str, win->_maxx)) ? ERR : OK;
}
Ejemplo n.º 23
0
NCURSES_EXPORT(int) (mvinstr) (int a1, int a2, char * z)
{
	T((T_CALLED("mvinstr(%d,%d,%s)"), a1, a2, _nc_visbuf2(2,z))); returnCode((wmove(stdscr,a1,a2) == (-1) ? (-1) : winnstr(stdscr, z, -1)));
}
Ejemplo n.º 24
0
EIF_INTEGER c_ecurses_winnstr (EIF_POINTER w, EIF_POINTER str, EIF_INTEGER n)
{
    return winnstr( ((WINDOW *) w), (char *)str,(int) n) ;
};
Ejemplo n.º 25
0
NCURSES_EXPORT(int) (innstr) (char * a1, int z)
{
	return winnstr(stdscr,a1,z) ;
}