Beispiel #1
0
/* After a resize, clear all the lines that were occupied by prompt + line buffer before the resize */
static
void wipe_textarea(struct winsize *old_winsize)
{
    int point, lineheight, linelength, cursor_height, i, promptlength;
    if (!prompt_is_single_line()) {       /* Don't need to do anything in horizontal_scroll_mode  */
        promptlength = colourless_strlen((saved_rl_state.cooked_prompt ? saved_rl_state.cooked_prompt:  saved_rl_state.raw_prompt), NULL, old_winsize -> ws_col);
        linelength = (within_line_edit ? strlen(rl_line_buffer) : 0) + promptlength;
        point = (within_line_edit ? rl_point : 0) + promptlength;
        assert(old_winsize -> ws_col > 0);
        lineheight = (linelength == 0 ? 0 : (1 + (max(point, (linelength - 1)) / old_winsize -> ws_col)));
        if (lineheight > 1 && term_cursor_up != NULL && term_cursor_down != NULL) {
            /* i.e. if we have multiple rows displayed, and we can clean them up first */
            cr();
            cursor_height = point / old_winsize -> ws_col;    /* cursor is still on old line */
            DPRINTF2(DEBUG_SIGNALS, "lineheight: %d, cursor_height: %d", lineheight, cursor_height);
            for (i = 1 + cursor_height; i < lineheight; i++)
                curs_down();    /* ...move it down to last line */
            for (i = lineheight; i > 1; i--) {        /* go up again, erasing every line */
                clear_line();
                curs_up();
            }
        }
        clear_line();
        cr();
    }
}
Beispiel #2
0
void
move_cursor_to_start_of_prompt(int erase)
{
  int termwidth = winsize.ws_col;
  int promptlen_on_screen, number_of_lines_in_prompt, curpos, count;
  int cooked = (saved_rl_state.cooked_prompt != NULL);
  
  DPRINTF2(DEBUG_READLINE,"prompt_is_still_uncooked: %d, impatient_prompt: %d", prompt_is_still_uncooked, impatient_prompt);
  if (prompt_is_still_uncooked && ! impatient_prompt)
    return; /* @@@ is this necessary ?*/

	
  promptlen_on_screen =  colourless_strlen_unmarked(saved_rl_state.cooked_prompt ? saved_rl_state.cooked_prompt : saved_rl_state.raw_prompt, termwidth);
  curpos = (within_line_edit ? 1 : 0); /* if the user has pressed a key the cursor will be 1 past the current prompt */
  assert(termwidth > 0); 
  number_of_lines_in_prompt = 1 +  ((promptlen_on_screen + curpos -1) / termwidth); /* integer arithmetic! (e.g. 171/80 = 2) */
  cr(); 
  for (count = 0; count < number_of_lines_in_prompt -1; count++) {
    if (erase)
      clear_line();
    curs_up();
  } 
  clear_line();
  DPRINTF4(DEBUG_READLINE,"moved cursor up %d lines (erase = %d, len=%d, cooked=%d)", number_of_lines_in_prompt - 1, erase, promptlen_on_screen, cooked); 
}       
Beispiel #3
0
/*** Move cursor to the left ***/
void curs_left(Project p, BYTE word)
{
	register LINE *prev;
	if(p->nbc != 0)
	{
		inv_curs(p,FALSE);
		if(word) p->nbc = backward_word(p->edited, p->nbc-1); else p->nbc--;
		p->nbrwc = p->nbrc = x2pos(p->edited, p->nbc);
		p->xcurs = (p->nbrc-p->left_pos) * XSIZE + gui.left;

		/* Is it gone outside edit area? */
		if(p->nbrc<p->left_pos)
			scroll_xy(p, adjust_leftpos(p, -gui.xstep), p->top_line, FALSE);

		if(p->ccp.select) move_selection(p, p->nbrc, p->nbl);
		inv_curs(p,TRUE);
		draw_info( p );

	}	else if( ( prev = p->edited->prev ) ) {
		/* jump up */
		p->nbrwc = x2pos(prev, prev->size);
		curs_up(p);
	}
}