-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add copyLineDown.js, copyLineUp.js, insertLineAbove.js, insertLineBel…
…ow.js, moveLineDown.js, moveLineUp.js
- Loading branch information
1 parent
89d1543
commit c59b5cc
Showing
14 changed files
with
582 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* =============================================================================================================================================== | ||
copyLineDown | ||
Description | ||
This script is equivalent to Visual Studio Code's Selection menu "Copy Line Down". | ||
Both point and area types are supported. | ||
Usage | ||
Move the cursor to the line you want to copy, run this script from File > Scripts > Other Script... | ||
It is not necessary to select a line. | ||
Notes | ||
When copying the last line, a new line is added to work around a bug. | ||
If you are using version 2020 or earlier, you will not be able to enter keyboard input after running the script. | ||
If you want to enter text, you must click with the mouse. | ||
In rare cases, you may not be able to create it. | ||
In that case, restart Illustrator and run this script again. | ||
Requirements | ||
Illustrator CC 2018 or higher | ||
Version | ||
1.0.0 | ||
Homepage | ||
github.com/sky-chaser-high/adobe-illustrator-scripts | ||
License | ||
Released under the MIT license. | ||
https://opensource.org/licenses/mit-license.php | ||
=============================================================================================================================================== */ | ||
|
||
(function() { | ||
if (app.documents.length > 0) main(); | ||
})(); | ||
|
||
|
||
function main() { | ||
try { | ||
var text = app.activeDocument.selection; | ||
var lines = text.story.lines; | ||
var cursor = text.start; | ||
|
||
var i = 0, count = 0; | ||
|
||
while (true) { | ||
var line = lines[i].contents.length; | ||
if (cursor <= line + count) { | ||
lines[i].select(); | ||
app.copy(); | ||
|
||
lines[i].insertionPoints[line].characters.add('\r'); | ||
// work around a bug | ||
if (i == lines.length - 1) { | ||
lines[i].insertionPoints[line].characters.add('\r'); | ||
} | ||
|
||
i++; | ||
lines[i].select(); | ||
app.paste(); | ||
|
||
// Restore the cursor position. | ||
text.story.textRanges[cursor + line].select(); | ||
app.cut(); | ||
app.paste(); | ||
return; | ||
} | ||
count += line + 1; | ||
i++; | ||
} | ||
} | ||
catch (err) { } | ||
} |
Oops, something went wrong.