On 04/21/2019, at 10:11, F. Alfredo Rego <[email protected]
<mailto:[email protected]>> wrote:
> I’m using AppleScript + BBEdit to “refresh” all the files in the “Release”
> directory with the contents of all the files in the “Prototype” directory. I
> do this “transfer of the file contents” (instead of simply copying and
> over-writing the files), to preserve the entire git history of each “Release”
> file.
>
> I have explored everywhere I can, but I can’t find any way to
> DESELECT/UNSELECT selected text.
Hey Alfredo,
This is not at all intuitive. You can't de-select text directly, but you can
set the selection to nothing like so.
tell application "BBEdit"
tell front text window
select insertion point before its text
end tell
end tell
As Rich observed – you don't need to select the text to meet your objective.
I would write your script similarly to this:
set filePath to "~/test_directory/BBEdit_Test_Dir_Level_01/textFile.txt"
tell application "System Events"
set filePath to POSIX path of disk item filePath
end tell
tell application "BBEdit"
# activate -- No need IF BBEdit is already frontmost.
set myDoc to open filePath with LF translation
set dataStr to text of myDoc
end tell
Although I generally use what I call Relative-Aliases to reference files in my
$HOME directory:
set fileAlias to alias ((path to home folder as text) &
"test_directory:BBEdit_Test_Dir_Level_01:textFile.txt")
I don't often publish scripts publicly this way anymore, because most people
don't understand what a relative-alias is.
So when I want to use a $HOME-based path in a publicly posted script I usually
use the Tilde-format (~/your_path).
I have a handler for converting them to a full POSIX Path that's way faster
than System Events, but using SE is easy and ~ 0.02 seconds is fast enough for
most folks.
Relative paths (of either kind) are portable through changes in hard drive
names and user-folder names, whereas hard-coded paths are often broken by those
changes.
I learned this lesson long ago after buying a new Mac and changing my HD name
and having to edit hundreds of scripts to get them working again...
I don't generally like to place paths within application-tell blocks for too
many reasons to get in to here.
--
Take Care,
Chris
--
This is the BBEdit Talk public discussion group. If you have a
feature request or need technical support, please email
"[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <https://www.twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/bbedit.