Ejemplo n.º 1
0
int unescape(char *dest, int lim, char *src) {
	int i, j;
	char c;
	for (i = j = 0; src[i] != '\0' && j + 1 < lim; i++) {
		c = src[i];
		if (c == '\\') {
			i++;
			switch (src[i]) {
			case 'x': dest[j++] = hexr(src[i + 1]) * 16 + hexr(src[i + 2]); i += 2; break;
			case 'a': dest[j++] = '\a'; break;
			case 'b': dest[j++] = '\b'; break;
			case 'f': dest[j++] = '\f'; break;
			case 'n': dest[j++] = '\n'; break;
			case 'r': dest[j++] = '\r'; break;
			case 'v': dest[j++] = '\v'; break;
			case 't': dest[j++] = '\t'; break;
			case '\'': dest[j++] = '\''; break;
			case '\"': dest[j++] = '\"'; break;
			case '\\': dest[j++] = '\\'; break;
			case '\?': dest[j++] = '\?'; break;
			default: break;
			}
		} else {
			dest[j++] = c;
		}
	}
	dest[j] = '\0';
	return j;
}
Ejemplo n.º 2
0
void QHexEditPrivate::drawLineBackground(QPainter &painter, qint64 line, qint64 linestart, int y)
{
	QRect hexr(this->_xposhex, y, this->_xposascii - (this->_charwidth / 2), this->_charheight);
	QRect asciir(this->_xposascii, y, (this->_charwidth * QHexEditPrivate::BYTES_PER_LINE) + (this->_charwidth / 2), this->_charheight);

	if((this->_cursorpos >= linestart) && (this->_cursorpos < (linestart + QHexEditPrivate::BYTES_PER_LINE))) /* This is the Selected Line */
	{
		painter.fillRect(hexr, this->_sellinecolor);
		painter.fillRect(asciir, this->_sellinecolor);
	}
	else if(line & 1)
	{
		painter.fillRect(hexr, this->_alternatelinecolor);
		painter.fillRect(asciir, this->_alternatelinecolor);
	}
	else
	{
		painter.fillRect(hexr, this->palette().color(QPalette::Base));
		painter.fillRect(asciir, this->palette().color(QPalette::Base));
	}
}