From: <nic...@us...> - 2009-11-06 15:26:00
|
Revision: 16446 http://jedit.svn.sourceforge.net/jedit/?rev=16446&view=rev Author: nicarran Date: 2009-11-06 15:25:50 +0000 (Fri, 06 Nov 2009) Log Message: ----------- * Some changes on LineInfo to make guidelines a little less "aggresive": ** guidelines on empty lines are now calculated only using lines below. * Cleanups. Modified Paths: -------------- plugins/CandyFolds/trunk/CandyFolds.props plugins/CandyFolds/trunk/candyfolds/LineInfo.java plugins/CandyFolds/trunk/candyfolds/TextAreaExt.java Modified: plugins/CandyFolds/trunk/CandyFolds.props =================================================================== --- plugins/CandyFolds/trunk/CandyFolds.props 2009-11-05 20:26:58 UTC (rev 16445) +++ plugins/CandyFolds/trunk/CandyFolds.props 2009-11-06 15:25:50 UTC (rev 16446) @@ -2,7 +2,7 @@ plugin.candyfolds.CandyFoldsPlugin.name=CandyFolds plugin.candyfolds.CandyFoldsPlugin.author=Nicol\xE1s Carranza # inspired and based on work by Andr\xE9 Kaplan & Nathan Jones (WhiteSpace plugin) -plugin.candyfolds.CandyFoldsPlugin.version=1.1.0 +plugin.candyfolds.CandyFoldsPlugin.version=1.1.1 plugin.candyfolds.CandyFoldsPlugin.description=CandyFolds draws colored indentation-guides on the text area to improve code readability. plugin.candyfolds.CandyFoldsPlugin.docs=index.html Modified: plugins/CandyFolds/trunk/candyfolds/LineInfo.java =================================================================== --- plugins/CandyFolds/trunk/candyfolds/LineInfo.java 2009-11-05 20:26:58 UTC (rev 16445) +++ plugins/CandyFolds/trunk/candyfolds/LineInfo.java 2009-11-06 15:25:50 UTC (rev 16446) @@ -40,7 +40,7 @@ private final List<Integer> indents=new ArrayList<Integer>(); private final List<Integer> lines=new ArrayList<Integer>(); // lines where the indents belong (1:1). private final List<StripConfig> stripConfigs=new ArrayList<StripConfig>(); - + LineInfo(TextAreaExt textAreaExt) { this.textAreaExt=textAreaExt; } @@ -67,52 +67,32 @@ lines.clear(); stripConfigs.clear(); } - - void copyFrom(LineInfo lineInfo){ - clear(); - line=lineInfo.line; - indents.addAll(lineInfo.indents); - lines.addAll(lineInfo.lines); - stripConfigs.addAll(lineInfo.stripConfigs); - } - void eval(Buffer buffer, int line){ + void eval(Buffer buffer, final int line){ eval(buffer, line, null); } - void eval(Buffer buffer, int line, LineInfo upLineInfo){ + void eval(Buffer buffer, final int line, LineInfo upLineInfo){ clear(); this.line=line; int upLine= upLineInfo==null? 0: upLineInfo.line+1; - + int calcLine; if(isEmptySegment(buffer, line)){ - int firstIndentUp=-1, firstIndentUpLine=line; - for(int i=line; i>=upLine; i--){ - if(i!=0 && isEmptySegment(buffer, i)) - continue; - firstIndentUp=buffer.getCurrentIndentForLine(i, null); - firstIndentUpLine=i; - break; - } - if(firstIndentUp==-1){ - firstIndentUp=upLineInfo.lineIndent; - firstIndentUpLine=upLineInfo.line; - } int firstIndentDown=-1, firstIndentDownLine=line; - for(int i=line, lineCount=buffer.getLineCount(); i<lineCount; i++){ // TODO: optimize for performance on large files with a lot of empty lines... + for(int i=line+1, lineCount=buffer.getLineCount(); i<lineCount; i++){ // TODO: optimize for performance on large files with a lot of empty lines... if(isEmptySegment(buffer, i)) continue; firstIndentDown=buffer.getCurrentIndentForLine(i, null); firstIndentDownLine=i; break; } - if(firstIndentDown>firstIndentUp){ + if(firstIndentDown!=-1){ calcLine=firstIndentDownLine; lineIndent=firstIndentDown; }else{ - calcLine=firstIndentUpLine; - lineIndent=firstIndentUp; + calcLine=line; + lineIndent=0; } } else{ @@ -124,7 +104,7 @@ for(; calcLine>=upLine; calcLine--) { indent=buffer.getCurrentIndentForLine(calcLine, null); if(indent>=lastCaughtIndent || - indent>lineIndent) + indent>lineIndent) continue; if(isEmptySegment(buffer, calcLine)) continue; @@ -138,12 +118,12 @@ } if(upLineInfo!=null - && lastCaughtIndent>0 // optimization - ){ + && lastCaughtIndent>0 // optimization + ){ for(int i=0; i<upLineInfo.indents.size(); i++){ indent=upLineInfo.indents.get(i); if(indent>=lastCaughtIndent || - indent>lineIndent) + indent>lineIndent) continue; lastCaughtIndent=indent; //L.fine("line="+line+", adding upLineInfo indent="+indent); @@ -180,14 +160,18 @@ buffer.getLineText(prevLine, segment); int segmentContentLength=evalSegmentContentLength(segment); if(segmentContentLength==0) - continue; + break; int prevLineIndent=buffer.getCurrentIndentForLine(prevLine, null); if(prevLineIndent>lineIndent) continue; if(prevLineIndent<lineIndent) break; - if(segmentContentLength==1) + if(segmentContentLength==1){ + if(line!=prevLine && + lineIndent==prevLineIndent) + break; continue; + } usePrevLine=true; // -> the segment is ready on prevLine break; Modified: plugins/CandyFolds/trunk/candyfolds/TextAreaExt.java =================================================================== --- plugins/CandyFolds/trunk/candyfolds/TextAreaExt.java 2009-11-05 20:26:58 UTC (rev 16445) +++ plugins/CandyFolds/trunk/candyfolds/TextAreaExt.java 2009-11-06 15:25:50 UTC (rev 16446) @@ -61,28 +61,10 @@ final EditPane editPane; private final TextAreaPainter painter; - /* - private final LineInfo firstLineInfo=new LineInfo(this); - private Buffer firstLineInfoBuffer; - private final BufferListener firstLineInfoBufferL=new BufferAdapter(){ - @Override - public void contentInserted(JEditBuffer buffer, int startLine, int offset, int numLines, int length){ - contentChanged(); - } - @Override - public void contentRemoved(JEditBuffer buffer, int startLine, int offset, int numLines, int length){ - contentChanged(); - } - private void contentChanged(){ - unregisterFirstLineInfoBuffer(); - } - };*/ private LineInfo previousLineInfo=new LineInfo(this); private LineInfo currentLineInfo=new LineInfo(this); //private final LineInfo toolTipLineInfo=new LineInfo(this); - - private final FontMetricsInfo fontMetricsInfo=new FontMetricsInfo(); private static final class FontMetricsInfo { @@ -99,7 +81,6 @@ lineHeight=fontMetrics.getHeight(); barStroke=new BasicStroke(spaceWidth/2.3f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND); } - } private ModeConfig modeConfig; @@ -138,24 +119,22 @@ @Override public void paintValidLine(Graphics2D g, - int screenLine, - int physicalLine, - int start, - int end, - int y) { - //lineInfo.eval(editPane.getBuffer(), physicalLine); - //drawLine(lineInfo, g, y); + int screenLine, + int physicalLine, + int start, + int end, + int y) { } @Override public synchronized void paintScreenLineRange(Graphics2D g, - int firstLine, - int lastLine, - int[] physicalLines, - int[] start, - int[] end, - int y, - int lineHeight) { + int firstLine, + int lastLine, + int[] physicalLines, + int[] start, + int[] end, + int y, + int lineHeight){ //Log.log(Log.NOTICE, this, "painting range: firstLine="+firstLine+", lastLine=" + lastLine + ", y=" + y+"lineHeight="+lineHeight); //long nanoTime=System.nanoTime(); Buffer buffer = editPane.getBuffer(); @@ -167,16 +146,8 @@ int line=physicalLines[i]; if(line==-1) continue; - if(i==0){ - /* this optimization does not worth the effort! - if(firstLineInfoBuffer!=buffer // firstLineInfoBuffer is set to null when buffer changes - || firstLineInfo.getLine()!=line){ - firstLineInfo.eval(buffer, line); - registerFirstLineInfoBuffer(buffer); - } - currentLineInfo.copyFrom(firstLineInfo);*/ + if(i==0) currentLineInfo.eval(buffer, line); - } else currentLineInfo.eval(buffer, line, previousLineInfo); drawLineIndents(buffer, currentLineInfo, g, y); @@ -189,21 +160,6 @@ //L.fine("new painting time="+(System.nanoTime()-nanoTime)); } - /* - private synchronized void registerFirstLineInfoBuffer(Buffer buffer){ - if(buffer==firstLineInfoBuffer) - return; - unregisterFirstLineInfoBuffer(); - firstLineInfoBuffer=buffer; - firstLineInfoBuffer.addBufferListener(firstLineInfoBufferL); - } - - private synchronized void unregisterFirstLineInfoBuffer(){ - if(firstLineInfoBuffer!=null) - firstLineInfoBuffer.removeBufferListener(firstLineInfoBufferL); - firstLineInfoBuffer=null; - }*/ - private void drawLineIndents(Buffer buffer, LineInfo lineInfo, Graphics2D g, int y) { fontMetricsInfo.setFontMetrics(painter.getFontMetrics()); Stroke gStroke=g.getStroke(); @@ -261,5 +217,5 @@ } } return null; -}*/ + }*/ } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |