title: Using mouse to paint row of characters in ncurses
body: <p>I'm trying to use ncurses to paint a row of characters on the screen with the mouse. I'm able to distinguish between a BUTTON1_CLICKED event and BUTTON1_RELEASED event on the screen, but haven't figured out how to paint between them.  </p>
  
  <p>The following code prints BUTTON1_CLICKED and BUTTON1_RELEASED at their event positions:</p>
  
  <pre><code>void obstacle_draw(WINDOW * boardWin, int array[LINES][COLS]) {
  
  int ch;
  MEVENT event;
  
  keypad(boardWin, TRUE);
  mousemask(BUTTON1_CLICKED | BUTTON1_RELEASED | REPORT_MOUSE_POSITION, NULL);
  mouseinterval(0);  
  
  while(1) {
      ch = wgetch(boardWin);   
      if (ch == KEY_MOUSE) {   
          getmouse(&amp;event);
          if (event.bstate &amp; BUTTON1_CLICKED) {
              wattron(boardWin, COLOR_PAIR(BLACK_ON_WHITE) | A_REVERSE);
              mvwprintw(boardWin, event.y, event.x, "CLICKED at %d,%d", event.y, event.x);
              wrefresh(boardWin);
          } else if (event.bstate &amp; BUTTON1_RELEASED) {
                  wattron(boardWin, COLOR_PAIR(BLACK_ON_WHITE) | A_REVERSE);
              mvwprintw(boardWin, event.y, event.x, "RELEASED at %d,%d", event.y, event.x);
              wrefresh(boardWin);
          }  
      }
      if (ch == '\n') {
          break;
      }
  }
  return;
  }
  </code></pre>
  
  <p>Adding the following line before my while loop allows me to paint these coordinates once I've made the first mouse click, and without holding the button. But I can't seem to turn it off (I also don't understand how it works): </p>
  
  <pre><code>printf("\033[?1003h\n");
  </code></pre>
  
  <p>I feel like I've read every ncurses mouse post on stack overflow. What am I missing?  </p>