Пример #1
0
WINDOW *
subwin(WINDOW *orig, int num_lines, int num_cols, int begy, int begx)
{
	WINDOW	*win;
	int	by, bx, nl, nc;

	by = begy;
	bx = begx;
	nl = num_lines;
	nc = num_cols;

	/*
	 * make sure window fits inside the original one
	 */
#ifdef	DEBUG
	fprintf(outf, "SUBWIN(%0.2o, %d, %d, %d, %d)\n", orig, nl, nc, by, bx);
#endif
	if (by < orig->_begy || bx < orig->_begx ||
	    by + nl > orig->_maxy + orig->_begy ||
	    bx + nc > orig->_maxx + orig->_begx)
		return (ERR);
	if (nl == 0)
		nl = orig->_maxy + orig->_begy - by;
	if (nc == 0)
		nc = orig->_maxx + orig->_begx - bx;
	if ((win = makenew(nl, nc, by, bx)) == NULL)
		return (ERR);
	win->_nextp = orig->_nextp;
	orig->_nextp = win;
	win->_orig = orig;
	_set_subwin_(orig, win);
	return (win);
}
Пример #2
0
void MainWindow::on_actionLoad_triggered()
{
    this->ui->textBrowser_5->clear();
    QString filename = QFileDialog::getOpenFileName(this,"Import a File");
    emit makenew(filename);
    cacheSize = 0;
    cacheLine = 0;
    breakPoint = 0;
}
Пример #3
0
WINDOW *
newwin(int num_lines, int num_cols, int begy, int begx)
{
	WINDOW	*win;
	char	*sp;
	int	i, by, bx, nl, nc;
	int	j;

	by = begy;
	bx = begx;
	nl = num_lines;
	nc = num_cols;

	if (nl == 0)
		nl = LINES - by;
	if (nc == 0)
		nc = COLS - bx;
	if ((win = makenew(nl, nc, by, bx)) == NULL)
		return (ERR);
	if ((win->_firstch = SMALLOC(nl * sizeof (win->_firstch[0]))) == NULL) {
		free(win->_y);
		free(win);
		return (NULL);
	}
	if ((win->_lastch = SMALLOC(nl * sizeof (win->_lastch[0]))) == NULL) {
		free(win->_y);
		free(win->_firstch);
		free(win);
		return (NULL);
	}
	win->_nextp = win;
	for (i = 0; i < nl; i++) {
		win->_firstch[i] = _NOCHANGE;
		win->_lastch[i] = _NOCHANGE;
	}
	for (i = 0; i < nl; i++)
		if ((win->_y[i] = malloc(nc * sizeof (win->_y[0]))) == NULL) {
			for (j = 0; j < i; j++)
				free(win->_y[j]);
			free(win->_firstch);
			free(win->_lastch);
			free(win->_y);
			free(win);
			return (ERR);
		}
		else
			for (sp = win->_y[i]; sp < win->_y[i] + nc; )
				*sp++ = ' ';
	win->_ch_off = 0;
#ifdef DEBUG
	fprintf(outf, "NEWWIN: win->_ch_off = %d\n", win->_ch_off);
#endif
	return (win);
}