Changeset 8725


Ignore:
Timestamp:
03/06/05 16:30:06 (16 years ago)
Author:
piso
Message:

listKeys(): support emacs-style keymaps.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/j/src/org/armedbear/j/KeyMap.java

    r8710 r8725  
    33 *
    44 * Copyright (C) 1998-2005 Peter Graves
    5  * $Id: KeyMap.java,v 1.24 2005-03-05 04:00:47 piso Exp $
     5 * $Id: KeyMap.java,v 1.25 2005-03-06 16:30:06 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    454454        command = command.intern();
    455455        ArrayList list = new ArrayList();
     456        _listKeys(command, "", list);
     457        return list;
     458    }
     459
     460    private void _listKeys(String command, String prefix, ArrayList list)
     461    {
    456462        for (int i = mappings.size(); i-- > 0;) {
    457463            KeyMapping mapping = (KeyMapping) mappings.get(i);
    458464            if (command == mapping.getCommand())
    459465                list.add(mapping.getKeyText());
    460         }
    461         return list;
     466            if (mapping.getCommand() instanceof KeyMap) {
     467                // A submap.
     468                KeyMap submap = (KeyMap) mapping.getCommand();
     469                FastStringBuffer sb = new FastStringBuffer();
     470                if (prefix.length() > 0) {
     471                    sb.append(prefix);
     472                    sb.append(' ');
     473                }
     474                sb.append(mapping.getKeyText());
     475                sb.append(' ');
     476                submap._listKeys(command, sb.toString(), list);
     477            }
     478        }
    462479    }
    463480
Note: See TracChangeset for help on using the changeset viewer.