Gridarta Editor
TextAreaCaret.java
Go to the documentation of this file.
1 /*
2  * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3  * Copyright (C) 2000-2023 The Gridarta Developers.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 package net.sf.gridarta.textedit.textarea;
21 
22 public class TextAreaCaret {
23 
24  private final boolean caretBlinks;
25 
26  private boolean caretVisible;
27 
28  private boolean blink = true;
29 
30  public TextAreaCaret(final boolean caretVisible, final boolean caretBlinks) {
31  this.caretVisible = caretVisible;
32  this.caretBlinks = caretBlinks;
33  }
34 
38  public boolean isCaretVisible() {
39  return (!caretBlinks || blink) && caretVisible;
40  }
41 
46  public void setCaretVisible(final boolean caretVisible) {
47  this.caretVisible = caretVisible;
48  blink = true;
49  }
50 
54  public boolean blinkCaret() {
55  if (caretBlinks) {
56  blink = !blink;
57  return true;
58  }
59  blink = true;
60  return false;
61  }
62 
63  public void setBlink(final boolean blink) {
64  this.blink = blink;
65  }
66 
67 }
net.sf.gridarta.textedit.textarea.TextAreaCaret.caretBlinks
final boolean caretBlinks
Definition: TextAreaCaret.java:24
net.sf.gridarta.textedit.textarea.TextAreaCaret.caretVisible
boolean caretVisible
Definition: TextAreaCaret.java:26
net.sf.gridarta.textedit.textarea.TextAreaCaret.blink
boolean blink
Definition: TextAreaCaret.java:28
net.sf.gridarta.textedit.textarea.TextAreaCaret.setCaretVisible
void setCaretVisible(final boolean caretVisible)
Sets if the caret should be visible.
Definition: TextAreaCaret.java:46
net.sf.gridarta.textedit.textarea.TextAreaCaret.blinkCaret
boolean blinkCaret()
Blinks the caret.
Definition: TextAreaCaret.java:54
net.sf.gridarta.textedit.textarea.TextAreaCaret.TextAreaCaret
TextAreaCaret(final boolean caretVisible, final boolean caretBlinks)
Definition: TextAreaCaret.java:30
net.sf.gridarta.textedit.textarea.TextAreaCaret
Definition: TextAreaCaret.java:22
net.sf.gridarta.textedit.textarea.TextAreaCaret.isCaretVisible
boolean isCaretVisible()
Returns true if the caret is visible, false otherwise.
Definition: TextAreaCaret.java:38
net.sf.gridarta.textedit.textarea.TextAreaCaret.setBlink
void setBlink(final boolean blink)
Definition: TextAreaCaret.java:63