public static void apply(Op op) {
        Document doc = textArea.getDocument();
        int pos = textArea.getCaretPosition();
        if (op == null)
            return;
        try {
            if (op.getOpType() == OpType.INSERT_CHAR) {
                Insertion insertion = (Insertion) op;
                //builder.insert(insertion.getPos(), insertion.getC());
                doc.insertString(insertion.getPos(), "" + insertion.getC(), null);
                if (insertion.getPos() <= pos) {
                    textArea.setCaretPosition(pos + 1);
                }
            } else {
                Deletion deletion = (Deletion) op;
                char c = textArea.getText().charAt(deletion.getPos());
                deletion.setC(c);
                // builder.delete(deletion.getPos(), deletion.getPos() + 1);
                doc.remove(deletion.getPos(), 1);
                if (deletion.getPos() < pos)
                    textArea.setCaretPosition(pos - 1);
            }
        } catch (Exception e) {
            System.out.println(e);
        }
    }