PageRenderTime 48ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-0-pre5/org/gjt/sp/jedit/Marker.java

#
Java | 108 lines | 40 code | 12 blank | 56 comment | 1 complexity | 389797aace03035512f08c27384b58eb MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  1. /*
  2. * Marker.java - Named location in a buffer
  3. * :tabSize=8:indentSize=8:noTabs=false:
  4. * :folding=explicit:collapseFolds=1:
  5. *
  6. * Copyright (C) 1998, 1999, 2000, 2001 Slava Pestov
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  21. */
  22. package org.gjt.sp.jedit;
  23. import javax.swing.text.Position;
  24. import org.gjt.sp.util.Log;
  25. /**
  26. * A named location in a buffer.
  27. *
  28. * @author Slava Pestov
  29. * @version $Id: Marker.java 3999 2002-01-28 11:40:33Z spestov $
  30. */
  31. public class Marker
  32. {
  33. //{{{ getShortcut() method
  34. /**
  35. * Returns the marker's shortcut.
  36. * @since jEdit 3.2pre1
  37. */
  38. public char getShortcut()
  39. {
  40. return shortcut;
  41. } //}}}
  42. //{{{ getPosition() method
  43. /**
  44. * Returns the position of this marker.
  45. * @since jEdit 3.2pre1
  46. */
  47. public int getPosition()
  48. {
  49. return (position == null ? pos : position.getOffset());
  50. } //}}}
  51. //{{{ Package-private members
  52. //{{{ Marker constructor
  53. Marker(Buffer buffer, char shortcut, int position)
  54. {
  55. this.buffer = buffer;
  56. this.shortcut = shortcut;
  57. this.pos = position;
  58. } //}}}
  59. //{{{ setShortcut() method
  60. /**
  61. * Sets the marker's shortcut.
  62. * @param shortcut The new shortcut
  63. * @since jEdit 3.2pre1
  64. */
  65. void setShortcut(char shortcut)
  66. {
  67. this.shortcut = shortcut;
  68. } //}}}
  69. //{{{ createPosition() method
  70. void createPosition()
  71. {
  72. position = buffer.createPosition(pos);
  73. } //}}}
  74. //{{{ removePosition() method
  75. void removePosition()
  76. {
  77. // forget the cached Position instance
  78. position = null;
  79. } //}}}
  80. //{{{ setPosition() method
  81. /**
  82. * Sets the position of this marker.
  83. * @since jEdit 4.0pre5
  84. */
  85. void setPosition(int pos)
  86. {
  87. this.pos = pos;
  88. } //}}}
  89. //}}}
  90. //{{{ Private members
  91. private Buffer buffer;
  92. private char shortcut;
  93. private int pos;
  94. private Position position;
  95. //}}}
  96. }