Beispiel #1
0
QString TextShow::unquoteString(const QString &s, int from, int to)
{
    string ss;
	if (!s.isEmpty())
		ss = s.local8Bit();
    unsigned startPos = textPosition(s, from);
    unsigned endPos = textPosition(s, to);
    log(L_DEBUG, "%s: %u %u %u %u", ss.c_str(), from, to, startPos, endPos);
    return SIM::unquoteText(s.mid(startPos, endPos - startPos));
}
Beispiel #2
0
QString TextShow::unquoteString(const QString &s, int from, int to)
{
    string text;
    unsigned startPos = textPosition(s, from);
    unsigned endPos = textPosition(s, to);
    text = s.mid(startPos, endPos - startPos).utf8();
    Event e(EventDecodeText, &text);
    e.process();
    return QString::fromUtf8(SIM::unquoteText(text.c_str()).c_str());
}
Beispiel #3
0
void XMLDocumentParser::parse()
{
    while (!isStopped() && !m_parserPaused && !m_stream.atEnd()) {
        m_stream.readNext();
        switch (m_stream.tokenType()) {
        case QXmlStreamReader::StartDocument:
            startDocument();
            break;
        case QXmlStreamReader::EndDocument:
            endDocument();
            break;
        case QXmlStreamReader::StartElement:
            parseStartElement();
            break;
        case QXmlStreamReader::EndElement:
            parseEndElement();
            break;
        case QXmlStreamReader::Characters: {
            if (m_stream.isCDATA()) {
                //cdata
                parseCdata();
            } else {
                //characters
                parseCharacters();
            }
            break;
        }
        case QXmlStreamReader::Comment:
            parseComment();
            break;
        case QXmlStreamReader::DTD:
            //qDebug()<<"------------- DTD";
            parseDtd();
            break;
        case QXmlStreamReader::EntityReference: {
            //qDebug()<<"---------- ENTITY = "<<m_stream.name().toString()
            //        <<", t = "<<m_stream.text().toString();
            if (isXHTMLDocument()) {
                QString entity = m_stream.name().toString();
                if (!m_leafTextNode)
                    enterText();
                // qDebug()<<" ------- adding entity "<<str;
                m_leafTextNode->appendData(decodeNamedEntity(entity), IGNORE_EXCEPTION);
            }
            break;
        }
        case QXmlStreamReader::ProcessingInstruction:
            parseProcessingInstruction();
            break;
        default: {
            if (m_stream.error() != QXmlStreamReader::PrematureEndOfDocumentError) {
                XMLErrors::ErrorType type = (m_stream.error() == QXmlStreamReader::NotWellFormedError) ?
                                 XMLErrors::fatal : XMLErrors::warning;
                handleError(type, qPrintable(m_stream.errorString()), textPosition());
            }
            break;
        }
        }
    }
}
Beispiel #4
0
bool ImGui::button(const char *text, int left, int right, int bottom, int top)
{
    if (invalid(left, right, bottom, top))
    {
        return false;
    }

    left += scrollX;
    right += scrollX;

    top += (int)scrollY;
    bottom += (int)scrollY;

    bool pressed = false;

    Int2 mousePos = platform->getMousePosition();
    mousePos.y = platform->getWindowHeight() - mousePos.y;
    bool highlighted = intersects(left, right, bottom, top, mousePos);

    float brightness = highlighted ? 0.95f : 1.0f;

    if (platform->isLeftMouseButtonPressed() and highlighted)
    {
        brightness = 0.8f;
        pressed = true;
    }

    rectangle(left-scrollX, right-scrollX, bottom-scrollY, top-scrollY, brightness);

    //For some reason doing this in integers won't work.
    size_t textWidth = font->predictWidth(textSize, text);

    float textHeightGL = textSize / float(platform->getWindowHeight()) / 2.0f;
    float textWidthGL = textWidth / float(platform->getWindowWidth()) / 2.0f;

    float w = gfxApi->getViewportWidth();
    float h = gfxApi->getViewportHeight();
    float fleft = left / w * 2.0f - 1.0f;
    float fright = right / w * 2.0f - 1.0f;
    float ftop = top / h * 2.0f - 1.0f;
    float fbottom = bottom / h * 2.0f - 1.0f;

    Float2 textPosition(fleft + (fright-fleft-textWidthGL)/2.0f,
                        fbottom + (ftop-fbottom-textHeightGL)/2.0f);

    Command command;
    command.type = Command::Text;
    command.text.size = textSize;
    command.text.left = (textPosition.x + 1.0f) / 2.0f * platform->getWindowWidth();
    command.text.bottom = (textPosition.y + 1.0f) / 2.0f * platform->getWindowHeight();
    command.text.colorR = buttonTextColor.x;
    command.text.colorG = buttonTextColor.y;
    command.text.colorB = buttonTextColor.z;
    command.textStr = text;

    commands.append(command);

    return pressed;
}
void XMLDocumentParser::parseStartElement()
{
    if (!m_sawFirstElement && m_parsingFragment) {
        // skip dummy element for fragments
        m_sawFirstElement = true;
        return;
    }

    exitText();

    String localName = m_stream.name();
    String uri       = m_stream.namespaceUri();
    String prefix    = prefixFromQName(m_stream.qualifiedName().toString());

    if (m_parsingFragment && uri.isNull()) {
        Q_ASSERT(prefix.isNull());
        uri = m_defaultNamespaceURI;
    }

    QualifiedName qName(prefix, localName, uri);
    RefPtr<Element> newElement = document()->createElement(qName, true);
    if (!newElement) {
        stopParsing();
        return;
    }

    bool isFirstElement = !m_sawFirstElement;
    m_sawFirstElement = true;

    ExceptionCode ec = 0;
    handleElementNamespaces(newElement.get(), m_stream.namespaceDeclarations(), ec, m_scriptingPermission);
    if (ec) {
        stopParsing();
        return;
    }

    handleElementAttributes(newElement.get(), m_stream.attributes(), ec, m_scriptingPermission);
    if (ec) {
        stopParsing();
        return;
    }

    ScriptElement* scriptElement = toScriptElement(newElement.get());
    if (scriptElement)
        m_scriptStartPosition = textPosition();

    m_currentNode->parserAddChild(newElement.get());

    pushCurrentNode(newElement.get());
    if (m_view && !newElement->attached())
        newElement->attach();

    if (newElement->hasTagName(HTMLNames::htmlTag))
        static_cast<HTMLHtmlElement*>(newElement.get())->insertedByParser();

    if (isFirstElement && document()->frame())
        document()->frame()->loader()->dispatchDocumentElementAvailable();
}
void ScriptDebugServer::createCallFrame(const DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, int lineNumber, int columnNumber)
{
    TextPosition textPosition(OrdinalNumber::fromOneBasedInt(lineNumber), OrdinalNumber::fromZeroBasedInt(columnNumber));
    m_currentCallFrame = JavaScriptCallFrame::create(debuggerCallFrame, m_currentCallFrame, sourceID, textPosition);
    if (m_lastExecutedSourceId != sourceID) {
        m_lastExecutedLine = -1;
        m_lastExecutedSourceId = sourceID;
    }
}
Beispiel #7
0
void ScriptDebugServer::updateCallFrameAndPauseIfNeeded(const DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, int lineNumber)
{
    ASSERT(m_currentCallFrame);
    if (!m_currentCallFrame)
        return;

    TextPosition0 textPosition(WTF::OneBasedNumber::fromOneBasedInt(lineNumber).convertToZeroBased(), WTF::ZeroBasedNumber::base());
    m_currentCallFrame->update(debuggerCallFrame, sourceID, textPosition);
    pauseIfNeeded(debuggerCallFrame.dynamicGlobalObject());
}
Beispiel #8
0
void ScriptDebugServer::updateCallFrameAndPauseIfNeeded(const DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, int lineNumber)
{
    ASSERT(m_currentCallFrame);
    if (!m_currentCallFrame)
        return;

    TextPosition textPosition(OrdinalNumber::fromOneBasedInt(lineNumber), OrdinalNumber::first());
    m_currentCallFrame->update(debuggerCallFrame, sourceID, textPosition);
    pauseIfNeeded(debuggerCallFrame.dynamicGlobalObject());
}
void ofxTextButton::setup(ofRectangle a,string description,int tS,ofColor tC,ofColor bC)
{
    area = a;
    text = description;
    tSize = tS;
    font.loadFont("verdana.ttf", tSize);
    tCol = tC;
    bCol = bC;
    tPos = textPosition();
    clicked = false;
}
	void ButtonElement::Draw()
	{
		if (_state.IsActive)
			_functionPtr->DrawImage(_spriteActive.Path, _position);
		else if (_state.IsHover)
			_functionPtr->DrawImage(_spriteHover.Path, _position);
		else
			_functionPtr->DrawImage(_sprite.Path, _position);

		vec2 textPosition(_position.x + (_size.x / 2) - (_textSize.x / 2), _position.y + (_size.y / 2) - (_textSize.y / 2));

		_functionPtr->DrawText(_id, textPosition);
	}
