Skip to content

Xcode Source Editor Extension Toolset (Plugins for Xcode 8)

License

Notifications You must be signed in to change notification settings

MySandBoxTestOrg/xTextHandler

 
 

Repository files navigation

🇨🇳中文介绍

xTextHandler

Xcode Source Editor Extension Toolset (Plugins for Xcode 8)

What is it

Xcode Source Editor Extension based tools, improve text editing experience for Xcode 8, you can extend with simple code

Features

  • Multiline Selections
  • Multiple Extensions
  • Extendable API
  • Clipboard Text Handling (if select nothing)
  • Regular Expression Matching

xEncode

image

  • Base64 Encode
  • Base64 Decode
  • URL Encode
  • URL Decode
  • MD5
  • Upper Case
  • Lower Case
  • Escape

xRadix

image

  • Hex
  • Bin
  • Oct
  • Dec

xColor

image

  • Hex
  • RGB
  • Preview

xSearch

image

  • Google
  • Translate
  • Developer
  • StackOverflow
  • GitHub
  • Dash
  • Dictionary

xFormat

image

  • JSON

Usage

  1. Install Xcode 8
  2. Build & Run
  3. Choose Xcode to debug
  4. Select text
  5. Open Editor menu to find extensions
  6. You can set a shortcut (Key-Binding) for each extension
  7. Maybe you will like this WWDC Session

How to write a new Extension

Add definition in Plist:

<dict>
    <key>XCSourceEditorCommandClassName</key>
    <string>aClassName</string>
    <key>XCSourceEditorCommandIdentifier</key>
    <string>test.extension</string>
    <key>XCSourceEditorCommandName</key>
    <string>Test Extension</string>
</dict>

Map handler via commandIdentifier in class:

// Implement your modify strategy using block (you can implement as singleton dict)
// @{ @"commandIdentifier": handlerBlock }
- (NSDictionary *)handlers {
    static NSDictionary *_instance;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _instance = @{
            @"test.extension": ^NSString *(NSString *text) { return text; }
        };
    });
    return _instance;
}

* Handle with regex:

// Override performCommandWithInvocation like that
- (void)performCommandWithInvocation:(XCSourceEditorCommandInvocation *)invocation completionHandler:(void (^)(NSError * _Nullable nilOrError))completionHandler {
    [xTextModifier select:invocation pattern:@"regex" handler:self.handlers[invocation.commandIdentifier]];
    completionHandler(nil);
}

TODO

  • More strategy for xFormat
  • Error handling
  • Preferences panel
  • JavaScript for text handling

Tips

Since Xcode 8.0 beta (8S128d) is totally unstable now, you may see nothing after you build & run this project :(

Contacts

Weibo: @StackOverflowError

Twitter: @cyanapps

Email: [email protected]

About

Xcode Source Editor Extension Toolset (Plugins for Xcode 8)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Objective-C 100.0%