예제 #1
0
			/**
			 * load BAM file index from filename
			 *
			 * @param filename name of .bai index file
			 * @return index
			 **/
			static libmaus2::bambam::BamIndex::unique_ptr_type loadIndex(std::string const & filename)
			{
				libmaus2::aio::InputStream::unique_ptr_type Pistr(libmaus2::aio::InputStreamFactoryContainer::constructUnique(filename));
				std::istream & CIS = *Pistr;
				libmaus2::bambam::BamIndex::unique_ptr_type Pindex(new libmaus2::bambam::BamIndex(CIS));
				return UNIQUE_PTR_MOVE(Pindex);
			}
예제 #2
0
파일: pattern.c 프로젝트: andreiw/polaris
int
set_menu_pattern(MENU *m, char *s)
{
	int top;
	ITEM *current;

	if (!m || !s) {
		return (E_BAD_ARGUMENT);
	}
	if (!Items(m)) {
		return (E_NOT_CONNECTED);
	}
	if (Indriver(m)) {
		return (E_BAD_STATE);
	}

	IthPattern(m, 0) = '\0';
	Pindex(m) = 0;

	if (*s == '\0') {
		_position_cursor(m);
		return (E_OK);
	}
	if (LinkNeeded(m)) {
		_link_items(m);
	}

	top = Top(m);
	current = Current(m);

	for (; *s; s++) {
		if (_match(m, *s, &current) != E_OK) {
			IthPattern(m, 0) = '\0';
			Pindex(m) = 0;
			_position_cursor(m);
			return (E_NO_MATCH);
		}
	}
	_chk_current(m, &top, current);
	_affect_change(m, top, current);
	return (E_OK);
}
예제 #3
0
int
set_menu_format(MENU *m, int rows, int cols)
{
	if (rows < 0 || cols < 0) {
		return (E_BAD_ARGUMENT);
	}
	if (m) {
		if (Posted(m)) {
			return (E_POSTED);
		}
		if (rows == 0) {
			rows = FRows(m);
		}
		if (cols == 0) {
			cols = FCols(m);
		}

		/* The pattern buffer is allocated after items have been */
		/* connected */
		if (Pattern(m)) {
			IthPattern(m, 0) = '\0';
			Pindex(m) = 0;
		}

		FRows(m) = rows;
		FCols(m) = cols;
		Cols(m) = min(cols, Nitems(m));
		Rows(m) = (Nitems(m)-1) / cols + 1;
		Height(m) = min(rows, Rows(m));
		Top(m) = 0;
		Current(m) = IthItem(m, 0);
		SetLink(m);
		_scale(m);
	} else {
		if (rows > 0) {
			FRows(Dfl_Menu) = rows;
		}
		if (cols > 0) {
			FCols(Dfl_Menu) = cols;
		}
	}
	return (E_OK);
}
예제 #4
0
파일: pattern.c 프로젝트: andreiw/polaris
int
_match(MENU *m, char c, ITEM **current)
{
	int i, j;
	int found;
	/*
	 * Indicates search has cycled past the current item.  If the current
	 * item is matched after cycled is true then NO_MATCH results.
	 */
	int cycled;

	/* If a backspace is encountered then search backward from the */
	/* current item.  Otherwise, search forward from the current item. */

	i = Index(*current);
	if (c && c != '\b') {		/* c could be null */
		if (Pindex(m)+1 > MaxName(m)) {
			return (E_NO_MATCH);
		}
		IthPattern(m, Pindex(m)) = c;
		IthPattern(m, ++Pindex(m)) = '\0';
		if (--i < 0) {
			i = Nitems(m)-1;
		}
	}

	j = i;
	found = FALSE;
	cycled = FALSE;

	do {
		if (c == '\b') {
			if (--i < 0) {
				i = Nitems(m)-1;
			}
		} else {
			if (++i >= Nitems(m)) {
				i = 0;
			}
		}
		if (substr(m, Pattern(m), Name(IthItem(m, i)))) {
			found = TRUE;
			break;
		}
		cycled = TRUE;
	} while (i != j);

	if (found) {
		if (i == Index(*current) && cycled) {
			return (E_NO_MATCH);
		}
		*current = IthItem(m, i);
	} else {
		if (c && c != '\b') {
			Pindex(m) -= 1;
			IthPattern(m, Pindex(m)) = '\0';
		}
		return (E_NO_MATCH);
	}
	return (E_OK);
}