Exemple #1
0
/* If the NO_HELP flag isn't set, blank the last two lines of the bottom
 * portion of the window. */
void blank_bottombars(void)
{
	if (!ISSET(NO_HELP)) {
		blank_line(bottomwin, 1, 0, COLS);
		blank_line(bottomwin, 2, 0, COLS);
	}
}
Exemple #2
0
static char *get_leaks(char *lines[], char **errs)
{
	char *leaks = tal_strdup(lines, "");
	unsigned int i;

	for (i = 0; i < tal_count(lines) - 1; i++) {
		if (strstr(lines[i], " lost ")) {
			/* A leak... */
			if (strstr(lines[i], " definitely lost ")) {
				/* Definite leak, report. */
				while (lines[i] && !blank_line(lines[i])) {
					tal_append_fmt(&leaks, "%s\n",
						       lines[i]);
					i++;
				}
			} else
				/* Not definite, ignore. */
				while (lines[i] && !blank_line(lines[i]))
					i++;
		} else {
			/* A real error. */
			while (lines[i] && !blank_line(lines[i])) {
				if (!*errs)
					*errs = tal_fmt(NULL, "%s\n", lines[i]);
				else
					tal_append_fmt(errs, "%s\n", lines[i]);
				i++;
			}
		}
	}
	return leaks;
}
Exemple #3
0
static int init_smg (void)
{
   unsigned int i, len;
   SLsmg_Char_Type *old, *neew;

   Smg_Inited = 0;

#ifdef REQUIRES_NON_BCE_SUPPORT
   Bce_Color_Offset = _pSLtt_get_bce_color_offset ();
#endif
   
   Screen_Rows = *tt_Screen_Rows;
   if (Screen_Rows > SLTT_MAX_SCREEN_ROWS)
     Screen_Rows = SLTT_MAX_SCREEN_ROWS;

   Screen_Cols = *tt_Screen_Cols;

   This_Col = This_Row = Start_Col = Start_Row = 0;

   This_Alt_Char = 0;
   SLsmg_set_color (0);
   Cls_Flag = 1;
   
   init_acs (ACS_MODE_AUTO);

   len = Screen_Cols + 3;
   for (i = 0; i < Screen_Rows; i++)
     {
	if ((NULL == (old = (SLsmg_Char_Type *) SLmalloc (sizeof(SLsmg_Char_Type) * len)))
	    || ((NULL == (neew = (SLsmg_Char_Type *) SLmalloc (sizeof(SLsmg_Char_Type) * len)))))
	  {
	     SLfree ((char *) old);
	     return -1;
	  }
	blank_line (old, len, ' ');
	blank_line (neew, len, ' ');
	SL_Screen[i].old = old;
	SL_Screen[i].neew = neew;
	SL_Screen[i].flags = 0;
#ifndef IBMPC_SYSTEM
	Blank_Hash = compute_hash (old, Screen_Cols);
	SL_Screen[i].new_hash = SL_Screen[i].old_hash =  Blank_Hash;
#endif
     }
   
   _pSLtt_color_changed_hook = SLsmg_touch_screen;
   Screen_Trashed = 1;
   Smg_Inited = 1;
   return 0;
}
Exemple #4
0
/* Refresh the screen without changing the position of lines.  Use this
 * if we've moved and changed text. */
void edit_refresh(void)
{
	filestruct *foo;
	int nlines;

	/* Figure out what maxrows should really be */
	compute_maxrows();

	if (openfile->current->lineno < openfile->edittop->lineno || openfile->current->lineno >= openfile->edittop->lineno + maxrows) {

		DEBUG_LOG("edit_refresh(): line = " << openfile->current->lineno << ", edittop " << openfile->edittop->lineno << " + maxrows " << maxrows);

		/* Make sure the current line is on the screen. */
		edit_update(ISSET(SMOOTH_SCROLL) ? NONE : CENTER);
	}

	foo = openfile->edittop;

	DEBUG_LOG("edit_refresh(): edittop->lineno = " << openfile->edittop->lineno);

	for (nlines = 0; nlines < editwinrows && foo != NULL; nlines++) {
		nlines += update_line(foo, (foo == openfile->current) ? openfile->current_x : 0);
		foo = foo->next;
	}

	for (; nlines < editwinrows; nlines++) {
		blank_line(edit, nlines, 0, COLS);
	}

	reset_cursor();
	wnoutrefresh(edit);
}
static bool ignored_line(GtIO *obo_file, GtError *err)
{
  gt_error_check(err);
  if (gt_io_peek(obo_file) == OBO_BLANK_CHAR)
    return blank_line(obo_file, err);
  return comment_line(obo_file, err);
}
Exemple #6
0
/* Blank all the lines of the middle portion of the window, i.e. the
 * edit window. */
