} else if (input.is('b') || input.isShift(Key_Left)) {
m_movetype = MoveExclusive;
moveToWordBoundary(false, false);
+ setTargetColumn();
finishMovement();
} else if (input.is('B')) {
m_movetype = MoveExclusive;
moveToWordBoundary(true, false);
+ setTargetColumn();
finishMovement();
} else if (input.is('c') && isNoVisualMode()) {
if (atEndOfLine())
} else if (input.is('e') || input.isShift(Key_Right)) {
m_movetype = MoveInclusive;
moveToWordBoundary(false, true);
+ setTargetColumn();
finishMovement("%1e", count());
} else if (input.is('E')) {
m_movetype = MoveInclusive;
moveToWordBoundary(true, true);
+ setTargetColumn();
finishMovement("%1E", count());
} else if (input.isControl('e')) {
// FIXME: this should use the "scroll" option, and "count"
// character of a word: only the current word will be changed
if (m_submode == ChangeSubMode) {
moveToWordBoundary(false, true, true);
+ setTargetColumn();
m_movetype = MoveInclusive;
} else {
moveToNextWord(false, m_submode == DeleteSubMode);
} else if (input.is('W')) {
if (m_submode == ChangeSubMode) {
moveToWordBoundary(true, true, true);
+ setTargetColumn();
m_movetype = MoveInclusive;
} else {
moveToNextWord(true, m_submode == DeleteSubMode);
} else if (input.isControl('w')) {
int endPos = position();
moveToWordBoundary(false, false, false);
+ setTargetColumn();
int beginPos = position();
Range range(beginPos, endPos, RangeCharMode);
removeText(range);
removeText(Range(pos, pos+i));
//} else if (key >= control('a') && key <= control('z')) {
// // ignore these
+ } else if (input.isControl('p') || input.isControl('n')) {
+ QTextCursor tc = EDITOR(textCursor());
+ moveToWordBoundary(false, false);
+ QString str = selectText(Range(position(), tc.position()));
+ EDITOR(setTextCursor(tc));
+ emit q->simpleCompletionRequested(str, input.isControl('n'));
} else if (!input.text().isEmpty()) {
insertInInsertMode(input.text());
} else {
if (repeat == -1)
break;
}
- setTargetColumn();
}
bool FakeVimHandler::Private::handleFfTt(QString key)
//if (isVisualMode())
// setMark('<', cursor().position());
moveToWordBoundary(false, true, true);
+ setTargetColumn();
m_movetype = MoveInclusive;
}
//if (isVisualMode())
// setMark('<', cursor().position());
moveToWordBoundary(true, true, true);
+ setTargetColumn();
m_movetype = MoveInclusive;
}
#include <texteditor/tabsettings.h>
#include <texteditor/texteditorsettings.h>
#include <texteditor/indenter.h>
+#include <texteditor/icompletioncollector.h>
#include <find/findplugin.h>
#include <find/textfindconstants.h>
void setUseFakeVim(const QVariant &value);
void quitFakeVim();
void triggerCompletions();
+ void triggerSimpleCompletions(const QString &needle, bool forward);
void windowCommand(int key);
void find(bool reverse);
void findNext(bool reverse);
this, SLOT(hasBlockSelection(bool*)));
connect(handler, SIGNAL(completionRequested()),
this, SLOT(triggerCompletions()));
+ connect(handler, SIGNAL(simpleCompletionRequested(QString,bool)),
+ this, SLOT(triggerSimpleCompletions(QString,bool)));
connect(handler, SIGNAL(windowCommandRequested(int)),
this, SLOT(windowCommand(int)));
connect(handler, SIGNAL(findRequested(bool)),
// bt->triggerCompletions();
}
+class WordCompletion : public ICompletionCollector
+{
+public:
+ WordCompletion(ITextEditable *editor = 0) : m_editor(editor) {}
+
+ virtual ~WordCompletion() {}
+
+ virtual bool shouldRestartCompletion() { return false; }
+
+ virtual ITextEditable *editor() const { return m_editor; }
+ virtual int startPosition() const { return 0; }
+
+ virtual bool supportsEditor(ITextEditable *editor)
+ { Q_UNUSED(editor); return true; }
+ virtual bool triggersCompletion(ITextEditable *editor)
+ {
+ qDebug() << "TRIGGERS?";
+ Q_UNUSED(editor); return false;
+ }
+ virtual int startCompletion(ITextEditable *editor)
+ {
+ qDebug() << "START COMPLETION";
+ Q_UNUSED(editor); return false;
+ }
+
+
+/*
+ QList<CompletionItem> getCompletions()
+ {
+ QList<CompletionItem> completionItems;
+ completions(&completionItems);
+ return completionItems;
+ }
+*/
+
+
+ /* This method should add all the completions it wants to show into
+ the list, based on the given cursor position. */
+ virtual void completions(QList<CompletionItem> *completions)
+ {
+ CompletionItem item;
+ item.text = "1st thing";
+ item.collector = this;
+ completions->append(item);
+ }
+ virtual bool typedCharCompletes(const CompletionItem &item, QChar typedChar)
+ {
+ qDebug() << "COMPLETE? " << typedChar;
+ Q_UNUSED(item); Q_UNUSED(typedChar); return false;
+ }
+
+ virtual void complete(const CompletionItem &item, QChar typedChar)
+ {
+ Q_UNUSED(item); Q_UNUSED(typedChar);
+ qDebug() << "COMPLETE: " << typedChar;
+ }
+ virtual bool partiallyComplete(const QList<CompletionItem> &completionItems)
+ {
+ qDebug() << "PARTIALLY";
+ Q_UNUSED(completionItems); return false;
+ }
+
+ virtual void cleanup() {}
+
+private:
+ int findStartOfName(int pos = -1) const;
+ bool isInComment() const;
+
+ ITextEditable *m_editor;
+ QList<CompletionItem> m_items;
+ int m_startPosition;
+};
+
+void FakeVimPluginPrivate::triggerSimpleCompletions(const QString &needle,
+ bool forward)
+{
+ FakeVimHandler *handler = qobject_cast<FakeVimHandler *>(sender());
+ if (!handler)
+ return;
+ BaseTextEditor *bt = qobject_cast<BaseTextEditor *>(handler->widget());
+ if (!bt)
+ return;
+ qDebug() << "NOT IMPLEMENTED, NEEDLE: " << needle << forward;
+ //WordCompletion *collector = new WordCompletion(bt->editableInterface());
+ TextEditor::CompletionSupport::instance()->
+ autoComplete(bt->editableInterface(), false);
+ // bt->triggerCompletions();
+}
+
void FakeVimPluginPrivate::setBlockSelection(bool on)
{
FakeVimHandler *handler = qobject_cast<FakeVimHandler *>(sender());
{
Q_UNUSED(arguments)
Q_UNUSED(errorMessage)
+/*
+ WordCompletion *completion = new WordCompletion;
+ addAutoReleasedObject(completion);
+ // Set completion settings and keep them up to date.
+ TextEditorSettings *textEditorSettings = TextEditorSettings::instance();
+ completion->setCompletionSettings(textEditorSettings->completionSettings());
+ connect(textEditorSettings,
+ SIGNAL(completionSettingsChanged(TextEditor::CompletionSettings)),
+ completion,
+ SLOT(setCompletionSettings(TextEditor::CompletionSettings)));
+*/
return d->initialize();
}