Input Method Kit

2,271 views

Published on

Published in: Technology
0 Comments
6 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,271
On SlideShare
0
From Embeds
0
Number of Embeds
23
Actions
Shares
0
Downloads
31
Comments
0
Likes
6
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Input Method Kit

    1. 1. InputMethodKit IMK a.k.a zonble
    2. 2. IMK• developer • hack• NSTextView NSTextField UI developer
    3. 3. zonble
    4. 4. zonble• OpenVanilla
    5. 5. zonble• OpenVanilla• Yahoo
    6. 6. zonble• OpenVanilla• Yahoo• X1
    7. 7. zonble• OpenVanilla• Yahoo• X1• Mac
    8. 8. zonble• OpenVanilla• Yahoo• X1• Mac•
    9. 9. IMK• Mac OS X 10.5• Mac OS X 10.4 TSM …
    10. 10. Dynamic Loading vs Client/Server
    11. 11. … dylib crash Finder crash Finder crash crash…
    12. 12. IMK Input Client Input Server用來打字的應用程式 輸入法IMK client/server app app plug-in 32/64
    13. 13. crash app IMK
    14. 14. IMK Input Controller 輸入法邏輯 Input Client 用來打字的應用程式 Input Server Proxy 監聽輸入事件的 server IPC server servercontroller
    15. 15. Input Controller delegate … Delegate Input Controller 輸入法邏輯 Input Client 用來打字的應用程式 Proxy Input Server 監聽輸入事件的 server delegate Input Controller
    16. 16. Input Controllre• delegate• …
    17. 17. Delegate IMKServerInput Input Controller IMKStateSetting 輸入法邏輯 Input ClientIMKTextInput 用來打字的應用程式 Proxy Input Server 監聽輸入事件的 server
    18. 18. IMKTextInput protocol App informal protocol
    19. 19. setMarkedText:selectionRange: replacementRange:• - (void)setMarkedText:(id)string selectionRange: (NSRange)selectionRange replacementRange: (NSRange)replacementRange• method••
    20. 20. setMarkedText:selectionRange: replacementRange: Opera
    21. 21. setMarkedText:selectionRange: replacementRange:
    22. 22. setMarkedText:selectionRange: replacementRange: Nally yllan++
    23. 23. setMarkedText:selectionRange: replacementRange: iTerm2 Leafy patch :D
    24. 24. attributesForCharacterIndex:li neHeightRectangle:• - (NSDictionary*)attributesForCharacterIndex: (NSUInteger)index lineHeightRectangle: (NSRect*)lineRect• attributes• lineRect
    25. 25. attributesForCharacterIndex:li neHeightRectangle: x -30000 …Mac OS X
    26. 26.
    27. 27. IMK
    28. 28. template• Xcode project template• OpenVanilla Syrup• https://github.com/lukhnos/syrup• template :p
    29. 29. info.plist<key>TISInputSourceID</key><string>org.openvanilla.inputmethod.syrup</string> id id inputmethodnet.zonble.inputmethod.myinputmethod…
    30. 30. Info.plist<key>TISIntendedLanguage</key><string>zh-Hant</string> 10.6 bug — Security Bug =_=
    31. 31. Main.mIMKServer *server = [[IMKServer alloc]initWithName:kConnectionName bundleIdentifier:[[NSBundle mainBundle] bundleIdentifier]]; serverconnection name info.plist
    32. 32. • compile app bundle ~/ Library/Input Methods/• syrup tistool tistool -r <PATH_OF_YOUR_INPUT_METHOD>• script compile
    33. 33. • TIS Text Input Service API• TISRegisterInputSource((CFURLRef)inBund leURL)
    34. 34. protocol
    35. 35. IMKStateSetting protocol Input Controller• activateServer: • • init• deactivateServer: • • …
    36. 36. IMKServerInput protocol Input Controller delegate• • / • input client input buffer • input client • /
    37. 37. /• • – handleEvent:client: • – inputText:key:modifiers:client: • – inputText:client: –  didCommandBySelector:client:
    38. 38. – handleEvent:client:• NSEvent • -characters // • -keyCode // key code • -modifierFlags // command shift option ctrl • – inputText:key:modifiers:client:
    39. 39. modifierFlags• flags & NSShiftKeyMask // shift• flags & NSControlKeyMask // control• flags & NSAlternateKeyMask // option• flags & NSCommandKeyMask // command• flags & NSNumericPadKeyMask //•
    40. 40. Key Code• Key Code char Key Code char• Key Code QWERTY Dvorak• overrideKeyboardWithKeyboardNamed Input Client Keyboard Layout
    41. 41. characters• NSString• • -characters • -charactersIgnoringModifiers
    42. 42. – inputText:key:modifiers:client:• – handleEvent:client: NSEvent :)• NSResponder interpretKeyEvents:•
    43. 43. inputText:client: – didCommandBySelector:client: • inputText:client: • didCommandBySelector:client: NSResponder Action Messages • insertNewline: insertTab:… • NSResponder -doCommandBySelector: method action editor :)
    44. 44. inputText:client: – didCommandBySelector:client:• selector keycode• Command Selector • Shift …
    45. 45. input client• Input Client setMarkedText:selectionRange:replacement Range: • [client setMarkedText:inputString selectionRange:NSMakeRange(cursorIndex, 0) replacementRange:NSMakeRange(NSNotFound, NSNotFound)]; • selectionRange replacementRange
    46. 46. input- (void)commitComposition:(id)client{ [client insertText:_composingBufferreplacementRange:NSMakeRange(NSNotFound, NSNotFound)]; //
    47. 47. • IMK IMKCandidate• class
    48. 48. IMKCandidate•• Grid•••
    49. 49. IMKCandidate•• setSelectionkeys: keyCode …• Shift+
    50. 50. • NSWindow sublcass• main window key window window level• window level 3D level CGShieldingWindowLevel() + 1 • input client window level
    51. 51. InputController• -menu
    52. 52. IMKTextInput protocol
    53. 53. IMKTextInput• IMKTextInput input client protocol input client• • input client window window frame input client
    54. 54. IMKTextInput• 10.7 ( TextEdit•• - (NSDictionary*)attributesForChara cterIndex:(NSUInteger)index lineHeightRectangle: (NSRect*)lineRect
    55. 55. • Xcode attach process Xcode Editor• Xcode crash• Xcode debug NSLog Console
    56. 56. • 10.7 Sandboxing • Input Methods
    57. 57.
    58. 58. •••
    59. 59. ••• …

    ×