void blank_edit(void)
{
	int i;

	for (i = 0; i < editwinrows; i++) {
		blank_line(edit, i, 0, COLS);
	}
}
Exemple #7
0
int SLcurses_wclear (SLcurses_Window_Type *w)
{
   unsigned int i;

   if (w != NULL) w->modified = 1;
   for (i=0; i < w->nrows; i++)
     blank_line (w->lines[i], w->ncols, w->color);
   return 0;
}
Exemple #8
0
SLcurses_Window_Type *SLcurses_newwin (unsigned int nrows, unsigned int ncols,
				       unsigned int r, unsigned int c)
{
   SLcurses_Window_Type *win;
   SLcurses_Cell_Type **lines;

   if (r >= (unsigned int) SLtt_Screen_Rows)
     return NULL;
   if (c >= (unsigned int) SLtt_Screen_Cols)
     return NULL;

   if (NULL == (win = (SLcurses_Window_Type *) SLmalloc (sizeof (SLcurses_Window_Type))))
     return NULL;

   SLMEMSET ((char *) win, 0, sizeof (SLcurses_Window_Type));

   if (nrows == 0)
     nrows = (unsigned int) SLtt_Screen_Rows - r;
   if (ncols == 0)
     ncols = (unsigned int) SLtt_Screen_Cols - c;

   lines = (SLcurses_Cell_Type **) SLmalloc (nrows * sizeof (SLcurses_Cell_Type *));
   if (lines == NULL)
     {
	SLcurses_delwin (win);
	return NULL;
     }

   SLMEMSET ((char *) lines, 0, nrows * sizeof (SLcurses_Cell_Type *));

   win->lines = lines;
   win->scroll_max = win->nrows = nrows;
   win->ncols = ncols;
   win->_begy = r;
   win->_begx = c;
   win->_maxx = (c + ncols) - 1;
   win->_maxy = (r + nrows) - 1;
   win->modified = 1;
   win->delay_off = -1;

   for (r = 0; r < nrows; r++)
     {
	SLcurses_Cell_Type *b;

	b = (SLcurses_Cell_Type *) SLmalloc (ncols * sizeof (SLcurses_Cell_Type));
	if (b == NULL)
	  {
	     SLcurses_delwin (win);
	     return NULL;
	  }
	lines [r] = b;
	blank_line (b, ncols, 0);
     }

   return win;
}
Exemple #9
0
  //
  // analyze_line
  //
  // Note that this function does not do any error checking regarding
  // the handling of string objects or the dictionary. Note also that it
  // allows for a null name. A line in the form: "=VALUE" assigns the
  // string "VALUE" to the name "". This might be useful for some
  // programs. This behavior is currently undocumented.
  //
  static void analyze_line(const string &the_line, bool personalized)
  {
    const char *p = the_line.c_str();
    bool            happy = false;  // =true if this line has the right syntax.
    dictionary_entry temp;

    temp.personalized = personalized;

    if (blank_line(the_line)) return;
    while (*p && is_white(*p)) p++;

    // Copy the first word into the temporary dictionary entry.
    while (*p && *p != '=' && !is_white(*p)) {
      temp.name.append(1, *p++);
    }

    while (*p && is_white(*p)) p++;

    if (*p++ == '=') {

      // Ok, the syntax is good enough.
      happy = true;

      while (*p && is_white(*p)) p++;

      // Copy to the end of the line into the temporary dictionary
      // entry. Note that this behavior includes embeded white spaces in
      // the value, and it also includes trailing white spaces.
      // 
      while (*p) temp.value.append(1, *p++);
      trim_string(temp.value);
    }

    // If the syntax looks good, then lets add this information to the
    // dictionary. Otherwise we'll just ignore this line.
    // 
    if (happy) {
      list<dictionary_entry>::iterator stepper = the_dictionary.begin();

      while (stepper != the_dictionary.end()) {
        if (stepper->name == temp.name) {
          *stepper = temp;
          break;
        }
        stepper++;
      }

      if (stepper == the_dictionary.end()) {
        the_dictionary.push_back(temp);
      }
    }
  }
Exemple #10
0
//index is the same for gnuplot
//using [init:fin] in fit function of gnuplot
//*ndata is # of data for fitting
//*ninit is the row # of the first data for fitting in the indexed subset data.
//*nfin is the row # of the last data.
void num_of_line(char *file, int index, double init, double fin, int *ndata, int *ninit, int *nfin)
{
	FILE *pFile;
	char c;
	int m = 0;
	int t=1;
	int i;
	double read;

	pFile=fopen (file,"r");
	while(t!=index){
		if(blank_line(pFile)) {t++;}
		else move_to_next_line(pFile);
	}
	do{
		if(blank_line(pFile)==0) {
			m++;
			fscanf(pFile, "%lf", &read);
			if(m==1){
				if(read>=init) {
					*ninit=1;
				}
				else *ninit=2;
			}
			
			if(m!=1) 
				if(read<init) *ninit=m+1;
			
			if(read<=fin) *nfin=m;
			move_to_next_line(pFile);
			
		}
		else {
			*ndata=*nfin-*ninit+1;
			return;
		}
	}while (1);
	fclose(pFile);
}
Exemple #11
0
int read_row(void *buf)
{
    void *p;

    if (last_read)
	return (0);
    if (first_read) {
	blank_line(buf);
	first_read = 0;
    }
    else {
	if (row_count >= n_rows) {
	    last_read = 1;
	    blank_line(buf);
	}
	else {
	    /* The buf variable is a void pointer and thus */
	    /* points to anything. Therefore, it's size is */
	    /* unknown and thus, it cannot be used for pointer */
	    /* arithmetic (some compilers treat this as an error */
	    /* - SGI MIPSPro compiler for one). Make the */
	    /* assumption that data_size is the proper number of */
	    /* bytes and cast the buf variable to char * before */
	    /* incrementing */
	    p = ((char *)buf) + data_size;
	    Rast_get_row(input_fd, p, row_count++, data_type);
	    p = buf;
	    Rast_set_null_value(p, 1, data_type);

	    /* Again we need to cast p to char * under the */
	    /* assumption that the increment is the proper */
	    /* number of bytes. */
	    p = ((char *)p) + (row_length + 1) * data_size;
	    Rast_set_null_value(p, 1, data_type);
	}
    }
    return (row_length + 2);
}
Exemple #12
0
void SLsmg_erase_eol (void)
{
   int r, c;

   if (Smg_Inited == 0) return;

   c = This_Col - Start_Col;
   r = This_Row - Start_Row;

   if ((r < 0) || (r >= (int)Screen_Rows)) return;
   if (c < 0) c = 0; else if (c >= (int)Screen_Cols) return;
   blank_line (SL_Screen[This_Row].neew + c , Screen_Cols - c, 0x20);
   SL_Screen[This_Row].flags |= TOUCHED;
}
Exemple #13
0
static void clear_region (int row, int n, SLwchar_Type ch)
{
   int i;
   int imax = row + n;

   if (imax > (int) Screen_Rows) imax = (int) Screen_Rows;
   if (row < 0)
     row = 0;

   for (i = row; i < imax; i++)
     {						  
	blank_line (SL_Screen[i].neew, Screen_Cols, ch);
	SL_Screen[i].flags |= TOUCHED;
     }
}
Exemple #14
0
static void scroll_up (void)
{
   unsigned int i, imax;
   SLsmg_Char_Type *neew;

   neew = SL_Screen[0].neew;
   imax = Screen_Rows - 1;
   for (i = 0; i < imax; i++)
     {
	SL_Screen[i].neew = SL_Screen[i + 1].neew;
	SL_Screen[i].flags |= TOUCHED;
     }
   SL_Screen[i].neew = neew;
   SL_Screen[i].flags |= TOUCHED;
   blank_line (neew, Screen_Cols, 0x20);
   This_Row--;
}
Exemple #15
0
int main(void) {
  int i,pos,s,nums;
  
  if (scanf("%d", &T) != 1) {
    exit(0);
  }
  for (t=0; t < T; t++) {
    scanf("%d", &N);
    for (n=0; n < N; n++) {
      for (i=0; i < 52; i++) {
        scanf("%d", &pos);
        shuffles[n][pos - 1] = i;
      }
    }
    gets(line);

    for(i=0; i < 52; i++) {
      cards_odd[i] = i;
    }
    nums = 0;
    while (1) {
      if (gets(line) == NULL) break;
      if (blank_line()) break;
      if (sscanf(line, "%d", &s) != 1) break;
      nums++;
      if (nums % 2 == 1) {
        src = cards_odd;
        dst = cards_even;
      } else {
        src = cards_even;
        dst = cards_odd;
      }
      for (i=0; i < 52; i++) {
        dst[shuffles[s - 1][i]] = src[i];
      }
    }
    if (t) printf("\n");
    for(i=0; i < 52; i++) {
      print_card(dst[i]);
    }
  }
}
Exemple #16
0
int main(void) {
  int i;
  int c, p, ptime;
  char r;

  gets(line);
  if (sscanf(line, "%d", &T) != 1) {
    exit(0);
  }
  gets(line);
  for (t=0; t < T; t++) {
    reset();
    while (1) {
      if (gets(line) == NULL) break;
      if (blank_line()) break;
      sscanf(line,"%d %d %d %c", &c, &p, &ptime, &r);
      attempted[c] = 1;
      if ((r == 'C')&&(solved[c][p]<=0)) {
        time[c] += ptime + (solved[c][p] * -20);
        solved[c][p] = 1;
        numsolved[c]++;
      }
      if ((r == 'I')&&(solved[c][p]<=0)) {
        solved[c][p]--;
      }
    }

    qsort(sortorder + 1, 100, sizeof(int), compare_contestant);

    if (t) printf("\n");
    for (i=1; i <= 100; i++) {
      c = sortorder[i];
      if (attempted[c]) {
        printf("%d %d %d\n", c, numsolved[c], time[c]);
      }
    }
  }
}
Exemple #17
0
static int parse_obo_file(GtOBOParseTree *obo_parse_tree,
                          GtIO *obo_file, GtError *err)
{
  int had_err = 0;
  gt_error_check(err);
  gt_assert(obo_parse_tree && obo_file);
  while (!had_err && ignored_char(obo_file)) {
    had_err = ignored_line(obo_file, err);
  }
  if (!had_err)
    had_err = header(obo_parse_tree, obo_file, err);
  while (!had_err && gt_io_has_char(obo_file)) {
    switch (gt_io_peek(obo_file)) {
      case OBO_BLANK_CHAR:
        had_err = blank_line(obo_file, err);
        break;
      case OBO_COMMENT_CHAR:
        had_err = comment_line(obo_file, err);
        break;
      case GT_CARRIAGE_RETURN:
        gt_io_next(obo_file);
        if (gt_io_peek(obo_file) == GT_END_OF_LINE)
          gt_io_next(obo_file);
        break;
      case GT_END_OF_LINE:
        gt_io_next(obo_file);
        break;
      default:
        had_err = stanza(obo_parse_tree, obo_file, err);
    }
  }
  if (!had_err)
    had_err = gt_io_expect(obo_file, GT_END_OF_FILE, err);
  if (!had_err)
    had_err = gt_obo_parse_tree_validate_stanzas(obo_parse_tree, err);
  return had_err;
}
Exemple #18
0
/* Set width to the number of files that we can display per line, if
 * necessary, and display the list of files. */
