public Mode(Mode parentMode, string name, string help = null, KeyMap keyMap = null) { this.parentMode = parentMode; this.name = name; this.help = help; this.keyMap = keyMap; }
public virtual bool Define([NotNull] int[] sequence, object value) { if (sequence == null) { throw new ArgumentNullException("sequence"); } var curentMap = this; var lastIndex = sequence.Length - 1; for (var i = 0; i < sequence.Length; i++) { var key = sequence[i]; var tmp = curentMap.GetLocal(key); // do not alow defaults if (tmp == null) { // there is no this binding // N.B. Do not look at the parent one! if (i == lastIndex) { // the curentMap is the target map and it does not have definition curentMap.SetLocal(key, value); return(true); } else { // the curentMap is the map in the sequence and it does not have definition var newMap = new KeyMap(); curentMap.SetLocal(key, newMap); curentMap = newMap; } } else { // we found binding in curentMap if (i == lastIndex) { // curentMap is target map, it has binding but we have to redefine it curentMap.SetLocal(key, value); } else { // the curentMap is the map in the sequence and it has definition var map = tmp.value as KeyMap; if (map != null) { curentMap = map; } else { throw new Exception(string.Format("Expect KeyMap at '{0}' found: '{1}' in: '{2}'", sequence[i], tmp, sequence)); } } } } throw new Exception("We can\'t be here"); }
/// <summary> /// Create empty keymap based on parent keymap /// </summary> /// <param name="parent"></param> /// <param name="title"></param> public KeyMap([NotNull] KeyMap parent, string title = null) { if (parent == null) { throw new ArgumentNullException("parent"); } this.title = title; this.parent = parent; items = new List <KeyMapItem>(); }
public virtual void CopyTo(KeyMap other) { other.title = title; other.title = help; other.parent = parent; foreach (var item in items) { other.SetLocal(item.key, item.value); } }
/// <summary> /// Create empty keymap based on parent keymap /// </summary> /// <param name="parent"></param> /// <param name="title"></param> public FullKeymap([NotNull] KeyMap parent, string title = null) : base(parent, title) { }
public KeyMap(KeyMap parent, string title, string help = null) : this(parent, title) { this.title = help; }
public Mode(string name, string help = null, KeyMap keyMap = null) { this.name = name; this.help = help; this.keyMap = keyMap; }
private ReadLine(Mode parentMode, string name, string help = null, KeyMap keyMap = null) : base(parentMode, name, help, keyMap) { Initialize(); }
private ReadLine(string name, string help = null, KeyMap keyMap = null) : base(name, help, keyMap) { Initialize(); }