0 Star 2 Fork 1

Cadaqs/XStudio

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
ActionRecorder.xcsm 1.39 KB
一键复制 编辑 原始数据 按行查看 历史
Cadaqs 提交于 2020-09-02 03:55 . 8710
//xlang Source, Name:ActionRecorder.xcsm
//Date: Wed Nov 15:17:35 2018
class ActionRecorder{
static class Action{
public Action(String s, int pos){
source = s;
position = pos;
}
public String source;
public int position;
};
Action lastAction ;
int pointer = 0;
Vector<Action> actions = new Vector<Action>();
public void addAction(String source, int pos){
if (lastAction != nilptr && lastAction.source.equals(source) && lastAction.position == pos){
return ;
}
tripAction();
if (actions.size() >= 1000){
actions.remove(0);
}
lastAction = new Action(source, pos);
pointer = actions.size();
actions.add(lastAction);
}
public void tripAction(){
while (actions.size() > (pointer + 1)){
actions.remove( actions.size() - 1);
}
}
public void undo(){
if ((pointer > 0) && (pointer < actions.size())){
pointer--;
lastAction = actions.get(pointer);
XSourceEditor.localtion(lastAction.source, lastAction.position);
}
}
public void redo(){
if ((pointer >=0) && (pointer + 1 < actions.size())){
pointer++;
lastAction = actions.get(pointer);
XSourceEditor.localtion(lastAction.source, lastAction.position);
}
}
public void clear(){
actions.clear();
}
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/ixlang/XStudio.git
[email protected]:ixlang/XStudio.git
ixlang
XStudio
XStudio
master

搜索帮助