├── .gitattributes ├── .github └── workflows │ ├── Create Release.yml │ └── opened-issue-reply.yml ├── .gitignore ├── LICENSE ├── MBeautifier ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── MBeautify.m ├── MBeautyShortcuts.m ├── MFormatter.m ├── README.md └── resources │ ├── settings │ ├── MBeautyConfigurationRules.m │ └── MBeautyConfigurationRules.xml │ └── testdata │ ├── testfile.m │ └── testfile_bugs.m ├── MWidgets ├── AutoCdPath.m ├── Beautifier.m ├── LiveScriptCustomize.m ├── MultiMlx2M.m ├── OneMlx2M.m └── Setup.m ├── README.md ├── README_zh.md ├── assets └── HatchfulExport-All │ ├── facebook_cover_photo_1.png │ ├── facebook_cover_photo_2.png │ ├── facebook_profile_image.png │ ├── favicon.png │ ├── instagram_profile_image.png │ ├── linkedin_banner_image_1.png │ ├── linkedin_banner_image_2.png │ ├── linkedin_profile_image.png │ ├── logo.png │ ├── logo_transparent.png │ ├── pinterest_board_photo.png │ ├── pinterest_profile_image.png │ ├── twitter_header_photo_1.png │ ├── twitter_header_photo_2.png │ ├── twitter_profile_image.png │ └── youtube_profile_image.png ├── icons ├── circle-1.png ├── code-compare.png ├── indent.png └── move-to-folder.png └── media ├── image-20210921110048305.png ├── image-20210921110103753.png ├── image-20210921110115227.png ├── image-20210921110140550.png ├── image-20210921111702490.png └── logo.png /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.github/workflows/Create Release.yml: -------------------------------------------------------------------------------- 1 | name: Create Release 2 | 3 | on: 4 | push: 5 | tags: 6 | - '*' 7 | 8 | jobs: 9 | 10 | build: 11 | runs-on: ubuntu-latest 12 | permissions: 13 | contents: write 14 | steps: 15 | - uses: actions/checkout@v2 16 | - uses: ncipollo/release-action@v1 17 | with: 18 | artifacts: "release.tar.gz" 19 | generateReleaseNotes: True 20 | prerelease: True 21 | allowUpdates: True 22 | -------------------------------------------------------------------------------- /.github/workflows/opened-issue-reply.yml: -------------------------------------------------------------------------------- 1 | name: Issue Reply 2 | on: 3 | issues: 4 | types: [opened] 5 | jobs: 6 | reply-helper: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - name: Comment to an open issue 10 | uses: Fentaniao/issues-action@0.01 11 | with: 12 | actions: 'create-comment' 13 | token: ${{ secrets.GITHUB_TOKEN }} 14 | issue-number: ${{ github.event.issue.number }} 15 | body: | 16 | Hello, @${{ github.event.issue.user.login }}! Thank you very much for your issue, I will deal with these problems soon. 17 | - name: Add assigness 18 | uses: actions-cool/issues-helper@v3 19 | with: 20 | actions: 'add-assignees' 21 | token: ${{ secrets.GITHUB_TOKEN }} 22 | issue-number: ${{ github.event.issue.number }} 23 | assignees: 'Fentaniao' -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | #Custom setting 2 | *.zip 3 | release 4 | 5 | # Windows default autosave extension 6 | *.asv 7 | 8 | # OSX / *nix default autosave extension 9 | *.m~ 10 | 11 | # Compiled MEX binaries (all platforms) 12 | *.mex* 13 | 14 | # Packaged app and toolbox files 15 | *.mlappinstall 16 | *.mltbx 17 | 18 | # Generated helpsearch folders 19 | helpsearch*/ 20 | 21 | # Simulink code generation folders 22 | slprj/ 23 | sccprj/ 24 | 25 | # Matlab code generation folders 26 | codegen/ 27 | 28 | # Simulink autosave extension 29 | *.autosave 30 | 31 | # Simulink cache files 32 | *.slxc 33 | 34 | # Octave session info 35 | octave-workspace -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /MBeautifier/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at dvarga90@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /MBeautifier/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Feel free to contribute in case of new bugs found. 2 | In the pull request please provide: 3 | - the description of the problem 4 | - a minimal example that can reproduce the issue 5 | - Matlab version you experienced the issue on 6 | 7 | For existing and usassigned bugs, please assign the issue to yourself before starting to work on it. 8 | 9 | For new changes and features, please make an issue without starting the implementation, to make us able to discuss the validness and the side-effect less feasibility of the change or new feature in advance. 10 | 11 | -------------------------------------------------------------------------------- /MBeautifier/LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | 676 | -------------------------------------------------------------------------------- /MBeautifier/MBeautify.m: -------------------------------------------------------------------------------- 1 | classdef MBeautify 2 | % Provides static methods to perform code formatting targeting file(s), the currently active editor page or the 3 | % current selection in editor. 4 | % The rules of the formatting are defined in the "MBeautyConfigurationRules.xml" in the resources directory. This 5 | % file can be modified to affect the formatting. 6 | % Important: Runtime, the M equivalent of this XML file is used, which is created whenever the "setup" static 7 | % method is called, therefore always call this method if the XML file has been modified. 8 | % To restore the XML file to the default configuration, the "createDefaultConfiguration" static method can be 9 | % called. 10 | % 11 | % Example usage: 12 | % 13 | % MBeautify.setup(); % Creates the default rules 14 | % MBeautify.formatCurrentEditorPage(); % Formats the current page in editor without saving 15 | % MBeautify.formatCurrentEditorPage(); % Formats the current page in editor with saving 16 | % MBeautify.formatFile('D:\testFile.m', 'D:\testFileNew.m'); % Formats the first file into the second file 17 | % MBeautify.formatFile('D:\testFile.m', 'D:\testFile.m'); % Formats the first file in-place 18 | % MBeautify.formatFiles('D:\mydir', '*.m'); % Formats all files in the specified diretory in-place 19 | % 20 | % Shortcuts: 21 | % 22 | % Shortcuts can be automatically created for "formatCurrentEditorPage", "formatEditorSelection" and 23 | % "formatFile" methods by executing MBeautify.createShortcut() in order with the parameter 'editorpage', 24 | % 'editorselection' or 'file'. 25 | % The created shortcuts add MBeauty to the Matlab path also (therefore no preparation of the path is needed additionally). 26 | 27 | properties(Access = private, Constant) 28 | RulesXMLFile = 'MBeautyConfigurationRules.xml'; 29 | RulesMFile = 'MBeautyConfigurationRules.m' 30 | SettingDirectory = [fileparts(mfilename('fullpath')), filesep, 'resources', filesep, 'settings']; 31 | RulesMFileFull = [fileparts(mfilename('fullpath')), filesep, 'resources', filesep, 'settings', filesep, 'MBeautyConfigurationRules.m']; 32 | RulesXMLFileFull = [fileparts(mfilename('fullpath')), filesep, 'resources', filesep, 'settings', filesep, 'MBeautyConfigurationRules.xml']; 33 | end 34 | 35 | %% Public API 36 | 37 | methods(Static = true) 38 | 39 | function setup() 40 | % MBeautify.setup() initializes MBeautifier for first use and usable to update the formatting configuration. 41 | % It optionally writes the default settings XML file, reads in the settings XML file and then writes the 42 | % configuration M-file which will be used in runtime. 43 | 44 | if ~exist(MBeautify.RulesXMLFileFull, 'file') 45 | MBeautify.writeSettingsXML(); 46 | end 47 | 48 | MBeautify.writeConfigurationFile(MBeautify.readSettingsXML()); 49 | 50 | fprintf('Configuration was successfully exported to:\n%s\n', MBeautify.RulesMFileFull); 51 | MBeautify.parsingUpToDate(false); 52 | end 53 | 54 | function createDefaultConfiguration() 55 | % Writes the default configuration XML file. 56 | 57 | MBeautify.writeSettingsXML(); 58 | end 59 | 60 | function formatFile(file, outFile) 61 | % Formats the file specified in the first argument. The file is opened in the Matlab Editor. If the second 62 | % argument is also specified, the formatted source is saved to this file. Otherwise the formatted input 63 | % file remains opened in the Matlab Editor. The input and the output file can be the same. 64 | if ~exist(file, 'file') 65 | return; 66 | end 67 | 68 | document = matlab.desktop.editor.openDocument(file); 69 | % Format the code 70 | formatter = MFormatter(MBeautify.getConfigurationStruct()); 71 | document.Text = formatter.performFormatting(document.Text); 72 | 73 | document.smartIndentContents(); 74 | 75 | if nargin >= 2 76 | if exist(outFile, 'file') 77 | fileattrib(outFile, '+w'); 78 | end 79 | 80 | document.saveAs(outFile) 81 | document.close(); 82 | end 83 | end 84 | 85 | function formatFiles(directory, fileFilter) 86 | % Formats the files in-place (files are overwritten) in the specified directory, collected by the specified filter. 87 | % The file filter is a wildcard expression used by the dir command. 88 | 89 | files = dir(fullfile(directory, fileFilter)); 90 | 91 | for iF = 1:numel(files) 92 | file = fullfile(directory, files(iF).name); 93 | MBeautify.formatFile(file, file); 94 | end 95 | end 96 | 97 | function formatEditorSelection(doSave) 98 | % Performs formatting on selection of the currently active Matlab Editor page. 99 | % The selection is automatically extended until the first empty line above and below. 100 | % This method can be useful for large files, but using "formatCurrentEditorPage" is always suggested. 101 | % Optionally saves the file (if it is possible) and it is forced on the first argument (true). By default 102 | % the file is not saved. 103 | 104 | currentEditorPage = matlab.desktop.editor.getActive(); 105 | 106 | if isempty(currentEditorPage) 107 | return; 108 | end 109 | 110 | currentSelection = currentEditorPage.Selection; 111 | 112 | if isempty(currentEditorPage.SelectedText) 113 | return; 114 | end 115 | 116 | if nargin == 0 117 | doSave = false; 118 | end 119 | 120 | % Expand the selection from the beginnig of the first line to the end of the last line 121 | expandedSelection = [currentSelection(1), 1, currentSelection(3), Inf]; 122 | 123 | 124 | % Search for the first empty line before the selection 125 | if currentSelection(1) > 1 126 | lineBeforePosition = [currentSelection(1) - 1, 1, currentSelection(1) - 1, Inf]; 127 | 128 | currentEditorPage.Selection = lineBeforePosition; 129 | lineBeforeText = currentEditorPage.SelectedText; 130 | 131 | while lineBeforePosition(1) > 1 && ~isempty(strtrim(lineBeforeText)) 132 | lineBeforePosition = [lineBeforePosition(1) - 1, 1, lineBeforePosition(1) - 1, Inf]; 133 | currentEditorPage.Selection = lineBeforePosition; 134 | lineBeforeText = currentEditorPage.SelectedText; 135 | end 136 | end 137 | expandedSelection = [lineBeforePosition(1), 1, expandedSelection(3), Inf]; 138 | 139 | % Search for the first empty line after the selection 140 | lineAfterSelection = [currentSelection(3) + 1, 1, currentSelection(3) + 1, Inf]; 141 | currentEditorPage.Selection = lineAfterSelection; 142 | lineAfterText = currentEditorPage.SelectedText; 143 | beforeselect = currentSelection(1); 144 | while ~isequal(lineAfterSelection(1), beforeselect) && ~isempty(strtrim(lineAfterText)) 145 | beforeselect = lineAfterSelection(1); 146 | lineAfterSelection = [lineAfterSelection(1) + 1, 1, lineAfterSelection(1) + 1, Inf]; 147 | currentEditorPage.Selection = lineAfterSelection; 148 | lineAfterText = currentEditorPage.SelectedText; 149 | 150 | end 151 | 152 | endReached = isequal(lineAfterSelection(1), currentSelection(1)); 153 | 154 | expandedSelection = [expandedSelection(1), 1, lineAfterSelection(3), Inf]; 155 | 156 | if isequal(currentSelection(1), 1) 157 | codeBefore = ''; 158 | else 159 | codeBeforeSelection = [1, 1, expandedSelection(1), Inf]; 160 | currentEditorPage.Selection = codeBeforeSelection; 161 | codeBefore = currentEditorPage.SelectedText; 162 | end 163 | 164 | if endReached 165 | codeAfter = ''; 166 | else 167 | codeAfterSelection = [expandedSelection(3) + 1, 1, Inf, Inf]; 168 | currentEditorPage.Selection = codeAfterSelection; 169 | codeAfter = currentEditorPage.SelectedText; 170 | 171 | end 172 | 173 | currentEditorPage.Selection = expandedSelection; 174 | codeToFormat = currentEditorPage.SelectedText; 175 | selectedPosition = currentEditorPage.Selection; 176 | 177 | % Format the code 178 | formatter = MFormatter(MBeautify.getConfigurationStruct()); 179 | formattedSource = formatter.performFormatting(codeToFormat); 180 | 181 | % Save back the modified data then use Matlab samrt indent functionality 182 | % Set back the selection 183 | currentEditorPage.Text = [codeBefore, formattedSource, codeAfter]; 184 | if ~isempty(selectedPosition) 185 | currentEditorPage.goToLine(selectedPosition(1)); 186 | end 187 | currentEditorPage.smartIndentContents(); 188 | currentEditorPage.makeActive(); 189 | 190 | % Save if it is possible 191 | if doSave 192 | fileName = currentEditorPage.Filename; 193 | if exist(fileName, 'file') && numel(fileparts(fileName)) 194 | fileattrib(fileName, '+w'); 195 | currentEditorPage.saveAs(currentEditorPage.Filename) 196 | end 197 | end 198 | end 199 | 200 | function formatCurrentEditorPage(doSave) 201 | % Performs formatting on the currently active Matlab Editor page. 202 | % Optionally saves the file (if it is possible) and it is forced on the first argument (true). By default 203 | % the file is not saved. 204 | 205 | currentEditorPage = matlab.desktop.editor.getActive(); 206 | if isempty(currentEditorPage) 207 | return; 208 | end 209 | 210 | if nargin == 0 211 | doSave = false; 212 | end 213 | 214 | selectedPosition = currentEditorPage.Selection; 215 | 216 | % Format the code 217 | formatter = MFormatter(MBeautify.getConfigurationStruct()); 218 | currentEditorPage.Text = formatter.performFormatting(currentEditorPage.Text); 219 | 220 | % Set back the selection 221 | if ~isempty(selectedPosition) 222 | currentEditorPage.goToLine(selectedPosition(1)); 223 | end 224 | % Use Smart Indent 225 | currentEditorPage.smartIndentContents(); 226 | currentEditorPage.makeActive(); 227 | 228 | % Save if it is possible 229 | if doSave 230 | fileName = currentEditorPage.Filename; 231 | if exist(fileName, 'file') && numel(fileparts(fileName)) 232 | fileattrib(fileName, '+w'); 233 | currentEditorPage.saveAs(currentEditorPage.Filename) 234 | end 235 | end 236 | end 237 | 238 | function createShortcut(mode) 239 | % Creates a shortcut with the selected mode: 'editorpage', 'editorselection', 'file'. The shortcut adds 240 | % MBeauty to the Matlab path and executes the following command: 241 | % 'editorpage' - MBeauty.formatCurrentEditorPage 242 | % 'editorselection' - MBeauty.formatEditorSelection 243 | % 'file' - MBeauty.formatFile 244 | 245 | MBeautyShortcuts.createShortcut(mode); 246 | end 247 | 248 | end 249 | 250 | %% Private helpers 251 | 252 | methods(Static = true, Access = private) 253 | 254 | % Method to mimic a static data member 255 | % Indicates that the token parsing is up to date or the rules file should be reparsed 256 | function val = parsingUpToDate(val) 257 | persistent currentval; 258 | if isempty(currentval) 259 | currentval = true; 260 | end 261 | if nargin >= 1 262 | currentval = val; 263 | end 264 | 265 | val = currentval; 266 | end 267 | 268 | function configurationStruct = getConfigurationStruct() 269 | % MBeautify.getConfigurationStruct returns the configuration struct from the rules file 270 | 271 | % Persistent variable to store the returned rules 272 | % If MBeautify.setup was not called, the stored struct should be returned 273 | persistent configurationStructStored; 274 | 275 | if isempty(configurationStructStored) || ~MBeautify.parsingUpToDate() 276 | currCD = cd(); 277 | cd(MBeautify.SettingDirectory); 278 | configurationStruct = eval(MBeautify.RulesMFile(1:end - 2)); 279 | cd(currCD) 280 | configurationStructStored = configurationStruct; 281 | MBeautify.parsingUpToDate(true); 282 | else 283 | configurationStruct = configurationStructStored; 284 | end 285 | 286 | end 287 | 288 | 289 | function writeConfigurationFile(resStruct) 290 | % MBeautify.writeConfigurationFile creates the configuration M file from the structure of the configuration XML file. 291 | 292 | operetorRules = resStruct.OperatorRules; 293 | opFields = fields(operetorRules); 294 | 295 | [pathOfMFile, nameOfMFile] = fileparts(MBeautify.RulesMFileFull); %#ok 296 | 297 | settingMFileString = ['function this = ', nameOfMFile, '()', sprintf('\n'), ... 298 | 'this = struct();', sprintf('\n'), sprintf('\n')]; 299 | 300 | settingMFileString = [settingMFileString, 'this.OperatorRules = struct();', sprintf('\n'), sprintf('\n')]; 301 | 302 | for iOp = 1:numel(opFields) 303 | 304 | settingMFileString = [settingMFileString, sprintf('\n')]; 305 | settingMFileString = [settingMFileString, ['this.OperatorRules.', opFields{iOp}, ' = struct();'], sprintf('\n')]; 306 | 307 | valueFrom = regexptranslate('escape', operetorRules.(opFields{iOp}).ValueFrom); 308 | valueTo = regexptranslate('escape', operetorRules.(opFields{iOp}).ValueTo); 309 | 310 | settingMFileString = [settingMFileString, ['this.OperatorRules.', opFields{iOp}, '.ValueFrom = ''', valueFrom, ''';'], sprintf('\n')]; 311 | settingMFileString = [settingMFileString, ['this.OperatorRules.', opFields{iOp}, '.ValueTo = ''', valueTo, ''';'], sprintf('\n')]; 312 | end 313 | 314 | 315 | settingMFileString = [settingMFileString, 'this.SpecialRules = struct();', sprintf('\n'), sprintf('\n')]; 316 | 317 | specialRules = resStruct.SpecialRules; 318 | spFields = fields(specialRules); 319 | 320 | for iSp = 1:numel(spFields) 321 | settingMFileString = [settingMFileString, sprintf('\n')]; %#ok<*AGROW> 322 | settingMFileString = [settingMFileString, ['this.SpecialRules.', spFields{iSp}, ' = struct();'], sprintf('\n')]; 323 | settingMFileString = [settingMFileString, ['this.SpecialRules.', spFields{iSp}, 'Value = ''', specialRules.(spFields{iSp}).Value, ''';'], sprintf('\n')]; 324 | end 325 | 326 | settingMFileString = [settingMFileString, 'end']; 327 | 328 | if exist(MBeautify.RulesMFileFull, 'file') 329 | fileattrib(MBeautify.RulesMFileFull, '+w'); 330 | end 331 | fid = fopen(MBeautify.RulesMFileFull, 'w'); 332 | fwrite(fid, settingMFileString); 333 | fclose(fid); 334 | 335 | end 336 | 337 | 338 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 339 | % Writes the default settings XML file 340 | function writeSettingsXML() 341 | % MBeautify.writeSettingsXML creates the default configuration XML structure to the configuration XML file. 342 | 343 | docNode = com.mathworks.xml.XMLUtils.createDocument('MBeautifyRuleConfiguration'); 344 | docRootNode = docNode.getDocumentElement(); 345 | 346 | operatorPaddings = docNode.createElement('OperatorPadding'); 347 | docRootNode.appendChild(operatorPaddings); 348 | 349 | specialRules = docNode.createElement('SpecialRules'); 350 | docRootNode.appendChild(specialRules); 351 | 352 | %% Add operator rules 353 | operatorPaddings = appendOperatorPaddingRule('ShortCircuitAnd', '&&', ' && ', operatorPaddings, docNode); 354 | operatorPaddings = appendOperatorPaddingRule('ShortCircuitOr', '||', ' || ', operatorPaddings, docNode); 355 | operatorPaddings = appendOperatorPaddingRule('LogicalAnd', '&', ' & ', operatorPaddings, docNode); 356 | operatorPaddings = appendOperatorPaddingRule('LogicalOr', '|', ' | ', operatorPaddings, docNode); 357 | operatorPaddings = appendOperatorPaddingRule('LessEquals', '<=', ' <= ', operatorPaddings, docNode); 358 | operatorPaddings = appendOperatorPaddingRule('Less', '<', ' < ', operatorPaddings, docNode); 359 | operatorPaddings = appendOperatorPaddingRule('GreaterEquals', '>=', ' >= ', operatorPaddings, docNode); 360 | operatorPaddings = appendOperatorPaddingRule('Greater', '>', ' > ', operatorPaddings, docNode); 361 | operatorPaddings = appendOperatorPaddingRule('Equals', '==', ' == ', operatorPaddings, docNode); 362 | operatorPaddings = appendOperatorPaddingRule('NotEquals', '~=', ' ~= ', operatorPaddings, docNode); 363 | operatorPaddings = appendOperatorPaddingRule('Assignment', '=', ' = ', operatorPaddings, docNode); 364 | operatorPaddings = appendOperatorPaddingRule('Plus', '+', ' + ', operatorPaddings, docNode); 365 | operatorPaddings = appendOperatorPaddingRule('Minus', '-', ' - ', operatorPaddings, docNode); 366 | operatorPaddings = appendOperatorPaddingRule('ElementWiseMultiplication', '.*', ' .* ', operatorPaddings, docNode); 367 | operatorPaddings = appendOperatorPaddingRule('Multiplication', '*', ' * ', operatorPaddings, docNode); 368 | operatorPaddings = appendOperatorPaddingRule('RightArrayDivision', './', ' ./ ', operatorPaddings, docNode); 369 | operatorPaddings = appendOperatorPaddingRule('LeftArrayDivision', '.\', ' .\ ', operatorPaddings, docNode); 370 | operatorPaddings = appendOperatorPaddingRule('Division', '/', ' / ', operatorPaddings, docNode); 371 | operatorPaddings = appendOperatorPaddingRule('LeftDivision', '\', ' \ ', operatorPaddings, docNode); 372 | operatorPaddings = appendOperatorPaddingRule('ElementWisePower', '.^', '.^', operatorPaddings, docNode); 373 | operatorPaddings = appendOperatorPaddingRule('Power', '^', '^', operatorPaddings, docNode); 374 | operatorPaddings = appendOperatorPaddingRule('Not', '~', ' ~', operatorPaddings, docNode); 375 | operatorPaddings = appendOperatorPaddingRule('Comma', ',', ', ', operatorPaddings, docNode); 376 | operatorPaddings = appendOperatorPaddingRule('SemiColon', ';', '; ', operatorPaddings, docNode); 377 | appendOperatorPaddingRule('Colon', ':', ':', operatorPaddings, docNode); 378 | 379 | %% Add special rules 380 | specialRules = appendSpecialRule('MaximalNewLines', '2', specialRules, docNode); 381 | specialRules = appendSpecialRule('AddCommasToMatrices', '1', specialRules, docNode); 382 | specialRules = appendSpecialRule('AddCommasToCellArrays', '1', specialRules, docNode); 383 | specialRules = appendSpecialRule('CellArrayIndexing_ArithmeticOperatorPadding', '0', specialRules, docNode); 384 | appendSpecialRule('MatrixIndexing_ArithmeticOperatorPadding', '0', specialRules, docNode); 385 | 386 | xmlwrite(MBeautify.RulesXMLFileFull, docNode); 387 | 388 | fprintf('Default configuration XML has been created:\n%s\n', MBeautify.RulesXMLFileFull); 389 | 390 | 391 | function operatorPaddings = appendOperatorPaddingRule(key, valueFrom, valueTo, operatorPaddings, docNode) 392 | opPaddingRule = docNode.createElement('OperatorPaddingRule'); 393 | 394 | keyElement = docNode.createElement('Key'); 395 | keyElement.appendChild(docNode.createTextNode(key)); 396 | 397 | valueFromElement = docNode.createElement('ValueFrom'); 398 | valueFromElement.appendChild(docNode.createTextNode(valueFrom)); 399 | 400 | valueToElement = docNode.createElement('ValueTo'); 401 | valueToElement.appendChild(docNode.createTextNode(valueTo)); 402 | 403 | opPaddingRule.appendChild(keyElement); 404 | opPaddingRule.appendChild(valueFromElement); 405 | opPaddingRule.appendChild(valueToElement); 406 | 407 | operatorPaddings.appendChild(opPaddingRule); 408 | 409 | end 410 | 411 | function specialRules = appendSpecialRule(key, value, specialRules, docNode) 412 | specialRule = docNode.createElement('SpecialRule'); 413 | 414 | keyElement = docNode.createElement('Key'); 415 | keyElement.appendChild(docNode.createTextNode(key)); 416 | 417 | valueElement = docNode.createElement('Value'); 418 | valueElement.appendChild(docNode.createTextNode(value)); 419 | 420 | specialRule.appendChild(keyElement); 421 | specialRule.appendChild(valueElement); 422 | 423 | specialRules.appendChild(specialRule); 424 | 425 | end 426 | 427 | end 428 | 429 | % Reads the settings XML file to a structure 430 | function settingsStruct = readSettingsXML() 431 | % MBeautify.readSettingsXML reads the configuration XML file to a structure. 432 | 433 | settingsStruct = struct('OperatorRules', struct(), 'SpecialRules', struct()); 434 | 435 | XMLDoc = xmlread(MBeautify.RulesXMLFileFull); 436 | 437 | allOperatorItems = XMLDoc.getElementsByTagName('OperatorPaddingRule'); 438 | operatorNode = settingsStruct.OperatorRules; 439 | 440 | for iOperator = 0:allOperatorItems.getLength() -1 441 | 442 | currentOperator = allOperatorItems.item(iOperator); 443 | 444 | key = char(currentOperator.getElementsByTagName('Key').item(0).getTextContent().toString()); 445 | operatorNode.(key) = struct(); 446 | operatorNode.(key).ValueFrom = removeXMLEscaping(char(currentOperator.getElementsByTagName('ValueFrom').item(0).getTextContent().toString())); 447 | operatorNode.(key).ValueTo = removeXMLEscaping(char(currentOperator.getElementsByTagName('ValueTo').item(0).getTextContent().toString())); 448 | end 449 | 450 | settingsStruct.OperatorRules = operatorNode; 451 | 452 | allSpecialItems = XMLDoc.getElementsByTagName('SpecialRule'); 453 | specialRulesNode = settingsStruct.SpecialRules; 454 | 455 | for iSpecRule = 0:allSpecialItems.getLength() -1 456 | 457 | currentRule = allSpecialItems.item(iSpecRule); 458 | 459 | key = char(currentRule.getElementsByTagName('Key').item(0).getTextContent().toString()); 460 | specialRulesNode.(key) = struct(); 461 | specialRulesNode.(key).Value = char(currentRule.getElementsByTagName('Value').item(0).getTextContent().toString()); 462 | end 463 | 464 | settingsStruct.SpecialRules = specialRulesNode; 465 | 466 | function escapedValue = removeXMLEscaping(value) 467 | escapedValue = regexprep(value, '<', '<'); 468 | escapedValue = regexprep(escapedValue, '&', '&'); 469 | escapedValue = regexprep(escapedValue, '>', '>'); 470 | 471 | end 472 | 473 | end 474 | 475 | 476 | end 477 | end 478 | 479 | -------------------------------------------------------------------------------- /MBeautifier/MBeautyShortcuts.m: -------------------------------------------------------------------------------- 1 | classdef MBeautyShortcuts 2 | % Creates and executes MBeautifier related Matlab shortcuts. 3 | 4 | properties(Access = private, Constant) 5 | ShorcutModes = {'editorpage', 'editorselection', 'file'}; 6 | end 7 | 8 | methods(Static) 9 | 10 | function createShortcut(mode) 11 | % Creates a shortcut with the selected mode: 'editorpage', 'editorselection', 'file' 12 | % 'editorpage' - Execute MBeauty.formatCurrentEditorPage 13 | % 'editorselection' - Execute MBeauty.formatEditorSelection 14 | % 'file' - Execute MBeauty.formatFile 15 | 16 | mode = MBeautyShortcuts.checkMode(mode); 17 | 18 | if ~verLessThan('matlab', '8.0') 19 | category = 'MBeautifier'; 20 | else 21 | category = 'Toolbar Shortcuts'; 22 | end 23 | 24 | shortCutStruct = MBeautyShortcuts.getShortcutCategoryStructure(mode); 25 | 26 | shortcutUtils = com.mathworks.mlwidgets.shortcuts.ShortcutUtils(); 27 | 28 | try 29 | shortcutUtils.removeShortcut(category, shortCutStruct.Name); 30 | catch %#ok 31 | % This command only fails on R2012b 32 | end 33 | shortcutUtils.addShortcutToBottom(shortCutStruct.Name, shortCutStruct.Callback, '', category, 'true'); 34 | 35 | end 36 | 37 | function executeCallback(mode) 38 | mode = MBeautyShortcuts.checkMode(mode); 39 | if strcmp(mode, 'editorpage') 40 | MBeautyShortcuts.editorPageShortcutCallback(); 41 | elseif strcmp(mode, 'editorselection') 42 | MBeautyShortcuts.editorSelectionShortcutCallback(); 43 | elseif strcmp(mode, 'file') 44 | MBeautyShortcuts.fileShortcutCallback(); 45 | end 46 | end 47 | end 48 | 49 | methods(Static, Access = private) 50 | 51 | function structure = getShortcutCategoryStructure(mode) 52 | mode = MBeautyShortcuts.checkMode(mode); 53 | 54 | if strcmp(mode, 'editorpage') 55 | structure = MBeautyShortcuts.getEditorPageShortcut(); 56 | elseif strcmp(mode, 'editorselection') 57 | structure = MBeautyShortcuts.getEditorSelectionShortcut(); 58 | elseif strcmp(mode, 'file') 59 | structure = MBeautyShortcuts.getFileShortcut(); 60 | end 61 | 62 | pathToAdd = eval('fileparts(mfilename(''fullpath''))'); 63 | addPathCommand = ['addpath(''', pathToAdd, ''');']; 64 | structure.Callback = [addPathCommand, structure.Callback]; 65 | 66 | end 67 | 68 | function mode = checkMode(mode) 69 | 70 | mode = lower(strtrim(mode)); 71 | if ~any(strcmp(mode, MBeautyShortcuts.ShorcutModes)) 72 | error('MBeautifier:InvalidShortcutMode', 'Unavailable shortcut mode defined!'); 73 | end 74 | end 75 | 76 | function structure = getEditorPageShortcut() 77 | structure = struct(); 78 | structure.Name = 'MBeauty: Format Editor Page'; 79 | structure.Callback = MBeautyShortcuts.editorPageShortcutCallback(); 80 | end 81 | 82 | function command = editorPageShortcutCallback() 83 | command = 'MBeautify.formatCurrentEditorPage();'; 84 | end 85 | 86 | 87 | function structure = getEditorSelectionShortcut() 88 | structure = struct(); 89 | structure.Name = 'MBeauty: Format Editor Selection'; 90 | structure.Callback = MBeautyShortcuts.editorSelectionShortcutCallback(); 91 | end 92 | 93 | function command = editorSelectionShortcutCallback() 94 | 95 | command = 'MBeautify.formatEditorSelection();'; 96 | end 97 | 98 | function structure = getFileShortcut() 99 | structure = struct(); 100 | structure.Name = 'MBeauty: Format File'; 101 | structure.Callback = MBeautyShortcuts.fileShortcutCallback(); 102 | end 103 | 104 | function command = fileShortcutCallback() 105 | command = ['[sourceFile, sourcePath] = uigetfile(); drawnow(); sourceFile = fullfile(sourcePath, sourceFile);', ... 106 | 'if isempty(sourceFile), return; end', sprintf('\n'), ... 107 | '[destFile, destPath] = uiputfile(); drawnow(); destFile = fullfile(destPath, destFile);', ... 108 | 'if isempty(destFile), return; end', sprintf('\n'), ... 109 | 'MBeautify.formatFile(sourceFile, destFile);']; 110 | end 111 | end 112 | 113 | end 114 | 115 | -------------------------------------------------------------------------------- /MBeautifier/MFormatter.m: -------------------------------------------------------------------------------- 1 | classdef MFormatter < handle 2 | % Performs the actual code formatting. Should not be used directly but only by MBeautify. 3 | 4 | properties (Access = private) 5 | SettingConfiguration; 6 | AllOperators; 7 | 8 | % Properties used during the formatting 9 | StringTokenStructs; 10 | BlockCommentDepth; 11 | IsInBlockComment; 12 | 13 | MatrixIndexingOperatorPadding; 14 | CellArrayIndexingOperatorPadding; 15 | end 16 | 17 | properties(Access = private, Constant) 18 | WhiteSpaceToken = '#MBeauty_WhiteSpace_Token#'; 19 | ContainerOpeningBrackets = {'[', '{', '('}; 20 | ContainerClosingBrackets = {']', '}', ')'}; 21 | TokenStruct = MFormatter.getTokenStruct(); 22 | end 23 | 24 | methods 25 | 26 | function obj = MFormatter(settingConfiguration) 27 | % Creates a new formatter using the passed configuration. 28 | 29 | obj.SettingConfiguration = settingConfiguration; 30 | 31 | obj.MatrixIndexingOperatorPadding = str2double(obj.SettingConfiguration.SpecialRules.MatrixIndexing_ArithmeticOperatorPaddingValue); 32 | obj.CellArrayIndexingOperatorPadding = str2double(obj.SettingConfiguration.SpecialRules.CellArrayIndexing_ArithmeticOperatorPaddingValue); 33 | 34 | % Init run-time members 35 | obj.StringTokenStructs = {}; 36 | obj.BlockCommentDepth = 0; 37 | obj.IsInBlockComment = false; 38 | 39 | % All of these because of performance reasons 40 | % Update the setting configuration with more members: mostly tokens and regular expressions that can be 41 | % calculated only once, and it costs a lot if they are calculated for every line. 42 | 43 | fieldList = fields(obj.SettingConfiguration.OperatorRules); 44 | obj.AllOperators = cell(numel(fieldList), 1); 45 | 46 | wsTokenLength = numel(obj.WhiteSpaceToken); 47 | 48 | for i = 1:numel(fieldList) 49 | 50 | obj.AllOperators{i} = obj.SettingConfiguration.OperatorRules.(fieldList{i}).ValueFrom; 51 | obj.SettingConfiguration.OperatorRules.(fieldList{i}).OperatorToken = ['#MBeauty_OP_', fieldList{i}, '#']; 52 | 53 | tokenizedReplaceString = strrep(obj.SettingConfiguration.OperatorRules.(fieldList{i}).ValueTo, ... 54 | ' ', obj.WhiteSpaceToken); 55 | % Calculate the starting WS count 56 | leadingWSNum = 0; 57 | matchCell = regexp(tokenizedReplaceString, ['^(', obj.WhiteSpaceToken, ')+'], 'match'); 58 | if numel(matchCell) 59 | leadingWSNum = numel(matchCell{1}) / wsTokenLength; 60 | end 61 | 62 | % Calculate ending whitespace count 63 | endingWSNum = 0; 64 | matchCell = regexp(tokenizedReplaceString, ['(', obj.WhiteSpaceToken, ')+$'], 'match'); 65 | if numel(matchCell) 66 | endingWSNum = numel(matchCell{1}) / wsTokenLength; 67 | end 68 | 69 | obj.SettingConfiguration.OperatorRules.(fieldList{i}).ReplacementPattern = ... 70 | ['\s*(', obj.WhiteSpaceToken, '){0,', num2str(leadingWSNum), '}', ... 71 | obj.SettingConfiguration.OperatorRules.(fieldList{i}).OperatorToken, ... 72 | '(', obj.WhiteSpaceToken, '){0,', num2str(endingWSNum), '}\s*']; 73 | 74 | 75 | if numel(regexp(obj.SettingConfiguration.OperatorRules.(fieldList{i}).ValueFrom, '\+|\-|\/|\*')) 76 | if ~str2double(obj.SettingConfiguration.SpecialRules.MatrixIndexing_ArithmeticOperatorPaddingValue) 77 | obj.SettingConfiguration.OperatorRules.(fieldList{i}).MatrixIndexingReplacementPattern = ... 78 | ['\s*(', obj.WhiteSpaceToken, '){0,0}', ... 79 | obj.SettingConfiguration.OperatorRules.(fieldList{i}).OperatorToken, ... 80 | '(', obj.WhiteSpaceToken, '){0,0}\s*']; 81 | else 82 | obj.SettingConfiguration.OperatorRules.(fieldList{i}).MatrixIndexingReplacementPattern = ... 83 | obj.SettingConfiguration.OperatorRules.(fieldList{i}).ReplacementPattern; 84 | end 85 | 86 | if ~str2double(obj.SettingConfiguration.SpecialRules.CellArrayIndexing_ArithmeticOperatorPaddingValue) 87 | obj.SettingConfiguration.OperatorRules.(fieldList{i}).CellArrayIndexingReplacementPattern = ... 88 | ['\s*(', obj.WhiteSpaceToken, '){0,0}', ... 89 | obj.SettingConfiguration.OperatorRules.(fieldList{i}).OperatorToken, ... 90 | '(', obj.WhiteSpaceToken, '){0,0}\s*']; 91 | else 92 | obj.SettingConfiguration.OperatorRules.(fieldList{i}).CellArrayIndexingReplacementPattern = ... 93 | obj.SettingConfiguration.OperatorRules.(fieldList{i}).ReplacementPattern; 94 | end 95 | end 96 | end 97 | end 98 | 99 | function formattedSource = performFormatting(obj, source) 100 | % Performs formatting on the specified source. 101 | 102 | obj.StringTokenStructs = {}; 103 | obj.BlockCommentDepth = 0; 104 | obj.IsInBlockComment = false; 105 | 106 | nMaximalNewLines = str2double(obj.SettingConfiguration.SpecialRules.MaximalNewLinesValue); 107 | nSectionPrecedingNewlines = str2double(obj.SettingConfiguration.SpecialRules.SectionPrecedingNewlineCountValue); 108 | formatSectionPrecedingNewlines = nSectionPrecedingNewlines >= 0; 109 | nSectionTrailingNewlines = str2double(obj.SettingConfiguration.SpecialRules.SectionTrailingNewlineCountValue); 110 | formatSectionTrailingNewlines = nSectionTrailingNewlines >= 0; 111 | newLine = sprintf('\n'); 112 | 113 | contTokenStruct = MFormatter.TokenStruct.ContinueToken; 114 | 115 | textArray = regexp(source, newLine, 'split'); 116 | 117 | replacedTextArray = {}; 118 | isInContinousLine = 0; 119 | containerDepth = 0; 120 | contLineArray = cell(0, 2); 121 | isSectionSeparator = false; 122 | 123 | nNewLinesFound = 0; 124 | for j = 1:numel(textArray) 125 | line = textArray{j}; 126 | 127 | %% Process the maximal new-line count 128 | if isempty(strtrim(line)) 129 | nNewLinesFound = nNewLinesFound + 1; 130 | 131 | if nNewLinesFound > nMaximalNewLines || ... 132 | (formatSectionTrailingNewlines && isSectionSeparator && nNewLinesFound > nSectionTrailingNewlines) 133 | continue; 134 | end 135 | 136 | replacedTextArray = [replacedTextArray, sprintf('\n')]; 137 | continue; 138 | 139 | else 140 | if isSectionSeparator && formatSectionTrailingNewlines && (nNewLinesFound - nSectionTrailingNewlines < 0) 141 | for i = 1:abs(nNewLinesFound - nSectionTrailingNewlines) 142 | replacedTextArray = [replacedTextArray, sprintf('\n')]; 143 | end 144 | end 145 | 146 | nNewLinesFound = 0; 147 | end 148 | 149 | 150 | 151 | %% Determine the position where the line shall be splitted into code and comment 152 | [actCode, actComment, splittingPos, isSectionSeparator] = obj.findComment(line); 153 | 154 | if isSectionSeparator && formatSectionPrecedingNewlines 155 | replacedTextArray = MFormatter.handleTrailingEmptyLines(replacedTextArray, nSectionPrecedingNewlines); 156 | end 157 | 158 | 159 | %% Check for line continousment (...) 160 | % Continous lines have to be converted into one single code line to perform replacement on it 161 | % The continousment characters have to be replaced by tokens and the comments of the lines must be stored 162 | % After replacement, the continuosment has to be re-created along with the comments. 163 | 164 | trimmedCode = strtrim(actCode); 165 | if ~numel(trimmedCode) 166 | actCodeFinal = ''; 167 | else 168 | containerDepth = containerDepth + obj.calculateContainerDepthDeltaOfLine(trimmedCode); 169 | 170 | % Auto append "..." to the lines of continuous containers 171 | if containerDepth && ~(numel(trimmedCode) >= 3 && strcmp(trimmedCode(end - 2:end), '...')) 172 | if strcmp(trimmedCode(end), ',') || strcmp(trimmedCode(end), ';') 173 | actCode = [trimmedCode, ' ...']; 174 | else 175 | actCode = [actCode, '; ...']; 176 | end 177 | 178 | end 179 | 180 | trimmedCode = strtrim(actCode); 181 | 182 | % Line ends with "..." 183 | if (numel(trimmedCode) >= 3 && strcmp(trimmedCode(end - 2:end), '...')) ... 184 | || (isequal(splittingPos, 1) && isInContinousLine) 185 | isInContinousLine = true; 186 | contLineArray{end + 1, 1} = actCode; 187 | contLineArray{end, 2} = actComment; 188 | % Step to next line 189 | continue; 190 | else 191 | % End of cont line 192 | if isInContinousLine 193 | isInContinousLine = false; 194 | contLineArray{end + 1, 1} = actCode; 195 | contLineArray{end, 2} = actComment; 196 | 197 | % Build the line for replacement 198 | replacedLines = ''; 199 | for iLine = 1:size(contLineArray, 1) -1 200 | tempRow = strtrim(contLineArray{iLine, 1}); 201 | tempRow = [tempRow(1:end - 3), [' ', contTokenStruct.Token, ' ']]; 202 | tempRow = regexprep(tempRow, ['\s+', contTokenStruct.Token, '\s+'], [' ', contTokenStruct.Token, ' ']); 203 | replacedLines = [replacedLines, tempRow]; 204 | end 205 | replacedLines = [replacedLines, actCode]; 206 | 207 | % Replace 208 | actCodeFinal = obj.performReplacements(replacedLines); 209 | 210 | % Re-create the original structure 211 | splitToLine = regexp(actCodeFinal, contTokenStruct.Token, 'split'); 212 | 213 | line = ''; 214 | for iSplitLine = 1:numel(splitToLine) -1 215 | line = [line, strtrim(splitToLine{iSplitLine}), [' ', contTokenStruct.StoredValue, ' '], contLineArray{iSplitLine, 2}, newLine]; 216 | end 217 | 218 | line = [line, strtrim(splitToLine{end}), actComment]; %#ok<*AGROW> 219 | replacedTextArray = [replacedTextArray, {line, sprintf('\n')}]; 220 | contLineArray = cell(0, 2); 221 | 222 | continue; 223 | end 224 | 225 | end 226 | 227 | actCodeFinal = obj.performReplacements(actCode); 228 | end 229 | 230 | if ~obj.IsInBlockComment 231 | line = [strtrim(actCodeFinal), ' ', actComment]; 232 | else 233 | line = [strtrim(actCodeFinal), actComment]; 234 | end 235 | replacedTextArray = [replacedTextArray, [line, sprintf('\n')]]; 236 | end 237 | % The last new-line must be removed: inner new-lines are removed by the split, the last one is an additional one 238 | if numel(replacedTextArray) && numel(strtrim(replacedTextArray{end})) 239 | replacedTextArray{end} = strtrim(replacedTextArray{end}); 240 | end 241 | 242 | nEndingNewlines = str2double(obj.SettingConfiguration.SpecialRules.EndingNewlineCountValue); 243 | formatEndingNewlines = nEndingNewlines >= 0; 244 | if formatEndingNewlines 245 | 246 | replacedTextArray = MFormatter.handleTrailingEmptyLines(replacedTextArray, nEndingNewlines); 247 | 248 | replacedTextArray{end} = strtrim(replacedTextArray{end}); 249 | end 250 | 251 | formattedSource = [replacedTextArray{:}]; 252 | end 253 | end 254 | 255 | methods (Access = private, Static) 256 | 257 | function textArray = handleTrailingEmptyLines(textArray, neededEmptyLineCount) 258 | precedingNewLines = MFormatter.getPrecedingNewlineCount(textArray); 259 | 260 | newLineDelta = neededEmptyLineCount - precedingNewLines; 261 | 262 | if newLineDelta < 0 263 | for i = 1:abs(newLineDelta) 264 | textArray(end) = []; 265 | end 266 | elseif newLineDelta > 0 267 | for i = 1:newLineDelta 268 | textArray = [textArray, sprintf('\n')]; 269 | end 270 | 271 | end 272 | 273 | end 274 | 275 | function count = getPrecedingNewlineCount(textArray) 276 | count = 0; 277 | for i = numel(textArray):-1:1 278 | if isempty(strtrim(textArray{i})) 279 | count = count + 1; 280 | else 281 | return; 282 | end 283 | end 284 | end 285 | 286 | function outStr = joinString(cellStr, delim) 287 | 288 | outStr = ''; 289 | for i = 1:numel(cellStr) 290 | outStr = [outStr, cellStr{i}, delim]; 291 | end 292 | 293 | outStr(end-numel(delim)+1:end) = ''; 294 | 295 | end 296 | 297 | function tokenStructs = getTokenStruct() 298 | % Returns the tokens used in replacement. 299 | 300 | % Persistent variable to serve as cache 301 | persistent tokenStructStored; 302 | if isempty(tokenStructStored) 303 | 304 | tokenStructs = struct(); 305 | tokenStructs.ContinueToken = newStruct('...', '#MBeutyCont#'); 306 | tokenStructs.StringToken = newStruct('', '#MBeutyString#'); 307 | tokenStructs.ArrayElementToken = newStruct('', '#MBeutyArrayElement#'); 308 | tokenStructs.TransposeToken = newStruct('''', '#MBeutyTransp#'); 309 | tokenStructs.NonConjTransposeToken = newStruct('.''', '#MBeutyNonConjTransp#'); 310 | tokenStructs.NormNotationPlus = newStruct('+', '#MBeauty_OP_NormNotationPlus'); 311 | tokenStructs.NormNotationMinus = newStruct('-', '#MBeauty_OP_NormNotationMinus'); 312 | tokenStructs.UnaryPlus = newStruct('+', '#MBeauty_OP_UnaryPlus'); 313 | tokenStructs.UnaryMinus = newStruct('-', '#MBeauty_OP_UnaryMinus'); 314 | 315 | tokenStructStored = tokenStructs; 316 | else 317 | tokenStructs = tokenStructStored; 318 | end 319 | 320 | function retStruct = newStruct(storedValue, replacementString) 321 | retStruct = struct('StoredValue', storedValue, 'Token', replacementString); 322 | end 323 | end 324 | 325 | function code = restoreTransponations(code) 326 | % Restores transponation tokens to original transponation signs. 327 | 328 | trnspTokStruct = MFormatter.TokenStruct.TransposeToken; 329 | nonConjTrnspTokStruct = MFormatter.TokenStruct.NonConjTransposeToken; 330 | 331 | code = regexprep(code, trnspTokStruct.Token, trnspTokStruct.StoredValue); 332 | code = regexprep(code, nonConjTrnspTokStruct.Token, nonConjTrnspTokStruct.StoredValue); 333 | end 334 | 335 | function actCode = replaceTransponations(actCode) 336 | % Replaces transponation signs in the code with tokens. 337 | 338 | trnspTokStruct = MFormatter.TokenStruct.TransposeToken; 339 | nonConjTrnspTokStruct = MFormatter.TokenStruct.NonConjTransposeToken; 340 | 341 | charsIndicateTranspose = '[a-zA-Z0-9\)\]\}\.]'; 342 | 343 | tempCode = ''; 344 | isLastCharDot = false; 345 | isLastCharTransp = false; 346 | isInStr = false; 347 | for iStr = 1:numel(actCode) 348 | actChar = actCode(iStr); 349 | 350 | if isequal(actChar, '''') 351 | % .' => NonConj transpose 352 | if isLastCharDot 353 | tempCode = [tempCode(1:end - 1), nonConjTrnspTokStruct.Token]; 354 | isLastCharTransp = true; 355 | else 356 | if isLastCharTransp 357 | tempCode = [tempCode, trnspTokStruct.Token]; 358 | else 359 | if numel(tempCode) && ~isInStr && numel(regexp(tempCode(end), charsIndicateTranspose)) 360 | tempCode = [tempCode, trnspTokStruct.Token]; 361 | isLastCharTransp = true; 362 | else 363 | tempCode = [tempCode, actChar]; 364 | isInStr = ~isInStr; 365 | isLastCharTransp = false; 366 | end 367 | end 368 | end 369 | 370 | isLastCharDot = false; 371 | elseif isequal(actChar, '.') && ~isInStr 372 | isLastCharDot = true; 373 | tempCode = [tempCode, actChar]; 374 | isLastCharTransp = false; 375 | else 376 | isLastCharDot = false; 377 | tempCode = [tempCode, actChar]; 378 | isLastCharTransp = false; 379 | end 380 | end 381 | actCode = tempCode; 382 | end 383 | end 384 | 385 | 386 | methods (Access = private) 387 | function actCodeTemp = replaceStrings(obj, actCode) 388 | % Replaces strings in the code with string tokens while filling StringTokenStructs member to store the 389 | % original values. 390 | 391 | %% Strings 392 | splittedCode = regexp(actCode, '''', 'split'); 393 | 394 | obj.StringTokenStructs = cell(1, ceil(numel(splittedCode) / 2)); 395 | strArray = cell(1, numel(splittedCode)); 396 | 397 | for iSplit = 1:numel(splittedCode) 398 | % Not string 399 | if ~isequal(mod(iSplit, 2), 0) 400 | strArray{iSplit} = splittedCode{iSplit}; 401 | else % String 402 | strTokenStruct = MFormatter.TokenStruct.StringToken; 403 | 404 | strArray{iSplit} = strTokenStruct.Token; 405 | strTokenStruct.StoredValue = splittedCode{iSplit}; 406 | obj.StringTokenStructs{iSplit} = strTokenStruct; 407 | end 408 | end 409 | 410 | obj.StringTokenStructs = obj.StringTokenStructs(cellfun(@(x) ~isempty(x), obj.StringTokenStructs)); 411 | actCodeTemp = [strArray{:}]; 412 | end 413 | 414 | function actCodeFinal = restoreStrings(obj, actCodeTemp) 415 | % Replaces string tokens with the original string from the StringTokenStructs member. 416 | 417 | strTokStructs = obj.StringTokenStructs; 418 | splitByStrTok = regexp(actCodeTemp, MFormatter.TokenStruct.StringToken.Token, 'split'); 419 | 420 | if numel(strTokStructs) 421 | actCodeFinal = ''; 422 | for iSplit = 1:numel(strTokStructs) 423 | actCodeFinal = [actCodeFinal, splitByStrTok{iSplit}, '''', strTokStructs{iSplit}.StoredValue, '''']; 424 | end 425 | 426 | if numel(splitByStrTok) > numel(strTokStructs) 427 | actCodeFinal = [actCodeFinal, splitByStrTok{end}]; 428 | end 429 | else 430 | actCodeFinal = actCodeTemp; 431 | end 432 | end 433 | 434 | function code = performReplacements(obj, code) 435 | % Wrapper around code replacement: Replace transponations -> replace strings -> perform other replacements 436 | % (operators, containers, ...) -> restore strings -> restore transponations. 437 | 438 | code = obj.replaceStrings(obj.replaceTransponations(code)); 439 | code = obj.performFormattingSingleLine(code, false, '', false); 440 | code = obj.restoreTransponations(obj.restoreStrings(code)); 441 | end 442 | 443 | function [actCode, actComment, splittingPos, isSectionSeparator] = findComment(obj, line) 444 | % Splits a continous line into code and comment parts. 445 | 446 | %% Set the variables 447 | retComm = -1; 448 | exclamationPos = -1; 449 | actCode = line; 450 | actComment = ''; 451 | splittingPos = -1; 452 | isSectionSeparator = false; 453 | 454 | trimmedLine = strtrim(line); 455 | 456 | %% Handle some special cases 457 | if isempty(trimmedLine) 458 | return; 459 | elseif strcmp(trimmedLine, '%{') 460 | retComm = 1; 461 | obj.IsInBlockComment = true; 462 | obj.BlockCommentDepth = obj.BlockCommentDepth + 1; 463 | elseif strcmp(trimmedLine, '%}') && obj.IsInBlockComment 464 | retComm = 1; 465 | 466 | obj.BlockCommentDepth = obj.BlockCommentDepth - 1; 467 | obj.IsInBlockComment = obj.BlockCommentDepth > 0; 468 | else 469 | if obj.IsInBlockComment 470 | retComm = 1; 471 | obj.IsInBlockComment = true; 472 | end 473 | end 474 | 475 | if isequal(trimmedLine(1), '%') || (numel(trimmedLine) > 7 && isequal(trimmedLine(1:7), 'import ')) 476 | retComm = 1; 477 | elseif isequal(trimmedLine(1), '!') 478 | exclamationPos = 1; 479 | end 480 | 481 | splittingPos = max(retComm, exclamationPos); 482 | 483 | if isequal(splittingPos, 1) 484 | actCode = ''; 485 | actComment = line; 486 | 487 | if ~obj.IsInBlockComment && ... 488 | numel(regexp(trimmedLine, '^%%(\s+|$)')) 489 | isSectionSeparator = true; 490 | end 491 | return 492 | end 493 | 494 | %% Searh for comment signs(%) and exclamation marks(!) 495 | 496 | exclamationInd = strfind(line, '!'); 497 | commentSignIndexes = strfind(line, '%'); 498 | contIndexes = strfind(line, '...'); 499 | 500 | if ~iscell(exclamationInd) 501 | exclamationInd = num2cell(exclamationInd); 502 | end 503 | if ~iscell(commentSignIndexes) 504 | commentSignIndexes = num2cell(commentSignIndexes); 505 | end 506 | if ~iscell(contIndexes) 507 | contIndexes = num2cell(contIndexes); 508 | end 509 | 510 | % Make the union of indexes of '%' and '!' symbols then sort them 511 | indexUnion = [commentSignIndexes, exclamationInd, contIndexes]; 512 | indexUnion = sortrows(indexUnion(:))'; 513 | 514 | % Iterate through the union 515 | commentSignCount = numel(indexUnion); 516 | if ~commentSignCount 517 | retComm = -1; 518 | exclamationPos = -1; 519 | else 520 | 521 | for iCommSign = 1:commentSignCount 522 | currentIndex = indexUnion{iCommSign}; 523 | 524 | % Check all leading parts that can be "code" 525 | % Replace transponation (and noin-conjugate transponations) to avoid not relevant matches 526 | possibleCode = obj.replaceTransponations(line(1:currentIndex - 1)); 527 | 528 | % The line is currently "not in string" 529 | if isequal(mod(numel(strfind(possibleCode, '''')), 2), 0) 530 | if ismember(currentIndex, [commentSignIndexes{:}]) 531 | retComm = currentIndex; 532 | elseif ismember(currentIndex, [exclamationInd{:}]) 533 | exclamationPos = currentIndex; 534 | else 535 | % Branch of '...' 536 | retComm = currentIndex + 3; 537 | end 538 | 539 | break; 540 | end 541 | end 542 | end 543 | 544 | splittingPos = max(retComm, exclamationPos); 545 | 546 | if isequal(splittingPos, 1) 547 | actCode = ''; 548 | actComment = line; 549 | elseif splittingPos == -1 550 | actCode = line; 551 | actComment = ''; 552 | else 553 | actCode = line(1:max(splittingPos - 1, 1)); 554 | actComment = strtrim(line(splittingPos:end)); 555 | end 556 | end 557 | 558 | function data = performFormattingSingleLine(obj, data, doIndexing, contType, isContainerElement) 559 | % Performs formatting on a code snippet, where the strings and transponations are already replaced: 560 | % operator, container formatting 561 | 562 | if isempty(data) 563 | return; 564 | end 565 | 566 | if nargin < 3 567 | doIndexing = false; 568 | end 569 | 570 | if nargin < 4 571 | contType = ''; 572 | end 573 | 574 | setConfigOperatorFields = fields(obj.SettingConfiguration.OperatorRules); 575 | % At this point, the data contains one line of code, but all user-defined strings enclosed in '' are replaced by #MBeutyString# 576 | 577 | % Old-style function calls, such as 'subplot 211' or 'disp Hello World' -> return unchanged 578 | if numel(regexp(data, '^[a-zA-Z0-9_]+\s+[^(=]')) 579 | 580 | splitData = regexp(strtrim(data), ' ', 'split'); 581 | % The first elemen is not a keyword and does not exist (function on the path) 582 | if numel(splitData) && ~any(strcmp(splitData{1}, iskeyword())) && exist(splitData{1}) %#ok 583 | return 584 | end 585 | end 586 | 587 | % Process matrixes and cell arrays 588 | % All containers are processed element wised. The replaced containers are placed into a map where the key is a token 589 | % inserted to the original data 590 | [data, arrayMapCell] = obj.replaceContainer(data); 591 | 592 | % Convert all operators like + * == etc to #MBeauty_OP_whatever# tokens 593 | opBuffer = {}; 594 | operatorList = obj.AllOperators; 595 | operatorAppearance = regexp(data, operatorList); 596 | 597 | if ~isempty([operatorAppearance{:}]) 598 | for iOpConf = 1:numel(setConfigOperatorFields) 599 | currField = setConfigOperatorFields{iOpConf}; 600 | currOpStruct = obj.SettingConfiguration.OperatorRules.(currField); 601 | dataNew = regexprep(data, ['\s*', currOpStruct.ValueFrom, '\s*'], currOpStruct.OperatorToken); 602 | if ~strcmp(data, dataNew) 603 | opBuffer{end + 1} = currField; 604 | end 605 | data = dataNew; 606 | end 607 | end 608 | 609 | % Remove all duplicate space 610 | data = regexprep(data, '\s+', ' '); 611 | keywords = iskeyword(); 612 | 613 | % Handle special + and - cases: 614 | % - unary plus/minus, such as in (+1): replace #MBeauty_OP_Plus/Minus# by #MBeauty_OP_UnaryPlus/Minus# 615 | % - normalized number format, such as 7e-3: replace #MBeauty_OP_Plus/Minus# by #MBeauty_OP_NormNotation_Plus/Minus# 616 | % Then convert UnaryPlus tokens to '+' signs same for minus) 617 | plusMinusCell = {'Plus', 'Minus'}; 618 | unaryPlusOperatorPresent = false; 619 | unaryMinusOperatorPresent = false; 620 | normPlusOperatorPresent = false; 621 | normMinusOperatorPresent = false; 622 | 623 | for iOpConf = 1:numel(plusMinusCell) 624 | 625 | if any(strcmp(plusMinusCell{iOpConf}, opBuffer)) 626 | 627 | currField = plusMinusCell{iOpConf}; 628 | isPlus = isequal(currField, 'Plus'); 629 | 630 | opToken = obj.SettingConfiguration.OperatorRules.(currField).OperatorToken; 631 | 632 | splittedData = regexp(data, opToken, 'split'); 633 | 634 | replaceTokens = {}; 635 | for iSplit = 1:numel(splittedData) -1 636 | beforeItem = strtrim(splittedData{iSplit}); 637 | if ~isempty(beforeItem) && numel(regexp(beforeItem, ... 638 | ['([0-9a-zA-Z_)}\]\.]|', MFormatter.TokenStruct.TransposeToken.Token, '|#MBeauty_ArrayToken_\d+#)$'])) && ... 639 | (~numel(regexp(beforeItem, ['(?=^|\s)(', MFormatter.joinString(keywords', '|'), ')$'])) || doIndexing) 640 | % + or - is a binary operator after: 641 | % - numbers [0-9.], 642 | % - variable names [a-zA-Z0-9_] or 643 | % - closing brackets )}] 644 | % - transpose signs ', here represented as #MBeutyTransp# 645 | % - keywords 646 | 647 | % Special treatment for E: 7E-3 or 7e+4 normalized notation 648 | % In this case the + and - signs are not operators so shoud be skipped 649 | if numel(beforeItem) > 1 && strcmpi(beforeItem(end), 'e') && numel(regexp(beforeItem(end - 1), '[0-9.]')) 650 | if isPlus 651 | replaceTokens{end + 1} = MFormatter.TokenStruct.NormNotationPlus.Token; 652 | normPlusOperatorPresent = true; 653 | else 654 | replaceTokens{end + 1} = MFormatter.TokenStruct.NormNotationMinus.Token; 655 | normMinusOperatorPresent = true; 656 | end 657 | else 658 | replaceTokens{end + 1} = opToken; 659 | end 660 | else 661 | if isPlus 662 | replaceTokens{end + 1} = MFormatter.TokenStruct.UnaryPlus.Token; 663 | unaryPlusOperatorPresent = true; 664 | else 665 | replaceTokens{end + 1} = MFormatter.TokenStruct.UnaryMinus.Token; 666 | unaryMinusOperatorPresent = true; 667 | end 668 | end 669 | end 670 | 671 | replacedSplittedData = cell(1, numel(replaceTokens) + numel(splittedData)); 672 | tokenIndex = 1; 673 | for iSplit = 1:numel(splittedData) 674 | replacedSplittedData{iSplit * 2 - 1} = splittedData{iSplit}; 675 | if iSplit < numel(splittedData) 676 | replacedSplittedData{iSplit * 2} = replaceTokens{tokenIndex}; 677 | end 678 | tokenIndex = tokenIndex + 1; 679 | end 680 | data = [replacedSplittedData{:}]; 681 | end 682 | end 683 | 684 | %% 685 | % At this point the data is in a completely tokenized representation, e.g.'x#MBeauty_OP_Plus#y' instead of the 'x + y'. 686 | % Now go backwards and replace the tokens by the real operators 687 | 688 | % Special tokens: Unary Plus/Minus, Normalized Number Format 689 | % Performance tweak: only if there were any unary or norm operators 690 | if unaryPlusOperatorPresent 691 | data = regexprep(data, ['\s*', MFormatter.TokenStruct.UnaryPlus.Token, '\s*'], [' ', MFormatter.TokenStruct.UnaryPlus.StoredValue]); 692 | end 693 | if unaryMinusOperatorPresent 694 | data = regexprep(data, ['\s*', MFormatter.TokenStruct.UnaryMinus.Token, '\s*'], [' ', MFormatter.TokenStruct.UnaryMinus.StoredValue]); 695 | end 696 | if normPlusOperatorPresent 697 | data = regexprep(data, ['\s*', MFormatter.TokenStruct.NormNotationPlus.Token, '\s*'], MFormatter.TokenStruct.NormNotationPlus.StoredValue); 698 | end 699 | if normMinusOperatorPresent 700 | data = regexprep(data, ['\s*', MFormatter.TokenStruct.NormNotationMinus.Token, '\s*'], MFormatter.TokenStruct.NormNotationMinus.StoredValue); 701 | end 702 | 703 | 704 | 705 | % Replace all other operators 706 | for iOpConf = 1:numel(setConfigOperatorFields) 707 | 708 | currField = setConfigOperatorFields{iOpConf}; 709 | 710 | if any(strcmp(currField, opBuffer)) 711 | 712 | currOpStruct = obj.SettingConfiguration.OperatorRules.(currField); 713 | 714 | valTo = currOpStruct.ValueTo; 715 | if doIndexing && ~isempty(contType) && numel(regexp(currOpStruct.ValueFrom, '\+|\-|\/|\*')) 716 | if strcmp(contType, 'matrix') 717 | replacementPattern = currOpStruct.MatrixIndexingReplacementPattern; 718 | if ~obj.MatrixIndexingOperatorPadding 719 | valTo = strrep(valTo, ' ', ''); 720 | end 721 | 722 | elseif strcmp(contType, 'cell') 723 | replacementPattern = currOpStruct.CellArrayIndexingReplacementPattern; 724 | if ~obj.CellArrayIndexingOperatorPadding 725 | valTo = strrep(valTo, ' ', ''); 726 | end 727 | end 728 | else 729 | 730 | replacementPattern = currOpStruct.ReplacementPattern; 731 | end 732 | 733 | tokenizedReplaceString = strrep(valTo, ' ', obj.WhiteSpaceToken); 734 | 735 | % Replace only the amount of whitespace tokens that are actually needed by the operator rule 736 | data = regexprep(data, replacementPattern, tokenizedReplaceString); 737 | end 738 | end 739 | 740 | if ~isContainerElement && ~str2double(obj.SettingConfiguration.SpecialRules.AllowMultipleStatementsPerLineValue) 741 | data = regexprep(data, ';(?!\s*$)', ';\n'); 742 | end 743 | 744 | data = regexprep(data, obj.WhiteSpaceToken, ' '); 745 | 746 | data = regexprep(data, ' \)', ')'); 747 | data = regexprep(data, ' \]', ']'); 748 | data = regexprep(data, '\( ', '('); 749 | data = regexprep(data, '\[ ', '['); 750 | 751 | % TODO: keyword formatting here could be done 752 | data = regexprep(data, '^function(?=#MBeauty_ArrayToken_\d+#)', 'function '); 753 | 754 | % Restore containers 755 | data = obj.restoreContainers(data, arrayMapCell); 756 | 757 | % Fix semicolon whitespace at end of line 758 | data = regexprep(data, '\s+;\s*$', ';'); 759 | end 760 | 761 | function ret = calculateContainerDepthDeltaOfLine(obj, code) 762 | % Calculates the delta of container depth in a single code line. 763 | 764 | % Pre-check for opening and closing brackets: the final delta has to be calculated after the transponations and the 765 | % strings are replaced, which are time consuming actions 766 | ret = 0; 767 | if numel(regexp(code, '{|[')) || numel(regexp(code, '}|]')) 768 | actCodeTemp = obj.replaceStrings(obj.replaceTransponations(code)); 769 | ret = numel(regexp(actCodeTemp, '{|[')) - numel(regexp(actCodeTemp, '}|]')); 770 | end 771 | end 772 | 773 | function [containerBorderIndexes, maxDepth] = calculateContainerDepths(obj, data) 774 | % Calculates the container boundaries with container depth for a continous code line. 775 | 776 | containerBorderIndexes = {}; 777 | depth = 1; 778 | maxDepth = 1; 779 | for i = 1:numel(data) 780 | borderFound = true; 781 | if any(strcmp(data(i), obj.ContainerOpeningBrackets)) 782 | newDepth = depth + 1; 783 | maxDepth = newDepth; 784 | elseif any(strcmp(data(i), obj.ContainerClosingBrackets)) 785 | newDepth = depth - 1; 786 | depth = depth - 1; 787 | else 788 | borderFound = false; 789 | end 790 | 791 | if borderFound 792 | containerBorderIndexes{end + 1, 1} = i; 793 | containerBorderIndexes{end, 2} = depth; 794 | depth = newDepth; 795 | end 796 | end 797 | end 798 | 799 | function [data, arrayMap] = replaceContainer(obj, data) 800 | % Replaces containers in a code line with container tokens while storing the original container contents in 801 | % the second output argument. 802 | 803 | arrayMap = containers.Map(); 804 | if isempty(data) 805 | return 806 | end 807 | 808 | data = regexprep(data, '\s+;', ';'); 809 | 810 | operatorArray = {'+', '-', '&', '&&', '|', '||', '/', './', '\', '.\', '*', '.*', ':', '^', '.^', '~'}; 811 | contTokenStruct = MFormatter.TokenStruct.ContinueToken; 812 | 813 | [containerBorderIndexes, maxDepth] = obj.calculateContainerDepths(data); 814 | 815 | id = 0; 816 | 817 | while maxDepth > 0 818 | 819 | if isempty(containerBorderIndexes) 820 | break; 821 | end 822 | 823 | indexes = find([containerBorderIndexes{:, 2}] == maxDepth, 2); 824 | 825 | if ~numel(indexes) || mod(numel(indexes), 2) ~= 0 826 | maxDepth = maxDepth - 1; 827 | continue; 828 | end 829 | 830 | openingBracket = data(containerBorderIndexes{indexes(1), 1}); 831 | closingBracket = data(containerBorderIndexes{indexes(2), 1}); 832 | 833 | isContainerIndexing = numel(regexp(data(1:containerBorderIndexes{indexes(1), 1}), ['[a-zA-Z0-9_]\s*[', openingBracket, ']$'])); 834 | preceedingKeyWord = false; 835 | if isContainerIndexing 836 | keywords = iskeyword(); 837 | prevStr = strtrim(data(1:containerBorderIndexes{indexes(1), 1} - 1)); 838 | 839 | if numel(prevStr) >= 2 840 | 841 | for i = 1:numel(keywords) 842 | if numel(regexp(prevStr, ['(\s|^)', keywords{i}, '$'])) 843 | isContainerIndexing = false; 844 | preceedingKeyWord = true; 845 | break; 846 | end 847 | end 848 | end 849 | end 850 | 851 | doIndexing = isContainerIndexing; 852 | contType = ''; 853 | if doIndexing 854 | if strcmp(openingBracket, '(') 855 | doIndexing = true; 856 | contType = 'matrix'; 857 | elseif strcmp(openingBracket, '{') 858 | doIndexing = true; 859 | contType = 'cell'; 860 | else 861 | doIndexing = false; 862 | end 863 | end 864 | 865 | str = data(containerBorderIndexes{indexes(1), 1}:containerBorderIndexes{indexes(2), 1}); 866 | str = regexprep(str, '\s+', ' '); 867 | str = regexprep(str, [openingBracket, '\s+'], openingBracket); 868 | str = regexprep(str, ['\s+', closingBracket], closingBracket); 869 | 870 | if ~strcmp(openingBracket, '(') 871 | if doIndexing 872 | strNew = strtrim(str); 873 | strNew = [strNew(1), strtrim(obj.performFormattingSingleLine(strNew(2:end - 1), doIndexing, contType, true)), strNew(end)]; 874 | else 875 | elementsCell = regexp(str, ' ', 'split'); 876 | 877 | firstElem = strtrim(elementsCell{1}); 878 | lastElem = strtrim(elementsCell{end}); 879 | 880 | if numel(elementsCell) == 1 881 | elementsCell{1} = firstElem(2:end - 1); 882 | else 883 | elementsCell{1} = firstElem(2:end); 884 | elementsCell{end} = lastElem(1:end - 1); 885 | end 886 | 887 | for iElem = 1:numel(elementsCell) 888 | elem = strtrim(elementsCell{iElem}); 889 | if numel(elem) && strcmp(elem(1), ',') 890 | elem = elem(2:end); 891 | end 892 | elementsCell{iElem} = elem; 893 | end 894 | 895 | isInCurlyBracket = 0; 896 | for elemInd = 1:numel(elementsCell) -1 897 | 898 | currElem = strtrim(elementsCell{elemInd}); 899 | nextElem = strtrim(elementsCell{elemInd + 1}); 900 | 901 | if ~numel(currElem) 902 | continue; 903 | end 904 | 905 | isInCurlyBracket = isInCurlyBracket || numel(strfind(currElem, openingBracket)); 906 | isInCurlyBracket = isInCurlyBracket && ~numel(strfind(currElem, closingBracket)); 907 | 908 | currElemStripped = regexprep(currElem, ['[', openingBracket, closingBracket, ']'], ''); 909 | nextElemStripped = regexprep(nextElem, ['[', openingBracket, closingBracket, ']'], ''); 910 | 911 | currElem = strtrim(obj.performFormattingSingleLine(currElem, doIndexing, contType, true)); 912 | 913 | if strcmp(openingBracket, '[') 914 | addCommas = str2double(obj.SettingConfiguration.SpecialRules.AddCommasToMatricesValue); 915 | else 916 | addCommas = str2double(obj.SettingConfiguration.SpecialRules.AddCommasToCellArraysValue); 917 | end 918 | 919 | if numel(currElem) && addCommas && ... 920 | ~(strcmp(currElem(end), ',') || strcmp(currElem(end), ';')) && ~isInCurlyBracket && ... 921 | ~strcmp(currElem, contTokenStruct.Token) && ... 922 | ~any(strcmp(currElemStripped, operatorArray)) && ~any(strcmp(nextElemStripped, operatorArray)) && ... 923 | ~numel(regexp(currElemStripped, '^@#MBeauty_ArrayToken_\d+#$')) 924 | 925 | elementsCell{elemInd} = [currElem, '#MBeauty_OP_Comma#']; 926 | else 927 | elementsCell{elemInd} = [currElem, ' ']; 928 | end 929 | end 930 | 931 | elementsCell{end} = strtrim(obj.performFormattingSingleLine(elementsCell{end}, doIndexing, contType, true)); 932 | 933 | strNew = [openingBracket, elementsCell{:}, closingBracket]; 934 | end 935 | else 936 | strNew = strtrim(str); 937 | strNew = [strNew(1), strtrim(obj.performFormattingSingleLine(strNew(2:end - 1), doIndexing, contType, true)), strNew(end)]; 938 | end 939 | 940 | datacell = cell(1, 3); 941 | if containerBorderIndexes{indexes(1), 1} == 1 942 | datacell{1} = ''; 943 | else 944 | 945 | datacell{1} = data(1:containerBorderIndexes{indexes(1), 1} - 1); 946 | if isContainerIndexing 947 | datacell{1} = strtrim(datacell{1}); 948 | elseif preceedingKeyWord 949 | datacell{1} = strtrim(datacell{1}); 950 | datacell{1} = [datacell{1}, ' ']; 951 | end 952 | end 953 | 954 | if containerBorderIndexes{indexes(2), 1} == numel(data) 955 | datacell{end} = ''; 956 | else 957 | datacell{end} = data(containerBorderIndexes{indexes(2), 1} + 1:end); 958 | end 959 | 960 | idAsStr = num2str(id); 961 | idStr = [repmat('0', 1, 5 - numel(idAsStr)), idAsStr]; 962 | tokenOfCUrElem = ['#MBeauty_ArrayToken_', idStr, '#']; 963 | arrayMap(tokenOfCUrElem) = strNew; 964 | id = id + 1; 965 | datacell{2} = tokenOfCUrElem; 966 | data = [datacell{:}]; 967 | 968 | containerBorderIndexes = obj.calculateContainerDepths(data); 969 | end 970 | end 971 | 972 | function data = restoreContainers(obj, data, map) 973 | % Replaces container tokens with the original container contents. 974 | 975 | arrayTokenList = map.keys(); 976 | if isempty(arrayTokenList) 977 | return; 978 | end 979 | 980 | for iKey = numel(arrayTokenList):-1:1 981 | data = regexprep(data, arrayTokenList{iKey}, regexptranslate('escape', map(arrayTokenList{iKey}))); 982 | end 983 | 984 | data = regexprep(data, obj.SettingConfiguration.OperatorRules.Comma.OperatorToken, ... 985 | obj.SettingConfiguration.OperatorRules.Comma.ValueTo); 986 | end 987 | 988 | end 989 | end 990 | -------------------------------------------------------------------------------- /MBeautifier/README.md: -------------------------------------------------------------------------------- 1 | # MBeautifier 2 | 3 | MBeautifier is a lightweight M-Script based Matlab source code formatter usable directly in the Matlab Editor. 4 | 5 | ![Basic working](https://cloud.githubusercontent.com/assets/12681120/20592407/904cb1d6-b22d-11e6-93dd-1637c3738e50.png) 6 | 7 | 8 | Main features 9 | ------------- 10 | 11 | - Padding operators with white spaces based on the XML configuration file. 12 | - Correction white space padding of keywords 13 | - Correction of indentation using the Smart Indent functionality of the Matlab Editor 14 | - Removal of continuous empty lines (the number can be configured) 15 | - Optionally inserting missing element separators (commas) in matrix and cell array initializations 16 | - Different working modes: format the current page of the Matlab editor, format only a selection in the Matlab Editor or format file(s) 17 | 18 | Deployment and Configuration 19 | ---------------------------- 20 | Add containing directory to the Matlab path, then execute: `MBeautify.setup()`. 21 | 22 | This command will create the standard configuration of formatting stored in `MBeautifier\resources\settings\MBeautyConfigurationRules.m`. 23 | 24 | This file is used in run-time to gather the configuration rules, therefore when the configuration XML file has been modified, executing this function again will make the rules active. 25 | 26 | ### Configuration 27 | 28 | The configuration can be modified by editing the `MBeautifier\resources\settings\MBeautyConfigurationRules.xml` file. 29 | 30 | #### Configuration rules 31 | 32 | Currently two types of configuration rules are implemented: `OperatorPaddingRule` and `SpecialRule`. 33 | 34 | #### Operator padding rules 35 | 36 | Each `OperatorPaddingRule` represents the formatting rules for one single operator and consists of a key, the string that should be replaced and a string that should be used for the replacement. 37 | 38 | 39 | NotEquals 40 | ~= 41 | ~= 42 | 43 | 44 | The example above shows the rule for the "not equals" operator. The `ValueFrom` node stores the operator `~=` and the `ValueTo` node stores the expected format: the operator should be preceded and followed by a white-space character. 45 | 46 | All of the operator padding rules are collected dynamically, therefore adding a new node to this list then executing the `setup` command will result in that MBeautifier will replace the currently added node also. 47 | 48 | #### Special rules 49 | 50 | These rules are basically switches for certain functionalities of MBeautifier. 51 | 52 | The current list of special rules: 53 | 54 | - **MaximalNewLines**: Integer value. MBeautifier will remove continuous empty lines. This rule can be used to specify the maximal number of maximal continuous empty lines. 55 | - **SectionPrecedingNewlineCount**: Integer value. Defines how many empty lines should precede the section comments (`%% `). Negative values mean no special formatting is needed (the final format is defined by the input and the MaximalNewLines rule). For any number "X" bigger or equal to zero: section comments will be preceded exactly by X empty lines. 56 | - **SectionTrailingNewlineCount**: Integer value. Defines how many empty lines should follow the section comments (`%% `). Negative values mean no special formatting is needed (the final format is defined by the input and the MaximalNewLines rule). For any number "X" bigger or equal to zero: section comments will be followed exactly by X empty lines. 57 | - **EndingNewlineCount**: Integer value. Defines how many empty lines should be placed on the end of the input. Negative values mean no special formatting is needed (the final format is defined by the input and the MaximalNewLines rule). For any number "X" bigger or equal to zero: input will trailed exactly by X empty lines. 58 | - **AllowMultipleStatementsPerLine**: [1|0]. If set to 1, MBeautifier will allow multiple statements per line (`a = 1; b = 2;`), otherwise it will break every statement into a new line. Defaults to "0". 59 | - **AddCommasToMatrices**: [1|0]. Indicates whether the missing element separator commas in matrices should be inserted. For example: `[1 2 3]` will be formatted as `[1, 2, 3]`. 60 | - **AddCommasToCellArrays**: [1|0]. Indicates whether the missing element separator commas in cell arrays should be inserted. For example: `{1 2 3}` will be formatted as `{1, 2, 3}`. 61 | - **MatrixIndexing_ArithmeticOperatorPadding**: [1|0]. Indicates whether the arithmetic operators should be padded by white spaces (using the operator padding rules), when they are used to index matrices. For example: `matrix(end+1) = 1` can be formatted as `matrix(end+1) = 1` when value is set to 0, or as `matrix(end + 1) = 1` if value is set to 1. 62 | - **CellArrayIndexing_ArithmeticOperatorPadding**: [1|0]. Indicates the same as `MatrixIndexing_ArithmeticOperatorPadding` but for cell arrays. 63 | 64 | 65 | Usage 66 | ----- 67 | 68 | ### From Matlab Command Window 69 | 70 | Currently four approaches are supported: 71 | 72 | - Perform formatting on the currently active page of Matlab Editor. Command: `MBeautify.formatCurrentEditorPage()`. By default the file is not saved, but it remains opened modified in the editor. Optionally the formatted file can be saved using the `MBeautify.formatCurrentEditorPage(true)` syntax. 73 | - Perform formatting on the currently selected text of the active page of Matlab Editor. Command: `MBeautify.formatEditorSelection()`. An optional saving mechanism as above exists also in this case. Useful in case of large files, but in any case `MBeautify.formatCurrentEditorPage()` is suggested. 74 | - Perform formatting on a file. Command: `MBeautify.formatFile(file)`. Can be used with (1)one argument: the input file is formatted and remains open in the Matlab editor unsaved; (2)two arguments as `MBeautify.formatFile(file, outFile)`: the formatted file is saved to the specified output file if possible. Output can be the same as input. 75 | - Perform formatting on several files in a directory. Command: `MBeautify.formatFiles(directory, fileFilter)`. The first argument is an absolute path to a directory, the second one is a wildcard expression (used for `dir` command) to filter files in the target directory. The files will be formatted in-place (overwritten). 76 | 77 | ### Shortcuts 78 | 79 | There is a possibility to create shortcuts for the first three approaches above, which shortcut buttons will appear under the "Shortcuts" tab of Matlab's main window. 80 | 81 | To create these buttons, the following commands can be used: 82 | 83 | - `MBeautify.createShortcut('editorpage')`: Creates a shortcut for `MBeautify.formatCurrentEditorPage()` 84 | - `MBeautify.createShortcut('editorselection')`: Creates a shortcut for `MBeautify.formatEditorSelection()` 85 | - `MBeautify.createShortcut('file')`: Creates a shortcut for `MBeautify.formatFile(sourceFile, destFile)` 86 | 87 | These shortcuts will add the MBeautifier root directory to the Matlab path too, therefore no Matlab path preparation is needed to use MBeauty next time when a new Matlab instance is opened. 88 | 89 | Supported Matlab versions 90 | ------------------------- 91 | 92 | As MBeautifier uses the built-in Matlab Editor functionality, it supports Matlab versions from R2011a. 93 | 94 | Planned future versions 95 | ----------------------- 96 | 97 | As Matlab does not contain any formatter even in R2017 releases, and will not contain in R2018 releases this project will be at least maintained until R2019a (if live editor will contain a formatter). 98 | 99 | As it is planned at the moment, the current release is the last one which is M-Script based, and the next release is planned to be implemented in Java with Matlab interface. This is the first step to make MBeautifier also usable in Octave. 100 | 101 | -------------------------------------------------------------------------------- /MBeautifier/resources/settings/MBeautyConfigurationRules.m: -------------------------------------------------------------------------------- 1 | function this = MBeautyConfigurationRules() 2 | this = struct(); 3 | 4 | this.OperatorRules = struct(); 5 | 6 | 7 | this.OperatorRules.ShortCircuitAnd = struct(); 8 | this.OperatorRules.ShortCircuitAnd.ValueFrom = '&&'; 9 | this.OperatorRules.ShortCircuitAnd.ValueTo = ' && '; 10 | 11 | this.OperatorRules.ShortCircuitOr = struct(); 12 | this.OperatorRules.ShortCircuitOr.ValueFrom = '\|\|'; 13 | this.OperatorRules.ShortCircuitOr.ValueTo = ' \|\| '; 14 | 15 | this.OperatorRules.LogicalAnd = struct(); 16 | this.OperatorRules.LogicalAnd.ValueFrom = '&'; 17 | this.OperatorRules.LogicalAnd.ValueTo = ' & '; 18 | 19 | this.OperatorRules.LogicalOr = struct(); 20 | this.OperatorRules.LogicalOr.ValueFrom = '\|'; 21 | this.OperatorRules.LogicalOr.ValueTo = ' \| '; 22 | 23 | this.OperatorRules.LessEquals = struct(); 24 | this.OperatorRules.LessEquals.ValueFrom = '<='; 25 | this.OperatorRules.LessEquals.ValueTo = ' <= '; 26 | 27 | this.OperatorRules.Less = struct(); 28 | this.OperatorRules.Less.ValueFrom = '<'; 29 | this.OperatorRules.Less.ValueTo = ' < '; 30 | 31 | this.OperatorRules.GreaterEquals = struct(); 32 | this.OperatorRules.GreaterEquals.ValueFrom = '>='; 33 | this.OperatorRules.GreaterEquals.ValueTo = ' >= '; 34 | 35 | this.OperatorRules.Greater = struct(); 36 | this.OperatorRules.Greater.ValueFrom = '>'; 37 | this.OperatorRules.Greater.ValueTo = ' > '; 38 | 39 | this.OperatorRules.Equals = struct(); 40 | this.OperatorRules.Equals.ValueFrom = '=='; 41 | this.OperatorRules.Equals.ValueTo = ' == '; 42 | 43 | this.OperatorRules.NotEquals = struct(); 44 | this.OperatorRules.NotEquals.ValueFrom = '~='; 45 | this.OperatorRules.NotEquals.ValueTo = ' ~= '; 46 | 47 | this.OperatorRules.Assignment = struct(); 48 | this.OperatorRules.Assignment.ValueFrom = '='; 49 | this.OperatorRules.Assignment.ValueTo = ' = '; 50 | 51 | this.OperatorRules.Plus = struct(); 52 | this.OperatorRules.Plus.ValueFrom = '\+'; 53 | this.OperatorRules.Plus.ValueTo = ' \+ '; 54 | 55 | this.OperatorRules.Minus = struct(); 56 | this.OperatorRules.Minus.ValueFrom = '\-'; 57 | this.OperatorRules.Minus.ValueTo = ' \- '; 58 | 59 | this.OperatorRules.ElementWiseMultiplication = struct(); 60 | this.OperatorRules.ElementWiseMultiplication.ValueFrom = '\.\*'; 61 | this.OperatorRules.ElementWiseMultiplication.ValueTo = ' \.\* '; 62 | 63 | this.OperatorRules.Multiplication = struct(); 64 | this.OperatorRules.Multiplication.ValueFrom = '\*'; 65 | this.OperatorRules.Multiplication.ValueTo = ' \* '; 66 | 67 | this.OperatorRules.RightArrayDivision = struct(); 68 | this.OperatorRules.RightArrayDivision.ValueFrom = '\./'; 69 | this.OperatorRules.RightArrayDivision.ValueTo = ' \./ '; 70 | 71 | this.OperatorRules.LeftArrayDivision = struct(); 72 | this.OperatorRules.LeftArrayDivision.ValueFrom = '\.\\'; 73 | this.OperatorRules.LeftArrayDivision.ValueTo = ' \.\\ '; 74 | 75 | this.OperatorRules.Division = struct(); 76 | this.OperatorRules.Division.ValueFrom = '/'; 77 | this.OperatorRules.Division.ValueTo = ' / '; 78 | 79 | this.OperatorRules.LeftDivision = struct(); 80 | this.OperatorRules.LeftDivision.ValueFrom = '\\'; 81 | this.OperatorRules.LeftDivision.ValueTo = ' \\ '; 82 | 83 | this.OperatorRules.ElementWisePower = struct(); 84 | this.OperatorRules.ElementWisePower.ValueFrom = '\.\^'; 85 | this.OperatorRules.ElementWisePower.ValueTo = '\.\^'; 86 | 87 | this.OperatorRules.Power = struct(); 88 | this.OperatorRules.Power.ValueFrom = '\^'; 89 | this.OperatorRules.Power.ValueTo = '\^'; 90 | 91 | this.OperatorRules.Not = struct(); 92 | this.OperatorRules.Not.ValueFrom = '~'; 93 | this.OperatorRules.Not.ValueTo = ' ~'; 94 | 95 | this.OperatorRules.Comma = struct(); 96 | this.OperatorRules.Comma.ValueFrom = ','; 97 | this.OperatorRules.Comma.ValueTo = ', '; 98 | 99 | this.OperatorRules.SemiColon = struct(); 100 | this.OperatorRules.SemiColon.ValueFrom = ';'; 101 | this.OperatorRules.SemiColon.ValueTo = '; '; 102 | 103 | this.OperatorRules.Colon = struct(); 104 | this.OperatorRules.Colon.ValueFrom = ':'; 105 | this.OperatorRules.Colon.ValueTo = ':'; 106 | this.SpecialRules = struct(); 107 | 108 | 109 | this.SpecialRules.MaximalNewLines = struct(); 110 | this.SpecialRules.MaximalNewLinesValue = '2'; 111 | 112 | this.SpecialRules.SectionPrecedingNewlineCount = struct(); 113 | this.SpecialRules.SectionPrecedingNewlineCountValue = '1'; 114 | 115 | this.SpecialRules.SectionTrailingNewlineCount = struct(); 116 | this.SpecialRules.SectionTrailingNewlineCountValue = '-1'; 117 | 118 | this.SpecialRules.EndingNewlineCount = struct(); 119 | this.SpecialRules.EndingNewlineCountValue = '1'; 120 | 121 | this.SpecialRules.AddCommasToMatrices = struct(); 122 | this.SpecialRules.AddCommasToMatricesValue = '1'; 123 | 124 | this.SpecialRules.AddCommasToCellArrays = struct(); 125 | this.SpecialRules.AddCommasToCellArraysValue = '1'; 126 | 127 | this.SpecialRules.CellArrayIndexing_ArithmeticOperatorPadding = struct(); 128 | this.SpecialRules.CellArrayIndexing_ArithmeticOperatorPaddingValue = '0'; 129 | 130 | this.SpecialRules.MatrixIndexing_ArithmeticOperatorPadding = struct(); 131 | this.SpecialRules.MatrixIndexing_ArithmeticOperatorPaddingValue = '0'; 132 | 133 | this.SpecialRules.AllowMultipleStatementsPerLine = struct(); 134 | this.SpecialRules.AllowMultipleStatementsPerLineValue = '0'; 135 | end -------------------------------------------------------------------------------- /MBeautifier/resources/settings/MBeautyConfigurationRules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ShortCircuitAnd 6 | &amp;&amp; 7 | &amp;&amp; 8 | 9 | 10 | ShortCircuitOr 11 | || 12 | || 13 | 14 | 15 | LogicalAnd 16 | &amp; 17 | &amp; 18 | 19 | 20 | LogicalOr 21 | | 22 | | 23 | 24 | 25 | LessEquals 26 | &lt;= 27 | &lt;= 28 | 29 | 30 | Less 31 | &lt; 32 | &lt; 33 | 34 | 35 | GreaterEquals 36 | &gt;= 37 | &gt;= 38 | 39 | 40 | Greater 41 | &gt; 42 | &gt; 43 | 44 | 45 | Equals 46 | == 47 | == 48 | 49 | 50 | NotEquals 51 | ~= 52 | ~= 53 | 54 | 55 | Assignment 56 | = 57 | = 58 | 59 | 60 | Plus 61 | + 62 | + 63 | 64 | 65 | Minus 66 | - 67 | - 68 | 69 | 70 | ElementWiseMultiplication 71 | .* 72 | .* 73 | 74 | 75 | Multiplication 76 | * 77 | * 78 | 79 | 80 | RightArrayDivision 81 | ./ 82 | ./ 83 | 84 | 85 | LeftArrayDivision 86 | .\ 87 | .\ 88 | 89 | 90 | Division 91 | / 92 | / 93 | 94 | 95 | LeftDivision 96 | \ 97 | \ 98 | 99 | 100 | ElementWisePower 101 | .^ 102 | .^ 103 | 104 | 105 | Power 106 | ^ 107 | ^ 108 | 109 | 110 | Not 111 | ~ 112 | ~ 113 | 114 | 115 | Comma 116 | , 117 | , 118 | 119 | 120 | SemiColon 121 | ; 122 | ; 123 | 124 | 125 | Colon 126 | : 127 | : 128 | 129 | 130 | 131 | 132 | MaximalNewLines 133 | 2 134 | 135 | 136 | SectionPrecedingNewlineCount 137 | 1 138 | 139 | 140 | SectionTrailingNewlineCount 141 | -1 142 | 143 | 144 | EndingNewlineCount 145 | 1 146 | 147 | 148 | AddCommasToMatrices 149 | 1 150 | 151 | 152 | AddCommasToCellArrays 153 | 1 154 | 155 | 156 | CellArrayIndexing_ArithmeticOperatorPadding 157 | 0 158 | 159 | 160 | MatrixIndexing_ArithmeticOperatorPadding 161 | 0 162 | 163 | 164 | AllowMultipleStatementsPerLine 165 | 0 166 | 167 | 168 | -------------------------------------------------------------------------------- /MBeautifier/resources/testdata/testfile.m: -------------------------------------------------------------------------------- 1 | % This file should NOT change when run through MBeautify 2 | % If you find anything that is difficult or failed in some MBeautify 3 | % version, please add it here. 4 | 5 | % unary operator testcases 6 | 7 | +2 8 | +2. 9 | +.2 10 | ' string with lots of spaces ' 11 | 1 + 2 12 | f(+1) + 1 13 | 14 | x = y 15 | x + 1. + 2 16 | x + 1. + +.1 17 | x + 1 + 2 18 | x = 1 19 | x = -1 20 | x = +1 21 | x = +.1 22 | +(-[-.1]) 23 | z = [1, 2, 3, 4] 24 | 25 | if 1 > +2 26 | return 27 | end; % comment +-+-+- +++ 123 *** 28 | if 1 > -2 29 | end 30 | % different meanings of 'end' 31 | if any(z == -[-1, -2, -3, -4]) 32 | ifmyvariablenamecontainsif = z(1:end); 33 | end 34 | 35 | % old-style function calls 36 | disp +end+ this is not any keyword if else endif while +1 37 | % bracket handling 38 | while (1) 39 | a = [0, 1]; 40 | a(1) = 2 * [a(0)]; 41 | break 42 | end; 43 | 44 | % transpose 45 | -x' + +1 + x'' + 2 * x''' * 1 46 | a = eye(27) 47 | a(3, 4:5) = [3, 1] 48 | 49 | % norm notation 50 | 1.e-6 51 | -------------------------------------------------------------------------------- /MBeautifier/resources/testdata/testfile_bugs.m: -------------------------------------------------------------------------------- 1 | % This file should NOT change when run through MBeautify, but 2 | % currently these examples trigger known bugs, and are therefore 3 | % excluded from testfile.m. 4 | % As soon as the bug is fixed, these should be moved to testfile.m. 5 | 6 | % #34 7 | if -1 > -2 8 | end 9 | if +1 > -2 10 | end 11 | 12 | % #35, if ArithmeticOperatorPadding=0 13 | trace(3 + 4) 14 | a = eye(1 + 1) 15 | 16 | % #36 17 | a(1, 1:2) = [3, 1] 18 | a(3, :) = [3, 1] 19 | b = zeros(3, 3, 3); 20 | b(:, :, 2) = rand(2, 2); 21 | 22 | %if AddCommasToMatrices=1 23 | a=[@(x) minus(x,1),] 24 | 25 | %if AddCommasToCellArrays=1 26 | a={@(x) minus(x,1), @(x,y) minus(x,y)} 27 | -------------------------------------------------------------------------------- /MWidgets/AutoCdPath.m: -------------------------------------------------------------------------------- 1 | % AutoCdPath 2 | % cd to this file's path 3 | 4 | file = matlab.desktop.editor.getActiveFilename; 5 | 6 | if isempty(matlab.desktop.editor.getActiveFilename) 7 | % Print error message 8 | msg = "Please open an existing file first."; 9 | error(msg); 10 | else 11 | [filepath, filename, ext] = fileparts(file); 12 | 13 | cd(filepath); 14 | 15 | % Print success message 16 | fprintf("Success. \nCurrent folder is ""%s"".\n", filepath); 17 | end 18 | -------------------------------------------------------------------------------- /MWidgets/Beautifier.m: -------------------------------------------------------------------------------- 1 | % Beautifier 2 | % Format the .m script 3 | 4 | % Print start message 5 | fprintf("Beatuifier processing... \n"); 6 | file = matlab.desktop.editor.getActiveFilename; 7 | if isempty(matlab.desktop.editor.getActiveFilename) 8 | % Print error message 9 | msg = "Please open an existing .m script first."; 10 | error(msg); 11 | else 12 | [filepath, filename, ext] = fileparts(file); 13 | 14 | if ext == ".m" 15 | % Call the main program to format the file 16 | MBeautify.formatCurrentEditorPage(); 17 | 18 | % Print success message 19 | fprintf("Success. \nBeatuify successful format ""%s"".\n", file); 20 | else 21 | % Print error message 22 | msg = "Opened file must be a .m script."; 23 | error(msg); 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /MWidgets/LiveScriptCustomize.m: -------------------------------------------------------------------------------- 1 | s = settings; 2 | 3 | Font_name = "Jetbrains Mono"; 4 | 5 | % Live Editor code font name 6 | s.matlab.fonts.editor.code.Name.PersonalValue = Font_name; 7 | 8 | % Live Editor normal font name 9 | s.matlab.fonts.editor.normal.Name.PersonalValue = Font_name; -------------------------------------------------------------------------------- /MWidgets/MultiMlx2M.m: -------------------------------------------------------------------------------- 1 | % MultiMlx2M 2 | % Autotmatically backup '.mlx' to '.m' 3 | % Multi files edition 4 | 5 | % Print start message 6 | fprintf("MultiMlx2M processing... \n"); 7 | 8 | % cd to this file's path 9 | AutoCdPath; 10 | 11 | % Read the all live scripts in this dir 12 | files = dir('*.mlx'); 13 | nrfiles = numel(files); 14 | 15 | if nrfiles > 0 16 | % Transfer '.m' script to '.mlx' live script 17 | for r = 1:nrfiles 18 | [filepath, filename, ext] = fileparts([files(r).folder, '/', files(r).name]); 19 | 20 | matlab.internal.liveeditor.openAndConvert([filename, '.mlx'], [filename, '.m']); 21 | % Print process message 22 | fprintf("[Process: %d / %d] Successfully transfer ""%s"" to .m script.\n", ... 23 | r, nrfiles, filename); 24 | end 25 | % Print success message 26 | fprintf("Success. \nMultiMlx2M successful backups ""%s"" to .m.\n", filepath); 27 | else 28 | % Print no exit message 29 | msg = "No .mlx script exits in this directory."; 30 | error(msg); 31 | end 32 | -------------------------------------------------------------------------------- /MWidgets/OneMlx2M.m: -------------------------------------------------------------------------------- 1 | % OneMlx2M 2 | % Autotmatically backup '.mlx' to '.m' 3 | % Single file edition 4 | 5 | % Print start message 6 | fprintf("OneMlx2M processing... \n"); 7 | 8 | file = matlab.desktop.editor.getActiveFilename; 9 | if isempty(matlab.desktop.editor.getActiveFilename) 10 | % Print error message 11 | msg = "Please open an existing .m script first."; 12 | error(msg); 13 | else 14 | [filepath, filename, ext] = fileparts(file); 15 | 16 | if ext == ".mlx" 17 | matlab.internal.liveeditor.openAndConvert(file, [filepath, '/', filename, '.m']); 18 | 19 | % Print success message 20 | fprintf("Success. \nOneMlx2M successful backups ""%s"" to .m.\n", file); 21 | else 22 | % Print error message 23 | msg = "Opened file must be a .mlx live script."; 24 | error(msg); 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /MWidgets/Setup.m: -------------------------------------------------------------------------------- 1 | AutoCdPath; 2 | 3 | Labels = ["AutoCdPath", "OneMlx2M", "MultiMlx2M", "Beautifier"]; 4 | Codes = ["AutoCdPath", "OneMlx2M", "MultiMlx2M", "Beautifier"]; 5 | Path = what("..\icons\").path; 6 | IconNames = ["move-to-folder.png", "circle-1.png", "code-compare.png", "indent.png"]; 7 | % IconNames = ["favorite_command_A", "favorite_command_O", "favorite_command_M", "favorite_command_B"]; 8 | 9 | fc = com.mathworks.mlwidgets.favoritecommands.FavoriteCommands.getInstance(); 10 | % methodsview(fc) % to show all available methods with their parameters 11 | for ii = length(Labels):-1:1 12 | Label = Labels(ii); 13 | Code = Codes(ii); 14 | IconName = IconNames(ii); 15 | 16 | newFavoriteCommand = com.mathworks.mlwidgets.favoritecommands.FavoriteCommandProperties(); 17 | newFavoriteCommand.setLabel(Label); 18 | newFavoriteCommand.setCategoryLabel("WIDGETS"); 19 | newFavoriteCommand.setCode(Code); 20 | newFavoriteCommand.setIconName(IconName); 21 | newFavoriteCommand.setIconPath(Path); 22 | newFavoriteCommand.setIsOnQuickToolBar(true); 23 | newFavoriteCommand.setIsShowingLabelOnToolBar(true); 24 | % add the command to the favorite commands (the category is automatically created if it doesn't exist) 25 | fc.addCommand(newFavoriteCommand); 26 | end -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | logo 3 |

