Example #1
0
void Cursor::dispatchEvents()
{
    if (m_new_position != m_position|| m_content_height_changed) {
        bool emit_x_changed = m_new_position.x() != m_position.x();
        bool emit_y_changed = m_new_position.y() != m_position.y();
        m_position = m_new_position;
        if (emit_x_changed)
            emit xChanged();
        if (emit_y_changed || m_content_height_changed)
            emit yChanged();
    }

    if (m_new_visibillity != m_visible) {
        m_visible = m_new_visibillity;
        emit visibilityChanged();
    }

    if (m_new_blinking != m_blinking) {
        m_blinking = m_new_blinking;
        emit blinkingChanged();
    }
}
Example #2
0
void Text::dispatchEvents()
{
    int old_line = m_old_line + (m_old_start_index / m_width);
    int new_line = m_line + (m_start_index / m_width);
    if (old_line != new_line) {
        m_old_line = m_line;
        emit lineChanged();
    }

    if (m_latin != m_latin_old) {
        m_latin_old = m_latin;
        emit latinChanged();
    }

    if (m_old_start_index != m_start_index
            || m_text_dirty) {
        m_text_dirty = false;
        QString old_text = m_text;
        m_text = m_text_line->mid(m_start_index, m_end_index - m_start_index + 1);
        if (m_old_start_index != m_start_index) {
            m_old_start_index = m_start_index;
            emit indexChanged();
        }
        emit textChanged();
    }

    if (m_style_dirty) {
        m_style_dirty = false;

        bool emit_foreground = m_new_style.foreground != m_style.foreground;
        bool emit_background = m_new_style.background != m_style.background;
        TextStyle::Styles new_style = m_new_style.style;
        TextStyle::Styles old_style = m_style.style;

        bool emit_bold = false;
        bool emit_blink = false;
        bool emit_underline = false;
        bool emit_inverse = false;
        if (new_style != old_style) {
            emit_bold = differentStyle(new_style, old_style, TextStyle::Bold);
            emit_blink = differentStyle(new_style, old_style, TextStyle::Blinking);
            emit_underline = differentStyle(new_style, old_style, TextStyle::Underlined);
            emit_inverse = differentStyle(new_style, old_style, TextStyle::Inverse);
        }

        m_style = m_new_style;
        if (emit_inverse) {
            setForegroundColor();
            setBackgroundColor();
        } else {
            if (emit_foreground || emit_bold) {
                setForegroundColor();
            }
            if (emit_background) {
                setBackgroundColor();
            }
        }

        if (emit_bold) {
            emit boldChanged();
        }

        if (emit_blink) {
            emit blinkingChanged();
        }

        if (emit_underline) {
            emit underlineChanged();
        }

    }


    if (m_visible_old != m_visible) {
        m_visible_old = m_visible;
        emit visibleChanged();
    }
}