[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jedit-cvs
Subject:    [ jEdit-commits ] SF.net SVN: jedit: [8271]
From:       kpouer () users ! sourceforge ! net
Date:       2006-12-28 8:05:52
Message-ID: E1GzqGu-00055O-81 () sc8-pr-svn4 ! sourceforge ! net
[Download RAW message or body]

Revision: 8271
          http://svn.sourceforge.net/jedit/?rev=8271&view=rev
Author:   kpouer
Date:     2006-12-28 00:05:51 -0800 (Thu, 28 Dec 2006)

Log Message:
-----------
some minor changes and comments added

Modified Paths:
--------------
    jEdit/trunk/org/gjt/sp/jedit/textarea/ChunkCache.java

Modified: jEdit/trunk/org/gjt/sp/jedit/textarea/ChunkCache.java
===================================================================
--- jEdit/trunk/org/gjt/sp/jedit/textarea/ChunkCache.java	2006-12-27 22:58:41 UTC \
                (rev 8270)
+++ jEdit/trunk/org/gjt/sp/jedit/textarea/ChunkCache.java	2006-12-28 08:05:51 UTC \
(rev 8271) @@ -81,59 +81,60 @@
 			return -1;
 		if(line < textArea.getFirstPhysicalLine())
 			return -1;
-		else if(line == textArea.getFirstPhysicalLine()
+		if(line == textArea.getFirstPhysicalLine()
 			&& offset < getLineInfo(0).offset)
 			return -1;
-		else if(line > textArea.getLastPhysicalLine())
+		if(line > textArea.getLastPhysicalLine())
 			return -1;
-		else
+		
+		if(line == lastScreenLineP)
 		{
-			if(line == lastScreenLineP)
-			{
-				LineInfo last = getLineInfo(lastScreenLine);
+			LineInfo last = getLineInfo(lastScreenLine);
 
-				if(offset >= last.offset
-					&& offset < last.offset + last.length) {
-					return lastScreenLine;
-				}
+			if(offset >= last.offset
+				&& offset < last.offset + last.length) {
+				return lastScreenLine;
 			}
+		}
 
-			int screenLine = -1;
+		int screenLine = -1;
 
-			// Find the screen line containing this offset
-			for(int i = 0; i < textArea.getVisibleLines(); i++)
+		// Find the screen line containing this offset
+		for(int i = 0; i < textArea.getVisibleLines(); i++)
+		{
+			LineInfo info = getLineInfo(i);
+			if(info.physicalLine > line)
 			{
-				LineInfo info = getLineInfo(i);
-				if(info.physicalLine > line)
+				// line is invisible?
+				return i - 1;
+				//return -1;
+			}
+			if(info.physicalLine == line)
+			{
+				if(offset >= info.offset
+					&& offset < info.offset + info.length)
 				{
-					// line is invisible?
-					return i - 1;
-					//return -1;
+					screenLine = i;
+					break;
 				}
-				else if(info.physicalLine == line)
-				{
-					if(offset >= info.offset
-						&& offset < info.offset + info.length)
-					{
-						screenLine = i;
-						break;
-					}
-				}
 			}
+		}
 
-			if(screenLine == -1)
-				return -1;
-			else
-			{
-				lastScreenLineP = line;
-				lastScreenLine = screenLine;
+		if(screenLine == -1)
+			return -1;
 
-				return screenLine;
-			}
-		}
+
+		lastScreenLineP = line;
+		lastScreenLine = screenLine;
+
+		return screenLine;
 	} //}}}
 
 	//{{{ recalculateVisibleLines() method
+	/**
+	 * Recalculate visible lines.
+	 * This is called when the TextArea geometry is changed or when the font is \
changed. +	 */
 	void recalculateVisibleLines()
 	{
 		LineInfo[] newLineInfo = new LineInfo[textArea.getVisibleLines()];
@@ -276,8 +277,14 @@
 	/**
 	 * Returns the subregion containing the specified offset. A subregion
 	 * is a subset of a physical line. Each screen line corresponds to one
-	 * subregion. Unlike the {@link #getScreenLineOfOffset()} method,
+	 * subregion. Unlike the {@link #getScreenLineOfOffset(int, int)} method,
 	 * this method works with non-visible lines too.
+	 *
+	 * @param offset the offset
+	 * @param lineInfos a lineInfos array. Usualy the array is the result of
+	 *	{@link #getLineInfosForPhysicalLine(int)} call
+	 *
+	 * @return the subregion of the offset, or -1 if the offset was not in one of the \
                given lineInfos
 	 */
 	static int getSubregionOfOffset(int offset, LineInfo[] lineInfos)
 	{
@@ -489,18 +496,24 @@
 	//{{{ Private members
 
 	//{{{ Instance variables
-	private TextArea textArea;
+	private final TextArea textArea;
 	private JEditBuffer buffer;
+	/**
+	 * The lineInfo array. There is LineInfo for each line that is visible in the \
textArea. +	 * it can be resized by {@link #recalculateVisibleLines()}.
+	 * The content is valid from 0 to {@link #firstInvalidLine}
+	 */
 	private LineInfo[] lineInfo;
 	private final List<Chunk> out;
 
+	/** The first invalid line. All lines before this one are valid. */
 	private int firstInvalidLine;
 	private int lastScreenLineP;
 	private int lastScreenLine;
 
 	private boolean needFullRepaint;
 
-	private DisplayTokenHandler tokenHandler;
+	private final DisplayTokenHandler tokenHandler;
 	//}}}
 
 	//{{{ getLineInfosForPhysicalLine() method
@@ -690,8 +703,7 @@
 								out.remove(0);
 						}
 					}
-					chunks = (Chunk)out.get(0);
-					out.remove(0);
+					chunks = out.remove(0);
 					offset = chunks.offset;
 					if (!out.isEmpty())
 						length = out.get(0).offset - offset;
@@ -703,8 +715,7 @@
 			{
 				info.firstSubregion = false;
 
-				chunks = out.get(0);
-				out.remove(0);
+				chunks = out.remove(0);
 				offset = chunks.offset;
 				if (!out.isEmpty())
 					length = out.get(0).offset - offset;


This was sent by the SourceForge.net collaborative development platform, the world's \
largest Open Source development site.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
jEdit-CVS mailing list
jEdit-CVS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jedit-cvs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic