示例#1
0
 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;
 }
示例#2
0
 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;
 }
示例#3
0
 @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()]));
 }
示例#4
0
 @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()]));
 }
示例#5
0
 private void onNewHotPointY(boolean briefIntroduction) {
   if (hotPointY <= 0) {
     hotPointX = 0;
     luwrain.hint(Hints.EMPTY_LINE);
     luwrain.onAreaNewHotPoint(this);
     return;
   }
   final Object item = items[hotPointY - 1];
   luwrain.playSound(Sounds.NEW_LIST_ITEM);
   if (item == null) {
     hotPointX = 0;
     luwrain.hint(Hints.EMPTY_LINE);
   } else {
     hotPointX = getInitialHotPointX(item);
     appearance.introduceItem(item, briefIntroduction ? ListItemAppearance.BRIEF : 0);
   }
   luwrain.onAreaNewHotPoint(this);
 }
示例#6
0
 @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) : "";
 }
示例#7
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();
 }