-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTEAACController.m
56 lines (44 loc) · 1.34 KB
/
TEAACController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//
// TEAACController.m
// TEAAC
//
// Created by 北䑓 如法 (KITADAI, Yukinori) on 09/08/20.
// Copyright 2009 EXTRAORDINARY. All rights reserved.
//
#import "TEAACController.h"
#import <objc/objc-class.h>
@implementation NSObject (TerminalEastAsianAmbiguousClearer)
- (BOOL)isDoubleWidthCharacter:(int)unicode
{
//http://unicode.org/charts/PDF/UFF00.pdf
//http://unicode.org/charts/PDF/U0080.pdf
if ((unicode <= 0xff && unicode != 0x00d7) || (unicode >= 0xff61 && unicode <= 0xffdf))
return NO;
return YES;
}
- (unsigned int)myLogicalWidthForCharacter:(int)c
{
if([self isDoubleWidthCharacter:c])
return 2;
return 1;
}
- (unsigned int)myDisplayWidthForCharacter:(int)c
{
if([self isDoubleWidthCharacter:c])
return 2;
return 1;
}
@end
@implementation TEAACController
+ (void) load
{
Class class = objc_getClass("TTLogicalScreen");
Method logi = class_getInstanceMethod(class, @selector(logicalWidthForCharacter:));
Method myLogi = class_getInstanceMethod(class, @selector(myLogicalWidthForCharacter:));
method_exchangeImplementations(logi, myLogi);
Method disp = class_getInstanceMethod(class, @selector(displayWidthForCharacter:));
Method myDisp = class_getInstanceMethod(class, @selector(myDisplayWidthForCharacter:));
method_exchangeImplementations(disp, myDisp);
NSLog(@"Terminal East Asian Ambiguous Clearer started.");
}
@end