int rl_forward_word(t_rl_reader *r, long key) { (void)key; while (r->cursor < r->end && !ft_isspace(r->line[r->cursor])) rl_forward_char(r, 0); while (r->cursor < r->end && ft_isspace(r->line[r->cursor])) rl_forward_char(r, 0); return (0); }
static int _rl_vi_change_mbchar_case(int count) { wchar_t wc; char mb[MB_LEN_MAX + 1]; int mb_len; mbstate_t ps; memset(&ps, 0, sizeof(mbstate_t)); if (_rl_adjust_point(rl_line_buffer, rl_point, &ps) > 0) count--; while (count-- && (rl_point < rl_end)) { mbrtowc(&wc, (rl_line_buffer + rl_point), (size_t)(rl_end - rl_point), &ps); if (iswupper(wc)) wc = towlower(wc); else if (iswlower(wc)) wc = towupper(wc); else { /* Just skip over chars neither upper nor lower case */ rl_forward_char(1, 0); continue; } /* Vi is kind of strange here. */ if (wc) { mb_len = wctomb(mb, wc); if (mb_len >= 0) mb[mb_len] = '\0'; rl_begin_undo_group(); rl_delete(1, 0); rl_insert_text(mb); rl_end_undo_group(); rl_vi_check(); } else rl_forward_char(1, 0); } return 0; }
int rl_vi_change_case(int count, int ignore) { char c = 0; /* Do NOT try this on an empty line: */ if (rl_point >= rl_end) return (0); #if defined(HANDLE_MULTIBYTE) if ((MB_CUR_MAX > 1) && (rl_byte_oriented == 0)) return (_rl_vi_change_mbchar_case(count)); #endif while (count-- && (rl_point < rl_end)) { if (_rl_uppercase_p(rl_line_buffer[rl_point])) c = (char)_rl_to_lower(rl_line_buffer[rl_point]); else if (_rl_lowercase_p(rl_line_buffer[rl_point])) c = (char)_rl_to_upper(rl_line_buffer[rl_point]); else { /* Just skip over characters neither upper nor lower case. */ rl_forward_char (1, c); continue; } /* Vi is kind of strange here. */ if (c) { rl_begin_undo_group (); rl_delete (1, c); _rl_insert_char (1, c); rl_end_undo_group (); rl_vi_check (); } else rl_forward_char (1, c); } return (0); }
int rl_vi_append_mode(int count, int key) { if (rl_point < rl_end) { if (MB_CUR_MAX == 1 || rl_byte_oriented) rl_point++; else { int point = rl_point; rl_forward_char (1, key); if (point == rl_point) rl_point = rl_end; } } rl_vi_insertion_mode (1, key); return (0); }