From 0a84fa22bbe2f160f56bdfef6143c283ff9d4f98 Mon Sep 17 00:00:00 2001 From: stephena Date: Tue, 7 Jun 2005 21:22:39 +0000 Subject: [PATCH] Fixed remaining problems with the debugger console. Erase to beginning of line (Ctrl-U) now works, as do shifted characters. Still TODO is use a monospaced font for the debugger widgets, and possibly add some new colors, etc. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@472 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/src/emucore/EventHandler.cxx | 21 +++++++-------------- stella/src/emucore/EventHandler.hxx | 6 +++--- stella/src/emucore/FrameBuffer.cxx | 6 +++++- stella/src/gui/DialogContainer.cxx | 10 +++++----- stella/src/gui/DialogContainer.hxx | 13 +++++++------ stella/src/gui/ListWidget.cxx | 6 +++--- stella/src/gui/PromptDialog.cxx | 24 +++++++++++++----------- 7 files changed, 43 insertions(+), 43 deletions(-) diff --git a/stella/src/emucore/EventHandler.cxx b/stella/src/emucore/EventHandler.cxx index 61936271b..6e11e6cbe 100644 --- a/stella/src/emucore/EventHandler.cxx +++ b/stella/src/emucore/EventHandler.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: EventHandler.cxx,v 1.71 2005-06-07 19:01:53 stephena Exp $ +// $Id: EventHandler.cxx,v 1.72 2005-06-07 21:22:38 stephena Exp $ //============================================================================ #include @@ -242,18 +242,11 @@ void EventHandler::poll(uInt32 time) case SDL_KEYUP: case SDL_KEYDOWN: { + int unicode = event.key.keysym.unicode; SDLKey key = event.key.keysym.sym; SDLMod mod = event.key.keysym.mod; uInt8 state = event.key.type == SDL_KEYDOWN ? 1 : 0; -if(event.type == SDL_KEYDOWN) -{ - if(kbdShift(mod)) - cerr << "shift key: " << (char)key << endl; - else - cerr << "key: " << (char)key << endl; -} - // An attempt to speed up event processing // All SDL-specific event actions are accessed by either // Control/Cmd or Alt/Shift-Cmd keys. So we quickly check for those. @@ -444,7 +437,7 @@ if(event.type == SDL_KEYDOWN) } // Otherwise, let the event handler deal with it - handleKeyEvent(key, mod, state); + handleKeyEvent(unicode, key, mod, state); break; // SDL_KEYUP, SDL_KEYDOWN } @@ -623,7 +616,7 @@ if(event.type == SDL_KEYDOWN) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void EventHandler::handleKeyEvent(SDLKey key, SDLMod mod, uInt8 state) +void EventHandler::handleKeyEvent(int unicode, SDLKey key, SDLMod mod, uInt8 state) { // Determine which mode we're in, then send the event to the appropriate place switch(myState) @@ -650,11 +643,11 @@ void EventHandler::handleKeyEvent(SDLKey key, SDLMod mod, uInt8 state) leaveMenuMode(); return; } - myOSystem->menu().handleKeyEvent(key, mod, state); + myOSystem->menu().handleKeyEvent(unicode, key, mod, state); break; case S_LAUNCHER: - myOSystem->launcher().handleKeyEvent(key, mod, state); + myOSystem->launcher().handleKeyEvent(unicode, key, mod, state); break; case S_DEBUGGER: @@ -663,7 +656,7 @@ void EventHandler::handleKeyEvent(SDLKey key, SDLMod mod, uInt8 state) leaveDebugMode(); return; } - myOSystem->debugger().handleKeyEvent(key, mod, state); + myOSystem->debugger().handleKeyEvent(unicode, key, mod, state); break; case S_NONE: diff --git a/stella/src/emucore/EventHandler.hxx b/stella/src/emucore/EventHandler.hxx index 004a8951d..389a1cb20 100644 --- a/stella/src/emucore/EventHandler.hxx +++ b/stella/src/emucore/EventHandler.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: EventHandler.hxx,v 1.35 2005-06-07 19:01:53 stephena Exp $ +// $Id: EventHandler.hxx,v 1.36 2005-06-07 21:22:39 stephena Exp $ //============================================================================ #ifndef EVENTHANDLER_HXX @@ -74,7 +74,7 @@ struct Stella_Joystick { mapping can take place. @author Stephen Anthony - @version $Id: EventHandler.hxx,v 1.35 2005-06-07 19:01:53 stephena Exp $ + @version $Id: EventHandler.hxx,v 1.36 2005-06-07 21:22:39 stephena Exp $ */ class EventHandler { @@ -233,7 +233,7 @@ class EventHandler @param mod modifiers @param state state of key */ - void handleKeyEvent(SDLKey key, SDLMod mod, uInt8 state); + void handleKeyEvent(int unicode, SDLKey key, SDLMod mod, uInt8 state); /** Send a mouse motion event to the handler. diff --git a/stella/src/emucore/FrameBuffer.cxx b/stella/src/emucore/FrameBuffer.cxx index 6a0199693..da5e2cb7b 100644 --- a/stella/src/emucore/FrameBuffer.cxx +++ b/stella/src/emucore/FrameBuffer.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: FrameBuffer.cxx,v 1.41 2005-05-30 16:25:46 stephena Exp $ +// $Id: FrameBuffer.cxx,v 1.42 2005-06-07 21:22:39 stephena Exp $ //============================================================================ #include @@ -148,6 +148,10 @@ void FrameBuffer::initialize(const string& title, uInt32 width, uInt32 height, // Initialize video subsystem initSubsystem(); + // Enable unicode so we can see translated key events + // (lowercase vs. uppercase characters) + SDL_EnableUNICODE(1); + // Erase any messages from a previous run myMessageTime = 0; theRedrawEntireFrameIndicator = true; diff --git a/stella/src/gui/DialogContainer.cxx b/stella/src/gui/DialogContainer.cxx index 6ab9096c5..b36b68672 100644 --- a/stella/src/gui/DialogContainer.cxx +++ b/stella/src/gui/DialogContainer.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: DialogContainer.cxx,v 1.7 2005-05-26 15:43:44 stephena Exp $ +// $Id: DialogContainer.cxx,v 1.8 2005-06-07 21:22:39 stephena Exp $ //============================================================================ #include "OSystem.hxx" @@ -121,7 +121,7 @@ void DialogContainer::reStack() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void DialogContainer::handleKeyEvent(int key, int mod, uInt8 state) +void DialogContainer::handleKeyEvent(int unicode, int key, int mod, uInt8 state) { if(myDialogStack.empty()) return; @@ -130,16 +130,16 @@ void DialogContainer::handleKeyEvent(int key, int mod, uInt8 state) Dialog* activeDialog = myDialogStack.top(); if(state == 1) { - myCurrentKeyDown.ascii = key; + myCurrentKeyDown.ascii = unicode; myCurrentKeyDown.keycode = key; myCurrentKeyDown.flags = mod; myKeyRepeatTime = myTime + kKeyRepeatInitialDelay; - activeDialog->handleKeyDown(key, key, mod); + activeDialog->handleKeyDown(unicode, key, mod); } else { - activeDialog->handleKeyUp(key, key, mod); + activeDialog->handleKeyUp(unicode, key, mod); // Only stop firing events if it's the current key if (key == myCurrentKeyDown.keycode) diff --git a/stella/src/gui/DialogContainer.hxx b/stella/src/gui/DialogContainer.hxx index eb75b9362..49fd011c5 100644 --- a/stella/src/gui/DialogContainer.hxx +++ b/stella/src/gui/DialogContainer.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: DialogContainer.hxx,v 1.4 2005-05-26 15:43:44 stephena Exp $ +// $Id: DialogContainer.hxx,v 1.5 2005-06-07 21:22:39 stephena Exp $ //============================================================================ #ifndef DIALOG_CONTAINER_HXX @@ -37,7 +37,7 @@ typedef FixedStack DialogStack; a stack, and handles their events. @author Stephen Anthony - @version $Id: DialogContainer.hxx,v 1.4 2005-05-26 15:43:44 stephena Exp $ + @version $Id: DialogContainer.hxx,v 1.5 2005-06-07 21:22:39 stephena Exp $ */ class DialogContainer { @@ -64,11 +64,12 @@ class DialogContainer /** Handle a keyboard event. - @param key keysym - @param mod modifiers - @param state state of key + @param unicode Unicode translation + @param key Actual key symbol + @param mod Modifiers + @param state Pressed or released */ - void handleKeyEvent(int key, int mod, uInt8 state); + void handleKeyEvent(int unicode, int key, int mod, uInt8 state); /** Handle a mouse motion event. diff --git a/stella/src/gui/ListWidget.cxx b/stella/src/gui/ListWidget.cxx index 6ef2c826a..eccf3e6d6 100644 --- a/stella/src/gui/ListWidget.cxx +++ b/stella/src/gui/ListWidget.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: ListWidget.cxx,v 1.10 2005-06-07 19:01:53 stephena Exp $ +// $Id: ListWidget.cxx,v 1.11 2005-06-07 21:22:39 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -197,7 +197,7 @@ bool ListWidget::handleKeyDown(int ascii, int keycode, int modifiers) bool dirty = false; int oldSelectedItem = _selectedItem; - if (!_editMode && isalpha((char)ascii)) + if (!_editMode && isalnum((char)ascii)) { // Quick selection mode: Go to first list item starting with this key // (or a substring accumulated from the last couple key presses). @@ -255,7 +255,7 @@ bool ListWidget::handleKeyDown(int ascii, int keycode, int modifiers) dirty = true; break; default: - if (ascii < 128) + if (isprint(ascii)) { _list[_selectedItem] += (char)ascii; dirty = true; diff --git a/stella/src/gui/PromptDialog.cxx b/stella/src/gui/PromptDialog.cxx index caac5317f..2d57b2aaa 100644 --- a/stella/src/gui/PromptDialog.cxx +++ b/stella/src/gui/PromptDialog.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: PromptDialog.cxx,v 1.2 2005-06-07 19:01:53 stephena Exp $ +// $Id: PromptDialog.cxx,v 1.3 2005-06-07 21:22:39 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -304,26 +304,21 @@ cerr << "Command entered: \'" << str << "\'\n"; break; default: -cerr << "ascii: " << ascii << endl; if (instance()->eventHandler().kbdControl(modifiers)) { specialKeys(keycode); } +/* else if (instance()->eventHandler().kbdAlt(modifiers)) { -cerr << "Alt from prompt\n"; } - else if (ascii < 256) +*/ + else if (isprint(ascii)) { - // Do uppercase letters -// if(instance()->eventHandler().kbdShift(modifiers)) -// ascii = ascii & ~0x20; - for (i = _promptEndPos - 1; i >= _currentPos; i--) buffer(i + 1) = buffer(i); _promptEndPos++; - putchar((int)*(SDL_GetKeyName((SDLKey)ascii))); -// putchar(ascii); + putchar(ascii); scrollToCurrent(); } break; @@ -442,7 +437,14 @@ void PromptDialog::killChar(int direction) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PromptDialog::killLine(int direction) { - if(direction == 1) // erase from current position to end of line + if(direction == -1) // erase from current position to beginning of line + { + int count = _currentPos - _promptStartPos; + if(count > 0) + for (int i = 0; i < count; i++) + killChar(-1); + } + else if(direction == 1) // erase from current position to end of line { for (int i = _currentPos; i < _promptEndPos; i++) buffer(i) = ' ';