Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
eb132a4c
Commit
eb132a4c
authored
Dec 25, 2008
by
hjk
Committed by
Roberto Raggi
Dec 29, 2008
Browse files
partial implementation of 'e' and 'E'
parent
9e5e5d1d
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/plugins/fakevim/handler.cpp
View file @
eb132a4c
...
...
@@ -120,7 +120,9 @@ public:
void
scrollToLineInDocument
(
int
line
);
void
moveToFirstNonBlankOnLine
();
void
moveWord
(
int
repeat
,
bool
simple
);
void
moveToNextWord
(
int
repeat
,
bool
simple
);
void
moveToWordBegin
(
int
repeat
,
bool
simple
);
void
moveToWordEnd
(
int
repeat
,
bool
simple
);
FakeVimHandler
*
q
;
Mode
m_mode
;
...
...
@@ -301,6 +303,12 @@ void FakeVimHandler::Private::handleCommandMode(int key, const QString &text)
}
else
if
(
key
==
'A'
)
{
m_tc
.
movePosition
(
EndOfLine
,
MoveAnchor
);
m_mode
=
InsertMode
;
}
else
if
(
key
==
'b'
)
{
moveToWordBegin
(
count
(),
false
);
finishMovement
();
}
else
if
(
key
==
'B'
)
{
moveToWordBegin
(
count
(),
true
);
finishMovement
();
}
else
if
(
key
==
'c'
)
{
m_submode
=
ChangeSubMode
;
}
else
if
(
key
==
'C'
)
{
...
...
@@ -315,6 +323,12 @@ void FakeVimHandler::Private::handleCommandMode(int key, const QString &text)
m_submode
=
DeleteSubMode
;
m_tc
.
movePosition
(
EndOfLine
,
KeepAnchor
);
finishMovement
();
}
else
if
(
key
==
'e'
)
{
moveToWordEnd
(
count
(),
false
);
finishMovement
();
}
else
if
(
key
==
'E'
)
{
moveToWordEnd
(
count
(),
true
);
finishMovement
();
}
else
if
(
key
==
'h'
||
key
==
Key_Left
)
{
int
n
=
qMin
(
count
(),
leftDist
());
if
(
m_fakeEnd
&&
m_tc
.
block
().
length
()
>
1
)
...
...
@@ -370,10 +384,10 @@ void FakeVimHandler::Private::handleCommandMode(int key, const QString &text)
}
else
if
(
key
==
'u'
)
{
m_editor
->
undo
();
}
else
if
(
key
==
'w'
)
{
moveWord
(
count
(),
false
);
move
ToNext
Word
(
count
(),
false
);
finishMovement
();
}
else
if
(
key
==
'W'
)
{
moveWord
(
count
(),
true
);
move
ToNext
Word
(
count
(),
true
);
finishMovement
();
}
else
if
(
key
==
'x'
)
{
// = "dl"
if
(
atEol
())
...
...
@@ -528,7 +542,43 @@ static int charClass(QChar c, bool simple)
return
c
.
isSpace
()
?
0
:
1
;
}
void
FakeVimHandler
::
Private
::
moveWord
(
int
repeat
,
bool
simple
)
void
FakeVimHandler
::
Private
::
moveToWordBegin
(
int
repeat
,
bool
simple
)
{
QTextDocument
*
doc
=
m_tc
.
document
();
int
n
=
lastPositionInDocument
()
-
1
;
int
lastClass
=
0
;
while
(
m_tc
.
position
()
<
n
)
{
QChar
c
=
doc
->
characterAt
(
m_tc
.
position
());
int
thisClass
=
charClass
(
c
,
simple
);
if
(
thisClass
!=
lastClass
&&
thisClass
!=
0
)
--
repeat
;
if
(
repeat
==
-
1
)
return
;
lastClass
=
thisClass
;
m_tc
.
movePosition
(
Right
,
KeepAnchor
,
1
);
}
}
void
FakeVimHandler
::
Private
::
moveToWordEnd
(
int
repeat
,
bool
simple
)
{
QTextDocument
*
doc
=
m_tc
.
document
();
int
n
=
lastPositionInDocument
()
-
1
;
int
lastClass
=
0
;
while
(
m_tc
.
position
()
<
n
)
{
QChar
c
=
doc
->
characterAt
(
m_tc
.
position
());
int
thisClass
=
charClass
(
c
,
simple
);
if
(
thisClass
!=
lastClass
&&
lastClass
!=
0
)
--
repeat
;
if
(
repeat
==
-
1
)
{
m_tc
.
movePosition
(
Left
,
KeepAnchor
,
1
);
return
;
}
lastClass
=
thisClass
;
m_tc
.
movePosition
(
Right
,
KeepAnchor
,
1
);
}
}
void
FakeVimHandler
::
Private
::
moveToNextWord
(
int
repeat
,
bool
simple
)
{
// FIXME: 'w' should stop on empty lines, too
QTextDocument
*
doc
=
m_tc
.
document
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment