示例#1
0
文件: cursor.cpp 项目: siyuano/yat
void Cursor::setDocumentHeight(int height, int currentCursorBlock, int currentScrollBackHeight)
{
    Q_UNUSED(currentCursorBlock);
    resetScrollArea();
    if (m_document_height > height) {
        const int to_remove = m_document_height - height;
        const int removeLinesBelowCursor =
            std::min(m_document_height - new_y(), to_remove);
        const int removeLinesAtTop = to_remove - removeLinesBelowCursor;
        if (!removeLinesAtTop) {
            new_ry() -= removeLinesAtTop;
            notifyChanged();
        }
    } else {
        int height_diff = height - m_document_height;
        if (currentScrollBackHeight >= height_diff) {
            new_ry() += height_diff;
        } else if (currentScrollBackHeight > 0) {
            const int move = height_diff - currentScrollBackHeight;
            new_ry() += move;
        }
    }

    m_document_height = height;

    if (new_y() >= height) {
        new_ry() = height - 1;
        notifyChanged();
    }
    if (new_y() <= 0) {
        new_ry() = 0;
    }
}
示例#2
0
void Cursor::setScreenHeight(int newHeight, int removedBeginning, int reclaimed)
{
    resetScrollArea();
    m_screen_height = newHeight;
    new_ry() -= removedBeginning;
    new_ry() += reclaimed;
    if (new_y() <= 0) {
        new_ry() = 0;
    }
}