1999-09-27 18:44:28 +00:00
|
|
|
|
//<2F>-*- C++ -*-
|
|
|
|
|
/* ======================================================================= *\
|
|
|
|
|
File : kbmap.h, kbmap.h,v 1.3 1996/12/10 04:35:57 larsbj Exp
|
|
|
|
|
Author : chb, 30.Oct.1995
|
|
|
|
|
Docu : see kbmap.C
|
|
|
|
|
Purpose: class definitions for XKeyEvent keymap handling
|
1999-10-07 18:44:17 +00:00
|
|
|
|
\* ==================================================================== */
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
|
#ifndef KBMAP_H
|
|
|
|
|
#define KBMAP_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
|
#pragma interface
|
|
|
|
|
#endif
|
|
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
|
#include <list>
|
2001-03-07 16:18:05 +00:00
|
|
|
|
#include <boost/smart_ptr.hpp>
|
1999-10-02 16:21:10 +00:00
|
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
|
#include "LString.h"
|
2000-01-20 01:41:55 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
class kb_sequence;
|
|
|
|
|
|
|
|
|
|
/// Defines key maps and actions for key sequences
|
|
|
|
|
class kb_keymap {
|
|
|
|
|
public:
|
2000-02-04 09:38:32 +00:00
|
|
|
|
/** Bind a key-sequence to an action.
|
|
|
|
|
Returns 0 on success. Otherwise, position in string where
|
1999-12-16 06:43:25 +00:00
|
|
|
|
error occured. */
|
2001-10-01 15:31:59 +00:00
|
|
|
|
string::size_type bind(string const & seq, int action);
|
1999-12-16 06:43:25 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
1999-12-16 06:43:25 +00:00
|
|
|
|
void print(string & buf) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
/// Look up a key in the keymap
|
2000-02-04 09:38:32 +00:00
|
|
|
|
int lookup(unsigned int key,
|
|
|
|
|
unsigned int mod, kb_sequence * seq) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
/// Given an action, find all keybindings.
|
2001-05-17 15:11:01 +00:00
|
|
|
|
string const findbinding(int action,
|
|
|
|
|
string const & prefix = string()) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
private:
|
2000-02-04 09:38:32 +00:00
|
|
|
|
///
|
|
|
|
|
struct kb_key {
|
|
|
|
|
/// Keysym
|
|
|
|
|
unsigned int code;
|
|
|
|
|
|
|
|
|
|
/// Modifier masks
|
|
|
|
|
unsigned int mod;
|
|
|
|
|
|
|
|
|
|
/// Keymap for prefix keys
|
2001-03-07 16:18:05 +00:00
|
|
|
|
boost::shared_ptr<kb_keymap> table;
|
2000-02-04 09:38:32 +00:00
|
|
|
|
|
|
|
|
|
/// Action for !prefix keys
|
|
|
|
|
int action;
|
|
|
|
|
};
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
|
/// Define a new key sequence
|
|
|
|
|
int defkey(kb_sequence * seq, int action, int idx = 0);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2000-09-14 17:53:12 +00:00
|
|
|
|
static string const keyname(kb_key const & k);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
///
|
2000-02-04 09:38:32 +00:00
|
|
|
|
static
|
|
|
|
|
void printKey(kb_key const & key, string & buf);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2000-02-04 09:38:32 +00:00
|
|
|
|
bool empty() const {
|
|
|
|
|
return table.empty();
|
2000-01-25 12:35:27 +00:00
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2000-04-04 00:19:15 +00:00
|
|
|
|
typedef std::list<kb_key> Table;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2000-02-04 09:38:32 +00:00
|
|
|
|
Table table;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|