MATLAB Utilities

4 |

5 |

6 | 7 | MATLAB 8 |

9 |

10 | English Readme | 11 | 中文自述文件 12 |

13 | 14 | A set of utilities to power MATLAB developing progress. 15 | 16 | ## Current utilities 17 | 18 | ### `AutoCdPath` 19 | 20 | - Filename: `AutoCdPath.m` 21 | 22 | - Function: Automatically set current path to the opened file's path 23 | 24 | - Command: `AutoCdPath` 25 | 26 | ### `OneMlx2M` 27 | 28 | - Filename: `OneMlx2M.m` 29 | 30 | - Function: Transfer current .mlx file to .m file 31 | 32 | - Command: `OneMlx2M` 33 | 34 | ### `MultiMlx2M` 35 | 36 | - Filename: `MultiMlx2M.m` 37 | 38 | - Function: Transfer all .mlx file in current path to .m file 39 | 40 | - Command: `MultiMlx2M` 41 | 42 | ### `MBeautifier` 43 | 44 | - Folder name: `MBeautifier` 45 | 46 | - Function: A MATLAB source code formatter, beautifier. It can be used directly in the MATLAB Editor and it is configurable. 47 | 48 | - Command: `MBeautify.formatCurrentEditorPage()` 49 | 50 | - Remark: base on [MBeautifier](https://github.com/davidvarga/MBeautifier)。 51 | 52 | ## Install 53 | 54 | ### Requirement 55 | 56 | last than MATLAB R2013b. 57 | 58 | #### Download scripts via GitHub 59 | 60 | [GitHub releases page](https://github.com/Fentaniao/MATLAB-Utilities/releases), click on `Assets` at the bottom to show the files available in the release and then click on the .m scripts or .zip file you want to download. 61 | 62 | #### Don't forget to Add to MATLAB search path 63 | 64 | ## Usage 65 | 66 | Here provides more than one way to use these utilities. 67 | 68 | ### 1.Via command window 69 | 70 | Enter command directly in command window. 71 | 72 | For example, you can transfer the current path to the opened file's path by enter the command in command window: 73 | 74 | ```matlab 75 | AutoCdPath 76 | ``` 77 | 78 | then you can find such the result in command window: 79 | 80 | ```matlab 81 | AutoCdPath to "C:\Users\username\Documents\Scripts". 82 | ``` 83 | 84 | ### 2.Set to favorites command, point-and-use 85 | 86 | #### Add to favorites command 87 | 88 | image-20210921110048305 89 | 90 | #### Edit favorites command 91 | 92 | image-20210921110103753 93 | 94 | image-20210921110115227 95 | 96 | #### Effect picture 97 | 98 | image-20210921110140550 99 | 100 | ### 3.Include the required code directly in your project 101 | 102 | ## Contact 103 | 104 | Author: Fentaniao 105 | 106 | Email: [fentaniao@gmail.com](mailto:fentaniao@gmail.com) 107 | 108 | ## License 109 | 110 | [GPL-3.0 License](https://github.com/Fentaniao/MATLAB-Utilities/blob/main/LICENSE) © Fentaniao 111 | -------------------------------------------------------------------------------- /README_zh.md: -------------------------------------------------------------------------------- 1 |

