Patch 05
This commit is contained in:
parent
1e08853a8b
commit
75f480ba10
@ -147,7 +147,8 @@ void do_backspace(void)
|
||||
openfile->current_x = step_left(openfile->current->data, openfile->current_x);
|
||||
do_deletion(BACK);
|
||||
} else if (openfile->current != openfile->filetop) {
|
||||
do_left();
|
||||
openfile->current = openfile->current->prev;
|
||||
openfile->current_x = strlen(openfile->current->data);
|
||||
do_deletion(BACK);
|
||||
}
|
||||
}
|
||||
|
||||
17
src/move.c
17
src/move.c
@ -37,7 +37,13 @@ void to_first_line(void)
|
||||
void to_last_line(void)
|
||||
{
|
||||
openfile->current = openfile->filebot;
|
||||
openfile->current_x = (inhelp) ? 0 : strlen(openfile->filebot->data);
|
||||
#ifdef ENABLE_FOLDING
|
||||
if (openfile->current->folded) {
|
||||
openfile->current = get_start_of_folded_segment(openfile->current);
|
||||
openfile->current_x = 0;
|
||||
} else
|
||||
#endif
|
||||
openfile->current_x = (inhelp) ? 0 : strlen(openfile->filebot->data);
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
/* Set the last line of the screen as the target for the cursor. */
|
||||
@ -112,6 +118,15 @@ void set_proper_index_and_pww(size_t *leftedge, size_t target, bool forward)
|
||||
openfile->placewewant = *leftedge + target;
|
||||
}
|
||||
|
||||
/* Move the cursor position on the current line to the desired column */
|
||||
void move_cursor_to_proper_column(void)
|
||||
{
|
||||
size_t leftedge;
|
||||
size_t target_column;
|
||||
get_edge_and_target(&leftedge, &target_column);
|
||||
set_proper_index_and_pww(&leftedge, target_column, TRUE);
|
||||
}
|
||||
|
||||
/* Move up almost one screenful. */
|
||||
void do_page_up(void)
|
||||
{
|
||||
|
||||
@ -380,6 +380,7 @@ void do_center(void);
|
||||
#endif
|
||||
void do_left(void);
|
||||
void do_right(void);
|
||||
void move_cursor_to_proper_column(void);
|
||||
|
||||
/* Most functions in nano.c. */
|
||||
linestruct *make_new_node(linestruct *prevnode);
|
||||
|
||||
85
src/winio.c
85
src/winio.c
@ -2538,20 +2538,37 @@ void place_the_cursor(void)
|
||||
|
||||
/* Calculate how many rows the lines from edittop to current use. */
|
||||
while (line != NULL && line != openfile->current) {
|
||||
row += 1 + extra_chunks_in(line);
|
||||
#ifdef ENABLE_FOLDING
|
||||
if (line->folded) {
|
||||
line = get_end_of_folded_segment(line);
|
||||
++row;
|
||||
} else
|
||||
#endif
|
||||
row += 1 + extra_chunks_in(line);
|
||||
line = line->next;
|
||||
}
|
||||
|
||||
/* Add the number of wraps in the current line before the cursor. */
|
||||
row += get_chunk_and_edge(column, openfile->current, &leftedge);
|
||||
column -= leftedge;
|
||||
} else
|
||||
#ifdef ENABLE_FOLDING
|
||||
if (!openfile->current->folded)
|
||||
#endif
|
||||
{
|
||||
/* Add the number of wraps in the current line before the cursor. */
|
||||
row += get_chunk_and_edge(column, openfile->current, &leftedge);
|
||||
column -= leftedge;
|
||||
}
|
||||
} else
|
||||
#endif /* !NANO_TINY */
|
||||
{
|
||||
row = openfile->current->lineno - openfile->edittop->lineno;
|
||||
row = get_row_from_edittop(openfile->current);
|
||||
column -= get_page_start(column);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_FOLDING
|
||||
if (openfile->current->folded) {
|
||||
openfile->current_x = 0;
|
||||
column = 0;
|
||||
}
|
||||
#endif
|
||||
if (row < editwinrows)
|
||||
wmove(midwin, row, margin + column);
|
||||
#ifndef NANO_TINY
|
||||
@ -3048,7 +3065,14 @@ int go_back_chunks(int nrows, linestruct **line, size_t *leftedge)
|
||||
if (ISSET(SOFTWRAP)) {
|
||||
/* Recede through the requested number of chunks. */
|
||||
for (i = nrows; i > 0; i--) {
|
||||
size_t chunk = chunk_for(*leftedge, *line);
|
||||
size_t chunk;
|
||||
|
||||
#ifdef ENABLE_FOLDING
|
||||
if ((*line)->folded)
|
||||
chunk = 0;
|
||||
else
|
||||
#endif
|
||||
chunk = chunk_for(*leftedge, *line);
|
||||
|
||||
*leftedge = 0;
|
||||
|
||||
@ -3062,11 +3086,15 @@ int go_back_chunks(int nrows, linestruct **line, size_t *leftedge)
|
||||
*line = get_prev_visible_line(*line);
|
||||
*leftedge = HIGHEST_POSITIVE;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_FOLDING
|
||||
if ((*line)->folded)
|
||||
*leftedge = 0;
|
||||
else
|
||||
#endif
|
||||
if (*leftedge == HIGHEST_POSITIVE)
|
||||
*leftedge = leftedge_for(*leftedge, *line);
|
||||
} else
|
||||
#endif
|
||||
#endif /* !NANO_TINY */
|
||||
{
|
||||
linestruct *prev = get_prev_visible_line(*line);
|
||||
for (i = nrows; i > 0 && prev != NULL; i--) {
|
||||
@ -3093,6 +3121,14 @@ int go_forward_chunks(int nrows, linestruct **line, size_t *leftedge)
|
||||
|
||||
/* Advance through the requested number of chunks. */
|
||||
for (i = nrows; i > 0; i--) {
|
||||
#ifdef ENABLE_FOLDING
|
||||
if ((*line)->folded) {
|
||||
*line = get_next_visible_line(*line);
|
||||
current_leftedge = 0;
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool end_of_line = FALSE;
|
||||
|
||||
current_leftedge = get_softwrap_breakpoint((*line)->data,
|
||||
@ -3113,7 +3149,7 @@ int go_forward_chunks(int nrows, linestruct **line, size_t *leftedge)
|
||||
if (i < nrows)
|
||||
*leftedge = current_leftedge;
|
||||
} else
|
||||
#endif
|
||||
#endif /* !NANO_TINY */
|
||||
{
|
||||
linestruct *next = get_next_visible_line(*line);
|
||||
for (i = nrows; i > 0 && next != NULL; i--) {
|
||||
@ -3240,7 +3276,12 @@ void edit_scroll(bool direction)
|
||||
if (thebar)
|
||||
draw_scrollbar();
|
||||
|
||||
if (ISSET(SOFTWRAP)) {
|
||||
#ifdef ENABLE_FOLDING
|
||||
if (ISSET(SOFTWRAP) && !line->folded)
|
||||
#else
|
||||
if (ISSET(SOFTWRAP))
|
||||
#endif
|
||||
{
|
||||
/* Compensate for the earlier chunks of a softwrapped line. */
|
||||
nrows += chunk_for(leftedge, line);
|
||||
|
||||
@ -3252,9 +3293,10 @@ void edit_scroll(bool direction)
|
||||
|
||||
/* Draw new content on the blank row (and on the bordering row too
|
||||
* when it was deemed necessary). */
|
||||
int row = get_row_from_edittop(line);
|
||||
while (nrows > 0 && line != NULL) {
|
||||
nrows -= update_line(line, (line == openfile->current) ?
|
||||
openfile->current_x : 0);
|
||||
nrows -= update_line_at(line, (line == openfile->current) ?
|
||||
openfile->current_x : 0, row++);
|
||||
line = get_next_visible_line(line);
|
||||
}
|
||||
}
|
||||
@ -3452,8 +3494,7 @@ bool current_is_below_screen(void)
|
||||
leftedge < leftedge_for(xplustabs(), openfile->current))));
|
||||
} else
|
||||
#endif
|
||||
return (openfile->current->lineno >=
|
||||
openfile->edittop->lineno + editwinrows - SHIM);
|
||||
return (get_row_from_edittop(openfile->current) >= editwinrows - SHIM);
|
||||
}
|
||||
|
||||
/* Return TRUE if current[current_x] is outside the viewport. */
|
||||
@ -3481,14 +3522,16 @@ void edit_redraw(linestruct *old_current, update_type manner)
|
||||
/* If the mark is on, update all lines between old_current and current. */
|
||||
if (openfile->mark) {
|
||||
linestruct *line = old_current;
|
||||
|
||||
int row = get_row_from_edittop(line);
|
||||
while (line != openfile->current) {
|
||||
update_line(line, 0);
|
||||
update_line_at(line, 0, row);
|
||||
|
||||
if (line->lineno > openfile->current->lineno) {
|
||||
line = get_prev_visible_line(line);
|
||||
--row;
|
||||
} else {
|
||||
line = get_next_visible_line(line);
|
||||
++row;
|
||||
}
|
||||
}
|
||||
} else
|
||||
@ -3544,9 +3587,13 @@ void edit_refresh(void)
|
||||
|
||||
while (row < editwinrows && line != NULL) {
|
||||
if (line == openfile->current)
|
||||
row += update_line(line, openfile->current_x);
|
||||
row += update_line_at(line, openfile->current_x, row);
|
||||
else
|
||||
row += update_line(line, 0);
|
||||
row += update_line_at(line, 0, row);
|
||||
|
||||
#ifdef ENABLE_FOLDING
|
||||
line = get_end_of_folded_segment(line);
|
||||
#endif
|
||||
line = line->next;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user