Beispiel #11
0
void XMLDocumentParser::doEnd()
{
#if ENABLE(XSLT)
    if (m_sawXSLTransform) {
        document()->setTransformSource(adoptPtr(new TransformSource(m_originalSourceForTransform.toString())));
        document()->setParsing(false); // Make the doc think it's done, so it will apply xsl sheets.
        document()->styleResolverChanged(RecalcStyleImmediately);
        document()->setParsing(true);
        DocumentParser::stopParsing();
    }
#endif

    if (m_stream.error() == QXmlStreamReader::PrematureEndOfDocumentError
        || (m_wroteText && !m_sawFirstElement && !m_sawXSLTransform && !m_sawError))
        handleError(XMLErrors::fatal, qPrintable(m_stream.errorString()), textPosition());
}
CharTransforms ArtisticTextLoadingContext::yOffsets(int count)
{
    switch(yOffsetType()) {
    case Absolute: {
        const QPointF origin = textPosition();
        CharTransforms offsets = collectValues(count, m_currentAbsolutePosY, m_absolutePosY);
        const int offsetCount = offsets.count();
        for (int i = 0; i < offsetCount; ++i) {
            offsets[i] -= origin.y();
        }
        return offsets;
    }
    case Relative:
        return collectValues(count, m_currentRelativePosY, m_relativePosY);
    default:
        return CharTransforms();
    }
}
Beispiel #13
0
void XMLDocumentParser::doWrite(const String& parseString)
{
    m_wroteText = true;

    if (document()->decoder() && document()->decoder()->sawError()) {
        // If the decoder saw an error, report it as fatal (stops parsing)
        handleError(XMLErrors::fatal, "Encoding error", textPosition());
        return;
    }

    QString data(parseString);
    if (!data.isEmpty()) {
        // JavaScript may cause the parser to detach,
        // keep this alive until this function is done.
        RefPtr<XMLDocumentParser> protect(this);

        m_stream.addData(data);
        parse();
    }

    return;
}
Beispiel #14
0
void ScriptDebugServer::createCallFrameAndPauseIfNeeded(const DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, int lineNumber)
{
    TextPosition textPosition(OrdinalNumber::fromOneBasedInt(lineNumber), OrdinalNumber::first());
    m_currentCallFrame = JavaScriptCallFrame::create(debuggerCallFrame, m_currentCallFrame, sourceID, textPosition);
    pauseIfNeeded(debuggerCallFrame.dynamicGlobalObject());
}
Beispiel #15
0
QString TextShow::unquoteString(const QString &s, int from, int to)
{
    unsigned startPos = textPosition(s, from);
    unsigned endPos = textPosition(s, to);
    return SIM::unquoteText(s.mid(startPos, endPos - startPos));
}
Beispiel #16
0
void ScriptDebugServer::createCallFrameAndPauseIfNeeded(const DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, int lineNumber)
{
    TextPosition0 textPosition(WTF::OneBasedNumber::fromOneBasedInt(lineNumber).convertToZeroBased(), WTF::ZeroBasedNumber::base());
    m_currentCallFrame = JavaScriptCallFrame::create(debuggerCallFrame, m_currentCallFrame, sourceID, textPosition);
    pauseIfNeeded(debuggerCallFrame.dynamicGlobalObject());
}
Beispiel #17
0
void XMLDocumentParser::doEnd()
{
    if (m_stream.error() == QXmlStreamReader::PrematureEndOfDocumentError
        || (m_wroteText && !m_sawFirstElement && !m_sawXSLTransform && !m_sawError))
        handleError(XMLErrors::fatal, qPrintable(m_stream.errorString()), textPosition());
}