diff --git a/XVim/XVimKeyStroke.h b/XVim/XVimKeyStroke.h index 33d1788e..a7864ba2 100644 --- a/XVim/XVimKeyStroke.h +++ b/XVim/XVimKeyStroke.h @@ -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; diff --git a/XVim/XVimKeyStroke.m b/XVim/XVimKeyStroke.m index d0981e37..ee63d9f3 100644 --- a/XVim/XVimKeyStroke.m +++ b/XVim/XVimKeyStroke.m @@ -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(); @@ -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; diff --git a/XVim/XVimReplaceEvaluator.m b/XVim/XVimReplaceEvaluator.m index a5564a12..269ca338 100644 --- a/XVim/XVimReplaceEvaluator.m +++ b/XVim/XVimReplaceEvaluator.m @@ -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];