PageRenderTime 44ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
Java | 112 lines | 44 code | 12 blank | 56 comment | 3 complexity | 0e151d257fd5a48eaa84c91e8cccc453 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 4022 2002-02-11 03:15:30Z 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. if(position != null)
  79. {
  80. pos = position.getOffset();
  81. position = null;
  82. }
  83. } //}}}
  84. //{{{ setPosition() method
  85. /**
  86. * Sets the position of this marker.
  87. * @since jEdit 4.0pre5
  88. */
  89. void setPosition(int pos)
  90. {
  91. this.pos = pos;
  92. } //}}}
  93. //}}}
  94. //{{{ Private members
  95. private Buffer buffer;
  96. private char shortcut;
  97. private int pos;
  98. private Position position;
  99. //}}}
  100. }