move the paragraph-searching functions to move.c, as they're movement

functions, and make them call check_statusblank() too; also reorder some
other movement functions


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2902 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
David Lawrence Ramsey 2005-07-20 19:24:11 +00:00
parent 38f70a5edd
commit ca62f9fa2b
4 changed files with 120 additions and 107 deletions

View File

@ -94,6 +94,10 @@ CVS code -
do_first_line(), do_last_line()
- Simplify by only using edit_redraw(), and also make them call
check_statusblank(). (DLR)
do_para_begin(), do_para_begin_void(), do_para_end(),
do_para_end_void()
- Move here from nano.c, as they're movement functions, and also
make them call check_statusblank().
do_page_up(), do_page_down()
- If there's less than a page of text onscreen, just call
do_(first|last)_line(). (DLR)

View File

@ -59,48 +59,6 @@ void do_last_line(void)
edit_redraw(current_save, pww_save);
}
void do_home(void)
{
size_t pww_save = openfile->placewewant;
check_statusblank();
#ifndef NANO_SMALL
if (ISSET(SMART_HOME)) {
size_t current_x_save = openfile->current_x;
openfile->current_x = indent_length(openfile->current->data);
if (openfile->current_x == current_x_save ||
openfile->current->data[openfile->current_x] == '\0')
openfile->current_x = 0;
openfile->placewewant = xplustabs();
} else {
#endif
openfile->current_x = 0;
openfile->placewewant = 0;
#ifndef NANO_SMALL
}
#endif
if (need_horizontal_update(pww_save))
update_line(openfile->current, openfile->current_x);
}
void do_end(void)
{
size_t pww_save = openfile->placewewant;
check_statusblank();
openfile->current_x = strlen(openfile->current->data);
openfile->placewewant = xplustabs();
if (need_horizontal_update(pww_save))
update_line(openfile->current, openfile->current_x);
}
void do_page_up(void)
{
int i;
@ -182,6 +140,114 @@ void do_page_down(void)
edit_scroll(DOWN, editwinrows - 2);
}
#ifndef DISABLE_JUSTIFY
/* Move up to the last beginning-of-paragraph line before the current
* line. */
void do_para_begin(bool allow_update)
{
const filestruct *current_save = openfile->current;
const size_t pww_save = openfile->placewewant;
check_statusblank();
openfile->current_x = 0;
openfile->placewewant = 0;
if (openfile->current->prev != NULL) {
do {
openfile->current = openfile->current->prev;
openfile->current_y--;
} while (!begpar(openfile->current));
}
if (allow_update)
edit_redraw(current_save, pww_save);
}
void do_para_begin_void(void)
{
do_para_begin(TRUE);
}
/* Move down to the end of a paragraph, then one line farther. A line
* is the last line of a paragraph if it is in a paragraph, and the next
* line either is a beginning-of-paragraph line or isn't in a
* paragraph. */
void do_para_end(bool allow_update)
{
const filestruct *const current_save = openfile->current;
const size_t pww_save = openfile->placewewant;
check_statusblank();
openfile->current_x = 0;
openfile->placewewant = 0;
while (openfile->current->next != NULL && !inpar(openfile->current))
openfile->current = openfile->current->next;
while (openfile->current->next != NULL &&
inpar(openfile->current->next) &&
!begpar(openfile->current->next)) {
openfile->current = openfile->current->next;
openfile->current_y++;
}
if (openfile->current->next != NULL)
openfile->current = openfile->current->next;
if (allow_update)
edit_redraw(current_save, pww_save);
}
void do_para_end_void(void)
{
do_para_end(TRUE);
}
#endif /* !DISABLE_JUSTIFY */
void do_home(void)
{
size_t pww_save = openfile->placewewant;
check_statusblank();
#ifndef NANO_SMALL
if (ISSET(SMART_HOME)) {
size_t current_x_save = openfile->current_x;
openfile->current_x = indent_length(openfile->current->data);
if (openfile->current_x == current_x_save ||
openfile->current->data[openfile->current_x] == '\0')
openfile->current_x = 0;
openfile->placewewant = xplustabs();
} else {
#endif
openfile->current_x = 0;
openfile->placewewant = 0;
#ifndef NANO_SMALL
}
#endif
if (need_horizontal_update(pww_save))
update_line(openfile->current, openfile->current_x);
}
void do_end(void)
{
size_t pww_save = openfile->placewewant;
check_statusblank();
openfile->current_x = strlen(openfile->current->data);
openfile->placewewant = xplustabs();
if (need_horizontal_update(pww_save))
update_line(openfile->current, openfile->current_x);
}
void do_up(void)
{
check_statusblank();

View File

@ -2948,32 +2948,6 @@ bool begpar(const filestruct *const foo)
return FALSE;
}
/* We find the last beginning-of-paragraph line before the current
* line. */
void do_para_begin(bool allow_update)
{
const filestruct *current_save = openfile->current;
const size_t pww_save = openfile->placewewant;
openfile->current_x = 0;
openfile->placewewant = 0;
if (openfile->current->prev != NULL) {
do {
openfile->current = openfile->current->prev;
openfile->current_y--;
} while (!begpar(openfile->current));
}
if (allow_update)
edit_redraw(current_save, pww_save);
}
void do_para_begin_void(void)
{
do_para_begin(TRUE);
}
/* Is foo inside a paragraph? */
bool inpar(const filestruct *const foo)
{
@ -2988,39 +2962,6 @@ bool inpar(const filestruct *const foo)
quote_len)] != '\0';
}
/* A line is the last line of a paragraph if it is in a paragraph, and
* the next line isn't, or is the beginning of a paragraph. We move
* down to the end of a paragraph, then one line farther. */
void do_para_end(bool allow_update)
{
const filestruct *const current_save = openfile->current;
const size_t pww_save = openfile->placewewant;
openfile->current_x = 0;
openfile->placewewant = 0;
while (openfile->current->next != NULL && !inpar(openfile->current))
openfile->current = openfile->current->next;
while (openfile->current->next != NULL &&
inpar(openfile->current->next) &&
!begpar(openfile->current->next)) {
openfile->current = openfile->current->next;
openfile->current_y++;
}
if (openfile->current->next != NULL)
openfile->current = openfile->current->next;
if (allow_update)
edit_redraw(current_save, pww_save);
}
void do_para_end_void(void)
{
do_para_end(TRUE);
}
/* Put the next par_len lines, starting with first_line, into the
* justify buffer, leaving copies of those lines in place. Assume there
* are enough lines after first_line. Return the new copy of

View File

@ -329,10 +329,16 @@ void thanks_for_all_the_fish(void);
/* Public functions in move.c. */
void do_first_line(void);
void do_last_line(void);
void do_home(void);
void do_end(void);
void do_page_up(void);
void do_page_down(void);
#ifndef DISABLE_JUSTIFY
void do_para_begin(bool allow_update);
void do_para_begin_void(void);
void do_para_end(bool allow_update);
void do_para_end_void(void);
#endif
void do_home(void);
void do_end(void);
void do_up(void);
void do_down(void);
void do_left(bool allow_update);
@ -420,11 +426,7 @@ bool quotes_match(const char *a_line, size_t a_quote, const char
bool indents_match(const char *a_line, size_t a_indent, const char
*b_line, size_t b_indent);
bool begpar(const filestruct *const foo);
void do_para_begin(bool allow_update);
void do_para_begin_void(void);
bool inpar(const filestruct *const foo);
void do_para_end(bool allow_update);
void do_para_end_void(void);
filestruct *backup_lines(filestruct *first_line, size_t par_len, size_t
quote_len);
bool find_paragraph(size_t *const quote, size_t *const par);