ANNOUNCE: eBook "CotEditor scripting book with AppleScript"

Piyomaru Software released a new e-book (written in Japanese) about CotEditor, open source developed text editor for only macOS.

CotEditor has various AppleScript functions and has smart & tidy GUI. This book introduce its whole AppleScript related functions.

This book is aimed to translate to English by design.

Format: PDF (343 pages) with sample script Zip archive

–Table Of Contents (Translated by Google)

■ Elementary

・Start the script editor

Let’s start the script editor!
Script editor help
Let’s change the color settings!
enter the script
save the script
Let’s run the script (1/3)
Let’s run the script (2/3)
Security and privacy
Privacy and Security (13.x and later)
Security & Privacy > Privacy
Privacy and Security (macOS 13)

・Start CotEditor

Specify CotEditor
Start CotEditor.app
Exit CotEditor.app
How to look up CotEditor’s AppleScript dictionary
How to check menu items and forced screen operations
Detailed specifications of CotEditor

・Get information about CotEditor itself

Get name of CotEditor
Get version of CotEditor
Property items and contents of CotEditor

・Access to open documents

Access to open documents in CotEditor
Access frontmost documents and windows
Access attribute information of document
Access window attribute information
What you can’t do with window-related operations

・Access to selected parts of documents

selection = selected text
properties of the selection itself
Get the text of the selection content
Rewriting selection content
creating selections

・Scrolling and jumping through documents

Document scroll ①
Document scroll ②
Jump to specified line in document
Jump to random line in document

・Window operation

Accessing Window Attribute Values
Bring the specified window to the front
Change the display state of the specified window
Zoom display of specified window
Reference: Display frontmost window in full screen
Resize specified window

・Character string output to CotEditor built-in console

print string to console

・Operation from the built-in/OS-installed script menu

Two Script Menu environments
CotEditor built-in script menu
macOS standard script menu
Technical specifications for each script menu

・Pattern to operate CotEditor from AppleScript

■ Intermediate

・Open file

Specify file and open document
Open documents by specifying multiple files
Column “Path expressions used by CotEditor”

・Save file

Save document to specified path
Create a new document, set the text and save it to the specified path
Save any changes to the saved document

・Close file

Close documents (with saving)
Close documents (without saving)
Closing documents (saving ask)
Close new document

・Various character operations (manipulation of selection range)

change case
change kana
change roman width
shift right
shift left
move line up
move line down
sort lines
delete duplicate line
comment out
uncomment
smarten quotes
straighten quotes
smarten dashes
normalize unicode

・Various character operations (manipulation of the entire document)

find(1/2)
find(2/2)
replace
string

・Handling of tabs and line feed codes

Change line feed code Change tab width
Character code specification
convert
reinterpret

・Formatted text support function

Formatted text support function of CotEditor
Access Formatted Text Features from AppleScript

・Call non-AppleScript functions

Range that can be manipulated by AppleScript
GUI Scripting: Forced operation of menus, etc. (1)
GUI Scripting: Forced operation of menus, etc. (2)
GUI Scripting: Accessing Menus
Bring the specified window to the front

·print out

Print output from CotEditor (macOS 13)
Printout with AppleScript
Printout by GUI Scripting (1)
Printout by GUI Scripting (2)
Printout by GUI Scripting (3)
Printout by GUI Scripting (4)
Printout by GUI Scripting (5)

■ Advanced

Regular expressions
AppleScript commands that can use regular expressions
find command + regular expression (correspondence with GUI side)
replace command + regular expression (correspondence with GUI side)
replace sample ①
replace sample ②
replace Sample ③
replace Sample ④

・ Document specification that can force vertical / horizontal writing when opening

Force vertical display with xattr command

・Count the number of characters

CotEditor’s character count function
AppleScript character count

  • Proprietary built-in script menu

The folder hierarchy structure is reflected as it is
Unique features of the built-in script menu
Specify order on menu
Delimiter separator display specification on the menu
Specifying keyboard shortcuts
Do not show Script in the menu (hidden setting)

・Bug in CotEditor’s AppleScript-related functions (v4.4.2)

Command reserved word “string” is strange
The class reserved word “rich text” is strange
“print” command not working
script hook function is not present

・Advanced sample collection

Range that can be manipulated by AppleScript
Display frontmost window in full screen (1/2)
Show frontmost window full screen (2/2)
hexdump (1/2) the text of the selection
hexdump (2/2) the text of the selection
Comma separated text from selection to Numbers (1/2)
Comma separated text from selection to Numbers (2/2)
Show character ratio graph for selected text (1/8)
Graphical display of the ratio of characters used in selected text (2/8)
Graphical display of the ratio of characters used in selected text (3/8)
Graphical display of the ratio of characters used in selected text (4/8)
Graphical display of the ratio of characters used in selected text (5/8)
Graphical display of the ratio of characters used in selected text (6/8)
Graphical display of the ratio of characters used in selected text (7/8)
Graphical display of the ratio of characters used in selected text (8/8)

・Other useful programs and peripherals

Operation ① (1/2) from various AppleScript calling programs
Operation ① (2/2) from various AppleScript calling programs
Operation from various AppleScript calling programs (2)
Operation from various AppleScript calling programs (3)
Operation from various AppleScript calling programs (4)

■ Document collection

・CotEditor’s AppleScript dictionary explanation

・Changes in CotEditor AppleScript terminology
Changes in the CotEditor terminology dictionary

・CotEditor & AppleScript Q&A
Q&A about AppleScript❶
Q&A about AppleScript❷
Q&A about AppleScript❸

・AppleScript mini Reference

・Documents related to AppleScript on macOS

Resources for AppleScript

・macOS version and trends in AppleScript

Elemental technology history of macOS and AppleScript
AppleScript commentary for each macOS (1/4)
AppleScript commentary for each macOS (2/4)
AppleScript commentary for each macOS (3/4)
AppleScript commentary for each macOS (4/4)
History of AppleScript helper tools in macOS
System Events AppleScript Terminology Changes
AppleScript runtime environment information
AppleScript-related tools
Cocoa Scripting related tools

・List of AppleScript reserved words
・Call third-party Frameworks and AppleScript Libraries
・Error code table