当前位置: 首页>>代码示例>>C++>>正文


C++ TabSettings::indentationColumn方法代码示例

本文整理汇总了C++中texteditor::TabSettings::indentationColumn方法的典型用法代码示例。如果您正苦于以下问题:C++ TabSettings::indentationColumn方法的具体用法?C++ TabSettings::indentationColumn怎么用?C++ TabSettings::indentationColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在texteditor::TabSettings的用法示例。


在下文中一共展示了TabSettings::indentationColumn方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: reindent

void Indenter::reindent(QTextDocument *doc, const QTextCursor &cursor, const TextEditor::TabSettings &tabSettings)
{
    if (cursor.hasSelection()) {
        QTextBlock block = doc->findBlock(cursor.selectionStart());
        const QTextBlock end = doc->findBlock(cursor.selectionEnd()).next();

        // skip empty blocks
        while (block.isValid() && block != end) {
            QString bt = block.text();
            if (tabSettings.firstNonSpace(bt) < bt.size())
                break;
            indentBlock(doc, block, QChar::Null, tabSettings);
            block = block.next();
        }

        int previousIndentation = tabSettings.indentationColumn(block.text());
        indentBlock(doc, block, QChar::Null, tabSettings);
        int currentIndentation = tabSettings.indentationColumn(block.text());
        int delta = currentIndentation - previousIndentation;

        block = block.next();
        while (block.isValid() && block != end) {
            tabSettings.reindentLine(block, delta);
            block = block.next();
        }
    } else {
        indentBlock(doc, cursor.block(), QChar::Null, tabSettings);
    }
}
开发者ID:KDE,项目名称:android-qt-creator,代码行数:29,代码来源:indenter.cpp

示例2: indentBlock

void GLSLIndenter::indentBlock(QTextDocument *doc,
                               const QTextBlock &block,
                               const QChar &typedChar,
                               const TextEditor::TabSettings &tabSettings)
{
    Q_UNUSED(doc)

    // TODO: do something with it
    CppTools::QtStyleCodeFormatter codeFormatter(tabSettings,
              CppTools::CppToolsSettings::instance()->cppCodeStyle()->codeStyleSettings());

    codeFormatter.updateStateUntil(block);
    int indent;
    int padding;
    codeFormatter.indentFor(block, &indent, &padding);

    // only reindent the current line when typing electric characters if the
    // indent is the same it would be if the line were empty
    if (isElectricCharacter(typedChar)) {
        int newlineIndent;
        int newlinePadding;
        codeFormatter.indentForNewLineAfter(block.previous(), &newlineIndent, &newlinePadding);
        if (tabSettings.indentationColumn(block.text()) != newlineIndent + newlinePadding)
            return;
    }

    tabSettings.indentLine(block, indent + padding, padding);
}
开发者ID:KDE,项目名称:android-qt-creator,代码行数:28,代码来源:glslindenter.cpp

示例3: indentBlock

void CMakeIndenter::indentBlock(QTextDocument *doc, const QTextBlock &block, const QChar &typedChar, const TextEditor::TabSettings &tabSettings)
{
    Q_UNUSED(doc)
    Q_UNUSED(typedChar)

    QTextBlock previousBlock = block.previous();
    // find the next previous block that is non-empty (contains non-whitespace characters)
    while (previousBlock.isValid() && lineIsEmpty(previousBlock.text()))
        previousBlock = previousBlock.previous();
    if (previousBlock.isValid()) {
        const QString previousLine = previousBlock.text();
        const QString currentLine = block.text();
        int indentation = tabSettings.indentationColumn(previousLine);

        if (lineStartsBlock(previousLine))
            indentation += tabSettings.m_indentSize;
        if (lineEndsBlock(currentLine))
            indentation = qMax(0, indentation - tabSettings.m_indentSize);

        // increase/decrease/keep the indentation level depending on if we have more opening or closing parantheses
        indentation = qMax(0, indentation + tabSettings.m_indentSize * paranthesesLevel(previousLine));

        tabSettings.indentLine(block, indentation);
    } else {
        // First line in whole document
        tabSettings.indentLine(block, 0);
    }
}
开发者ID:KeeganRen,项目名称:qt-creator,代码行数:28,代码来源:cmakeindenter.cpp

