Changeset 8729


Ignore:
Timestamp:
03/06/05 19:35:20 (16 years ago)
Author:
piso
Message:

handleJEvent(): when both the global and local definitions of a key are other
keymaps, the next character is looked up in both keymaps, with the local
definition overriding the global one.

File:
1 edited

Legend:

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

    r8722 r8729  
    33 *
    44 * Copyright (C) 1998-2005 Peter Graves
    5  * $Id: Editor.java,v 1.144 2005-03-06 16:26:15 piso Exp $
     5 * $Id: Editor.java,v 1.145 2005-03-06 19:35:20 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    24612461
    24622462    private KeyMap requestedKeyMap;
    2463 
    24642463    private EventSequence currentEventSequence;
     2464    private boolean local;
    24652465
    24662466    public boolean handleJEvent(JEvent event)
     
    24742474            return true;
    24752475        }
     2476
     2477        KeyMapping mapping = null;
    24762478        if (requestedKeyMap != null) {
    24772479            if (checkKeyboardQuit(event)) {
    24782480                requestedKeyMap = null;
    24792481                currentEventSequence = null;
     2482                local = false;
    24802483                status("");
    24812484                return false;
    24822485            }
    2483         }
    2484         KeyMapping mapping = getKeyMapping(keyChar, keyCode, modifiers);
     2486            mapping = requestedKeyMap.lookup(keyChar, keyCode, modifiers);
     2487            // "When both the global and local definitions of a key are other
     2488            // keymaps, the next character is looked up in both keymaps, with
     2489            // the local definition overriding the global one. The character
     2490            // after the `C-x' is looked up in both the major mode's own keymap
     2491            // for redefined `C-x' commands and in `ctl-x-map'. If the major
     2492            // mode's own keymap for `C-x' commands contains `nil', the
     2493            // definition from the global keymap for `C-x' commands is used."
     2494            // (from the documentation for xemacs 21.4.17)
     2495            if (mapping == null && local) {
     2496                // Not found in local keymap.
     2497                EventSequence copy = currentEventSequence.copy();
     2498                copy.addEvent(event);
     2499                mapping = KeyMap.getGlobalKeyMap().lookupEventSequence(copy);
     2500            }
     2501        } else {
     2502            // Look in mode-specific key map.
     2503            mapping =
     2504                buffer.getMode().getKeyMap().lookup(keyChar, keyCode, modifiers);
     2505            if (mapping != null)
     2506                local = true;
     2507            else
     2508                // Look in global key map.
     2509                mapping = KeyMap.getGlobalKeyMap().lookup(keyChar, keyCode,
     2510                                                          modifiers);
     2511        }
     2512
    24852513        if (mapping == null) {
    24862514            if (event.getID() == JEvent.KEY_TYPED) {
     
    24882516                requestedKeyMap = null;
    24892517                currentEventSequence = null;
     2518                local = false;
    24902519            }
    24912520            return false;
     
    24982527                    currentEventSequence = new EventSequence();
    24992528                currentEventSequence.addEvent(event);
    2500                 Log.debug(String.valueOf(currentEventSequence));
    25012529                requestedKeyMap = (KeyMap) command;
    25022530                status(currentEventSequence.getStatusText() + "-");
     
    25102538                requestedKeyMap = null;
    25112539                currentEventSequence = null;
     2540                local = false;
    25122541                String commandString = (String) command;
    25132542                if (commandString.length() > 0 && commandString.charAt(0) == '(') {
     
    25282557                requestedKeyMap = null;
    25292558                currentEventSequence = null;
     2559                local = false;
    25302560                try {
    25312561                    LispThread.currentThread().execute(Lisp.coerceToFunction((LispObject)command));
     
    25422572    public KeyMapping getKeyMapping(char keyChar, int keyCode, int modifiers)
    25432573    {
    2544         if (requestedKeyMap != null) {
    2545             KeyMapping mapping =
    2546                 requestedKeyMap.lookup(keyChar, keyCode, modifiers);
    2547             // FIXME From the xemacs 21.4.17 documentation:
    2548             // "When both the global and local definitions of a key are other
    2549             // keymaps, the next character is looked up in both keymaps, with
    2550             // the local definition overriding the global one. The character
    2551             // after the `C-x' is looked up in both the major mode's own keymap
    2552             // for redefined `C-x' commands and in `ctl-x-map'. If the major
    2553             // mode's own keymap for `C-x' commands contains `nil', the
    2554             // definition from the global keymap for `C-x' commands is used."
    2555             return mapping;
    2556         }
     2574        if (requestedKeyMap != null)
     2575            return requestedKeyMap.lookup(keyChar, keyCode, modifiers);
    25572576        // Look in mode-specific key map.
    25582577        KeyMapping mapping =
Note: See TracChangeset for help on using the changeset viewer.