mirror of
git://git.sv.gnu.org/nano.git
synced 2025-02-13 03:44:50 +03:00
tweaks: miscellaneous frobbings
This commit is contained in:
parent
58c3dd6cd0
commit
c0aa5ad258
@ -258,7 +258,7 @@ void do_uncut_text(void)
|
||||
{
|
||||
ssize_t was_lineno = openfile->current->lineno;
|
||||
|
||||
/* If the cutbuffer is empty, get out. */
|
||||
/* If the cutbuffer is empty, there is nothing to do. */
|
||||
if (cutbuffer == NULL)
|
||||
return;
|
||||
|
||||
@ -277,8 +277,7 @@ void do_uncut_text(void)
|
||||
if (openfile->current->lineno - was_lineno < editwinrows)
|
||||
focusing = FALSE;
|
||||
|
||||
/* Set the current place we want to where the text from the
|
||||
* cutbuffer ends. */
|
||||
/* Set the desired x position to where the pasted text ends. */
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
/* Mark the file as modified. */
|
||||
|
@ -906,8 +906,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkw
|
||||
openfile->current_x = 0;
|
||||
}
|
||||
|
||||
/* Set the current place we want to the end of the last line of the
|
||||
* file we inserted. */
|
||||
/* Set the desired x position at the end of what was inserted. */
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
if (!writable)
|
||||
@ -2978,7 +2977,7 @@ bool writehist(FILE *hist, const filestruct *head)
|
||||
{
|
||||
const filestruct *item;
|
||||
|
||||
/* Write a history list from the oldest entry to the newest. */
|
||||
/* Write a history list, from the oldest item to the newest. */
|
||||
for (item = head; item != NULL; item = item->next) {
|
||||
size_t length = strlen(item->data);
|
||||
|
||||
|
@ -348,7 +348,7 @@ const char *tail(const char *path);
|
||||
#ifndef DISABLE_HISTORIES
|
||||
char *histfilename(void);
|
||||
void load_history(void);
|
||||
bool writehist(FILE *hist, const filestruct *histhead);
|
||||
bool writehist(FILE *hist, const filestruct *head);
|
||||
void save_history(void);
|
||||
int check_dotnano(void);
|
||||
void load_poshistory(void);
|
||||
@ -743,8 +743,8 @@ void statusline(message_type importance, const char *msg, ...);
|
||||
void bottombars(int menu);
|
||||
void onekey(const char *keystroke, const char *desc, int length);
|
||||
void reset_cursor(void);
|
||||
void edit_draw(filestruct *fileptr, const char *converted, int
|
||||
line, size_t start);
|
||||
void edit_draw(filestruct *fileptr, const char *converted,
|
||||
int line, size_t from_col);
|
||||
int update_line(filestruct *fileptr, size_t index);
|
||||
bool need_horizontal_scroll(const size_t old_column, const size_t new_column);
|
||||
void edit_scroll(scroll_dir direction, ssize_t nlines);
|
||||
|
@ -823,10 +823,12 @@ void do_undo(void)
|
||||
statusline(HUSH, _("Undid action (%s)"), undidmsg);
|
||||
|
||||
renumber(f);
|
||||
|
||||
openfile->current_undo = openfile->current_undo->next;
|
||||
openfile->last_action = OTHER;
|
||||
openfile->mark_set = FALSE;
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
openfile->totsize = u->wassize;
|
||||
set_modified();
|
||||
}
|
||||
@ -974,6 +976,7 @@ void do_redo(void)
|
||||
openfile->last_action = OTHER;
|
||||
openfile->mark_set = FALSE;
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
openfile->totsize = u->newsize;
|
||||
set_modified();
|
||||
}
|
||||
|
37
src/winio.c
37
src/winio.c
@ -2294,8 +2294,8 @@ void reset_cursor(void)
|
||||
* character of this page. That is, the first character of converted
|
||||
* corresponds to character number actual_x(fileptr->data, from_col) of the
|
||||
* line. */
|
||||
void edit_draw(filestruct *fileptr, const char *converted, int
|
||||
line, size_t from_col)
|
||||
void edit_draw(filestruct *fileptr, const char *converted,
|
||||
int line, size_t from_col)
|
||||
{
|
||||
#if !defined(NANO_TINY) || !defined(DISABLE_COLOR)
|
||||
size_t from_x = actual_x(fileptr->data, from_col);
|
||||
@ -2483,8 +2483,8 @@ void edit_draw(filestruct *fileptr, const char *converted, int
|
||||
while (TRUE) {
|
||||
index += startmatch.rm_so;
|
||||
startmatch.rm_eo -= startmatch.rm_so;
|
||||
if (regexec(varnish->end, start_line->data +
|
||||
index + startmatch.rm_eo, 0, NULL,
|
||||
if (regexec(varnish->end, start_line->data + index +
|
||||
startmatch.rm_eo, 0, NULL,
|
||||
(index + startmatch.rm_eo == 0) ?
|
||||
0 : REG_NOTBOL) == REG_NOMATCH)
|
||||
/* No end found after this start. */
|
||||
@ -2497,8 +2497,8 @@ void edit_draw(filestruct *fileptr, const char *converted, int
|
||||
}
|
||||
/* Indeed, there is a start without an end on that line. */
|
||||
|
||||
/* We've already checked that there is no end before fileptr
|
||||
* and after the start. But is there an end after the start
|
||||
/* We've already checked that there is no end between the start
|
||||
* and the current line. But is there an end after the start
|
||||
* at all? We don't paint unterminated starts. */
|
||||
while (end_line != NULL && regexec(varnish->end, end_line->data,
|
||||
1, &endmatch, 0) == REG_NOMATCH)
|
||||
@ -2557,9 +2557,8 @@ void edit_draw(filestruct *fileptr, const char *converted, int
|
||||
* the beginning of the line. */
|
||||
endmatch.rm_so += startmatch.rm_eo;
|
||||
endmatch.rm_eo += startmatch.rm_eo;
|
||||
/* There is an end on this line. But does
|
||||
* it appear on this page, and is the match
|
||||
* more than zero characters long? */
|
||||
/* Only paint the match if it is visible on screen and
|
||||
* it is more than zero characters long. */
|
||||
if (endmatch.rm_eo > from_x &&
|
||||
endmatch.rm_eo > startmatch.rm_so) {
|
||||
paintlen = actual_x(thetext, strnlenpt(fileptr->data,
|
||||
@ -2662,15 +2661,12 @@ void edit_draw(filestruct *fileptr, const char *converted, int
|
||||
int update_line(filestruct *fileptr, size_t index)
|
||||
{
|
||||
int line = 0;
|
||||
/* The line in the edit window that we want to update. */
|
||||
/* The row in the edit window we will be updating. */
|
||||
int extralinesused = 0;
|
||||
char *converted;
|
||||
/* fileptr->data converted to have tabs and control characters
|
||||
* expanded. */
|
||||
/* The data of the line with tabs and control characters expanded. */
|
||||
size_t page_start;
|
||||
|
||||
assert(fileptr != NULL);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(SOFTWRAP)) {
|
||||
filestruct *tmp;
|
||||
@ -2795,8 +2791,6 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
|
||||
ssize_t i;
|
||||
filestruct *foo;
|
||||
|
||||
assert(nlines > 0);
|
||||
|
||||
/* Part 1: nlines is the number of lines we're going to scroll the
|
||||
* text of the edit window. */
|
||||
|
||||
@ -2856,12 +2850,10 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
|
||||
if (nlines > editwinrows)
|
||||
nlines = editwinrows;
|
||||
|
||||
/* If we scrolled up, we're on the line before the scrolled
|
||||
* region. */
|
||||
/* If we scrolled up, we're on the line before the scrolled region. */
|
||||
foo = openfile->edittop;
|
||||
|
||||
/* If we scrolled down, move down to the line before the scrolled
|
||||
* region. */
|
||||
/* If we scrolled down, move down to the line before the scrolled region. */
|
||||
if (direction == DOWNWARD) {
|
||||
for (i = editwinrows - nlines; i > 0 && foo != NULL; i--)
|
||||
foo = foo->next;
|
||||
@ -2873,8 +2865,8 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
|
||||
* blank, so we don't need to draw it unless the mark is on or we're
|
||||
* not on the first page. */
|
||||
for (i = nlines; i > 0 && foo != NULL; i--) {
|
||||
if ((i == nlines && direction == DOWNWARD) || (i == 1 &&
|
||||
direction == UPWARD)) {
|
||||
if ((i == nlines && direction == DOWNWARD) ||
|
||||
(i == 1 && direction == UPWARD)) {
|
||||
if (need_horizontal_scroll(openfile->placewewant, 0))
|
||||
update_line(foo, (foo == openfile->current) ?
|
||||
openfile->current_x : 0);
|
||||
@ -2883,6 +2875,7 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
|
||||
openfile->current_x : 0);
|
||||
foo = foo->next;
|
||||
}
|
||||
|
||||
compute_maxrows();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user