projects
/
dana
/
urxvt.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7f84a94
)
*** empty log message ***
author
root
<root>
Sun, 16 Jan 2005 23:55:42 +0000
(23:55 +0000)
committer
root
<root>
Sun, 16 Jan 2005 23:55:42 +0000
(23:55 +0000)
src/keyboard.C
patch
|
blob
|
history
src/misc.C
patch
|
blob
|
history
diff --git
a/src/keyboard.C
b/src/keyboard.C
index
45bf19d
..
008e587
100644
(file)
--- a/
src/keyboard.C
+++ b/
src/keyboard.C
@@
-1,12
+1,13
@@
#include "../config.h"
#include "rxvt.h"
#include "../config.h"
#include "rxvt.h"
-#include "keyboard.h"
-#include "command.h"
-#include <string.h>
-#include <X11/X.h>
#ifdef KEYSYM_RESOURCE
#ifdef KEYSYM_RESOURCE
+#include <cstring>
+
+#include "keyboard.h"
+#include "command.h"
+
////////////////////////////////////////////////////////////////////////////////
// default keycode translation map and keyevent handlers
////////////////////////////////////////////////////////////////////////////////
// default keycode translation map and keyevent handlers
@@
-70,16
+71,11
@@
output_string_meta8 (rxvt_term *rt, unsigned int state, char *buf, int buflen)
static int
format_keyrange_string (const char *str, int keysym_offset, char *buf, int bufsize)
{
static int
format_keyrange_string (const char *str, int keysym_offset, char *buf, int bufsize)
{
-
in
t len = snprintf (buf, bufsize, str + 1, keysym_offset + str [0]);
+
size_
t len = snprintf (buf, bufsize, str + 1, keysym_offset + str [0]);
- if (len >= bufsize)
+ if (len >=
(size_t)
bufsize)
{
{
- rxvt_warn ("buffer overflowed!\n");
- *buf = 0;
- }
- else if (len < 0)
- {
- rxvt_warn ("keyrange_translator(), snprintf error");
+ rxvt_warn ("format_keyrange_string: formatting failed, ignoring key.\n");
*buf = 0;
}
*buf = 0;
}
@@
-88,16
+84,20
@@
format_keyrange_string (const char *str, int keysym_offset, char *buf, int bufsi
////////////////////////////////////////////////////////////////////////////////
// return: #bits of '1'
////////////////////////////////////////////////////////////////////////////////
// return: #bits of '1'
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3)
+# define bitcount(n) (__extension__ ({ uint32_t n__ = (n); __builtin_popcount (n); }))
+#else
static int
static int
-bitcount (u
nsigned in
t n)
+bitcount (u
int16_
t n)
{
int i;
{
int i;
- for (i = 0; n; ++i, n &=
(n - 1)
)
+ for (i = 0; n; ++i, n &=
n - 1
)
;
return i;
}
;
return i;
}
+#endif
// return: priority_of_a - priority_of_b
static int
// return: priority_of_a - priority_of_b
static int
@@
-163,6
+163,7
@@
keyboard_manager::register_user_translation (KeySym keysym, unsigned int state,
keysym_t *key = new keysym_t;
wchar_t *wc = rxvt_mbstowcs (trans);
keysym_t *key = new keysym_t;
wchar_t *wc = rxvt_mbstowcs (trans);
+printf ("CONV <%s> %x %x %x %x\n", trans, (int)wc[0], (int)wc[1], (int)wc[2], (int)wc[3]);
const char *translation = rxvt_wcstoutf8 (wc);
free (wc);
const char *translation = rxvt_wcstoutf8 (wc);
free (wc);
@@
-187,12
+188,8
@@
keyboard_manager::register_user_translation (KeySym keysym, unsigned int state,
strcpy (translation, translation + 4);
}
else
strcpy (translation, translation + 4);
}
else
- {
- key->range = 1;
- rxvt_warn ("cannot parse list-type keysym '%s', treating as normal keysym.\n", translation);
- }
+ rxvt_warn ("cannot parse list-type keysym '%s', treating as normal keysym.\n", translation);
}
}
- else
user_keymap.push_back (key);
user_translations.push_back (translation);
user_keymap.push_back (key);
user_translations.push_back (translation);
@@
-249,12
+246,12
@@
keyboard_manager::dispatch (rxvt_term *term, KeySym keysym, unsigned int state)
if (index >= 0)
{
if (index >= 0)
{
- assert (term && keymap [index]);
const keysym_t &key = *keymap [index];
int keysym_offset = keysym - key.keysym;
wchar_t *wc = rxvt_utf8towcs (key.str);
const keysym_t &key = *keymap [index];
int keysym_offset = keysym - key.keysym;
wchar_t *wc = rxvt_utf8towcs (key.str);
+
char *str = rxvt_wcstombs (wc);
// TODO: do translations, unescaping etc, here (allow \u escape etc.)
free (wc);
char *str = rxvt_wcstombs (wc);
// TODO: do translations, unescaping etc, here (allow \u escape etc.)
free (wc);
@@
-434,7
+431,7
@@
keyboard_manager::setup_hash ()
keysym_t *a = sorted_keymap[i];
for (int j = 0; j < a->range; ++j)
{
keysym_t *a = sorted_keymap[i];
for (int j = 0; j < a->range; ++j)
{
- int index = find_keysym (a->keysym + j, a->state
& OtherModMask
);
+ int index = find_keysym (a->keysym + j, a->state);
assert (index >= 0);
keysym_t *b = keymap [index];
assert (index >= 0);
keysym_t *b = keymap [index];
@@
-458,7
+455,7
@@
keyboard_manager::find_keysym (KeySym keysym, unsigned int state)
if (key->keysym <= keysym && key->keysym + key->range > keysym
// match only the specified bits in state and ignore others
if (key->keysym <= keysym && key->keysym + key->range > keysym
// match only the specified bits in state and ignore others
- && (key->state &
OtherModMask) == (key->state & state)
)
+ && (key->state &
state) == key->state
)
return index;
else if (key->keysym > keysym && key->range == 1)
return -1;
return index;
else if (key->keysym > keysym && key->range == 1)
return -1;
diff --git
a/src/misc.C
b/src/misc.C
index
e229074
..
1544283
100644
(file)
--- a/
src/misc.C
+++ b/
src/misc.C
@@
-38,7
+38,7
@@
rxvt_wcstombs (const wchar_t *str, int len)
char *dst = r;
while (len--)
{
char *dst = r;
while (len--)
{
-
in
t l = wcrtomb (dst, *str++, mbs);
+
ssize_
t l = wcrtomb (dst, *str++, mbs);
if (l < 0)
*dst++ = '?';
else
if (l < 0)
*dst++ = '?';
else
@@
-47,7
+47,7
@@
rxvt_wcstombs (const wchar_t *str, int len)
*dst++ = 0;
*dst++ = 0;
- return
r
;
+ return
(char *)rxvt_realloc (r, dst - r)
;
}
wchar_t *
}
wchar_t *
@@
-57,7
+57,7
@@
rxvt_mbstowcs (const char *str, int len)
wchar_t *r = (wchar_t *)rxvt_malloc ((len + 1) * sizeof (wchar_t));
wchar_t *r = (wchar_t *)rxvt_malloc ((len + 1) * sizeof (wchar_t));
- if (mbstowcs (r, str, len + 1) < 0)
+ if (
(ssize_t)
mbstowcs (r, str, len + 1) < 0)
*r = 0;
return r;
*r = 0;
return r;
@@
-93,9
+93,9
@@
rxvt_wcstoutf8 (const wchar_t *str, int len)
*p++ = '?';
}
*p++ = '?';
}
- *p = 0;
+ *p
++
= 0;
- return
r
;
+ return
(char *)rxvt_realloc (r, p - r)
;
}
wchar_t *
}
wchar_t *