URL Schemes
Textwell supports several URL schemes which allow other apps to call methods of Textwell remotely and to make Textwell callback other apps to pass some data.
By following the spec of "x-callback-url," each URL scheme of Textwell has "x-success" option for calling back. If "x-success" parameter is specified, Textwell executes it right after the first URL scheme is executed successfully.
Every value for URL query parameters must be URL-encoded.
First of all, to just open Textwell, do this.
textwell://
Methods
Replace
textwell:///replace?text=[text to replace with]
This URL scheme replaces the whole text on the main text view with the specified text.
Insert
textwell:///insert?text=[text to insert]
This URL scheme inserts the specified text into the current caret position on the main text view. If there is a selection, the selected text will be replaced with the inserting text.
Add
textwell:///add?text=[text to add with]
This URL scheme adds the specified text to the end of the existing text on the main text view.
Replace Range
textwell:///replaceRange?replacingLoc=[location of range to be replaced]&replacingLen=[length of range to be replaced]&text=[text to replace with]&selectingLoc=[location of range to select]&selectingLen=[length of range to select]
This URL scheme is for complex replacing. In addition to the inserting text, you can specify a range which is to be replaced and a range which is to be selected after replacement.
For example, if the main text view has a string "Hello, world." as its content,
textwell:///replaceRange?replacingLoc=7&replacingLen=5&text=Textwell&selectingLoc=0&selectingLen=16
this URL scheme will change the content as "Hello, Textwell." then selects the whole string. In this case, the range of { loc: 7, len: 5 }, which represents "world", is to be replaced with "Textwell", and the range of { loc: 0, len: 16 }, which represents "Hello, Textwell.", is to be selected after replacement.
Paste to Replace
textwell:///pasteReplace?
This URL scheme replaces the whole text on the main text view with the text from the general paste board.
Paste to Insert
textwell:///pasteInsert?
This URL scheme inserts the text from the general paste board into the current caret position on the main text view. If there is a selection, the selected text will be replaced with the inserting text.
Paste to Add
textwell:///pasteAdd?
This URL scheme adds the text from the general paste board to the end of the existing text on the main text view.
Paste to Replace Range
textwell:///pasteReplaceRange?replacingLoc=[location of range to be replaced]&replacingLen=[length of range to be replaced]&selectingLoc=[location of range to select]&selectingLen=[length of range to select]
This URL scheme replaces a specific range with the text from the general paste board then selects a specific range. See "Replace Range" for the detail of parameters.
Execute Action
textwell:///executeAction?title=[title of an action to execute]
This URL scheme executes a specific action. If there are more than one actions which have the same title, the more-recently-used one will be executed.
Import Action
textwell:///importAction?title=[title of the importing action]&source=[source of the importing action]&iconTitle=[icon title of the importing action]&desc=[description of the importing action]&platform=[0 is for All, 1 is for iOS, 2 is for Mac]&confirming=[1 is to make the action show confirming dialog when it is executed]
This URL scheme creates a new action into Textwell. Usually the action composer will be shown with the specified parameters, and it lets users to choose "Save" or "Cancel" for the new action. Check
General options
x-success
x-success=[URL scheme which will be executed after the first URL scheme is executed successfully]
If this parameter is added to the URL scheme, the URL which is represented by the value will be executed right after the first URL scheme is executed successfully.
extendXSuccess
extendXSuccess=[true or false if the x-success is to be extended]
If this parameter is added to the URL scheme and is set as true, "textwell-text," "textwell-loc," and "textwell-len" parameters will be added to the x-success URL for helping the receiver to handle updated content of the Textwell. By using this parameter, for example, another app can insert some text to Textwell then get the modified content back to it in one stroke.
Pasting options
prefix
prefix=[prefix string]
Inserts specified string before the pasting string. This option is for the pasting methods (pasteReplace, pasteInsert, pasteAdd, and pasteReplaceRange).
suffix
suffix=[suffix string]
Inserts specified string after the pasting string. This option is for the pasting methods (pasteReplace, pasteInsert, pasteAdd, and pasteReplaceRange).