Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions XVim/XVimKeyStroke.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ NSString* XVimKeyNotationFromXVimString(XVimString* string);
@property unsigned char modifier;
@property (nonatomic, readonly) BOOL isNumeric;
@property (nonatomic, readonly) BOOL isPrintable;
@property (nonatomic, readonly) BOOL isWhitespace;

- (id)initWithCharacter:(unichar)c modifier:(unsigned char)mod;

Expand Down
12 changes: 12 additions & 0 deletions XVim/XVimKeyStroke.m
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,13 @@ NS_INLINE BOOL isPrintable(unichar c)
return !isNSFunctionKey(c) && iswprint_l(c, s_locale);
}

NS_INLINE BOOL isWhitespace(unichar c)
{
init_maps();

return !isNSFunctionKey(c) && iswspace_l(c, s_locale);
}

NS_INLINE BOOL isValidKey(NSString *key)
{
init_maps();
Expand Down Expand Up @@ -619,6 +626,11 @@ - (BOOL)isPrintable
return !_modifier && isPrintable(_character);
}

- (BOOL)isWhitespace
{
return !_modifier && isWhitespace(_character);
}

- (NSString*)keyNotation{
NSMutableString *keyStr = [[NSMutableString alloc] init];
unichar charcode = _character;
Expand Down
4 changes: 2 additions & 2 deletions XVim/XVimReplaceEvaluator.m
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ - (XVimEvaluator*)eval:(XVimKeyStroke*)keyStroke{
// Here we pass the key input to original text view.
// The input coming to this method is already handled by "Input Method"
// and the input maight be non ascii like 'あ'
if (self.oneCharMode || keyStroke.isPrintable) {
if (!keyStroke.isPrintable) {
if (self.oneCharMode || keyStroke.isPrintable || keyStroke.isWhitespace) {
if (!keyStroke.isPrintable && !keyStroke.isWhitespace) {
nextEvaluator = [XVimEvaluator invalidEvaluator];
} else if (![self.sourceView xvim_replaceCharacters:keyStroke.character count:1]) {
nextEvaluator = [XVimEvaluator invalidEvaluator];
Expand Down