コード例 #1
0
ファイル: editline.c プロジェクト: jakubpawlo/editline
/* Skip forward to start of next word. If @move is set we also move the cursor. */
static el_status_t do_forward(el_status_t move)
{
    int         i;
    char        *p;

    i = 0;
    do {
        p = &rl_line_buffer[rl_point];

	/* Skip to end of word, if inside a word. */
        for (; rl_point < rl_end && is_alpha_num(p[0]); rl_point++, p++)
            if (move == CSmove)
                right(CSstay);

	/* Skip to next word, or skip leading white space if outside a word. */
        for ( ; rl_point < rl_end && (p[0] == ' ' || !is_alpha_num(p[0])); rl_point++, p++)
            if (move == CSmove)
                right(CSstay);

        if (rl_point == rl_end)
            break;
    } while (++i < Repeat);

    return CSstay;
}
コード例 #2
0
char * get_last_word(char * str){
	if (str == NULL)
		return NULL;

	int index, space_index = 0, sec_index = 0, str_len;
	for (index = 0; str[index] != '\0'; index++)
	{
		if (str[index] == 32 && is_alpha_num(str[index + 1]))
		{
			space_index = index + 1;
		}
	}
	str_len = index;
	char *last_word = (char *)malloc(sizeof(char)*(index - space_index + 1));
	if (is_alpha_num(str[space_index]))
	{
		for (index = space_index; str[index] != '\0'; index++)
		{
			if (str[index] != 32)
			{
				last_word[sec_index] = str[index];
				sec_index++;
			}

		}
		last_word[str_len - (index - sec_index)] = NULL;
	}
	else
		last_word[space_index] = NULL;

	return last_word;
}
コード例 #3
0
ファイル: editline.c プロジェクト: jakubpawlo/editline
static el_status_t bk_word(void)
{
    int         i;
    char        *p;

    i = 0;
    do {
        for (p = &rl_line_buffer[rl_point]; p > rl_line_buffer && !is_alpha_num(p[-1]); p--)
            left(CSmove);

        for (; p > rl_line_buffer && !isblank(p[-1]) && is_alpha_num(p[-1]); p--)
            left(CSmove);

        if (rl_point == 0)
            break;
    } while (++i < Repeat);

    return CSstay;
}