/ime/aimelib/src/com/google/android/marvin/aime/TextNavigation.java

http://eyes-free.googlecode.com/ · Java · 86 lines · 14 code · 12 blank · 60 comment · 0 complexity · 17af8ba1b410470656740059e23096d4 MD5 · raw file

  1. /*
  2. * Copyright (C) 2010 The Android Open Source Project
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.google.android.marvin.aime;
  17. /**
  18. * This interface allows to navigate through text by character, word, sentence and paragraph.
  19. *
  20. * @author hiteshk@google.com (Hitesh Khandelwal)
  21. */
  22. public interface TextNavigation {
  23. /** Flag to indicate moving cursor. */
  24. public static final int ACTION_MOVE = 0;
  25. /** Flag to indicate extending selection. */
  26. public static final int ACTION_EXTEND = 1;
  27. /** Flag for navigating by character. */
  28. public static final int GRANULARITY_CHAR = 0;
  29. /** Flag for navigating by word. */
  30. public static final int GRANULARITY_WORD = 1;
  31. /** Flag for navigating by sentence. */
  32. public static final int GRANULARITY_SENTENCE = 2;
  33. /** Flag for navigating by paragraph (hard line breaks). */
  34. public static final int GRANULARITY_PARAGRAPH = 3;
  35. /** Flag for entire content. */
  36. public static final int GRANULARITY_ENTIRE_TEXT = 4;
  37. /** Number of granularity types. */
  38. public static final int NUM_GRANULARITY_TYPES = 5;
  39. /**
  40. * Move cursor or extend selection to the beginning of next unit.
  41. *
  42. * @param granularity Granularity for navigation. Value could be {@link #GRANULARITY_CHAR},
  43. * {@link #GRANULARITY_WORD}, {@link #GRANULARITY_SENTENCE},
  44. * {@link #GRANULARITY_PARAGRAPH} or {@link #GRANULARITY_ENTIRE_TEXT}
  45. * @param action Set action need to be performed on Selection. Value could be either
  46. * {@link #ACTION_MOVE} or{@link #ACTION_EXTEND}.
  47. * @return Start and end positions of the unit. Returns null if <code>granularity</code> or
  48. * <code>action</code> is invalid.
  49. */
  50. public Position next(int granularity, int action);
  51. /**
  52. * Move cursor or extend selection to the beginning of previous unit.
  53. *
  54. * @param granularity Granularity for navigation. Value could be {@link #GRANULARITY_CHAR},
  55. * {@link #GRANULARITY_WORD}, {@link #GRANULARITY_SENTENCE},
  56. * {@link #GRANULARITY_PARAGRAPH} or {@link #GRANULARITY_ENTIRE_TEXT}
  57. * @param action Set action need to be performed on Selection. Value could be either
  58. * {@link #ACTION_MOVE} or{@link #ACTION_EXTEND}.
  59. * @return Start and end positions of the unit. Returns null if <code>granularity</code> or
  60. * <code>action</code> is invalid.
  61. */
  62. public Position previous(int granularity, int action);
  63. /**
  64. * Get current text unit, pointed by cursor position. For character as granularity, current
  65. * character is the character on the right of cursor position.
  66. *
  67. * @param granularity Granularity for navigation. Value could be {@link #GRANULARITY_CHAR},
  68. * {@link #GRANULARITY_WORD}, {@link #GRANULARITY_SENTENCE},
  69. * {@link #GRANULARITY_PARAGRAPH} or {@link #GRANULARITY_ENTIRE_TEXT}
  70. * @return Start and end positions of the unit. Returns null if <code>granularity</code> or
  71. * <code>action</code> is invalid, or text is in selection mode.
  72. */
  73. public Position get(int granularity);
  74. }