本文整理汇总了Java中jline.console.history.MemoryHistory类的典型用法代码示例。如果您正苦于以下问题:Java MemoryHistory类的具体用法?Java MemoryHistory怎么用?Java MemoryHistory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MemoryHistory类属于jline.console.history包,在下文中一共展示了MemoryHistory类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getJLineHistory
import jline.console.history.MemoryHistory; //导入依赖的package包/类
/**
* Load the History from disk if a $HOME directory is defined, otherwise fall back to using an in-memory history object
*
* @return
* @throws IOException
*/
protected History getJLineHistory() throws IOException {
String home = System.getProperty("HOME");
if (null == home) {
home = System.getenv("HOME");
}
// Get the home directory
File homeDir = new File(home);
// Make sure it actually exists
if (homeDir.exists() && homeDir.isDirectory()) {
// Check for, and create if necessary, the directory for cosmos to use
File historyDir = new File(homeDir, ".cosmos");
if (!historyDir.exists() && !historyDir.mkdirs()) {
log.warn("Could not create directory for history at {}, using temporary history.", historyDir);
}
// Get a file for jline history
File historyFile = new File(historyDir, "history");
return new FileHistory(historyFile);
} else {
log.warn("Home directory not found: {}, using temporary history", homeDir);
return new MemoryHistory();
}
}
示例2: getCommandHistory
import jline.console.history.MemoryHistory; //导入依赖的package包/类
/**Read the asciigenome history file and put it a list as current history. Or
* return empty history file does not exist or can't be read.
* */
public History getCommandHistory(){
History cmdHistory= new MemoryHistory();
for(String x : this.getCommands()){
cmdHistory.add(x);
}
return cmdHistory;
}
示例3: testHistory
import jline.console.history.MemoryHistory; //导入依赖的package包/类
@Test
public void testHistory() throws IOException{
ConsoleReader console= new ConsoleReader();
//History history= new History(new File(System.getProperty("user.home") + File.separator + ".asciigenome_history"));
History history= new MemoryHistory();
history.add("foobar");
history.add("baz");
console.setHistory(history);
System.out.println(console.getHistory());
}
示例4: applyHistory
import jline.console.history.MemoryHistory; //导入依赖的package包/类
private void applyHistory() throws IOException {
console.setHistory(new MemoryHistory());
requestHistory();
Message response = connector.receive();
if(response instanceof HistoryResponse){
HistoryResponse historyResponse = (HistoryResponse)response;
for(String line : historyResponse.getHistoryLines()){
console.getHistory().add(line);
}
}else{
LOG.log(SEVERE, "The history can not be apply because the server sends an unexpected response!" + response);
}
}
示例5: Terminal
import jline.console.history.MemoryHistory; //导入依赖的package包/类
public Terminal(Configuration configuration) {
try {
this.configuration = configuration;
jline.TerminalFactory.configure("auto");
reader = new ConsoleReader();
reader.setHistory(new MemoryHistory());
reader.addCompleter(new ArgumentCompleter(selectCompleters()));
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}
示例6: EditingHistory
import jline.console.history.MemoryHistory; //导入依赖的package包/类
protected EditingHistory(Preferences prefs) {
this.prefs = prefs;
this.fullHistory = new MemoryHistory();
this.currentDelegate = fullHistory;
load();
}
示例7: FileHistorian
import jline.console.history.MemoryHistory; //导入依赖的package包/类
private FileHistorian(MemoryHistory history) {
this.history = history;
}
示例8: shellHistory
import jline.console.history.MemoryHistory; //导入依赖的package包/类
public static MemoryHistory shellHistory() {
return shellHistory;
}
示例9: disableHistory
import jline.console.history.MemoryHistory; //导入依赖的package包/类
void disableHistory() {
consoleReader.setHistory(new MemoryHistory());
consoleReader.setHistoryEnabled(false);
}