2 | logo 3 |

MATLAB Utilities

4 |

5 |

6 | 7 | MATLAB 8 |

9 |

10 | English Readme | 11 | 中文自述文件 12 |

13 | 14 | 这是一组MATLAB实用程序,旨在优化MATLAB开发流程。 15 | 16 | ## 工具箱内容 17 | 18 | ### `AutoCdPath` 19 | 20 | - 文件名:`AutoCdPath.m` 21 | 22 | - 功能:自动设置当前目录 23 | 24 | - 调用命令:`AutoCdPath` 25 | 26 | ### `OneMlx2M` 27 | 28 | - 文件名:`OneMlx2M.m` 29 | 30 | - 功能:自动转换当前.mlx文件为.m文件 31 | 32 | - 调用命令:`OneMlx2M` 33 | 34 | ### `MultiMlx2M` 35 | 36 | - 文件名:`MultiMlx2M.m` 37 | 38 | - 功能:自动转换目录下所有.mlx文件为.m文件 39 | 40 | - 调用命令:`MultiMlx2M` 41 | 42 | ### `MBeautifier` 43 | 44 | - 文件夹名称:`MBeautifier` 45 | 46 | - 功能:格式化.m文件 47 | 48 | - 调用命令:`MBeautify.formatCurrentEditorPage()` 49 | 50 | - 注:基于[MBeautifier](https://github.com/davidvarga/MBeautifier)项目。 51 | 52 | ## 安装 53 | 54 | ### 要求 55 | 56 | MATLAB 版本不低于R2013b. 57 | 58 | #### 通过GitHub下载脚本 59 | 60 | 导航到[GitHub releases page](https://github.com/Fentaniao/MATLAB-Utilities/releases),点击底部的**Assets**来显示发布版本中可用的文件,然后点击你想要下载的.m 脚本或.zip压缩包。 61 | 62 | #### 别忘记将脚本所在文件夹添加到MATLAB搜索路径 63 | 64 | ## 用法 65 | 66 | 这里提供了多种方法来使用这些实用程序。 67 | 68 | ### 1.通过命令行调用 69 | 70 | 在命令窗口中直接输入命令。 71 | 72 | 例如,您可以在命令窗口中输入命令将该目录转移到打开文件的目录下: 73 | 74 | ```matlab 75 | AutoCdPath 76 | ``` 77 | 78 | 然后您可以在命令窗口中直接找到类似这样的运行结果: 79 | 80 | ```matlab 81 | AutoCdPath to "C:\Users\username\Documents\Scripts". 82 | ``` 83 | 84 | ### 2.设置为收藏夹命令,即点即用 85 | 86 | #### 添加到收藏命令 87 | 88 | image-20210921110048305 89 | 90 | #### 编辑收藏命令 91 | 92 | image-20210921110103753 93 | 94 | image-20210921110115227 95 | 96 | #### 效果图 97 | 98 | image-20210921110140550 99 | 100 | ### 3.直接在项目中包含所需要的代码 101 | 102 | ## 联系 103 | 104 | 作者:Fentaniao 105 | 106 | 邮箱:[fentaniao@gmail.com](mailto:fentaniao@gmail.com) 107 | 108 | ## 开源许可证 109 | 110 | [GPL-3.0 License](https://github.com/Fentaniao/MATLAB-Utilities/blob/main/LICENSE) © Fentaniao 111 | -------------------------------------------------------------------------------- /assets/HatchfulExport-All/facebook_cover_photo_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fentaniao/MATLAB-Utilities/c61f73c790a3d500c65b6c7d51bc7e7ca94915c1/assets/HatchfulExport-All/facebook_cover_photo_1.png -------------------------------------------------------------------------------- /assets/HatchfulExport-All/facebook_cover_photo_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fentaniao/MATLAB-Utilities/c61f73c790a3d500c65b6c7d51bc7e7ca94915c1/assets/HatchfulExport-All/facebook_cover_photo_2.png -------------------------------------------------------------------------------- /assets/HatchfulExport-All/facebook_profile_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fentaniao/MATLAB-Utilities/c61f73c790a3d500c65b6c7d51bc7e7ca94915c1/assets/HatchfulExport-All/facebook_profile_image.png -------------------------------------------------------------------------------- /assets/HatchfulExport-All/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fentaniao/MATLAB-Utilities/c61f73c790a3d500c65b6c7d51bc7e7ca94915c1/assets/HatchfulExport-All/favicon.png -------------------------------------------------------------------------------- /assets/HatchfulExport-All/instagram_profile_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fentaniao/MATLAB-Utilities/c61f73c790a3d500c65b6c7d51bc7e7ca94915c1/assets/HatchfulExport-All/instagram_profile_image.png -------------------------------------------------------------------------------- /assets/HatchfulExport-All/linkedin_banner_image_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fentaniao/MATLAB-Utilities/c61f73c790a3d500c65b6c7d51bc7e7ca94915c1/assets/HatchfulExport-All/linkedin_banner_image_1.png -------------------------------------------------------------------------------- /assets/HatchfulExport-All/linkedin_banner_image_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fentaniao/MATLAB-Utilities/c61f73c790a3d500c65b6c7d51bc7e7ca94915c1/assets/HatchfulExport-All/linkedin_banner_image_2.png -------------------------------------------------------------------------------- /assets/HatchfulExport-All/linkedin_profile_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fentaniao/MATLAB-Utilities/c61f73c790a3d500c65b6c7d51bc7e7ca94915c1/assets/HatchfulExport-All/linkedin_profile_image.png -------------------------------------------------------------------------------- /assets/HatchfulExport-All/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fentaniao/MATLAB-Utilities/c61f73c790a3d500c65b6c7d51bc7e7ca94915c1/assets/HatchfulExport-All/logo.png -------------------------------------------------------------------------------- /assets/HatchfulExport-All/logo_transparent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fentaniao/MATLAB-Utilities/c61f73c790a3d500c65b6c7d51bc7e7ca94915c1/assets/HatchfulExport-All/logo_transparent.png -------------------------------------------------------------------------------- /assets/HatchfulExport-All/pinterest_board_photo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fentaniao/MATLAB-Utilities/c61f73c790a3d500c65b6c7d51bc7e7ca94915c1/assets/HatchfulExport-All/pinterest_board_photo.png -------------------------------------------------------------------------------- /assets/HatchfulExport-All/pinterest_profile_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fentaniao/MATLAB-Utilities/c61f73c790a3d500c65b6c7d51bc7e7ca94915c1/assets/HatchfulExport-All/pinterest_profile_image.png -------------------------------------------------------------------------------- /assets/HatchfulExport-All/twitter_header_photo_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fentaniao/MATLAB-Utilities/c61f73c790a3d500c65b6c7d51bc7e7ca94915c1/assets/HatchfulExport-All/twitter_header_photo_1.png -------------------------------------------------------------------------------- /assets/HatchfulExport-All/twitter_header_photo_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fentaniao/MATLAB-Utilities/c61f73c790a3d500c65b6c7d51bc7e7ca94915c1/assets/HatchfulExport-All/twitter_header_photo_2.png -------------------------------------------------------------------------------- /assets/HatchfulExport-All/twitter_profile_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fentaniao/MATLAB-Utilities/c61f73c790a3d500c65b6c7d51bc7e7ca94915c1/assets/HatchfulExport-All/twitter_profile_image.png -------------------------------------------------------------------------------- /assets/HatchfulExport-All/youtube_profile_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fentaniao/MATLAB-Utilities/c61f73c790a3d500c65b6c7d51bc7e7ca94915c1/assets/HatchfulExport-All/youtube_profile_image.png -------------------------------------------------------------------------------- /icons/circle-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fentaniao/MATLAB-Utilities/c61f73c790a3d500c65b6c7d51bc7e7ca94915c1/icons/circle-1.png -------------------------------------------------------------------------------- /icons/code-compare.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fentaniao/MATLAB-Utilities/c61f73c790a3d500c65b6c7d51bc7e7ca94915c1/icons/code-compare.png -------------------------------------------------------------------------------- /icons/indent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fentaniao/MATLAB-Utilities/c61f73c790a3d500c65b6c7d51bc7e7ca94915c1/icons/indent.png -------------------------------------------------------------------------------- /icons/move-to-folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fentaniao/MATLAB-Utilities/c61f73c790a3d500c65b6c7d51bc7e7ca94915c1/icons/move-to-folder.png -------------------------------------------------------------------------------- /media/image-20210921110048305.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fentaniao/MATLAB-Utilities/c61f73c790a3d500c65b6c7d51bc7e7ca94915c1/media/image-20210921110048305.png -------------------------------------------------------------------------------- /media/image-20210921110103753.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fentaniao/MATLAB-Utilities/c61f73c790a3d500c65b6c7d51bc7e7ca94915c1/media/image-20210921110103753.png -------------------------------------------------------------------------------- /media/image-20210921110115227.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fentaniao/MATLAB-Utilities/c61f73c790a3d500c65b6c7d51bc7e7ca94915c1/media/image-20210921110115227.png -------------------------------------------------------------------------------- /media/image-20210921110140550.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fentaniao/MATLAB-Utilities/c61f73c790a3d500c65b6c7d51bc7e7ca94915c1/media/image-20210921110140550.png -------------------------------------------------------------------------------- /media/image-20210921111702490.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fentaniao/MATLAB-Utilities/c61f73c790a3d500c65b6c7d51bc7e7ca94915c1/media/image-20210921111702490.png -------------------------------------------------------------------------------- /media/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fentaniao/MATLAB-Utilities/c61f73c790a3d500c65b6c7d51bc7e7ca94915c1/media/logo.png --------------------------------------------------------------------------------