Changeset 112


Ignore:
Timestamp:
10/12/02 00:06:39 (21 years ago)
Author:
piso
Message:

lastCommand, thisCommand

Location:
trunk/j/src/org/armedbear/j
Files:
5 edited

Legend:

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

    r23 r112  
    33 *
    44 * Copyright (C) 1998-2002 Peter Graves
    5  * $Id: Dispatcher.java,v 1.2 2002-10-02 16:32:12 piso Exp $
     5 * $Id: Dispatcher.java,v 1.3 2002-10-12 00:06:39 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    189189        }
    190190
    191         if (editor.lastCommand == COMMAND_PASTE && editor.thisCommand != COMMAND_PASTE)
    192             if (editor.thisCommand != COMMAND_UNDO)
    193                 Editor.promoteLastPaste();
    194 
    195         editor.lastCommand = editor.thisCommand;
    196         editor.thisCommand = COMMAND_NOTHING;
     191        final int currentCommand = editor.getCurrentCommand();
     192        if (editor.getLastCommand() == COMMAND_PASTE)
     193            if (currentCommand != COMMAND_PASTE)
     194                if (currentCommand != COMMAND_UNDO)
     195                    Editor.promoteLastPaste();
     196
     197        editor.setLastCommand(currentCommand);
     198        editor.setCurrentCommand(COMMAND_NOTHING);
    197199
    198200        editor.updateSystemSelection();
  • trunk/j/src/org/armedbear/j/Display.java

    r2 r112  
    33 *
    44 * Copyright (C) 1998-2002 Peter Graves
    5  * $Id: Display.java,v 1.1.1.1 2002-09-24 16:08:37 piso Exp $
     5 * $Id: Display.java,v 1.2 2002-10-12 00:06:39 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    12231223            if (editor.getMark() == null)
    12241224                editor.addUndo(SimpleEdit.MOVE);
    1225             else if (editor.lastCommand != COMMAND_UP)
     1225            else if (editor.getLastCommand() != COMMAND_UP)
    12261226                editor.addUndo(SimpleEdit.MOVE);
    12271227        } else {
     
    12341234                if (isLineBlock)
    12351235                    return;
    1236             } else if (editor.lastCommand != COMMAND_UP)
     1236            } else if (editor.getLastCommand() != COMMAND_UP)
    12371237                editor.addUndo(SimpleEdit.MOVE);
    12381238        }
     
    12851285            if (editor.getMark() == null)
    12861286                editor.addUndo(SimpleEdit.MOVE);
    1287             else if (editor.lastCommand != COMMAND_DOWN)
     1287            else if (editor.getLastCommand() != COMMAND_DOWN)
    12881288                editor.addUndo(SimpleEdit.MOVE);
    12891289        } else {
     
    12971297                    return;
    12981298            }
    1299             else if (editor.lastCommand != COMMAND_DOWN)
    1300                 editor.addUndo(SimpleEdit.MOVE);
     1299            else {
     1300                if (editor.getLastCommand() != COMMAND_DOWN) {
     1301                    Log.debug("down calling addUndo(MOVE)");
     1302                    editor.addUndo(SimpleEdit.MOVE);
     1303                } else
     1304                    Log.debug("down lastCommand was DOWN");
     1305            }
    13011306        }
    13021307        final Line dotLine = editor.getDotLine();
  • trunk/j/src/org/armedbear/j/Editor.java

    r110 r112  
    33 *
    44 * Copyright (C) 1998-2002 Peter Graves
    5  * $Id: Editor.java,v 1.8 2002-10-11 18:32:13 piso Exp $
     5 * $Id: Editor.java,v 1.9 2002-10-12 00:06:39 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    150150
    151151    // BUG! This stuff should be factored somehow...
    152     int thisCommand = COMMAND_NOTHING;
    153     int lastCommand = COMMAND_NOTHING;
     152    private int currentCommand = COMMAND_NOTHING;
     153    private int lastCommand = COMMAND_NOTHING;
     154
     155    public final int getCurrentCommand()
     156    {
     157        return currentCommand;
     158    }
     159
     160    public final void setCurrentCommand(int command)
     161    {
     162        currentCommand = command;
     163    }
     164
     165    public final int getLastCommand()
     166    {
     167        return lastCommand;
     168    }
     169
     170    public final void setLastCommand(int command)
     171    {
     172        lastCommand = command;
     173    }
    154174
    155175    static Marker[] bookmarks = new Marker[10];
     
    24312451    public void recordMacro()
    24322452    {
    2433         if (isRecordingMacro)
     2453        if (isRecordingMacro) {
    24342454            isRecordingMacro = false;
    2435         else {
     2455            Log.debug("----- recordMacro end -----");
     2456        } else {
    24362457            if (macro != null && !macro.isEmpty())
    24372458                if (!confirm("Record Macro", "Overwrite existing keyboard macro?"))
     
    24402461            macro = new Macro();
    24412462            isRecordingMacro = true;
     2463            Log.debug("----- recordMacro -----");
    24422464        }
    24432465    }
     
    24702492        } else
    24712493            pageDownInternal();
    2472         thisCommand = COMMAND_PAGE_DOWN;
     2494        setCurrentCommand(COMMAND_PAGE_DOWN);
    24732495    }
    24742496
     
    24862508        } else
    24872509            pageDownInternal();
    2488         thisCommand = COMMAND_PAGE_DOWN;
     2510        setCurrentCommand(COMMAND_PAGE_DOWN);
    24892511    }
    24902512
     
    25032525        } else
    25042526            pageUpInternal();
    2505         thisCommand = COMMAND_PAGE_UP;
     2527        setCurrentCommand(COMMAND_PAGE_UP);
    25062528    }
    25072529
     
    25192541        } else
    25202542            pageUpInternal();
    2521         thisCommand = COMMAND_PAGE_UP;
     2543        setCurrentCommand(COMMAND_PAGE_UP);
    25222544    }
    25232545
     
    26532675                if (getDotLine().next() != null) {
    26542676                    moveDotTo(getDotLine().next(), 0);
    2655                     thisCommand = COMMAND_RIGHT;
     2677                    setCurrentCommand(COMMAND_RIGHT);
    26562678                }
    26572679                return;
     
    26692691        }
    26702692        updateDotLine();
    2671         thisCommand = COMMAND_RIGHT;
     2693        setCurrentCommand(COMMAND_RIGHT);
    26722694        setUpdateFlag(REFRAME);
    26732695    }
     
    27042726        }
    27052727        updateDotLine();
    2706         thisCommand = COMMAND_RIGHT;
     2728        setCurrentCommand(COMMAND_RIGHT);
    27072729        setUpdateFlag(REFRAME);
    27082730    }
     
    27412763        }
    27422764        updateDotLine();
    2743         thisCommand = COMMAND_LEFT;
     2765        setCurrentCommand(COMMAND_LEFT);
    27442766        setUpdateFlag(REFRAME);
    27452767    }
     
    27802802        }
    27812803        updateDotLine();
    2782         thisCommand = COMMAND_LEFT;
     2804        setCurrentCommand(COMMAND_LEFT);
    27832805        setUpdateFlag(REFRAME);
    27842806    }
     
    28202842        maybeResetGoalColumn();
    28212843        display.down(false);
    2822         thisCommand = COMMAND_DOWN;
     2844        setCurrentCommand(COMMAND_DOWN);
    28232845    }
    28242846
     
    28272849        maybeResetGoalColumn();
    28282850        display.down(true);
    2829         thisCommand = COMMAND_DOWN;
     2851        setCurrentCommand(COMMAND_DOWN);
    28302852    }
    28312853
     
    28362858        maybeResetGoalColumn();
    28372859        display.up(false);
    2838         thisCommand = COMMAND_UP;
     2860        setCurrentCommand(COMMAND_UP);
    28392861    }
    28402862
     
    28432865        maybeResetGoalColumn();
    28442866        display.up(true);
    2845         thisCommand = COMMAND_UP;
     2867        setCurrentCommand(COMMAND_UP);
    28462868    }
    28472869
     
    29292951            buffer.getCol(pos) != display.getAbsoluteCaretCol()) {
    29302952            moveDotTo(pos);
    2931             thisCommand = COMMAND_HOME;
     2953            setCurrentCommand(COMMAND_HOME);
    29322954            return;
    29332955        }
     
    29382960            // Timed out.
    29392961            setUpdateFlag(REFRAME);
    2940             thisCommand = COMMAND_HOME;
     2962            setCurrentCommand(COMMAND_HOME);
    29412963            return;
    29422964        }
     
    29462968            pos = new Position(getTopLine(), 0);
    29472969            setUpdateFlag(REFRAME);
    2948             thisCommand = COMMAND_HOME_HOME;
     2970            setCurrentCommand(COMMAND_HOME_HOME);
    29492971        } else {
    29502972            setUpdateFlag(REFRAME);
    2951             thisCommand = COMMAND_HOME;
     2973            setCurrentCommand(COMMAND_HOME);
    29522974            return;
    29532975        }
     
    29853007            selectToPosition(pos);
    29863008            setUpdateFlag(REFRAME);
    2987             thisCommand = COMMAND_SELECT_HOME;
     3009            setCurrentCommand(COMMAND_SELECT_HOME);
    29883010            return;
    29893011        }
     
    29943016            // Timed out.
    29953017            setUpdateFlag(REFRAME);
    2996             thisCommand = COMMAND_SELECT_HOME;
     3018            setCurrentCommand(COMMAND_SELECT_HOME);
    29973019            return;
    29983020        }
     
    30023024            pos = new Position(getTopLine(), 0);
    30033025            setUpdateFlag(REFRAME);
    3004             thisCommand = COMMAND_SELECT_HOME_HOME;
     3026            setCurrentCommand(COMMAND_SELECT_HOME_HOME);
    30053027        } else {
    30063028            setUpdateFlag(REFRAME);
    3007             thisCommand = COMMAND_SELECT_HOME;
     3029            setCurrentCommand(COMMAND_SELECT_HOME);
    30083030            return;
    30093031        }
     
    30363058            moveDotTo(pos);
    30373059            setUpdateFlag(REFRAME);
    3038             thisCommand = COMMAND_END;
     3060            setCurrentCommand(COMMAND_END);
    30393061            return;
    30403062        }
     
    30453067            // Timed out.
    30463068            setUpdateFlag(REFRAME);
    3047             thisCommand = COMMAND_END;
     3069            setCurrentCommand(COMMAND_END);
    30483070            return;
    30493071        }
     
    30573079                pos = getEob();
    30583080            setUpdateFlag(REFRAME);
    3059             thisCommand = COMMAND_END_END;
     3081            setCurrentCommand(COMMAND_END_END);
    30603082        } else {
    30613083            setUpdateFlag(REFRAME);
    3062             thisCommand = COMMAND_END;
     3084            setCurrentCommand(COMMAND_END);
    30633085            return;
    30643086        }
     
    30823104            selectToPosition(pos);
    30833105            setUpdateFlag(REFRAME);
    3084             thisCommand = COMMAND_END;
     3106            setCurrentCommand(COMMAND_END);
    30853107            return;
    30863108        }
     
    30913113            // Timed out.
    30923114            setUpdateFlag(REFRAME);
    3093             thisCommand = COMMAND_END;
     3115            setCurrentCommand(COMMAND_END);
    30943116            return;
    30953117        }
     
    31033125                pos = getEob();
    31043126            setUpdateFlag(REFRAME);
    3105             thisCommand = COMMAND_END_END;
     3127            setCurrentCommand(COMMAND_END_END);
    31063128        } else {
    3107             thisCommand = COMMAND_END;
     3129            setCurrentCommand(COMMAND_END);
    31083130            return;
    31093131        }
     
    50915113                else
    50925114                    updateInAllEditors(getDotLine());
    5093                 thisCommand = COMMAND_KILL;
     5115                setCurrentCommand(COMMAND_KILL);
    50945116            }
    50955117            setMark(null);
     
    51055127                killLine();
    51065128                endCompoundEdit(compoundEdit);
    5107                 thisCommand = COMMAND_KILL;
     5129                setCurrentCommand(COMMAND_KILL);
    51085130                return;
    51095131            }
     
    51365158            moveCaretToDotCol();
    51375159            buffer.repaint();
    5138             thisCommand = COMMAND_KILL;
     5160            setCurrentCommand(COMMAND_KILL);
    51395161        }
    51405162    }
     
    51465168            return;
    51475169        }
    5148         lastCommand = COMMAND_KILL; // Force append.
     5170        setLastCommand(COMMAND_KILL); // Force append.
    51495171        killRegion();
    51505172    }
     
    53085330        if (toBeInserted != null) {
    53095331            paste(toBeInserted);
    5310             thisCommand = COMMAND_PASTE;
     5332            setCurrentCommand(COMMAND_PASTE);
    53115333        }
    53125334        setDefaultCursor();
     
    53395361        } else
    53405362            paste(s);
    5341         thisCommand = COMMAND_PASTE;
     5363        setCurrentCommand(COMMAND_PASTE);
    53425364    }
    53435365
     
    53565378                undo();
    53575379                paste(s);
    5358                 thisCommand = COMMAND_PASTE;
     5380                setCurrentCommand(COMMAND_PASTE);
    53595381            }
    53605382            setDefaultCursor();
     
    60346056            buffer.undo();
    60356057            checkDotInOtherFrames();
    6036             thisCommand = COMMAND_UNDO;
     6058            setCurrentCommand(COMMAND_UNDO);
    60376059        }
    60386060        catch (Throwable t) {
  • trunk/j/src/org/armedbear/j/Expansion.java

    r2 r112  
    33 *
    44 * Copyright (C) 1998-2002 Peter Graves
    5  * $Id: Expansion.java,v 1.1.1.1 2002-09-24 16:09:26 piso Exp $
     5 * $Id: Expansion.java,v 1.2 2002-10-12 00:06:39 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    234234    {
    235235        final Editor editor = Editor.currentEditor();
    236         if (editor.lastCommand == COMMAND_EXPAND)
     236        if (editor.getLastCommand() == COMMAND_EXPAND)
    237237            expand(editor, Expansion.getLastExpansion(), true);
    238238        else {
     
    278278            buffer.endCompoundEdit(compoundEdit);
    279279            Editor.updateInAllEditors(line);
    280             editor.thisCommand = COMMAND_EXPAND;
     280            editor.setCurrentCommand(COMMAND_EXPAND);
    281281        }
    282282        finally {
  • trunk/j/src/org/armedbear/j/Shell.java

    r95 r112  
    33 *
    44 * Copyright (C) 1998-2002 Peter Graves
    5  * $Id: Shell.java,v 1.5 2002-10-11 13:54:37 piso Exp $
     5 * $Id: Shell.java,v 1.6 2002-10-12 00:06:39 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    293293            return;
    294294        }
    295         if (editor.lastCommand != COMMAND_HISTORY)
     295        if (editor.getLastCommand() != COMMAND_HISTORY)
    296296            history.reset();
    297297        String currentInput = dotLine.getText();
     
    324324            endCompoundEdit(compoundEdit);
    325325        }
    326         editor.thisCommand = COMMAND_HISTORY;
     326        editor.setCurrentCommand(COMMAND_HISTORY);
    327327    }
    328328
Note: See TracChangeset for help on using the changeset viewer.