SlideShare a Scribd company logo
InputMethodKit
     IMK
      a.k.a zonble
IMK
•               developer

    •               hack

•               NSTextView   NSTextField
                                    UI
    developer
zonble
zonble
• OpenVanilla
zonble
• OpenVanilla
• Yahoo
zonble
• OpenVanilla
• Yahoo
•                X1
zonble
• OpenVanilla
• Yahoo
•                X1

•                     Mac
zonble
• OpenVanilla
• Yahoo
•                X1

•                     Mac

•
IMK

• Mac OS X 10.5
• Mac OS X 10.4         TSM


      …
Dynamic Loading
      vs
 Client/Server
…
    dylib                      crash


                              Finder
                 crash
        Finder        crash
             crash…
IMK

  Input Client               Input Server
用來打字的應用程式                       輸入法




IMK                client/server
                 app           app          plug-in
                 32/64
crash    app




   IMK
IMK
                                            Input Controller
                                              輸入法邏輯




          Input Client
        用來打字的應用程式
                                      Input Server
                         Proxy      監聽輸入事件的 server




                                                IPC
                                 server server
controller
Input Controller
                        delegate                             …
                                        Delegate




                                          Input Controller
                                            輸入法邏輯




        Input Client
      用來打字的應用程式

                       Proxy

                                   Input Server
                                 監聽輸入事件的 server




                               delegate
     Input Controller
Input Controllre

•
    delegate

•
               …
Delegate     IMKServerInput




                                                 Input Controller     IMKStateSetting
                                                   輸入法邏輯




                 Input Client
IMKTextInput   用來打字的應用程式

                                Proxy

                                          Input Server
                                        監聽輸入事件的 server
IMKTextInput
  protocol
                   App
     informal protocol
setMarkedText:selectionRange:
     replacementRange:
•   - (void)setMarkedText:(id)string selectionRange:
    (NSRange)selectionRange replacementRange:
    (NSRange)replacementRange

•        method



•
•
setMarkedText:selectionRange:
     replacementRange:




   Opera
setMarkedText:selectionRange:
     replacementRange:
setMarkedText:selectionRange:
     replacementRange:




       Nally
               yllan++
setMarkedText:selectionRange:
     replacementRange:




          iTerm2
      Leafy        patch   :D
attributesForCharacterIndex:li
       neHeightRectangle:
• - (NSDictionary*)attributesForCharacterIndex:
  (NSUInteger)index lineHeightRectangle:
    (NSRect*)lineRect

•   attributes



•   lineRect
attributesForCharacterIndex:li
      neHeightRectangle:




                     x    -30000
                 …
Mac OS X
…
IMK
template
•     Xcode                     project
    template

•          OpenVanilla Syrup

• https://github.com/lukhnos/syrup
•                      template :p
info.plist
<key>TISInputSourceID</key>
<string>org.openvanilla.inputmethod.syrup</string>

                                 id
                        id



  inputmethod
net.zonble.inputmethod.myinputmethod…
Info.plist

<key>TISIntendedLanguage</key>
<string>zh-Hant</string>
  10.6
     bug
           —               Security Bug
               =_=
Main.m
IMKServer *server = [[IMKServer alloc]
initWithName:kConnectionName bundleIdentifier:
[[NSBundle mainBundle] bundleIdentifier]];

                                 server
connection name     info.plist
•      compile         app bundle         ~/
    Library/Input Methods/
•          syrup              tistool
                     tistool -r
    <PATH_OF_YOUR_INPUT_METHOD>
•                    script     compile
•        TIS Text Input Service API

• TISRegisterInputSource((CFURLRef)inBund
  leURL)
protocol
IMKStateSetting protocol
            Input Controller
•   activateServer:

    •
    •                   init

•   deactivateServer:

    •
    •                              …
IMKServerInput protocol
    Input Controller   delegate

•
    •   /

    •   input client     input buffer

    •                  input client

    •   /
/
•

    •        – handleEvent:client:

    •        – inputText:key:modifiers:client:

    •              – inputText:client:    – 
        didCommandBySelector:client:
– handleEvent:client:
•                    NSEvent

    •   -characters //

    •   -keyCode //            key code

    •   -modifierFlags //                     command
        shift    option ctrl

    •           – inputText:key:modifiers:client:
