|
| 1 | +%% **************************************************************************** |
| 2 | +%% ViewIdReplace.pidoc - Released 2017/01/15 00:00:00 UTC |
| 3 | +%% **************************************************************************** |
| 4 | +%% |
| 5 | +%% This file is part of ViewIdReplace Script Version 1.4 |
| 6 | +%% |
| 7 | +%% Copyright (C) 2012-2017 Mike Schuster. All Rights Reserved. |
| 8 | +%% Copyright (C) 2003-2017 Pleiades Astrophoto S.L. All Rights Reserved. |
| 9 | +%% |
| 10 | +%% Redistribution and use in both source and binary forms, with or without |
| 11 | +%% modification, is permitted provided that the following conditions are met: |
| 12 | +%% |
| 13 | +%% 1. All redistributions of source code must retain the above copyright |
| 14 | +%% notice, this list of conditions and the following disclaimer. |
| 15 | +%% |
| 16 | +%% 2. All redistributions in binary form must reproduce the above copyright |
| 17 | +%% notice, this list of conditions and the following disclaimer in the |
| 18 | +%% documentation and/or other materials provided with the distribution. |
| 19 | +%% |
| 20 | +%% 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names |
| 21 | +%% of their contributors, may be used to endorse or promote products derived |
| 22 | +%% from this software without specific prior written permission. For written |
| 23 | +%% permission, please contact [email protected]. |
| 24 | +%% |
| 25 | +%% 4. All products derived from this software, in any form whatsoever, must |
| 26 | +%% reproduce the following acknowledgment in the end-user documentation |
| 27 | +%% and/or other materials provided with the product: |
| 28 | +%% |
| 29 | +%% "This product is based on software from the PixInsight project, developed |
| 30 | +%% by Pleiades Astrophoto and its contributors (http://pixinsight.com/)." |
| 31 | +%% |
| 32 | +%% Alternatively, if that is where third-party acknowledgments normally |
| 33 | +%% appear, this acknowledgment must be reproduced in the product itself. |
| 34 | +%% |
| 35 | +%% THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS |
| 36 | +%% "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
| 37 | +%% TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 38 | +%% PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS |
| 39 | +%% CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 40 | +%% EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS |
| 41 | +%% INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE, |
| 42 | +%% DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 43 | +%% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 44 | +%% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 45 | +%% POSSIBILITY OF SUCH DAMAGE. |
| 46 | +%% **************************************************************************** |
| 47 | + |
| 48 | +\documentclass PIScriptDoc |
| 49 | + |
| 50 | +\script ViewIdReplace |
| 51 | + |
| 52 | +\keywords { |
| 53 | + view identifier replacement |
| 54 | +} |
| 55 | + |
| 56 | +\author { |
| 57 | + Mike Schuster |
| 58 | +} |
| 59 | + |
| 60 | +\copyright { |
| 61 | + 2012-2017 Mike Schuster. All Rights Reserved. |
| 62 | +} |
| 63 | + |
| 64 | +\brief { |
| 65 | + Script that renames a view with some or all matches of a pattern replaced by a replacement. |
| 66 | +} |
| 67 | + |
| 68 | +\description { |
| 69 | + ViewIdReplace renames a view with some or all matches of a pattern replaced by a replacement. The pattern may be a regular expression of the form /pattern/flags or a string. The replacement is a string. A number of special replacement patterns are supported. |
| 70 | + |
| 71 | + The script provides an alternative to manually renaming multiple views when the renaming can be expressed as a regular expression or string replacement. |
| 72 | + |
| 73 | + Typical usage is as follows: Launch the script, specify pattern and replacement, drag an instance to the workspace, dismiss the script, drag the instance onto one or more views to rename. |
| 74 | + |
| 75 | + Multiple instances of the script with different patterns and replacements may be created in the workspace. Drag the appropriate instance onto the view. |
| 76 | + |
| 77 | + This document describes ViewIdReplace Version 1.4. |
| 78 | + |
| 79 | + \subsection {Example: string pattern} { |
| 80 | + \image [marginleft:36pt] Usage/clone_work_dialog.png |
| 81 | + |
| 82 | + Replace the string "clone" with the replacement "work". Example input "integration_clone", output "integration_work". |
| 83 | + } |
| 84 | + |
| 85 | + \subsection {Example: regular expression pattern} { |
| 86 | + \image [marginleft:36pt] Usage/clone_clone_star_work.png |
| 87 | + |
| 88 | + Replace the string "clone" followed by zero or more occurances of the string "_clone" with the replacement "work". Example input "integration_clone_clone", output "integration_work". Pattern * matches the preceeding parenthesized item zero or more times. |
| 89 | + } |
| 90 | + |
| 91 | + \subsection {Example: append string} { |
| 92 | + \image [marginleft:36pt] Usage/append_work.png |
| 93 | + |
| 94 | + Append the string "_work". Example input "integration", output "integration_work". Pattern $ matches end of input. |
| 95 | + } |
| 96 | + |
| 97 | + \subsection {Example: prepend string} { |
| 98 | + \image [marginleft:36pt] Usage/prepend_work.png |
| 99 | + |
| 100 | + Prepend the string "work_". Example input "integration", output "work_integration". Pattern ^ matches beginning of input. |
| 101 | + } |
| 102 | + |
| 103 | + \subsection {Example: replace any} { |
| 104 | + \image [marginleft:36pt] Usage/any_work.png |
| 105 | + |
| 106 | + Replace any string with "work". Example input "light_012", output "work". Pattern . matches any character. Pattern * matches the preceeding item zero or more times. |
| 107 | + } |
| 108 | + |
| 109 | + \subsection {Example: append string, preserve suffix} { |
| 110 | + \image [marginleft:36pt] Usage/append_preserve_work.png |
| 111 | + |
| 112 | + Append the string "_work" while preserving suffix underscore and digits. Example input "light_012", output "light_work_012". Pattern \bslash{d} matches any digit. Pattern * matches the preceeding item zero or more times. The parenthesized item is remembered as the 1st parenthesized submatch string. Pattern $ matches end of input. The replacement pattern $1 inserts the 1st parenthesized submatch string. |
| 113 | + } |
| 114 | +} |
| 115 | + |
| 116 | +\usage { |
| 117 | + \subsection {ViewIdReplace} { |
| 118 | + \image [marginleft:36pt] Usage/clone_work_dialog.png |
| 119 | + \image [marginleft:36pt] Usage/clone_clone_star_work.png |
| 120 | + |
| 121 | + \division { Pattern } { |
| 122 | + A regular expression or a string. |
| 123 | + |
| 124 | + If a regular expression of the form /pattern/flags, the match or matches are replaced with the string specified by replacement parameter. |
| 125 | + |
| 126 | + If a string, it is treated as a verbatim string. Only the first occurrence will be replaced. |
| 127 | + |
| 128 | + An abbreviated list of pattern meanings in regular expressions. |
| 129 | + |
| 130 | + \table [unnumbered, caption, header, marginleft:36pt, width:500pt] { |
| 131 | + { \left {Character classes} } |
| 132 | + { {Pattern} {Meaning} } |
| 133 | + { {.} {Matches any single character.} } |
| 134 | + { {\bslash{d}} {Matches any digit character, equivalent to \[0-9\].} } |
| 135 | + { {\bslash{D}} {Matches any character that is not a digit, equivalent to \[^0-9\].} } |
| 136 | + } |
| 137 | + |
| 138 | + \table [unnumbered, caption, header, marginleft:36pt, width:500pt] { |
| 139 | + { \left {Character sets} } |
| 140 | + { {Pattern} {Meaning} } |
| 141 | + { {\[xyz\] \n \[a-c\]} {A character set. Matches any one of the enclosed characters. You can specify a range of characters by using a hyphen.} } |
| 142 | + { {\[^xyz\] \n \[^a-c\]} {A negated or complemented character set. That is, it matches anything that is not enclosed in the brackets. You can specify a range of characters by using a hyphen.} } |
| 143 | + } |
| 144 | + |
| 145 | + \table [unnumbered, caption, header, marginleft:36pt, width:500pt] { |
| 146 | + { \left {Alternation} } |
| 147 | + { {Pattern} {Meaning} } |
| 148 | + { {x|y} {Matches either x or y.} } |
| 149 | + } |
| 150 | + |
| 151 | + \table [unnumbered, caption, header, marginleft:36pt, width:500pt] { |
| 152 | + { \left {Boundaries} } |
| 153 | + { {Pattern} {Meaning} } |
| 154 | + { {^} {Matches beginning of input.} } |
| 155 | + { {$} {Matches end of input.} } |
| 156 | + } |
| 157 | + |
| 158 | + \table [unnumbered, caption, header, marginleft:36pt, width:500pt] { |
| 159 | + { \left {Grouping and back references} } |
| 160 | + { {Pattern} {Meaning} } |
| 161 | + { {(x)} {Matches x and remembers the match as a parenthesized submatch string.} } |
| 162 | + { {\bslash{n}} {Where n is a positive integer, a back reference to the substring matching the nth parenthesized submatch string.} } |
| 163 | + { {(?:x)} {Matches x but does not remember the match.} } |
| 164 | + } |
| 165 | + |
| 166 | + \table [unnumbered, caption, header, marginleft:36pt, width:500pt] { |
| 167 | + { \left {Quantifiers} } |
| 168 | + { {Pattern} {Meaning} } |
| 169 | + { {x*} {Matches the preceding item x 0 or more times.} } |
| 170 | + { {x+} {Matches the preceding item x 1 or more times.} } |
| 171 | + { {x?} {Matches the preceding item x 0 or 1 time.} } |
| 172 | + { {x*? \n x+? \n x??} {Matches the preceding item x like *, +, and ?, however the match is the smallest possible match.} } |
| 173 | + } |
| 174 | + |
| 175 | + \table [unnumbered, caption, header, marginleft:36pt, width:500pt] { |
| 176 | + { \left {Assertions} } |
| 177 | + { {Pattern} {Meaning} } |
| 178 | + { {x(?=y)} {Matches x only if x is followed by y.} } |
| 179 | + { {x(?!y)} {Matches x only if x is not followed by y.} } |
| 180 | + } |
| 181 | + |
| 182 | + If specified, flags can have any combination of the following values: |
| 183 | + |
| 184 | + \table [unnumbered, header, marginleft:36pt, width:500pt] { |
| 185 | + { {Flag} {Meaning} } |
| 186 | + { {g} {Global match; find all matches rather than stopping after the first match.} } |
| 187 | + { {i} {Ignore character case.} } |
| 188 | + } |
| 189 | + } |
| 190 | + |
| 191 | + \division { Replacement } { |
| 192 | + The string that replaces the substring specified by the pattern parameter. A number of special replacement patterns are supported: |
| 193 | + |
| 194 | + \table [unnumbered, header, marginleft:36pt, width:500pt] { |
| 195 | + { {Pattern} {Inserts} } |
| 196 | + { {$&} {Inserts the matched substring.} } |
| 197 | + { {$`} {Inserts the portion of the string that precedes the matched substring.} } |
| 198 | + { {$'} {Inserts the portion of the string that follows the matched substring.} } |
| 199 | + { {$n} {Where n is a positive integer, inserts the nth parenthesized submatch string, provided the pattern parameter was a regular expression.} } |
| 200 | + } |
| 201 | + |
| 202 | + Replacement characters not in the set \[A-Za-z0-9_\] are themselves replaced with underscore. |
| 203 | + |
| 204 | + If the output is not a unique view id, one or more digits will be appended. |
| 205 | + } |
| 206 | + } |
| 207 | + |
| 208 | + \subsection { Button pane } { |
| 209 | + \image [marginleft:36pt] Usage/clone_work_dialog.png |
| 210 | + \image [marginleft:36pt] Usage/clone_clone_star_work.png |
| 211 | + |
| 212 | + \definition { |
| 213 | + { \image Usage/new_instance.png } { |
| 214 | + Create a new instance. |
| 215 | + } |
| 216 | + |
| 217 | + { \image Usage/browse_documentation.png } { |
| 218 | + Open a browser to view documentation. |
| 219 | + } |
| 220 | + |
| 221 | + { \image Usage/reset.png } { |
| 222 | + Reset all parameters. |
| 223 | + } |
| 224 | + |
| 225 | + { \image Usage/diagnostics.png } { |
| 226 | + Check the pattern for syntax errors. |
| 227 | + } |
| 228 | + |
| 229 | + { Dismiss } { |
| 230 | + Dismiss the dialog. |
| 231 | + } |
| 232 | + |
| 233 | + } |
| 234 | + } |
| 235 | +} |
| 236 | + |
| 237 | +\make |
| 238 | + |
| 239 | +%% **************************************************************************** |
| 240 | +%% ViewIdReplace.pidoc - Released 2017/01/15 00:00:00 UTC |
0 commit comments