Changeset d07af84 for keypress.c
- Timestamp:
- Mar 24, 2011, 4:10:28 PM (14 years ago)
- Branches:
- master, release-1.10, release-1.8, release-1.9
- Children:
- 47e0a6a
- Parents:
- 45e2c95
- git-author:
- David Benjamin <davidben@mit.edu> (03/11/11 10:24:36)
- git-committer:
- David Benjamin <davidben@mit.edu> (03/24/11 16:10:28)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
keypress.c
r369a7f0 rd07af84 129 129 /* OWL_META is definied in owl.h */ 130 130 131 /* returns 0 on success */ 132 int owl_keypress_tostring(int j, int esc, char *buff, int bufflen) 131 char *owl_keypress_tostring(int j, int esc) 133 132 { 134 char kb[64], kb2[2];133 GString *kb; 135 134 const struct _owl_keypress_specialmap *sm; 136 135 137 *kb = '\0';136 kb = g_string_new(""); 138 137 for (sm = specialmap; sm->kj!=0; sm++) { 139 138 if (j == OWL_META(sm->kj) || (esc && j == sm->kj)) { 140 strcat(kb, "M-");141 strcat(kb, sm->ks);139 g_string_append(kb, "M-"); 140 g_string_append(kb, sm->ks); 142 141 break; 143 142 } else if (j == sm->kj) { 144 strcat(kb, sm->ks);143 g_string_append(kb, sm->ks); 145 144 break; 146 145 } 147 146 } 148 if (! *kb) {147 if (!kb->str[0]) { 149 148 if (j & OWL_META(0)) { 150 strcat(kb, "M-");149 g_string_append(kb, "M-"); 151 150 j &= ~OWL_META(0); 152 151 } 153 152 if ((OWL_CTRL(j) == j)) { 154 strcat(kb, "C-");153 g_string_append(kb, "C-"); 155 154 j |= 0x40; 156 155 if (isupper(j)) j = tolower(j); … … 158 157 } 159 158 if (isascii(j)) { 160 kb2[0] = j; 161 kb2[1] = 0; 162 strcat(kb, kb2); 159 g_string_append_c(kb, j); 163 160 } 164 161 165 162 } 166 if (! *kb) {163 if (!kb->str[0]) { 167 164 /* not a valid key */ 168 strncpy(buff, "INVALID", bufflen); 169 return(-1); 170 } 171 strncpy(buff, kb, bufflen); 172 return(0); 165 g_string_free(kb, true); 166 return NULL; 167 } 168 return g_string_free(kb, false); 173 169 } 174 170
Note: See TracChangeset
for help on using the changeset viewer.