void browser_refresh(void)
{
    size_t i;
    int line = 0, col = 0;
	/* The current line and column while the list is getting displayed. */
    char *foo;
	/* The additional information that we'll display about a file. */

    /* Perhaps window dimensions have changed; reinitialize the browser. */
    browser_init(path_save, opendir(path_save));
    qsort(filelist, filelist_len, sizeof(char *), diralphasort);

    /* Make sure the selected file is within range. */
    if (selected >= filelist_len)
	selected = filelist_len - 1;

    titlebar(path_save);
    blank_edit();

    wmove(edit, 0, 0);

    i = width * editwinrows * ((selected / width) / editwinrows);

    for (; i < filelist_len && line < editwinrows; i++) {
	struct stat st;
	const char *filetail = tail(filelist[i]);
		/* The filename we display, minus the path. */
	size_t filetaillen = strlenpt(filetail);
		/* The length of the filename in columns. */
	size_t foolen;
		/* The length of the file information in columns. */
	int foomaxlen = 7;
		/* The maximum length of the file information in
		 * columns: seven for "--", "(dir)", or the file size,
		 * and 12 for "(parent dir)". */
	bool dots = (COLS >= 15 && filetaillen >= longest - foomaxlen);
		/* Do we put an ellipsis before the filename?  Don't set
		 * this to TRUE if we have fewer than 15 columns (i.e.
		 * one column for padding, plus seven columns for a
		 * filename other than ".."). */
	char *disp = display_string(filetail, dots ? filetaillen -
		longest + foomaxlen + 4 : 0, longest, FALSE);
		/* If we put an ellipsis before the filename, reserve
		 * one column for padding, plus seven columns for "--",
		 * "(dir)", or the file size, plus three columns for the
		 * ellipsis. */

	/* Start highlighting the currently selected file or directory. */
	if (i == selected)
	    wattron(edit, hilite_attribute);

	blank_line(edit, line, col, longest);

	/* If dots is TRUE, we will display something like "...ename". */
	if (dots)
	    mvwaddstr(edit, line, col, "...");
	mvwaddstr(edit, line, dots ? col + 3 : col, disp);

	free(disp);

	col += longest;

	/* Show information about the file.  We don't want to report
	 * file sizes for links, so we use lstat(). */
	if (lstat(filelist[i], &st) == -1 || S_ISLNK(st.st_mode)) {
	    /* If the file doesn't exist (i.e. it's been deleted while
	     * the file browser is open), or it's a symlink that doesn't
	     * point to a directory, display "--". */
	    if (stat(filelist[i], &st) == -1 || !S_ISDIR(st.st_mode))
		foo = mallocstrcpy(NULL, "--");
	    /* If the file is a symlink that points to a directory,
	     * display it as a directory. */
	    else
		/* TRANSLATORS: Try to keep this at most 7 characters. */
		foo = mallocstrcpy(NULL, _("(dir)"));
	} else if (S_ISDIR(st.st_mode)) {
	    /* If the file is a directory, display it as such. */
	    if (strcmp(filetail, "..") == 0) {
		/* TRANSLATORS: Try to keep this at most 12 characters. */
		foo = mallocstrcpy(NULL, _("(parent dir)"));
		foomaxlen = 12;
	    } else
		foo = mallocstrcpy(NULL, _("(dir)"));
	} else {
	    unsigned long result = st.st_size;
	    char modifier;

	    foo = charalloc(foomaxlen + 1);

	    if (st.st_size < (1 << 10))
		modifier = ' ';  /* bytes */
	    else if (st.st_size < (1 << 20)) {
		result >>= 10;
		modifier = 'K';  /* kilobytes */
	    } else if (st.st_size < (1 << 30)) {
		result >>= 20;
		modifier = 'M';  /* megabytes */
	    } else {
Exemple #19
0
static void
scan_input (int ac, char **av)
{
  extern int optind;
  Boolean last_was_note = FALSE;
  outer = list_create (LIST_DOUBLE);
  new_outer (outer, OUTER_TEXT);

  while (optind < ac || do_stdin)
    {
      Uchar *fname = av[optind++];
      Uchar *lp;
      Boolean in_matrix = FALSE, in_block = FALSE;

      if (do_stdin)
	{
	  file_open("", "r");
	  do_stdin = FALSE;
	}
      else
	{
	  extern const char *file;
	  extern FILE *f_log;
	  f_log = stderr;
	  file_open (fname, "r");
	  file = fname;
	}
      if (fragments)
	{
	  in_matrix = TRUE;
	  new_outer (outer, OUTER_MATRIX);
	  ++matrices_found;
	}
      while (NULL != (lp = getline (curr_file->fp)))
	{
	  ++curr_file->line;
	  strip_trailing_white (lp);
	  if (matches_matrix(lp)) 
	    {
	      if (in_matrix)
		warning (matrix_location(), 
			 "new matrix began before end of old one");
	      list_add (curr_stuff, xstrdup (lp));
	      new_outer (outer, OUTER_MATRIX);
	      in_matrix = TRUE;
	      ++matrices_found;
	    }
	  else if (matches_end_matrix (lp))
	    {
	      if (list_len (multi_column_entries))
		fix_multis ();
	      new_outer (outer, OUTER_TEXT);
	      list_add (curr_stuff, xstrdup (lp));
	      in_matrix = in_block = FALSE;
	    }
	  else if (in_matrix)
	    {
	      if (blank_line (lp))
		{
		  if (last_was_note)
		    {
		      list_add (curr_notes, xstrdup (""));
		      last_was_note = FALSE;
		    }
		  continue;
		}
	      else if (isdigit (*lp))
		{
		  /* lp = strip_b (lp); */
		  last_was_note = FALSE;
		  if (list_len (multi_column_entries))
		    fix_multis ();
		  multi_column_entries = list_create (LIST_DOUBLE);
		  in_block = 1;
		  new_block (curr_matrix);
		  new_composite (curr_block, lp);
		  curr_block->reconstructed = curr_block->composite;
		}
	      else if (in_block) 
		{
		  if (isspace (*lp) || '#' == *lp)
		    {
		      list_add (curr_notes, xstrdup (lp));
		      last_was_note = TRUE;
		    }
		  else if (RECONSTRUCTED_LINE(lp))
		    {
		      /* lp = strip_b (lp); */
		      if (last_was_note)
			{
			  list_add (curr_notes, xstrdup (""));
			  last_was_note = FALSE;
			}
		      new_composite (curr_block, lp);
		      last_was_note = FALSE;
		    }
		  else
		    {
		      /* lp = strip_b (lp); */
		      if (last_was_note)
			{
			  list_add (curr_notes, xstrdup (""));
			  last_was_note = FALSE;
			}
		      new_source (curr_block, lp);
		      last_was_note = FALSE;
		    }
		}
	      else
		{
		  warning (matrix_location(), 
			   "junk in matrix, outside of block");
		}
	    }
	  else
	    {
	      list_add (curr_stuff, xstrdup (lp));
	    }
	}
      /* in case we didn't have a </matrix> tag */
      if (list_len (multi_column_entries))
	fix_multis ();
      file_close ();
    }
}
Exemple #20
0
/* Set width to the number of files that we can display per line, if
 * necessary, and display the list of files. */
void browser_refresh(void)
{
	size_t i;
	int col = 0;
	/* The maximum number of columns that the filenames will take up. */
	int line = 0;
	/* The maximum number of lines that the filenames will take up. */
	std::string foo;
	/* The file information that we'll display. */

	blank_edit();

	wmove(edit, 0, 0);

	i = width * editwinrows * ((selected / width) / editwinrows);

	for (; i < filelist.size() && line < editwinrows; i++) {
		struct stat st;
		std::string filetail = tail(filelist[i]);
		/* The filename we display, minus the path. */
		int foomaxlen = 7;
		/* The maximum length of the file information in
		 * columns: seven for "--", "(dir)", or the file size,
		 * and 12 for "(parent dir)". */
		bool dots = (COLS >= 15 && filetail.length() >= longest - foomaxlen);
		/* Do we put an ellipsis before the filename?  Don't set
		 * this to true if we have fewer than 15 columns (i.e.
		 * one column for padding, plus seven columns for a
		 * filename other than ".."). */
		std::string disp = display_string(filetail, dots ? filetail.length() - longest + foomaxlen + 4 : 0, longest, false);
		/* If we put an ellipsis before the filename, reserve one column
		 * for padding, plus seven columns for "--", "(dir)", or the file
		 * size, plus three columns for the ellipsis. */

		/* Start highlighting the currently selected file or
		 * directory. */
		if (i == selected) {
			wattron(edit, highlight_attribute);
		}

		blank_line(edit, line, col, longest);

		/* If dots is true, we will display something like "...ename". */
		if (dots) {
			mvwaddstr(edit, line, col, "...");
		}
		mvwaddstr(edit, line, dots ? col + 3 : col, disp.c_str());

		col += longest;

		/* Show information about the file.  We don't want to report
		 * file sizes for links, so we use lstat(). */
		if (lstat(filelist[i], &st) == -1 || S_ISLNK(st.st_mode)) {
			/* If the file doesn't exist (i.e. it's been deleted while
			 * the file browser is open), or it's a symlink that doesn't
			 * point to a directory, display "--". */
			if (stat(filelist[i], &st) == -1 || !S_ISDIR(st.st_mode)) {
				foo = "--";
			} else {
			/* If the file is a symlink that points to a directory,
			 * display it as a directory. */
			/* TRANSLATORS: Try to keep this at most 7
			 * characters. */
				foo = _("(dir)");
			}
		} else if (S_ISDIR(st.st_mode)) {
			/* If the file is a directory, display it as such. */
			if (filetail == "..") {
				/* TRANSLATORS: Try to keep this at most 12 characters. */
				foo = _("(parent dir)");
				foomaxlen = 12;
			} else {
				foo = _("(dir)");
			}
		} else {
			unsigned long result = st.st_size;
			char modifier;

			foo = charalloc(foomaxlen + 1);

			if (st.st_size < (1 << 10)) {
				modifier = ' '; // bytes
			} else if (st.st_size < (1 << 20)) {
				result >>= 10;
				modifier = 'K'; // kilobytes
			} else if (st.st_size < (1 << 30)) {
				result >>= 20;
				modifier = 'M'; // megabytes
			} else {
Exemple #21
0
/* Just update one line in the edit buffer.  This is basically a wrapper
 * for edit_draw().  The line will be displayed starting with
 * fileptr->data[index].  Likely arguments are current_x or zero.
 * Returns: Number of additiona lines consumed (needed for SOFTWRAP)
 */
int update_line(filestruct *fileptr, size_t index)
{
	int line = 0;
	int extralinesused = 0;
	/* The line in the edit window that we want to update. */
	char *converted;
	/* fileptr->data converted to have tabs and control characters
	 * expanded. */
	size_t page_start;
	filestruct *tmp;

	assert(fileptr != NULL);

	if (ISSET(SOFTWRAP)) {
		for (tmp = openfile->edittop; tmp && tmp != fileptr; tmp = tmp->next) {
			line += 1 + (strlenpt(tmp->data) / COLS);
		}
	} else {
		line = fileptr->lineno - openfile->edittop->lineno;
	}

	if (line < 0 || line >= editwinrows) {
		return 1;
	}

	/* First, blank out the line. */
	blank_line(edit, line, 0, COLS);

	/* Next, convert variables that index the line to their equivalent
	 * positions in the expanded line. */
	if (ISSET(SOFTWRAP)) {
		index = 0;
	} else {
		index = strnlenpt(fileptr->data, index);
	}
	page_start = get_page_start(index);

	/* Expand the line, replacing tabs with spaces, and control
	 * characters with their displayed forms. */
	converted = display_string(fileptr->data, page_start, COLS, !ISSET(SOFTWRAP));

#ifdef DEBUG
	if (ISSET(SOFTWRAP) && strlen(converted) >= COLS - 2) {
		fprintf(stderr, "update_line(): converted(1) line = %s\n", converted);
	}
#endif


	/* Paint the line. */
	edit_draw(fileptr, converted, line, page_start);
	free(converted);

	if (!ISSET(SOFTWRAP)) {
		if (page_start > 0) {
			mvwaddch(edit, line, 0, '$');
		}
		if (strlenpt(fileptr->data) > page_start + COLS) {
			mvwaddch(edit, line, COLS - 1, '$');
		}
	} else {
		int full_length = strlenpt(fileptr->data);
		for (index += COLS; index <= full_length && line < editwinrows; index += COLS) {
			line++;
			DEBUG_LOG("update_line(): Softwrap code, moving to " << line << " index " << index);
			blank_line(edit, line, 0, COLS);

			/* Expand the line, replacing tabs with spaces, and control
			 * characters with their displayed forms. */
			converted = display_string(fileptr->data, index, COLS, !ISSET(SOFTWRAP));
			if (ISSET(SOFTWRAP) && strlen(converted) >= COLS - 2) {
				DEBUG_LOG("update_line(): converted(2) line == " << converted);
			}

			/* Paint the line. */
			edit_draw(fileptr, converted, line, index);
			free(converted);
			extralinesused++;
		}
	}
	return extralinesused;
}
Exemple #22
0
void SLsmg_refresh (void)
{
   unsigned int i;
#ifndef IBMPC_SYSTEM
   int trashed = 0;
#endif
   int r, c;

   if (Smg_Inited == 0) return;
   
   if (Screen_Trashed)
     {
	Cls_Flag = 1;
	for (i = 0; i < Screen_Rows; i++)
	  SL_Screen[i].flags |= TRASHED;
#ifdef REQUIRES_NON_BCE_SUPPORT
	adjust_colors ();
#endif
     }

#ifndef IBMPC_SYSTEM
   for (i = 0; i < Screen_Rows; i++)
     {
	if (SL_Screen[i].flags == 0) continue;
	SL_Screen[i].new_hash = compute_hash (SL_Screen[i].neew, Screen_Cols);
	trashed = 1;
     }
#endif

   if (Cls_Flag)
     {
	(*tt_normal_video) ();  (*tt_cls) ();
     }
#ifndef IBMPC_SYSTEM
   else if (trashed && (*tt_Term_Cannot_Scroll == 0)) try_scroll ();
#endif

   for (i = 0; i < Screen_Rows; i++)
     {
	if (SL_Screen[i].flags == 0) continue;

	if (Cls_Flag || SL_Screen[i].flags & TRASHED)
	  {
	     SLsmg_Color_Type color = This_Color;

	     if (Cls_Flag == 0) 
	       {
		  (*tt_goto_rc) (i, 0);
		  (*tt_del_eol) ();
	       }
	     This_Color = 0;
	     blank_line (SL_Screen[i].old, Screen_Cols, 0x20);
	     This_Color = color;
	  }

	(*tt_smart_puts) (SL_Screen[i].neew, SL_Screen[i].old, Screen_Cols, i);

	memcpy ((char *) SL_Screen[i].old, (char *) SL_Screen[i].neew,
		Screen_Cols * sizeof (SLsmg_Char_Type));

	SL_Screen[i].flags = 0;
#ifndef IBMPC_SYSTEM
	SL_Screen[i].old_hash = SL_Screen[i].new_hash;
#endif
     }


   r = This_Row - Start_Row;
   c = This_Col - Start_Col;
   if (r < 0) 
     {
	r = 0; 
	c = 0;
     }
   else if (r >= (int)Screen_Rows)
     {
	r = (int)Screen_Rows;
	c = (int)Screen_Cols-1;
     }
   if (c < 0) 
     c = 0;
   else if (c >= (int)Screen_Cols)
     c = (int)Screen_Cols-1;

   (*tt_goto_rc) (r,c);
   (void) (*tt_flush_output) ();
   Cls_Flag = 0;
   Screen_Trashed = 0;
}
Exemple #23
0
static int try_scroll_up (int rmin, int rmax)
{
   int i, r1, r2, di, j;
   unsigned long hash;
   int did_scroll;
   SLsmg_Color_Type color;
   SLsmg_Char_Type *tmp;
   int ignore;

   did_scroll = 0;
   for (i = rmin; i < rmax; i++)
     {
	hash = SL_Screen[i].new_hash;
	if (hash == Blank_Hash) continue;
	if (hash == SL_Screen[i].old_hash)
	  continue;
	/* find a match further down screen */
	for (j = i + 1; j <= rmax; j++)
	  {
	     if (hash == SL_Screen[j].old_hash) break;
	  }
	if (j > rmax) continue;

	r1 = i;			       /* beg scroll region */
	di = j - i;		       /* number of lines to scroll */
	j++;			       /* since we know this is a match */

	/* find end of scroll region */
	ignore = 0;
	while ((j <= rmax) && (SL_Screen[j].old_hash == SL_Screen[j - di].new_hash))
	  {
	     if (SL_Screen[j].old_hash == Blank_Hash) ignore++;
	     j++;
	  }
	r2 = j - 1;		       /* end of scroll region */

	/* If this scroll only scrolls this line into place, don't do it.
	 */
	if ((di > 1) && (r1 + di + ignore == r2)) continue;

	/* If there is anything in the scrolling region that is ok, abort the
	 * scroll.
	 */

	for (j = r1; j <= r2; j++)
	  {
	     if ((SL_Screen[j].old_hash != Blank_Hash)
		 && (SL_Screen[j].old_hash == SL_Screen[j].new_hash))
	       {
		  if ((j - di < r1) || (SL_Screen[j].old_hash != SL_Screen[j - di].new_hash))
		    break;
	       }

	  }
	if (j <= r2) continue;

	did_scroll = 1;

	/* See the above comments about BCE */
	color = This_Color;  This_Color = 0;
	(*tt_normal_video) ();
	(*tt_set_scroll_region) (r1, r2);
	(*tt_goto_rc) (0, 0);	       /* relative to scroll region */
	(*tt_delete_nlines) (di);
	(*tt_reset_scroll_region) ();
	/* Now we have a hole in the screen.  Make the virtual screen look
	 * like it.
	 */
	for (j = r1; j <= r2; j++) SL_Screen[j].flags = TOUCHED;

	while (di--)
	  {
	     tmp = SL_Screen[r1].old;
	     for (j = r1; j < r2; j++)
	       {
		  SL_Screen[j].old = SL_Screen[j + 1].old;
		  SL_Screen[j].old_hash = SL_Screen[j + 1].old_hash;
	       }
	     SL_Screen[r2].old = tmp;
	     blank_line (SL_Screen[r2].old, Screen_Cols, ' ');
	     SL_Screen[r2].old_hash = Blank_Hash;
	     r2--;
	  }
	This_Color = color;
     }
   return did_scroll;
}
Exemple #24
0
static int try_scroll_down (int rmin, int rmax)
{
   int i, r1, r2, di, j;
   unsigned long hash;
   int did_scroll;
   SLsmg_Color_Type color;
   SLsmg_Char_Type *tmp;
   int ignore;

   did_scroll = 0;
   for (i = rmax; i > rmin; i--)
     {
	hash = SL_Screen[i].new_hash;
	if (hash == Blank_Hash) continue;

	if ((hash == SL_Screen[i].old_hash)
#if 0
	    || ((i + 1 < Screen_Rows) && (hash == SL_Screen[i + 1].old_hash))
	    || ((i - 1 > rmin) && (SL_Screen[i].old_hash == SL_Screen[i - 1].new_hash))
#endif
	    )
	  continue;

	for (j = i - 1; j >= rmin; j--)
	  {
	     if (hash == SL_Screen[j].old_hash) break;
	  }
	if (j < rmin) continue;

	r2 = i;			       /* end scroll region */

	di = i - j;
	j--;
	ignore = 0;
	while ((j >= rmin) && (SL_Screen[j].old_hash == SL_Screen[j + di].new_hash))
	  {
	     if (SL_Screen[j].old_hash == Blank_Hash) ignore++;
	     j--;
	  }
	r1 = j + 1;

	/* If this scroll only scrolls this line into place, don't do it.
	 */
	if ((di > 1) && (r1 + di + ignore == r2)) continue;

	/* If there is anything in the scrolling region that is ok, abort the
	 * scroll.
	 */

	for (j = r1; j <= r2; j++)
	  {
	     if ((SL_Screen[j].old_hash != Blank_Hash)
		 && (SL_Screen[j].old_hash == SL_Screen[j].new_hash))
	       {
		  /* See if the scroll is happens to scroll this one into place. */
		  if ((j + di > r2) || (SL_Screen[j].old_hash != SL_Screen[j + di].new_hash))
		    break;
	       }
	  }
	if (j <= r2) continue;

	color = This_Color;  This_Color = 0;
	did_scroll = 1;
	(*tt_normal_video) ();
	(*tt_set_scroll_region) (r1, r2);
	(*tt_goto_rc) (0, 0);
	(*tt_reverse_index) (di);
	(*tt_reset_scroll_region) ();
	/* Now we have a hole in the screen.
	 * Make the virtual screen look like it.
	 * 
	 * Note that if the terminal does not support BCE, then we have
	 * no idea what color the hole is.  So, for this case, we do not
	 * want to add Bce_Color_Offset to This_Color since if Bce_Color_Offset
	 * is non-zero, then This_Color = 0 does not match any valid color
	 * obtained by adding Bce_Color_Offset.
	 */
	for (j = r1; j <= r2; j++) SL_Screen[j].flags = TOUCHED;

	while (di--)
	  {
	     tmp = SL_Screen[r2].old;
	     for (j = r2; j > r1; j--)
	       {
		  SL_Screen[j].old = SL_Screen[j - 1].old;
		  SL_Screen[j].old_hash = SL_Screen[j - 1].old_hash;
	       }
	     SL_Screen[r1].old = tmp;
	     blank_line (SL_Screen[r1].old, Screen_Cols, 0x20);
	     SL_Screen[r1].old_hash = Blank_Hash;
	     r1++;
	  }
	This_Color = color;
     }

   return did_scroll;
}
Exemple #25
0
/* If the MORE_SPACE flag isn't set, blank the second line of the top
 * portion of the window. */
void blank_topbar(void)
{
	if (!ISSET(MORE_SPACE)) {
		blank_line(topwin, 1, 0, COLS);
	}
}
void SearchAndFill(struct FrcFieldItem *item)
{
  int i,j;  /* counters */
  int got_it = 0;
  int ctr = 0;
  long file_pos;
  char line[MAX_LINE_LENGTH] = "empty";
  char *charptr,*status;

  /***********************ALLOCATE MEMORY FOR STRUCTURE ********************/

  /* Read and discard lines until keyword is found */

  rewind(FrcF);
  while (got_it == 0) {
    status = fgets( line, MAX_LINE_LENGTH, FrcF );
    if (status == NULL) {
      fprintf(stderr," Unable to find keyword '%s'\n",item->keyword);
      fprintf(stderr," Check consistency of forcefield name and class \n");
      fprintf(stderr," Exiting....\n");
      exit(1);
    }
    if (line[0] == '#') {
      if (string_match(strtok(line," '\t'("),item->keyword)) got_it = 1;
    }
    /*     if (strncmp(line, item->keyword,strlen(item->keyword))==0) got_it = 1; */
  }

  file_pos = ftell(FrcF);

  /* Count the number of lines until next item is found */

  while( strncmp(fgets(line,MAX_LINE_LENGTH,FrcF), "#", 1) != 0 )
    ctr++;

  /* Allocate the memory using calloc */

  item->data = (struct FrcFieldData *)calloc(ctr, sizeof(struct FrcFieldData));

  if (item->data == NULL) {
    fprintf(stderr,"Could not allocate memory to %s\n", item->keyword);
    exit(2);
  }

  /********************FILL PARAMETERS AND EQUIVALENCES ********************/

  /* Read lines until keyword is found */

  fseek(FrcF,file_pos,SEEK_SET);
  strcpy(line,"empty");

  /* Read lines until data starts (when !--- is found) */

  ctr = 0;
  while ( strncmp(line,"!---", 4) != 0 ) {
    fgets(line, MAX_LINE_LENGTH, FrcF);
  }

  /* Get first line of data that isn't commented out */

  fgets(line, MAX_LINE_LENGTH, FrcF);
  while (strncmp(line,"!",1) == 0) {
    fgets( line, MAX_LINE_LENGTH, FrcF);
  }

  /* Read data into structure */

  while( strncmp( line, "#", 1 ) != 0 ) {

    float version;
    int reference,replace;
    char atom_types[5][5];
    double parameters[8];

    /* version number and reference number */

    version = atof(strtok(line, " "));
    reference = atoi(strtok(NULL, " "));

    /* equivalences */

    for(i = 0; i < item->number_of_members; i++ ) {
      charptr = strtok(NULL, " ");
      if (strlen(charptr) > 4) {
        fprintf(stderr,"Warning: type name overflow for '%s'. "
                "Truncating to 4 characters.\n",charptr);
      }
      sscanf(charptr,"%4s",atom_types[i]);
    }

    /* parameters -- Because of symmetrical terms, bonang, angtor, and
       endbontor have to be treated carefully */

    for( i = 0; i < item->number_of_parameters; i++ ) {
      charptr = strtok(NULL, " ");
      if(charptr == NULL) {
        for ( j = i; j < item->number_of_parameters; j++ )
          parameters[j] = parameters[j-i];
        break;
      } else {
        parameters[i] = atof(charptr);
      }
    }
    /* Search for matching sets of atom types.
       If found and the version number is greater, substitute
       the current set of parameters in place of the found set.
       Otherwise, add the current set of parameters to the
       list.
    */
    replace = ctr;
    for (j=0; j < ctr; j++) {

      int k=0;
      int match = 1;
      while (match && (k < item->number_of_members)) {
        if (strncmp(item->data[j].ff_types[k],atom_types[k],5) == 0)
          k++;
        else
          match = 0;
      }
      if (match == 1) {
        replace = j;
        break;
      }
    }
    if (replace != ctr) {
      if (version > item->data[replace].ver) {

        if (pflag > 1) {
          fprintf(stderr," Using higher version of parameters for");
          fprintf(stderr," %s  ",item->keyword);
          for (i=0; i < item->number_of_members; i++)
            fprintf(stderr,"%s ",atom_types[i]);
          fprintf(stderr," version %3.2f\n",version);
        }

        item->data[replace].ver = version;
        item->data[replace].ref = reference;
        for (i=0; i < item->number_of_members; i++) {
          strncpy(item->data[replace].ff_types[i],atom_types[i],5);
        }
        for (i=0; i < item->number_of_parameters; i++) {
          item->data[replace].ff_param[i] = parameters[i];
        }
      } else {
        if (pflag > 1) {
          fprintf(stderr," Using higher version of parameters for");
          fprintf(stderr," %s  ",item->keyword);
          for (i=0; i < item->number_of_members; i++)
            fprintf(stderr,"%s ",item->data[replace].ff_types[i]);
          fprintf(stderr," version %3.2f\n",item->data[replace].ver);
        }
      }
    } else {
      item->data[ctr].ver = version;
      item->data[ctr].ref = reference;
      for (i=0; i < item->number_of_members; i++) {
        strncpy(item->data[ctr].ff_types[i],atom_types[i],5);
      }
      for (i=0; i < item->number_of_parameters; i++) {
        item->data[ctr].ff_param[i] = parameters[i];
      }
      ctr++;
    }
    fgets( line, MAX_LINE_LENGTH, FrcF);
    /*if blank line encountered, get next */
    while((blank_line(line)) ||
          (strncmp(line,"!",1) == 0)) {
      status = fgets( line, MAX_LINE_LENGTH, FrcF);
      if (status == NULL) break;
    }
  }
  item->entries = ctr;

  /*Debugging
    fprintf(stderr,"\n%s\n", item->keyword);
    for(i=0;i<ctr;i++) {
    for(j=0;j<item->number_of_members;j++)
    fprintf(stderr,"%3s ", item->data[i].ff_equiv[j]);
    fprintf(stderr,"     ");
    for(j=0;j<item->number_of_parameters;j++)
    fprintf(stderr,"%10.5f ",item->data[i].ff_param[j]);
    fprintf(stderr,"\n");
    }
  */
}
Exemple #27
0
void
read_args_file(const char *infile)
{   char *line;
    FILE *fp = fopen(infile,"r");

    if(fp == NULL){
        fprintf(GlobalState.logfile,"Cannot open %s for reading.\n",infile);
        exit(1);
    }
    else{
        ArgType linetype = NO_ARGUMENT_MATCH;
        ArgType nexttype;
        while((line = read_line(fp)) != NULL){
            if(blank_line(line)){
                (void) free(line);
                continue;
            }
            nexttype = classify_arg(line);
            if(nexttype == NO_ARGUMENT_MATCH){
                if(*line == argument_prefix[0]){
                    /* Treat the line as a source file name. */
                    add_filename_to_source_list(&line[1],NORMALFILE);
                }
                else if(linetype != NO_ARGUMENT_MATCH){
                    /* Handle the line. */
                    switch(linetype){
                        case MOVES_ARGUMENT:
                            add_textual_variation_from_line(line);
                            break;
                        case POSITIONS_ARGUMENT:
                            add_positional_variation_from_line(line);
                            break;
                        case TAGS_ARGUMENT:
                            process_tag_line(infile,line);
                            break;
                        case TAG_ROSTER_ARGUMENT:
                            process_roster_line(line);
                            break;
                        case ENDINGS_ARGUMENT:
                            process_ending_line(line);
                            (void) free(line);
                            break;
                        default:
                            fprintf(GlobalState.logfile,
                                    "Internal error: unknown linetype %d in read_args_file\n",
                                    linetype);
                            (void) free(line);
                            exit(-1);
                    }
                }
                else{
                    /* It should have been a line applying to the
                     * current linetype.
                     */
                    fprintf(GlobalState.logfile,
                        "Missing argument type for line %s in the argument file.\n",
                        line);
                    exit(1);
                }
            }
            else{
                switch(nexttype){
                        /* Arguments with a possible additional
                         * argument value.
                         * All of these apply only to the current
                         * line in the argument file.
                         */
                    case WRITE_TO_OUTPUT_FILE_ARGUMENT:
                    case APPEND_TO_OUTPUT_FILE_ARGUMENT:
                    case WRITE_TO_LOG_FILE_ARGUMENT:
                    case APPEND_TO_LOG_FILE_ARGUMENT:
                    case DUPLICATES_FILE_ARGUMENT:
                    case USE_ECO_FILE_ARGUMENT:
                    case CHECK_FILE_ARGUMENT:
                    case FILE_OF_FILES_ARGUMENT:
                    case BOUNDS_ARGUMENT:
                    case GAMES_PER_FILE_ARGUMENT:
                    case ECO_OUTPUT_LEVEL_ARGUMENT:
                    case FILE_OF_ARGUMENTS_ARGUMENT:
                    case NON_MATCHING_GAMES_ARGUMENT:
                    case TAG_EXTRACTION_ARGUMENT:
                    case LINE_WIDTH_ARGUMENT:
                    case OUTPUT_FORMAT_ARGUMENT:
                        process_argument(line[argument_prefix_len],
                                         &line[argument_prefix_len+1]);
                        linetype = NO_ARGUMENT_MATCH;
                        break;
                    case LONG_FORM_ARGUMENT:
			{
			    char *arg = &line[argument_prefix_len+1];
			    char *space = strchr(arg, ' ');
			    if(space != NULL) {
				/* We need to drop an associated value from arg. */
				int arglen = space - arg;
				char *just_arg = (char *) MallocOrDie(arglen + 1);
				strncpy(just_arg, arg, arglen);
				just_arg[arglen] = '\0';
				process_long_form_argument(just_arg,
							   skip_leading_spaces(space));
			    }
			    else {
				process_long_form_argument(arg, "");
				linetype = NO_ARGUMENT_MATCH;
			    }
			}
                        break;

                        /* Arguments with no additional
                         * argument value.
                         * All of these apply only to the current
                         * line in the argument file.
                         */
                    case SEVEN_TAG_ROSTER_ARGUMENT:
                    case HELP_ARGUMENT:
                    case ALTERNATIVE_HELP_ARGUMENT:
                    case DONT_KEEP_COMMENTS_ARGUMENT:
                    case DONT_KEEP_DUPLICATES_ARGUMENT:
                    case DONT_MATCH_PERMUTATIONS_ARGUMENT:
                    case DONT_KEEP_NAGS_ARGUMENT:
                    case OUTPUT_FEN_STRING_ARGUMENT:
                    case CHECK_ONLY_ARGUMENT:
                    case KEEP_SILENT_ARGUMENT:
                    case USE_SOUNDEX_ARGUMENT:
                    case MATCH_CHECKMATE_ARGUMENT:
                    case SUPPRESS_ORIGINALS_ARGUMENT:
                    case DONT_KEEP_VARIATIONS_ARGUMENT:
                    case USE_VIRTUAL_HASH_TABLE_ARGUMENT:
                        process_argument(line[argument_prefix_len],"");
                        linetype = NO_ARGUMENT_MATCH;
                        break;

                        /* Arguments whose values persist beyond
                         * the current line.
                         */
                    case MOVES_ARGUMENT:
                    case POSITIONS_ARGUMENT:
                    case ENDINGS_ARGUMENT:
                    case TAGS_ARGUMENT:
                    case TAG_ROSTER_ARGUMENT:
                        process_argument(line[argument_prefix_len],
                                         &line[argument_prefix_len+1]);
                        /* Apply this type to subsequent lines. */
                        linetype = nexttype;
                        break;
                    default:
                        linetype = nexttype;
                        break;
                }
                (void) free(line);
            }
        }
        (void) fclose(fp);
    }
}
Exemple #28
0
/* Blank the first line of the bottom portion of the window. */
void blank_statusbar(void)
{
	blank_line(bottomwin, 0, 0, COLS);
}
Exemple #29
0
int SLcurses_wscrl (SLcurses_Window_Type *w, int n)
{
   SLcurses_Cell_Type **lines;
   unsigned int r0, r1, rmax, rmin, ncols;
   SLsmg_Color_Type color;

   if ((w == NULL) || (w->scroll_ok == 0))
     return -1;

   w->modified = 1;
#if 0
   if (w->is_subwin)
     {
	SLang_reset_tty ();
	SLsmg_reset_smg ();
	fprintf (stderr, "\rAttempt to scroll a subwindow\n");
	exit (1);
     }
#endif

   color = w->color;
   ncols = w->ncols;
   lines = w->lines;
   rmax = w->scroll_max;
   rmin = w->scroll_min;
   if (rmax > w->nrows)
     rmax = w->nrows;
   if ((rmin >= rmax) || (rmax == 0))
     return 0;

   if (n == 0)
     return 0;

   if (n > 0)
     {
	r0 = rmin;
	r1 = rmin + n;

	while (r1 < rmax)
	  {
	     if (w->is_subwin)
	       memcpy ((char *)lines[r0], (char *)lines[r1],
		       sizeof (SLcurses_Cell_Type) * ncols);
	     else
	       {
		  SLcurses_Cell_Type *swap = lines[r0];
		  lines[r0] = lines[r1];
		  lines[r1] = swap;
	       }
	     r0++;
	     r1++;
	  }
	while (r0 < rmax)
	  {
	     blank_line (lines[r0], ncols, color);
	     r0++;
	  }
	return 0;
     }

   /* else n < 0 */
   n = -n;

   r1 = rmax - 1;
   if (r1 < (unsigned int) n)
     n = r1;
   r0 = r1 - n;

   while (r0 >= rmin)
     {
	if (w->is_subwin)
	  memcpy ((char *)lines[r1], (char *)lines[r0],
		  sizeof (SLcurses_Cell_Type) * ncols);
	else
	  {
	     SLcurses_Cell_Type *swap = lines[r1];
	     lines[r1] = lines[r0];
	     lines[r0] = swap;
	  }
	r1--;
	if (r0 == 0)
	  break;
	r0--;
     }
   r0 = rmin;
   while (r0 <= r1)
     {
	blank_line (lines[r0], ncols, color);
	r0++;
     }

   return 0;
}
Exemple #30
0
/* Blank the first line of the top portion of the window. */
void blank_titlebar(void)
{
	blank_line(topwin, 0, 0, COLS);
}