Example #1
0
uint32 ConsoleWindow::findWordEnd(const Common::UString &line, uint32 pos) {
	Common::UString::iterator it = line.getPosition(pos);
	if ((it == line.end()) || (*it == ' '))
		return 0;

	while ((it != line.end()) && (*it != ' '))
		++it;

	return line.getPosition(it);
}
Example #2
0
void Functions::insertString(Aurora::NWScript::FunctionContext &ctx) {
	ctx.getReturn().getString().clear();
	if (ctx.getParams()[2].getInt() < 0)
		return;

	Common::UString str = ctx.getParams()[0].getString();

	str.insert(str.getPosition((size_t) ctx.getParams()[2].getInt()), ctx.getParams()[1].getString());

	ctx.getReturn() = str;
}
Example #3
0
UString FilePath::relativize(const UString &basePath, const UString &path) {
	const Common::UString normPath = normalize(path, false);
	const Common::UString normBase = normalize(basePath, false);

	UString relative = "";

	if (normPath.beginsWith(normBase))
		relative = normPath.substr(normPath.getPosition(normBase.size() + 1), normPath.end());

	return relative;
}
Example #4
0
Common::UString ConsoleWindow::getHighlight() const {
	if ((_highlightLength == 0) || (_highlightY >= kConsoleLines))
		return "";

	int32 start = _highlightX;
	int32 end   = _highlightX + _highlightLength;

	if (start > end)
		SWAP(start, end);

	Common::UString line;
	if (_highlightY == 0) {
		start = start - _prompt->get().size();
		end   = end   - _prompt->get().size();
		line  = _input->get();
	} else
		line = _lines[_lines.size() - _highlightY]->get();

	start = MAX(0, start);
	end   = MAX(0, end  );

	return line.substr(line.getPosition(start), line.getPosition(end));
}