modifierFlags
•   flags & NSShiftKeyMask //       shift

•   flags & NSControlKeyMask //         control

•   flags & NSAlternateKeyMask //           option

•   flags & NSCommandKeyMask //             command

•   flags & NSNumericPadKeyMask //

•
Key Code
•     Key Code                char
             Key Code                 char

•                                Key Code
                   QWERTY            Dvorak



•     overrideKeyboardWithKeyboardNamed
    Input Client   Keyboard Layout
characters
•           NSString



•
    • -characters
    • -charactersIgnoringModifiers
– inputText:key:modifiers:client:

•             – handleEvent:client:
    NSEvent                            :)

•   NSResponder      interpretKeyEvents:

•
inputText:client:                      – 
didCommandBySelector:client:
 • inputText:client:
 • didCommandBySelector:client:
  NSResponder          Action Messages

  •   insertNewline:    insertTab:…

  •        NSResponder        -doCommandBySelector:
           method                          action
           editor                     :)
inputText:client:                – 
didCommandBySelector:client:

•              selector        keycode

•                             Command
    Selector

    •                 Shift              …
input client
•              Input Client
    setMarkedText:selectionRange:replacement
    Range:
    •   [client setMarkedText:inputString
        selectionRange:NSMakeRange(cursorIndex, 0)
        replacementRange:NSMakeRange(NSNotFound,
        NSNotFound)];

    •   selectionRange
        replacementRange
