├── .gitignore ├── META-INF └── plugin.xml ├── demo.gif ├── readme.md └── src └── com └── jonathonstaff └── ideaascii ├── AsciiComment.java ├── AsciiFontSelector.java └── util └── Util.java /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by http://www.gitignore.io 2 | 3 | ### Java ### 4 | *.class 5 | 6 | # Mobile Tools for Java (J2ME) 7 | .mtj.tmp/ 8 | 9 | # Package Files # 10 | *.jar 11 | *.war 12 | *.ear 13 | 14 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 15 | hs_err_pid* 16 | 17 | 18 | ### Intellij ### 19 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm 20 | 21 | ## Directory-based project format 22 | .idea/ 23 | # if you remove the above rule, at least ignore user-specific stuff: 24 | # .idea/workspace.xml 25 | # .idea/tasks.xml 26 | # and these sensitive or high-churn files: 27 | # .idea/dataSources.ids 28 | # .idea/dataSources.xml 29 | # .idea/sqlDataSources.xml 30 | # .idea/dynamic.xml 31 | 32 | ## File-based project format 33 | *.ipr 34 | *.iws 35 | *.iml 36 | 37 | ## Additional for IntelliJ 38 | out/ 39 | 40 | # generated by mpeltonen/sbt-idea plugin 41 | .idea_modules/ 42 | 43 | # generated by JIRA plugin 44 | atlassian-ide-plugin.xml 45 | 46 | # generated by Crashlytics plugin (for Android Studio and Intellij) 47 | com_crashlytics_export_strings.xml 48 | 49 | 50 | ### OSX ### 51 | .DS_Store 52 | .AppleDouble 53 | .LSOverride 54 | 55 | # Icon must end with two \r 56 | Icon 57 | 58 | # Thumbnails 59 | ._* 60 | 61 | # Files that might appear on external disk 62 | .Spotlight-V100 63 | .Trashes 64 | 65 | # Directories potentially created on remote AFP share 66 | .AppleDB 67 | .AppleDesktop 68 | Network Trash Folder 69 | Temporary Items 70 | .apdisk 71 | 72 | -------------------------------------------------------------------------------- /META-INF/plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | com.jonathonstaff.ideaascii 3 | IdeaAscii 4 | 1.1 5 | Jonathon Staff 6 | 7 | 9 | Check out the repo on GitHub for more details:
10 | https://github.com/jonstaff/IdeaAscii 11 | ]]>
12 | 13 | 17 |
  • Support for text on current line
  • 18 |
  • Support for indentation
  • 19 |
  • Support for selected text
  • 20 | 21 | 22 | Version 1.0 23 | 26 | 27 | ]]>
    28 | 29 | 30 | 31 | 32 | 33 | 35 | 36 | 37 | com.intellij.modules.lang 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 56 | 57 | 58 | 59 | 63 | 64 | 65 | 66 | 67 |
    -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jonstaff/IdeaAscii/f125e485999bb957b28ece12070dfec4fc2be031/demo.gif -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | IdeaAscii 2 | ========= 3 | 4 | IdeaAscii is an IntelliJ plugin to generate comments as ASCII artwork. 5 | 6 | ![](demo.gif) 7 | 8 | Installation 9 | ------------ 10 | 11 | `Preferences > Plugins > Browse repositories... > Search for "IdeaAscii" > Install Plugin` 12 | 13 | Usage 14 | ----- 15 | 16 | Locate your cursor where you would like to add a comment/heading, and press `ctrl shift I`. Type in the text you would like generated, and hit enter. Your text will be converted to ASCII and automatically commented. 17 | 18 | Alternatively, you can go to `Tools > Insert Ascii Comment`. 19 | 20 | Configuration 21 | ------------- 22 | 23 | You can change the font by going to `Tools > Select Ascii Font`. The item you select from the dropdown menu will become the font used until you change it. 24 | 25 | The default font is 'ivrit' simply because that's what I've used before and like the way it looks. For some reason, this particular font always seems to be generated in reverse, so I've fixed that interally. If you notice any other fonts that are rending backward, please let me know. 26 | 27 | Developed By 28 | ------------ 29 | 30 | [Jonathon Staff](http://jonathonstaff.com) 31 | 32 | Contributors 33 | ------------ 34 | 35 | [Kjartan Olason](http://www.kjartan.com.br) 36 | 37 | License 38 | ======= 39 | 40 | Copyright 2014 Jonathon Staff 41 | 42 | Licensed under the Apache License, Version 2.0 (the "License"); 43 | you may not use this file except in compliance with the License. 44 | You may obtain a copy of the License at 45 | 46 | http://www.apache.org/licenses/LICENSE-2.0 47 | 48 | Unless required by applicable law or agreed to in writing, software 49 | distributed under the License is distributed on an "AS IS" BASIS, 50 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 51 | See the License for the specific language governing permissions and 52 | limitations under the License. 53 | -------------------------------------------------------------------------------- /src/com/jonathonstaff/ideaascii/AsciiComment.java: -------------------------------------------------------------------------------- 1 | package com.jonathonstaff.ideaascii; 2 | 3 | import com.intellij.openapi.actionSystem.AnAction; 4 | import com.intellij.openapi.actionSystem.AnActionEvent; 5 | import com.intellij.openapi.application.ApplicationManager; 6 | import com.intellij.openapi.command.CommandProcessor; 7 | import com.intellij.openapi.editor.Document; 8 | import com.intellij.openapi.editor.Editor; 9 | import com.intellij.openapi.editor.SelectionModel; 10 | import com.intellij.openapi.fileEditor.FileEditorManager; 11 | import com.intellij.openapi.project.Project; 12 | import com.intellij.openapi.ui.Messages; 13 | import com.jonathonstaff.ideaascii.util.Util; 14 | 15 | // Created by jonstaff on 6/11/14. 16 | // Edited by kjarrio on 2014-07-01 17 | 18 | public class AsciiComment extends AnAction { 19 | 20 | public void actionPerformed(AnActionEvent e) { 21 | final Project project = e.getProject(); 22 | if (project == null) return; 23 | 24 | final Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor(); 25 | if (editor == null) return; 26 | 27 | String initialValue = ""; 28 | 29 | final SelectionModel selectionModel = editor.getSelectionModel(); 30 | 31 | if (!selectionModel.hasSelection()) { 32 | selectionModel.selectLineAtCaret(); 33 | } 34 | 35 | String selectedText = selectionModel.getSelectedText(); 36 | if ((selectedText != null) && (!selectedText.isEmpty())) { 37 | selectedText = selectedText.trim(); 38 | 39 | if (selectedText.contains("\n")) { 40 | selectedText = selectedText.substring(0, selectedText.indexOf("\n")); 41 | } 42 | 43 | initialValue = selectedText; 44 | } 45 | 46 | final String text = Messages.showInputDialog(project, null, "ASCII Text", null, initialValue, null); 47 | 48 | final Runnable readRunner = new Runnable() { 49 | @Override 50 | public void run() { 51 | if (text == null) return; 52 | int offset = editor.getCaretModel().getOffset(); 53 | final Document document = editor.getDocument(); 54 | 55 | // Check if we should replace the selected text 56 | if (selectionModel.hasSelection()) { 57 | int selectionStart = selectionModel.getSelectionStart(); 58 | int selectionEnd = selectionModel.getSelectionEnd(); 59 | 60 | selectionModel.removeSelection(); 61 | document.deleteString(selectionStart, selectionEnd); 62 | offset = selectionStart; 63 | } 64 | 65 | int lineNumber = document.getLineNumber(offset); 66 | int lineStartOffset = document.getLineStartOffset(lineNumber); 67 | int indentLength = offset - lineStartOffset; 68 | 69 | document.insertString(offset, Util.convertTextToAscii(text, indentLength)); 70 | } 71 | }; 72 | 73 | ApplicationManager.getApplication().invokeLater(new Runnable() { 74 | @Override 75 | public void run() { 76 | CommandProcessor.getInstance().executeCommand(project, new Runnable() { 77 | @Override 78 | public void run() { 79 | ApplicationManager.getApplication().runWriteAction(readRunner); 80 | } 81 | }, "IdeaAscii", null); 82 | } 83 | }); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/com/jonathonstaff/ideaascii/AsciiFontSelector.java: -------------------------------------------------------------------------------- 1 | package com.jonathonstaff.ideaascii; 2 | 3 | // Created by jonstaff on 6/12/14. 4 | 5 | import com.intellij.ide.util.PropertiesComponent; 6 | import com.intellij.openapi.actionSystem.AnAction; 7 | import com.intellij.openapi.actionSystem.AnActionEvent; 8 | import com.intellij.openapi.ui.Messages; 9 | import com.jonathonstaff.ideaascii.util.Util; 10 | 11 | public class AsciiFontSelector extends AnAction { 12 | 13 | @Override 14 | public void actionPerformed(AnActionEvent event) { 15 | PropertiesComponent prop = PropertiesComponent.getInstance(); 16 | String font = Messages.showEditableChooseDialog(null, "Select Font", null, fonts, 17 | prop.getValue(Util.KEY_FONT, "rounded"), null); 18 | prop.setValue(Util.KEY_FONT, font); 19 | } 20 | 21 | String fonts[] = {"3-d", 22 | "3x5", 23 | "5lineoblique", 24 | "1943____", 25 | "4x4_offr", 26 | "64f1____", 27 | "a_zooloo", 28 | "advenger", 29 | "aquaplan", 30 | "asc_____", 31 | "ascii___", 32 | "assalt_m", 33 | "asslt__m", 34 | "atc_____", 35 | "atc_gran", 36 | "b_m__200", 37 | "battle_s", 38 | "battlesh", 39 | "baz__bil", 40 | "beer_pub", 41 | "bubble__", 42 | "bubble_b", 43 | "c1______", 44 | "c2______", 45 | "c_ascii_", 46 | "c_consen", 47 | "caus_in_", 48 | "char1___", 49 | "char2___", 50 | "char3___", 51 | "char4___", 52 | "charact1", 53 | "charact2", 54 | "charact3", 55 | "charact4", 56 | "charact5", 57 | "charact6", 58 | "characte", 59 | "charset_", 60 | "coil_cop", 61 | "com_sen_", 62 | "computer", 63 | "convoy__", 64 | "d_dragon", 65 | "dcs_bfmo", 66 | "deep_str", 67 | "demo_1__", 68 | "demo_2__", 69 | "demo_m__", 70 | "devilish", 71 | "druid___", 72 | "e__fist_", 73 | "ebbs_1__", 74 | "ebbs_2__", 75 | "eca_____", 76 | "etcrvs__", 77 | "f15_____", 78 | "faces_of", 79 | "fair_mea", 80 | "fairligh", 81 | "fantasy_", 82 | "fbr12___", 83 | "fbr1____", 84 | "fbr2____", 85 | "fbr_stri", 86 | "fbr_tilt", 87 | "finalass", 88 | "fireing_", 89 | "flyn_sh", 90 | "fp1_____", 91 | "fp2_____", 92 | "funky_dr", 93 | "future_1", 94 | "future_2", 95 | "future_3", 96 | "future_4", 97 | "future_5", 98 | "future_6", 99 | "future_7", 100 | "future_8", 101 | "gauntlet", 102 | "ghost_bo", 103 | "gothic", 104 | "gothic__", 105 | "grand_pr", 106 | "green_be", 107 | "hades___", 108 | "heavy_me", 109 | "heroboti", 110 | "high_noo", 111 | "hills___", 112 | "home_pak", 113 | "house_of", 114 | "hypa_bal", 115 | "hyper___", 116 | "inc_raw_", 117 | "italics_", 118 | "joust___", 119 | "kgames_i", 120 | "kik_star", 121 | "krak_out", 122 | "lazy_jon", 123 | "letter_w", 124 | "letterw3", 125 | "lexible_", 126 | "mad_nurs", 127 | "magic_ma", 128 | "master_o", 129 | "mayhem_d", 130 | "mcg_____", 131 | "mig_ally", 132 | "modern__", 133 | "new_asci", 134 | "nfi1____", 135 | "notie_ca", 136 | "npn_____", 137 | "odel_lak", 138 | "ok_beer_", 139 | "outrun__", 140 | "p_s_h_m_", 141 | "p_skateb", 142 | "pacos_pe", 143 | "panther_", 144 | "pawn_ins", 145 | "phonix__", 146 | "platoon2", 147 | "platoon_", 148 | "pod_____", 149 | "r2-d2___", 150 | "rad_____", 151 | "rad_phan", 152 | "radical_", 153 | "rainbow_", 154 | "rally_s2", 155 | "rally_sp", 156 | "rampage_", 157 | "rastan__", 158 | "raw_recu", 159 | "rci_____", 160 | "ripper!_", 161 | "road_rai", 162 | "rockbox_", 163 | "rok_____", 164 | "roman", 165 | "roman___", 166 | "script__", 167 | "skate_ro", 168 | "skateord", 169 | "skateroc", 170 | "sketch_s", 171 | "sm______", 172 | "space_op", 173 | "spc_demo", 174 | "star_war", 175 | "stealth_", 176 | "stencil1", 177 | "stencil2", 178 | "street_s", 179 | "subteran", 180 | "super_te", 181 | "t__of_ap", 182 | "tav1____", 183 | "taxi____", 184 | "tec1____", 185 | "tec_7000", 186 | "tecrvs__", 187 | "ti_pan__", 188 | "timesofl", 189 | "tomahawk", 190 | "top_duck", 191 | "trashman", 192 | "triad_st", 193 | "ts1_____", 194 | "tsm_____", 195 | "tsn_base", 196 | "twin_cob", 197 | "type_set", 198 | "ucf_fan_", 199 | "ugalympi", 200 | "unarmed_", 201 | "usa_____", 202 | "usa_pq__", 203 | "vortron_", 204 | "war_of_w", 205 | "yie-ar__", 206 | "yie_ar_k", 207 | "z-pilot_", 208 | "zig_zag_", 209 | "zone7___", 210 | "acrobatic", 211 | "alligator", 212 | "alligator2", 213 | "alphabet", 214 | "avatar", 215 | "banner", 216 | "banner3-D", 217 | "banner3", 218 | "banner4", 219 | "barbwire", 220 | "basic", 221 | "5x7", 222 | "5x8", 223 | "6x10", 224 | "6x9", 225 | "brite", 226 | "briteb", 227 | "britebi", 228 | "britei", 229 | "chartr", 230 | "chartri", 231 | "clb6x10", 232 | "clb8x10", 233 | "clb8x8", 234 | "cli8x8", 235 | "clr4x6", 236 | "clr5x10", 237 | "clr5x6", 238 | "clr5x8", 239 | "clr6x10", 240 | "clr6x6", 241 | "clr6x8", 242 | "clr7x10", 243 | "clr7x8", 244 | "clr8x10", 245 | "clr8x8", 246 | "cour", 247 | "courb", 248 | "courbi", 249 | "couri", 250 | "helv", 251 | "helvb", 252 | "helvbi", 253 | "helvi", 254 | "sans", 255 | "sansb", 256 | "sansbi", 257 | "sansi", 258 | "sbook", 259 | "sbookb", 260 | "sbookbi", 261 | "sbooki", 262 | "times", 263 | "tty", 264 | "ttyb", 265 | "utopia", 266 | "utopiab", 267 | "utopiabi", 268 | "utopiai", 269 | "xbrite", 270 | "xbriteb", 271 | "xbritebi", 272 | "xbritei", 273 | "xchartr", 274 | "xchartri", 275 | "xcour", 276 | "xcourb", 277 | "xcourbi", 278 | "xcouri", 279 | "xhelv", 280 | "xhelvb", 281 | "xhelvbi", 282 | "xhelvi", 283 | "xsans", 284 | "xsansb", 285 | "xsansbi", 286 | "xsansi", 287 | "xsbook", 288 | "xsbookb", 289 | "xsbookbi", 290 | "xsbooki", 291 | "xtimes", 292 | "xtty", 293 | "xttyb", 294 | "bell", 295 | "big", 296 | "bigchief", 297 | "binary", 298 | "block", 299 | "broadway", 300 | "bubble", 301 | "bulbhead", 302 | "calgphy2", 303 | "caligraphy", 304 | "catwalk", 305 | "chunky", 306 | "coinstak", 307 | "colossal", 308 | "contessa", 309 | "contrast", 310 | "cosmic", 311 | "cosmike", 312 | "crawford", 313 | "cricket", 314 | "cursive", 315 | "cyberlarge", 316 | "cybermedium", 317 | "cybersmall", 318 | "decimal", 319 | "diamond", 320 | "digital", 321 | "doh", 322 | "doom", 323 | "dotmatrix", 324 | "double", 325 | "drpepper", 326 | "dwhistled", 327 | "eftichess", 328 | "eftifont", 329 | "eftipiti", 330 | "eftirobot", 331 | "eftitalic", 332 | "eftiwall", 333 | "eftiwater", 334 | "epic", 335 | "fender", 336 | "fourtops", 337 | "fraktur", 338 | "goofy", 339 | "graceful", 340 | "gradient", 341 | "graffiti", 342 | "hex", 343 | "hollywood", 344 | "invita", 345 | "isometric1", 346 | "isometric2", 347 | "isometric3", 348 | "isometric4", 349 | "italic", 350 | "ivrit", 351 | "jazmine", 352 | "jerusalem", 353 | "katakana", 354 | "kban", 355 | "l4me", 356 | "larry3d", 357 | "lcd", 358 | "lean", 359 | "letters", 360 | "linux", 361 | "lockergnome", 362 | "madrid", 363 | "marquee", 364 | "maxfour", 365 | "mike", 366 | "mini", 367 | "mirror", 368 | "mnemonic", 369 | "morse", 370 | "moscow", 371 | "mshebrew210", 372 | "nancyj-fancy", 373 | "nancyj-underlined", 374 | "nancyj", 375 | "nipples", 376 | "ntgreek", 377 | "nvscript", 378 | "o8", 379 | "octal", 380 | "ogre", 381 | "os2", 382 | "pawp", 383 | "peaks", 384 | "pebbles", 385 | "pepper", 386 | "poison", 387 | "puffy", 388 | "pyramid", 389 | "rectangles", 390 | "relief", 391 | "relief2", 392 | "rev", 393 | "rot13", 394 | "rounded", 395 | "rowancap", 396 | "rozzo", 397 | "runic", 398 | "runyc", 399 | "sblood", 400 | "script", 401 | "serifcap", 402 | "shadow", 403 | "short", 404 | "slant", 405 | "slide", 406 | "slscript", 407 | "small", 408 | "smisome1", 409 | "smkeyboard", 410 | "smscript", 411 | "smshadow", 412 | "smslant", 413 | "smtengwar", 414 | "speed", 415 | "stacey", 416 | "stampatello", 417 | "standard", 418 | "starwars", 419 | "stellar", 420 | "stop", 421 | "straight", 422 | "tanja", 423 | "tengwar", 424 | "term", 425 | "thick", 426 | "thin", 427 | "threepoint", 428 | "ticks", 429 | "ticksslant", 430 | "tinker-toy", 431 | "tombstone", 432 | "trek", 433 | "tsalagi", 434 | "twopoint", 435 | "univers", 436 | "usaflag", 437 | "weird", 438 | "whimsy"}; 439 | } 440 | -------------------------------------------------------------------------------- /src/com/jonathonstaff/ideaascii/util/Util.java: -------------------------------------------------------------------------------- 1 | package com.jonathonstaff.ideaascii.util; 2 | 3 | // Created by jonstaff on 6/11/14. 4 | // Edited by kjarrio on 2014-07-01 5 | 6 | import com.intellij.ide.util.PropertiesComponent; 7 | 8 | import org.apache.commons.httpclient.HttpClient; 9 | import org.apache.commons.httpclient.methods.GetMethod; 10 | 11 | import java.io.IOException; 12 | import java.io.UnsupportedEncodingException; 13 | import java.net.URLEncoder; 14 | 15 | public class Util { 16 | 17 | public static final String KEY_FONT = "ascii_font"; 18 | 19 | public static String convertTextToAscii(String text, int indentLength) { 20 | PropertiesComponent prop = PropertiesComponent.getInstance(); 21 | if (!prop.getValue(KEY_FONT, "ivrit").equals("ivrit")) { 22 | return convertTextToAsciiCommented(text, prop.getValue(KEY_FONT), indentLength); 23 | } else { 24 | return convertTextToAsciiCommented(new StringBuilder(text).reverse().toString(), "ivrit", indentLength); 25 | } 26 | } 27 | 28 | public static String convertTextToAscii(String text, String font) { 29 | HttpClient client = new HttpClient(); 30 | GetMethod get = new GetMethod("http://artii.herokuapp.com/make?text=" 31 | + urlEncodedString(text) + "&font=" + font); 32 | 33 | String response = "Something went wrong...\nThis plugin requires an Internet connection " + 34 | "- please ensure you have one."; 35 | try { 36 | client.executeMethod(get); 37 | response = get.getResponseBodyAsString(); 38 | } catch (IOException e1) { 39 | e1.printStackTrace(); 40 | } finally { 41 | get.releaseConnection(); 42 | } 43 | 44 | return response; 45 | } 46 | 47 | public static String urlEncodedString(String str) { 48 | String encodedStr = ""; 49 | try { 50 | encodedStr = URLEncoder.encode(str, "UTF-8"); 51 | } catch (UnsupportedEncodingException e) { 52 | e.printStackTrace(); 53 | } 54 | return encodedStr; 55 | } 56 | 57 | public static String convertTextToAsciiCommented(String text, String font, int indentLength) { 58 | StringBuilder ascii = new StringBuilder(convertTextToAscii(text, font)); 59 | ascii.insert(0, "// "); 60 | 61 | StringBuilder indent = new StringBuilder(); 62 | for (int a = 0; a < indentLength; a++) indent.append(" "); 63 | 64 | return ascii.toString().replace("\n", "\n" + indent + "// "); 65 | } 66 | } 67 | --------------------------------------------------------------------------------