code: function gli_window_put_string(win, val) {
      var ix, ch;
  
      //### might be efficient to split the implementation up into
      //### gli_window_buffer_put_string(), etc, since many functions
      //### know the window type when they call this
      switch (win.type) {
      case Const.wintype_TextBuffer:
          if (win.style != win.accumstyle
              || win.hyperlink != win.accumhyperlink)
              gli_window_buffer_deaccumulate(win);
          win.accum.push(val);
          break;
      case Const.wintype_TextGrid:
          for (ix=0; ix<val.length; ix++) {
              ch = val.charAt(ix);
  
              /* Canonicalize the cursor position. This is like calling
                 gli_window_grid_canonicalize(), but I've inlined it. */
              if (win.cursorx < 0)
                  win.cursorx = 0;
              else if (win.cursorx >= win.gridwidth) {
                  win.cursorx = 0;
                  win.cursory++;
              }
              if (win.cursory < 0)
                  win.cursory = 0;
              else if (win.cursory >= win.gridheight)
                  break; /* outside the window */
  
              if (ch == "\n") {
                  /* a newline just moves the cursor. */
                  win.cursory++;
                  win.cursorx = 0;
                  continue;
              }
  
              lineobj = win.lines[win.cursory];
              lineobj.dirty = true;
              lineobj.chars[win.cursorx] = ch;
              lineobj.styles[win.cursorx] = win.style;
              lineobj.hyperlinks[win.cursorx] = win.hyperlink;
  
              win.cursorx++;
              /* We can leave the cursor outside the window, since it will be
                 canonicalized next time a character is printed. */
          }
          break;
      }
  }
docs: /* Add a (Javascript) string to the given window's display.