📄 commandhistory.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 + -