do_research(), do_replace_loop(), do_find_bracket(), and
edit_refresh(). New functions do_left_void(),
do_right_void(), need_horizontal_update(),
- need_vertical_update(), edit_scroll(), and edit_redraw().
- Also rename the int refresh in do_delete() and do_backspace()
- to do_refresh so as not to conflict with refresh(). (DLR)
+ need_vertical_update(), edit_scroll(), and edit_redraw(). All
+ of these functions but the first two require the previous
+ versions of current and/or placewewant as parameters. Also
+ rename the int refresh in do_delete() and do_backspace() to
+ do_refresh so as not to conflict with refresh(). (DLR)
- Add some comments better explaining what is disabled in
restricted mode and why. (DLR)
- Since KEEP_CUTBUFFER is only used in cut.c, make it a static
int do_page_up(void)
{
- int new_pww = placewewant;
+ int old_pww = placewewant;
const filestruct *old_current = current;
#ifndef DISABLE_WRAPPING
wrap_reset();
* and put the cursor at the beginning of the line. */
if (edittop == fileage) {
current = fileage;
- new_pww = 0;
+ placewewant = 0;
} else {
edit_scroll(UP, editwinrows - 2);
else {
#endif
current = edittop;
- new_pww = 0;
+ placewewant = 0;
#ifndef NANO_SMALL
}
#endif
}
/* Get the equivalent x-coordinate of the new line. */
- current_x = actual_x(current->data, new_pww);
+ current_x = actual_x(current->data, placewewant);
- /* Update all the lines that need to be updated, and then set
- * placewewant, so that the update will work properly. */
- edit_redraw(old_current);
- placewewant = new_pww;
+ /* Update all the lines that need to be updated. */
+ edit_redraw(old_current, old_pww);
check_statblank();
return 1;
int do_page_down(void)
{
- int new_pww = placewewant;
+ int old_pww = placewewant;
const filestruct *old_current = current;
#ifndef DISABLE_WRAPPING
wrap_reset();
* there and put the cursor at the beginning of the line. */
if (edittop->lineno + editwinrows > filebot->lineno) {
current = filebot;
- new_pww = 0;
+ placewewant = 0;
} else {
edit_scroll(DOWN, editwinrows - 2);
else {
#endif
current = edittop;
- new_pww = 0;
+ placewewant = 0;
#ifndef NANO_SMALL
}
#endif
}
/* Get the equivalent x-coordinate of the new line. */
- current_x = actual_x(current->data, new_pww);
+ current_x = actual_x(current->data, placewewant);
- /* Update all the lines that need to be updated, and then set
- * placewewant, so that the update will work properly. */
- edit_redraw(old_current);
- placewewant = new_pww;
+ /* Update all the lines that need to be updated. */
+ edit_redraw(old_current, old_pww);
check_statblank();
return 1;
#ifndef NANO_SMALL
int do_next_word(void)
{
+ int old_pww = placewewant;
const filestruct *current_save = current;
assert(current != NULL && current->data != NULL);
/* Refresh the screen. If current has run off the bottom, this
* call puts it at the center line. */
- edit_redraw(current_save);
+ edit_redraw(current_save, old_pww);
return 0;
}
/* The same thing for backwards. */
int do_prev_word(void)
{
+ int old_pww = placewewant;
const filestruct *current_save = current;
assert(current != NULL && current->data != NULL);
/* Refresh the screen. If current has run off the top, this call
* puts it at the center line. */
- edit_redraw(current_save);
+ edit_redraw(current_save, old_pww);
return 0;
}
int do_para_search(justbegend search_type, size_t *quote, size_t *par,
size_t *indent, int do_refresh)
{
+ int old_pww = placewewant;
const filestruct *current_save = current;
size_t quote_len;
/* Length of the initial quotation of the paragraph we
if (current->prev == NULL) {
placewewant = 0;
if (do_refresh)
- edit_redraw(current_save);
+ edit_redraw(current_save, old_pww);
#ifdef HAVE_REGEX_H
if (!do_restart)
regfree(&qreg);
if (current->next == NULL) {
placewewant = 0;
if (do_refresh)
- edit_redraw(current_save);
+ edit_redraw(current_save, old_pww);
#ifdef HAVE_REGEX_H
regfree(&qreg);
#endif
/* Refresh the screen if needed. */
if (do_refresh)
- edit_redraw(current_save);
+ edit_redraw(current_save, old_pww);
/* Save the values of quote_len, par_len, and indent_len if
* needed. */
int need_horizontal_update(int old_placewewant);
int need_vertical_update(int old_placewewant);
void edit_scroll(updown direction, int nlines);
-void edit_redraw(const filestruct *old_current);
+void edit_redraw(const filestruct *old_current, int old_pww);
void edit_refresh(void);
void edit_update(filestruct *fileptr, topmidnone location);
int statusq(int allowtabs, const shortcut *s, const char *def,
/* Search for a string. */
int do_search(void)
{
- int i, fileptr_x = current_x, didfind;
+ int old_pww = placewewant, i, fileptr_x = current_x, didfind;
filestruct *fileptr = current;
#ifndef DISABLE_WRAPPING
#endif
}
- edit_redraw(fileptr);
placewewant = xplustabs();
+ edit_redraw(fileptr, old_pww);
search_abort();
return 1;
/* Search for the next string without prompting. */
int do_research(void)
{
- int fileptr_x = current_x, didfind;
+ int old_pww = placewewant, fileptr_x = current_x, didfind;
filestruct *fileptr = current;
#ifndef DISABLE_WRAPPING
} else
statusbar(_("No current search pattern"));
- edit_redraw(fileptr);
placewewant = xplustabs();
+ edit_redraw(fileptr, old_pww);
search_abort();
return 1;
int do_replace_loop(const char *needle, const filestruct *real_current,
size_t *real_current_x, int wholewords)
{
- int replaceall = 0, numreplaced = -1;
+ int old_pww = placewewant, replaceall = 0, numreplaced = -1;
size_t current_x_save = current_x;
const filestruct *current_save = current;
#ifdef HAVE_REGEX_H
#endif
if (!replaceall)
- edit_redraw(current_save);
+ edit_redraw(current_save, old_pww);
#ifdef HAVE_REGEX_H
if (ISSET(USE_REGEXP))
char ch_under_cursor, wanted_ch;
const char *pos, *brackets = "([{<>}])";
char regexp_pat[] = "[ ]";
- int current_x_save, flagsave, count = 1;
+ int old_pww = placewewant, current_x_save, flagsave, count = 1;
filestruct *current_save;
ch_under_cursor = current->data[current_x];
count++;
/* Found complementary bracket. */
else if (--count == 0) {
- edit_redraw(current_save);
placewewant = xplustabs();
+ edit_redraw(current_save, old_pww);
break;
}
} else {
}
/* Update any lines between old_current and current that need to be
- * updated. Note that we use placewewant to determine whether we need
- * updates and current_x to update current, so if placewewant needs to
- * be changed, it should be changed after calling this, and if current_x
- * needs to be changed, it should be changed before calling this.
- * Assume none of the text has changed since the last update. */
-void edit_redraw(const filestruct *old_current)
+ * updated. Assume none of the text has changed since the last
+ * update. */
+void edit_redraw(const filestruct *old_current, int old_pww)
{
- int do_refresh = need_vertical_update(0);
+ int do_refresh = need_vertical_update(old_pww);
const filestruct *foo;
/* If either old_current or current is offscreen, refresh the screen