|
From: Márcio V. d. S. <mv...@us...> - 2007-10-24 21:30:08
|
Update of /cvsroot/tail/TailS/src/java/org/gjt/sp/jedit/syntax In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv26011/src/java/org/gjt/sp/jedit/syntax Modified Files: JEditTextArea.java Log Message: dsl improving Index: JEditTextArea.java =================================================================== RCS file: /cvsroot/tail/TailS/src/java/org/gjt/sp/jedit/syntax/JEditTextArea.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** JEditTextArea.java 10 Oct 2007 22:00:48 -0000 1.1 --- JEditTextArea.java 24 Oct 2007 21:30:09 -0000 1.2 *************** *** 32,36 **** import java.awt.event.InputEvent; import java.awt.event.KeyEvent; - import java.awt.event.KeyListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; --- 32,35 ---- *************** *** 127,135 **** blink = true; // Initialize the GUI setLayout(new ScrollLayout()); add(CENTER,painter); ! add(RIGHT,vertical = new JScrollBar(JScrollBar.VERTICAL)); ! add(BOTTOM,horizontal = new JScrollBar(JScrollBar.HORIZONTAL)); // Add some event listeners --- 126,138 ---- blink = true; + vertical = new JScrollBar(JScrollBar.VERTICAL); + horizontal = new JScrollBar(JScrollBar.HORIZONTAL); + // Initialize the GUI setLayout(new ScrollLayout()); add(CENTER,painter); ! //add(RIGHT,vertical); ! //add(BOTTOM,horizontal); ! // Add some event listeners *************** *** 139,158 **** painter.addMouseListener(new MouseHandler()); painter.addMouseMotionListener(new DragHandler()); - painter.addKeyListener(new KeyListener(){ - public void keyPressed(KeyEvent e) { - System.out.println("cfoemvoemvo"); - - } - public void keyReleased(KeyEvent e) { - System.out.println("cfoemvoemvo"); - - } - - public void keyTyped(KeyEvent e) { - System.out.println("cfoemvoemvo"); - - } - - }); addFocusListener(new FocusHandler()); --- 142,145 ---- *************** *** 300,304 **** horizontal.setValues(-horizontalOffset,width,0,width * 5); horizontal.setUnitIncrement(painter.getFontMetrics() ! .charWidth('w')); horizontal.setBlockIncrement(width / 2); } --- 287,291 ---- horizontal.setValues(-horizontalOffset,width,0,width * 5); horizontal.setUnitIncrement(painter.getFontMetrics() ! .charWidth('w')); horizontal.setBlockIncrement(width / 2); } *************** *** 421,425 **** int lineStart = getLineStartOffset(line); int offset = Math.max(0,Math.min(getLineLength(line) - 1, ! getCaretPosition() - lineStart)); return scrollTo(line,offset); --- 408,412 ---- int lineStart = getLineStartOffset(line); int offset = Math.max(0,Math.min(getLineLength(line) - 1, ! getCaretPosition() - lineStart)); return scrollTo(line,offset); *************** *** 467,476 **** { newHorizontalOffset = Math.min(0,horizontalOffset ! - x + width + 5); } else if(x + width >= painter.getWidth()) { newHorizontalOffset = horizontalOffset + ! (painter.getWidth() - x) - width - 5; } --- 454,463 ---- { newHorizontalOffset = Math.min(0,horizontalOffset ! - x + width + 5); } else if(x + width >= painter.getWidth()) { newHorizontalOffset = horizontalOffset + ! (painter.getWidth() - x) - width - 5; } *************** *** 486,490 **** FontMetrics fm = painter.getFontMetrics(); return (line - firstLine) * fm.getHeight() ! - (fm.getLeading() + fm.getMaxDescent()); } --- 473,477 ---- FontMetrics fm = painter.getFontMetrics(); return (line - firstLine) * fm.getHeight() ! - (fm.getLeading() + fm.getMaxDescent()); } *************** *** 498,502 **** int height = fm.getHeight(); return Math.max(0,Math.min(getLineCount() - 1, ! y / height + firstLine)); } --- 485,489 ---- int height = fm.getHeight(); return Math.max(0,Math.min(getLineCount() - 1, ! y / height + firstLine)); } *************** *** 538,542 **** lineSegment.count = offset; return x + Utilities.getTabbedTextWidth(lineSegment, ! fm,x,painter,0); } /* If syntax coloring is enabled, we have to do this because --- 525,529 ---- lineSegment.count = offset; return x + Utilities.getTabbedTextWidth(lineSegment, ! fm,x,painter,0); } /* If syntax coloring is enabled, we have to do this because *************** *** 546,550 **** Token tokens; if(painter.currentLineIndex == line ! && painter.currentLineTokens != null) tokens = painter.currentLineTokens; else --- 533,537 ---- Token tokens; if(painter.currentLineIndex == line ! && painter.currentLineTokens != null) tokens = painter.currentLineTokens; else *************** *** 552,556 **** painter.currentLineIndex = line; tokens = painter.currentLineTokens ! = tokenMarker.markTokens(lineSegment,line); } --- 539,543 ---- painter.currentLineIndex = line; tokens = painter.currentLineTokens ! = tokenMarker.markTokens(lineSegment,line); } *************** *** 579,583 **** lineSegment.count = offset - (lineSegment.offset - segmentOffset); return x + Utilities.getTabbedTextWidth( ! lineSegment,fm,x,painter,0); } else --- 566,570 ---- lineSegment.count = offset - (lineSegment.offset - segmentOffset); return x + Utilities.getTabbedTextWidth( ! lineSegment,fm,x,painter,0); } else *************** *** 585,589 **** lineSegment.count = length; x += Utilities.getTabbedTextWidth( ! lineSegment,fm,x,painter,0); lineSegment.offset += length; } --- 572,576 ---- lineSegment.count = length; x += Utilities.getTabbedTextWidth( ! lineSegment,fm,x,painter,0); lineSegment.offset += length; } *************** *** 621,625 **** if(c == '\t') charWidth = (int)painter.nextTabStop(width,i) ! - width; else charWidth = fm.charWidth(c); --- 608,612 ---- if(c == '\t') charWidth = (int)painter.nextTabStop(width,i) ! - width; else charWidth = fm.charWidth(c); *************** *** 645,649 **** Token tokens; if(painter.currentLineIndex == line && painter ! .currentLineTokens != null) tokens = painter.currentLineTokens; else --- 632,636 ---- Token tokens; if(painter.currentLineIndex == line && painter ! .currentLineTokens != null) tokens = painter.currentLineTokens; else *************** *** 651,655 **** painter.currentLineIndex = line; tokens = painter.currentLineTokens ! = tokenMarker.markTokens(lineSegment,line); } --- 638,642 ---- painter.currentLineIndex = line; tokens = painter.currentLineTokens ! = tokenMarker.markTokens(lineSegment,line); } *************** *** 679,683 **** if(c == '\t') charWidth = (int)painter.nextTabStop(width,offset + i) ! - width; else charWidth = fm.charWidth(c); --- 666,670 ---- if(c == '\t') charWidth = (int)painter.nextTabStop(width,offset + i) ! - width; else charWidth = fm.charWidth(c); *************** *** 796,800 **** { Element lineElement = document.getDefaultRootElement() ! .getElement(line); if(lineElement == null) return -1; --- 783,787 ---- { Element lineElement = document.getDefaultRootElement() ! .getElement(line); if(lineElement == null) return -1; *************** *** 812,816 **** { Element lineElement = document.getDefaultRootElement() ! .getElement(line); if(lineElement == null) return -1; --- 799,803 ---- { Element lineElement = document.getDefaultRootElement() ! .getElement(line); if(lineElement == null) return -1; *************** *** 826,835 **** { Element lineElement = document.getDefaultRootElement() ! .getElement(line); if(lineElement == null) return -1; else return lineElement.getEndOffset() ! - lineElement.getStartOffset() - 1; } --- 813,822 ---- { Element lineElement = document.getDefaultRootElement() ! .getElement(line); if(lineElement == null) return -1; else return lineElement.getEndOffset() ! - lineElement.getStartOffset() - 1; } *************** *** 952,956 **** Element map = document.getDefaultRootElement(); int start = selectionStart - map.getElement(selectionStartLine) ! .getStartOffset(); Element lineElement = map.getElement(line); --- 939,943 ---- Element map = document.getDefaultRootElement(); int start = selectionStart - map.getElement(selectionStartLine) ! .getStartOffset(); Element lineElement = map.getElement(line); *************** *** 1002,1006 **** Element map = document.getDefaultRootElement(); int end = selectionEnd - map.getElement(selectionEndLine) ! .getStartOffset(); Element lineElement = map.getElement(line); --- 989,993 ---- Element map = document.getDefaultRootElement(); int end = selectionEnd - map.getElement(selectionEndLine) ! .getStartOffset(); Element lineElement = map.getElement(line); *************** *** 1123,1128 **** { throw new IllegalArgumentException("Bounds out of" ! + " range: " + newStart + "," + ! newEnd); } --- 1110,1115 ---- { throw new IllegalArgumentException("Bounds out of" ! + " range: " + newStart + "," + ! newEnd); } *************** *** 1131,1135 **** // the end (clearing magic position, scrolling) if(newStart != selectionStart || newEnd != selectionEnd ! || newBias != biasLeft) { int newStartLine = getLineOfOffset(newStart); --- 1118,1122 ---- // the end (clearing magic position, scrolling) if(newStart != selectionStart || newEnd != selectionEnd ! || newBias != biasLeft) { int newStartLine = getLineOfOffset(newStart); *************** *** 1149,1153 **** document.addUndoableEdit(new CaretUndo( ! selectionStart,selectionEnd)); selectionStart = newStart; --- 1136,1140 ---- document.addUndoableEdit(new CaretUndo( ! selectionStart,selectionEnd)); selectionStart = newStart; *************** *** 1190,1196 **** int start = selectionStart - map.getElement(selectionStartLine) ! .getStartOffset(); int end = selectionEnd - map.getElement(selectionEndLine) ! .getStartOffset(); // Certain rectangles satisfy this condition... --- 1177,1183 ---- int start = selectionStart - map.getElement(selectionStartLine) ! .getStartOffset(); int end = selectionEnd - map.getElement(selectionEndLine) ! .getStartOffset(); // Certain rectangles satisfy this condition... *************** *** 1227,1231 **** { return getText(selectionStart, ! selectionEnd - selectionStart); } } --- 1214,1218 ---- { return getText(selectionStart, ! selectionEnd - selectionStart); } } *************** *** 1240,1244 **** { throw new InternalError("Text component" ! + " read only"); } --- 1227,1231 ---- { throw new InternalError("Text component" ! + " read only"); } *************** *** 1252,1258 **** int start = selectionStart - map.getElement(selectionStartLine) ! .getStartOffset(); int end = selectionEnd - map.getElement(selectionEndLine) ! .getStartOffset(); // Certain rectangles satisfy this condition... --- 1239,1245 ---- int start = selectionStart - map.getElement(selectionStartLine) ! .getStartOffset(); int end = selectionEnd - map.getElement(selectionEndLine) ! .getStartOffset(); // Certain rectangles satisfy this condition... *************** *** 1275,1279 **** document.remove(rectStart,Math.min(lineEnd - rectStart, ! end - start)); if(selectedText == null) --- 1262,1266 ---- document.remove(rectStart,Math.min(lineEnd - rectStart, ! end - start)); if(selectedText == null) *************** *** 1285,1302 **** document.insertString(rectStart,selectedText ! .substring(lastNewline,currNewline),null); lastNewline = Math.min(selectedText.length(), ! currNewline + 1); } if(selectedText != null && ! currNewline != selectedText.length()) { int offset = map.getElement(selectionEndLine) ! .getEndOffset() - 1; document.insertString(offset,"\n",null); document.insertString(offset + 1,selectedText ! .substring(currNewline + 1),null); } } --- 1272,1289 ---- document.insertString(rectStart,selectedText ! .substring(lastNewline,currNewline),null); lastNewline = Math.min(selectedText.length(), ! currNewline + 1); } if(selectedText != null && ! currNewline != selectedText.length()) { int offset = map.getElement(selectionEndLine) ! .getEndOffset() - 1; document.insertString(offset,"\n",null); document.insertString(offset + 1,selectedText ! .substring(currNewline + 1),null); } } *************** *** 1304,1312 **** { document.remove(selectionStart, ! selectionEnd - selectionStart); if(selectedText != null) { document.insertString(selectionStart, ! selectedText,null); } } --- 1291,1299 ---- { document.remove(selectionStart, ! selectionEnd - selectionStart); if(selectedText != null) { document.insertString(selectionStart, ! selectedText,null); } } *************** *** 1316,1320 **** bl.printStackTrace(); throw new InternalError("Cannot replace" ! + " selection"); } // No matter what happends... stops us from leaving document --- 1303,1307 ---- bl.printStackTrace(); throw new InternalError("Cannot replace" ! + " selection"); } // No matter what happends... stops us from leaving document *************** *** 1545,1551 **** // so do it here String selection = ((String)clipboard ! .getContents(this).getTransferData( ! DataFlavor.stringFlavor)) ! .replace('\r','\n'); int repeatCount = inputHandler.getRepeatCount(); --- 1532,1538 ---- // so do it here String selection = ((String)clipboard ! .getContents(this).getTransferData( ! DataFlavor.stringFlavor)) ! .replace('\r','\n'); int repeatCount = inputHandler.getRepeatCount(); *************** *** 1560,1564 **** getToolkit().beep(); System.err.println("Clipboard does not" ! + " contain a string"); } } --- 1547,1551 ---- getToolkit().beep(); System.err.println("Clipboard does not" ! + " contain a string"); } } *************** *** 1606,1610 **** protected static JEditTextArea focusedComponent; protected static Timer caretTimer; ! protected TextAreaPainter painter; --- 1593,1597 ---- protected static JEditTextArea focusedComponent; protected static Timer caretTimer; ! protected TextAreaPainter painter; *************** *** 1625,1629 **** protected int horizontalOffset; ! protected JScrollBar vertical; protected JScrollBar horizontal; --- 1612,1616 ---- protected int horizontalOffset; ! protected JScrollBar vertical; protected JScrollBar horizontal; *************** *** 1672,1676 **** { int offset = TextUtilities.findMatchingBracket( ! document,newCaretPosition - 1); if(offset != -1) { --- 1659,1663 ---- { int offset = TextUtilities.findMatchingBracket( ! document,newCaretPosition - 1); if(offset != -1) { *************** *** 1691,1695 **** { DocumentEvent.ElementChange ch = evt.getChange( ! document.getDefaultRootElement()); int count; --- 1678,1682 ---- { DocumentEvent.ElementChange ch = evt.getChange( ! document.getDefaultRootElement()); int count; *************** *** 1698,1702 **** else count = ch.getChildrenAdded().length - ! ch.getChildrenRemoved().length; int line = getLineOfOffset(evt.getOffset()); --- 1685,1689 ---- else count = ch.getChildrenAdded().length - ! ch.getChildrenRemoved().length; int line = getLineOfOffset(evt.getOffset()); *************** *** 1755,1762 **** dim.width += centerPref.width; dim.height += centerPref.height; ! Dimension rightPref = right.getPreferredSize(); ! dim.width += rightPref.width; ! Dimension bottomPref = bottom.getPreferredSize(); ! dim.height += bottomPref.height; return dim; --- 1742,1753 ---- dim.width += centerPref.width; dim.height += centerPref.height; ! if(right != null){ ! Dimension rightPref = right.getPreferredSize(); ! dim.width += rightPref.width; ! } ! if(bottom != null){ ! Dimension bottomPref = bottom.getPreferredSize(); ! dim.height += bottomPref.height; ! } return dim; *************** *** 1773,1781 **** dim.width += centerPref.width; dim.height += centerPref.height; ! Dimension rightPref = right.getMinimumSize(); ! dim.width += rightPref.width; ! Dimension bottomPref = bottom.getMinimumSize(); ! dim.height += bottomPref.height; ! return dim; } --- 1764,1775 ---- dim.width += centerPref.width; dim.height += centerPref.height; ! if(right != null){ ! Dimension rightPref = right.getMinimumSize(); ! dim.width += rightPref.width; ! } ! if(bottom != null){ ! Dimension bottomPref = bottom.getMinimumSize(); ! dim.height += bottomPref.height; ! } return dim; } *************** *** 1790,1810 **** int ibottom = insets.bottom; int iright = insets.right; ! int rightWidth = right.getPreferredSize().width; ! int bottomHeight = bottom.getPreferredSize().height; int centerWidth = size.width - rightWidth - ileft - iright; int centerHeight = size.height - bottomHeight - itop - ibottom; center.setBounds( ! ileft, ! itop, ! centerWidth, ! centerHeight); ! right.setBounds( ! ileft + centerWidth, ! itop, ! rightWidth, ! centerHeight); // Lay out all status components, in order --- 1784,1811 ---- int ibottom = insets.bottom; int iright = insets.right; + int rightWidth = 0; + if(right != null){ + rightWidth = right.getPreferredSize().width; + } ! int bottomHeight = 0; ! if(bottom != null){ ! bottomHeight = bottom.getPreferredSize().height; ! } int centerWidth = size.width - rightWidth - ileft - iright; int centerHeight = size.height - bottomHeight - itop - ibottom; center.setBounds( ! ileft, ! itop, ! centerWidth, ! centerHeight); ! if(right != null) ! right.setBounds( ! ileft + centerWidth, ! itop, ! rightWidth, ! centerHeight); // Lay out all status components, in order *************** *** 1815,1829 **** Dimension dim = comp.getPreferredSize(); comp.setBounds(ileft, ! itop + centerHeight, ! dim.width, ! bottomHeight); ileft += dim.width; } ! bottom.setBounds( ! ileft, ! itop + centerHeight, ! size.width - rightWidth - ileft - iright, ! bottomHeight); } --- 1816,1831 ---- Dimension dim = comp.getPreferredSize(); comp.setBounds(ileft, ! itop + centerHeight, ! dim.width, ! bottomHeight); ileft += dim.width; } ! if(bottom != null) ! bottom.setBounds( ! ileft, ! itop + centerHeight, ! size.width - rightWidth - ileft - iright, ! bottomHeight); } *************** *** 1841,1845 **** { if(focusedComponent != null ! && focusedComponent.hasFocus()) focusedComponent.blinkCaret(); } --- 1843,1847 ---- { if(focusedComponent != null ! && focusedComponent.hasFocus()) focusedComponent.blinkCaret(); } *************** *** 1913,1917 **** if(selectionStart > offset || (selectionStart ! == selectionEnd && selectionStart == offset)) newStart = selectionStart + length; else --- 1915,1919 ---- if(selectionStart > offset || (selectionStart ! == selectionEnd && selectionStart == offset)) newStart = selectionStart + length; else *************** *** 1925,1929 **** select(newStart,newEnd); } ! public void removeUpdate(DocumentEvent evt) { --- 1927,1931 ---- select(newStart,newEnd); } ! public void removeUpdate(DocumentEvent evt) { *************** *** 1972,1976 **** setSelectionRectangular((evt.getModifiers() ! & InputEvent.CTRL_MASK) != 0); select(getMarkPosition(),xyToOffset(evt.getX(),evt.getY())); } --- 1974,1978 ---- setSelectionRectangular((evt.getModifiers() ! & InputEvent.CTRL_MASK) != 0); select(getMarkPosition(),xyToOffset(evt.getX(),evt.getY())); } *************** *** 1993,1997 **** } } ! class MouseHandler extends MouseAdapter { --- 1995,1999 ---- } } ! class MouseHandler extends MouseAdapter { *************** *** 2005,2009 **** if((evt.getModifiers() & InputEvent.BUTTON3_MASK) != 0 ! && popup != null) { popup.show(painter,evt.getX(),evt.getY()); --- 2007,2011 ---- if((evt.getModifiers() & InputEvent.BUTTON3_MASK) != 0 ! && popup != null) { popup.show(painter,evt.getX(),evt.getY()); *************** *** 2039,2043 **** private void doSingleClick(MouseEvent evt, int line, ! int offset, int dot) { if((evt.getModifiers() & InputEvent.SHIFT_MASK) != 0) --- 2041,2045 ---- private void doSingleClick(MouseEvent evt, int line, ! int offset, int dot) { if((evt.getModifiers() & InputEvent.SHIFT_MASK) != 0) *************** *** 2051,2056 **** private void doDoubleClick(MouseEvent evt, int line, ! int offset, int dot) throws BadLocationException ! { // Ignore empty lines if(getLineLength(line) == 0) --- 2053,2058 ---- private void doDoubleClick(MouseEvent evt, int line, ! int offset, int dot) throws BadLocationException ! { // Ignore empty lines if(getLineLength(line) == 0) *************** *** 2060,2064 **** { int bracket = TextUtilities.findMatchingBracket( ! document,Math.max(0,dot - 1)); if(bracket != -1) { --- 2062,2066 ---- { int bracket = TextUtilities.findMatchingBracket( ! document,Math.max(0,dot - 1)); if(bracket != -1) { *************** *** 2090,2095 **** // we select the surrounding non-letters boolean selectNoLetter = (!Character ! .isLetterOrDigit(ch) ! && noWordSep.indexOf(ch) == -1); int wordStart = 0; --- 2092,2097 ---- // we select the surrounding non-letters boolean selectNoLetter = (!Character ! .isLetterOrDigit(ch) ! && noWordSep.indexOf(ch) == -1); int wordStart = 0; *************** *** 2099,2104 **** ch = lineText.charAt(i); if(selectNoLetter ^ (!Character ! .isLetterOrDigit(ch) && ! noWordSep.indexOf(ch) == -1)) { wordStart = i + 1; --- 2101,2106 ---- ch = lineText.charAt(i); if(selectNoLetter ^ (!Character ! .isLetterOrDigit(ch) && ! noWordSep.indexOf(ch) == -1)) { wordStart = i + 1; *************** *** 2112,2117 **** ch = lineText.charAt(i); if(selectNoLetter ^ (!Character ! .isLetterOrDigit(ch) && ! noWordSep.indexOf(ch) == -1)) { wordEnd = i; --- 2114,2119 ---- ch = lineText.charAt(i); if(selectNoLetter ^ (!Character ! .isLetterOrDigit(ch) && ! noWordSep.indexOf(ch) == -1)) { wordEnd = i; *************** *** 2131,2139 **** int lineStart = getLineStartOffset(line); select(lineStart + wordStart,lineStart + wordEnd); ! */ ! } private void doTripleClick(MouseEvent evt, int line, ! int offset, int dot) { select(getLineStartOffset(line),getLineEndOffset(line)-1); --- 2133,2141 ---- int lineStart = getLineStartOffset(line); select(lineStart + wordStart,lineStart + wordEnd); ! */ ! } private void doTripleClick(MouseEvent evt, int line, ! int offset, int dot) { select(getLineStartOffset(line),getLineEndOffset(line)-1); |