Replace with null string option, ran source through indent again

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@243 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Chris Allegretta 2000-10-26 01:44:42 +00:00
parent a0e957bc0d
commit bd9e7c3c36
13 changed files with 594 additions and 574 deletions

2
BUGS
View File

@ -2,6 +2,7 @@
certain col values. (9) [FIXED]
- edit_refresh() and update_line() do not handle selecting text when the
cursor is beyond COLS (10) [FIXED]
- no way to do a replace with the empty string (11). [FIXED, yay!]
- Moving to the end of a line when close to a multiple of COLS and at
least COLS * 2 does not make the screen jump early like it would for
if we were around COLS (bugs in edit_refresh, update_line) (13)
@ -70,7 +71,6 @@
- Marked cutting sometimes leaves a newline in the file unintelligently,
such as when all of a line is selected but the mark doesn't proceed to
the new line. (8) { Is this an issue? compare to pico 3.5 }
- no way to do a replace with the empty string (11).
- Spelling support is not elegant like pico's integration of the 'spell'
program. Nano only uses ispell (for now) (12).
- In replace, there is no way to accept the default replace string. (27)

View File

@ -1,4 +1,7 @@
CVS Code -
- Ran source through indent -kr again. Make everything pretty.
- Added "replace with null" option. ^N in replace. New alias
NANO_NULL_KEY, and code in do_replace to check for it.
- global.c
toggle_init()
- Added #ifdef around toggle_regex_msg to get rid of compiler

23
cut.c
View File

@ -123,7 +123,7 @@ void cut_marked_segment(filestruct * top, int top_x, filestruct * bot,
filebot = top;
}
}
if (top->lineno < edittop->lineno)
if (top->lineno < edittop->lineno)
edit_update(top, CENTER);
}
#endif
@ -152,20 +152,17 @@ int do_cut_text(void)
}
/* Must let cutbuffer get blown away first before we do this... */
if (fileptr == filebot && !ISSET(MARK_ISSET))
if (fileptr == filebot && !ISSET(MARK_ISSET))
return 0;
#ifndef NANO_SMALL
if (ISSET(CUT_TO_END) && !ISSET(MARK_ISSET)) {
if (current_x == strlen(current->data))
{
if (current_x == strlen(current->data)) {
do_delete();
SET(KEEP_CUTBUFFER);
marked_cut = 2;
return 1;
}
else
{
} else {
SET(MARK_ISSET);
SET(KEEP_CUTBUFFER);
@ -227,7 +224,7 @@ int do_cut_text(void)
tmp = fileptr;
fileage = fileptr;
add_to_cutbuffer(fileptr->prev);
totsize--; /* get the newline */
totsize--; /* get the newline */
totlines--;
fileptr->prev = NULL;
current = fileptr;
@ -247,10 +244,10 @@ int do_cut_text(void)
(fileptr->next)->prev = fileptr->prev;
current = fileptr->next;
totlines--;
totsize--; /* get the newline */
} /* No longer an else here, because we never get here anymore...
No need to cut the magic line, as it's empty */
totsize--; /* get the newline */
}
/* No longer an else here, because we never get here anymore...
No need to cut the magic line, as it's empty */
add_to_cutbuffer(fileptr);
}
@ -404,7 +401,7 @@ int do_uncut_text(void)
i = editbot->lineno;
renumber(newbuf);
if (i < newend->lineno)
if (i < newend->lineno)
edit_update(fileptr, CENTER);
dump_buffer_reverse(fileptr);

12
files.c
View File

