private void setup() {
        initComponents();
        
        //{{{ Set up the text area
        textPane.setCaretPosition(0);
        
        initDocument();
        
        textPane.addCaretListener(new CaretListener() {
//            int lastLocation = 0;
            public void caretUpdate(CaretEvent e) {
                // TODO: Highlight matching brackets
//                if (e.getDot() != lastLocation) {
//                    lastLocation = e.getDot();
//                }
                if (e.getMark() != e.getDot()) {
                    cutMenuItem.setEnabled(true);
                    copyMenuItem.setEnabled(true);
                } else {
                    cutMenuItem.setEnabled(false);
                    copyMenuItem.setEnabled(false);
                }
            }
        });
        
        // FIXME Is there a better way to add global key bindings?
        // TODO Add find and replace
        textPane.addKeyListener(new KeyListener() {
            public void keyPressed(final KeyEvent e) {
                if (((e.getModifiers() & KeyEvent.CTRL_MASK) != 0) ||
                        (e.getModifiers() & KeyEvent.CTRL_DOWN_MASK) != 0) {
                    if (e.getKeyCode() == KeyEvent.VK_Z)
                        undoMenuItem.doClick();
                    else if (e.getKeyCode() == KeyEvent.VK_R)
                        redoMenuItem.doClick();
                    else if (e.getKeyCode() == KeyEvent.VK_G)
                        goToMenuItem.doClick();
                    else if (e.getKeyCode() == KeyEvent.VK_F)
                        findMenuItem.doClick();
                }
            }
            public void keyReleased(KeyEvent e) { }
            public void keyTyped(KeyEvent e) { }
        });
//        DefaultInputHandler handler = (DefaultInputHandler) textArea.getInputHandler();
//        handler.addKeyBinding("C+C", new CopyListener());
//        handler.addKeyBinding("C+X", new CutListener());
//        handler.addKeyBinding("C+V", new PasteListener());
//        handler.addKeyBinding("C+Z", new UndoListener());
//        handler.addKeyBinding("C+R", new RedoListener());
//        handler.addKeyBinding("C+G", new GoToListener());
        //}}}
        
        Toolkit.getDefaultToolkit().getSystemClipboard().addFlavorListener(
                new FlavorListener() {
            public void flavorsChanged(FlavorEvent e) {
                final Clipboard clipboard =
                        Toolkit.getDefaultToolkit().getSystemClipboard();
                
                if (clipboard.isDataFlavorAvailable(DataFlavor.stringFlavor)) {
                    pasteMenuItem.setEnabled(true);
                } else {
                    pasteMenuItem.setEnabled(false);
                }
            }
        }
        );
        
        textAreaKeyTyped(); // set the syntaxCheckLabel
    }