/* 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(); } }
/*** Split line ***/ void split_curline( Project p ) { if( split_line(&p->undo, p->edited, p->nbc, &p->nbrwc, prefs.auto_indent) ) { register LINE *ln = p->edited; /* Redraw line where cursor is */ Move(RP,gui.left,p->ycurs); write_text(p, ln); /* A line has been added */ p->max_lines++; p->nbrwc = x2pos(ln,p->nbrwc); /* Scroll manually the display and redraw new line */ if(p->ycurs < gui.botcurs) { ScrollRaster(RP, 0, -YSIZE, gui.left,p->ycurs+YSIZE-BASEL,gui.right,gui.bottom); Move(RP,gui.left,p->ycurs+YSIZE); ln = ln->next; write_text(p, ln); prop_adj(p); } /* Go down one line */ curs_down(p); } else ThrowError(Wnd, ErrMsg(ERR_NOMEM)); }
/*** One pos right ***/ void curs_right(Project p, BYTE word) { if(p->nbc < p->edited->size) { inv_curs(p,FALSE); if(word) p->nbc = forward_word(p->edited, p->nbc); else p->nbc++; p->nbrwc = p->nbrc = x2pos(p->edited, p->nbc); p->xcurs = (p->nbrc-p->left_pos) * XSIZE + gui.left; /* Move the cursor */ /* Is it gone outside edit area? */ if(p->nbrc>=p->left_pos+gui.nbcol) 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(p->edited->next) { /* jump down to next line */ p->nbrwc = 0; curs_down(p); } }