/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
- /*
- * Marker.java - Named location in a buffer
- * :tabSize=8:indentSize=8:noTabs=false:
- * :folding=explicit:collapseFolds=1:
- *
- * Copyright (C) 1998, 1999, 2000, 2001 Slava Pestov
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
- package org.gjt.sp.jedit;
- import javax.swing.text.Position;
- import org.gjt.sp.util.Log;
- /**
- * A named location in a buffer.
- *
- * @author Slava Pestov
- * @version $Id: Marker.java 4022 2002-02-11 03:15:30Z spestov $
- */
- public class Marker
- {
- //{{{ getShortcut() method
- /**
- * Returns the marker's shortcut.
- * @since jEdit 3.2pre1
- */
- public char getShortcut()
- {
- return shortcut;
- } //}}}
- //{{{ getPosition() method
- /**
- * Returns the position of this marker.
- * @since jEdit 3.2pre1
- */
- public int getPosition()
- {
- return (position == null ? pos : position.getOffset());
- } //}}}
- //{{{ Package-private members
- //{{{ Marker constructor
- Marker(Buffer buffer, char shortcut, int position)
- {
- this.buffer = buffer;
- this.shortcut = shortcut;
- this.pos = position;
- } //}}}
- //{{{ setShortcut() method
- /**
- * Sets the marker's shortcut.
- * @param shortcut The new shortcut
- * @since jEdit 3.2pre1
- */
- void setShortcut(char shortcut)
- {
- this.shortcut = shortcut;
- } //}}}
- //{{{ createPosition() method
- void createPosition()
- {
- position = buffer.createPosition(pos);
- } //}}}
- //{{{ removePosition() method
- void removePosition()
- {
- // forget the cached Position instance
- if(position != null)
- {
- pos = position.getOffset();
- position = null;
- }
- } //}}}
- //{{{ setPosition() method
- /**
- * Sets the position of this marker.
- * @since jEdit 4.0pre5
- */
- void setPosition(int pos)
- {
- this.pos = pos;
- } //}}}
- //}}}
- //{{{ Private members
- private Buffer buffer;
- private char shortcut;
- private int pos;
- private Position position;
- //}}}
- }