DLR's latest patch
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1204 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Этот коммит содержится в:
родитель
7c27be42d0
Коммит
4dc03d5733
10
ChangeLog
10
ChangeLog
@ -24,6 +24,11 @@ CVS code -
|
|||||||
syntaxfile_regexp and synfilematches. Global flag -Y ,--syntax
|
syntaxfile_regexp and synfilematches. Global flag -Y ,--syntax
|
||||||
to specify the type on the command line, if there's no good
|
to specify the type on the command line, if there's no good
|
||||||
filename regex to use. Global variable syntaxstr.
|
filename regex to use. Global variable syntaxstr.
|
||||||
|
- Changed many strcmp()s and strcpy()s to their equivalent
|
||||||
|
'\0' conterparts (David Lawrence Ramsey).
|
||||||
|
- Many chanes to allow marked cutting to work with multiple
|
||||||
|
file buffers: changes to openfilestruct type in nano.h and
|
||||||
|
files.c (David Lawrence Ramsey).
|
||||||
- configure.ac:
|
- configure.ac:
|
||||||
- Define NDEBUG to silence asserts (David Benbennick).
|
- Define NDEBUG to silence asserts (David Benbennick).
|
||||||
- files.c:
|
- files.c:
|
||||||
@ -47,10 +52,15 @@ CVS code -
|
|||||||
- nano.spec.in:
|
- nano.spec.in:
|
||||||
- Don't put Chris' name as the Packager in the distribution
|
- Don't put Chris' name as the Packager in the distribution
|
||||||
by default (Im an idiot).
|
by default (Im an idiot).
|
||||||
|
- Fixed Source line (David Lawrence Ramsey).
|
||||||
- nano.1:
|
- nano.1:
|
||||||
- Changed references to Debian GNU/Linux to Debian GNU (Jordi).
|
- Changed references to Debian GNU/Linux to Debian GNU (Jordi).
|
||||||
|
- nano.1.html:
|
||||||
|
- Updated for -Y option (David Lawrence Ramsey).
|
||||||
- rcfile.c
|
- rcfile.c
|
||||||
- Made some rc file errors less fatal.
|
- Made some rc file errors less fatal.
|
||||||
|
- Added in my patch for getpwent instead of relying on $HOME
|
||||||
|
(David Lawrence Ramsey).
|
||||||
- winio.c:
|
- winio.c:
|
||||||
edit_add()
|
edit_add()
|
||||||
- Changed some syntax hilight computations for the sake of COLS.
|
- Changed some syntax hilight computations for the sake of COLS.
|
||||||
|
143
files.c
143
files.c
@ -50,15 +50,15 @@ static int fileformat = 0; /* 0 = *nix, 1 = DOS, 2 = Mac */
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Load file into edit buffer - takes data from file struct */
|
/* Load file into edit buffer - takes data from file struct */
|
||||||
void load_file(int quiet)
|
void load_file(int update)
|
||||||
{
|
{
|
||||||
current = fileage;
|
current = fileage;
|
||||||
|
|
||||||
#ifdef ENABLE_MULTIBUFFER
|
#ifdef ENABLE_MULTIBUFFER
|
||||||
/* if quiet is zero, add a new entry to the open_files structure;
|
/* if update is zero, add a new entry to the open_files structure;
|
||||||
otherwise, update the current entry (the latter is needed in the
|
otherwise, update the current entry (the latter is needed in the
|
||||||
case of the alternate spell checker) */
|
case of the alternate spell checker) */
|
||||||
add_open_file(quiet);
|
add_open_file(update);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_COLOR
|
#ifdef ENABLE_COLOR
|
||||||
@ -73,7 +73,7 @@ void new_file(void)
|
|||||||
{
|
{
|
||||||
fileage = nmalloc(sizeof(filestruct));
|
fileage = nmalloc(sizeof(filestruct));
|
||||||
fileage->data = charalloc(1);
|
fileage->data = charalloc(1);
|
||||||
strcpy(fileage->data, "");
|
fileage->data[0] = '\0';
|
||||||
fileage->prev = NULL;
|
fileage->prev = NULL;
|
||||||
fileage->next = NULL;
|
fileage->next = NULL;
|
||||||
fileage->lineno = 1;
|
fileage->lineno = 1;
|
||||||
@ -88,7 +88,7 @@ void new_file(void)
|
|||||||
/* if there aren't any entries in open_files, create the entry for
|
/* if there aren't any entries in open_files, create the entry for
|
||||||
this new file; without this, if nano is started without a filename
|
this new file; without this, if nano is started without a filename
|
||||||
on the command line, a new file will be created, but it will be
|
on the command line, a new file will be created, but it will be
|
||||||
given no open_files entry, leading to problems later on */
|
given no open_files entry */
|
||||||
if (!open_files) {
|
if (!open_files) {
|
||||||
add_open_file(0);
|
add_open_file(0);
|
||||||
/* turn off view mode in this case; this is for consistency
|
/* turn off view mode in this case; this is for consistency
|
||||||
@ -108,7 +108,7 @@ void new_file(void)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
filestruct *read_line(char *buf, filestruct * prev, int *line1ins)
|
filestruct *read_line(char *buf, filestruct *prev, int *line1ins)
|
||||||
{
|
{
|
||||||
filestruct *fileptr;
|
filestruct *fileptr;
|
||||||
|
|
||||||
@ -156,10 +156,10 @@ filestruct *read_line(char *buf, filestruct * prev, int *line1ins)
|
|||||||
return fileptr;
|
return fileptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int read_file(FILE *f, char *filename, int quiet)
|
int read_file(FILE *f, const char *filename, int quiet)
|
||||||
{
|
{
|
||||||
int num_lines = 0;
|
int num_lines = 0;
|
||||||
char input; /* current input character */
|
signed char input; /* current input character */
|
||||||
char *buf;
|
char *buf;
|
||||||
long i = 0, bufx = 128;
|
long i = 0, bufx = 128;
|
||||||
filestruct *fileptr = current, *tmp = NULL;
|
filestruct *fileptr = current, *tmp = NULL;
|
||||||
@ -260,7 +260,9 @@ int read_file(FILE *f, char *filename, int quiet)
|
|||||||
new_magicline();
|
new_magicline();
|
||||||
totsize--;
|
totsize--;
|
||||||
|
|
||||||
/* Update the edit buffer */
|
/* Update the edit buffer; note that if using multibuffers, a
|
||||||
|
quiet load will update the current open_files entry, while a
|
||||||
|
noisy load will add a new open_files entry */
|
||||||
load_file(quiet);
|
load_file(quiet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,15 +283,14 @@ int read_file(FILE *f, char *filename, int quiet)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Open the file (and decide if it exists) */
|
/* Open the file (and decide if it exists) */
|
||||||
int open_file(char *filename, int insert, int quiet)
|
int open_file(const char *filename, int insert, int quiet)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
struct stat fileinfo;
|
struct stat fileinfo;
|
||||||
|
|
||||||
if (!strcmp(filename, "") || stat(filename, &fileinfo) == -1) {
|
if (filename[0] == '\0' || stat(filename, &fileinfo) == -1) {
|
||||||
if (insert && !quiet) {
|
if (insert && !quiet) {
|
||||||
statusbar(_("\"%s\" not found"), filename);
|
statusbar(_("\"%s\" not found"), filename);
|
||||||
return -1;
|
return -1;
|
||||||
@ -313,7 +314,6 @@ int open_file(char *filename, int insert, int quiet)
|
|||||||
/* Don't open character or block files. Sorry, /dev/sndstat! */
|
/* Don't open character or block files. Sorry, /dev/sndstat! */
|
||||||
statusbar(_("File \"%s\" is a device file"), filename);
|
statusbar(_("File \"%s\" is a device file"), filename);
|
||||||
|
|
||||||
|
|
||||||
if (!insert)
|
if (!insert)
|
||||||
new_file();
|
new_file();
|
||||||
return -1;
|
return -1;
|
||||||
@ -331,7 +331,6 @@ int open_file(char *filename, int insert, int quiet)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* This function will return the name of the first available extension
|
/* This function will return the name of the first available extension
|
||||||
of a filename (starting with the filename, then filename.1, etc).
|
of a filename (starting with the filename, then filename.1, etc).
|
||||||
Memory is allocated for the return value. If no writable extension
|
Memory is allocated for the return value. If no writable extension
|
||||||
@ -365,7 +364,7 @@ char *get_next_filename(const char *name)
|
|||||||
|
|
||||||
int do_insertfile(int loading_file)
|
int do_insertfile(int loading_file)
|
||||||
{
|
{
|
||||||
int i;
|
int i, old_current_x = current_x;
|
||||||
char *realname = NULL;
|
char *realname = NULL;
|
||||||
|
|
||||||
wrap_reset();
|
wrap_reset();
|
||||||
@ -428,7 +427,7 @@ int do_insertfile(int loading_file)
|
|||||||
if (i == NANO_EXTCMD_KEY) {
|
if (i == NANO_EXTCMD_KEY) {
|
||||||
int ts;
|
int ts;
|
||||||
ts = statusq(1, extcmd_list, "", _("Command to execute "));
|
ts = statusq(1, extcmd_list, "", _("Command to execute "));
|
||||||
if (ts == -1 || answer == NULL || !strcmp(answer,"")) {
|
if (ts == -1 || answer == NULL || answer[0] == '\0') {
|
||||||
statusbar(_("Cancelled"));
|
statusbar(_("Cancelled"));
|
||||||
UNSET(KEEP_CUTBUFFER);
|
UNSET(KEEP_CUTBUFFER);
|
||||||
display_main_list();
|
display_main_list();
|
||||||
@ -445,6 +444,9 @@ int do_insertfile(int loading_file)
|
|||||||
|
|
||||||
new_file();
|
new_file();
|
||||||
UNSET(MODIFIED);
|
UNSET(MODIFIED);
|
||||||
|
#ifndef NANO_SMALL
|
||||||
|
UNSET(MARK_ISSET);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -489,6 +491,17 @@ int do_insertfile(int loading_file)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_MULTIBUFFER
|
||||||
|
if (!loading_file) {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Restore the old x-coordinate position */
|
||||||
|
current_x = old_current_x;
|
||||||
|
|
||||||
|
#ifdef ENABLE_MULTIBUFFER
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* If we've gone off the bottom, recenter; otherwise, just redraw */
|
/* If we've gone off the bottom, recenter; otherwise, just redraw */
|
||||||
if (current->lineno > editbot->lineno)
|
if (current->lineno > editbot->lineno)
|
||||||
edit_update(current, CENTER);
|
edit_update(current, CENTER);
|
||||||
@ -582,19 +595,29 @@ int add_open_file(int update)
|
|||||||
/* save current line number */
|
/* save current line number */
|
||||||
open_files->file_lineno = current->lineno;
|
open_files->file_lineno = current->lineno;
|
||||||
|
|
||||||
|
/* if we're updating, save current modification status (and marking
|
||||||
|
status, if available) */
|
||||||
|
if (update) {
|
||||||
|
#ifndef NANO_SMALL
|
||||||
|
open_files->file_flags = (MODIFIED & ISSET(MODIFIED)) | (MARK_ISSET & ISSET(MARK_ISSET));
|
||||||
|
if (ISSET(MARK_ISSET)) {
|
||||||
|
open_files->file_mark_beginbuf = mark_beginbuf;
|
||||||
|
open_files->file_mark_beginx = mark_beginx;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
open_files->file_flags = (MODIFIED & ISSET(MODIFIED));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/* if we're in view mode and updating, the file contents won't
|
/* if we're in view mode and updating, the file contents won't
|
||||||
have changed, so we won't bother resaving the filestruct
|
have changed, so we won't bother resaving the filestruct
|
||||||
then; otherwise, we will */
|
then; otherwise, we will */
|
||||||
if (!(ISSET(VIEW_MODE) && !update)) {
|
if (!(ISSET(VIEW_MODE) && !update)) {
|
||||||
/* save current filestruct and restore full file position
|
/* save current file buffer */
|
||||||
afterward */
|
|
||||||
open_files->fileage = fileage;
|
open_files->fileage = fileage;
|
||||||
do_gotopos(open_files->file_lineno, open_files->file_current_x, open_files->file_current_y, open_files->file_placewewant);
|
open_files->filebot = filebot;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* save current modification status */
|
|
||||||
open_files->file_modified = ISSET(MODIFIED);
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, _("filename is %s"), open_files->filename);
|
fprintf(stderr, _("filename is %s"), open_files->filename);
|
||||||
#endif
|
#endif
|
||||||
@ -602,21 +625,6 @@ int add_open_file(int update)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Update only the filename stored in the current entry. Return 0 on
|
|
||||||
* success or 1 on error.
|
|
||||||
*/
|
|
||||||
int open_file_change_name(void)
|
|
||||||
{
|
|
||||||
if (!open_files || !filename)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
/* save current filename */
|
|
||||||
open_files->filename = mallocstrcpy(open_files->filename, filename);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read the current entry in the open_files structure and set up the
|
* Read the current entry in the open_files structure and set up the
|
||||||
* currently open file using that entry's information. Return 0 on
|
* currently open file using that entry's information. Return 0 on
|
||||||
@ -624,7 +632,6 @@ int open_file_change_name(void)
|
|||||||
*/
|
*/
|
||||||
int load_open_file(void)
|
int load_open_file(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!open_files)
|
if (!open_files)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
@ -633,27 +640,31 @@ int load_open_file(void)
|
|||||||
filename = mallocstrcpy(filename, open_files->filename);
|
filename = mallocstrcpy(filename, open_files->filename);
|
||||||
fileage = open_files->fileage;
|
fileage = open_files->fileage;
|
||||||
current = fileage;
|
current = fileage;
|
||||||
|
filebot = open_files->filebot;
|
||||||
totlines = open_files->file_totlines;
|
totlines = open_files->file_totlines;
|
||||||
totsize = open_files->file_totsize;
|
totsize = open_files->file_totsize;
|
||||||
|
|
||||||
/* Unset the marker because nano can't (yet) handle marked text
|
/* restore modification status */
|
||||||
flipping between open files */
|
if (open_files->file_flags & MODIFIED)
|
||||||
|
SET(MODIFIED);
|
||||||
|
else
|
||||||
|
UNSET(MODIFIED);
|
||||||
|
|
||||||
|
#ifndef NANO_SMALL
|
||||||
|
/* restore marking status */
|
||||||
|
if (open_files->file_flags & MARK_ISSET) {
|
||||||
|
mark_beginbuf = open_files->file_mark_beginbuf;
|
||||||
|
mark_beginx = open_files->file_mark_beginx;
|
||||||
|
SET(MARK_ISSET);
|
||||||
|
} else
|
||||||
UNSET(MARK_ISSET);
|
UNSET(MARK_ISSET);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* restore full file position: line number, x-coordinate, y-
|
/* restore full file position: line number, x-coordinate, y-
|
||||||
coordinate, place we want */
|
coordinate, place we want */
|
||||||
do_gotopos(open_files->file_lineno, open_files->file_current_x, open_files->file_current_y, open_files->file_placewewant);
|
do_gotopos(open_files->file_lineno, open_files->file_current_x, open_files->file_current_y, open_files->file_placewewant);
|
||||||
|
|
||||||
/* restore the bottom of the file */
|
/* update the titlebar */
|
||||||
filebot = current;
|
|
||||||
while (filebot->next)
|
|
||||||
filebot = filebot->next;
|
|
||||||
|
|
||||||
/* set up modification status and update the titlebar */
|
|
||||||
if (open_files->file_modified)
|
|
||||||
SET(MODIFIED);
|
|
||||||
else
|
|
||||||
UNSET(MODIFIED);
|
|
||||||
clearok(topwin, FALSE);
|
clearok(topwin, FALSE);
|
||||||
titlebar(NULL);
|
titlebar(NULL);
|
||||||
|
|
||||||
@ -811,7 +822,11 @@ int close_open_file(void)
|
|||||||
if (!open_files)
|
if (!open_files)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
/* make sure open_files->fileage and fileage, and open_files->filebot
|
||||||
|
and filebot, are in sync; they might not be if lines have been cut
|
||||||
|
from the top or bottom of the file */
|
||||||
open_files->fileage = fileage;
|
open_files->fileage = fileage;
|
||||||
|
open_files->filebot = filebot;
|
||||||
|
|
||||||
tmp = open_files;
|
tmp = open_files;
|
||||||
if (open_nextfile(1)) {
|
if (open_nextfile(1)) {
|
||||||
@ -1203,7 +1218,7 @@ int write_file(char *name, int tmp, int append, int nonamechange)
|
|||||||
struct stat st, lst;
|
struct stat st, lst;
|
||||||
char *realname = NULL;
|
char *realname = NULL;
|
||||||
|
|
||||||
if (!strcmp(name, "")) {
|
if (name[0] == '\0') {
|
||||||
statusbar(_("Cancelled"));
|
statusbar(_("Cancelled"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1224,8 +1239,9 @@ int write_file(char *name, int tmp, int append, int nonamechange)
|
|||||||
|
|
||||||
#ifndef DISABLE_OPERATINGDIR
|
#ifndef DISABLE_OPERATINGDIR
|
||||||
if (!tmp && operating_dir) {
|
if (!tmp && operating_dir) {
|
||||||
/* if we're writing a temporary file, we're going outside the
|
/* if we're writing a temporary file, we're probably going
|
||||||
operating directory, so skip the operating directory test */
|
outside the operating directory, so skip the operating
|
||||||
|
directory test */
|
||||||
if (check_operating_dir(realname, 0)) {
|
if (check_operating_dir(realname, 0)) {
|
||||||
statusbar(_("Can't write outside of %s"), operating_dir);
|
statusbar(_("Can't write outside of %s"), operating_dir);
|
||||||
|
|
||||||
@ -1634,21 +1650,8 @@ int do_writeout(char *path, int exiting, int append)
|
|||||||
#ifdef ENABLE_MULTIBUFFER
|
#ifdef ENABLE_MULTIBUFFER
|
||||||
/* if we're not about to exit, update the current entry in
|
/* if we're not about to exit, update the current entry in
|
||||||
the open_files structure */
|
the open_files structure */
|
||||||
if (!exiting) {
|
if (!exiting)
|
||||||
|
|
||||||
/* first, if the filename was changed during the save,
|
|
||||||
update the filename stored in the current entry, and
|
|
||||||
then update the current entry */
|
|
||||||
if (strcmp(open_files->filename, filename)) {
|
|
||||||
open_file_change_name();
|
|
||||||
add_open_file(1);
|
add_open_file(1);
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
/* otherwise, just update the current entry */
|
|
||||||
add_open_file(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
display_main_list();
|
display_main_list();
|
||||||
@ -1825,7 +1828,7 @@ char **cwd_tab_completion(char *buf, int *num_matches)
|
|||||||
strcat(buf, "*");
|
strcat(buf, "*");
|
||||||
|
|
||||||
/* Okie, if there's a / in the buffer, strip out the directory part */
|
/* Okie, if there's a / in the buffer, strip out the directory part */
|
||||||
if (strcmp(buf, "") && strstr(buf, "/")) {
|
if (buf[0] != '\0' && strstr(buf, "/")) {
|
||||||
dirName = charalloc(strlen(buf) + 1);
|
dirName = charalloc(strlen(buf) + 1);
|
||||||
tmp = buf + strlen(buf);
|
tmp = buf + strlen(buf);
|
||||||
while (*tmp != '/' && tmp != buf)
|
while (*tmp != '/' && tmp != buf)
|
||||||
@ -1988,7 +1991,7 @@ char *input_tab(char *buf, int place, int *lastWasTab, int *newplace, int *list)
|
|||||||
|
|
||||||
buf = nrealloc(buf, strlen(buf) + strlen(matches[0]) + 1);
|
buf = nrealloc(buf, strlen(buf) + strlen(matches[0]) + 1);
|
||||||
|
|
||||||
if (strcmp(buf, "") && strstr(buf, "/")) {
|
if (buf[0] != '\0' && strstr(buf, "/")) {
|
||||||
for (tmp = buf + strlen(buf); *tmp != '/' && tmp != buf;
|
for (tmp = buf + strlen(buf); *tmp != '/' && tmp != buf;
|
||||||
tmp--);
|
tmp--);
|
||||||
tmp++;
|
tmp++;
|
||||||
@ -2025,7 +2028,7 @@ char *input_tab(char *buf, int place, int *lastWasTab, int *newplace, int *list)
|
|||||||
/* Check to see if all matches share a beginning, and, if so,
|
/* Check to see if all matches share a beginning, and, if so,
|
||||||
tack it onto buf and then beep */
|
tack it onto buf and then beep */
|
||||||
|
|
||||||
if (strcmp(buf, "") && strstr(buf, "/")) {
|
if (buf[0] != '\0' && strstr(buf, "/")) {
|
||||||
for (tmp = buf + strlen(buf); *tmp != '/' && tmp != buf;
|
for (tmp = buf + strlen(buf); *tmp != '/' && tmp != buf;
|
||||||
tmp--);
|
tmp--);
|
||||||
tmp++;
|
tmp++;
|
||||||
|
7
move.c
7
move.c
@ -113,12 +113,8 @@ int do_down(void)
|
|||||||
wrap_reset();
|
wrap_reset();
|
||||||
if (current->next != NULL) {
|
if (current->next != NULL) {
|
||||||
update_line(current->prev, 0);
|
update_line(current->prev, 0);
|
||||||
|
|
||||||
if (placewewant > 0)
|
if (placewewant > 0)
|
||||||
current_x = actual_x(current->next, placewewant);
|
current_x = actual_x(current->next, placewewant);
|
||||||
|
|
||||||
if (current_x > strlen(current->next->data))
|
|
||||||
current_x = strlen(current->next->data);
|
|
||||||
} else {
|
} else {
|
||||||
UNSET(KEEP_CUTBUFFER);
|
UNSET(KEEP_CUTBUFFER);
|
||||||
check_statblank();
|
check_statblank();
|
||||||
@ -193,9 +189,6 @@ int do_up(void)
|
|||||||
if (current->prev != NULL) {
|
if (current->prev != NULL) {
|
||||||
if (placewewant > 0)
|
if (placewewant > 0)
|
||||||
current_x = actual_x(current->prev, placewewant);
|
current_x = actual_x(current->prev, placewewant);
|
||||||
|
|
||||||
if (current_x > strlen(current->prev->data))
|
|
||||||
current_x = strlen(current->prev->data);
|
|
||||||
}
|
}
|
||||||
if (current_y > 0)
|
if (current_y > 0)
|
||||||
current_y--;
|
current_y--;
|
||||||
|
8
nano.1
8
nano.1
@ -130,9 +130,11 @@ Nano will try to dump the buffer into an emergency file in some cases.
|
|||||||
Mainly, this will happen if Nano receives a SIGHUP or runs out of
|
Mainly, this will happen if Nano receives a SIGHUP or runs out of
|
||||||
memory, when it will write the buffer into a file named "nano.save" if the
|
memory, when it will write the buffer into a file named "nano.save" if the
|
||||||
buffer didn't have a name already, or will add a ".save" suffix to the
|
buffer didn't have a name already, or will add a ".save" suffix to the
|
||||||
current filename. In multibuffer mode, nano will write all the open buffers to
|
current filename. If an emergency file with that name already exists in
|
||||||
the respective emergency files. Nano will \fBnot\fP write this file if a
|
the current directory, ".save" and a number (e.g. ".save.1") will be
|
||||||
previous one exists in the current directory.
|
suffixed to the current filename in order to make it unique. In
|
||||||
|
multibuffer mode, nano will write all the open buffers to the respective
|
||||||
|
emergency files.
|
||||||
.SH BUGS
|
.SH BUGS
|
||||||
Please send any comments or bug reports to
|
Please send any comments or bug reports to
|
||||||
.br
|
.br
|
||||||
|
16
nano.1.html
16
nano.1.html
@ -88,6 +88,10 @@ Set the size (width) of a tab.
|
|||||||
|
|
||||||
<DD>
|
<DD>
|
||||||
Show the current version number and author.
|
Show the current version number and author.
|
||||||
|
<DT><B>-Y (--syntax=[str])</B>
|
||||||
|
|
||||||
|
<DD>
|
||||||
|
Specify a specific syntax hilighting from the .nanorc to use (if available).
|
||||||
<DT><B>-c (--const)</B>
|
<DT><B>-c (--const)</B>
|
||||||
|
|
||||||
<DD>
|
<DD>
|
||||||
@ -171,9 +175,11 @@ Nano will try to dump the buffer into an emergency file in some cases.
|
|||||||
Mainly, this will happen if Nano receives a SIGHUP or runs out of
|
Mainly, this will happen if Nano receives a SIGHUP or runs out of
|
||||||
memory, when it will write the buffer into a file named "nano.save" if the
|
memory, when it will write the buffer into a file named "nano.save" if the
|
||||||
buffer didn't have a name already, or will add a ".save" suffix to the
|
buffer didn't have a name already, or will add a ".save" suffix to the
|
||||||
current filename. In multibuffer mode, nano will write all the open buffers to
|
current filename. If an emergency file with that name already exists in
|
||||||
the respective emergency files. Nano will <B>not</B> write this file if a
|
the current directory, ".save" and a number (e.g. ".save.1") will be
|
||||||
previous one exists in the current directory.
|
suffixed to the current filename in order to make it unique. In
|
||||||
|
multibuffer mode, nano will write all the open buffers to the respective
|
||||||
|
emergency files.
|
||||||
<A NAME="lbAG"> </A>
|
<A NAME="lbAG"> </A>
|
||||||
<H2>BUGS</H2>
|
<H2>BUGS</H2>
|
||||||
|
|
||||||
@ -201,7 +207,7 @@ subject of "subscribe".
|
|||||||
Chris Allegretta <<A HREF="mailto:chrisa@asty.org">chrisa@asty.org</A>>, et al (see AUTHORS and THANKS for
|
Chris Allegretta <<A HREF="mailto:chrisa@asty.org">chrisa@asty.org</A>>, et al (see AUTHORS and THANKS for
|
||||||
details).
|
details).
|
||||||
This manual page was originally written by Jordi Mallach
|
This manual page was originally written by Jordi Mallach
|
||||||
<<A HREF="mailto:jordi@sindominio.net">jordi@sindominio.net</A>>, for the Debian GNU/Linux system (but may be
|
<<A HREF="mailto:jordi@sindominio.net">jordi@sindominio.net</A>>, for the Debian GNU system (but may be
|
||||||
used by others).
|
used by others).
|
||||||
<P>
|
<P>
|
||||||
|
|
||||||
@ -221,6 +227,6 @@ used by others).
|
|||||||
This document was created by
|
This document was created by
|
||||||
<A HREF="http://localhost/cgi-bin/man/man2html">man2html</A>,
|
<A HREF="http://localhost/cgi-bin/man/man2html">man2html</A>,
|
||||||
using the manual pages.<BR>
|
using the manual pages.<BR>
|
||||||
Time: 12:14:20 GMT, March 04, 2002
|
Time: 19:17:30 GMT, May 08, 2002
|
||||||
</BODY>
|
</BODY>
|
||||||
</HTML>
|
</HTML>
|
||||||
|
28
nano.c
28
nano.c
@ -143,9 +143,14 @@ void die(char *msg, ...)
|
|||||||
/* if we already saved the file above (i. e. if it was the
|
/* if we already saved the file above (i. e. if it was the
|
||||||
currently loaded file), don't save it again */
|
currently loaded file), don't save it again */
|
||||||
if (tmp != open_files) {
|
if (tmp != open_files) {
|
||||||
|
/* make sure open_files->fileage and fileage, and
|
||||||
|
open_files->filebot and filebot, are in sync; they
|
||||||
|
might not be if lines have been cut from the top or
|
||||||
|
bottom of the file */
|
||||||
fileage = open_files->fileage;
|
fileage = open_files->fileage;
|
||||||
|
filebot = open_files->filebot;
|
||||||
/* save the file if it's been modified */
|
/* save the file if it's been modified */
|
||||||
if (open_files->file_modified)
|
if (open_files->file_flags & MODIFIED)
|
||||||
die_save_file(open_files->filename);
|
die_save_file(open_files->filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,7 +173,7 @@ void die_save_file(char *die_filename)
|
|||||||
if (die_filename[0] == '\0') {
|
if (die_filename[0] == '\0') {
|
||||||
name = "nano.save";
|
name = "nano.save";
|
||||||
ret = get_next_filename(name);
|
ret = get_next_filename(name);
|
||||||
if (strcmp(ret, ""))
|
if (ret[0] != '\0')
|
||||||
i = write_file(ret, 1, 0, 0);
|
i = write_file(ret, 1, 0, 0);
|
||||||
name = ret;
|
name = ret;
|
||||||
}
|
}
|
||||||
@ -177,7 +182,7 @@ void die_save_file(char *die_filename)
|
|||||||
strcpy(buf, die_filename);
|
strcpy(buf, die_filename);
|
||||||
strcat(buf, ".save");
|
strcat(buf, ".save");
|
||||||
ret = get_next_filename(buf);
|
ret = get_next_filename(buf);
|
||||||
if (strcmp(ret, ""))
|
if (ret[0] != '\0')
|
||||||
i = write_file(ret, 1, 0, 0);
|
i = write_file(ret, 1, 0, 0);
|
||||||
name = ret;
|
name = ret;
|
||||||
free(buf);
|
free(buf);
|
||||||
@ -637,6 +642,7 @@ openfilestruct *make_new_opennode(openfilestruct * prevnode)
|
|||||||
newnode = nmalloc(sizeof(openfilestruct));
|
newnode = nmalloc(sizeof(openfilestruct));
|
||||||
newnode->filename = NULL;
|
newnode->filename = NULL;
|
||||||
newnode->fileage = NULL;
|
newnode->fileage = NULL;
|
||||||
|
newnode->filebot = NULL;
|
||||||
|
|
||||||
newnode->prev = prevnode;
|
newnode->prev = prevnode;
|
||||||
newnode->next = NULL;
|
newnode->next = NULL;
|
||||||
@ -1267,7 +1273,7 @@ int do_backspace(void)
|
|||||||
line we're on now is NOT blank. if it is blank we
|
line we're on now is NOT blank. if it is blank we
|
||||||
can just use IT for the magic line. This is how Pico
|
can just use IT for the magic line. This is how Pico
|
||||||
appears to do it, in any case */
|
appears to do it, in any case */
|
||||||
if (strcmp(current->data, "")) {
|
if (current->data[0] != '\0') {
|
||||||
new_magicline();
|
new_magicline();
|
||||||
fix_editbot();
|
fix_editbot();
|
||||||
}
|
}
|
||||||
@ -1297,7 +1303,7 @@ int do_delete(void)
|
|||||||
/* blbf -> blank line before filebot (see below) */
|
/* blbf -> blank line before filebot (see below) */
|
||||||
int blbf = 0;
|
int blbf = 0;
|
||||||
|
|
||||||
if (current->next == filebot && !strcmp(current->data, ""))
|
if (current->next == filebot && current->data[0] == '\0')
|
||||||
blbf = 1;
|
blbf = 1;
|
||||||
|
|
||||||
if (current_x != strlen(current->data)) {
|
if (current_x != strlen(current->data)) {
|
||||||
@ -1329,7 +1335,7 @@ int do_delete(void)
|
|||||||
|
|
||||||
/* Please see the comment in do_backspace if you don't understand
|
/* Please see the comment in do_backspace if you don't understand
|
||||||
this test */
|
this test */
|
||||||
if (current == filebot && strcmp(current->data, "")) {
|
if (current == filebot && current->data[0] != '\0') {
|
||||||
new_magicline();
|
new_magicline();
|
||||||
fix_editbot();
|
fix_editbot();
|
||||||
totsize++;
|
totsize++;
|
||||||
@ -1407,7 +1413,7 @@ int do_int_spell_fix(char *word)
|
|||||||
|
|
||||||
search_last_line = FALSE;
|
search_last_line = FALSE;
|
||||||
|
|
||||||
if (strcmp(prevanswer,answer) != 0) {
|
if (strcmp(prevanswer, answer)) {
|
||||||
j = i;
|
j = i;
|
||||||
do_replace_loop(prevanswer, fileage, &beginx_top, TRUE, &j);
|
do_replace_loop(prevanswer, fileage, &beginx_top, TRUE, &j);
|
||||||
}
|
}
|
||||||
@ -1475,7 +1481,6 @@ int do_int_speller(char *tempfile_name)
|
|||||||
}
|
}
|
||||||
close(tempfile_fd);
|
close(tempfile_fd);
|
||||||
|
|
||||||
|
|
||||||
/* send spell's standard out to the pipe */
|
/* send spell's standard out to the pipe */
|
||||||
|
|
||||||
if (dup2(in_fd[1], STDOUT_FILENO) != STDOUT_FILENO) {
|
if (dup2(in_fd[1], STDOUT_FILENO) != STDOUT_FILENO) {
|
||||||
@ -1662,8 +1667,7 @@ int do_spell(void)
|
|||||||
|
|
||||||
#ifdef ENABLE_MULTIBUFFER
|
#ifdef ENABLE_MULTIBUFFER
|
||||||
/* update the current open_files entry before spell-checking, in case
|
/* update the current open_files entry before spell-checking, in case
|
||||||
any problems occur; the case of there being no open_files entries
|
any problems occur */
|
||||||
is handled elsewhere (before we reach this point) */
|
|
||||||
add_open_file(1);
|
add_open_file(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -3098,8 +3102,6 @@ int main(int argc, char *argv[])
|
|||||||
fprintf(stderr, _("Main: open file\n"));
|
fprintf(stderr, _("Main: open file\n"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
titlebar(NULL);
|
|
||||||
|
|
||||||
/* Now we check to see if argv[optind] is non-null to determine if
|
/* Now we check to see if argv[optind] is non-null to determine if
|
||||||
we're dealing with a new file or not, not argc == 1... */
|
we're dealing with a new file or not, not argc == 1... */
|
||||||
if (argv[optind] == NULL)
|
if (argv[optind] == NULL)
|
||||||
@ -3107,6 +3109,8 @@ int main(int argc, char *argv[])
|
|||||||
else
|
else
|
||||||
open_file(filename, 0, 0);
|
open_file(filename, 0, 0);
|
||||||
|
|
||||||
|
titlebar(NULL);
|
||||||
|
|
||||||
if (startline > 0)
|
if (startline > 0)
|
||||||
do_gotoline(startline, 0);
|
do_gotoline(startline, 0);
|
||||||
else
|
else
|
||||||
|
11
nano.h
11
nano.h
@ -82,9 +82,18 @@ typedef struct openfilestruct {
|
|||||||
struct openfilestruct *next; /* Next node */
|
struct openfilestruct *next; /* Next node */
|
||||||
struct openfilestruct *prev; /* Previous node */
|
struct openfilestruct *prev; /* Previous node */
|
||||||
struct filestruct *fileage; /* Current file */
|
struct filestruct *fileage; /* Current file */
|
||||||
|
struct filestruct *filebot; /* Current file's last line */
|
||||||
|
#ifndef NANO_SMALL
|
||||||
|
struct filestruct *file_mark_beginbuf;
|
||||||
|
/* Current file's beginning marked line */
|
||||||
|
int file_mark_beginx; /* Current file's beginning marked line's
|
||||||
|
x-coordinate position */
|
||||||
|
#endif
|
||||||
int file_current_x; /* Current file's x-coordinate position */
|
int file_current_x; /* Current file's x-coordinate position */
|
||||||
int file_current_y; /* Current file's y-coordinate position */
|
int file_current_y; /* Current file's y-coordinate position */
|
||||||
int file_modified; /* Current file's modification status */
|
int file_flags; /* Current file's flags: modification
|
||||||
|
status (and marking status, if
|
||||||
|
available) */
|
||||||
int file_placewewant; /* Current file's place we want */
|
int file_placewewant; /* Current file's place we want */
|
||||||
int file_totlines; /* Current file's total number of lines */
|
int file_totlines; /* Current file's total number of lines */
|
||||||
long file_totsize; /* Current file's total size */
|
long file_totsize; /* Current file's total size */
|
||||||
|
@ -9,7 +9,7 @@ Release : %{rel}
|
|||||||
Copyright : GPL
|
Copyright : GPL
|
||||||
Group : Console/Editors
|
Group : Console/Editors
|
||||||
URL : http://www.nano-editor.org
|
URL : http://www.nano-editor.org
|
||||||
Source : http://www.nano-editor.org/dist/v1.1/%{name}/%{name}-%{ver}.tar.gz
|
Source : http://www.nano-editor.org/dist/v1.1/%{name}-%{ver}.tar.gz
|
||||||
BuildRoot : /var/tmp/%{name}-buildroot
|
BuildRoot : /var/tmp/%{name}-buildroot
|
||||||
Requires : ncurses
|
Requires : ncurses
|
||||||
|
|
||||||
|
4
proto.h
4
proto.h
@ -132,11 +132,11 @@ int do_cut_text(void);
|
|||||||
int do_uncut_text(void);
|
int do_uncut_text(void);
|
||||||
int no_help(void);
|
int no_help(void);
|
||||||
int renumber_all(void);
|
int renumber_all(void);
|
||||||
int open_file(char *filename, int insert, int quiet);
|
int open_file(const char *filename, int insert, int quiet);
|
||||||
int do_insertfile(int loading_file);
|
int do_insertfile(int loading_file);
|
||||||
int num_of_digits(int n);
|
int num_of_digits(int n);
|
||||||
int open_pipe(char *command);
|
int open_pipe(char *command);
|
||||||
int read_file(FILE *f, char *filename, int quiet);
|
int read_file(FILE *f, const char *filename, int quiet);
|
||||||
|
|
||||||
#ifdef ENABLE_MULTIBUFFER
|
#ifdef ENABLE_MULTIBUFFER
|
||||||
int add_open_file(int update);
|
int add_open_file(int update);
|
||||||
|
23
rcfile.c
23
rcfile.c
@ -24,6 +24,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <pwd.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@ -546,9 +548,7 @@ void do_rcfile(void)
|
|||||||
char *unable = _("Unable to open ~/.nanorc file, %s");
|
char *unable = _("Unable to open ~/.nanorc file, %s");
|
||||||
struct stat fileinfo;
|
struct stat fileinfo;
|
||||||
FILE *rcstream;
|
FILE *rcstream;
|
||||||
|
struct passwd *userage;
|
||||||
if (getenv("HOME") == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
nanorc = charalloc(strlen(SYSCONFDIR) + 10);
|
nanorc = charalloc(strlen(SYSCONFDIR) + 10);
|
||||||
sprintf(nanorc, "%s/nanorc", SYSCONFDIR);
|
sprintf(nanorc, "%s/nanorc", SYSCONFDIR);
|
||||||
@ -562,10 +562,21 @@ void do_rcfile(void)
|
|||||||
fclose(rcstream);
|
fclose(rcstream);
|
||||||
}
|
}
|
||||||
|
|
||||||
nanorc = charalloc(strlen(getenv("HOME")) + 10);
|
|
||||||
sprintf(nanorc, "%s/.nanorc", getenv("HOME"));
|
|
||||||
|
|
||||||
lineno = 0;
|
lineno = 0;
|
||||||
|
|
||||||
|
/* Determine home directory using getpwent(), don't rely on $HOME */
|
||||||
|
for (userage = getpwent(); userage != NULL
|
||||||
|
&& userage->pw_uid != geteuid(); userage = getpwent())
|
||||||
|
;
|
||||||
|
|
||||||
|
if (userage == NULL) {
|
||||||
|
rcfile_error(_("I can't find my home directory! Wah!"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
nanorc = charalloc(strlen(userage->pw_dir) + 10);
|
||||||
|
sprintf(nanorc, "%s/.nanorc", userage->pw_dir);
|
||||||
|
|
||||||
if (stat(nanorc, &fileinfo) == -1) {
|
if (stat(nanorc, &fileinfo) == -1) {
|
||||||
|
|
||||||
/* Abort if the file doesn't exist and there's some other kind
|
/* Abort if the file doesn't exist and there's some other kind
|
||||||
|
29
search.c
29
search.c
@ -56,11 +56,11 @@ void search_init_globals(void)
|
|||||||
{
|
{
|
||||||
if (last_search == NULL) {
|
if (last_search == NULL) {
|
||||||
last_search = charalloc(1);
|
last_search = charalloc(1);
|
||||||
last_search[0] = 0;
|
last_search[0] = '\0';
|
||||||
}
|
}
|
||||||
if (last_replace == NULL) {
|
if (last_replace == NULL) {
|
||||||
last_replace = charalloc(1);
|
last_replace = charalloc(1);
|
||||||
last_replace[0] = 0;
|
last_replace[0] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ int search_init(int replacing)
|
|||||||
search_init_globals();
|
search_init_globals();
|
||||||
|
|
||||||
buf = charalloc(strlen(last_search) + 5);
|
buf = charalloc(strlen(last_search) + 5);
|
||||||
buf[0] = 0;
|
buf[0] = '\0';
|
||||||
|
|
||||||
|
|
||||||
/* Clear the backupstring if we've changed from Pico mode to regular
|
/* Clear the backupstring if we've changed from Pico mode to regular
|
||||||
@ -123,7 +123,7 @@ int search_init(int replacing)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
strcpy(buf, "");
|
buf[0] = '\0';
|
||||||
|
|
||||||
/* This is now one simple call. It just does a lot */
|
/* This is now one simple call. It just does a lot */
|
||||||
i = statusq(0, replacing ? replace_list : whereis_list, backupstring,
|
i = statusq(0, replacing ? replace_list : whereis_list, backupstring,
|
||||||
@ -247,10 +247,9 @@ int past_editbuff; /* findnextstr() is now searching lines not displayed */
|
|||||||
filestruct *findnextstr(int quiet, int bracket_mode, filestruct * begin, int beginx,
|
filestruct *findnextstr(int quiet, int bracket_mode, filestruct * begin, int beginx,
|
||||||
char *needle)
|
char *needle)
|
||||||
{
|
{
|
||||||
filestruct *fileptr;
|
filestruct *fileptr = current;
|
||||||
char *searchstr, *rev_start = NULL, *found = NULL;
|
char *searchstr, *rev_start = NULL, *found = NULL;
|
||||||
int current_x_find = 0;
|
int current_x_find = 0;
|
||||||
fileptr = current;
|
|
||||||
|
|
||||||
past_editbuff = 0;
|
past_editbuff = 0;
|
||||||
|
|
||||||
@ -278,6 +277,7 @@ filestruct *findnextstr(int quiet, int bracket_mode, filestruct * begin, int beg
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
update_line(fileptr, 0);
|
||||||
fileptr = fileptr->next;
|
fileptr = fileptr->next;
|
||||||
|
|
||||||
if (fileptr == editbot)
|
if (fileptr == editbot)
|
||||||
@ -340,6 +340,7 @@ filestruct *findnextstr(int quiet, int bracket_mode, filestruct * begin, int beg
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
update_line(fileptr, 0);
|
||||||
fileptr = fileptr->prev;
|
fileptr = fileptr->prev;
|
||||||
|
|
||||||
if (fileptr == edittop->prev)
|
if (fileptr == edittop->prev)
|
||||||
@ -436,7 +437,7 @@ int do_search(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* The sneaky user deleted the previous search string */
|
/* The sneaky user deleted the previous search string */
|
||||||
if (!ISSET(PICO_MODE) && !strcmp(answer, "")) {
|
if (!ISSET(PICO_MODE) && answer[0] == '\0') {
|
||||||
statusbar(_("Search Cancelled"));
|
statusbar(_("Search Cancelled"));
|
||||||
search_abort();
|
search_abort();
|
||||||
return 0;
|
return 0;
|
||||||
@ -445,7 +446,7 @@ int do_search(void)
|
|||||||
/* If answer is now == "", then PICO_MODE is set. So, copy
|
/* If answer is now == "", then PICO_MODE is set. So, copy
|
||||||
last_search into answer... */
|
last_search into answer... */
|
||||||
|
|
||||||
if (!strcmp(answer, ""))
|
if (answer[0] == '\0')
|
||||||
answer = mallocstrcpy(answer, last_search);
|
answer = mallocstrcpy(answer, last_search);
|
||||||
else
|
else
|
||||||
last_search = mallocstrcpy(last_search, answer);
|
last_search = mallocstrcpy(last_search, answer);
|
||||||
@ -604,7 +605,7 @@ int do_replace_loop(char *prevanswer, filestruct *begin, int *beginx,
|
|||||||
|
|
||||||
switch (*i) {
|
switch (*i) {
|
||||||
case -1: /* Aborted enter */
|
case -1: /* Aborted enter */
|
||||||
if (strcmp(last_replace, ""))
|
if (last_replace[0] != '\0')
|
||||||
answer = mallocstrcpy(answer, last_replace);
|
answer = mallocstrcpy(answer, last_replace);
|
||||||
statusbar(_("Replace Cancelled"));
|
statusbar(_("Replace Cancelled"));
|
||||||
replace_abort();
|
replace_abort();
|
||||||
@ -620,7 +621,7 @@ int do_replace_loop(char *prevanswer, filestruct *begin, int *beginx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ISSET(PICO_MODE) && !strcmp(answer, ""))
|
if (ISSET(PICO_MODE) && answer[0] == '\0')
|
||||||
answer = mallocstrcpy(answer, last_replace);
|
answer = mallocstrcpy(answer, last_replace);
|
||||||
|
|
||||||
last_replace = mallocstrcpy(last_replace, answer);
|
last_replace = mallocstrcpy(last_replace, answer);
|
||||||
@ -739,7 +740,7 @@ int do_replace(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Again, there was a previous string, but they deleted it and hit enter */
|
/* Again, there was a previous string, but they deleted it and hit enter */
|
||||||
if (!ISSET(PICO_MODE) && !strcmp(answer, "")) {
|
if (!ISSET(PICO_MODE) && answer[0] == '\0') {
|
||||||
statusbar(_("Replace Cancelled"));
|
statusbar(_("Replace Cancelled"));
|
||||||
replace_abort();
|
replace_abort();
|
||||||
return 0;
|
return 0;
|
||||||
@ -747,7 +748,7 @@ int do_replace(void)
|
|||||||
|
|
||||||
/* If answer is now == "", then PICO_MODE is set. So, copy
|
/* If answer is now == "", then PICO_MODE is set. So, copy
|
||||||
last_search into answer (and prevanswer)... */
|
last_search into answer (and prevanswer)... */
|
||||||
if (!strcmp(answer, "")) {
|
if (answer[0] == '\0') {
|
||||||
answer = mallocstrcpy(answer, last_search);
|
answer = mallocstrcpy(answer, last_search);
|
||||||
prevanswer = mallocstrcpy(prevanswer, last_search);
|
prevanswer = mallocstrcpy(prevanswer, last_search);
|
||||||
} else {
|
} else {
|
||||||
@ -757,7 +758,7 @@ int do_replace(void)
|
|||||||
|
|
||||||
if (ISSET(PICO_MODE)) {
|
if (ISSET(PICO_MODE)) {
|
||||||
buf = charalloc(strlen(last_replace) + 5);
|
buf = charalloc(strlen(last_replace) + 5);
|
||||||
if (strcmp(last_replace, "")) {
|
if (last_replace[0] != '\0') {
|
||||||
if (strlen(last_replace) > (COLS / 3)) {
|
if (strlen(last_replace) > (COLS / 3)) {
|
||||||
strncpy(buf, last_replace, COLS / 3);
|
strncpy(buf, last_replace, COLS / 3);
|
||||||
sprintf(&buf[COLS / 3 - 1], "...");
|
sprintf(&buf[COLS / 3 - 1], "...");
|
||||||
@ -857,7 +858,6 @@ int do_gotoline_void(void)
|
|||||||
#if (defined ENABLE_MULTIBUFFER || !defined DISABLE_SPELLER)
|
#if (defined ENABLE_MULTIBUFFER || !defined DISABLE_SPELLER)
|
||||||
void do_gotopos(int line, int pos_x, int pos_y, int pos_placewewant)
|
void do_gotopos(int line, int pos_x, int pos_y, int pos_placewewant)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* since do_gotoline() resets the x-coordinate but not the
|
/* since do_gotoline() resets the x-coordinate but not the
|
||||||
y-coordinate, set the coordinates up this way */
|
y-coordinate, set the coordinates up this way */
|
||||||
current_y = pos_y;
|
current_y = pos_y;
|
||||||
@ -877,7 +877,6 @@ void do_gotopos(int line, int pos_x, int pos_y, int pos_placewewant)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(NANO_SMALL) && defined(HAVE_REGEX_H)
|
#if !defined(NANO_SMALL) && defined(HAVE_REGEX_H)
|
||||||
|
|
||||||
int do_find_bracket(void)
|
int do_find_bracket(void)
|
||||||
{
|
{
|
||||||
char ch_under_cursor, wanted_ch;
|
char ch_under_cursor, wanted_ch;
|
||||||
|
23
winio.c
23
winio.c
@ -91,7 +91,6 @@ int xpt(filestruct * fileptr, int index)
|
|||||||
return tabs;
|
return tabs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Return the actual place on the screen of current->data[current_x], which
|
/* Return the actual place on the screen of current->data[current_x], which
|
||||||
should always be > current_x */
|
should always be > current_x */
|
||||||
int xplustabs(void)
|
int xplustabs(void)
|
||||||
@ -99,7 +98,6 @@ int xplustabs(void)
|
|||||||
return xpt(current, current_x);
|
return xpt(current, current_x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Return what current_x should be, given xplustabs() for the line,
|
/* Return what current_x should be, given xplustabs() for the line,
|
||||||
* given a start position in the filestruct's data */
|
* given a start position in the filestruct's data */
|
||||||
int actual_x_from_start(filestruct * fileptr, int xplus, int start)
|
int actual_x_from_start(filestruct * fileptr, int xplus, int start)
|
||||||
@ -111,19 +109,20 @@ int actual_x_from_start(filestruct * fileptr, int xplus, int start)
|
|||||||
|
|
||||||
for (i = start; tot <= xplus && fileptr->data[i] != 0; i++, tot++)
|
for (i = start; tot <= xplus && fileptr->data[i] != 0; i++, tot++)
|
||||||
if (fileptr->data[i] == NANO_CONTROL_I) {
|
if (fileptr->data[i] == NANO_CONTROL_I) {
|
||||||
if (tot % tabsize == 0)
|
if (tot % tabsize != 0)
|
||||||
tot++;
|
|
||||||
else
|
|
||||||
tot += tabsize - (tot % tabsize);
|
tot += tabsize - (tot % tabsize);
|
||||||
} else if (fileptr->data[i] & 0x80)
|
} else if (fileptr->data[i] & 0x80)
|
||||||
tot++; /* Make 8 bit chars only 1 column (again) */
|
tot++; /* Make 8 bit chars only 1 column (again) */
|
||||||
else if (fileptr->data[i] < 32)
|
else if (fileptr->data[i] < 32 || fileptr->data[i] == 127) {
|
||||||
|
i++;
|
||||||
tot += 2;
|
tot += 2;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, _("actual_x_from_start for xplus=%d returned %d\n"),
|
fprintf(stderr, _("actual_x_from_start for xplus=%d returned %d\n"),
|
||||||
xplus, i);
|
xplus, i);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return i - start;
|
return i - start;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,7 +150,7 @@ int strnlenpt(char *buf, int size)
|
|||||||
} else if (buf[i] & 0x80)
|
} else if (buf[i] & 0x80)
|
||||||
/* Make 8 bit chars only 1 column! */
|
/* Make 8 bit chars only 1 column! */
|
||||||
;
|
;
|
||||||
else if (buf[i] < 32)
|
else if (buf[i] < 32 || buf[i] == 127)
|
||||||
tabs++;
|
tabs++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +162,6 @@ int strlenpt(char *buf)
|
|||||||
return strnlenpt(buf, strlen(buf));
|
return strnlenpt(buf, strlen(buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* resets current_y, based on the position of current, and puts the cursor at
|
/* resets current_y, based on the position of current, and puts the cursor at
|
||||||
(current_y, current_x) */
|
(current_y, current_x) */
|
||||||
void reset_cursor(void)
|
void reset_cursor(void)
|
||||||
@ -510,7 +508,7 @@ int nanogetstr(int allowtabs, char *buf, char *def, shortcut *s,
|
|||||||
free(inputbuf);
|
free(inputbuf);
|
||||||
|
|
||||||
/* In pico mode, just check for a blank answer here */
|
/* In pico mode, just check for a blank answer here */
|
||||||
if (((ISSET(PICO_MODE)) && !strcmp(answer, "")))
|
if (ISSET(PICO_MODE) && answer[0] == '\0')
|
||||||
return -2;
|
return -2;
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
@ -546,7 +544,7 @@ void titlebar(char *path)
|
|||||||
|
|
||||||
namelen = strlen(what);
|
namelen = strlen(what);
|
||||||
|
|
||||||
if (!strcmp(what, ""))
|
if (what[0] == '\0')
|
||||||
mvwaddstr(topwin, 0, COLS / 2 - 6, _("New Buffer"));
|
mvwaddstr(topwin, 0, COLS / 2 - 6, _("New Buffer"));
|
||||||
else {
|
else {
|
||||||
if (namelen > space) {
|
if (namelen > space) {
|
||||||
@ -567,7 +565,8 @@ void titlebar(char *path)
|
|||||||
}
|
}
|
||||||
if (ISSET(MODIFIED))
|
if (ISSET(MODIFIED))
|
||||||
mvwaddstr(topwin, 0, COLS - 10, _("Modified"));
|
mvwaddstr(topwin, 0, COLS - 10, _("Modified"));
|
||||||
|
else if (ISSET(VIEW_MODE))
|
||||||
|
mvwaddstr(topwin, 0, COLS - 10, _("View"));
|
||||||
|
|
||||||
#ifdef ENABLE_COLOR
|
#ifdef ENABLE_COLOR
|
||||||
color_off(topwin, COLOR_TITLEBAR);
|
color_off(topwin, COLOR_TITLEBAR);
|
||||||
@ -1170,7 +1169,7 @@ void update_line(filestruct * fileptr, int index)
|
|||||||
|
|
||||||
fileptr->data[pos] = '\0';
|
fileptr->data[pos] = '\0';
|
||||||
|
|
||||||
/* Now, Paint the line */
|
/* Now, paint the line */
|
||||||
if (current == fileptr && index > COLS - 2) {
|
if (current == fileptr && index > COLS - 2) {
|
||||||
/* This handles when the current line is beyond COLS */
|
/* This handles when the current line is beyond COLS */
|
||||||
/* It requires figuring out what page we're on */
|
/* It requires figuring out what page we're on */
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user