-/* ---F+------------------------------------------------------------------ *\
- Function : printKeysym
- Called by : kb_sequence::print and printKeyMap. RVDK_PATCH_5
- Purpose : prints a keysym, including modifiers.
- Parameters: key - keysym
- mod - modifiers
- buf - string where the result goes
- maxlen - length of string (including '\0')
- Returns : length of printed string if ok, 0 otherwise.
-\* ---F------------------------------------------------------------------- */
-
-static
-int printKeysym( KeySym key, unsigned int mod, char *buf, int maxlen )
-{
- int len;
- char *s;
-
- mod &= ModsMask;
-
- // calc required length;
- len = 0;
- if ( mod & ShiftMask ) len += 2;
- if ( mod & ControlMask ) len += 2;
- if ( mod & Mod1Mask ) len += 2;
-
- s = XKeysymToString( key );
- if ( s ) len += strlen( s );
- if ( len < maxlen ) {
- if ( mod & ShiftMask ) {
- *buf++ = 'S'; *buf++ = '-'; }
- if ( mod & ControlMask ) {
- *buf++ = 'C'; *buf++ = '-'; }
- if ( mod & Mod1Mask ) {
- *buf++ = 'M'; *buf++ = '-'; }
- if ( s ) strcpy( buf, s );
- return len;
- } else
- return 0;
-}
-
-
-/* ---F+------------------------------------------------------------------ *\
- Function : printKeyTab
- Called by : kb_keymap::print
- Purpose : print the keysyms found in the given key table. RVDK_PATCH_5
- Parameters: tabPt - keytable pointer
- buf - string where the result goes
- maxLen - length of string (including '\0')
- Returns : length of printed string.
-\* ---F------------------------------------------------------------------- */
-
-static
-int printKeyTab( kb_key *tabPt, char *buf, int maxLen )
-{
- int len, doneLen = 0;
- unsigned int ksym, mod;
-
- /* -------> Print each of the slots into buf. */
- for( ; (tabPt->code & 0xffff) != NoSymbol; tabPt++) {
- if ( maxLen <= 0 ) break;
-
- ksym = tabPt->code;
- mod = tabPt->mod & 0xffff;
-
- len = printKeysym( ksym, mod, buf, maxLen );
- if ( len <= 0 ) break;
- buf += len;
- maxLen -= len;
- doneLen += len;
-
- /* -------> Add space when possible. */
- if ( maxLen > 0 ) {
- *buf++ = ' ';
- *buf = '\0';
- maxLen--;
- doneLen++;
- }
- }
- return doneLen;
-}