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
Tobias Hunger
qt-creator
Commits
44c02264
Commit
44c02264
authored
Apr 16, 2010
by
hjk
Browse files
fakevim: make :map work for non-ASCII characters
parent
ac366209
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/plugins/fakevim/fakevimhandler.cpp
View file @
44c02264
...
...
@@ -288,7 +288,7 @@ class Input
{
public:
Input
()
:
key
(
0
),
unmodified
(
0
),
modifiers
(
0
)
{}
Input
(
c
har
x
)
:
key
(
x
),
unmodified
(
0
),
modifiers
(
0
),
text
(
1
,
QLatin1Char
(
x
)
)
{}
Input
(
QC
har
x
)
:
key
(
x
.
unicode
()
),
unmodified
(
0
),
modifiers
(
0
),
text
(
x
)
{}
Input
(
int
k
,
int
u
,
int
m
,
QString
t
)
:
key
(
k
),
unmodified
(
u
),
modifiers
(
m
),
text
(
t
)
{}
...
...
@@ -365,7 +365,7 @@ private:
if
(
needle
.
size
()
>
haystack
.
size
())
return
false
;
for
(
int
i
=
0
;
i
!=
needle
.
size
();
++
i
)
{
if
(
needle
.
at
(
i
).
key
!=
haystack
.
at
(
i
).
key
)
if
(
needle
.
at
(
i
).
text
!=
haystack
.
at
(
i
).
text
)
return
false
;
}
return
true
;
...
...
@@ -2564,20 +2564,19 @@ static bool isSubstitution(const QString &cmd0, QStringList *result)
return
true
;
}
bool
FakeVimHandler
::
Private
::
handleMapping
(
const
QString
&
cmd0
)
bool
FakeVimHandler
::
Private
::
handleMapping
(
const
QString
&
line
)
{
QByteArray
line
=
cmd0
.
toLatin1
();
int
pos1
=
line
.
indexOf
(
' '
);
int
pos1
=
line
.
indexOf
(
QLatin1Char
(
' '
));
if
(
pos1
==
-
1
)
return
false
;
int
pos2
=
line
.
indexOf
(
' '
,
pos1
+
1
);
int
pos2
=
line
.
indexOf
(
QLatin1Char
(
' '
)
,
pos1
+
1
);
if
(
pos2
==
-
1
)
return
false
;
QByteArray
modes
;
enum
Type
{
Map
,
Noremap
,
Unmap
}
type
;
QByteArray
cmd
=
line
.
left
(
pos1
);
QByteArray
cmd
=
line
.
left
(
pos1
)
.
toLatin1
()
;
// Strange formatting. But everything else is even uglier.
if
(
cmd
==
"map"
)
{
modes
=
"nvo"
;
type
=
Map
;
}
else
...
...
@@ -2615,12 +2614,12 @@ bool FakeVimHandler::Private::handleMapping(const QString &cmd0)
else
return
false
;
Q
ByteArray
lhs
=
line
.
mid
(
pos1
+
1
,
pos2
-
pos1
-
1
);
Q
ByteArray
rhs
=
line
.
mid
(
pos2
+
1
);
Q
String
lhs
=
line
.
mid
(
pos1
+
1
,
pos2
-
pos1
-
1
);
Q
String
rhs
=
line
.
mid
(
pos2
+
1
);
Inputs
key
;
foreach
(
c
har
c
,
lhs
)
foreach
(
QC
har
c
,
lhs
)
key
.
append
(
Input
(
c
));
qDebug
()
<<
"MAPPING: "
<<
modes
<<
lhs
<<
rhs
;
//
qDebug() << "MAPPING: " << modes << lhs << rhs;
switch
(
type
)
{
case
Unmap
:
foreach
(
char
c
,
modes
)
...
...
@@ -2632,7 +2631,7 @@ bool FakeVimHandler::Private::handleMapping(const QString &cmd0)
// Fall through.
case
Noremap
:
{
Inputs
inputs
;
foreach
(
c
har
c
,
rhs
)
foreach
(
QC
har
c
,
rhs
)
inputs
.
append
(
Input
(
c
));
foreach
(
char
c
,
modes
)
m_mappings
[
c
].
insert
(
key
,
inputs
);
...
...
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