#define CTRL_B          2
#define BOXCHAR         "*"


init()
{
  assign_key("box",    CTRL_B);   /* <CTRL> B */
}

/* box() - this macro draws a comment box around a marked region */
box()
{
  int col1, col2;      /* starting and ending columns of the marked region */
  int line1, line2;    /* starting and ending lines of the marked region   */
  int width;           /* number of characters across (really col2-col1+1) */

  col1 = marked_col();    col2 = currcol();
  line1 = marked_line();  line2 = currlinenum();
  width = col2 - col1 + 1;
  goline(line1);

  insline();
  setcol(col1);
  insert(strcat("/", repstr(BOXCHAR, width)));
  down();

  while (currlinenum() <= line2 + 1)
  {
    setcol(col1);
    insert("*");
    setcol(col2+1);
    insert(BOXCHAR);
    down();
  }

  insline();
  setcol(col1);
  insert(strcat(repstr(BOXCHAR, width), "/"));
  clear_mark();
}

