Mein Ziel ist es, ein AppleScript zu erstellen, die automatisch einen Aufzählungspunkt für mich automatisch einfügt, wenn ich Alt + Eingabe drücken. Ich versuche, dies in BBEdit zu tun, und hier ist das Apple-Skript, das ich von den BBEdit Foren verhakt:Holen Sie die Anzahl der Tabstops oder Leerraum und verketten in Applescript (Smart-Newline-Skript zum Einfügen von bullet)
tell application "BBEdit"
try
tell text of front text window
set lineOfInsertionPoint to line (startLine of selection)
set findReco to find "^\\s*\\d+\\." searching in lineOfInsertionPoint options {search mode:grep}
if found of findReco = true then
set leadingNumber to text 1 thru -2 of (found text of findReco)
set text of selection to return & (leadingNumber + 1) & ". "
select insertion point after selection
else if found of findReco = false then
set findReco to find "^\\s*\\* " searching in lineOfInsertionPoint options {search mode:grep}
if found of findReco = true then
set text of selection to return & "* "
select insertion point after selection
else
set findReco to find "^\\s*\\+" searching in lineOfInsertionPoint options {search mode:grep}
if found of findReco = true then
set text of selection to return & tab & "+ "
select insertion point after selection
end if
end if
end if
end tell
on error errMsg number errNum
set sep to "=============================="
set e to sep & return & "Error: " & errMsg & return & sep & return ¬
& "Error Number: " & errNum & return & sep
beep
display dialog e
end try
end tell
Das Skript funktioniert gut, aber das Problem ist, dass, wenn Sie bereits eine bestimmte Anzahl von Tab haben stoppt oder weiß Platz am Anfang, das AppleScript fügt die nächste Kugel direkt am Anfang der Zeile ein und ignoriert die Whitespaces/Tabstopps.
Also meine eigentliche Frage ist ganz einfach "Wie erhält man die Anzahl der führenden Tabstopps oder Leerzeichen durch Applescript" und verketten Sie es hier?
Prost.