diff --git a/English.lproj/MainMenu.nib/classes.nib b/English.lproj/MainMenu.nib/classes.nib
deleted file mode 100644
index 71089e9..0000000
--- a/English.lproj/MainMenu.nib/classes.nib
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- IBClasses = (
- {
- CLASS = ConversionEngine;
- LANGUAGE = ObjC;
- OUTLETS = {
- formatter = NSNumberFormatter;
- };
- SUPERCLASS = NSObject;
- },
- {
- CLASS = FirstResponder;
- LANGUAGE = ObjC;
- SUPERCLASS = NSObject;
- }
- );
- IBVersion = 1;
-}
\ No newline at end of file
diff --git a/English.lproj/MainMenu.nib/designable.nib b/English.lproj/MainMenu.nib/designable.nib
new file mode 100644
index 0000000..b7a9ab4
--- /dev/null
+++ b/English.lproj/MainMenu.nib/designable.nib
@@ -0,0 +1,59 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/English.lproj/MainMenu.nib/info.nib b/English.lproj/MainMenu.nib/info.nib
deleted file mode 100644
index 805e1ff..0000000
--- a/English.lproj/MainMenu.nib/info.nib
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
- IBDocumentLocation
- 94 134 356 240 0 0 1280 778
- IBFramework Version
- 461.0
- IBSystem Version
- 9A439
-
-
diff --git a/English.lproj/MainMenu.nib/keyedobjects.nib b/English.lproj/MainMenu.nib/keyedobjects.nib
index 7d65dd0..4bed0b8 100644
Binary files a/English.lproj/MainMenu.nib/keyedobjects.nib and b/English.lproj/MainMenu.nib/keyedobjects.nib differ
diff --git a/hallelujah.xcodeproj/project.pbxproj b/hallelujah.xcodeproj/project.pbxproj
index 3c0fa90..3fc6203 100644
--- a/hallelujah.xcodeproj/project.pbxproj
+++ b/hallelujah.xcodeproj/project.pbxproj
@@ -17,6 +17,7 @@
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
E93074B70A5C264700470842 /* InputMethodKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E93074B60A5C264700470842 /* InputMethodKit.framework */; };
+ F109B4911E1A83AF00AA7A41 /* AnnotationWinController.m in Sources */ = {isa = PBXBuildFile; fileRef = F109B48F1E1A83AF00AA7A41 /* AnnotationWinController.m */; };
F1CDA2AF1B551A55005086C6 /* InputController.h in Sources */ = {isa = PBXBuildFile; fileRef = F1CDA2A41B55180A005086C6 /* InputController.h */; };
F1CDA2B01B551A55005086C6 /* InputController.m in Sources */ = {isa = PBXBuildFile; fileRef = F1CDA2A51B55180A005086C6 /* InputController.m */; };
F1CDA2B11B551A55005086C6 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = F1CDA2A61B55180A005086C6 /* main.m */; };
@@ -41,6 +42,8 @@
8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; };
8D1107320486CEB800E47090 /* hallelujah.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = hallelujah.app; sourceTree = BUILT_PRODUCTS_DIR; };
E93074B60A5C264700470842 /* InputMethodKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = InputMethodKit.framework; path = /System/Library/Frameworks/InputMethodKit.framework; sourceTree = ""; };
+ F109B48F1E1A83AF00AA7A41 /* AnnotationWinController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AnnotationWinController.m; path = src/AnnotationWinController.m; sourceTree = ""; };
+ F109B4901E1A83AF00AA7A41 /* AnnotationWinController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AnnotationWinController.h; path = src/AnnotationWinController.h; sourceTree = ""; };
F1CDA2A41B55180A005086C6 /* InputController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = InputController.h; path = src/InputController.h; sourceTree = ""; };
F1CDA2A51B55180A005086C6 /* InputController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = InputController.m; path = src/InputController.m; sourceTree = ""; };
F1CDA2A61B55180A005086C6 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = src/main.m; sourceTree = ""; };
@@ -65,6 +68,8 @@
080E96DDFE201D6D7F000001 /* Classes */ = {
isa = PBXGroup;
children = (
+ F109B48F1E1A83AF00AA7A41 /* AnnotationWinController.m */,
+ F109B4901E1A83AF00AA7A41 /* AnnotationWinController.h */,
F1CDA2A41B55180A005086C6 /* InputController.h */,
F1CDA2A51B55180A005086C6 /* InputController.m */,
F1CDA2A61B55180A005086C6 /* main.m */,
@@ -218,6 +223,7 @@
F1CDA2B11B551A55005086C6 /* main.m in Sources */,
F1CDA2B41B551A55005086C6 /* PJTernarySearchTree.h in Sources */,
F1CDA2B51B551A55005086C6 /* PJTernarySearchTree.m in Sources */,
+ F109B4911E1A83AF00AA7A41 /* AnnotationWinController.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/src/AnnotationWinController.h b/src/AnnotationWinController.h
new file mode 100644
index 0000000..0e20486
--- /dev/null
+++ b/src/AnnotationWinController.h
@@ -0,0 +1,15 @@
+#import
+
+@interface AnnotationWinController : NSWindowController{
+
+}
+
+- (void)showWindow:(NSPoint)origin;
+
+- (void)hideWindow;
+
+- (void)setAnnotation:(NSString *)annotation;
+
++ (id)sharedController;
+
+@end
diff --git a/src/AnnotationWinController.m b/src/AnnotationWinController.m
new file mode 100644
index 0000000..98ed4e8
--- /dev/null
+++ b/src/AnnotationWinController.m
@@ -0,0 +1,53 @@
+#import "AnnotationWinController.h"
+
+static AnnotationWinController *sharedController;
+
+@interface AnnotationWinController ()
+ @property (retain, nonatomic) IBOutlet NSPanel *panel;
+ @property (retain, nonatomic) IBOutlet NSTextView *view;
+@end
+
+@implementation AnnotationWinController
+@synthesize view;
+@synthesize panel;
+
++ (id)sharedController
+{
+ return sharedController;
+}
+
+-(void)awakeFromNib{
+ sharedController = self;
+ [[self panel] setStyleMask:NSBorderlessWindowMask];
+ [[self panel] setOpaque:NO];
+ [[self panel] setBackgroundColor:[NSColor colorWithCalibratedWhite:1.0 alpha:0.0]];
+ [self hideWindow];
+}
+
+- (void)showWindow:(NSPoint)origin {
+ NSSize size;
+ size.width = 170;
+ size.height = 258;
+ [[self panel] setMinSize:size];
+ [[self panel] setContentSize: size];
+ [[self panel] setAlphaValue: 0.9];
+
+ [[self panel] setFrameTopLeftPoint: origin];
+ [[self panel] orderFront:nil];
+ [[self panel] setLevel: CGShieldingWindowLevel() + 1];
+ [[self panel] setAutodisplay:YES];
+}
+
+- (void)hideWindow{
+// [[self panel] orderOut:nil];
+ NSRect rect;
+ rect.size.width = 0;
+ rect.size.height = 0;
+ [[self panel] setFrame:rect display:NO];
+}
+
+- (void)setAnnotation:(NSString *)annotation{
+ [[self view] setString:annotation];
+}
+
+@end
diff --git a/src/InputController.h b/src/InputController.h
index de837ac..2d562bd 100644
--- a/src/InputController.h
+++ b/src/InputController.h
@@ -1,5 +1,6 @@
#import
#import
+#import
@interface InputController : IMKInputController {
NSMutableString* _composedBuffer;
@@ -10,6 +11,7 @@
BOOL _is_cmd_mode;
NSUInteger _lastModifiers[2];
NSEventType _lastEventTypes[2];
+ AnnotationWinController* _annotationWin;
}
-(NSMutableString*)composedBuffer;
diff --git a/src/InputController.m b/src/InputController.m
index f08aef5..0b5eea3 100644
--- a/src/InputController.m
+++ b/src/InputController.m
@@ -4,7 +4,6 @@
#import
extern IMKCandidates* sharedCandidates;
-extern IMKCandidates* subCandidates;
extern PJTernarySearchTree* trie;
extern NSMutableDictionary* wordsWithFrequency;
extern BOOL defaultEnglishMode;
@@ -158,7 +157,7 @@ -(void)reset{
[self setOriginalBuffer:@""];
_insertionIndex = 0;
[sharedCandidates hide];
- [subCandidates hide];
+ [_annotationWin hideWindow];
}
-(NSMutableString*)composedBuffer{
@@ -283,40 +282,43 @@ - (void)candidateSelectionChanged:(NSAttributedString*)candidateString{
_insertionIndex = [candidateString length];
- [self showSubCandidates: candidateString];
+ [self showAnnotation: candidateString];
}
--(void)showSubCandidates:(NSAttributedString*)candidateString{
- NSInteger candidateIdentifier = [sharedCandidates selectedCandidate];
- NSInteger subCandidateStringIdentifier = [sharedCandidates candidateStringIdentifier: candidateString];
-
- if (candidateIdentifier == subCandidateStringIdentifier) {
- NSArray* subList = [self getSubCandidates: candidateString];
- if(subList && subList.count > 0){
- NSString* phoneticSymbol = [self getPhoneticSymbolOfWord: candidateString];
- if([phoneticSymbol length] > 0){
- NSArray* list = @[phoneticSymbol];
- [subCandidates setCandidateData: [list arrayByAddingObjectsFromArray:subList]];
- }else{
- [subCandidates setCandidateData: subList];
- }
-
- NSRect currentFrame = [sharedCandidates candidateFrame];
- NSPoint windowInsertionPoint = NSMakePoint(NSMaxX(currentFrame), NSMaxY(currentFrame));
- [subCandidates setCandidateFrameTopLeft:windowInsertionPoint];
-
-
- [sharedCandidates attachChild:subCandidates toCandidate:(NSInteger)candidateIdentifier type:kIMKSubList];
- [sharedCandidates showChild];
+- (void)activateServer:(id)sender {
+ if (_annotationWin == nil){
+ _annotationWin = [AnnotationWinController sharedController];
+ }
+}
+
+- (void)deactivateServer:(id)sender {
+ [_annotationWin hideWindow];
+}
+
+-(void)showAnnotation:(NSAttributedString*)candidateString{
+ NSArray* subList = [self getTranslations: candidateString];
+ if(subList && subList.count > 0){
+ NSString* translations;
+ NSString* phoneticSymbol = [self getPhoneticSymbolOfWord: candidateString];
+ if([phoneticSymbol length] > 0){
+ NSArray* list = @[phoneticSymbol];
+ translations = [[list arrayByAddingObjectsFromArray:subList] componentsJoinedByString: @"\n"];
}else{
- [subCandidates hide];
+ translations = [subList componentsJoinedByString: @"\n"];
}
+ NSRect currentFrame = [sharedCandidates candidateFrame];
+ NSRect tempRect;
+ [_currentClient attributesForCharacterIndex:0 lineHeightRectangle:&tempRect];
+ NSPoint windowInsertionPoint = NSMakePoint(NSMinX(tempRect), NSMinY(tempRect));
+ windowInsertionPoint.x = windowInsertionPoint.x + currentFrame.size.width;
+ [_annotationWin setAnnotation: translations];
+ [_annotationWin showWindow: windowInsertionPoint];
}else{
- [subCandidates hide];
+ [_annotationWin hideWindow];
}
}
--(NSArray*)getSubCandidates: (NSAttributedString*)candidateString{
+-(NSArray*)getTranslations: (NSAttributedString*)candidateString{
return translationes[[[candidateString string] lowercaseString]];
}
diff --git a/src/main.m b/src/main.m
index 482931b..5a179ef 100644
--- a/src/main.m
+++ b/src/main.m
@@ -5,7 +5,6 @@
const NSString* kConnectionName = @"Hallelujah_1_Connection";
IMKServer* server;
IMKCandidates* sharedCandidates;
-IMKCandidates* subCandidates;
PJTernarySearchTree* trie;
NSMutableDictionary* wordsWithFrequency;
BOOL defaultEnglishMode;
@@ -70,7 +69,6 @@ int main(int argc, char *argv[])
bundleIdentifier:[[NSBundle mainBundle] bundleIdentifier]];
sharedCandidates = [[IMKCandidates alloc] initWithServer:server panelType:kIMKSingleColumnScrollingCandidatePanel];
- subCandidates = [[IMKCandidates alloc] initWithServer:nil panelType:kIMKSingleColumnScrollingCandidatePanel];
if (!sharedCandidates){
NSLog(@"Fatal error: Cannot initialize shared candidate panel with connection %@.", kConnectionName);
@@ -88,4 +86,4 @@ int main(int argc, char *argv[])
[[NSApplication sharedApplication] run];
return 0;
-}
\ No newline at end of file
+}