/**
* <b>Optional:</b> <i>If possible</i>, this method will return a
- * <60 char long rendering of the input region (for example, if
- * the input is a region of characters, it would be those
- * characters, possibly with ellipses in the middle to truncate
- * the length) -- otherwise, returns null.
+ * rendering of the input region (for example, if the input is a
+ * region of characters, it would be those characters) --
+ * otherwise, returns null. In any case, the string returned
+ * will be no more than <tt>maxLength</tt> characters long;
+ * typically ellipses will be inserted to perform truncation.
*/
- public abstract String showRegion(Region<Token> r);
+ public abstract String showRegion(Region<Token> r, int maxLength);
/** <font color=purple>a location (position) in the input stream -- <i>between tokens</i></font> */
public static interface Location<Token> extends Comparable<Location> {
if (i>0) { r.unread(CharAtom.left); redent(i-1); return; }
}
- public String showRegion(Region<Character> rc) {
+ public String showRegion(Region<Character> rc, int maxLength) {
if (cache == null) return null;
Cartesian.Region r = (Cartesian.Region)rc;
int start = r.getStart().getScalar()+1;
if (end < start) end = start;
if (end > cache.length()) end = cache.length();
String ret;
- if (end-start < 60) ret = cachesubstring(start, end);
- else ret = cachesubstring(start, start+25) +
+ if (end-start < maxLength) ret = cachesubstring(start, end);
+ else ret = cachesubstring(start, start+(maxLength/2-5)) +
"..." +
- cachesubstring(end-25, end);
+ cachesubstring(end-(maxLength/2-5), end);
return StringUtil.escapify(ret, "\n\r");
}
*/
public class Tib implements Input<Character> {
- public String showRegion(Region<Character> r) { return ""; }
+ public String showRegion(Region<Character> r, int max) { return ""; }
public Tib(String s) throws IOException { this(new StringReader(s)); }
public Tib(Reader r) throws IOException { this(new BufferedReader(r)); }