private boolean onAltEnd(KeyboardEvent event) { if (noContentCheck()) return true; if (hotPointY <= 0 || hotPointY > items.length || items[hotPointY - 1] == null) { luwrain.hint(Hints.EMPTY_LINE); return true; } final Object item = items[hotPointY - 1]; final String line = appearance.getScreenAppearance(item, 0); int leftBound = appearance.getObservableLeftBound(item); if (leftBound < 0) leftBound = 0; if (leftBound > line.length()) leftBound = line.length(); int rightBound = appearance.getObservableRightBound(item); if (rightBound < 0) rightBound = 0; if (rightBound >= line.length()) rightBound = line.length(); if (leftBound >= rightBound) { luwrain.hint(Hints.EMPTY_LINE); return true; } if (hotPointX <= leftBound) { luwrain.hint(Hints.BEGIN_OF_LINE); return true; } hotPointX = rightBound; luwrain.hint(Hints.END_OF_LINE); luwrain.onAreaNewHotPoint(this); return true; }
private boolean onAltLeft(KeyboardEvent event) { if (noContentCheck()) return true; if (hotPointY <= 0 || hotPointY > items.length || items[hotPointY - 1] == null) { luwrain.hint(Hints.EMPTY_LINE); return true; } final Object item = items[hotPointY - 1]; final String line = appearance.getScreenAppearance(item, 0); int leftBound = appearance.getObservableLeftBound(item); if (leftBound < 0) leftBound = 0; if (leftBound > line.length()) leftBound = line.length(); int rightBound = appearance.getObservableRightBound(item); if (rightBound < 0) rightBound = 0; if (rightBound >= line.length()) rightBound = line.length(); if (leftBound >= rightBound) { luwrain.hint(Hints.EMPTY_LINE); return true; } if (hotPointX <= leftBound) { luwrain.hint(Hints.BEGIN_OF_LINE); return true; } final String subline = line.substring(leftBound, rightBound); WordIterator it = new WordIterator(subline, hotPointX - leftBound); if (!it.stepBackward()) { luwrain.hint(Hints.BEGIN_OF_LINE); return true; } hotPointX = it.pos() + leftBound; luwrain.say(it.announce()); luwrain.onAreaNewHotPoint(this); return true; }
@Override public RegionContent getWholeRegion() { if (model == null || model.getItemCount() == 0) return null; final LinkedList<String> res = new LinkedList<String>(); final int count = model.getItemCount(); for (int i = 0; i < count; ++i) { final String line = appearance.getScreenAppearance(model.getItem(i), ListItemAppearance.FOR_CLIPBOARD); res.add(line != null ? line : ""); } res.add(""); return new RegionContent(res.toArray(new String[res.size()])); }
@Override public RegionContent getRegion(int fromX, int fromY, int toX, int toY) { if (model == null || model.getItemCount() == 0) return null; if (fromY >= model.getItemCount() || toY >= model.getItemCount()) return null; if (fromY == toY) { final String line = appearance.getScreenAppearance( model.getItem(fromY - 1), ListItemAppearance.FOR_CLIPBOARD); if (line.isEmpty()) return null; final int fromPos = fromX < line.length() ? fromX : line.length(); final int toPos = toX < line.length() ? toX : line.length(); if (fromPos >= toPos) return null; return new RegionContent(new String[] {line.substring(fromPos, toPos)}); } final LinkedList<String> res = new LinkedList<String>(); for (int i = fromY; i <= toY; ++i) { if (i == 0) continue; final String line = appearance.getScreenAppearance(model.getItem(i - 1), ListItemAppearance.FOR_CLIPBOARD); res.add(line != null ? line : ""); } res.add(""); return new RegionContent(res.toArray(new String[res.size()])); }
@Override public String getLine(int index) { if (items == null || index <= 0 || index > items.length) return ""; final Object item = items[index - 1]; return item != null ? appearance.getScreenAppearance(item, 0) : ""; }
private int getInitialHotPointX(Object item) { if (item == null) return 0; final String line = appearance.getScreenAppearance(item, 0); final int leftBound = appearance.getObservableLeftBound(item); return leftBound < line.length() ? leftBound : line.length(); }