Commit 71844ba0 authored by Chris Allegretta's avatar Chris Allegretta
Browse files

Use old-style editing with PICO_MSGS enabled

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@265 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 111 additions and 71 deletions
+111 -71
...@@ -13,6 +13,7 @@ CVS Code - ...@@ -13,6 +13,7 @@ CVS Code -
nightmare, changed last_search, last_replace, answer to nightmare, changed last_search, last_replace, answer to
pointers. New function not_found_msg in search.c for displaying pointers. New function not_found_msg in search.c for displaying
truncated strings in satusbar when the string is not found. truncated strings in satusbar when the string is not found.
We disable this feature when using PICO_MSGS (-p).
- files.c: - files.c:
do_writeout() do_writeout()
- Change strcpy to answer to mallocstrcpy. - Change strcpy to answer to mallocstrcpy.
......
...@@ -209,29 +209,30 @@ Usage: nano [option] +LINE <file>\n\ ...@@ -209,29 +209,30 @@ Usage: nano [option] +LINE <file>\n\
{"Replaced %d occurences", 176}, {"Replaced %d occurences", 176},
{"Replaced 1 occurence", 177}, {"Replaced 1 occurence", 177},
{"Replace Cancelled", 178}, {"Replace Cancelled", 178},
{"Replace with", 179}, {"Replace with [%s]", 179},
{"Replace this instance?", 180}, {"Replace with", 180},
{"Replace failed: unknown subexpression!", 181}, {"Replace this instance?", 181},
{"Enter line number", 182}, {"Replace failed: unknown subexpression!", 182},
{"Aborted", 183}, {"Enter line number", 183},
{"Come on, be reasonable", 184}, {"Aborted", 184},
{"Only %d lines available, skipping to last line", 185}, {"Come on, be reasonable", 185},
{"actual_x_from_start for xplus=%d returned %d\n", 186}, {"Only %d lines available, skipping to last line", 186},
{"input '%c' (%d)\n", 187}, {"actual_x_from_start for xplus=%d returned %d\n", 187},
{"New Buffer", 188}, {"input '%c' (%d)\n", 188},
{" File: ...", 189}, {"New Buffer", 189},
{"Modified", 190}, {" File: ...", 190},
{"Moved to (%d, %d) in edit buffer\n", 191}, {"Modified", 191},
{"current->data = \"%s\"\n", 192}, {"Moved to (%d, %d) in edit buffer\n", 192},
{"I got \"%s\"\n", 193}, {"current->data = \"%s\"\n", 193},
{"Yes", 194}, {"I got \"%s\"\n", 194},
{"All", 195}, {"Yes", 195},
{"No", 196}, {"All", 196},
{"do_cursorpos: linepct = %f, bytepct = %f\n", 197}, {"No", 197},
{"line %d of %d (%.0f%%), character %d of %d (%.0f%%)", 198}, {"do_cursorpos: linepct = %f, bytepct = %f\n", 198},
{"Dumping file buffer to stderr...\n", 199}, {"line %d of %d (%.0f%%), character %d of %d (%.0f%%)", 199},
{"Dumping cutbuffer to stderr...\n", 200}, {"Dumping file buffer to stderr...\n", 200},
{"Dumping a buffer to stderr...\n", 201}, {"Dumping cutbuffer to stderr...\n", 201},
{"Dumping a buffer to stderr...\n", 202},
}; };
int _msg_tbl_length = 201; int _msg_tbl_length = 202;
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2000-11-02 20:48-0500\n" "POT-Creation-Date: 2000-11-03 09:21-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
...@@ -32,7 +32,7 @@ msgstr "" ...@@ -32,7 +32,7 @@ msgstr ""
msgid "Read %d lines" msgid "Read %d lines"
msgstr "" msgstr ""
#: files.c:217 search.c:148 #: files.c:217 search.c:163
#, c-format #, c-format
msgid "\"%s\" not found" msgid "\"%s\" not found"
msgstr "" msgstr ""
...@@ -380,7 +380,7 @@ msgid "Case Sens" ...@@ -380,7 +380,7 @@ msgid "Case Sens"
msgstr "" msgstr ""
#: global.c:344 global.c:364 global.c:375 global.c:385 global.c:401 #: global.c:344 global.c:364 global.c:375 global.c:385 global.c:401
#: global.c:405 global.c:411 winio.c:992 #: global.c:405 global.c:411 winio.c:993
msgid "Cancel" msgid "Cancel"
msgstr "" msgstr ""
...@@ -729,82 +729,87 @@ msgstr "" ...@@ -729,82 +729,87 @@ msgstr ""
msgid "I got Alt-%c! (%d)\n" msgid "I got Alt-%c! (%d)\n"
msgstr "" msgstr ""
#: search.c:88 #: search.c:98
#, c-format #, c-format
msgid "Case Sensitive Regexp Search%s%s" msgid "Case Sensitive Regexp Search%s%s"
msgstr "" msgstr ""
#: search.c:90 #: search.c:100
#, c-format #, c-format
msgid "Regexp Search%s%s" msgid "Regexp Search%s%s"
msgstr "" msgstr ""
#: search.c:92 #: search.c:102
#, c-format #, c-format
msgid "Case Sensitive Search%s%s" msgid "Case Sensitive Search%s%s"
msgstr "" msgstr ""
#: search.c:94 #: search.c:104
#, c-format #, c-format
msgid "Search%s%s" msgid "Search%s%s"
msgstr "" msgstr ""
#: search.c:97 #: search.c:107
msgid " (to replace)" msgid " (to replace)"
msgstr "" msgstr ""
#: search.c:105 search.c:274 #: search.c:120 search.c:289
msgid "Search Cancelled" msgid "Search Cancelled"
msgstr "" msgstr ""
#: search.c:152 #: search.c:167
#, c-format #, c-format
msgid "\"%s...\" not found" msgid "\"%s...\" not found"
msgstr "" msgstr ""
#: search.c:199 #: search.c:214
msgid "Search Wrapped" msgid "Search Wrapped"
msgstr "" msgstr ""
#: search.c:288 #: search.c:303
#, c-format #, c-format
msgid "Replaced %d occurences" msgid "Replaced %d occurences"
msgstr "" msgstr ""
#: search.c:290 #: search.c:305
msgid "Replaced 1 occurence" msgid "Replaced 1 occurence"
msgstr "" msgstr ""
#: search.c:426 search.c:442 search.c:456 #: search.c:441 search.c:457 search.c:488
msgid "Replace Cancelled" msgid "Replace Cancelled"
msgstr "" msgstr ""
#: search.c:450 #: search.c:474
#, c-format
msgid "Replace with [%s]"
msgstr ""
#: search.c:478 search.c:482
msgid "Replace with" msgid "Replace with"
msgstr "" msgstr ""
#: search.c:487 #: search.c:519
msgid "Replace this instance?" msgid "Replace this instance?"
msgstr "" msgstr ""
#: search.c:495 #: search.c:527
msgid "Replace failed: unknown subexpression!" msgid "Replace failed: unknown subexpression!"
msgstr "" msgstr ""
#. Ask for it #. Ask for it
#: search.c:548 #: search.c:580
msgid "Enter line number" msgid "Enter line number"
msgstr "" msgstr ""
#: search.c:550 #: search.c:582
msgid "Aborted" msgid "Aborted"
msgstr "" msgstr ""
#: search.c:570 #: search.c:602
msgid "Come on, be reasonable" msgid "Come on, be reasonable"
msgstr "" msgstr ""
#: search.c:575 #: search.c:607
#, c-format #, c-format
msgid "Only %d lines available, skipping to last line" msgid "Only %d lines available, skipping to last line"
msgstr "" msgstr ""
...@@ -819,62 +824,62 @@ msgstr "" ...@@ -819,62 +824,62 @@ msgstr ""
msgid "input '%c' (%d)\n" msgid "input '%c' (%d)\n"
msgstr "" msgstr ""
#: winio.c:445 #: winio.c:446
msgid "New Buffer" msgid "New Buffer"
msgstr "" msgstr ""
#: winio.c:448 #: winio.c:449
msgid " File: ..." msgid " File: ..."
msgstr "" msgstr ""
#: winio.c:456 #: winio.c:457
msgid "Modified" msgid "Modified"
msgstr "" msgstr ""
#: winio.c:908 #: winio.c:909
#, c-format #, c-format
msgid "Moved to (%d, %d) in edit buffer\n" msgid "Moved to (%d, %d) in edit buffer\n"
msgstr "" msgstr ""
#: winio.c:919 #: winio.c:920
#, c-format #, c-format
msgid "current->data = \"%s\"\n" msgid "current->data = \"%s\"\n"
msgstr "" msgstr ""
#: winio.c:962 #: winio.c:963
#, c-format #, c-format
msgid "I got \"%s\"\n" msgid "I got \"%s\"\n"
msgstr "" msgstr ""
#: winio.c:987 #: winio.c:988
msgid "Yes" msgid "Yes"
msgstr "" msgstr ""
#: winio.c:989 #: winio.c:990
msgid "All" msgid "All"
msgstr "" msgstr ""
#: winio.c:991 #: winio.c:992
msgid "No" msgid "No"
msgstr "" msgstr ""
#: winio.c:1128 #: winio.c:1129
#, c-format #, c-format
msgid "do_cursorpos: linepct = %f, bytepct = %f\n" msgid "do_cursorpos: linepct = %f, bytepct = %f\n"
msgstr "" msgstr ""
#: winio.c:1132 #: winio.c:1133
msgid "line %d of %d (%.0f%%), character %d of %d (%.0f%%)" msgid "line %d of %d (%.0f%%), character %d of %d (%.0f%%)"
msgstr "" msgstr ""
#: winio.c:1260 #: winio.c:1261
msgid "Dumping file buffer to stderr...\n" msgid "Dumping file buffer to stderr...\n"
msgstr "" msgstr ""
#: winio.c:1262 #: winio.c:1263
msgid "Dumping cutbuffer to stderr...\n" msgid "Dumping cutbuffer to stderr...\n"
msgstr "" msgstr ""
#: winio.c:1264 #: winio.c:1265
msgid "Dumping a buffer to stderr...\n" msgid "Dumping a buffer to stderr...\n"
msgstr "" msgstr ""
...@@ -63,8 +63,8 @@ void regexp_cleanup() ...@@ -63,8 +63,8 @@ void regexp_cleanup()
*/ */
int search_init(int replacing) int search_init(int replacing)
{ {
int i; int i = 0;
/* char buf[BUFSIZ]; */ char *buf;
char *prompt, *reprompt = ""; char *prompt, *reprompt = "";
if (last_search == NULL) { if (last_search == NULL) {
...@@ -76,13 +76,23 @@ int search_init(int replacing) ...@@ -76,13 +76,23 @@ int search_init(int replacing)
last_replace[0] = 0; last_replace[0] = 0;
} }
/* buf = nmalloc(strlen(last_search) + 5);
if (last_search[0]) { buf[0] = 0;
snprintf(buf, BUFSIZ, " [%s]", last_search);
} else { /* If using Pico messages, we do things the old fashioned way... */
buf[0] = '\0'; if (ISSET(PICO_MSGS)) {
if (last_search[0]) {
/* We use COLS / 3 here because we need to see more on the line */
if (strlen(last_search) > COLS / 3) {
snprintf(buf, COLS / 3 + 3, " [%s", last_search);
sprintf(&buf[COLS / 3 + 2], "...]");
} else
sprintf(buf, " [%s]", last_search);
} else {
buf[0] = '\0';
}
} }
*/
if (ISSET(USE_REGEXP) && ISSET(CASE_SENSITIVE)) if (ISSET(USE_REGEXP) && ISSET(CASE_SENSITIVE))
prompt = _("Case Sensitive Regexp Search%s%s"); prompt = _("Case Sensitive Regexp Search%s%s");
...@@ -96,7 +106,12 @@ int search_init(int replacing) ...@@ -96,7 +106,12 @@ int search_init(int replacing)
if (replacing) if (replacing)
reprompt = _(" (to replace)"); reprompt = _(" (to replace)");
i = statusq(replacing ? replace_list : whereis_list, if (ISSET(PICO_MSGS))
i = statusq(replacing ? replace_list : whereis_list,
replacing ? REPLACE_LIST_LEN : WHEREIS_LIST_LEN, "",
prompt, reprompt, buf);
else
i = statusq(replacing ? replace_list : whereis_list,
replacing ? REPLACE_LIST_LEN : WHEREIS_LIST_LEN, last_search, replacing ? REPLACE_LIST_LEN : WHEREIS_LIST_LEN, last_search,
prompt, reprompt, ""); prompt, reprompt, "");
...@@ -418,7 +433,7 @@ int do_replace(void) ...@@ -418,7 +433,7 @@ int do_replace(void)
{ {
int i, replaceall = 0, numreplaced = 0, beginx; int i, replaceall = 0, numreplaced = 0, beginx;
filestruct *fileptr, *begin; filestruct *fileptr, *begin;
char *copy, *prevanswer = NULL; char *copy, *prevanswer = NULL, *buf = NULL;
i = search_init(1); i = search_init(1);
switch (i) { switch (i) {
...@@ -446,7 +461,24 @@ int do_replace(void) ...@@ -446,7 +461,24 @@ int do_replace(void)
prevanswer = mallocstrcpy(prevanswer, answer); prevanswer = mallocstrcpy(prevanswer, answer);
i = statusq(replace_list_2, REPLACE_LIST_2_LEN, last_replace, if (ISSET(PICO_MSGS)) {
buf = nmalloc(strlen(last_replace) + 5);
if (strcmp(last_replace, "")) {
if (strlen(last_replace) > (COLS / 3)) {
strncpy(buf, last_replace, COLS / 3);
sprintf(&buf[COLS / 3 - 1], "...");
} else
sprintf(buf, "%s", last_replace);
i = statusq(replace_list_2, REPLACE_LIST_2_LEN, "",
_("Replace with [%s]"), buf);
}
else
i = statusq(replace_list_2, REPLACE_LIST_2_LEN, "",
_("Replace with"));
}
else
i = statusq(replace_list_2, REPLACE_LIST_2_LEN, last_replace,
_("Replace with")); _("Replace with"));
switch (i) { switch (i) {
......
...@@ -416,7 +416,8 @@ int nanogetstr(char *buf, char *def, shortcut s[], int slen, int start_x) ...@@ -416,7 +416,8 @@ int nanogetstr(char *buf, char *def, shortcut s[], int slen, int start_x)
/* Now that the text is editable instead of bracketed, we have to /* Now that the text is editable instead of bracketed, we have to
check for answer == def, instead of answer == "" */ check for answer == def, instead of answer == "" */
if (!strcmp(answer, def)) if (((ISSET(PICO_MSGS)) && !strcmp(answer, "")) ||
((!ISSET(PICO_MSGS)) && !strcmp(answer, def)))
return -2; return -2;
else else
return 0; return 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment