本文整理汇总了Java中org.jline.keymap.KeyMap类的典型用法代码示例。如果您正苦于以下问题:Java KeyMap类的具体用法?Java KeyMap怎么用?Java KeyMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
KeyMap类属于org.jline.keymap包,在下文中一共展示了KeyMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: AddressField
import org.jline.keymap.KeyMap; //导入依赖的package包/类
public AddressField(KeyMap<Runnable> keyMap, Terminal terminal) {
addressBuffer = new StringBuffer();
for (char i = '0'; i <= '9'; i++) {
keyMap.bind(insertAddressChar(i), Character.toString(i));
}
for (char i = 'A'; i <= 'F'; i++) {
keyMap.bind(insertAddressChar(Character.toLowerCase(i)), Character.toString(i));
}
for (char i = 'a'; i <= 'f'; i++) {
keyMap.bind(insertAddressChar(i), Character.toString(i));
}
keyMap.bind(insertAddressChar(DEL), KeyMap.key(terminal, InfoCmp.Capability.key_dc));
// this should be KeyMap.key(debugger.getTerminal(), InfoCmp.Capability.key_backspace) but jline does not support it
keyMap.bind(insertAddressChar('\b'), "\177");
keyMap.bind(this::moveCursorRight, KeyMap.key(terminal, InfoCmp.Capability.key_right));
keyMap.bind(this::moveCursorLeft, KeyMap.key(terminal, InfoCmp.Capability.key_left));
}
示例2: Breakpoints
import org.jline.keymap.KeyMap; //导入依赖的package包/类
public Breakpoints(Debugger debugger) {
this.debugger = debugger;
this.state = State.Idle;
execBreakpoints = new ArrayList<>();
memBreakpoints = new ArrayList<>();
execBreakpointsTable = new ExecBreakpointsTable(debugger.getTerminal());
memBreakpointsTable = new MemBreakpointsTable(debugger.getTerminal());
selectedTable = execBreakpointsTable;
selectedTable.setActive(true);
addIdleKeyBindings(execBreakpointsTable.getKeyMap());
addIdleKeyBindings(memBreakpointsTable.getKeyMap());
addTableKeyBindings(execBreakpointsTable, execBreakpoints, debugger.getTerminal());
addTableKeyBindings(memBreakpointsTable, memBreakpoints, debugger.getTerminal());
addingKeyMap = new KeyMap<>();
addingKeyMap.bind(this::finishAddBreakpoint, "\r");
addingKeyMap.bind(this::abortAddBreakpoint, "q");
addingKeyMap.bind(() -> this.addingExec = !this.addingExec, "x");
addingKeyMap.bind(() -> this.addingRead = !this.addingRead, "r");
addingKeyMap.bind(() -> this.addingWrite = !this.addingWrite, "w");
addressField = new AddressField(addingKeyMap, debugger.getTerminal());
verticalBoxes = new VerticalBoxes("Breakpoints", execBreakpointsTable, memBreakpointsTable);
}
示例3: initKeyMap
import org.jline.keymap.KeyMap; //导入依赖的package包/类
private KeyMap<Runnable> initKeyMap() {
KeyMap<Runnable> keyMap = new KeyMap<>();
for (int i = 0; i < views.size(); i++) {
int idx = i;
Runnable r = () -> {
currentViewIndex = idx;
};
keyMap.bind(r, KeyMap.ctrl(views.get(i).getAccelerator()));
}
keyMap.bind(() -> {
this.virtualBoy.halt();
if (this.state != State.Running) {
this.state = State.Halted;
}
}, "q");
keyMap.setAmbiguousTimeout(10);
return keyMap;
}
示例4: addTableKeyBindings
import org.jline.keymap.KeyMap; //导入依赖的package包/类
private void addTableKeyBindings(Table table, List<? extends Breakpoint> list, Terminal terminal) {
table.bind((index) -> {
if (index < list.size()) {
list.remove(index);
}
}, KeyMap.key(terminal, InfoCmp.Capability.key_dc));
table.bind(i -> {
if (i < list.size()) {
Breakpoint breakpoint = list.get(i);
breakpoint.setEnabled(!breakpoint.isEnabled());
}
}, "e");
}
示例5: addIdleKeyBindings
import org.jline.keymap.KeyMap; //导入依赖的package包/类
private void addIdleKeyBindings(KeyMap<Runnable> keyMap) {
keyMap.bind(this::startAddBreakpoint, "a");
keyMap.bind(() -> {
selectedTable = execBreakpointsTable;
selectedTable.setActive(true);
memBreakpointsTable.setActive(false);
}, KeyMap.key(debugger.getTerminal(), InfoCmp.Capability.key_ppage));
keyMap.bind(() -> {
selectedTable = memBreakpointsTable;
selectedTable.setActive(true);
execBreakpointsTable.setActive(false);
}, KeyMap.key(debugger.getTerminal(), InfoCmp.Capability.key_npage));
}
示例6: getKeyMap
import org.jline.keymap.KeyMap; //导入依赖的package包/类
@Override
public KeyMap<Runnable> getKeyMap() {
switch (state) {
case Idle:
return selectedTable.getKeyMap();
case Adding:
return addingKeyMap;
default:
throw new RuntimeException("Should not reach here");
}
}
示例7: getKeyMap
import org.jline.keymap.KeyMap; //导入依赖的package包/类
@Override
public KeyMap<Runnable> getKeyMap() {
switch (state) {
case Default:
return logBox.getKeyMap();
case Settings:
return settingsKeyMap;
}
return null;
}
示例8: LogBox
import org.jline.keymap.KeyMap; //导入依赖的package包/类
public LogBox(List<LogMessage> messages, Terminal terminal, Map<Component, Level> levels) {
this.messages = messages;
this.levels = levels;
keyMap = new KeyMap<>();
keyMap.bind(() -> {
if (selectedLine + 1 < messages.size()) {
this.selectedLine++;
}
}, KeyMap.key(terminal, InfoCmp.Capability.key_down));
keyMap.bind(() -> {
if (selectedLine > 0) {
this.selectedLine--;
}
scrolling = false;
}, KeyMap.key(terminal, InfoCmp.Capability.key_up));
keyMap.bind(() -> {
selectedLine = max(0, selectedLine - lastHeight);
scrolling = false;
}, KeyMap.key(terminal, InfoCmp.Capability.key_ppage));
keyMap.bind(() -> {
selectedLine = min(max(0, messages.size() - 1), selectedLine + lastHeight);
}, KeyMap.key(terminal, InfoCmp.Capability.key_npage));
keyMap.bind(() -> {
scrolling = true;
}, KeyMap.key(terminal, InfoCmp.Capability.key_end));
keyMap.bind(() -> {
selectedLine = 0;
scrolling = false;
}, KeyMap.key(terminal, InfoCmp.Capability.key_home));
}
示例9: CPUView
import org.jline.keymap.KeyMap; //导入依赖的package包/类
public CPUView(Debugger debugger) {
this.debugger = debugger;
runningKeyMap = new KeyMap<>();
pausedKeyMap = new KeyMap<>();
runningKeyMap.bind(debugger::pause, "p");
pausedKeyMap.bind(debugger::continueExecution, "c");
pausedKeyMap.bind(debugger::step, "s");
disassemblyBox = new DisassemblyBox();
horizontalBoxes = new HorizontalBoxes("CPU", new VerticalBoxes("Instructions", new TraceBox(), disassemblyBox), new RegistersBox());
}
示例10: getKeyMap
import org.jline.keymap.KeyMap; //导入依赖的package包/类
@Override
public KeyMap<Runnable> getKeyMap() {
switch (debugger.getState()) {
case Running:
return runningKeyMap;
case Stepping:
case Paused:
return pausedKeyMap;
default:
return null;
}
}
示例11: Table
import org.jline.keymap.KeyMap; //导入依赖的package包/类
protected Table(String name, List<Column> columns, Terminal terminal) {
this.columns = columns;
this.minWidth = columns.stream().mapToInt(Column::minWidth).sum() + max(0, columns.size() - 1);
this.name = name;
keyMap = new KeyMap<>();
if (terminal != null) {
keyMap.bind(() -> this.selectedRow++, KeyMap.key(terminal, InfoCmp.Capability.key_down));
keyMap.bind(() -> {
if (selectedRow > 0) {
this.selectedRow--;
}
}, KeyMap.key(terminal, InfoCmp.Capability.key_up));
}
}
示例12: MemoryView
import org.jline.keymap.KeyMap; //导入依赖的package包/类
public MemoryView(Debugger debugger) {
this.debugger = debugger;
state = State.Idle;
memoryBox = new MemoryBox();
verticalBoxes = new VerticalBoxes("Memory", memoryBox);
Terminal terminal = debugger.getTerminal();
keyMap = new KeyMap<>();
keyMap.bind(() -> {
if (compareUnsigned(startAddress, memoryBox.height * 16) < 0) {
startAddress = 0;
} else {
startAddress -= memoryBox.height * 16;
}
}, KeyMap.key(terminal, InfoCmp.Capability.key_ppage));
keyMap.bind(() -> {
if (compareUnsigned(startAddress, -memoryBox.height * 16 * 2) > 0) {
startAddress = -memoryBox.height * 16;
} else {
startAddress += memoryBox.height * 16;
}
}, KeyMap.key(terminal, InfoCmp.Capability.key_npage));
keyMap.bind(() -> {
startAddress = -memoryBox.height * 16;
}, KeyMap.key(terminal, InfoCmp.Capability.key_end));
keyMap.bind(() -> {
startAddress = 0;
}, KeyMap.key(terminal, InfoCmp.Capability.key_home));
keyMap.bind(this::startGoto, "g");
gotoKeyMap = new KeyMap<>();
gotoKeyMap.bind(this::finishGoto, "\r");
gotoKeyMap.bind(this::abortGoto, "q");
addressField = new Breakpoints.AddressField(gotoKeyMap, debugger.getTerminal());
}
示例13: getKeyMap
import org.jline.keymap.KeyMap; //导入依赖的package包/类
@Override
public KeyMap<Runnable> getKeyMap() {
switch (state) {
case Idle:
return keyMap;
case Goto:
return gotoKeyMap;
default:
throw new RuntimeException("Should not reach here");
}
}
示例14: getKeyMap
import org.jline.keymap.KeyMap; //导入依赖的package包/类
@Override
public KeyMap<Runnable> getKeyMap() {
return null;
}
示例15: getKeyMap
import org.jline.keymap.KeyMap; //导入依赖的package包/类
@Override
public KeyMap<Runnable> getKeyMap() {
return windowAttributesTable.getKeyMap();
}