示例4: indentFor

int PythonIndenter::indentFor(const QTextBlock &block, const TextEditor::TabSettings &tabSettings)
{
    QTextBlock previousBlock = block.previous();
        if (!previousBlock.isValid())
            return 0;

        QString previousLine = previousBlock.text();
        int indentation = tabSettings.indentationColumn(previousLine);

        if (isElectricLine(previousLine))
            indentation += tabSettings.m_indentSize;
        else
            indentation = qMax<int>(0, indentation + getIndentDiff(previousLine, tabSettings));

        return indentation;
}
开发者ID:intelligide,项目名称:UnicornEdit,代码行数:16,代码来源:PythonIndenter.cpp

示例5: indentFor

int CMakeIndenter::indentFor(const QTextBlock &block, const TextEditor::TabSettings &tabSettings)
{
    QTextBlock previousBlock = block.previous();
    // find the next previous block that is non-empty (contains non-whitespace characters)
    while (previousBlock.isValid() && lineIsEmpty(previousBlock.text()))
        previousBlock = previousBlock.previous();
    if (!previousBlock.isValid())
        return 0;

    const QString previousLine = previousBlock.text();
    const QString currentLine = block.text();
    int indentation = tabSettings.indentationColumn(previousLine);

    if (lineStartsBlock(previousLine))
        indentation += tabSettings.m_indentSize;
    if (lineEndsBlock(currentLine))
        indentation = qMax(0, indentation - tabSettings.m_indentSize);

    // increase/decrease/keep the indentation level depending on if we have more opening or closing parantheses
    return qMax(0, indentation + tabSettings.m_indentSize * paranthesesLevel(previousLine));
}
开发者ID:AvatarSD,项目名称:cmakeprojectmanager2,代码行数:21,代码来源:cmakeindenter.cpp

示例6: indentBlock

/**
 * @brief Indenter::indentBlock Indents one block (usually one line) of code
 * @param block
 * @param typedChar
 * @param tabSettings An IDE tabulation settings
 *
 * Usually this method called once when you begin new line of code by pressing
 * Enter. If Indenter reimplements indent() method, than indentBlock() may be
 * called in other cases.
 */
void Indenter::indentBlock(QTextDocument */*doc*/,
                           const QTextBlock &block,
                           const QChar &/*typedChar*/,
                           const TextEditor::TabSettings &settings)
{
    QTextBlock previousBlock = block.previous();
    if (previousBlock.isValid()) {
        QString previousLine = previousBlock.text();
        int indentation = settings.indentationColumn(previousLine);

        if (isElectricLine(previousLine)) {
            indentation += TAB_SIZE;
        }
        parsePreviousLine(settings, previousLine, previousBlock, indentation);

        settings.indentLine(block, indentation);
    } else {
        // First line in whole document
        settings.indentLine(block, 0);
    }
}
开发者ID:sergey-shambir,项目名称:sergey-shambir-sandbox,代码行数:31,代码来源:indenter.cpp

示例7: indentBlock

void Indenter::indentBlock(QTextDocument *doc,
                           const QTextBlock &block,
                           const QChar &typedChar,
                           const TextEditor::TabSettings &tabSettings)
{
    Q_UNUSED(doc)

    QmlJSTools::QtStyleCodeFormatter codeFormatter(tabSettings);

    codeFormatter.updateStateUntil(block);
    const int depth = codeFormatter.indentFor(block);

    if (isElectricCharacter(typedChar)) {
        // only reindent the current line when typing electric characters if the
        // indent is the same it would be if the line were empty
        const int newlineIndent = codeFormatter.indentForNewLineAfter(block.previous());
        if (tabSettings.indentationColumn(block.text()) != newlineIndent)
            return;
    }

    tabSettings.indentLine(block, depth);
}
开发者ID:anchowee,项目名称:QtCreator,代码行数:22,代码来源:qmljsindenter.cpp


注:本文中的texteditor::TabSettings::indentationColumn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。