[Aptitude-svn-commit] r3460 - in branches/aptitude-0.3/aptitude: . src/vscreen/config
Daniel Burrows
dburrows@costa.debian.org
Sun, 26 Jun 2005 17:00:13 +0000
Author: dburrows
Date: Sun Jun 26 17:00:10 2005
New Revision: 3460
Modified:
branches/aptitude-0.3/aptitude/ChangeLog
branches/aptitude-0.3/aptitude/src/vscreen/config/keybindings.cc
branches/aptitude-0.3/aptitude/src/vscreen/config/keybindings.h
Log:
Take wide character values in the keybinding lookup tables.
Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog (original)
+++ branches/aptitude-0.3/aptitude/ChangeLog Sun Jun 26 17:00:10 2005
@@ -1,5 +1,9 @@
2005-06-26 Daniel Burrows <dburrows@debian.org>
+ * src/vscreen/config/keybindings.cc, src/vscreen/config/keybindings.h:
+
+ Make the keybinding lookup tables take wide character values.
+
* src/vscreen/vscreen_widget.cc, src/vscreen/vscreen_widget.h:
Modify the prototypes of dispatch_char and handle_char to
Modified: branches/aptitude-0.3/aptitude/src/vscreen/config/keybindings.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/config/keybindings.cc (original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/config/keybindings.cc Sun Jun 26 17:00:10 2005
@@ -36,13 +36,13 @@
keybindings global_bindings;
-hash_map<string, chtype> keynames;
-hash_map<string, chtype> s_keynames;
+hash_map<string, wint_t> keynames;
+hash_map<string, wint_t> s_keynames;
// For simplicity, we use the convention that the names are stored in
// lowercase; however, the routines to parse keys take this into account and
// convert the input to lowercase before checking it.
// FIXME: Function keys (F0-Fx) really ought to be handled specially
-hash_map<chtype, string> rev_keynames;
+hash_map<wint_t, string> rev_keynames;
bool key_tables_initialized=false;
@@ -256,7 +256,7 @@
keymap[tag]=strokes;
}
-bool keybindings::key_matches(chtype ch, string tag)
+bool keybindings::key_matches(wint_t ch, string tag)
{
hash_map<string, keybinding>::iterator found=keymap.find(tag);
if(found==keymap.end())
@@ -277,11 +277,11 @@
}
}
-chtype parse_key(string keystr)
+wint_t parse_key(string keystr)
{
bool sfound=false,cfound=false,afound=false;
string tmpstr=keystr;
- chtype rval=(chtype) ERR;
+ wint_t rval=(wint_t) ERR;
init_key_tables();
@@ -307,7 +307,7 @@
#ifdef HAVE_LIBAPT_PKG
_error->Error("Cannot parse key description: %s", keystr.c_str());
#endif
- return (chtype) ERR;
+ return (wint_t) ERR;
}
tmpstr=string(tmpstr,2);
}
@@ -317,7 +317,7 @@
#ifdef HAVE_LIBAPT_PKG
_error->Error("Invalid null keybinding");
#endif
- return (chtype) ERR;
+ return (wint_t) ERR;
}
if(cfound && tmpstr.size()>1)
@@ -325,7 +325,7 @@
#ifdef HAVE_LIBAPT_PKG
_error->Error("Sorry, control modifiers may not be used with unprintable characters");
#endif
- return (chtype) ERR;
+ return (wint_t) ERR;
}
if(tmpstr.size()==1)
@@ -341,9 +341,9 @@
{
for(unsigned int i=0; i<tmpstr.size(); i++)
tmpstr[i]=tolower(tmpstr[i]);
- hash_map<string,chtype>::iterator found=(sfound?s_keynames:keynames).find(tmpstr);
+ hash_map<string, wint_t>::iterator found=(sfound?s_keynames:keynames).find(tmpstr);
if(found==(sfound?s_keynames:keynames).end())
- return (chtype) ERR;
+ return (wint_t) ERR;
else
{
rval=found->second;
@@ -355,7 +355,7 @@
}
}
-string keyname(chtype ch)
+string keyname(wint_t ch)
{
init_key_tables();
@@ -372,7 +372,7 @@
return "A-"+keyname(ch&~0x200);
else
{
- hash_map<chtype, string>::iterator found=rev_keynames.find(ch);
+ hash_map<wint_t, string>::iterator found=rev_keynames.find(ch);
if(found!=rev_keynames.end())
return found->second;
@@ -386,7 +386,7 @@
}
}
-string readable_keyname(chtype ch)
+string readable_keyname(wint_t ch)
{
if(ch == ',')
return ",";
Modified: branches/aptitude-0.3/aptitude/src/vscreen/config/keybindings.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/config/keybindings.h (original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/config/keybindings.h Sun Jun 26 17:00:10 2005
@@ -42,7 +42,7 @@
#include "../../generic/strhash.h"
#include "../curses++.h"
-typedef std::list<chtype> keybinding;
+typedef std::vector<wint_t> keybinding;
class keybindings
{
@@ -82,28 +82,28 @@
// Adds a setting for the given binding, clobbering whatever was there
// previously.
- void set(std::string tag, chtype stroke)
+ void set(std::string tag, wint_t stroke)
{
keybinding strokes;
strokes.push_back(stroke);
set(tag, strokes);
}
- bool key_matches(chtype ch, std::string tag);
+ bool key_matches(wint_t ch, std::string tag);
// Tests whether the given keystroke matches the keybinding with the given
// name. If no keybinding by that name exists, the match fails.
};
-chtype parse_key(std::string keystr);
+wint_t parse_key(std::string keystr);
// Parses a string to a keycode. Returns ERR if the parse fails.
-std::string keyname(chtype ch);
+std::string keyname(wint_t ch);
// Returns a string identifying the given keystroke.
/** \return a human-readable string identifying the given keystroke
* (as opposed to 'keyname', which is a strict reverse mapping).
*/
-std::string readable_keyname(chtype ch);
+std::string readable_keyname(wint_t ch);
extern keybindings global_bindings;
// For now, this is where the global bindings are stored (I might want to move