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);
|
openfile->current_x = step_left(openfile->current->data, openfile->current_x);
|
||||||
do_deletion(BACK);
|
do_deletion(BACK);
|
||||||
} else if (openfile->current != openfile->filetop) {
|
} else if (openfile->current != openfile->filetop) {
|
||||||
do_left();
|
openfile->current = openfile->current->prev;
|
||||||
|
openfile->current_x = strlen(openfile->current->data);
|
||||||
do_deletion(BACK);
|
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)
|
void to_last_line(void)
|
||||||
{
|
{
|
||||||
openfile->current = openfile->filebot;
|
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();
|
openfile->placewewant = xplustabs();
|
||||||
|
|
||||||
/* Set the last line of the screen as the target for the cursor. */
|
/* 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;
|
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. */
|
/* Move up almost one screenful. */
|
||||||
void do_page_up(void)
|
void do_page_up(void)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -380,6 +380,7 @@ void do_center(void);
|
|||||||
#endif
|
#endif
|
||||||
void do_left(void);
|
void do_left(void);
|
||||||
void do_right(void);
|
void do_right(void);
|
||||||
|
void move_cursor_to_proper_column(void);
|
||||||
|
|
||||||
/* Most functions in nano.c. */
|
/* Most functions in nano.c. */
|
||||||
linestruct *make_new_node(linestruct *prevnode);
|
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. */
|
/* Calculate how many rows the lines from edittop to current use. */
|
||||||
while (line != NULL && line != openfile->current) {
|
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;
|
line = line->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add the number of wraps in the current line before the cursor. */
|
#ifdef ENABLE_FOLDING
|
||||||
row += get_chunk_and_edge(column, openfile->current, &leftedge);
|
if (!openfile->current->folded)
|
||||||
column -= leftedge;
|
|
||||||
} else
|
|
||||||
#endif
|
#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);
|
column -= get_page_start(column);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_FOLDING
|
||||||
|
if (openfile->current->folded) {
|
||||||
|
openfile->current_x = 0;
|
||||||
|
column = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (row < editwinrows)
|
if (row < editwinrows)
|
||||||
wmove(midwin, row, margin + column);
|
wmove(midwin, row, margin + column);
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
@ -3048,7 +3065,14 @@ int go_back_chunks(int nrows, linestruct **line, size_t *leftedge)
|
|||||||
if (ISSET(SOFTWRAP)) {
|
if (ISSET(SOFTWRAP)) {
|
||||||
/* Recede through the requested number of chunks. */
|
/* Recede through the requested number of chunks. */
|
||||||
for (i = nrows; i > 0; i--) {
|
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;
|
*leftedge = 0;
|
||||||
|
|
||||||
@ -3062,11 +3086,15 @@ int go_back_chunks(int nrows, linestruct **line, size_t *leftedge)
|
|||||||
*line = get_prev_visible_line(*line);
|
*line = get_prev_visible_line(*line);
|
||||||
*leftedge = HIGHEST_POSITIVE;
|
*leftedge = HIGHEST_POSITIVE;
|
||||||
}
|
}
|
||||||
|
#ifdef ENABLE_FOLDING
|
||||||
|
if ((*line)->folded)
|
||||||
|
*leftedge = 0;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
if (*leftedge == HIGHEST_POSITIVE)
|
if (*leftedge == HIGHEST_POSITIVE)
|
||||||
*leftedge = leftedge_for(*leftedge, *line);
|
*leftedge = leftedge_for(*leftedge, *line);
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif /* !NANO_TINY */
|
||||||
{
|
{
|
||||||
linestruct *prev = get_prev_visible_line(*line);
|
linestruct *prev = get_prev_visible_line(*line);
|
||||||
for (i = nrows; i > 0 && prev != NULL; i--) {
|
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. */
|
/* Advance through the requested number of chunks. */
|
||||||
for (i = nrows; i > 0; i--) {
|
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;
|
bool end_of_line = FALSE;
|
||||||
|
|
||||||
current_leftedge = get_softwrap_breakpoint((*line)->data,
|
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)
|
if (i < nrows)
|
||||||
*leftedge = current_leftedge;
|
*leftedge = current_leftedge;
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif /* !NANO_TINY */
|
||||||
{
|
{
|
||||||
linestruct *next = get_next_visible_line(*line);
|
linestruct *next = get_next_visible_line(*line);
|
||||||
for (i = nrows; i > 0 && next != NULL; i--) {
|
for (i = nrows; i > 0 && next != NULL; i--) {
|
||||||
@ -3240,7 +3276,12 @@ void edit_scroll(bool direction)
|
|||||||
if (thebar)
|
if (thebar)
|
||||||
draw_scrollbar();
|
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. */
|
/* Compensate for the earlier chunks of a softwrapped line. */
|
||||||
nrows += chunk_for(leftedge, 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
|
/* Draw new content on the blank row (and on the bordering row too
|
||||||
* when it was deemed necessary). */
|
* when it was deemed necessary). */
|
||||||
|
int row = get_row_from_edittop(line);
|
||||||
while (nrows > 0 && line != NULL) {
|
while (nrows > 0 && line != NULL) {
|
||||||
nrows -= update_line(line, (line == openfile->current) ?
|
nrows -= update_line_at(line, (line == openfile->current) ?
|
||||||
openfile->current_x : 0);
|
openfile->current_x : 0, row++);
|
||||||
line = get_next_visible_line(line);
|
line = get_next_visible_line(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3452,8 +3494,7 @@ bool current_is_below_screen(void)
|
|||||||
leftedge < leftedge_for(xplustabs(), openfile->current))));
|
leftedge < leftedge_for(xplustabs(), openfile->current))));
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
return (openfile->current->lineno >=
|
return (get_row_from_edittop(openfile->current) >= editwinrows - SHIM);
|
||||||
openfile->edittop->lineno + editwinrows - SHIM);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return TRUE if current[current_x] is outside the viewport. */
|
/* 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 the mark is on, update all lines between old_current and current. */
|
||||||
if (openfile->mark) {
|
if (openfile->mark) {
|
||||||
linestruct *line = old_current;
|
linestruct *line = old_current;
|
||||||
|
int row = get_row_from_edittop(line);
|
||||||
while (line != openfile->current) {
|
while (line != openfile->current) {
|
||||||
update_line(line, 0);
|
update_line_at(line, 0, row);
|
||||||
|
|
||||||
if (line->lineno > openfile->current->lineno) {
|
if (line->lineno > openfile->current->lineno) {
|
||||||
line = get_prev_visible_line(line);
|
line = get_prev_visible_line(line);
|
||||||
|
--row;
|
||||||
} else {
|
} else {
|
||||||
line = get_next_visible_line(line);
|
line = get_next_visible_line(line);
|
||||||
|
++row;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
@ -3544,9 +3587,13 @@ void edit_refresh(void)
|
|||||||
|
|
||||||
while (row < editwinrows && line != NULL) {
|
while (row < editwinrows && line != NULL) {
|
||||||
if (line == openfile->current)
|
if (line == openfile->current)
|
||||||
row += update_line(line, openfile->current_x);
|
row += update_line_at(line, openfile->current_x, row);
|
||||||
else
|
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;
|
line = line->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user