예제 #1
0
YCursor YLineSearch::forward(const QString& ch, bool& found, unsigned int times)
{
    YCursor cur = mView->getLineColumnCursor();
    int x = cur.x() + 1; // Start search after cursor pos
    int y = cur.y();
    const QString& current = mView->buffer()->textline(y);
    int index = 0;
    unsigned int nfound = 0;

    while(nfound < times && x < current.length()) {
        index = current.indexOf(ch, x);

        if(index < 0) {
            break;
        }

        x = index + 1;
        nfound++;
    }

    YCursor pos;
    found = (nfound == times);

    if(found) {
        pos.setX(x - 1);
        pos.setY(y);
    }

    updateHistory(ch, SearchForward);
    return pos;
}
예제 #2
0
YCursor YLineSearch::forwardBefore(const QString& ch, bool& found, unsigned int times)
{
    YCursor pos = forward(ch, found, times);

    if(found) {
        pos.setX(pos.x() - 1);
    }

    updateHistory(ch, SearchForwardBefore);
    return pos;
}
예제 #3
0
YCursor YLineSearch::reverseAfter(const QString& ch, bool& found, unsigned int times)
{
    YCursor pos = reverse(ch, found, times);

    if(found) {
        pos.setX(pos.x() + 1);
    }

    updateHistory(ch, SearchBackwardAfter);
    return pos;
}
예제 #4
0
void YModeInsert::imCompose(YView* mView, const QString& entry)
{
    if(!m_imPreedit.isEmpty()) {    // replace current one
        YCursor pos = mView->getLinePositionCursor();
        int len = m_imPreedit.length();

        if(pos.x() >= len) {
            pos.setX(pos.x() - len);
        } else {
            pos.setX(0);
        }

        mView->buffer()->action()->replaceText(mView, pos, len, entry);
    } else {
        YKey input;
        input.fromString(entry);
        YSession::self()->sendKey(mView, input);
    }

    m_imPreedit = entry;
}
예제 #5
0
YCursor YLineSearch::reverse(const QString& ch, bool& found, unsigned int times)
{
    YCursor cur = mView->getLineColumnCursor();
    unsigned int x = cur.x();
    unsigned int y = cur.y();

    if(x) {
        x--;    // Start search before current cursor
    }

    const QString& current = mView->buffer()->textline(y);
    int index = 0;
    unsigned int nfound = 0;

    while(nfound < times && x > 0) {
        index = current.lastIndexOf(ch, x);

        if(index < 0) {
            break;
        }

        x = index - 1;
        nfound++;
    }

    YCursor pos;
    found = (nfound == times);

    if(found) {
        pos.setX(x + 1);
        pos.setY(y);
    }

    updateHistory(ch, SearchBackward);
    return pos;
}