- Translation updates (see po/ChangeLog for details).
- Upgraded to gettext 0.11.2 (Jordi).
Removed intl/ entirely, and a few more tweaks by gettextize.
+ - i18nized a few strings used in DEBUG mode. (DLR)
+ - Some chars being assigned 0 are now assigned '\0'. (DLR)
+ - Put header files in a more consistent order. (DLR)
+ - Remove some unneeded blank lines and spaces, and make some
+ spacing more consistent. (DLR)
+ - When possible, use iscntrl() to determine whether a character
+ is a control character or not. (DLR)
+ - Miscellaneous typo fixes. (DLR)
+- files.c:
+ read_file(), read_line():
+ - Rework to properly handle nulls in the input file, fix
+ detection of binary files to properly mark a file as binary if
+ the only binary characters it contains are ASCII 127's, and
+ after reading the last line of a file that doesn't end in a
+ newline, increment totsize. Remove previous kludge to set
+ totsize properly. (DLR)
+ write_file():
+ - Rework to properly handle nulls in the input file. When
+ appending/prepending, don't change the current file's name to
+ the name of the file it's being appended/prepended to. When
+ writing a marked selection to a file, save and restore totsize
+ so it isn't decreased by the size of the selection afterward.
+ (DLR)
+ append_slash_if_dir(), input_tab():
+ - Changed a variable name: lastWasTab -> lastwastab. (DLR)
- global.c:
shortcut_init()
- Rework IFHELP macro (David Benbennick).
+- move.c:
+ page_down(), page_up():
+ - Put sanity checks for current_x back in, to avoid rare
+ segfaults (oops). Now, however, they are only called when
+ placewewant is zero instead of being called unconditionally;
+ see changes to winio.c:actual_x_from_start() below. (DLR)
- nanorc.sample:
- Put in much less crappy example regex rules for c-file.
+- nano.c:
+ clear_filename():
+ - Remove this function, as it has unneeded functionality, is
+ short enough to be inlined, and is only called in two spots
+ anyway. (DLR)
+ do_int_spell(), do_alt_spell():
+ - Rework to save the marked selection before doing spell checking
+ and restore it afterward. (DLR)
+ main():
+ - Rework to blank out filename manually before doing anything
+ with it, instead of calling clear_filename() in two places.
+ Make startline an int instead of a long, since it's supposed to
+ hold a line number. (DLR)
+- search.c:
+ findnextstr():
+ - Update the current line at current_x if we don't find a match.
+ (DLR)
+ do_gotopos():
+ - Simplify the sanity check to only put x within the range of the
+ current line; don't call actual_x() anymore. (DLR)
+- utils.c:
+ - Add sunder() and unsunder(). These functions convert nulls
+ other than the terminating null in strings to newlines and
+ back; they're used to handle null characters in files properly.
+ (DLR)
+- winio.c:
+ actual_x_from_start():
+ - Overhaul to make cursor placement more like that of Pico: add
+ sanity check for i, and then place i as close to the value of
+ xplus column as possible. This change is most noticeable when
+ moving down through binary files. (DLR)
+ nanogetstr():
+ - After the user presses Enter at the prompt, refresh the edit
+ window in case there's a list of possible filename matches
+ (left over from attempted tab completion) on it. (DLR)
+ update_line():
+ - When marking control characters, make sure the mark moves
+ forward by two characters inctead of one. Rework control
+ character display routine to display newlines within the line
+ (which should never occur under normal circumstances; they will
+ only be there if the line had nulls in it and was unsunder()ed
+ beforehand) as ^@'s. (DLR)
+ do_help():
+ - Add support for the handled keyboard escape sequences in the
+ help menu, as they are needed with some terminals (e.g. xterm
+ with TERM=ansi). (DLR)
- THANKS:
- Completed a bit (Jordi).
GNU nano 1.1.9 - 05/12/2002
(David Lawrence Ramsey).
- winio.c:
edit_add()
- - Changed some syntax hilight computations for the sake of COLS.
+ - Changed some syntax highlight computations for the sake of COLS.
- Add in the necessary regfree() calls to stop nano from leaking
memory like a sieve when using color syntax highlighting :-)
botombars(), onekey()
- UTF-8 support.
- Undo/Redo key?
-
Old requests:
For version 1.0:
/* Define this if your curses library has the use_default_colors command */
#undef HAVE_USE_DEFAULT_COLORS
-/* Define this to have syntax hilighting, requires ENABLE_NANORC too! */
+/* Define this to have syntax highlighting, requires ENABLE_NANORC too! */
#undef ENABLE_COLOR
/* Define this to enable undoing....something */
void color_on(WINDOW *win, int whatever)
{
/* Temporary fallback, if the color value hasn't been set,
- turn on hilighting */
+ turn on highlighting */
if (!colors[whatever - FIRST_COLORNUM].set) {
wattron(win, A_REVERSE);
return;
wattroff(win, A_BOLD);
}
-
void colorinit_one(int colortoset, short fg, short bg, int bold)
{
colors[colortoset - FIRST_COLORNUM].fg = fg;
init_pair(i, tmpcolor->fg, tmpcolor->bg);
#ifdef DEBUG
- fprintf(stderr, "Running init_pair with fg = %d and bg = %d\n", tmpcolor->fg, tmpcolor->bg);
+ fprintf(stderr, _("Running init_pair with fg = %d and bg = %d\n"), tmpcolor->fg, tmpcolor->bg);
#endif
tmpcolor->pairnum = i;
}
#endif /* ENABLE_COLOR */
-
current_x = top_x;
update_cursor();
}
- tmpstr[newsize - 1] = 0;
+ tmpstr[newsize - 1] = '\0';
tmp->data = tmpstr;
add_to_cutbuffer(tmp);
dump_buffer(cutbuffer);
junk = NULL;
junk = make_new_node(current);
junk->data = charalloc(1);
- junk->data[0] = 0;
+ junk->data[0] = '\0';
add_to_cutbuffer(junk);
dump_buffer(cutbuffer);
'gettext' and/or 'gettextdomain'. What can I do about it?</font></h2>
<blockquote><font color="#330000">Try doing a <b>./configure --with-included-gettext</b>
-and see if that solves your problem. You make need to do a <b>make
+and see if that solves your problem. You may need to do a <b>make
clean ; make</b> to get it to work fully.</font></blockquote>
<h2>
<a NAME="8"></a><font color="#330000">8. ChangeLog</font>
</h2>
+<blockquote>2002/05/15 - Typo fix (DLR).</blockquote>
<blockquote>2001/12/26 - Misc. fixes (Aaron S. Hawley, DLR).</blockquote>
<blockquote>2001/10/02 - Update for Free Translation Project.</blockquote>
<blockquote>2001/10/02 - Assorted fixes, Debian additions.</blockquote>
#include <ctype.h>
#include <dirent.h>
#include <pwd.h>
-
#include "proto.h"
#include "nano.h"
}
-filestruct *read_line(char *buf, filestruct *prev, int *line1ins)
+filestruct *read_line(char *buf, filestruct *prev, int *line1ins, int len)
{
filestruct *fileptr;
fileptr = nmalloc(sizeof(filestruct));
+
+ /* nulls to newlines; len is the string's real length here */
+ unsunder(buf, len);
+
fileptr->data = charalloc(strlen(buf) + 2);
strcpy(fileptr->data, buf);
/* If it's a DOS file (CRLF), and file conversion isn't disabled,
strip out the CR part */
if (!ISSET(NO_CONVERT) && buf[strlen(buf) - 1] == '\r') {
- fileptr->data[strlen(buf) - 1] = 0;
+ fileptr->data[strlen(buf) - 1] = '\0';
totsize--;
if (!fileformat)
int read_file(FILE *f, const char *filename, int quiet)
{
- int num_lines = 0;
- signed char input; /* current input character */
+ int num_lines = 0, len = 0;
+ char input; /* current input character */
char *buf;
long i = 0, bufx = 128;
filestruct *fileptr = current, *tmp = NULL;
while ((input_int = getc(f)) != EOF) {
input = (char) input_int;
#ifndef NANO_SMALL
- if (!ISSET(NO_CONVERT) && input >= 0 && input <= 31
- && input != 127 && input != '\t' && input != '\r'
- && input != '\n')
- /* If the file has binary chars in it, don't stupidly
- assume it's a DOS or Mac formatted file! */
- SET(NO_CONVERT);
+ if (!ISSET(NO_CONVERT) && iscntrl((int) input) && input != '\t'
+ && input != '\r' && input != '\n') {
+ /* If the file has binary chars in it, don't stupidly
+ assume it's a DOS or Mac formatted file! */
+ SET(NO_CONVERT);
+ }
#endif
+ /* calculate the total length of the line; it might have nulls in
+ it, so we can't just use strlen() */
+ len++;
+
if (input == '\n') {
- fileptr = read_line(buf, fileptr, &line1ins);
+
+ /* don't count the newline in the line length */
+ len--;
+
+ /* read in the line properly */
+ fileptr = read_line(buf, fileptr, &line1ins, len);
+
+ /* reset the line length, in preparation for the next line */
+ len = 0;
+
num_lines++;
- buf[0] = 0;
+ buf[0] = '\0';
i = 0;
#ifndef NANO_SMALL
/* If it's a Mac file (no LF just a CR), and file conversion
isn't disabled, handle it! */
- } else if (!ISSET(NO_CONVERT) && i > 0 && buf[i-1] == '\r') {
+ } else if (!ISSET(NO_CONVERT) && i > 0 && buf[i - 1] == '\r') {
fileformat = 2;
- fileptr = read_line(buf, fileptr, &line1ins);
+
+ /* don't count the newline in the line length */
+ len--;
+
+ /* read in the line properly */
+ fileptr = read_line(buf, fileptr, &line1ins, len);
+
+ /* reset the line length, in preparation for the next line */
+ len = 0;
+
num_lines++;
+ totsize++;
buf[0] = input;
- buf[1] = 0;
+ buf[1] = '\0';
i = 1;
#endif
} else {
bufx += 128;
}
buf[i] = input;
- buf[i + 1] = 0;
+ buf[i + 1] = '\0';
i++;
}
totsize++;
}
/* Did we not get a newline but still have stuff to do? */
- if (buf[0]) {
- fileptr = read_line(buf, fileptr, &line1ins);
+ if (len > 0) {
+
+ /* read in the LAST line properly */
+ fileptr = read_line(buf, fileptr, &line1ins, len);
+
num_lines++;
- buf[0] = 0;
+ totsize++;
+ buf[0] = '\0';
}
/* Did we even GET a file if we don't already have one? */
}
#endif
- /* Here is a kludge. If the current file is blank (including
- * after new_file()), then totlines==1 and totsize==0. Thus
- * after open_pipe() or open_file() below, the totsize is short
- * by one. */
- if (totlines==1 && totsize==0)
- totsize++;
-
#ifndef NANO_SMALL
if (i == NANO_EXTCMD_KEY) {
i = open_pipe(answer);
* append == 2 means we are prepending instead of overwriting.
*
* nonamechange means don't change the current filename, it is ignored
- * if tmp == 1.
+ * if tmp == 1 or if we're appending/prepending.
*/
int write_file(char *name, int tmp, int append, int nonamechange)
{
dump_buffer(fileage);
- f = fdopen(fd, append==1 ? "ab" : "wb");
+ f = fdopen(fd, append == 1 ? "ab" : "wb");
if (!f) {
statusbar(_("Could not open file for writing: %s"),
strerror(errno));
break;
data_len = strlen(fileptr->data);
+
+ /* newlines to nulls, just before we write to disk */
+ sunder(fileptr->data);
+
size = fwrite(fileptr->data, 1, data_len, f);
+
+ /* nulls to newlines; data_len is the string's real length here */
+ unsunder(fileptr->data, data_len);
+
if (size < data_len) {
statusbar(_("Could not open file for writing: %s"),
strerror(errno));
int data_len;
data_len = strlen(fileptr->data);
+
+ /* newlines to nulls, just before we write to disk */
+ sunder(fileptr->data);
+
size = fwrite(fileptr->data, 1, data_len, f);
+
+ /* nulls to newlines; data_len is the string's real length here */
+ unsunder(fileptr->data, data_len);
+
if (size < data_len) {
statusbar(_("Could not open file for writing: %s"),
strerror(errno));
statusbar(_("Could not set permissions %o on %s: %s"),
mask, realname, strerror(errno));
- if (!tmp) {
+ if (!tmp && !append) {
if (!nonamechange)
filename = mallocstrcpy(filename, realname);
TOGGLE(MAC_FILE);
return(do_writeout(answer, exiting, append));
} else if (i == NANO_PREPEND_KEY)
- return(do_writeout(answer, exiting, append==2 ? 0 : 2));
+ return(do_writeout(answer, exiting, append == 2 ? 0 : 2));
else if (i == NANO_APPEND_KEY)
- return(do_writeout(answer, exiting, append==1 ? 0 : 1));
+ return(do_writeout(answer, exiting, append == 1 ? 0 : 1));
#ifdef DEBUG
fprintf(stderr, _("filename is %s"), answer);
filestruct *fileagebak = fileage;
filestruct *filebotbak = filebot;
filestruct *cutback = cutbuffer;
+ long totsizebak = totsize;
int oldmod = 0;
cutbuffer = NULL;
fileage = fileagebak;
filebot = filebotbak;
cutbuffer = cutback;
+ totsize = totsizebak;
if (oldmod)
set_modified();
} else
;
find_user = mallocstrcpy(find_user, &buf[1]);
- find_user[i - 1] = 0;
+ find_user[i - 1] = '\0';
for (userdata = getpwent(); userdata != NULL &&
strcmp(userdata->pw_name, find_user);
}
/* Tack a slash onto the string we're completing if it's a directory */
-int append_slash_if_dir(char *buf, int *lastWasTab, int *place)
+int append_slash_if_dir(char *buf, int *lastwastab, int *place)
{
char *dirptr;
struct stat fileinfo;
strncat(buf, "/", 1);
*place += 1;
/* now we start over again with # of tabs so far */
- *lastWasTab = 0;
+ *lastwastab = 0;
ret = 1;
}
tmp++;
strncpy(dirName, buf, tmp - buf + 1);
- dirName[tmp - buf] = 0;
+ dirName[tmp - buf] = '\0';
} else {
/* This function now has an arg which refers to how much the
* statusbar (place) should be advanced, i.e. the new cursor pos.
*/
-char *input_tab(char *buf, int place, int *lastWasTab, int *newplace, int *list)
+char *input_tab(char *buf, int place, int *lastwastab, int *newplace, int *list)
{
/* Do TAB completion */
static int num_matches = 0, match_matches = 0;
*list = 0;
- if (*lastWasTab == FALSE) {
+ if (*lastwastab == FALSE) {
char *tmp, *copyto, *matchBuf;
- *lastWasTab = 1;
+ *lastwastab = 1;
/* Make a local copy of the string -- up to the position of the
cursor */
tmp = buf;
if (!strcmp(tmp, matches[0]))
- is_dir = append_slash_if_dir(buf, lastWasTab, newplace);
+ is_dir = append_slash_if_dir(buf, lastwastab, newplace);
if (is_dir)
break;
*newplace = 0;
/* Is it a directory? */
- append_slash_if_dir(buf, lastWasTab, newplace);
+ append_slash_if_dir(buf, lastwastab, newplace);
break;
default:
#include <assert.h>
#include <sys/stat.h>
-#include "nano.h"
#include "proto.h"
+#include "nano.h"
#ifdef ENABLE_NLS
#include <libintl.h>
*/
int flags = 0; /* Our new flag containing many options */
-WINDOW *edit; /* The file portion of the editor */
+WINDOW *edit; /* The file portion of the editor */
WINDOW *topwin; /* Top line of screen */
WINDOW *bottomwin; /* Bottom buffer */
char *filename = NULL; /* Name of the file */
{
wrap_reset();
if (current->next != NULL) {
- update_line(current->prev, 0);
if (placewewant > 0)
current_x = actual_x(current->next, placewewant);
+ else if (current_x > strlen(current->next->data))
+ current_x = strlen(current->next->data);
} else {
UNSET(KEEP_CUTBUFFER);
check_statblank();
current_y = 0;
update_cursor();
-
}
int do_page_up(void)
{
- int i;
+ int i;
wrap_reset();
current_x = 0;
return 1;
}
-
int do_up(void)
{
wrap_reset();
if (current->prev != NULL) {
if (placewewant > 0)
current_x = actual_x(current->prev, placewewant);
+ else if (current_x > strlen(current->prev->data))
+ current_x = strlen(current->prev->data);
}
if (current_y > 0)
current_y--;
Show the current version number and author.
.TP
.B \-Y (\-\-syntax=[str])
-Specify a specific syntax hilighting from the .nanorc to use (if available).
+Specify a specific syntax highlighting from the .nanorc to use (if available).
.TP
.B \-c (\-\-const)
Constantly show the cursor position.
<DT><B>-Y (--syntax=[str])</B>
<DD>
-Specify a specific syntax hilighting from the .nanorc to use (if available).
+Specify a specific syntax highlighting from the .nanorc to use (if available).
<DT><B>-c (--const)</B>
<DD>
#include <locale.h>
#include <limits.h>
#include <assert.h>
-
#include "proto.h"
#include "nano.h"
statusbar(_("Key illegal in VIEW mode"));
}
-void clear_filename(void)
-{
- if (filename != NULL)
- free(filename);
- filename = charalloc(1);
- filename[0] = 0;
-}
-
/* Initialize global variables - no better way for now. If
save_cutbuffer is nonzero, don't set cutbuffer to NULL. */
void global_init(int save_cutbuffer)
hblank = charalloc(COLS + 1);
memset(hblank, ' ', COLS);
- hblank[COLS] = 0;
+ hblank[COLS] = '\0';
}
{
/* Ahh! Damn dereferencing */
- (*data)[index] = 0;
+ (*data)[index] = '\0';
align(data);
}
char *prevanswer = NULL, *save_search = NULL, *save_replace = NULL;
filestruct *begin;
int i = 0, j = 0, beginx, beginx_top, reverse_search_set;
+#ifndef NANO_SMALL
+ int mark_set;
+#endif
/* save where we are */
begin = current;
reverse_search_set = ISSET(REVERSE_SEARCH);
UNSET(REVERSE_SEARCH);
+#ifndef NANO_SMALL
+ /* Make sure the marking highlight is off during Spell Check */
+ mark_set = ISSET(MARK_ISSET);
+ UNSET(MARK_ISSET);
+#endif
+
/* save the current search/replace strings */
search_init_globals();
save_search = mallocstrcpy(save_search, last_search);
if (reverse_search_set)
SET(REVERSE_SEARCH);
+#ifndef NANO_SMALL
+ /* restore marking highlight */
+ if (mark_set)
+ SET(MARK_ISSET);
+#endif
+
edit_update(current, CENTER);
if (i == -1)
{
char *read_buff, *read_buff_ptr, *read_buff_word;
size_t pipe_buff_size, read_buff_size, read_buff_read, bytesread;
- int in_fd[2], tempfile_fd;
- int spell_status;
+ int in_fd[2], tempfile_fd, spell_status;
pid_t pid_spell;
/* Create a pipe to spell program */
{
int alt_spell_status, lineno_cur = current->lineno;
int x_cur = current_x, y_cur = current_y, pww_cur = placewewant;
+#ifndef NANO_SMALL
+ int mark_set = 0, mbb_lineno_cur, mbx_cur;
+#endif
pid_t pid_spell;
char *ptr;
static int arglen = 3;
static char **spellargs = (char **) NULL;
+#ifndef NANO_SMALL
+ mark_set = ISSET(MARK_ISSET);
+ if (mark_set) {
+ /* Save the marking position */
+ mbb_lineno_cur = mark_beginbuf->lineno;
+ mbx_cur = mark_beginx;
+ UNSET(MARK_ISSET);
+ }
+#endif
+
endwin();
/* Set up an argument list to pass the execvp function */
global_init(1);
open_file(file_name, 0, 1);
+#ifndef NANO_SMALL
+ if (mark_set) {
+ /* Restore the marking position */
+ do_gotopos(mbb_lineno_cur, mbx_cur, y_cur, 0);
+ mark_beginbuf = current;
+ SET(MARK_ISSET);
+ }
+#endif
+
/* go back to the old position, mark the file as modified, and make
sure that the titlebar is refreshed */
do_gotopos(lineno_cur, x_cur, y_cur, pww_cur);
hblank = nrealloc(hblank, COLS + 1);
memset(hblank, ' ', COLS);
- hblank[COLS] = 0;
+ hblank[COLS] = '\0';
#ifdef HAVE_RESIZETERM
resizeterm(LINES, COLS);
{
int optchr;
int kbinput; /* Input from keyboard */
- long startline = 0; /* Line to try and start at */
+ int startline = 0; /* Line to try and start at */
int keyhandled; /* Have we handled the keystroke yet? */
int modify_control_seq;
char *argv0;
}
+ /* Clear the filename we'll be using */
+ filename = charalloc(1);
+ filename[0] = '\0';
+
+ /* See if we were invoked with the name "pico" */
argv0 = strrchr(argv[0], '/');
if ((argv0 && strstr(argv0, "pico"))
|| (!argv0 && strstr(argv[0], "pico")))
/* See if there's a non-option in argv (first non-option is the
filename, if +LINE is not given) */
- if (argc == 1 || argc <= optind)
- clear_filename();
- else {
+ if (argc > 1 && argc > optind) {
/* Look for the +line flag... */
if (argv[optind][0] == '+') {
startline = atoi(&argv[optind][1]);
optind++;
- if (argc == 1 || argc <= optind)
- clear_filename();
- else
+ if (argc > 1 && argc > optind)
filename = mallocstrcpy(filename, argv[optind]);
-
} else
filename = mallocstrcpy(filename, argv[optind]);
}
-
/* First back up the old settings so they can be restored, duh */
tcgetattr(0, &oldterm);
kbinput = wgetch(edit);
#ifdef DEBUG
- fprintf(stderr, "AHA! %c (%d)\n", kbinput, kbinput);
+ fprintf(stderr, _("AHA! %c (%d)\n"), kbinput, kbinput);
#endif
if (kbinput == 27) { /* Grab Alt-key stuff first */
break;
default:
#ifdef DEBUG
- fprintf(stderr, "I got %c (%d)!\n", kbinput, kbinput);
+ fprintf(stderr, _("I got %c (%d)!\n"), kbinput, kbinput);
#endif
/* We no longer stop unhandled sequences so that people with
odd character sets can type... */
#
# syntax "mutt"
# color green "^>.*"
-
int do_right(void);
int check_wildcard_match(const char *text, const char *pattern);
-char *input_tab(char *buf, int place, int *lastWasTab, int *newplace, int *list);
+char *input_tab(char *buf, int place, int *lastwastab, int *newplace, int *list);
char *real_dir_from_tilde(char *buf);
void signal_init(void);
+void unsunder(char *str, int true_len);
+void sunder(char *str);
void lowercase(char *src);
void blank_bottombars(void);
void check_wrap(filestruct * inptr);
tmpsyntax = syntaxes;
#ifdef DEBUG
fprintf(stderr,
- "Starting a new syntax type\n");
+ _("Starting a new syntax type\n"));
fprintf(stderr, "string val=%s\n", nameptr);
#endif
for (tmpsyntax = syntaxes;
tmpsyntax->next != NULL; tmpsyntax = tmpsyntax->next);
#ifdef DEBUG
- fprintf(stderr, "Adding new syntax after 1st\n");
+ fprintf(stderr, _("Adding new syntax after 1st\n"));
#endif
tmpsyntax->next = nmalloc(sizeof(syntaxtype));
tmpcolor = tmpsyntax->color;
#ifdef DEBUG
fprintf(stderr,
- "Starting a new colorstring for fg %d bg %d\n",
+ _("Starting a new colorstring for fg %d bg %d\n"),
fg, bg);
- fprintf(stderr, "string val=%s\n", tmp);
+ fprintf(stderr, _("string val=%s\n"), tmp);
#endif
} else {
for (tmpcolor = tmpsyntax->color;
tmpcolor->next != NULL; tmpcolor = tmpcolor->next);
#ifdef DEBUG
- fprintf(stderr, "Adding new entry for fg %d bg %d\n", fg, bg);
- fprintf(stderr, "string val=%s\n", tmp);
+ fprintf(stderr, _("Adding new entry for fg %d bg %d\n"), fg, bg);
+ fprintf(stderr, _("string val=%s\n"), tmp);
#endif
tmpcolor->next = nmalloc(sizeof(colortype));
beginning = ptr;
ptr = parse_next_regex(ptr);
#ifdef DEBUG
- fprintf(stderr, "For end part, beginning = \"%s\"\n",
+ fprintf(stderr, _("For end part, beginning = \"%s\"\n"),
beginning);
#endif
tmp = NULL;
char *foo = NULL;
foo = mallocstrcpy(foo, str);
- foo[COLS / 2] = 0;
+ foo[COLS / 2] = '\0';
statusbar(_("\"%s...\" not found"), foo);
free(foo);
if (search_last_line) {
if (!quiet)
not_found_msg(needle);
+ update_line(fileptr, current_x);
return NULL;
}
/* Head of Original Line */
strncpy(copy, current->data, current_x);
- copy[current_x] = 0;
+ copy[current_x] = '\0';
/* Replacement Text */
if (!ISSET(USE_REGEXP))
current_y = pos_y;
do_gotoline(line, 1);
- /* recalculate the x-coordinate and place we want, just in case their
- values are insane; if they aren't, they won't be changed by this */
- current_x = pos_x;
- pos_placewewant = xplustabs();
- pos_x = actual_x(current, pos_placewewant);
+ /* make sure that the x-coordinate is sane here */
+ if (pos_x > strlen(current->data))
+ pos_x = strlen(current->data);
/* set the rest of the coordinates up */
current_x = pos_x;
* *
**************************************************************************/
-#include "config.h"
-
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
-
-#include "nano.h"
+#include "config.h"
#include "proto.h"
+#include "nano.h"
#ifdef ENABLE_NLS
#include <libintl.h>
return i;
}
+/* For non-null-terminated lines. A line, by definition, shouldn't
+ normally have newlines in it, so encode its nulls as newlines. */
+void unsunder(char *str, int true_len)
+{
+ int i;
+ if (strlen(str) < true_len) {
+ for (i = 0; i < true_len; i++) {
+ if (str[i] == '\0')
+ str[i] = '\n';
+ }
+ }
+}
+
+/* For non-null-terminated lines. A line, by definition, shouldn't
+ normally have newlines in it, so decode its newlines into nulls. */
+void sunder(char *str)
+{
+ int i, true_len = strlen(str);
+ if (strchr(str, '\n')) {
+ for (i = 0; i < true_len; i++) {
+ if (str[i] == '\n')
+ str[i] = '\0';
+ }
+ }
+}
+
/* Lower case a string - must be null terminated */
void lowercase(char *src)
{
* *
**************************************************************************/
-#include "config.h"
-
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
+#include <ctype.h>
#include <assert.h>
+#include "config.h"
#include "proto.h"
#include "nano.h"
} else if (fileptr->data[i] & 0x80)
/* Make 8 bit chars only 1 column! */
;
- else if (fileptr->data[i] < 32 || fileptr->data[i] == 127)
+ else if (iscntrl((int) fileptr->data[i]))
tabs++;
}
tot += tabsize - (tot % tabsize);
} else if (fileptr->data[i] & 0x80)
tot++; /* Make 8 bit chars only 1 column (again) */
- else if (fileptr->data[i] < 32 || fileptr->data[i] == 127) {
+ else if (iscntrl((int) fileptr->data[i])) {
i++;
tot += 2;
}
+ if (i > strlen(fileptr->data))
+ i = strlen(fileptr->data);
+
+ /* see if we're in the x-plus-tabs column of xplus; if not, look
+ for the closest column to it */
+ if (xpt(fileptr, i) < xplus) {
+ while (xpt(fileptr, i) < xplus && i < strlen(fileptr->data))
+ i++;
+ }
+ else if (xpt(fileptr, i) > xplus) {
+ while (xpt(fileptr, i) > xplus && i > start)
+ i--;
+ }
+
#ifdef DEBUG
fprintf(stderr, _("actual_x_from_start for xplus=%d returned %d\n"),
xplus, i);
} else if (buf[i] & 0x80)
/* Make 8 bit chars only 1 column! */
;
- else if (buf[i] < 32 || buf[i] == 127)
+ else if (iscntrl((int) buf[i]))
tabs++;
}
for (; i <= 2; i++)
mvwaddstr(bottomwin, i, 0, hblank);
-
}
void blank_edit(void)
slen = length_of_list(s);
inputbuf = charalloc(strlen(def) + 1);
- inputbuf[0] = 0;
+ inputbuf[0] = '\0';
x_left = strlen(buf);
x = strlen(def) + x_left;
memmove(inputbuf + (x - x_left),
inputbuf + (x - x_left) + 1,
strlen(inputbuf) - (x - x_left) - 1);
- inputbuf[strlen(inputbuf) - 1] = 0;
+ inputbuf[strlen(inputbuf) - 1] = '\0';
}
break;
case NANO_CONTROL_K:
case NANO_CONTROL_H:
if (strlen(inputbuf) > 0) {
if (x == (x_left + strlen(inputbuf)))
- inputbuf[strlen(inputbuf) - 1] = 0;
+ inputbuf[strlen(inputbuf) - 1] = '\0';
else if (x - x_left) {
memmove(inputbuf + (x - x_left) - 1,
inputbuf + (x - x_left),
strlen(inputbuf) - (x - x_left));
- inputbuf[strlen(inputbuf) - 1] = 0;
+ inputbuf[strlen(inputbuf) - 1] = '\0';
}
}
if (x > strlen(buf))
memmove(inputbuf + (x - x_left),
inputbuf + (x - x_left) + 1,
strlen(inputbuf) - (x - x_left) - 1);
- inputbuf[strlen(inputbuf) - 1] = 0;
+ inputbuf[strlen(inputbuf) - 1] = '\0';
}
goto skip_tilde;
case '4':
nanoget_repaint(buf, inputbuf, x);
wrefresh(bottomwin);
}
+#ifndef DISABLE_TABCOMP
+ /* if we've done tab completion, there might be a list of filename
+ matches on the edit window at this point; make sure they're
+ cleared off */
+ if (list)
+ edit_refresh();
+#endif
answer = mallocstrcpy(answer, inputbuf);
free(inputbuf);
break;
}
#ifdef DEBUG
- fprintf(stderr, "Match! (%d chars) \"%s\"\n",
+ fprintf(stderr, _("Match! (%d chars) \"%s\"\n"),
colormatches[0].rm_eo - colormatches[0].rm_so,
&fileptr->data[k + colormatches[0].rm_so]);
#endif
paintlen =
colormatches[0].rm_eo - colormatches[0].rm_so;
#ifdef DEBUG
- fprintf(stderr, "paintlen (%d) = eo (%d) - so (%d)\n",
+ fprintf(stderr, _("paintlen (%d) = eo (%d) - so (%d)\n"),
paintlen, colormatches[0].rm_eo, colormatches[0].rm_so);
#endif
else {
paintlen = COLS - k - colormatches[0].rm_so - 1;
#ifdef DEBUG
- fprintf(stderr, "paintlen (%d) = COLS (%d) - k (%d), - rm.so (%d) - 1\n",
+ fprintf(stderr, _("paintlen (%d) = COLS (%d) - k (%d), - rm.so (%d) - 1\n"),
paintlen, COLS, k, colormatches[0].rm_so);
#endif
}
&fileptr->data[start + smatch],
ematch - smatch);
#ifdef DEBUG
- fprintf(stderr, "start = %d, smatch = %d, ematch = %d\n", start,
+ fprintf(stderr, _("start = %d, smatch = %d, ematch = %d\n"), start,
smatch, ematch);
#endif
if (i < mark_beginx)
virt_mark_beginx--;
} else if (realdata[i] == 127) {
- /* Treat control characters as ^symbol (ASCII 1 - 31, 127) */
+ /* Treat control characters as ^symbol (ASCII 1 - 31 omitting
+ 10, 127) */
fileptr->data[pos++] = '^';
fileptr->data[pos++] = '?';
- } else if (realdata[i] >= 1 && realdata[i] <= 31) {
+ if (i < current_x)
+ virt_cur_x++;
+ if (i < mark_beginx)
+ virt_mark_beginx++;
+ } else if (realdata[i] >= 1 && realdata[i] <= 31 && realdata[i] != 10) {
fileptr->data[pos++] = '^';
fileptr->data[pos++] = realdata[i] + 64;
+ if (i < current_x)
+ virt_cur_x++;
+ if (i < mark_beginx)
+ virt_mark_beginx++;
+ } else if (realdata[i] == 10) {
+ /* Treat newlines (ASCII 10's) embedded in a line as encoded
+ nulls (ASCII 0's); the line in question should be run
+ through unsunder() before reaching here */
+ fileptr->data[pos++] = '^';
+ fileptr->data[pos++] = '@';
+ if (i < current_x)
+ virt_cur_x++;
+ if (i < mark_beginx)
+ virt_mark_beginx++;
} else {
fileptr->data[pos++] = realdata[i];
}
break;
#endif
#endif
+ case 27:
+ kbinput = wgetch(edit);
+ switch(kbinput) {
+ case '[':
+ kbinput = wgetch(edit);
+ switch(kbinput) {
+ case '5': /* Alt-[-5 = Page Up */
+ wgetch(edit);
+ goto do_pageupkey;
+ break;
+ case 'V': /* Alt-[-V = Page Up in Hurd Console */
+ case 'I': /* Alt-[-I = Page Up - FreeBSD Console */
+ goto do_pageupkey;
+ break;
+ case '6': /* Alt-[-6 = Page Down */
+ wgetch(edit);
+ goto do_pagedownkey;
+ break;
+ case 'U': /* Alt-[-U = Page Down in Hurd Console */
+ case 'G': /* Alt-[-G = Page Down - FreeBSD Console */
+ goto do_pagedownkey;
+ break;
+ }
+ break;
+ }
+ break;
case NANO_NEXTPAGE_KEY:
case NANO_NEXTPAGE_FKEY:
case KEY_NPAGE:
+ do_pagedownkey:
if (!no_more) {
blank_edit();
page++;
case NANO_PREVPAGE_KEY:
case NANO_PREVPAGE_FKEY:
case KEY_PPAGE:
+ do_pageupkey:
if (page > 1) {
no_more = 0;
blank_edit();