input
- (void)commitComposition:(id)client
{
   [client insertText:_composingBuffer
replacementRange:NSMakeRange(NSNotFou
nd, NSNotFound)];
	

 //
• IMK   IMKCandidate



•             class
IMKCandidate
•
•           Grid

•
•

•
IMKCandidate
•

•              setSelectionkeys:
     keyCode                  …

•                Shift+
•              NSWindow sublcass

•                 main window          key window
        window level

•                           window level
        3D                                     level
        CGShieldingWindowLevel() + 1

    •        input client       window level
InputController


•          -menu
IMKTextInput
  protocol
IMKTextInput
•   IMKTextInput         input client
    protocol                            input client



•
    •               input client    window
         window    frame
               input client
IMKTextInput
•       10.7
    (     TextEdit


•

•              -
    (NSDictionary*)attributesForChara
    cterIndex:(NSUInteger)index
    lineHeightRectangle:
    (NSRect*)lineRect
Input Method Kit
•               Xcode attach
    process            Xcode      Editor



•             Xcode crash

•                       Xcode        debug
              NSLog            Console
• 10.7 Sandboxing
 •                  Input Methods
Input Method Kit
喻
•
•




•
•
•


•
    …
Input Method Kit

More Related Content

What's hot (20)

PDF
promgen - prometheus managemnet tool / simpleclient_java hacks @ Prometheus c...
Tokuhiro Matsuno
 
PDF
What Can Compilers Do for Us?
National Cheng Kung University
 
PDF
Javaコードが速く実⾏される秘密 - JITコンパイラ⼊⾨(JJUG CCC 2020 Fall講演資料)
NTT DATA Technology & Innovation
 
PDF
モバイルアプリの高速で安定したビルドを支えるJenkins運用術
KLab Inc. / Tech
 
PDF
Build Programming Language Runtime with LLVM
National Cheng Kung University
 
PDF
モバイルオンラインゲームでの大規模観戦とチート対策 〜自社製リアルタイム通信システム「WSNet2」の事例〜
KLab Inc. / Tech
 
PDF
LLVM 總是打開你的心:從電玩模擬器看編譯器應用實例
National Cheng Kung University
 
PDF
Go言語によるwebアプリの作り方
Yasutaka Kawamoto
 
PDF
見終わったらすぐできる! VMware & Nutanix ユーザーのためのTerraform Cloud
Wataru Unno
 
PDF
For the Greater Good: Leveraging VMware's RPC Interface for fun and profit by...
CODE BLUE
 
PDF
Embedded Android : System Development - Part III (Audio / Video HAL)
Emertxe Information Technologies Pvt Ltd
 
PDF
How A Compiler Works: GNU Toolchain
National Cheng Kung University
 
PDF
Dockerイメージ管理の内部構造
Etsuji Nakai
 
PDF
GNU ld的linker script簡介
Wen Liao
 
PDF
TDOH x 台科 pwn課程
Weber Tsai
 
PDF
A whirlwind tour of the LLVM optimizer
Nikita Popov
 
PDF
from Source to Binary: How GNU Toolchain Works
National Cheng Kung University
 
PDF
バイナリアンを目指して For a binaryen
Eyes, JAPAN
 
PDF
[COSCUP 2022] Kotlin Collection 遊樂園
Shengyou Fan
 
PPTX
Android audio system(audioflinger)
fefe7270
 
promgen - prometheus managemnet tool / simpleclient_java hacks @ Prometheus c...
Tokuhiro Matsuno
 
What Can Compilers Do for Us?
National Cheng Kung University
 
Javaコードが速く実⾏される秘密 - JITコンパイラ⼊⾨(JJUG CCC 2020 Fall講演資料)
NTT DATA Technology & Innovation
 
モバイルアプリの高速で安定したビルドを支えるJenkins運用術
KLab Inc. / Tech
 
Build Programming Language Runtime with LLVM
National Cheng Kung University
 
モバイルオンラインゲームでの大規模観戦とチート対策 〜自社製リアルタイム通信システム「WSNet2」の事例〜
KLab Inc. / Tech
 
LLVM 總是打開你的心:從電玩模擬器看編譯器應用實例
National Cheng Kung University
 
Go言語によるwebアプリの作り方
Yasutaka Kawamoto
 
見終わったらすぐできる! VMware & Nutanix ユーザーのためのTerraform Cloud
Wataru Unno
 
For the Greater Good: Leveraging VMware's RPC Interface for fun and profit by...
CODE BLUE
 
Embedded Android : System Development - Part III (Audio / Video HAL)
Emertxe Information Technologies Pvt Ltd
 
How A Compiler Works: GNU Toolchain
National Cheng Kung University
 
Dockerイメージ管理の内部構造
Etsuji Nakai
 
GNU ld的linker script簡介
Wen Liao
 
TDOH x 台科 pwn課程
Weber Tsai
 
A whirlwind tour of the LLVM optimizer
Nikita Popov
 
from Source to Binary: How GNU Toolchain Works
National Cheng Kung University
 
バイナリアンを目指して For a binaryen
Eyes, JAPAN
 
[COSCUP 2022] Kotlin Collection 遊樂園
Shengyou Fan
 
Android audio system(audioflinger)
fefe7270
 

Similar to Input Method Kit (20)

PPTX
Connecting C++ and JavaScript on the Web with Embind
Chad Austin
 
PDF
Samantha Wang [InfluxData] | Data Collection Overview | InfluxDays 2022
InfluxData
 
PPTX
An introduction to the API for OnTime for IBM
ontimesuite
 
PDF
UA Mobile 2012 (English)
dmalykhanov
 
PDF
Dino2 - the Amazing Evolution of the VA Smalltalk Virtual Machine
ESUG
 
PDF
Gene Hynson [InfluxData] | How We Built the MQTT Native Collector | InfluxDay...
InfluxData
 
PPTX
System insight without Interference
Tony Tam
 
PDF
Runtime Bytecode Transformation for Smalltalk
ESUG
 
PPTX
MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...
MongoDB
 
PPTX
basic arithmetic operations in linux environment
fr0gkweeen
 
PDF
E yantra robot abstractions
Akshar Desai
 
PDF
Android IPC Mechanism
Lihan Chen
 
PPTX
Discovering Vulnerabilities For Fun and Profit
Abhisek Datta
 
PDF
y3dips hacking priv8 network
idsecconf
 
PDF
idsecconf2010-hacking priv8 network
Ammar WK
 
PDF
Wayland intro with_i18n_hacks
Peng Wu
 
PPTX
Swagger codegen tool to generate REST services
dhanup123
 
PDF
Over-the-Air: How we Remotely Compromised the Gateway, BCM, and Autopilot ECU...
Priyanka Aash
 
PDF
[shaderx7] 8.1 Cross-Platform Rendering Thread : Design and Implementation
종빈 오
 
PPTX
How bol.com makes sense of its logs, using the Elastic technology stack.
Renzo Tomà
 
Connecting C++ and JavaScript on the Web with Embind
Chad Austin
 
Samantha Wang [InfluxData] | Data Collection Overview | InfluxDays 2022
InfluxData
 
An introduction to the API for OnTime for IBM
ontimesuite
 
UA Mobile 2012 (English)
dmalykhanov
 
Dino2 - the Amazing Evolution of the VA Smalltalk Virtual Machine
ESUG
 
Gene Hynson [InfluxData] | How We Built the MQTT Native Collector | InfluxDay...
InfluxData
 
System insight without Interference
Tony Tam
 
Runtime Bytecode Transformation for Smalltalk
ESUG
 
MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...
MongoDB
 
basic arithmetic operations in linux environment
fr0gkweeen
 
E yantra robot abstractions
Akshar Desai
 
Android IPC Mechanism
Lihan Chen
 
Discovering Vulnerabilities For Fun and Profit
Abhisek Datta
 
y3dips hacking priv8 network
idsecconf
 
idsecconf2010-hacking priv8 network
Ammar WK
 
Wayland intro with_i18n_hacks
Peng Wu
 
Swagger codegen tool to generate REST services
dhanup123
 
Over-the-Air: How we Remotely Compromised the Gateway, BCM, and Autopilot ECU...
Priyanka Aash
 
[shaderx7] 8.1 Cross-Platform Rendering Thread : Design and Implementation
종빈 오
 
How bol.com makes sense of its logs, using the Elastic technology stack.
Renzo Tomà
 
Ad

More from Weizhong Yang (20)

PDF
Flutter BLE
Weizhong Yang
 
PDF
怎樣在 Flutter app 中使用 Google Maps
Weizhong Yang
 
PDF
關於延長役期這件事情
Weizhong Yang
 
PDF
Dart null safety
Weizhong Yang
 
PDF
導入 Flutter 前你應該知道的事
Weizhong Yang
 
PDF
Github Actions
Weizhong Yang
 
PDF
iPlayground: CarPlay and MFI Hearing Aids
Weizhong Yang
 
PDF
CocoaPods private repo
Weizhong Yang
 
PDF
Flutter 踩雷心得
Weizhong Yang
 
PDF
那些年被蘋果 Ban 掉的 API
Weizhong Yang
 
PDF
給 iOS 工程師的 Flutter 開發
Weizhong Yang
 
PDF
給 iOS 工程師的 Vue.js 開發
Weizhong Yang
 
PDF
苦集滅道:透過開發客製 Sketch Plug-in 改善產品設計流程
Weizhong Yang
 
PDF
使用 switch/case 重構程式碼
Weizhong Yang
 
PDF
怎樣寫出比較沒有問題的 Code
Weizhong Yang
 
PDF
貪食蛇
Weizhong Yang
 
PDF
Aspect Oriented Programming
Weizhong Yang
 
PDF
Mac OS X 與 iOS 的 Audio API
Weizhong Yang
 
KEY
Html 5 native drag
Weizhong Yang
 
KEY
Retina mac
Weizhong Yang
 
Flutter BLE
Weizhong Yang
 
怎樣在 Flutter app 中使用 Google Maps
Weizhong Yang
 
關於延長役期這件事情
Weizhong Yang
 
Dart null safety
Weizhong Yang
 
導入 Flutter 前你應該知道的事
Weizhong Yang
 
Github Actions
Weizhong Yang
 
iPlayground: CarPlay and MFI Hearing Aids
Weizhong Yang
 
CocoaPods private repo
Weizhong Yang
 
Flutter 踩雷心得
Weizhong Yang
 
那些年被蘋果 Ban 掉的 API
Weizhong Yang
 
給 iOS 工程師的 Flutter 開發
Weizhong Yang
 
給 iOS 工程師的 Vue.js 開發
Weizhong Yang
 
苦集滅道:透過開發客製 Sketch Plug-in 改善產品設計流程
Weizhong Yang
 
使用 switch/case 重構程式碼
Weizhong Yang
 
怎樣寫出比較沒有問題的 Code
Weizhong Yang
 
貪食蛇
Weizhong Yang
 
Aspect Oriented Programming
Weizhong Yang
 
Mac OS X 與 iOS 的 Audio API
Weizhong Yang
 
Html 5 native drag
Weizhong Yang
 
Retina mac
Weizhong Yang
 
Ad

Recently uploaded (20)

PDF
"Effect, Fiber & Schema: tactical and technical characteristics of Effect.ts"...
Fwdays
 
PDF
2025-07-15 EMEA Volledig Inzicht Dutch Webinar
ThousandEyes
 
PDF
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
PPTX
Simplifying End-to-End Apache CloudStack Deployment with a Web-Based Automati...
ShapeBlue
 
PPTX
TYPES OF COMMUNICATION Presentation of ICT
JulieBinwag
 
PPTX
UI5Con 2025 - Get to Know Your UI5 Tooling
Wouter Lemaire
 
PDF
Novus Safe Lite- What is Novus Safe Lite.pdf
Novus Hi-Tech
 
PDF
Women in Automation Presents: Reinventing Yourself — Bold Career Pivots That ...
DianaGray10
 
PDF
CIFDAQ'S Token Spotlight for 16th July 2025 - ALGORAND
CIFDAQ
 
PPTX
Top Managed Service Providers in Los Angeles
Captain IT
 
PPTX
Building and Operating a Private Cloud with CloudStack and LINBIT CloudStack ...
ShapeBlue
 
PPTX
Darren Mills The Migration Modernization Balancing Act: Navigating Risks and...
AWS Chicago
 
PDF
Meetup Kickoff & Welcome - Rohit Yadav, CSIUG Chairman
ShapeBlue
 
PDF
Trading Volume Explained by CIFDAQ- Secret Of Market Trends
CIFDAQ
 
PDF
Empowering Cloud Providers with Apache CloudStack and Stackbill
ShapeBlue
 
PDF
Market Insight : ETH Dominance Returns
CIFDAQ
 
PPTX
UI5Con 2025 - Beyond UI5 Controls with the Rise of Web Components
Wouter Lemaire
 
PDF
Building Resilience with Digital Twins : Lessons from Korea
SANGHEE SHIN
 
PDF
How a Code Plagiarism Checker Protects Originality in Programming
Code Quiry
 
PPTX
Extensions Framework (XaaS) - Enabling Orchestrate Anything
ShapeBlue
 
"Effect, Fiber & Schema: tactical and technical characteristics of Effect.ts"...
Fwdays
 
2025-07-15 EMEA Volledig Inzicht Dutch Webinar
ThousandEyes
 
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
Simplifying End-to-End Apache CloudStack Deployment with a Web-Based Automati...
ShapeBlue
 
TYPES OF COMMUNICATION Presentation of ICT
JulieBinwag
 
UI5Con 2025 - Get to Know Your UI5 Tooling
Wouter Lemaire
 
Novus Safe Lite- What is Novus Safe Lite.pdf
Novus Hi-Tech
 
Women in Automation Presents: Reinventing Yourself — Bold Career Pivots That ...
DianaGray10
 
CIFDAQ'S Token Spotlight for 16th July 2025 - ALGORAND
CIFDAQ
 
Top Managed Service Providers in Los Angeles
Captain IT
 
Building and Operating a Private Cloud with CloudStack and LINBIT CloudStack ...
ShapeBlue
 
Darren Mills The Migration Modernization Balancing Act: Navigating Risks and...
AWS Chicago
 
Meetup Kickoff & Welcome - Rohit Yadav, CSIUG Chairman
ShapeBlue
 
Trading Volume Explained by CIFDAQ- Secret Of Market Trends
CIFDAQ
 
Empowering Cloud Providers with Apache CloudStack and Stackbill
ShapeBlue
 
Market Insight : ETH Dominance Returns
CIFDAQ
 
UI5Con 2025 - Beyond UI5 Controls with the Rise of Web Components
Wouter Lemaire
 
Building Resilience with Digital Twins : Lessons from Korea
SANGHEE SHIN
 
How a Code Plagiarism Checker Protects Originality in Programming
Code Quiry
 
Extensions Framework (XaaS) - Enabling Orchestrate Anything
ShapeBlue
 

Input Method Kit

Editor's Notes