PageRenderTime 95ms CodeModel.GetById 86ms app.highlight 6ms RepoModel.GetById 2ms 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
  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
 23package org.gjt.sp.jedit;
 24
 25import javax.swing.text.Position;
 26import org.gjt.sp.util.Log;
 27
 28/**
 29 * A named location in a buffer.
 30 *
 31 * @author Slava Pestov
 32 * @version $Id: Marker.java 3999 2002-01-28 11:40:33Z spestov $
 33 */
 34public class Marker
 35{
 36	//{{{ getShortcut() method
 37	/**
 38	 * Returns the marker's shortcut.
 39	 * @since jEdit 3.2pre1
 40	 */
 41	public char getShortcut()
 42	{
 43		return shortcut;
 44	} //}}}
 45
 46	//{{{ getPosition() method
 47	/**
 48	 * Returns the position of this marker.
 49	 * @since jEdit 3.2pre1
 50	 */
 51	public int getPosition()
 52	{
 53		return (position == null ? pos : position.getOffset());
 54	} //}}}
 55
 56	//{{{ Package-private members
 57
 58	//{{{ Marker constructor
 59	Marker(Buffer buffer, char shortcut, int position)
 60	{
 61		this.buffer = buffer;
 62		this.shortcut = shortcut;
 63		this.pos = position;
 64	} //}}}
 65
 66	//{{{ setShortcut() method
 67	/**
 68	 * Sets the marker's shortcut.
 69	 * @param shortcut The new shortcut
 70	 * @since jEdit 3.2pre1
 71	 */
 72	void setShortcut(char shortcut)
 73	{
 74		this.shortcut = shortcut;
 75	} //}}}
 76
 77	//{{{ createPosition() method
 78	void createPosition()
 79	{
 80		position = buffer.createPosition(pos);
 81	} //}}}
 82
 83	//{{{ removePosition() method
 84	void removePosition()
 85	{
 86		// forget the cached Position instance
 87		position = null;
 88	} //}}}
 89
 90	//{{{ setPosition() method
 91	/**
 92	 * Sets the position of this marker.
 93	 * @since jEdit 4.0pre5
 94	 */
 95	void setPosition(int pos)
 96	{
 97		this.pos = pos;
 98	} //}}}
 99
100	//}}}
101
102	//{{{ Private members
103	private Buffer buffer;
104	private char shortcut;
105	private int pos;
106	private Position position;
107	//}}}
108}