Changeset 221


Ignore:
Timestamp:
11/10/02 00:49:43 (20 years ago)
Author:
piso
Message:

describeKey(): look in overrides first.

File:
1 edited

Legend:

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

    r2 r221  
    33 *
    44 * Copyright (C) 2000-2002 Peter Graves
    5  * $Id: DescribeKeyDialog.java,v 1.1.1.1 2002-09-24 16:09:26 piso Exp $
     5 * $Id: DescribeKeyDialog.java,v 1.2 2002-11-10 00:49:43 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    8686        if (seenKeyPressed && !disposed) {
    8787            dispose();
    88             MessageDialog.showMessageDialog(editor, keyStrokeText + " is not mapped", title);
     88            MessageDialog.showMessageDialog(editor,
     89                keyStrokeText + " is not mapped", title);
    8990        }
    9091    }
    9192
    92     public void describeKey(char keyChar, int keyCode, int modifiers)
     93    private void describeKey(char keyChar, int keyCode, int modifiers)
    9394    {
    9495        if (disposed)
     
    9899        if (keyCode == 0 && modifiers == InputEvent.SHIFT_MASK) // Shift only.
    99100            modifiers = 0; // Ignore modifier.
     101        KeyMapping mapping = null;
    100102        boolean local = false;
    101         KeyMapping mapping = buffer.getKeyMapForMode().lookup(keyChar, keyCode, modifiers);
     103        final Mode mode = buffer.getMode();
     104        // Look in user's mode-specific overrides (if any).
     105        KeyMap km = mode.getOverrides();
     106        if (km != null)
     107            mapping = km.lookup(keyChar, keyCode, modifiers);
     108        if (mapping == null)
     109            mapping = mode.getKeyMap().lookup(keyChar, keyCode, modifiers);
    102110        if (mapping != null)
    103111            local = true;
    104         else
    105             mapping = KeyMap.getGlobalKeyMap().lookup(keyChar, keyCode, modifiers);
    106         FastStringBuffer sb = new FastStringBuffer(128);
     112        else {
     113            // Look in user's global overrides (if any).
     114            km = KeyMap.getGlobalOverrides();
     115            if (km != null)
     116                mapping = km.lookup(keyChar, keyCode, modifiers);
     117            if (mapping == null)
     118                mapping = KeyMap.getGlobalKeyMap().lookup(keyChar, keyCode, modifiers);
     119        }
     120        FastStringBuffer sb = new FastStringBuffer();
    107121        if (mapping != null) {
    108122            sb.append(mapping.getKeyText());
Note: See TracChangeset for help on using the changeset viewer.