*/
public class Word {
+ // ------------------------------------------------------------------------
+ // Variables --------------------------------------------------------------
+ // ------------------------------------------------------------------------
+
/**
* The color to render this word as on screen.
*/
*/
private StringBuilder text = new StringBuilder(3);
+ // ------------------------------------------------------------------------
+ // Constructors -----------------------------------------------------------
+ // ------------------------------------------------------------------------
+
+ /**
+ * Construct a word with one character.
+ *
+ * @param ch the first character of the word
+ * @param defaultColor the color for unhighlighted text
+ * @param highlighter the highlighter to use
+ */
+ public Word(final char ch, final CellAttributes defaultColor,
+ final Highlighter highlighter) {
+
+ this.defaultColor = defaultColor;
+ this.highlighter = highlighter;
+ text.append(ch);
+ }
+
+ /**
+ * Construct a word with an empty string.
+ *
+ * @param defaultColor the color for unhighlighted text
+ * @param highlighter the highlighter to use
+ */
+ public Word(final CellAttributes defaultColor,
+ final Highlighter highlighter) {
+
+ this.defaultColor = defaultColor;
+ this.highlighter = highlighter;
+ }
+
+ // ------------------------------------------------------------------------
+ // Word -------------------------------------------------------------------
+ // ------------------------------------------------------------------------
+
/**
* Get the color used to display this word on screen.
*
return false;
}
- /**
- * Construct a word with one character.
- *
- * @param ch the first character of the word
- * @param defaultColor the color for unhighlighted text
- * @param highlighter the highlighter to use
- */
- public Word(final char ch, final CellAttributes defaultColor,
- final Highlighter highlighter) {
-
- this.defaultColor = defaultColor;
- this.highlighter = highlighter;
- text.append(ch);
- }
-
- /**
- * Construct a word with an empty string.
- *
- * @param defaultColor the color for unhighlighted text
- * @param highlighter the highlighter to use
- */
- public Word(final CellAttributes defaultColor,
- final Highlighter highlighter) {
-
- this.defaultColor = defaultColor;
- this.highlighter = highlighter;
- }
-
/**
* Perform highlighting.
*/
* Add a character to this word. If this is a whitespace character
* adding to a non-whitespace word, create a new word and return that;
* similarly if this a non-whitespace character adding to a whitespace
- * word, create a new word and return that.
+ * word, create a new word and return that. Note package private access:
+ * this is only called by Line to figure out highlighting boundaries.
*
* @param ch the new character to add
* @return either this word (if it was added), or a new word that