How to draw boxes and tables in plain text

In many plain text documents, box drawing characters are used to draw these boxes in figures and tables. Such examples (from RFC 5766) are shown below. Is there a better way to draw this (for instance, a Unix command line tool), other than using the trial-and-error method?


Examples from RFC 5766:

       +----------------------------+---------------------+
       | TURN client to TURN server | TURN server to peer |
       +----------------------------+---------------------+
       |             UDP            |         UDP         |
       |             TCP            |         UDP         |
       |        TLS over TCP        |         UDP         |
       +----------------------------+---------------------+

And this one, also from RFC 5766:

                                        Peer A
                                        Server-Reflexive    +---------+
                                        Transport Address   |         |
                                        192.0.2.150:32102   |         |
                                            |              /|         |
                          TURN              |            / ^|  Peer A |
    Client's              Server            |           /  ||         |
    Host Transport        Transport         |         //   ||         |
    Address               Address           |       //     |+---------+
   10.1.1.2:49721       192.0.2.15:3478     |+-+  //     Peer A
            |               |               ||N| /       Host Transport
            |   +-+         |               ||A|/        Address
            |   | |         |               v|T|     192.168.100.2:49582
            |   | |         |               /+-+
 +---------+|   | |         |+---------+   /              +---------+
 |         ||   |N|         ||         | //               |         |
 | TURN    |v   | |         v| TURN    |/                 |         |
 | Client  |----|A|----------| Server  |------------------|  Peer B |
 |         |    | |^         |         |^                ^|         |
 |         |    |T||         |         ||                ||         |
 +---------+    | ||         +---------+|                |+---------+
                | ||                    |                |
                | ||                    |                |
                +-+|                    |                |
                   |                    |                |
                   |                    |                |
             Client's                   |            Peer B
             Server-Reflexive    Relayed             Transport
             Transport Address   Transport Address   Address
             192.0.2.1:7000      192.0.2.15:50000     192.0.2.210:49191

                                 Figure 1

Solution 1:

The free ASCIIflow website will let you draw text boxes, text, lines, arrows, freeform lines, erase, import, export, and even undo/redo. What else would one need?

Here is my wonderful creation using this tool:

+-------------------------------+
|                               |
|  My first ASCII box           |
|                               |
+---------+---------------------+
          |
          |
          |
          | My first ever ASCII arrow
          |
          |
          |
+---------v----------------------+
|                                |
|  My second ASCII box           |
+--------------------------------+

Solution 2:

It is possible to draw such pictures using tools dating back 30 years, namely pic which is part of the troff command suite. These days gnu's groff package will contain the pic command. The link shows a picture of some typical PostScript output, but using nroff or the appropriate options you will get an ascii-art version. See the user manual (pdf) from 1991 for examples.

The tables in your example are probably produced by this same command suite, using just tbl which produces tables from simple lists.

For a gui version, you can use artist-mode in emacs to draw boxes and arrowed lines etc, using the mouse or keyboard. See youtube video demo.