1

I read a post here by @grgarside. He answered a question with a beautifully labelled command using what seems to be only Unicode characters:

┌── ln(1) link, ln -- make links
│   ┌── Create a symbolic link.
│   │                         ┌── the path to the intended symlink
│   │                         │   can use . or ~ or other relative paths
│   │                   ┌─────┴────────┐
ln -s /path/to/original /path/to/symlink
      └───────┬───────┘
              └── the path to the original file/folder
                  can use . or ~ or other relative paths

How did he do this? It seems hard to believe that he manually typed the whole thing into a text editor. Is there some type of Unicode editor that makes it easy to create such graphics?

Edit: as per @grgarside's instruction, except with my Keyboard-en.plist file being in a slightly different location:

Resources ❯ readlink Keyboard-en.plist
/System/Library/Input Methods/PressAndHold.app/Contents/Resources/Keyboard-en.plist

and with the addition towards to the top of the file (note that I needed to use sudo vim Keyboard-en.plist as sublime didn't let me save the file even with sudo subl:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>

    <key>Roman-Accent-k</key>
    <dict>
        <key>Direction</key>
        <string>right</string>
            <key>Keycaps</key>
            <string>└ ─ ┬ ┘ ┌ ┴ ┐</string>
            <key>Strings</key>
            <string>└ ─ ┬ ┘ ┌ ┴ ┐</string>
    </dict>

    <key>Roman-Accent-A</key>
    <dict>
        <key>Direction</key>
        <string>right</string>
        <key>Keycaps</key>
        <string>A À Á Â Ä Æ Ã Å Ā</string>
        <key>Strings</key>
        <string>A À Á Â Ä Æ Ã Å Ā</string>
    </dict>
    ...
</dict>
</plist>
Community
  • 1
  • 1
mbigras
  • 7,664
  • 11
  • 50
  • 111
  • While you might call this ASCII Art, the characters are not ASCII. They do go back, though, many decades to systems that didn't use ASCII either, such as the IBM PC. Of course, these characters have been incorporated into Unicode (which itself is 25-years old), the character set you're using everywhere (including this web site) except in specialized or archaic scenarios. – Tom Blodget May 31 '16 at 17:08
  • thanks @TomBlodget, I edited my question appropriately. – mbigras Jun 03 '16 at 05:31
  • https://en.wikipedia.org/wiki/Box-drawing_character – Hans Passant Jun 03 '16 at 12:44
  • @HansPassant thanks for the article, is there a program the you use to create text mode graphics that are simple like the one above? I see one [here](https://github.com/osaukko/TextPaint64) but it seems more complex than necessary – mbigras Jun 03 '16 at 13:21

2 Answers2

2

I'm the one who wrote the answer in question, and I did craft it manually. I use PressAndHold.app (part of macOS) to add the unicode quickly by holding a character down on the keyboard to insert the characters.

You can use the following in the relevant keyboard plist located at /System/Library/Input Methods/PressAndHold.app/Contents/Resources/Keyboard-en.plist to use the same thing yourself. In my plist, I set ‘k’ as the key to hold.

<key>Roman-Accent-k</key>
<dict>
    <key>Direction</key>
    <string>right</string>
    <key>Keycaps</key>
    <string>└ ─ ┬ ┘ ┌ ┴ ┐</string>
    <key>Strings</key>
    <string>└ ─ ┬ ┘ ┌ ┴ ┐</string>
</dict>
grg
  • 5,023
  • 3
  • 34
  • 50
  • thanks for getting back to me. Do you have any tips about how craft a label quickly? Just messing around with it for a couple minutes it seems a little tricky to wait for the pop up for each character. – mbigras Jun 04 '16 at 02:06
  • @mbigras You can use Karabiner (formerly KeyRemap4MacBook) to reduce the hold delay before the options are shown — see [Faster Press and Hold Character Picker](http://apple.stackexchange.com/q/99805/37797). – grg Jun 05 '16 at 12:42
0

I personally just use the Wikipedia page on unicode box-drawing characters to copy-paste the lines into my answers to write answers such as javascript can't access private properties and Does javascript process using an elastic racetrack algorithm.

Yes it's not as fancy as implementing a custom keyboard binding but I thought I'd just have to write this answer to say that yes, there are people who manually craft answers using only the internet and Stackoverflow's "Your Answer" textarea.

Community
  • 1
  • 1
slebetman
  • 109,858
  • 19
  • 140
  • 171