public void mouseDragged(MouseEvent evt) {
        if (buttonCheck(evt.getModifiers(), MouseEvent.BUTTON1_MASK) ||
                // Windows NT/95 etc: returns 0, which is a bug
                evt.getModifiers() == 0) {
            int xoffset = (super.getSize().width - buffer.width * charWidth) / 2;
            int yoffset = (super.getSize().height - buffer.height * charHeight) / 2;
            int x = (evt.getX() - xoffset) / charWidth;
            int y = (evt.getY() - yoffset) / charHeight + buffer.windowBase;
            int oldx = selectEnd.x, oldy = selectEnd.y;

            if ((x <= selectBegin.x && y <= selectBegin.y)) {
                selectBegin.x = x;
                selectBegin.y = y;
            } else {
                selectEnd.x = x;
                selectEnd.y = y;
            }

            if (oldx != x || oldy != y) {
                buffer.update[0] = true;
                if (debug > 0) {
                    System.err.println("select([" + selectBegin.x + "," + selectBegin.y + "]," +
                            "[" + selectEnd.x + "," + selectEnd.y + "])");
                }
                redraw();
            }
        }
    }