Skip to content

Instantly share code, notes, and snippets.

@RobTrew
RobTrew / make_or_deepen_header.applescript
Created November 16, 2012 13:11
Mark the selected FoldingText line as a heading (or deepen its heading level) – simple script for keyboard assignment
-- Change first selected node to heading,
-- or deepen level if already heading
-- DEV 1.1 Script
property pstrType : "heading"
on run
tell application "FoldingText"
-- CHECK THAT THERE IS A DOCUMENT
@RobTrew
RobTrew / select_ft_theme.applescript
Created November 18, 2012 15:39
Select FoldingText theme, and restart FoldingText
-- Permission is hereby granted, free of charge,
-- to any person obtaining a copy of this software
-- and associated documentation files (the "Software"),
-- to deal in the Software without restriction,
-- including without limitation the rights to use, copy,
-- modify, merge, publish, distribute, sublicense,
-- and/or sell copies of the Software, and to permit persons
-- to whom the Software is furnished to do so,
-- subject to the following conditions:
@RobTrew
RobTrew / set_ft_heading_levels.applescript
Created November 18, 2012 18:52
Script which sets the top N levels of a FoldingText outline to Markdown hash headers
-- Copyright (C) 2012 Robin Trew
--
-- Permission is hereby granted, free of charge,
-- to any person obtaining a copy of this software
-- and associated documentation files (the "Software"),
-- to deal in the Software without restriction,
-- including without limitation the rights to use, copy,
-- modify, merge, publish, distribute, sublicense,
-- and/or sell copies of the Software, and to permit persons
@RobTrew
RobTrew / expand_ft.applescript
Created November 18, 2012 18:57
Expand/Collapse FT to level N, or by N levels
-- Copyright (C) 2012 Robin Trew
--
-- Permission is hereby granted, free of charge,
-- to any person obtaining a copy of this software
-- and associated documentation files (the "Software"),
-- to deal in the Software without restriction,
-- including without limitation the rights to use, copy,
-- modify, merge, publish, distribute, sublicense,
-- and/or sell copies of the Software, and to permit persons
-- to whom the Software is furnished to do so,
@RobTrew
RobTrew / DraftsFunctions_ScriptEditor.js
Last active April 12, 2023 07:26
OS X 10.10 (Yosemite) definitions of the basic script editing functions used in iOS Drafts 4
// Ver 0.4 Rob Trew
// Library for using OSX Yosemite Script Editor scripts
// written in an idiom compatible with FoldingText, Drafts, 1Writer, TextWell
// In iOS Drafts 4 scripts, the header is simply:
// var drafts = this;
// For headers for FoldingText and other editors, see:
// See: http://support.foldingtext.com/t/writing-scripts-which-run-on-both-foldingtext-and-ios-drafts-4/652/7
// Call functions, after this header, with the prefix:
// drafts.
@RobTrew
RobTrew / toggleComments.js
Last active January 21, 2023 00:53
Toggle selected comments in OS X 10.10 Script Editor
// ROBIN TREW 2015 MIT License
// OSX 10.10 SCRIPT EDITOR – TOGGLE COMMENTS
// Add remove '// ' from before printing characters
// Depends on a library .scpt being saved at ~/Library/Script Libraries/DraftsSE.scpt
// See: See: http://support.foldingtext.com/t/writing-scripts-which-run-on-both-foldingtext-and-ios-drafts-4/652/7
// INCLUDE LIBRARY OF IOS DRAFTS-COMPATIBLE EDITOR FUNCTIONS:
@RobTrew
RobTrew / indentLines.js
Last active January 21, 2023 00:54
Indent selected line(s) in OS X 10.10 Script Editor
// ROBIN TREW 2015 MIT License
// OSX 10.10 SCRIPT EDITOR – INDENT SELECTED LINES (with Tab or 4 spaces)
// Add remove '// ' from before printing characters
// Depends on a library .scpt being saved at ~/Library/Script Libraries/DraftsSE.scpt
// See: See: http://support.foldingtext.com/t/writing-scripts-which-run-on-both-foldingtext-and-ios-drafts-4/652/7
// INCLUDE ALL OR PART OF LIBRARY OF IOS DRAFTS-COMPATIBLE EDITOR FUNCTIONS:
@RobTrew
RobTrew / outdentLines.js
Last active January 21, 2023 00:54
Outdent selected line(s) in OS X 10.10 Script Editor
// ROBIN TREW 2015 MIT License
// OSX 10.10 SCRIPT EDITOR – REDUCE INDENTATION OF SELECTED LINES (by Tab or 4 spaces)
// Add remove '// ' from before printing characters
// Depends on a library .scpt being saved at ~/Library/Script Libraries/DraftsSE.scpt
// See: See: http://support.foldingtext.com/t/writing-scripts-which-run-on-both-foldingtext-and-ios-drafts-4/652/7
// INCLUDE ALL OR PART OF LIBRARY OF IOS DRAFTS-COMPATIBLE EDITOR FUNCTIONS:
@RobTrew
RobTrew / wrapInSimpleTimingCode.js
Last active January 21, 2023 00:54
OS X 10.10 (Yosemite) Script Editor - Wrap selected line(s) in simple timing code (for performance experiments)
// ROBIN TREW 2015 MIT License
// OSX 10.10 SCRIPT EDITOR – WRAP SELECTED LINE(S) IN SIMPLE TIMING CODE (FOR PERFORMANCE EXPERIMENTS)
// Add remove '// ' from before printing characters
// Depends on a library .scpt being saved at ~/Library/Script Libraries/DraftsSE.scpt
// See: See: http://support.foldingtext.com/t/writing-scripts-which-run-on-both-foldingtext-and-ios-drafts-4/652/7
// INCLUDE LIBRARY OF IOS DRAFTS-COMPATIBLE EDITOR FUNCTIONS:
@RobTrew
RobTrew / ParseAllOPMLAttributes.js
Last active December 8, 2022 23:02
PARSE LOCAL OPML FILE IN OS X 10.10 JXA USING $.NSXMLDocument (parsing 'text' + all other attributes)
// PARSE LOCAL OPML FILE IN OS X 10.10 JXA USING $.NSXMLDocument
// Ver 2.0 Parse all attributes (ver 1 just parsed text)
function run() {
var app = Application.currentApplication();
app.includeStandardAdditions = true;
function readTextFromFile(strPath) {
return $.NSString.stringWithContentsOfFile(strPath);
}