Example #1
0
static void backspace()
{
	int i;

	if( len == 0 || offset == 0 )
	{
		return;
	}

	memmove(line+offset-1, line+offset, STR_LINE_SIZE-(offset+1));

	len--;
	offset--;

	//fprintf(stdout,"\r%s", line);

	term_cursor_left();

	for(i = offset; i < len; i++)
	{
		term_putc(line[i]);
	}

	term_putc(' ');

	for(i = 0; i < len-offset; i++)
	{
		term_cursor_left();
	}

	term_cursor_left();
}
Example #2
0
/*
 * input_transpose_characters: swaps the positions of the two characters
 * before the cursor position 
 */
void input_transpose_characters(char unused, char *not_used)
{
    cursor_to_input();
    if (current_screen->buffer_pos > MIN_POS) {
	u_char c1[3] = { 0 };
	int pos, end_of_line = 0;

	if (THIS_CHAR)
	    pos = THIS_POS;
	else if (strlen(get_input()) > MIN_POS + 2) {
	    pos = THIS_CHAR - 1;
	    end_of_line = 1;
	} else
	    return;

	c1[0] = INPUT_BUFFER[pos];
	c1[1] = INPUT_BUFFER[pos] = INPUT_BUFFER[pos - 1];
	INPUT_BUFFER[pos - 1] = c1[0];
	term_cursor_left();
	if (end_of_line)
	    term_cursor_left();

	term_putchar(c1[0]);
	term_putchar(c1[1]);
	if (!end_of_line)
	    term_cursor_left();
	update_input(NO_UPDATE);
    }
}
Example #3
0
/* input_backspace: does a backspace in the input buffer */
void input_backspace(char key, char *blah)
{
    cursor_to_input();
    if (THIS_POS > MIN_POS) {
	char *ptr = NULL;
	int pos;

	malloc_strcpy(&ptr, &(THIS_CHAR));
	strcpy(&(PREV_CHAR), ptr);
	new_free(&ptr);
	THIS_POS--;
	term_cursor_left();
	if (THIS_CHAR) {
	    if (term_delete())
		update_input(UPDATE_FROM_CURSOR);
	    {
		pos = str_start + term_cols - 1;
		pos += count_ansi(&(current_screen->input_buffer[str_start]), zone);
		if (pos < strlen(INPUT_BUFFER)) {
		    term_move_cursor(term_cols - 1, input_line);
		    term_putchar(INPUT_BUFFER[pos]);
		}
		update_input(UPDATE_JUST_CURSOR);
	    }
	} else {
	    term_putchar(' ');
	    term_cursor_left();
	    update_input(NO_UPDATE);
	}
    }
    in_completion = STATE_NORMAL;
    *new_nick = 0;
}
Example #4
0
static void append(char c)
{
	int i;

	//fprintf(stderr, "c = %d\n", c);

	if( len >= STR_LINE_SIZE-1 )
	{
		return;
	}

	memmove(line+offset+1, line+offset, STR_LINE_SIZE-(offset+1));

	line[offset++] = c;
	len++;

	for(i = offset-1; i < len; i++)
	{
		term_putc(line[i]);
	}

	for(i = 0; i < len-offset; i++)
	{
		term_cursor_left();
	}
}
Example #5
0
static void move_left()
{
	if( offset == 0 )
	{
		return;
	}

	offset--;
	term_cursor_left();
	//printf("c = LEFT\n");

}
Example #6
0
/* input_move_cursor: moves the cursor left or right... got it? */
void input_move_cursor(int dir)
{
    cursor_to_input();
    if (dir) {
	if (THIS_CHAR) {
	    THIS_POS++;
	    term_cursor_right();
	}
    } else {
	if (THIS_POS > MIN_POS) {
	    THIS_POS--;
	    term_cursor_left();
	}
    }
    update_input(NO_UPDATE);
}