@ -336,7 +336,7 @@ int write_file(char *name, int tmp)
if (ISSET(TEMP_OPT)) {
UNSET(TEMP_OPT);
return do_writeout(1);
}
}
statusbar(_("Could not open file for writing: %s"),
strerror(errno));
return -1;
@ -346,7 +346,8 @@ int write_file(char *name, int tmp)
dump_buffer(fileage);
while (fileptr != NULL && fileptr->next != NULL) {
/* Next line is so we discount the "magic line" */
if(filebot == fileptr && fileptr->data[0] == '\0') break;
if (filebot == fileptr && fileptr->data[0] == '\0')
break;
size = write(fd, fileptr->data, strlen(fileptr->data));
if (size == -1) {
@ -446,14 +447,11 @@ int do_writeout(int exiting)
strncpy(answer, filename, 132);
if ((exiting) && (ISSET(TEMP_OPT))) {
if (filename[0])
{
if (filename[0]) {
i = write_file(answer, 0);
display_main_list();
return i;
}
else
{
} else {
UNSET(TEMP_OPT);
do_exit();

View File

@ -83,9 +83,9 @@ toggle toggles[TOGGLE_LEN];
/* Regular expressions */
#ifdef HAVE_REGEX_H
regex_t search_regexp; /* Global to store compiled search regexp */
regmatch_t regmatches[10]; /* Match positions for parenthetical
subexpressions, max of 10 */
regex_t search_regexp; /* Global to store compiled search regexp */
regmatch_t regmatches[10]; /* Match positions for parenthetical
subexpressions, max of 10 */
#endif
/* Initialize a struct *without* our lovely braces =( */
@ -117,7 +117,7 @@ void toggle_init(void)
*toggle_nohelp_msg, *toggle_picomode_msg, *toggle_mouse_msg,
*toggle_cuttoend_msg, *toggle_wrap_msg;
#ifdef HAVE_REGEX_H
char *toggle_regexp_msg;
char *toggle_regexp_msg;
#endif
toggle_const_msg = _("Constant cursor position");
@ -128,29 +128,29 @@ void toggle_init(void)
toggle_mouse_msg = _("Mouse support");
toggle_cuttoend_msg = _("Cut to end");
#ifdef HAVE_REGEX_H
toggle_regexp_msg = _("Regular expressions");
toggle_regexp_msg = _("Regular expressions");
#endif
toggle_wrap_msg = _("Auto wrap");
toggle_init_one(&toggles[0], TOGGLE_CONST_KEY, toggle_const_msg,
CONSTUPDATE);
toggle_init_one(&toggles[1], TOGGLE_AUTOINDENT_KEY, toggle_autoindent_msg,
AUTOINDENT);
toggle_init_one(&toggles[2], TOGGLE_SUSPEND_KEY, toggle_suspend_msg,
SUSPEND);
toggle_init_one(&toggles[3], TOGGLE_NOHELP_KEY, toggle_nohelp_msg,
NO_HELP);
toggle_init_one(&toggles[4], TOGGLE_PICOMODE_KEY, toggle_picomode_msg,
PICO_MSGS);
toggle_init_one(&toggles[5], TOGGLE_WRAP_KEY, toggle_wrap_msg,
NO_WRAP);
toggle_init_one(&toggles[6], TOGGLE_MOUSE_KEY, toggle_mouse_msg,
USE_MOUSE);
toggle_init_one(&toggles[7], TOGGLE_CUTTOEND_KEY, toggle_cuttoend_msg,
CUT_TO_END);
toggle_init_one(&toggles[0], TOGGLE_CONST_KEY, toggle_const_msg,
CONSTUPDATE);
toggle_init_one(&toggles[1], TOGGLE_AUTOINDENT_KEY,
toggle_autoindent_msg, AUTOINDENT);
toggle_init_one(&toggles[2], TOGGLE_SUSPEND_KEY, toggle_suspend_msg,
SUSPEND);
toggle_init_one(&toggles[3], TOGGLE_NOHELP_KEY, toggle_nohelp_msg,
NO_HELP);
toggle_init_one(&toggles[4], TOGGLE_PICOMODE_KEY, toggle_picomode_msg,
PICO_MSGS);
toggle_init_one(&toggles[5], TOGGLE_WRAP_KEY, toggle_wrap_msg,
NO_WRAP);
toggle_init_one(&toggles[6], TOGGLE_MOUSE_KEY, toggle_mouse_msg,
USE_MOUSE);
toggle_init_one(&toggles[7], TOGGLE_CUTTOEND_KEY, toggle_cuttoend_msg,
CUT_TO_END);
#ifdef HAVE_REGEX_H
toggle_init_one(&toggles[8], TOGGLE_REGEXP_KEY, toggle_regexp_msg,
USE_REGEXP);
toggle_init_one(&toggles[8], TOGGLE_REGEXP_KEY, toggle_regexp_msg,
USE_REGEXP);
#endif
#endif
}
@ -169,7 +169,7 @@ void shortcut_init(void)
"", *nano_mark_msg = "", *nano_delete_msg =
"", *nano_backspace_msg = "", *nano_tab_msg =
"", *nano_enter_msg = "", *nano_case_msg =
"", *nano_cancel_msg = "";
"", *nano_cancel_msg = "", *nano_null_msg = "";
#ifndef NANO_SMALL
nano_help_msg = _("Invoke the help menu");
@ -204,6 +204,7 @@ void shortcut_init(void)
nano_case_msg =
_("Make the current search or replace case (in)sensitive");
nano_cancel_msg = _("Cancel the current function");
nano_null_msg = _("Use the null string, \"\"");
#endif
if (ISSET(PICO_MSGS))
@ -228,7 +229,7 @@ void shortcut_init(void)
if (ISSET(PICO_MSGS))
sc_init_one(&main_list[3], NANO_JUSTIFY_KEY, _("Justify"),
nano_justify_msg, 0, NANO_JUSTIFY_FKEY, 0,
nano_justify_msg, 0, NANO_JUSTIFY_FKEY, 0,
NOVIEW, do_justify);
else
sc_init_one(&main_list[3], NANO_REPLACE_KEY, _("Replace"),
@ -307,7 +308,7 @@ void shortcut_init(void)
NANO_ALT_R, NANO_REPLACE_FKEY, 0, NOVIEW, do_replace);
else
sc_init_one(&main_list[23], NANO_JUSTIFY_KEY, _("Justify"),
nano_justify_msg, 0, NANO_JUSTIFY_FKEY, 0,
nano_justify_msg, 0, NANO_JUSTIFY_FKEY, 0,
NOVIEW, do_justify);
sc_init_one(&main_list[24], NANO_ENTER_KEY, _("Enter"),
@ -336,8 +337,9 @@ void shortcut_init(void)
sc_init_one(&whereis_list[3], NANO_OTHERSEARCH_KEY, _("Replace"),
nano_replace_msg, 0, 0, 0, VIEW, do_replace);
sc_init_one(&whereis_list[4], NANO_FROMSEARCHTOGOTO_KEY, _("Goto Line"),
nano_goto_msg, 0, 0, 0, VIEW, do_gotoline_void);
sc_init_one(&whereis_list[4], NANO_FROMSEARCHTOGOTO_KEY,
_("Goto Line"), nano_goto_msg, 0, 0, 0, VIEW,
do_gotoline_void);
sc_init_one(&whereis_list[5], NANO_CANCEL_KEY, _("Cancel"),
nano_cancel_msg, 0, 0, 0, VIEW, 0);
@ -355,10 +357,14 @@ void shortcut_init(void)
sc_init_one(&replace_list[3], NANO_OTHERSEARCH_KEY, _("No Replace"),
nano_whereis_msg, 0, 0, 0, VIEW, do_search);
sc_init_one(&replace_list[4], NANO_FROMSEARCHTOGOTO_KEY, _("Goto Line"),
nano_goto_msg, 0, 0, 0, VIEW, do_gotoline_void);
sc_init_one(&replace_list[4], NANO_FROMSEARCHTOGOTO_KEY,
_("Goto Line"), nano_goto_msg, 0, 0, 0, VIEW,
do_gotoline_void);
sc_init_one(&replace_list[5], NANO_CANCEL_KEY, _("Cancel"),
sc_init_one(&replace_list[5], NANO_NULL_KEY, _("Null Str"),
nano_null_msg, 0, 0, 0, VIEW, 0);
sc_init_one(&replace_list[6], NANO_CANCEL_KEY, _("Cancel"),
nano_cancel_msg, 0, 0, 0, VIEW, 0);

2
move.c
View File

@ -57,7 +57,7 @@ int page_down(void)
if (editbot != filebot || edittop == fileage) {
current_y = 0;
current = editbot;
current = editbot;
if (current->prev != NULL)
current = current->prev;

207
nano.c
View File

@ -95,12 +95,12 @@ void die(char *msg, ...)
/* if we can't save we have REAL bad problems,
* but we might as well TRY. */
if(filename[0] == '\0') {
if (filename[0] == '\0') {
write_file("nano.save", 0);
} else {
char buf[BUFSIZ];
strncpy(buf,filename,BUFSIZ);
strncat(buf,".save",BUFSIZ - strlen(buf));
strncpy(buf, filename, BUFSIZ);
strncat(buf, ".save", BUFSIZ - strlen(buf));
write_file(buf, 0);
}
/* Restore the old term settings */
@ -321,7 +321,7 @@ void usage(void)
(" -T --tabsize=[num] Set width of a tab to num\n"));
#ifdef HAVE_REGEX_H
printf(_
(" -R --regexp Use regular expressions for search\n"));
(" -R --regexp Use regular expressions for search\n"));
#endif
printf
(_
@ -399,7 +399,8 @@ void version(void)
{
printf(_(" nano version %s by Chris Allegretta (compiled %s, %s)\n"),
VERSION, __TIME__, __DATE__);
printf(_(" Email: nano@nano-editor.org Web: http://www.nano-editor.org\n"));
printf(_
(" Email: nano@nano-editor.org Web: http://www.nano-editor.org\n"));
}
filestruct *make_new_node(filestruct * prevnode)
@ -419,7 +420,7 @@ filestruct *make_new_node(filestruct * prevnode)
}
/* Splice a node into an existing filestruct */
void splice_node(filestruct *begin, filestruct *new, filestruct *end)
void splice_node(filestruct * begin, filestruct * new, filestruct * end)
{
new->next = end;
new->prev = begin;
@ -469,7 +470,7 @@ void do_char(char ch)
{
/* magic-line: when a character is inserted on the current magic line,
* it means we need a new one! */
if(filebot == current && current->data[0] == '\0') {
if (filebot == current && current->data[0] == '\0') {
new_magicline();
fix_editbot();
}
@ -540,7 +541,7 @@ int do_enter(filestruct * inptr)
*/
if (current_y == editwinrows - 1) {
edit_update(current, CENTER);
reset_cursor();
reset_cursor();
} else {
current_y++;
edit_refresh();
@ -624,7 +625,7 @@ void do_wrap(filestruct * inptr, char input_char)
current_word_start_t = i_tabs;
while (!isspace((int) inptr->data[i])
&& inptr->data[i]) {
&& inptr->data[i]) {
i++;
i_tabs++;
if (inptr->data[i] < 32)
@ -763,7 +764,8 @@ void do_wrap(filestruct * inptr, char input_char)
right = current_x - current_word_start;
i = current_word_start - 1;
if (isspace((int)input_char) && (current_x == current_word_start)) {
if (isspace((int) input_char)
&& (current_x == current_word_start)) {
current_x = current_word_start;
null_at(inptr->data, current_word_start);
@ -877,7 +879,7 @@ void check_wrap(filestruct * inptr, char ch)
/* Do not wrap if there are no words on or after wrap point. */
int char_found = 0;
while (isspace((int)inptr->data[i]) && inptr->data[i])
while (isspace((int) inptr->data[i]) && inptr->data[i])
i++;
if (!inptr->data[i])
@ -954,9 +956,9 @@ int do_backspace(void)
editbot = current;
/* Recreate the magic line if we're deleting it AND if the
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
appears to do it, in any case */
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
appears to do it, in any case */
if (strcmp(current->data, "")) {
new_magicline();
fix_editbot();
@ -1010,8 +1012,7 @@ int do_delete(void)
/* Please see the comment in do_basckspace if you don't understand
this test */
if (current == filebot && strcmp(current->data, ""))
{
if (current == filebot && strcmp(current->data, "")) {
new_magicline();
fix_editbot();
totsize++;
@ -1185,20 +1186,19 @@ void do_mouse(void)
}
current_x = mevent.x;
placewewant = current_x;
while(foo < current_x) {
if(current->data[foo] == NANO_CONTROL_I) {
while (foo < current_x) {
if (current->data[foo] == NANO_CONTROL_I) {
current_x -= tabsize - (foo % tabsize);
tab_found = 1;
} else if(current->data[foo] & 0x80)
;
else if(current->data[foo] < 32)
} else if (current->data[foo] & 0x80);
else if (current->data[foo] < 32)
current_x--;
foo++;
}
/* This is where tab_found comes in. I can't figure out why,
* but without it any line with a tab will place the cursor
* one character behind. Whatever, this fixes it. */
if(tab_found == 1)
if (tab_found == 1)
current_x++;
if (current_x > strlen(current->data))
@ -1227,7 +1227,7 @@ RETSIGTYPE do_suspend(int signal)
sigaction(SIGTSTP, &act, NULL);
endwin();
fprintf(stderr,"\n\n\n\n\nUse \"fg\" to return to nano\n");
fprintf(stderr, "\n\n\n\n\nUse \"fg\" to return to nano\n");
raise(SIGTSTP);
}
@ -1321,14 +1321,12 @@ void signal_init(void)
if (!ISSET(SUSPEND)) {
sigaction(SIGTSTP, &act, NULL);
}
else
{
} else {
act.sa_handler = do_suspend;
sigaction(SIGTSTP, &act, NULL);
act.sa_handler = do_cont;
sigaction (SIGCONT, &act, NULL);
sigaction(SIGCONT, &act, NULL);
}
@ -1350,8 +1348,7 @@ void window_init(void)
/* And the other windows */
topwin = newwin(2, COLS, 0, 0);
bottomwin = newwin(3 - no_help(), COLS, LINES - 3 + no_help(), 0);\
bottomwin = newwin(3 - no_help(), COLS, LINES - 3 + no_help(), 0);
}
void mouse_init(void)
@ -1365,8 +1362,7 @@ void mouse_init(void)
mousemask(BUTTON1_RELEASED, NULL);
mouseinterval(50);
}
else {
} else {
mousemask(0, NULL);
keypad(edit, FALSE);
keypad(bottomwin, FALSE);
@ -1500,8 +1496,8 @@ int do_justify(void)
slen = strlen(current->data);
totsize += slen;
if((strlenpt(current->data) > (fill))
&& !no_spaces(current->data)) {
if ((strlenpt(current->data) > (fill))
&& !no_spaces(current->data)) {
do {
int i = 0;
int len2 = 0;
@ -1516,11 +1512,12 @@ int do_justify(void)
i = slen;
for (; i > 0; i--) {
if (isspace((int) current->data[i]) &&
((strlenpt(current->data) - strlen(current->data +i)) <=
fill)) break;
((strlenpt(current->data) - strlen(current->data + i))
<= fill))
break;
}
if (!i)
break;
break;
current->data[i] = '\0';
@ -1542,8 +1539,8 @@ int do_justify(void)
current = tmpline;
slen -= i + 1;
current_y++;
} while ((strlenpt(current->data) > (fill))
&& !no_spaces(current->data));
} while ((strlenpt(current->data) > (fill))
&& !no_spaces(current->data));
}
if (current->next)
@ -1610,13 +1607,13 @@ void help_init(void)
if (main_list[i].misc1 > KEY_F0 && main_list[i].misc1 <= KEY_F(64))
sofar += snprintf(&buf[sofar], BUFSIZ - sofar, "(F%d) ",
main_list[i].misc1 - KEY_F0);
main_list[i].misc1 - KEY_F0);
else
sofar += snprintf(&buf[sofar], BUFSIZ - sofar, " ");
if (main_list[i].altval > 0)
sofar += snprintf(&buf[sofar], BUFSIZ - sofar, "(M-%c) ",
main_list[i].altval - 32);
main_list[i].altval - 32);
else
sofar += snprintf(&buf[sofar], BUFSIZ - sofar, " ");
@ -1631,12 +1628,12 @@ void help_init(void)
/* And the toggles... */
for (i = 0; i <= TOGGLE_LEN - 1; i++) {
sofar = snprintf(buf, BUFSIZ,
"M-%c ", toggles[i].val - 32 );
sofar = snprintf(buf, BUFSIZ,
"M-%c ", toggles[i].val - 32);
if (toggles[i].desc != NULL)
snprintf(&buf[sofar], BUFSIZ - sofar, _("%s enable/disable"),
toggles[i].desc);
snprintf(&buf[sofar], BUFSIZ - sofar, _("%s enable/disable"),
toggles[i].desc);
strcat(help_text, buf);
strcat(help_text, "\n");
@ -1677,13 +1674,13 @@ void do_toggle(int which)
if (!ISSET(toggles[which].flag)) {
if (toggles[which].val == TOGGLE_NOHELP_KEY ||
toggles[which].val == TOGGLE_WRAP_KEY)
toggles[which].val == TOGGLE_WRAP_KEY)
statusbar("%s %s", toggles[which].desc, enabled);
else
statusbar("%s %s", toggles[which].desc, disabled);
} else {
if (toggles[which].val == TOGGLE_NOHELP_KEY ||
toggles[which].val == TOGGLE_WRAP_KEY)
toggles[which].val == TOGGLE_WRAP_KEY)
statusbar("%s %s", toggles[which].desc, disabled);
else
statusbar("%s %s", toggles[which].desc, enabled);
@ -1711,7 +1708,7 @@ int main(int argc, char *argv[])
int option_index = 0;
struct option long_options[] = {
#ifdef HAVE_REGEX_H
{"regexp", 0, 0, 'R'},
{"regexp", 0, 0, 'R'},
#endif
{"version", 0, 0, 'V'},
{"const", 0, 0, 'c'},
@ -1925,97 +1922,95 @@ int main(int argc, char *argv[])
kbinput = wgetch(edit);
if (kbinput == 27) { /* Grab Alt-key stuff first */
switch (kbinput = wgetch(edit)) {
/* Alt-O, suddenly very important ;) */
/* Alt-O, suddenly very important ;) */
case 79:
kbinput = wgetch(edit);
if (kbinput <= 'S' && kbinput >= 'P')
kbinput = KEY_F(kbinput - 79);
kbinput = KEY_F(kbinput - 79);
#ifdef DEBUG
else {
fprintf(stderr, _("I got Alt-O-%c! (%d)\n"),
kbinput, kbinput);
break;
fprintf(stderr, _("I got Alt-O-%c! (%d)\n"),
kbinput, kbinput);
break;
}
#endif
break;
case 91:
switch (kbinput = wgetch(edit)) {
case '1': /* Alt-[-1-[0-5,7-9] = F1-F8 in X at least */
case '1': /* Alt-[-1-[0-5,7-9] = F1-F8 in X at least */
kbinput = wgetch(edit);
if (kbinput >= '1' && kbinput <= '5') {
kbinput = KEY_F(kbinput - 48);
wgetch(edit);
}
else if (kbinput >= '7' && kbinput <= '9') {
kbinput = KEY_F(kbinput - 49);
wgetch(edit);
}
else if (kbinput == 126)
kbinput = KEY_HOME;
kbinput = KEY_F(kbinput - 48);
wgetch(edit);
} else if (kbinput >= '7' && kbinput <= '9') {
kbinput = KEY_F(kbinput - 49);
wgetch(edit);
} else if (kbinput == 126)
kbinput = KEY_HOME;
#ifdef DEBUG
else {
fprintf(stderr, _("I got Alt-[-1-%c! (%d)\n"),
kbinput, kbinput);
break;
fprintf(stderr, _("I got Alt-[-1-%c! (%d)\n"),
kbinput, kbinput);
break;
}
#endif
break;
case '2': /* Alt-[-2-[0,1,3,4] = F9-F12 in many terms */
case '2': /* Alt-[-2-[0,1,3,4] = F9-F12 in many terms */
kbinput = wgetch(edit);
switch (kbinput) {
case '0':
kbinput = KEY_F(9);
wgetch(edit);
break;
case '1':
kbinput = KEY_F(10);
wgetch(edit);
break;
case '3':
kbinput = KEY_F(11);
wgetch(edit);
break;
case '4':
kbinput = KEY_F(12);
wgetch(edit);
break;
case 126: /* Hack, make insert key do something
usefile, like insert file */
do_insertfile();
keyhandled = 1;
break;
case '0':
kbinput = KEY_F(9);
wgetch(edit);
break;
case '1':
kbinput = KEY_F(10);
wgetch(edit);
break;
case '3':
kbinput = KEY_F(11);
wgetch(edit);
break;
case '4':
kbinput = KEY_F(12);
wgetch(edit);
break;
case 126: /* Hack, make insert key do something
usefile, like insert file */
do_insertfile();
keyhandled = 1;
break;
#ifdef DEBUG
default:
fprintf(stderr, _("I got Alt-[-2-%c! (%d)\n"),
kbinput, kbinput);
break;
default:
fprintf(stderr, _("I got Alt-[-2-%c! (%d)\n"),
kbinput, kbinput);
break;
#endif
}
break;
case '3': /* Alt-[-3 = Delete? */
case '3': /* Alt-[-3 = Delete? */
kbinput = NANO_DELETE_KEY;
wgetch(edit);
break;
case '4': /* Alt-[-4 = End? */
case '4': /* Alt-[-4 = End? */
kbinput = NANO_END_KEY;
wgetch(edit);
break;
case '5': /* Alt-[-5 = Page Up */
case '5': /* Alt-[-5 = Page Up */
kbinput = KEY_PPAGE;
wgetch(edit);
break;
case '6': /* Alt-[-6 = Page Down */
case '6': /* Alt-[-6 = Page Down */
kbinput = KEY_NPAGE;
wgetch(edit);
break;
case '[': /* Alt-[-[-[A-E], F1-F5 in linux console */
case '[': /* Alt-[-[-[A-E], F1-F5 in linux console */
kbinput = wgetch(edit);
if (kbinput >= 'A' && kbinput <= 'E')
kbinput = KEY_F(kbinput - 64);
if (kbinput >= 'A' && kbinput <= 'E')
kbinput = KEY_F(kbinput - 64);
break;
case 'A':
kbinput = KEY_UP;
@ -2049,17 +2044,17 @@ int main(int argc, char *argv[])
for (i = 0; i <= MAIN_LIST_LEN - 1; i++)
if (kbinput == main_list[i].altval ||
kbinput == main_list[i].altval - 32) {
kbinput = main_list[i].val;
break;
kbinput = main_list[i].val;
break;
}
#ifndef NANO_SMALL
/* And for toggle switches */
for (i = 0; i <= TOGGLE_LEN - 1 && !keyhandled; i++)
if (kbinput == toggles[i].val ||
kbinput == toggles[i].val - 32) {
do_toggle(i);
keyhandled = 1;
break;
do_toggle(i);
keyhandled = 1;
break;
}
#endif
#ifdef DEBUG
@ -2112,11 +2107,11 @@ int main(int argc, char *argv[])
case -1:
case 410: /* Must ignore this, it gets sent when we resize */
#ifdef PDCURSES
case 541: /* ???? */
case 542: /* Control and alt in Windows *shrug* */
case 541: /* ???? */
case 542: /* Control and alt in Windows *shrug* */
case 544:
#endif
break;
default:
#ifdef DEBUG

3
nano.h
View File

@ -225,6 +225,7 @@ know what you're doing */
#define NANO_SUSPEND_KEY NANO_CONTROL_Z
#define NANO_ENTER_KEY NANO_CONTROL_M
#define NANO_FROMSEARCHTOGOTO_KEY NANO_CONTROL_T
#define NANO_NULL_KEY NANO_CONTROL_N
#define TOGGLE_CONST_KEY NANO_ALT_C
#define TOGGLE_AUTOINDENT_KEY NANO_ALT_I
@ -239,7 +240,7 @@ know what you're doing */
#define MAIN_LIST_LEN 26
#define MAIN_VISIBLE 12
#define WHEREIS_LIST_LEN 6
#define REPLACE_LIST_LEN 6
#define REPLACE_LIST_LEN 7
#define GOTO_LIST_LEN 3
#define WRITEFILE_LIST_LEN 1
#define HELP_LIST_LEN 3

View File

@ -67,41 +67,43 @@ const struct _msg_ent _msg_tbl[] = {
{"Insert a carriage return at the cursor position", 58},
{"Make the current search or replace case (in)sensitive", 59},
{"Cancel the current function", 60},
{"Get Help", 61},
{"WriteOut", 62},
{"Exit", 63},
{"Goto Line", 64},
{"Justify", 65},
{"Replace", 66},
{"Read File", 67},
{"Where Is", 68},
{"Prev Page", 69},
{"Next Page", 70},
{"Cut Text", 71},
{"UnCut Txt", 72},
{"Cur Pos", 73},
{"To Spell", 74},
{"Up", 75},
{"Down", 76},
{"Forward", 77},
{"Back", 78},
{"Home", 79},
{"End", 80},
{"Refresh", 81},
{"Mark Text", 82},
{"Delete", 83},
{"Backspace", 84},
{"Tab", 85},
{"Enter", 86},
{"First Line", 87},
{"Last Line", 88},
{"Case Sens", 89},
{"Cancel", 90},
{"No Replace", 91},
{"Use the null string, \"\"", 61},
{"Get Help", 62},
{"WriteOut", 63},
{"Exit", 64},
{"Goto Line", 65},
{"Justify", 66},
{"Replace", 67},
{"Read File", 68},
{"Where Is", 69},
{"Prev Page", 70},
{"Next Page", 71},
{"Cut Text", 72},
{"UnCut Txt", 73},
{"Cur Pos", 74},
{"To Spell", 75},
{"Up", 76},
{"Down", 77},
{"Forward", 78},
{"Back", 79},
{"Home", 80},
{"End", 81},
{"Refresh", 82},
{"Mark Text", 83},
{"Delete", 84},
{"Backspace", 85},
{"Tab", 86},
{"Enter", 87},
{"First Line", 88},
{"Last Line", 89},
{"Case Sens", 90},
{"Cancel", 91},
{"No Replace", 92},
{"Null Str", 93},
{"\
\n\
Buffer written to 'nano.save'\n", 92},
{"Key illegal in VIEW mode", 93},
Buffer written to 'nano.save'\n", 94},
{"Key illegal in VIEW mode", 95},
{"\
nano help text\n\
\n\
@ -119,117 +121,118 @@ Escape-key sequences are notated with the Meta (M) symbol and can be entered \
using either the Esc, Alt or Meta key depending on your keyboard setup. The \
following keystrokes are available in the main editor window. Optional keys \
are shown in parentheses:\n\
\n", 94},
{"free_node(): free'd a node, YAY!\n", 95},
{"free_node(): free'd last node.\n", 96},
\n", 96},
{"free_node(): free'd a node, YAY!\n", 97},
{"free_node(): free'd last node.\n", 98},
{"\
Usage: nano [GNU long option] [option] +LINE <file>\n\
\n", 97},
{"Option\t\tLong option\t\tMeaning\n", 98},
{" -T \t\t--tabsize=[num]\t\tSet width of a tab to num\n", 99},
{" -R\t\t--regexp\t\tUse regular expressions for search\n", 100},
{" -V \t\t--version\t\tPrint version information and exit\n", 101},
{" -c \t\t--const\t\t\tConstantly show cursor position\n", 102},
{" -h \t\t--help\t\t\tShow this message\n", 103},
{" -k \t\t--cut\t\t\tLet ^K cut from cursor to end of line\n", 104},
{" -i \t\t--autoindent\t\tAutomatically indent new lines\n", 105},
{" -l \t\t--nofollow\t\tDon't follow symbolic links, overwrite\n", 106},
{" -m \t\t--mouse\t\t\tEnable mouse\n", 107},
\n", 99},
{"Option\t\tLong option\t\tMeaning\n", 100},
{" -T \t\t--tabsize=[num]\t\tSet width of a tab to num\n", 101},
{" -R\t\t--regexp\t\tUse regular expressions for search\n", 102},
{" -V \t\t--version\t\tPrint version information and exit\n", 103},
{" -c \t\t--const\t\t\tConstantly show cursor position\n", 104},
{" -h \t\t--help\t\t\tShow this message\n", 105},
{" -k \t\t--cut\t\t\tLet ^K cut from cursor to end of line\n", 106},
{" -i \t\t--autoindent\t\tAutomatically indent new lines\n", 107},
{" -l \t\t--nofollow\t\tDon't follow symbolic links, overwrite\n", 108},
{" -m \t\t--mouse\t\t\tEnable mouse\n", 109},
{"\
-r [#cols] \t--fill=[#cols]\t\tSet fill cols to (wrap lines at) #cols\n", 108},
{" -p\t \t--pico\t\t\tMake bottom 2 lines more Pico-like\n", 109},
{" -s [prog] \t--speller=[prog]\tEnable alternate speller\n", 110},
{" -t \t\t--tempfile\t\tAuto save on exit, don't prompt\n", 111},
{" -v \t\t--view\t\t\tView (read only) mode\n", 112},
{" -w \t\t--nowrap\t\tDon't wrap long lines\n", 113},
{" -x \t\t--nohelp\t\tDon't show help window\n", 114},
{" -z \t\t--suspend\t\tEnable suspend\n", 115},
{" +LINE\t\t\t\t\tStart at line number LINE\n", 116},
-r [#cols] \t--fill=[#cols]\t\tSet fill cols to (wrap lines at) #cols\n", 110},
{" -p\t \t--pico\t\t\tMake bottom 2 lines more Pico-like\n", 111},
{" -s [prog] \t--speller=[prog]\tEnable alternate speller\n", 112},
{" -t \t\t--tempfile\t\tAuto save on exit, don't prompt\n", 113},
{" -v \t\t--view\t\t\tView (read only) mode\n", 114},
{" -w \t\t--nowrap\t\tDon't wrap long lines\n", 115},
{" -x \t\t--nohelp\t\tDon't show help window\n", 116},
{" -z \t\t--suspend\t\tEnable suspend\n", 117},
{" +LINE\t\t\t\t\tStart at line number LINE\n", 118},
{"\
Usage: nano [option] +LINE <file>\n\
\n", 117},
{"Option\t\tMeaning\n", 118},
{" -T [num]\tSet width of a tab to num\n", 119},
{" -R\t\tUse regular expressions for search\n", 120},
{" -V \t\tPrint version information and exit\n", 121},
{" -c \t\tConstantly show cursor position\n", 122},
{" -h \t\tShow this message\n", 123},
{" -k \t\tLet ^K cut from cursor to end of line\n", 124},
{" -i \t\tAutomatically indent new lines\n", 125},
{" -l \t\tDon't follow symbolic links, overwrite\n", 126},
{" -m \t\tEnable mouse\n", 127},
{" -r [#cols] \tSet fill cols to (wrap lines at) #cols\n", 128},
{" -s [prog] \tEnable alternate speller\n", 129},
{" -p \t\tMake bottom 2 lines more Pico-like\n", 130},
{" -t \t\tAuto save on exit, don't prompt\n", 131},
{" -v \t\tView (read only) mode\n", 132},
{" -w \t\tDon't wrap long lines\n", 133},
{" -x \t\tDon't show help window\n", 134},
{" -z \t\tEnable suspend\n", 135},
{" +LINE\t\tStart at line number LINE\n", 136},
{" nano version %s by Chris Allegretta (compiled %s, %s)\n", 137},
{" Email: nano@nano-editor.org\tWeb: http://www.nano-editor.org\n", 138},
{"Mark Set", 139},
{"Mark UNset", 140},
{"check_wrap called with inptr->data=\"%s\"\n", 141},
{"current->data now = \"%s\"\n", 142},
{"After, data = \"%s\"\n", 143},
{"Error deleting tempfile, ack!", 144},
{"Could not create a temporary filename: %s", 145},
{"Could not invoke spell program \"%s\"", 146},
{"Could not invoke \"ispell\"", 147},
{"Finished checking spelling", 148},
{"Save modified buffer (ANSWERING \"No\" WILL DESTROY CHANGES) ? ", 149},
{"Cannot resize top win", 150},
{"Cannot move top win", 151},
{"Cannot resize edit win", 152},
{"Cannot move edit win", 153},
{"Cannot resize bottom win", 154},
{"Cannot move bottom win", 155},
{"%s enable/disable", 156},
{"enabled", 157},
{"disabled", 158},
{"Main: set up windows\n", 159},
{"Main: bottom win\n", 160},
{"Main: open file\n", 161},
{"I got Alt-O-%c! (%d)\n", 162},
{"I got Alt-[-1-%c! (%d)\n", 163},
{"I got Alt-[-2-%c! (%d)\n", 164},
{"I got Alt-[-%c! (%d)\n", 165},
{"I got Alt-%c! (%d)\n", 166},
{"Case Sensitive Regexp Search%s%s", 167},
{"Regexp Search%s%s", 168},
{"Case Sensitive Search%s%s", 169},
{"Search%s%s", 170},
{" (to replace)", 171},
{"Search Cancelled", 172},
{"Search Wrapped", 173},
{"Replaced %d occurences", 174},
{"Replaced 1 occurence", 175},
{"Replace Cancelled", 176},
{"Replace with [%s]", 177},
{"Replace with", 178},
{"Replace this instance?", 179},
{"Enter line number", 180},
{"Aborted", 181},
{"Come on, be reasonable", 182},
{"Only %d lines available, skipping to last line", 183},
{"actual_x_from_start for xplus=%d returned %d\n", 184},
{"input '%c' (%d)\n", 185},
{"New Buffer", 186},
{" File: ...", 187},
{"Modified", 188},
{"Moved to (%d, %d) in edit buffer\n", 189},
{"current->data = \"%s\"\n", 190},
{"I got \"%s\"\n", 191},
{"Yes", 192},
{"All", 193},
{"No", 194},
{"do_cursorpos: linepct = %f, bytepct = %f\n", 195},
{"line %d of %d (%.0f%%), character %d of %d (%.0f%%)", 196},
{"Dumping file buffer to stderr...\n", 197},
{"Dumping cutbuffer to stderr...\n", 198},
{"Dumping a buffer to stderr...\n", 199},
\n", 119},
{"Option\t\tMeaning\n", 120},
{" -T [num]\tSet width of a tab to num\n", 121},
{" -R\t\tUse regular expressions for search\n", 122},
{" -V \t\tPrint version information and exit\n", 123},
{" -c \t\tConstantly show cursor position\n", 124},
{" -h \t\tShow this message\n", 125},
{" -k \t\tLet ^K cut from cursor to end of line\n", 126},
{" -i \t\tAutomatically indent new lines\n", 127},
{" -l \t\tDon't follow symbolic links, overwrite\n", 128},
{" -m \t\tEnable mouse\n", 129},
{" -r [#cols] \tSet fill cols to (wrap lines at) #cols\n", 130},
{" -s [prog] \tEnable alternate speller\n", 131},
{" -p \t\tMake bottom 2 lines more Pico-like\n", 132},
{" -t \t\tAuto save on exit, don't prompt\n", 133},
{" -v \t\tView (read only) mode\n", 134},
{" -w \t\tDon't wrap long lines\n", 135},
{" -x \t\tDon't show help window\n", 136},
{" -z \t\tEnable suspend\n", 137},
{" +LINE\t\tStart at line number LINE\n", 138},
{" nano version %s by Chris Allegretta (compiled %s, %s)\n", 139},
{" Email: nano@nano-editor.org\tWeb: http://www.nano-editor.org\n", 140},
{"Mark Set", 141},
{"Mark UNset", 142},
{"check_wrap called with inptr->data=\"%s\"\n", 143},
{"current->data now = \"%s\"\n", 144},
{"After, data = \"%s\"\n", 145},
{"Error deleting tempfile, ack!", 146},
{"Could not create a temporary filename: %s", 147},
{"Could not invoke spell program \"%s\"", 148},
{"Could not invoke \"ispell\"", 149},
{"Finished checking spelling", 150},
{"Save modified buffer (ANSWERING \"No\" WILL DESTROY CHANGES) ? ", 151},
{"Cannot resize top win", 152},
{"Cannot move top win", 153},
{"Cannot resize edit win", 154},
{"Cannot move edit win", 155},
{"Cannot resize bottom win", 156},
{"Cannot move bottom win", 157},
{"%s enable/disable", 158},
{"enabled", 159},
{"disabled", 160},
{"Main: set up windows\n", 161},
{"Main: bottom win\n", 162},
{"Main: open file\n", 163},
{"I got Alt-O-%c! (%d)\n", 164},
{"I got Alt-[-1-%c! (%d)\n", 165},
{"I got Alt-[-2-%c! (%d)\n", 166},
{"I got Alt-[-%c! (%d)\n", 167},
{"I got Alt-%c! (%d)\n", 168},
{"Case Sensitive Regexp Search%s%s", 169},
{"Regexp Search%s%s", 170},
{"Case Sensitive Search%s%s", 171},
{"Search%s%s", 172},
{" (to replace)", 173},
{"Search Cancelled", 174},
{"Search Wrapped", 175},
{"Replaced %d occurences", 176},
{"Replaced 1 occurence", 177},
{"Replace Cancelled", 178},
{"Nothing Happens", 179},
{"Replace with [%s]", 180},
{"Replace with", 181},
{"Replace this instance?", 182},
{"Enter line number", 183},
{"Aborted", 184},
{"Come on, be reasonable", 185},
{"Only %d lines available, skipping to last line", 186},
{"actual_x_from_start for xplus=%d returned %d\n", 187},
{"input '%c' (%d)\n", 188},
{"New Buffer", 189},
{" File: ...", 190},
{"Modified", 191},
{"Moved to (%d, %d) in edit buffer\n", 192},
{"current->data = \"%s\"\n", 193},
{"I got \"%s\"\n", 194},
{"Yes", 195},
{"All", 196},
{"No", 197},
{"do_cursorpos: linepct = %f, bytepct = %f\n", 198},
{"line %d of %d (%.0f%%), character %d of %d (%.0f%%)", 199},
{"Dumping file buffer to stderr...\n", 200},
{"Dumping cutbuffer to stderr...\n", 201},
{"Dumping a buffer to stderr...\n", 202},
};
int _msg_tbl_length = 199;
int _msg_tbl_length = 202;

View File

@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2000-10-24 01:12-0400\n"
"POT-Creation-Date: 2000-10-25 21:35-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -55,11 +55,11 @@ msgstr ""
msgid "File to insert [from ./] "
msgstr ""
#: files.c:274 files.c:298 files.c:488 nano.c:1133
#: files.c:274 files.c:298 files.c:486 nano.c:1134
msgid "Cancelled"
msgstr ""
#: files.c:320 files.c:340 files.c:353 files.c:370 files.c:376
#: files.c:320 files.c:340 files.c:354 files.c:371 files.c:377
#, c-format
msgid "Could not open file for writing: %s"
msgstr ""
@ -68,42 +68,42 @@ msgstr ""
msgid "Could not open file: Path length exceeded."
msgstr ""
#: files.c:358
#: files.c:359
#, c-format
msgid "Wrote >%s\n"
msgstr ""
#: files.c:385
#: files.c:386
#, c-format
msgid "Could not close %s: %s"
msgstr ""
#. Try a rename??
#: files.c:406 files.c:417 files.c:422
#: files.c:407 files.c:418 files.c:423
#, c-format
msgid "Could not open %s for writing: %s"
msgstr ""
#: files.c:428
#: files.c:429
#, c-format
msgid "Could not set permissions %o on %s: %s"
msgstr ""
#: files.c:435
#: files.c:436
#, c-format
msgid "Wrote %d lines"
msgstr ""
#: files.c:467
#: files.c:465
msgid "File Name to write"
msgstr ""
#: files.c:472
#: files.c:470
#, c-format
msgid "filename is %s"
msgstr ""
#: files.c:477
#: files.c:475
msgid "File exists, OVERWRITE ?"
msgstr ""
@ -263,131 +263,139 @@ msgstr ""
msgid "Cancel the current function"
msgstr ""
#: global.c:210 global.c:322 global.c:394
#: global.c:207
msgid "Use the null string, \"\""
msgstr ""
#: global.c:211 global.c:323 global.c:400
msgid "Get Help"
msgstr ""
#: global.c:213 global.c:221
#: global.c:214 global.c:222
msgid "WriteOut"
msgstr ""
#: global.c:217 global.c:383
#: global.c:218 global.c:389
msgid "Exit"
msgstr ""
#: global.c:225 global.c:318 global.c:339 global.c:358
#: global.c:226 global.c:319 global.c:341 global.c:361
msgid "Goto Line"
msgstr ""
#: global.c:230 global.c:309
#: global.c:231 global.c:310
msgid "Justify"
msgstr ""
#: global.c:234 global.c:305 global.c:336
#: global.c:235 global.c:306 global.c:337
msgid "Replace"
msgstr ""
#: global.c:238
#: global.c:239
msgid "Read File"
msgstr ""
#: global.c:242
#: global.c:243
msgid "Where Is"
msgstr ""
#: global.c:246 global.c:375
#: global.c:247 global.c:381
msgid "Prev Page"
msgstr ""
#: global.c:250 global.c:379
#: global.c:251 global.c:385
msgid "Next Page"
msgstr ""
#: global.c:254
#: global.c:255
msgid "Cut Text"
msgstr ""
#: global.c:257
#: global.c:258
msgid "UnCut Txt"
msgstr ""
#: global.c:261
#: global.c:262
msgid "Cur Pos"
msgstr ""
#: global.c:265
#: global.c:266
msgid "To Spell"
msgstr ""
#: global.c:269
#: global.c:270
msgid "Up"
msgstr ""
#: global.c:272
#: global.c:273
msgid "Down"
msgstr ""
#: global.c:275
#: global.c:276
msgid "Forward"
msgstr ""
#: global.c:278
#: global.c:279
msgid "Back"
msgstr ""
#: global.c:281
#: global.c:282
msgid "Home"
msgstr ""
#: global.c:284
#: global.c:285
msgid "End"
msgstr ""
#: global.c:287
#: global.c:288
msgid "Refresh"
msgstr ""
#: global.c:290
#: global.c:291
msgid "Mark Text"
msgstr ""
#: global.c:293
#: global.c:294
msgid "Delete"
msgstr ""
#: global.c:297
#: global.c:298
msgid "Backspace"
msgstr ""
#: global.c:301
#: global.c:302
msgid "Tab"
msgstr ""
#: global.c:313
#: global.c:314
msgid "Enter"
msgstr ""
#: global.c:326 global.c:346 global.c:365
#: global.c:327 global.c:348 global.c:371
msgid "First Line"
msgstr ""
#: global.c:329 global.c:349 global.c:368
#: global.c:330 global.c:351 global.c:374
msgid "Last Line"
msgstr ""
#: global.c:332 global.c:352
#: global.c:333 global.c:354
msgid "Case Sens"
msgstr ""
#: global.c:342 global.c:361 global.c:371 global.c:387 global.c:391
#: global.c:397 winio.c:979
#: global.c:344 global.c:367 global.c:377 global.c:393 global.c:397
#: global.c:403 winio.c:971
msgid "Cancel"
msgstr ""
#: global.c:355
#: global.c:357
msgid "No Replace"
msgstr ""
#: global.c:364
msgid "Null Str"
msgstr ""
#: nano.c:115
msgid ""
"\n"
@ -597,57 +605,57 @@ msgstr ""
msgid " nano version %s by Chris Allegretta (compiled %s, %s)\n"
msgstr ""
#: nano.c:402
#: nano.c:403
msgid " Email: nano@nano-editor.org\tWeb: http://www.nano-editor.org\n"
msgstr ""
#: nano.c:437
#: nano.c:438
msgid "Mark Set"
msgstr ""
#: nano.c:442
#: nano.c:443
msgid "Mark UNset"
msgstr ""
#: nano.c:868
#: nano.c:870
#, c-format
msgid "check_wrap called with inptr->data=\"%s\"\n"
msgstr ""
#: nano.c:919
#: nano.c:921
#, c-format
msgid "current->data now = \"%s\"\n"
msgstr ""
#: nano.c:972
#: nano.c:974
#, c-format
msgid "After, data = \"%s\"\n"
msgstr ""
#: nano.c:1042
#: nano.c:1043
msgid "Error deleting tempfile, ack!"
msgstr ""
#: nano.c:1060
#: nano.c:1061
#, c-format
msgid "Could not create a temporary filename: %s"
msgstr ""
#: nano.c:1083
#: nano.c:1084
#, c-format
msgid "Could not invoke spell program \"%s\""
msgstr ""
#. Why 32512? I dont know!
#: nano.c:1089
#: nano.c:1090
msgid "Could not invoke \"ispell\""
msgstr ""
#: nano.c:1102
#: nano.c:1103
msgid "Finished checking spelling"
msgstr ""
#: nano.c:1120
#: nano.c:1121
msgid "Save modified buffer (ANSWERING \"No\" WILL DESTROY CHANGES) ? "
msgstr ""
@ -675,52 +683,52 @@ msgstr ""
msgid "Cannot move bottom win"
msgstr ""
#: nano.c:1638
#: nano.c:1635
#, c-format
msgid "%s enable/disable"
msgstr ""
#: nano.c:1650
#: nano.c:1647
msgid "enabled"
msgstr ""
#: nano.c:1651
#: nano.c:1648
msgid "disabled"
msgstr ""
#: nano.c:1881
#: nano.c:1878
msgid "Main: set up windows\n"
msgstr ""
#: nano.c:1895
#: nano.c:1892
msgid "Main: bottom win\n"
msgstr ""
#: nano.c:1901
#: nano.c:1898
msgid "Main: open file\n"
msgstr ""
#: nano.c:1935
#: nano.c:1932
#, c-format
msgid "I got Alt-O-%c! (%d)\n"
msgstr ""
#: nano.c:1959
#: nano.c:1954
#, c-format
msgid "I got Alt-[-1-%c! (%d)\n"
msgstr ""
#: nano.c:1992
#: nano.c:1987
#, c-format
msgid "I got Alt-[-2-%c! (%d)\n"
msgstr ""
#: nano.c:2040
#: nano.c:2035
#, c-format
msgid "I got Alt-[-%c! (%d)\n"
msgstr ""
#: nano.c:2066
#: nano.c:2061
#, c-format
msgid "I got Alt-%c! (%d)\n"
msgstr ""
@ -735,21 +743,21 @@ msgstr ""
msgid "Regexp Search%s%s"
msgstr ""
#: search.c:82
#: search.c:81
#, c-format
msgid "Case Sensitive Search%s%s"
msgstr ""
#: search.c:84
#: search.c:83
#, c-format
msgid "Search%s%s"
msgstr ""
#: search.c:87
#: search.c:86
msgid " (to replace)"
msgstr ""
#: search.c:95
#: search.c:94
msgid "Search Cancelled"
msgstr ""
@ -766,38 +774,44 @@ msgstr ""
msgid "Replaced 1 occurence"
msgstr ""
#: search.c:392 search.c:413 search.c:436
#: search.c:390 search.c:419 search.c:444
msgid "Replace Cancelled"
msgstr ""
#: search.c:409
#. They used ^N in the search field, shame on them.
#. Any Dungeon fans out there?
#: search.c:407
msgid "Nothing Happens"
msgstr ""
#: search.c:415
#, c-format
msgid "Replace with [%s]"
msgstr ""
#. last_search is empty
#: search.c:434
#: search.c:442
msgid "Replace with"
msgstr ""
#: search.c:475
#: search.c:485
msgid "Replace this instance?"
msgstr ""
#. Ask for it
#: search.c:536
#: search.c:546
msgid "Enter line number"
msgstr ""
#: search.c:538
#: search.c:548
msgid "Aborted"
msgstr ""
#: search.c:558
#: search.c:568
msgid "Come on, be reasonable"
msgstr ""
#: search.c:563
#: search.c:573
#, c-format
msgid "Only %d lines available, skipping to last line"
msgstr ""
@ -824,50 +838,50 @@ msgstr ""
msgid "Modified"
msgstr ""
#: winio.c:895
#: winio.c:887
#, c-format
msgid "Moved to (%d, %d) in edit buffer\n"
msgstr ""
#: winio.c:906
#: winio.c:898
#, c-format
msgid "current->data = \"%s\"\n"
msgstr ""
#: winio.c:949
#: winio.c:941
#, c-format
msgid "I got \"%s\"\n"
msgstr ""
#: winio.c:974
#: winio.c:966
msgid "Yes"
msgstr ""
#: winio.c:976
#: winio.c:968
msgid "All"
msgstr ""
#: winio.c:978
#: winio.c:970
msgid "No"
msgstr ""
#: winio.c:1115
#: winio.c:1107
#, c-format
msgid "do_cursorpos: linepct = %f, bytepct = %f\n"
msgstr ""
#: winio.c:1119
#: winio.c:1111
msgid "line %d of %d (%.0f%%), character %d of %d (%.0f%%)"
msgstr ""
#: winio.c:1247
#: winio.c:1239
msgid "Dumping file buffer to stderr...\n"
msgstr ""
#: winio.c:1249
#: winio.c:1241
msgid "Dumping cutbuffer to stderr...\n"
msgstr ""
#: winio.c:1251
#: winio.c:1243
msgid "Dumping a buffer to stderr...\n"
msgstr ""

160
search.c
View File

@ -36,7 +36,7 @@
static char last_search[132] = ""; /* Last string we searched for */
static char last_replace[132] = ""; /* Last replacement string */
static int search_last_line;
static int search_last_line;
/* Regular expression helper functions */
@ -66,7 +66,7 @@ int search_init(int replacing)
int i;
char buf[BUFSIZ];
char *prompt, *reprompt = "";
if (last_search[0]) {
snprintf(buf, BUFSIZ, " [%s]", last_search);
} else {
@ -74,18 +74,17 @@ int search_init(int replacing)
}
if (ISSET(USE_REGEXP) && ISSET(CASE_SENSITIVE))
prompt = _("Case Sensitive Regexp Search%s%s");
prompt = _("Case Sensitive Regexp Search%s%s");
else if (ISSET(USE_REGEXP))
prompt = _("Regexp Search%s%s");
else
if (ISSET(CASE_SENSITIVE))
prompt = _("Case Sensitive Search%s%s");
prompt = _("Regexp Search%s%s");
else if (ISSET(CASE_SENSITIVE))
prompt = _("Case Sensitive Search%s%s");
else
prompt = _("Search%s%s");
prompt = _("Search%s%s");
if (replacing)
reprompt = _(" (to replace)");
i = statusq(replacing ? replace_list : whereis_list,
replacing ? REPLACE_LIST_LEN : WHEREIS_LIST_LEN, "",
prompt, reprompt, buf);
@ -98,14 +97,14 @@ int search_init(int replacing)
} else if (i == -2) { /* Same string */
strncpy(answer, last_search, 132);
#ifdef HAVE_REGEX_H
if (ISSET(USE_REGEXP))
regexp_init(answer);
if (ISSET(USE_REGEXP))
regexp_init(answer);
#endif
} else if (i == 0) { /* They entered something new */
strncpy(last_search, answer, 132);
#ifdef HAVE_REGEX_H
if (ISSET(USE_REGEXP))
regexp_init(answer);
if (ISSET(USE_REGEXP))
regexp_init(answer);
#endif
/* Blow away last_replace because they entered a new search
string....uh, right? =) */
@ -130,7 +129,8 @@ int search_init(int replacing)
return 0;
}
filestruct *findnextstr(int quiet, filestruct * begin, int beginx, char *needle)
filestruct *findnextstr(int quiet, filestruct * begin, int beginx,
char *needle)
{
filestruct *fileptr;
char *searchstr, *found = NULL, *tmp;
@ -141,20 +141,20 @@ filestruct *findnextstr(int quiet, filestruct * begin, int beginx, char *needle)
current_x++;
/* Are we searching the last line? (i.e. the line where search started) */
if ( (fileptr == begin) && (current_x < beginx) )
if ((fileptr == begin) && (current_x < beginx))
search_last_line = 1;
/* Make sure we haven't passed the end of the string */
if ( strlen(fileptr->data) < current_x )
if (strlen(fileptr->data) < current_x)
current_x--;
searchstr = &fileptr->data[current_x];
/* Look for needle in searchstr */
while (( found = strstrwrapper(searchstr, needle)) == NULL) {
while ((found = strstrwrapper(searchstr, needle)) == NULL) {
/* finished processing file, get out */
if (search_last_line) {
if (search_last_line) {
if (!quiet)
statusbar(_("\"%s\" not found"), needle);
return NULL;
@ -211,12 +211,12 @@ void search_abort(void)
UNSET(KEEP_CUTBUFFER);
display_main_list();
wrefresh(bottomwin);
if (ISSET(MARK_ISSET))
if (ISSET(MARK_ISSET))
edit_refresh_clearok();
#ifdef HAVE_REGEX_H
if (ISSET(REGEXP_COMPILED))
regexp_cleanup();
regexp_cleanup();
#endif
}
@ -274,8 +274,7 @@ int replace_regexp(char *string, int create_flag)
char *c;
int new_size = strlen(current->data) + 1;
int search_match_count = regmatches[0].rm_eo -
regmatches[0].rm_so;
int search_match_count = regmatches[0].rm_eo - regmatches[0].rm_so;
new_size -= search_match_count;
@ -284,50 +283,50 @@ int replace_regexp(char *string, int create_flag)
c = last_replace;
while (*c) {
if (*c != '\\') {
if (create_flag)
*string++=*c;
c++;
new_size++;
} else {
int num = (int)*(c+1) - (int)'0';
if (num >= 1 && num <= 9) {
if (*c != '\\') {
if (create_flag)
*string++ = *c;
c++;
new_size++;
} else {
int num = (int) *(c + 1) - (int) '0';
if (num >= 1 && num <= 9) {
int i = regmatches[num].rm_so;
int i = regmatches[num].rm_so;
if (num > search_regexp.re_nsub) {
/* Ugh, they specified a subexpression that doesn't
exist. */
return -1;
}
if (num > search_regexp.re_nsub) {
/* Ugh, they specified a subexpression that doesn't
exist. */
return -1;
}
/* Skip over the replacement expression */
c+=2;
/* Skip over the replacement expression */
c += 2;
/* But add the length of the subexpression to new_size */
new_size += regmatches[num].rm_eo - regmatches[num].rm_so;
/* But add the length of the subexpression to new_size */
new_size += regmatches[num].rm_eo - regmatches[num].rm_so;
/* And if create_flag is set, append the result of the
* subexpression match to the new line */
while (create_flag && i < regmatches[num].rm_eo )
*string++=*(current->data + i++);
} else {
if (create_flag)
*string++=*c;
c++;
new_size++;
}
}
/* And if create_flag is set, append the result of the
* subexpression match to the new line */
while (create_flag && i < regmatches[num].rm_eo)
*string++ = *(current->data + i++);
} else {
if (create_flag)
*string++ = *c;
c++;
new_size++;
}
}
}
if (create_flag)
*string = 0;
*string = 0;
return new_size;
}
#endif
char *replace_line()
{
char *copy, *tmp;
@ -337,22 +336,21 @@ char *replace_line()
/* Calculate size of new line */
#ifdef HAVE_REGEX_H
if (ISSET(USE_REGEXP)) {
search_match_count = regmatches[0].rm_eo -
regmatches[0].rm_so;
new_line_size = replace_regexp(NULL, 0);
/* If they specified an invalid subexpression in the replace
* text, return NULL indicating an error */
if (new_line_size < 0)
return NULL;
search_match_count = regmatches[0].rm_eo - regmatches[0].rm_so;
new_line_size = replace_regexp(NULL, 0);
/* If they specified an invalid subexpression in the replace
* text, return NULL indicating an error */
if (new_line_size < 0)
return NULL;
} else {
#else
{
#endif
search_match_count = strlen(last_search);
new_line_size = strlen(current->data) - strlen(last_search) +
strlen(last_replace) + 1;
search_match_count = strlen(last_search);
new_line_size = strlen(current->data) - strlen(last_search) +
strlen(last_replace) + 1;
}
/* Create buffer */
copy = nmalloc(new_line_size);
@ -362,10 +360,10 @@ char *replace_line()
/* Replacement Text */
if (!ISSET(USE_REGEXP))
strcat(copy, last_replace);
strcat(copy, last_replace);
#ifdef HAVE_REGEX_H
else
(void)replace_regexp(copy + current_x, 1);
(void) replace_regexp(copy + current_x, 1);
#endif
/* The tail of the original line */
@ -402,6 +400,14 @@ int do_replace(void)
replace_abort();
return 0;
}
if (!strcmp(answer, "")) {
/* They used ^N in the search field, shame on them.
Any Dungeon fans out there? */
statusbar(_("Nothing Happens"));
replace_abort();
return 0;
}
strncpy(prevanswer, answer, 132);
if (strcmp(last_replace, "")) { /* There's a previous replace str */
@ -415,6 +421,8 @@ int do_replace(void)
return 0;
} else if (i == 0) /* They actually entered something */
strncpy(last_replace, answer, 132);
else if (i == NANO_NULL_KEY) /* They actually entered something */
strcpy(last_replace, "");
else if (i == NANO_CASE_KEY) { /* They asked for case sensitivity */
if (ISSET(CASE_SENSITIVE))
UNSET(CASE_SENSITIVE);
@ -423,7 +431,7 @@ int do_replace(void)
do_replace();
return 0;
} else if (i != -2 ) { /* First page, last page, for example could get here */
} else if (i != -2) { /* First page, last page, for example could get here */
do_early_abort();
replace_abort();
@ -445,8 +453,10 @@ int do_replace(void)
SET(CASE_SENSITIVE);
do_replace();
return 1;
} else { /* First line key, etc. */
return -1;
} else if (i == NANO_NULL_KEY)
strcpy(last_replace, "");
else { /* First line key, etc. */
do_early_abort();
replace_abort();
@ -478,12 +488,12 @@ int do_replace(void)
if (i == 2)
replaceall = 1;
copy = replace_line();
if (!copy) {
statusbar("Replace failed: unknown subexpression!");
replace_abort();
copy = replace_line();
if (!copy) {
statusbar("Replace failed: unknown subexpression!");
replace_abort();
return 0;
}
}
/* Cleanup */
free(current->data);

13
utils.c
View File

@ -84,11 +84,11 @@ char *strstrwrapper(char *haystack, char *needle)
{
#ifdef HAVE_REGEX_H
if (ISSET(USE_REGEXP)) {
int result=regexec(&search_regexp, haystack, 10, regmatches, 0);
if (!result)
return haystack+regmatches[0].rm_so;
return 0;
}
int result = regexec(&search_regexp, haystack, 10, regmatches, 0);
if (!result)
return haystack + regmatches[0].rm_so;
return 0;
}
#endif
if (ISSET(CASE_SENSITIVE))
return strstr(haystack, needle);
@ -120,7 +120,8 @@ void *nrealloc(void *ptr, size_t howmuch)
}
/* Append a new magic-line to filebot */
void new_magicline(void) {
void new_magicline(void)
{
filebot->next = nmalloc(sizeof(filestruct));
filebot->next->data = nmalloc(1);
filebot->next->data[0] = '\0';

200
winio.c
View File

@ -259,8 +259,8 @@ int nanogetstr(char *buf, char *def, shortcut s[], int slen, int start_x)
xend = strlen(buf) + strlen(inputbuf);
switch (kbinput) {
/* Stuff we want to equate with <enter>, ASCII 13 */
case 343:
/* Stuff we want to equate with <enter>, ASCII 13 */
case 343:
ungetch(13); /* Enter on iris-ansi $TERM, sometimes */
break;
@ -605,110 +605,106 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x,
#ifndef NANO_SMALL
/* There are quite a few cases that could take place, we'll deal
* with them each in turn */
if (ISSET(MARK_ISSET)
if (ISSET(MARK_ISSET)
&& !((fileptr->lineno > mark_beginbuf->lineno
&& fileptr->lineno > current->lineno)
|| (fileptr->lineno < mark_beginbuf->lineno
&& fileptr->lineno < current->lineno)))
{
/* If we get here we are on a line that is atleast
* partially selected. The lineno checks above determined
* that */
if (fileptr != mark_beginbuf && fileptr != current) {
/* We are on a completely marked line, paint it all
* inverse */
&& fileptr->lineno > current->lineno)
|| (fileptr->lineno < mark_beginbuf->lineno
&& fileptr->lineno < current->lineno))) {
/* If we get here we are on a line that is atleast
* partially selected. The lineno checks above determined
* that */
if (fileptr != mark_beginbuf && fileptr != current) {
/* We are on a completely marked line, paint it all
* inverse */
wattron(edit, A_REVERSE);
mvwaddnstr(edit, yval, 0, fileptr->data, COLS);
wattroff(edit, A_REVERSE);
} else if (fileptr == mark_beginbuf && fileptr == current) {
/* Special case, we're still on the same line we started
* marking -- so we call our helper function */
if (virt_cur_x < virt_mark_beginx) {
/* To the right of us is marked */
add_marked_sameline(virt_cur_x, virt_mark_beginx,
fileptr, yval, virt_cur_x, this_page);
} else {
/* To the left of us is marked */
add_marked_sameline(virt_mark_beginx, virt_cur_x,
fileptr, yval, virt_cur_x, this_page);
}
} else if (fileptr == mark_beginbuf) {
/*
* we're updating the line that was first marked
* but we're not currently on it. So we want to
* figur out which half to invert based on our
* relative line numbers.
*
* i.e. If we're above the "beginbuf" line, we want to
* mark the left side. Otherwise we're below, so we
* mark the right
*/
int target;
if (mark_beginbuf->lineno > current->lineno)
wattron(edit, A_REVERSE);
mvwaddnstr(edit, yval, 0, fileptr->data, COLS);
target =
(virt_mark_beginx <
COLS - 1) ? virt_mark_beginx : COLS - 1;
mvwaddnstr(edit, yval, 0, fileptr->data, target);
if (mark_beginbuf->lineno < current->lineno)
wattron(edit, A_REVERSE);
else
wattroff(edit, A_REVERSE);
} else if (fileptr == mark_beginbuf && fileptr == current) {
/* Special case, we're still on the same line we started
* marking -- so we call our helper function */
if (virt_cur_x < virt_mark_beginx) {
/* To the right of us is marked */
add_marked_sameline(virt_cur_x, virt_mark_beginx,
fileptr, yval, virt_cur_x,
this_page);
} else {
/* To the left of us is marked */
add_marked_sameline(virt_mark_beginx, virt_cur_x,
fileptr, yval, virt_cur_x,
this_page);
}
} else if (fileptr == mark_beginbuf) {
/*
* we're updating the line that was first marked
* but we're not currently on it. So we want to
* figur out which half to invert based on our
* relative line numbers.
*
* i.e. If we're above the "beginbuf" line, we want to
* mark the left side. Otherwise we're below, so we
* mark the right
*/
int target;
if (mark_beginbuf->lineno > current->lineno)
wattron(edit, A_REVERSE);
target = (COLS - 1) - virt_mark_beginx;
if (target < 0)
target = 0;
target =
(virt_mark_beginx <
COLS - 1) ? virt_mark_beginx : COLS - 1;
mvwaddnstr(edit, yval, virt_mark_beginx,
&fileptr->data[virt_mark_beginx], target);
mvwaddnstr(edit, yval, 0, fileptr->data, target);
if (mark_beginbuf->lineno < current->lineno)
wattroff(edit, A_REVERSE);
if (mark_beginbuf->lineno < current->lineno)
wattron(edit, A_REVERSE);
else
wattroff(edit, A_REVERSE);
} else if (fileptr == current) {
/* we're on the cursors line, but it's not the first
* one we marked. Similar to the previous logic. */
int this_page_start = get_page_start_virtual(this_page),
this_page_end = get_page_end_virtual(this_page);
target = (COLS - 1) - virt_mark_beginx;
if (target < 0)
target = 0;
if (mark_beginbuf->lineno < current->lineno)
wattron(edit, A_REVERSE);
mvwaddnstr(edit, yval, virt_mark_beginx,
&fileptr->data[virt_mark_beginx], target);
if (virt_cur_x > COLS - 2) {
mvwaddnstr(edit, yval, 0,
&fileptr->data[this_page_start],
virt_cur_x - this_page_start);
} else {
mvwaddnstr(edit, yval, 0, fileptr->data, virt_cur_x);
}
if (mark_beginbuf->lineno < current->lineno)
wattroff(edit, A_REVERSE);
if (mark_beginbuf->lineno > current->lineno)
wattron(edit, A_REVERSE);
else
wattroff(edit, A_REVERSE);
} else if (fileptr == current) {
/* we're on the cursors line, but it's not the first
* one we marked. Similar to the previous logic. */
int this_page_start = get_page_start_virtual(this_page),
this_page_end = get_page_end_virtual(this_page);
if (virt_cur_x > COLS - 2)
mvwaddnstr(edit, yval, virt_cur_x - this_page_start,
&fileptr->data[virt_cur_x],
this_page_end - virt_cur_x);
else
mvwaddnstr(edit, yval, virt_cur_x,
&fileptr->data[virt_cur_x], COLS - virt_cur_x);
if (mark_beginbuf->lineno < current->lineno)
wattron(edit, A_REVERSE);
if (virt_cur_x > COLS - 2) {
mvwaddnstr(edit, yval, 0,
&fileptr->data[this_page_start],
virt_cur_x - this_page_start);
} else {
mvwaddnstr(edit, yval, 0, fileptr->data, virt_cur_x);
}
if (mark_beginbuf->lineno > current->lineno)
wattron(edit, A_REVERSE);
else
wattroff(edit, A_REVERSE);
if (virt_cur_x > COLS - 2)
mvwaddnstr(edit, yval, virt_cur_x - this_page_start,
&fileptr->data[virt_cur_x],
this_page_end - virt_cur_x);
else
mvwaddnstr(edit, yval, virt_cur_x,
&fileptr->data[virt_cur_x],
COLS - virt_cur_x);
if (mark_beginbuf->lineno > current->lineno)
wattroff(edit, A_REVERSE);
if (mark_beginbuf->lineno > current->lineno)
wattroff(edit, A_REVERSE);
}
} else
#endif
/* Just paint the string (no mark on this line) */
/* Just paint the string (no mark on this line) */
mvwaddnstr(edit, yval, 0, &fileptr->data[start],
get_page_end_virtual(this_page) - start);
}
@ -760,9 +756,8 @@ void update_line(filestruct * fileptr, int index)
virt_cur_x--;
if (i < mark_beginx)
virt_mark_beginx--;
}
else if (realdata[i] >= 1 && realdata[i] <= 26) {
/* Treat control characters as ^letter */
} else if (realdata[i] >= 1 && realdata[i] <= 26) {
/* Treat control characters as ^letter */
fileptr->data[pos++] = '^';
fileptr->data[pos++] = realdata[i] + 64;
} else {
@ -828,12 +823,10 @@ void edit_refresh(void)
}
/* If noloop == 1, then we already did an edit_update without finishing
this function. So we don't run edit_update again */
if (!currentcheck && !noloop) /* Then current has run off the screen... */
{
if (!currentcheck && !noloop) { /* Then current has run off the screen... */
edit_update(current, CENTER);
noloop = 1;
}
else if (noloop)
} else if (noloop)
noloop = 0;
if (lines <= editwinrows - 1)
@ -870,8 +863,7 @@ void edit_update(filestruct * fileptr, int topmidbot)
return;
temp = fileptr;
if (topmidbot == 2)
;
if (topmidbot == 2);
else if (topmidbot == 0)
for (i = 0; i <= editwinrows - 1 && temp->prev != NULL; i++)
temp = temp->prev;
@ -1186,7 +1178,7 @@ int do_help(void)
}
if (i > 1) {
}
i = 0;
@ -1274,10 +1266,10 @@ void dump_buffer_reverse(filestruct * inptr)
}
/* Fix editbot based on the assumption that edittop is correct */
void fix_editbot(void) {
void fix_editbot(void)
{
int i;
editbot = edittop;
for(i = 0; (i <= editwinrows - 1) && (editbot->next != NULL)
&& (editbot != filebot); i++, editbot = editbot->next);
for (i = 0; (i <= editwinrows - 1) && (editbot->next != NULL)
&& (editbot != filebot); i++, editbot = editbot->next);
}