public List<ShortcutInfo> getActiveShortcutInfo() {
    List<ShortcutInfo> info = new ArrayList<ShortcutInfo>();

    HashMap<Command, ShortcutInfo> infoMap = new HashMap<Command, ShortcutInfo>();
    ArrayList<KeyboardShortcut> shortcuts = new ArrayList<KeyboardShortcut>();

    // Create a ShortcutInfo for each unbound shortcut
    for (KeyboardShortcut shortcut : unboundShortcuts_) info.add(new ShortcutInfo(shortcut, null));

    // Sort the shortcuts as they were presented in Commands.cmd.xml
    for (Map.Entry<KeySequence, List<AppCommandBinding>> entry : commands_.entrySet())
      for (AppCommandBinding binding : entry.getValue()) shortcuts.add(binding.getShortcut());

    Collections.sort(
        shortcuts,
        new Comparator<KeyboardShortcut>() {
          @Override
          public int compare(KeyboardShortcut o1, KeyboardShortcut o2) {
            return o1.getOrder() - o2.getOrder();
          }
        });

    // Create a ShortcutInfo for each command (a command may have multiple
    // shortcut bindings)
    for (KeyboardShortcut shortcut : shortcuts) {
      List<AppCommandBinding> bindings = commands_.getBoundCommands(shortcut.getKeySequence());
      for (AppCommandBinding binding : bindings) {
        AppCommand command = binding.getCommand();
        int disableModes = binding.getShortcut().getDisableModes();

        // If this command is disabled for the current mode, bail
        if ((editorMode_ & disableModes) != 0) continue;

        if (infoMap.containsKey(command)) {
          infoMap.get(command).addShortcut(shortcut);
        } else {
          ShortcutInfo shortcutInfo = new ShortcutInfo(shortcut, command);
          info.add(shortcutInfo);
          infoMap.put(command, shortcutInfo);
        }

        // Only add the top-level command bound
        break;
      }
    }
    // Sort the commands back into the order in which they were created
    // (reading them out of the keyset mangles the original order)
    Collections.sort(
        info,
        new Comparator<ShortcutInfo>() {
          @Override
          public int compare(ShortcutInfo o1, ShortcutInfo o2) {
            return o1.getOrder() - o2.getOrder();
          }
        });
    return info;
  }
    public AppCommand getCommand(
        KeySequence keys, int editorMode, Map<AppCommand, Boolean> maskedCommands) {
      if (!bindings_.containsKey(keys)) return null;

      List<AppCommandBinding> commands = bindings_.get(keys);
      for (AppCommandBinding binding : commands) {
        int disableModes = binding.getShortcut().getDisableModes();
        AppCommand command = binding.getCommand();

        // If this command is masked by another command, skip it.
        if (maskedCommands != null && maskedCommands.containsKey(command)) continue;

        // Check to see whether this command is enabled for the current
        // editor mode.
        boolean enabled = command.isEnabled() && (disableModes & editorMode) == 0;

        if (enabled) return command;
      }

      return null;
    }