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