X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fteditor%2FWord.java;h=ffb11aa1a520d9b37ca76eee98f776f9509794d9;hb=a69ed767c9c07cf35cf1c5f7821fc009cfe79cd2;hp=d9b3417c8eda196f222eea813e91f6158f778ebd;hpb=e8a11f986bfe2556e450d7b8ad6ef0059b369bbc;p=nikiroo-utils.git diff --git a/src/jexer/teditor/Word.java b/src/jexer/teditor/Word.java index d9b3417..ffb11aa 100644 --- a/src/jexer/teditor/Word.java +++ b/src/jexer/teditor/Word.java @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (C) 2017 Kevin Lamonte + * Copyright (C) 2019 Kevin Lamonte * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -40,6 +40,10 @@ import jexer.bits.CellAttributes; */ public class Word { + // ------------------------------------------------------------------------ + // Variables -------------------------------------------------------------- + // ------------------------------------------------------------------------ + /** * The color to render this word as on screen. */ @@ -61,6 +65,42 @@ public class Word { */ 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. * @@ -118,34 +158,6 @@ public class Word { 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. */ @@ -165,7 +177,8 @@ public class Word { * 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