MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / terminal_bind_arrow

Function terminal_bind_arrow

extern/editline/src/terminal.c:1152–1212  ·  view source on GitHub ↗

terminal_bind_arrow(): * Bind the arrow keys */

Source from the content-addressed store, hash-verified

1150 * Bind the arrow keys
1151 */
1152protected void
1153terminal_bind_arrow(EditLine *el)
1154{
1155 el_action_t *map;
1156 const el_action_t *dmap;
1157 int i, j;
1158 char *p;
1159 funckey_t *arrow = el->el_terminal.t_fkey;
1160
1161 /* Check if the components needed are initialized */
1162 if (el->el_terminal.t_buf == NULL || el->el_map.key == NULL)
1163 return;
1164
1165 map = el->el_map.type == MAP_VI ? el->el_map.alt : el->el_map.key;
1166 dmap = el->el_map.type == MAP_VI ? el->el_map.vic : el->el_map.emacs;
1167
1168 terminal_reset_arrow(el);
1169
1170 for (i = 0; i < A_K_NKEYS; i++) {
1171 Char wt_str[VISUAL_WIDTH_MAX];
1172 Char *px;
1173 size_t n;
1174
1175 p = el->el_terminal.t_str[arrow[i].key];
1176 if (!p || !*p)
1177 continue;
1178 for (n = 0; n < VISUAL_WIDTH_MAX && p[n]; ++n)
1179 wt_str[n] = p[n];
1180 while (n < VISUAL_WIDTH_MAX)
1181 wt_str[n++] = '\0';
1182 px = wt_str;
1183 j = (unsigned char) *p;
1184 /*
1185 * Assign the arrow keys only if:
1186 *
1187 * 1. They are multi-character arrow keys and the user
1188 * has not re-assigned the leading character, or
1189 * has re-assigned the leading character to be
1190 * ED_SEQUENCE_LEAD_IN
1191 * 2. They are single arrow keys pointing to an
1192 * unassigned key.
1193 */
1194 if (arrow[i].type == XK_NOD)
1195 keymacro_clear(el, map, px);
1196 else {
1197 if (p[1] && (dmap[j] == map[j] ||
1198 map[j] == ED_SEQUENCE_LEAD_IN)) {
1199 keymacro_add(el, px, &arrow[i].fun,
1200 arrow[i].type);
1201 map[j] = ED_SEQUENCE_LEAD_IN;
1202 } else if (map[j] == ED_UNASSIGNED) {
1203 keymacro_clear(el, map, px);
1204 if (arrow[i].type == XK_CMD)
1205 map[j] = arrow[i].fun.cmd;
1206 else
1207 keymacro_add(el, px, &arrow[i].fun,
1208 arrow[i].type);
1209 }

Callers 3

map_init_viFunction · 0.85
map_init_emacsFunction · 0.85
terminal_setFunction · 0.85

Calls 3

terminal_reset_arrowFunction · 0.85
keymacro_clearFunction · 0.85
keymacro_addFunction · 0.85

Tested by

no test coverage detected