Changeset 45e2c95
- Timestamp:
- Mar 24, 2011, 4:09:22 PM (14 years ago)
- Branches:
- master, release-1.10, release-1.8, release-1.9
- Children:
- d07af84
- Parents:
- b13daa0
- git-author:
- David Benjamin <davidben@mit.edu> (03/10/11 15:45:00)
- git-committer:
- David Benjamin <davidben@mit.edu> (03/24/11 16:09:22)
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
keybinding.c
rb13daa0 r45e2c95 85 85 } 86 86 87 /* returns 0 on success */ 88 int owl_keybinding_stack_tostring(int *j, int len, char *buff, int bufflen) 87 char *owl_keybinding_stack_tostring(int *j, int len) 89 88 { 90 char *pos = buff;91 int rem = bufflen;92 int i, n;89 GString *string; 90 char keypress[64]; /* TODO: don't hard-code a value here. */ 91 int i; 93 92 94 for (i=0; i < len; i++) { 95 owl_keypress_tostring(j[i], 0, pos, rem-1); 96 if (i < len - 1) strcat(pos, " "); 97 n = strlen(pos); 98 pos += n; 99 rem -= n; 93 string = g_string_new(""); 94 for (i = 0; i < len; i++) { 95 owl_keypress_tostring(j[i], 0, keypress, sizeof(keypress)); 96 g_string_append(string, keypress); 97 if (i < len - 1) g_string_append_c(string, ' '); 100 98 } 101 return 0;99 return g_string_free(string, false); 102 100 } 103 101 104 /* returns 0 on success */ 105 int owl_keybinding_tostring(const owl_keybinding *kb, char *buff, int bufflen) 102 char *owl_keybinding_tostring(const owl_keybinding *kb) 106 103 { 107 return owl_keybinding_stack_tostring(kb->keys, kb->len , buff, bufflen);104 return owl_keybinding_stack_tostring(kb->keys, kb->len); 108 105 } 109 106 -
keymap.c
rb13daa0 r45e2c95 144 144 nbindings = owl_list_get_size(&km->bindings); 145 145 for (i=0; i<nbindings; i++) { 146 char buff[100];146 char *kbstr; 147 147 const owl_cmd *cmd; 148 148 const char *tmpdesc, *desc = ""; 149 149 150 150 kb = owl_list_get_element(&km->bindings, i); 151 owl_keybinding_tostring(kb, buff, 100);151 kbstr = owl_keybinding_tostring(kb); 152 152 owl_fmtext_append_normal(fm, OWL_TABSTR); 153 owl_fmtext_append_normal(fm, buff); 154 owl_fmtext_append_spaces(fm, 11-strlen(buff)); 153 owl_fmtext_append_normal(fm, kbstr); 154 owl_fmtext_append_spaces(fm, 11-strlen(kbstr)); 155 g_free(kbstr); 155 156 owl_fmtext_append_normal(fm, " - "); 156 157 if (kb->desc && *kb->desc) { … … 313 314 void owl_keyhandler_invalidkey(owl_keyhandler *kh) 314 315 { 315 char kbbuff[500]; 316 owl_keybinding_stack_tostring(kh->kpstack, kh->kpstackpos+1, kbbuff, 500); 316 char *kbbuff = owl_keybinding_stack_tostring(kh->kpstack, kh->kpstackpos+1); 317 317 owl_function_makemsg("'%s' is not a valid key in this context.", kbbuff); 318 g_free(kbbuff); 318 319 owl_keyhandler_reset(kh); 319 320 }
Note: See TracChangeset
for help on using the changeset viewer.