/** * Creates a new FileTextArea. */ public FileTextArea(FileWindow w) { this.w = w; popup = new FilePopupMenu(this); popup.addPopupMenuListener(this); addMouseListener(this); addKeyListener(this); setFont(new Font("Monospaced", 0, 12)); }
/** * Called when the mouse is clicked. */ public void mouseClicked(MouseEvent e) { checkPopup(e); requestFocus(); getCaret().setVisible(true); }
/** * Selects a range of characters. */ public void select(int start, int end) { int docEnd = textArea.getDocument().getLength(); textArea.select(docEnd, docEnd); textArea.select(start, end); }
if (pos >= 0) { try { int line = getLineOfOffset(pos); Rectangle rect = modelToView(pos); if (rect == null) { select(pos, pos); } else { try { Rectangle nrect = modelToView(getLineStartOffset(line + 1)); if (nrect != null) { rect = nrect; JViewport vp = (JViewport)getParent(); Rectangle viewRect = vp.getViewRect(); if (viewRect.y + viewRect.height > rect.y) { select(pos, pos); } else { scrollRectToVisible(rect); select(pos, pos); select(pos, pos);
/** * Creates a new FileWindow. */ public FileWindow(SwingGui debugGui, Dim.SourceInfo sourceInfo) { super(SwingGui.getShortName(sourceInfo.url()), true, true, true, true); this.debugGui = debugGui; this.sourceInfo = sourceInfo; updateToolTip(); currentPos = -1; textArea = new FileTextArea(this); textArea.setRows(24); textArea.setColumns(80); p = new JScrollPane(); fileHeader = new FileHeader(this); p.setViewportView(textArea); p.setRowHeaderView(fileHeader); setContentPane(p); pack(); updateText(sourceInfo); textArea.select(0); }
super.paint(g); FileTextArea textArea = fileWindow.textArea; Font font = textArea.getFont(); g.setFont(font); FontMetrics metrics = getFontMetrics(font); int ascent = metrics.getMaxAscent(); int h = metrics.getHeight(); int lineCount = textArea.getLineCount() + 1; String dummy = Integer.toString(lineCount); if (dummy.length() < 2) { int pos = -2; try { pos = textArea.getLineStartOffset(i); } catch (BadLocationException ignored) {
/** * Performs an action. */ public void actionPerformed(ActionEvent e) { int pos = viewToModel(new Point(popup.x, popup.y)); popup.setVisible(false); String cmd = e.getActionCommand(); int line = -1; try { line = getLineOfOffset(pos); } catch (Exception exc) { } if (cmd.equals("Set Breakpoint")) { w.setBreakPoint(line + 1); } else if (cmd.equals("Clear Breakpoint")) { w.clearBreakPoint(line + 1); } else if (cmd.equals("Run")) { w.load(); } }
/** * Updates the gutter. */ public void update() { FileTextArea textArea = fileWindow.textArea; Font font = textArea.getFont(); setFont(font); FontMetrics metrics = getFontMetrics(font); int h = metrics.getHeight(); int lineCount = textArea.getLineCount() + 1; String dummy = Integer.toString(lineCount); if (dummy.length() < 2) { dummy = "99"; } Dimension d = new Dimension(); d.width = metrics.stringWidth(dummy) + 16; d.height = lineCount * h + 100; setPreferredSize(d); setSize(d); }
/** * Called when a mouse button is released. */ public void mouseReleased(MouseEvent e) { checkPopup(e); }
/** * Called when a mouse button is pressed. */ public void mousePressed(MouseEvent e) { Font font = fileWindow.textArea.getFont(); FontMetrics metrics = getFontMetrics(font); int h = metrics.getHeight(); pressLine = e.getY() / h; }
/** * Performs an action. */ public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); if (cmd.equals("Cut")) { // textArea.cut(); } else if (cmd.equals("Copy")) { textArea.copy(); } else if (cmd.equals("Paste")) { // textArea.paste(); } } }
if (pos >= 0) { try { int line = getLineOfOffset(pos); Rectangle rect = modelToView(pos); if (rect == null) { select(pos, pos); } else { try { Rectangle nrect = modelToView(getLineStartOffset(line + 1)); if (nrect != null) { rect = nrect; JViewport vp = (JViewport)getParent(); Rectangle viewRect = vp.getViewRect(); if (viewRect.y + viewRect.height > rect.y) { select(pos, pos); } else { scrollRectToVisible(rect); select(pos, pos); select(pos, pos);
/** * Creates a new FileWindow. */ public FileWindow(SwingGui debugGui, Dim.SourceInfo sourceInfo) { super(SwingGui.getShortName(sourceInfo.url()), true, true, true, true); this.debugGui = debugGui; this.sourceInfo = sourceInfo; updateToolTip(); currentPos = -1; textArea = new FileTextArea(this); textArea.setRows(24); textArea.setColumns(80); p = new JScrollPane(); fileHeader = new FileHeader(this); p.setViewportView(textArea); p.setRowHeaderView(fileHeader); setContentPane(p); pack(); updateText(sourceInfo); textArea.select(0); }
super.paint(g); FileTextArea textArea = fileWindow.textArea; Font font = textArea.getFont(); g.setFont(font); FontMetrics metrics = getFontMetrics(font); int ascent = metrics.getMaxAscent(); int h = metrics.getHeight(); int lineCount = textArea.getLineCount() + 1; String dummy = Integer.toString(lineCount); if (dummy.length() < 2) { int pos = -2; try { pos = textArea.getLineStartOffset(i); } catch (BadLocationException ignored) {
/** * Performs an action. */ public void actionPerformed(ActionEvent e) { int pos = viewToModel(new Point(popup.x, popup.y)); popup.setVisible(false); String cmd = e.getActionCommand(); int line = -1; try { line = getLineOfOffset(pos); } catch (Exception exc) { } if (cmd.equals("Set Breakpoint")) { w.setBreakPoint(line + 1); } else if (cmd.equals("Clear Breakpoint")) { w.clearBreakPoint(line + 1); } else if (cmd.equals("Run")) { w.load(); } }
/** * Updates the gutter. */ public void update() { FileTextArea textArea = fileWindow.textArea; Font font = textArea.getFont(); setFont(font); FontMetrics metrics = getFontMetrics(font); int h = metrics.getHeight(); int lineCount = textArea.getLineCount() + 1; String dummy = Integer.toString(lineCount); if (dummy.length() < 2) { dummy = "99"; } Dimension d = new Dimension(); d.width = metrics.stringWidth(dummy) + 16; d.height = lineCount * h + 100; setPreferredSize(d); setSize(d); }
/** * Called when a mouse button is released. */ public void mouseReleased(MouseEvent e) { checkPopup(e); }
/** * Called when a mouse button is pressed. */ public void mousePressed(MouseEvent e) { Font font = fileWindow.textArea.getFont(); FontMetrics metrics = getFontMetrics(font); int h = metrics.getHeight(); pressLine = e.getY() / h; }
/** * Performs an action. */ public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); if (cmd.equals("Cut")) { // textArea.cut(); } else if (cmd.equals("Copy")) { textArea.copy(); } else if (cmd.equals("Paste")) { // textArea.paste(); } } }
if (pos >= 0) { try { int line = getLineOfOffset(pos); Rectangle rect = modelToView(pos); if (rect == null) { select(pos, pos); } else { try { Rectangle nrect = modelToView(getLineStartOffset(line + 1)); if (nrect != null) { rect = nrect; JViewport vp = (JViewport)getParent(); Rectangle viewRect = vp.getViewRect(); if (viewRect.y + viewRect.height > rect.y) { select(pos, pos); } else { scrollRectToVisible(rect); select(pos, pos); select(pos, pos);