⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 commandhistory.java

📁 ErGo是一个很早的Java通用围棋服务器(IGS/NNGS)客户端程序。有全部源码和文档
💻 JAVA
字号:
package ergo.util;

// $Id: CommandHistory.java,v 1.2 1999/08/13 01:20:42 sigue Exp $

/*
 *  Copyright (C) 1999  Carl L. Gay and Antranig M. Basman.
 *  See the file copyright.txt, distributed with this software,
 *  for further information.
 */

import java.util.Vector;

// Maintain a command history.  Always add new elements on the end.
public class CommandHistory {
  private Vector history = new Vector();
  private int index = -1;

  public String getCurrentElement () {
    if (history.size() == 0)
      return null;
    else
      return (String) history.elementAt(index);
  }

  public String getPreviousElement () {
    if (index < 0)
      return null;
    else
      return (String) history.elementAt(index--);
  }

  public String getNextElement () {
    if (index >= history.size() - 1)
      return null;
    else
      return (String) history.elementAt(++index);
  }

  public void addElement (String text) {
    String end = ((history.size() == 0)
		  ? ""
		  : (String) history.elementAt(history.size() - 1));
    if (!text.equals(end))
      history.addElement(text);
    goToEnd();
  }

  public void goToEnd () {
    index = history.size() - 1;
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -