DLR's cut and miscellaneous fixes, my cut fixes, and context-sensitive help, woohoo

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@864 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
Chris Allegretta 2001-10-22 03:15:31 +00:00
parent fac011a5e1
commit b3655b4c5e
25 changed files with 361 additions and 150 deletions

View File

@ -1,13 +1,34 @@
CVS code -
- General
- Finally wrote function-specific help mode. Changes to
nano.c:help_init() and winio.c:do_help(). Changed
currshortcut and currslen #ifdefs to depend on both
DISABLE_HELP and DISABLE_MOUSE being defined to not
include. Changed all the shortcuts and lengths.
- cut.c:
do_cut_text()
- Check to see whether marked text is contained within edit
window and if so only do an edit_refresh (variable dontupdate
replaces cuttingpartialline).
do_uncut_text()
- Similar display fixes (David Lawrence Ramsey).
- faq.html
- Removed nano-editor.org FTP site address [deprecated] and added
the GNU one.
- files.c:
- Added status messages for converted DOS and Mac files.
People should know that their file wasnt normally formatted.
People should know that their file wasnt normally formatted.
load_file()
- Status message when trying to load an already loaded file with multiple
buffers (David Lawrence Ramsey).
read_file()
- Get rid of useless linetemp variable and name num_lines int
(David Lawrence Ramsey).
- nano.c:
- New function do_prev_word, similar to do_next_word. Hard coded as
Alt-space, as next word is hard coded as control-space.
- rcfile.c:
- Fix incorrect number of rc options (David Lawrence Ramsey).
- po/sv.po:
- Updated Swedish translation (Christian Rose).
- po/sv.po:

40
cut.c
View File

@ -187,6 +187,7 @@ void cut_marked_segment(filestruct * top, int top_x, filestruct * bot,
if (top->lineno < edittop->lineno)
edit_update(top, CENTER);
}
}
#endif
@ -194,7 +195,7 @@ int do_cut_text(void)
{
filestruct *tmp, *fileptr = current;
#ifndef NANO_SMALL
int cuttingpartialline = 0;
int dontupdate = 0;
int cuttingtoend = 0;
#endif
@ -252,25 +253,40 @@ int do_cut_text(void)
cuttingtoend = 1;
}
}
if (ISSET(MARK_ISSET)) {
if (current->lineno <= mark_beginbuf->lineno) {
if (current->lineno == mark_beginbuf->lineno)
cuttingpartialline = 1;
/* Don't do_update and move the screen position if the marked
area lies entirely within the screen buffer */
if (current->lineno == mark_beginbuf->lineno
|| (current->lineno >= edittop->lineno
&& mark_beginbuf->lineno <= editbot->lineno))
dontupdate = 1;
cut_marked_segment(current, current_x, mark_beginbuf,
mark_beginx, 1);
}
else
else {
/* Same as above, easier logic since we know it's a multi-line
cut and mark_beginbuf is before current */
if (mark_beginbuf->lineno >= edittop->lineno
&& current->lineno <= editbot->lineno)
dontupdate = 1;
cut_marked_segment(mark_beginbuf, mark_beginx, current,
current_x, 1);
}
placewewant = xplustabs();
UNSET(MARK_ISSET);
marked_cut = 1;
set_modified();
if (cuttingpartialline || cuttingtoend)
if (dontupdate || cuttingtoend) {
fix_editbot();
edit_refresh();
else
} else
edit_update(current, CENTER);
return 1;
@ -417,8 +433,12 @@ int do_uncut_text(void)
i = editbot->lineno;
current = newend;
if (i <= newend->lineno)
if (i < newend->lineno) {
edit_update(current, CENTER);
}
else {
edit_refresh();
}
}
/* If marked cut == 2, that means that we're doing a cut to end
@ -476,8 +496,12 @@ int do_uncut_text(void)
i = editbot->lineno;
renumber(newbuf);
if (i < newend->lineno)
if (i < newend->lineno) {
edit_update(fileptr, CENTER);
}
else {
edit_refresh();
}
dump_buffer_reverse(fileptr);

30
files.c
View File

@ -62,8 +62,10 @@ void load_file(int quiet)
duplicate handling) */
if (quiet != 0)
quiet = 1;
if (add_open_file(quiet, 1 - quiet) == 2)
if (add_open_file(quiet, 1 - quiet) == 2) {
load_open_file();
statusbar(_("File already loaded"));
}
#endif
wmove(edit, current_y, current_x);
@ -172,7 +174,8 @@ filestruct *read_line(char *buf, filestruct * prev, int *line1ins)
int read_file(int fd, char *filename, int quiet)
{
long size, num_lines = 0, linetemp = 0;
long size;
int num_lines = 0;
char input[2]; /* buffer */
char *buf;
long i = 0, bufx = 128;
@ -193,7 +196,6 @@ int read_file(int fd, char *filename, int quiet)
input[1] = 0;
/* Read the entire file into file struct */
while ((size = read_byte(fd, filename, input)) > 0) {
linetemp = 0;
if (input[0] == '\n') {
fileptr = read_line(buf, fileptr, &line1ins);
@ -323,7 +325,7 @@ int do_insertfile(int loading_file)
wrap_reset();
#ifndef DISABLE_MOUSE
#if !defined(DISABLE_BROWSER) || !defined(DISABLE_MOUSE)
currshortcut = insertfile_list;
currslen = INSERTFILE_LIST_LEN;
#endif
@ -346,7 +348,7 @@ int do_insertfile(int loading_file)
if (i == NANO_TOFILES_KEY) {
char *tmp = do_browse_from(realname);
#ifndef DISABLE_MOUSE
#if !defined(DISABLE_HELP) || !defined(DISABLE_MOUSE)
currshortcut = insertfile_list;
currslen = INSERTFILE_LIST_LEN;
#endif
@ -531,6 +533,10 @@ int add_open_file(int update, int dup_fix)
/* save current modification status */
open_files->file_modified = ISSET(MODIFIED);
/* Unset the marker because nano can't (yet) handle marked text flipping between
open files */
UNSET(MARK_ISSET);
#ifdef DEBUG
fprintf(stderr, _("filename is %s"), open_files->data);
#endif
@ -574,6 +580,10 @@ int load_open_file(void)
totlines = open_files->file_totlines;
totsize = open_files->file_totsize;
/* Unset the marker because nano can't (yet) handle marked text flipping between
open files */
UNSET(MARK_ISSET);
/* restore full file position: line number, x-coordinate, y-
coordinate, place we want */
do_gotopos(open_files->lineno, open_files->file_current_x, open_files->file_current_y, open_files->file_placewewant);
@ -1281,7 +1291,7 @@ int do_writeout(char *path, int exiting, int append)
static int did_cred = 0;
#endif
#ifndef DISABLE_MOUSE
#if !defined(DISABLE_BROWSER) || !defined(DISABLE_MOUSE)
currshortcut = writefile_list;
currslen = WRITEFILE_LIST_LEN;
#endif
@ -1332,7 +1342,7 @@ int do_writeout(char *path, int exiting, int append)
char *tmp = do_browse_from(answer);
#ifndef DISABLE_MOUSE
#if !defined(DISABLE_BROWSER) || !defined(DISABLE_MOUSE)
currshortcut = writefile_list;
currslen = WRITEFILE_LIST_LEN;
#endif
@ -2076,7 +2086,7 @@ char *do_browser(char *inpath)
blank_statusbar_refresh();
#ifndef DISABLE_MOUSE
#if !defined DISABLE_HELP || !defined(DISABLE_MOUSE)
currshortcut = browser_list;
currslen = BROWSER_LIST_LEN;
#endif
@ -2187,6 +2197,10 @@ char *do_browser(char *inpath)
else
selected = numents - 1;
break;
case NANO_HELP_KEY:
case NANO_HELP_FKEY:
do_help();
break;
case KEY_ENTER:
case NANO_ENTER_KEY:
case 's': /* More Pico compatibility */

111
global.c
View File

@ -60,7 +60,7 @@ filestruct *open_files = NULL; /* The list of open files */
char *answer = NULL; /* Answer str to many questions */
int totlines = 0; /* Total number of lines in the file */
int totsize = 0; /* Total number of bytes in the file */
long totsize = 0; /* Total number of bytes in the file */
int placewewant = 0; /* The column we'd like the cursor
to jump to when we go to the
next or previous line */
@ -426,85 +426,98 @@ void shortcut_init(int unjustify)
NANO_BRACKET_KEY, 0, 0, VIEW, do_find_bracket);
#endif
sc_init_one(&whereis_list[0], NANO_FIRSTLINE_KEY, _("First Line"),
sc_init_one(&whereis_list[0], NANO_HELP_KEY,
_("Get Help"), nano_help_msg, 0, 0, 0, VIEW, do_help);
sc_init_one(&whereis_list[1], NANO_CANCEL_KEY,
_("Cancel"), nano_cancel_msg, 0, 0, 0, VIEW, 0);
sc_init_one(&whereis_list[2], NANO_FIRSTLINE_KEY, _("First Line"),
nano_firstline_msg, 0, 0, 0, VIEW, do_first_line);
sc_init_one(&whereis_list[1], NANO_LASTLINE_KEY, _("Last Line"),
sc_init_one(&whereis_list[3], NANO_LASTLINE_KEY, _("Last Line"),
nano_lastline_msg, 0, 0, 0, VIEW, do_last_line);
sc_init_one(&whereis_list[2], NANO_OTHERSEARCH_KEY, _("Replace"),
sc_init_one(&whereis_list[4], NANO_OTHERSEARCH_KEY, _("Replace"),
nano_replace_msg, 0, 0, 0, VIEW, do_replace);
sc_init_one(&whereis_list[3], NANO_FROMSEARCHTOGOTO_KEY,
sc_init_one(&whereis_list[5], NANO_FROMSEARCHTOGOTO_KEY,
_("Goto Line"), nano_goto_msg, 0, 0, 0, VIEW,
do_gotoline_void);
#ifndef NANO_SMALL
sc_init_one(&whereis_list[4], TOGGLE_CASE_KEY, _("Case Sens"),
sc_init_one(&whereis_list[6], TOGGLE_CASE_KEY, _("Case Sens"),
nano_case_msg, 0, 0, 0, VIEW, 0);
sc_init_one(&whereis_list[5], TOGGLE_BACKWARDS_KEY, _("Direction"),
sc_init_one(&whereis_list[7], TOGGLE_BACKWARDS_KEY, _("Direction"),
nano_reverse_msg, 0, 0, 0, VIEW, 0);
#ifdef HAVE_REGEX_H
sc_init_one(&whereis_list[REPLACE_LIST_LEN - 2], TOGGLE_REGEXP_KEY,
sc_init_one(&whereis_list[REPLACE_LIST_LEN - 1], TOGGLE_REGEXP_KEY,
_("Regexp"), nano_regexp_msg, 0, 0, 0, VIEW, 0);
#endif
#endif /* NANO_SMALL */
sc_init_one(&whereis_list[REPLACE_LIST_LEN - 1], NANO_CANCEL_KEY,
sc_init_one(&replace_list[0], NANO_HELP_KEY,
_("Get Help"), nano_help_msg, 0, 0, 0, VIEW, do_help);
sc_init_one(&replace_list[1], NANO_CANCEL_KEY,
_("Cancel"), nano_cancel_msg, 0, 0, 0, VIEW, 0);
sc_init_one(&replace_list[0], NANO_FIRSTLINE_KEY, _("First Line"),
sc_init_one(&replace_list[2], NANO_FIRSTLINE_KEY, _("First Line"),
nano_firstline_msg, 0, 0, 0, VIEW, do_first_line);
sc_init_one(&replace_list[1], NANO_LASTLINE_KEY, _("Last Line"),
sc_init_one(&replace_list[3], NANO_LASTLINE_KEY, _("Last Line"),
nano_lastline_msg, 0, 0, 0, VIEW, do_last_line);
sc_init_one(&replace_list[2], NANO_OTHERSEARCH_KEY, _("No Replace"),
sc_init_one(&replace_list[4], NANO_OTHERSEARCH_KEY, _("No Replace"),
nano_whereis_msg, 0, 0, 0, VIEW, do_search);
sc_init_one(&replace_list[3], NANO_FROMSEARCHTOGOTO_KEY,
sc_init_one(&replace_list[5], NANO_FROMSEARCHTOGOTO_KEY,
_("Goto Line"), nano_goto_msg, 0, 0, 0, VIEW,
do_gotoline_void);
#ifndef NANO_SMALL
sc_init_one(&replace_list[4], TOGGLE_CASE_KEY, _("Case Sens"),
sc_init_one(&replace_list[6], TOGGLE_CASE_KEY, _("Case Sens"),
nano_case_msg, 0, 0, 0, VIEW, 0);
sc_init_one(&replace_list[5], TOGGLE_BACKWARDS_KEY, _("Direction"),
sc_init_one(&replace_list[7], TOGGLE_BACKWARDS_KEY, _("Direction"),
nano_reverse_msg, 0, 0, 0, VIEW, 0);
#ifdef HAVE_REGEX_H
sc_init_one(&replace_list[REPLACE_LIST_LEN - 2], TOGGLE_REGEXP_KEY,
sc_init_one(&replace_list[REPLACE_LIST_LEN - 1], TOGGLE_REGEXP_KEY,
_("Regexp"), nano_regexp_msg, 0, 0, 0, VIEW, 0);
#endif
#endif /* NANO_SMALL */
sc_init_one(&replace_list[REPLACE_LIST_LEN - 1], NANO_CANCEL_KEY,
sc_init_one(&replace_list_2[0], NANO_HELP_KEY,
_("Get Help"), nano_help_msg, 0, 0, 0, VIEW, do_help);
sc_init_one(&replace_list_2[1], NANO_CANCEL_KEY,
_("Cancel"), nano_cancel_msg, 0, 0, 0, VIEW, 0);
sc_init_one(&replace_list_2[0], NANO_FIRSTLINE_KEY, _("First Line"),
sc_init_one(&replace_list_2[2], NANO_FIRSTLINE_KEY, _("First Line"),
nano_firstline_msg, 0, 0, 0, VIEW, do_first_line);
sc_init_one(&replace_list_2[1], NANO_LASTLINE_KEY, _("Last Line"),
sc_init_one(&replace_list_2[3], NANO_LASTLINE_KEY, _("Last Line"),
nano_lastline_msg, 0, 0, 0, VIEW, do_last_line);
sc_init_one(&replace_list_2[2], NANO_CANCEL_KEY, _("Cancel"),
sc_init_one(&goto_list[0], NANO_HELP_KEY,
_("Get Help"), nano_help_msg, 0, 0, 0, VIEW, do_help);
sc_init_one(&goto_list[1], NANO_CANCEL_KEY, _("Cancel"),
nano_cancel_msg, 0, 0, 0, VIEW, 0);
sc_init_one(&goto_list[0], NANO_FIRSTLINE_KEY, _("First Line"),
sc_init_one(&goto_list[2], NANO_FIRSTLINE_KEY, _("First Line"),
nano_firstline_msg, 0, 0, 0, VIEW, &do_first_line);
sc_init_one(&goto_list[1], NANO_LASTLINE_KEY, _("Last Line"),
sc_init_one(&goto_list[3], NANO_LASTLINE_KEY, _("Last Line"),
nano_lastline_msg, 0, 0, 0, VIEW, &do_last_line);
sc_init_one(&goto_list[2], NANO_CANCEL_KEY, _("Cancel"),
nano_cancel_msg, 0, 0, 0, VIEW, 0);
sc_init_one(&help_list[0], NANO_PREVPAGE_KEY, _("Prev Page"),
nano_prevpage_msg,
@ -518,44 +531,60 @@ void shortcut_init(int unjustify)
nano_exit_msg, 0, NANO_EXIT_FKEY, 0, VIEW, do_exit);
sc_init_one(&writefile_list[0], NANO_HELP_KEY,
_("Get Help"), nano_help_msg, 0, 0, 0, VIEW, do_help);
sc_init_one(&writefile_list[1], NANO_CANCEL_KEY, _("Cancel"),
nano_cancel_msg, 0, 0, 0, VIEW, 0);
#ifndef DISABLE_BROWSER
sc_init_one(&writefile_list[0], NANO_TOFILES_KEY, _("To Files"),
sc_init_one(&writefile_list[2], NANO_TOFILES_KEY, _("To Files"),
nano_tofiles_msg, 0, 0, 0, NOVIEW, 0);
#endif
sc_init_one(&writefile_list[WRITEFILE_LIST_LEN - 2], NANO_APPEND_KEY, _("Append"),
sc_init_one(&writefile_list[WRITEFILE_LIST_LEN - 1], NANO_APPEND_KEY, _("Append"),
nano_append_msg, 0, 0, 0, NOVIEW, 0);
sc_init_one(&writefile_list[WRITEFILE_LIST_LEN - 1], NANO_CANCEL_KEY, _("Cancel"),
sc_init_one(&insertfile_list[0], NANO_HELP_KEY,
_("Get Help"), nano_help_msg, 0, 0, 0, VIEW, do_help);
sc_init_one(&insertfile_list[1], NANO_CANCEL_KEY, _("Cancel"),
nano_cancel_msg, 0, 0, 0, VIEW, 0);
#ifndef DISABLE_BROWSER
sc_init_one(&insertfile_list[0], NANO_TOFILES_KEY, _("To Files"),
sc_init_one(&insertfile_list[2], NANO_TOFILES_KEY, _("To Files"),
nano_tofiles_msg, 0, 0, 0, NOVIEW, 0);
#endif
sc_init_one(&insertfile_list[INSERTFILE_LIST_LEN - 1], NANO_CANCEL_KEY, _("Cancel"),
sc_init_one(&spell_list[0], NANO_HELP_KEY,
_("Get Help"), nano_help_msg, 0, 0, 0, VIEW, do_help);
sc_init_one(&spell_list[1], NANO_CANCEL_KEY, _("Cancel"),
nano_cancel_msg, 0, 0, 0, VIEW, 0);
sc_init_one(&spell_list[0], NANO_CANCEL_KEY, _("Cancel"),
nano_cancel_msg, 0, 0, 0, VIEW, 0);
#ifndef DISABLE_BROWSER
sc_init_one(&browser_list[0], NANO_PREVPAGE_KEY, _("Prev Page"),
sc_init_one(&browser_list[0], NANO_HELP_KEY,
_("Get Help"), nano_help_msg, 0, 0, 0, VIEW, do_help);
sc_init_one(&browser_list[1], NANO_EXIT_KEY, _("Exit"),
nano_exit_msg, 0, NANO_EXIT_FKEY, 0, VIEW, 0);
sc_init_one(&browser_list[2], NANO_PREVPAGE_KEY, _("Prev Page"),
nano_prevpage_msg,
0, NANO_PREVPAGE_FKEY, KEY_PPAGE, VIEW, 0);
sc_init_one(&browser_list[1], NANO_NEXTPAGE_KEY, _("Next Page"),
sc_init_one(&browser_list[3], NANO_NEXTPAGE_KEY, _("Next Page"),
nano_nextpage_msg,
0, NANO_NEXTPAGE_FKEY, KEY_NPAGE, VIEW, 0);
sc_init_one(&browser_list[2], NANO_GOTO_KEY, _("Goto"),
sc_init_one(&browser_list[4], NANO_GOTO_KEY, _("Goto"),
nano_gotodir_msg, 0, NANO_GOTO_FKEY, 0, VIEW, 0);
sc_init_one(&browser_list[3], NANO_EXIT_KEY, _("Exit"),
nano_exit_msg, 0, NANO_EXIT_FKEY, 0, VIEW, 0);
sc_init_one(&gotodir_list[0], NANO_HELP_KEY,
_("Get Help"), nano_help_msg, 0, 0, 0, VIEW, do_help);
sc_init_one(&gotodir_list[0], NANO_CANCEL_KEY, _("Cancel"),
sc_init_one(&gotodir_list[1], NANO_CANCEL_KEY, _("Cancel"),
nano_cancel_msg, 0, 0, 0, VIEW, 0);
#endif

159
nano.c
View File

@ -260,7 +260,6 @@ void init_help_msg(void)
"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");
}
#endif
@ -1597,10 +1596,11 @@ int do_int_speller(char *tempfile_name)
/* External spell checking */
int do_alt_speller(char *file_name)
{
int alt_spell_status, x_cur = current_x, y_cur = current_y, pww_cur = placewewant;
int alt_spell_status, lineno_cur = current->lineno;
int x_cur = current_x, y_cur = current_y, pww_cur = placewewant;
pid_t pid_spell;
char *ptr;
long lineno_cur = current->lineno;
static int arglen = 3;
static char **spellargs = (char **) NULL;
@ -2331,20 +2331,101 @@ void help_init(void)
{
int i, sofar = 0;
long allocsize = 1; /* How much space we're gonna need for the help text */
char buf[BUFSIZ] = "";
char buf[BUFSIZ] = "", *ptr = NULL;
/* First set up the initial help text for the current function */
if (currshortcut == whereis_list || currshortcut == replace_list
|| currshortcut == replace_list_2)
ptr = _("Search Command Help Text\n\n "
"Enter the words or characters you would like to search "
"for, then hit enter. If there is a match for the text you "
"entered, the screen will be updated to the location of the "
" nearest match for the search string.\n\n "
"If using Pico Mode via the -p or --pico flags or using the "
"Meta-P toggle, the previous search string will be shown in "
"brackets after the Search: prompt. Hitting enter without "
"entering any text will preform the previous search. "
"Otherwise, the previous string will be placed in front of "
"the cursor, and can be edited or deleted before hitting "
"enter.\n\n The following functions keys are available in "
"Search mode:\n\n");
else if (currshortcut == goto_list)
ptr = _("Goto Line Help Text\n\n "
"Enter the line number that you wish to go to and hit "
"Enter. If thre are fewer lines of text than the "
"number you entered, you will be brought to the last line "
"of the file.\n\n The following functions keys are "
"available in Goto Line mode:\n\n");
else if (currshortcut == insertfile_list)
ptr = _("Insert File Help Text\n\n "
"Type in the name of a file to be inserted into the current "
"file buffer at the current cursor location.\n\n "
"If you have compiled nano with multiple file buffer "
"support, and enable multiple buffers with the -F "
"or --multibuffer command line flags or the Meta-F "
"toggle, inserting a file will cause it to be loaded into "
"a separate buffer (use Ctrl-< and > to switch between "
"file buffers).\n\n The following function keys are "
"available in Insert File mode:\n\n");
else if (currshortcut == writefile_list)
ptr = _("Write File Help Text\n\n "
"Type the name that you wish to save the current file "
"as and hit enter to save the file.\n\n "
"If you are using the marker code with Ctrl-^ and have "
"selected text, you will be prompted to save only the "
"selected portion to a separate file. To reduce the "
"chance of overwriting the current file with just a portion "
"of it, the current filename is not the default in this "
"mode.\n\n The following function keys are available in "
"Write File mode:\n\n");
#ifndef DISABLE_BROWSER
else if (currshortcut == browser_list)
ptr = _("File Browser Help Text\n\n "
"The file browser is used to visually browse the "
"directory structure to select a file for reading "
"or writing. You may use the arrow keys or Page Up/"
"Down to browse through the files, and S or Enter to "
"choose the selected file or enter the selected "
"directory. To move up one level, select the directory "
"called \"..\" at the top of the file list.\n\n The "
"following functions keys are available in the file "
"browser:\n\n");
else if (currshortcut == gotodir_list)
ptr = _("Browser Goto Directory Help Text\n\n "
"Enter the name of the directory you would like to "
"browse to.\n\n If tab completion has not been disabled, "
"you can use the TAB key to (attempt to) automatically "
"complete the directory name. The following function "
"keys are available in Browser GotoDir mode:\n\n");
#endif
else if (currshortcut == spell_list)
ptr = _("Spell Check Help Text\n\n "
"The spell checker checks the spelling of all text "
"in the current file. When an unknown word is "
"encountered, it is highlighted and a replacement can "
"be edited. It will then prompt to replace every "
"instance of the given misspelled word in the "
"current file.\n\n The following other functions are "
"available in Spell Check mode:\n\n");
else /* Default to the main help list */
ptr = help_text_init;
/* Compute the space needed for the shortcut lists - we add 15 to
have room for the shortcut abbrev and its possible alternate keys */
for (i = 0; i <= MAIN_LIST_LEN - 1; i++)
if (main_list[i].help != NULL)
allocsize += strlen(main_list[i].help) + 15;
for (i = 0; i <= currslen - 1; i++)
if (currshortcut[i].help != NULL)
allocsize += strlen(currshortcut[i].help) + 15;
/* And for the toggle list, we also allocate space for extra text. */
for (i = 0; i <= TOGGLE_LEN - 1; i++)
if (toggles[i].desc != NULL)
allocsize += strlen(toggles[i].desc) + 30;
/* If we're on the main list, we also allocate space for toggle help text. */
if (currshortcut == main_list) {
for (i = 0; i <= TOGGLE_LEN - 1; i++)
if (toggles[i].desc != NULL)
allocsize += strlen(toggles[i].desc) + 30;
}
allocsize += strlen(ptr);
allocsize += strlen(help_text_init);
if (help_text != NULL)
free(help_text);
@ -2353,33 +2434,37 @@ void help_init(void)
help_text = charalloc(allocsize);
/* Now add the text we want */
strcpy(help_text, help_text_init);
strcpy(help_text, ptr);
/* Now add our shortcut info */
for (i = 0; i <= MAIN_LIST_LEN - 1; i++) {
if (main_list[i].val > 0)
sofar = snprintf(buf, BUFSIZ, "^%c ", main_list[i].val + 64);
for (i = 0; i <= currslen - 1; i++) {
if (currshortcut[i].val > 0 && currshortcut[i].val < 'a')
sofar = snprintf(buf, BUFSIZ, "^%c ", currshortcut[i].val + 64);
else
sofar = snprintf(buf, BUFSIZ, " ");
if (main_list[i].misc1 > KEY_F0 && main_list[i].misc1 <= KEY_F(64))
if (currshortcut[i].misc1 > KEY_F0 && currshortcut[i].misc1 <= KEY_F(64))
sofar += snprintf(&buf[sofar], BUFSIZ - sofar, "(F%d) ",
main_list[i].misc1 - KEY_F0);
currshortcut[i].misc1 - KEY_F0);
else
sofar += snprintf(&buf[sofar], BUFSIZ - sofar, " ");
if (main_list[i].altval > 0 && main_list[i].altval < 91)
if (currshortcut[i].altval > 0 && currshortcut[i].altval < 91)
sofar += snprintf(&buf[sofar], BUFSIZ - sofar, "(M-%c) ",
main_list[i].altval - 32);
else if (main_list[i].altval > 0)
currshortcut[i].altval - 32);
else if (currshortcut[i].altval > 0)
sofar += snprintf(&buf[sofar], BUFSIZ - sofar, "(M-%c) ",
main_list[i].altval);
currshortcut[i].altval);
/* Hack */
else if (currshortcut[i].val >= 'a')
sofar += snprintf(&buf[sofar], BUFSIZ - sofar, "(M-%c) ",
currshortcut[i].val - 32);
else
sofar += snprintf(&buf[sofar], BUFSIZ - sofar, " ");
if (main_list[i].help != NULL)
snprintf(&buf[sofar], BUFSIZ - sofar, "%s", main_list[i].help);
if (currshortcut[i].help != NULL)
snprintf(&buf[sofar], BUFSIZ - sofar, "%s", currshortcut[i].help);
strcat(help_text, buf);
@ -2387,20 +2472,21 @@ void help_init(void)
}
/* And the toggles... */
for (i = 0; i <= TOGGLE_LEN - 1; i++) {
if (toggles[i].override_ch != 0)
sofar = snprintf(buf, BUFSIZ,
if (currshortcut == main_list)
for (i = 0; i <= TOGGLE_LEN - 1; i++) {
if (toggles[i].override_ch != 0)
sofar = snprintf(buf, BUFSIZ,
"M-%c ", toggles[i].override_ch);
else
sofar = snprintf(buf, BUFSIZ,
else
sofar = snprintf(buf, BUFSIZ,
"M-%c ", toggles[i].val - 32);
if (toggles[i].desc != NULL) {
if (toggles[i].flag != 0)
snprintf(&buf[sofar], BUFSIZ - sofar, _("%s enable/disable"),
if (toggles[i].desc != NULL) {
if (toggles[i].flag != 0)
snprintf(&buf[sofar], BUFSIZ - sofar, _("%s enable/disable"),
toggles[i].desc);
else
snprintf(&buf[sofar], BUFSIZ - sofar, "%s",
else
snprintf(&buf[sofar], BUFSIZ - sofar, "%s",
toggles[i].desc);
}
@ -2820,7 +2906,7 @@ int main(int argc, char *argv[])
reset_cursor();
while (1) {
constcheck = current->lineno + current_x + totsize;
constcheck = current->lineno + current_x + current_y + totsize;
#ifndef DISABLE_MOUSE
currshortcut = main_list;
@ -3082,6 +3168,7 @@ int main(int argc, char *argv[])
case -1: /* Stuff that we don't want to do squat */
case 410: /* Must ignore this, it gets sent when we resize */
case 29: /* Ctrl-] */
#ifdef PDCURSES
case 541: /* ???? */
case 542: /* Control and alt in Windows *shrug* */
@ -3107,7 +3194,7 @@ int main(int argc, char *argv[])
if (ISSET(DISABLE_CURPOS))
UNSET(DISABLE_CURPOS);
else if (ISSET(CONSTUPDATE))
if (constcheck != current->lineno + current_x + totsize)
if (constcheck != current->lineno + current_x + current_y + totsize)
do_cursorpos();
reset_cursor();

24
nano.h
View File

@ -82,10 +82,10 @@ typedef struct filestruct {
char *file_path; /* Current file's full path location */
int file_placewewant; /* Current file's place we want */
int file_totlines; /* Current file's total number of lines */
int file_totsize; /* Current file's total size */
long file_totsize; /* Current file's total size */
#endif
long lineno; /* The line number */
int lineno; /* The line number */
} filestruct;
typedef struct shortcut {
@ -313,21 +313,19 @@ know what you're doing */
#define MULTI_TOGGLES 0
#endif
#define WHEREIS_LIST_LEN (8 - NO_REGEX - NO_TOGGLES)
#define REPLACE_LIST_LEN (8 - NO_REGEX - NO_TOGGLES)
#define WHEREIS_LIST_LEN (9 - NO_REGEX - NO_TOGGLES)
#define REPLACE_LIST_LEN (9 - NO_REGEX - NO_TOGGLES)
#define TOGGLE_LEN (14 - NO_REGEX + MULTI_TOGGLES)
#define WRITEFILE_LIST_LEN (3 - NO_BROWSER)
#define INSERTFILE_LIST_LEN (2 - NO_BROWSER)
#define BROWSER_LIST_LEN 4
#define WRITEFILE_LIST_LEN (4 - NO_BROWSER)
#define INSERTFILE_LIST_LEN (3 - NO_BROWSER)
#define BROWSER_LIST_LEN 5
#define MAIN_LIST_LEN (27 - NO_REGEX)
#define MAIN_VISIBLE 12
#define REPLACE_LIST_2_LEN 3
#define GOTO_LIST_LEN 3
#define GOTODIR_LIST_LEN 1
#define REPLACE_LIST_2_LEN 4
#define GOTO_LIST_LEN 4
#define GOTODIR_LIST_LEN 2
#define HELP_LIST_LEN 3
#define SPELL_LIST_LEN 1
#define SPELL_LIST_LEN 2
#define VIEW 1

View File

@ -1215,8 +1215,8 @@ msgstr "do_cursorpos: linepct = %f, bytepct = %f\n"
#: winio.c:1436
#, c-format
msgid "line %d of %d (%.0f%%), character %d of %d (%.0f%%)"
msgstr "línia %d de %d (%.0f%%), caràcter %d de %d (%.0f%%)"
msgid "line %d of %d (%.0f%%), character %ld of %ld (%.0f%%)"
msgstr "línia %d de %d (%.0f%%), caràcter %ld de %ld (%.0f%%)"
#: winio.c:1580
msgid "Dumping file buffer to stderr...\n"

View File

@ -1241,8 +1241,8 @@ msgstr "do_cursorpos: linepct = %f, bytepct = %f\n"
#: winio.c:1436
#, c-format
msgid "line %d of %d (%.0f%%), character %d of %d (%.0f%%)"
msgstr "øádka %d z %d (%.0f%%), znak %d z %d (%.0f%%)"
msgid "line %d of %d (%.0f%%), character %ld of %ld (%.0f%%)"
msgstr "øádka %d z %d (%.0f%%), znak %ld z %ld (%.0f%%)"
#: winio.c:1580
msgid "Dumping file buffer to stderr...\n"

View File

@ -1166,8 +1166,8 @@ msgstr "do_cursorpos: linepct = %f, bytepct = %f\n"
#: winio.c:1436
#, c-format
msgid "line %d of %d (%.0f%%), character %d of %d (%.0f%%)"
msgstr "linje %d af %d (%.0f%%), tegn %d af %d (%.0f%%)"
msgid "line %d of %d (%.0f%%), character %ld of %ld (%.0f%%)"
msgstr "linje %d af %d (%.0f%%), tegn %ld af %ld (%.0f%%)"
#: winio.c:1580
msgid "Dumping file buffer to stderr...\n"

View File

@ -1248,8 +1248,8 @@ msgstr "do_cursorpos: linepct = %f, bytepct = %f\n"
#: winio.c:1436
#, c-format
msgid "line %d of %d (%.0f%%), character %d of %d (%.0f%%)"
msgstr "Zeile %d von %d (%.0f%%), Zeichen %d von %d (%.0f%%)"
msgid "line %d of %d (%.0f%%), character %ld of %ld (%.0f%%)"
msgstr "Zeile %d von %d (%.0f%%), Zeichen %ld von %ld (%.0f%%)"
#: winio.c:1580
msgid "Dumping file buffer to stderr...\n"

View File

@ -1213,8 +1213,8 @@ msgstr "do_cursorpos: linepct = %f, bytepct = %f\n"
#: winio.c:1436
#, c-format
msgid "line %d of %d (%.0f%%), character %d of %d (%.0f%%)"
msgstr "línea %d de %d (%.0f%%), carácter %d de %d (%.0f%%)"
msgid "line %d of %d (%.0f%%), character %ld of %ld (%.0f%%)"
msgstr "línea %d de %d (%.0f%%), carácter %ld de %ld (%.0f%%)"
#: winio.c:1580
msgid "Dumping file buffer to stderr...\n"

View File

@ -1217,8 +1217,8 @@ msgstr "do_cursorpos: linepct = %f, bytepct = %f\n"
#: winio.c:1436
#, c-format
msgid "line %d of %d (%.0f%%), character %d of %d (%.0f%%)"
msgstr "rivi %d/%d (%.0f%%), merkki %d/%d (%.0f%%)"
msgid "line %d of %d (%.0f%%), character %ld of %ld (%.0f%%)"
msgstr "rivi %d/%d (%.0f%%), merkki %ld/%ld (%.0f%%)"
#: winio.c:1580
msgid "Dumping file buffer to stderr...\n"

View File

@ -1253,8 +1253,8 @@ msgstr "do_cursorpos: linepct = %f, bytepct = %f\n"
#: winio.c:1436
#, c-format
msgid "line %d of %d (%.0f%%), character %d of %d (%.0f%%)"
msgstr "ligne %d sur %d (%.0f%%), caractère %d sur %d (%.0f%%)"
msgid "line %d of %d (%.0f%%), character %ld of %ld (%.0f%%)"
msgstr "ligne %d sur %d (%.0f%%), caractère %ld sur %ld (%.0f%%)"
#: winio.c:1580
msgid "Dumping file buffer to stderr...\n"

View File

@ -1164,8 +1164,8 @@ msgstr "do_cursorpos: linepct = %f, bytepct = %f\n"
#: winio.c:1436
#, c-format
msgid "line %d of %d (%.0f%%), character %d of %d (%.0f%%)"
msgstr "liña %d de %d (%.0f%%), carácter %d de %d (%.0f%%)"
msgid "line %d of %d (%.0f%%), character %ld of %ld (%.0f%%)"
msgstr "liña %d de %d (%.0f%%), carácter %ld de %ld (%.0f%%)"
#: winio.c:1580
msgid "Dumping file buffer to stderr...\n"

View File

@ -1234,8 +1234,8 @@ msgstr ""
#: winio.c:1436
#, c-format
msgid "line %d of %d (%.0f%%), character %d of %d (%.0f%%)"
msgstr "%d(/%d). sor (%.0f%%) és a(z) %d(/%d). karakter (%.0f%%)"
msgid "line %d of %d (%.0f%%), character %ld of %ld (%.0f%%)"
msgstr "%d(/%d). sor (%.0f%%) és a(z) %ld(/%ld). karakter (%.0f%%)"
#: winio.c:1580
msgid "Dumping file buffer to stderr...\n"

View File

@ -1231,8 +1231,8 @@ msgstr "do_cursorpos: linepct = %f, bytepct = %f\n"
#: winio.c:1436
#, c-format
msgid "line %d of %d (%.0f%%), character %d of %d (%.0f%%)"
msgstr "baris %d dari %d (%f.0f%%), karakter %d dari %d (%.0f%%)"
msgid "line %d of %d (%.0f%%), character %ld of %ld (%.0f%%)"
msgstr "baris %d dari %d (%f.0f%%), karakter %ld dari %ld (%.0f%%)"
#: winio.c:1580
msgid "Dumping file buffer to stderr...\n"

View File

@ -1226,8 +1226,8 @@ msgstr "do_cursorpos: linepct = %f, bytepct = %f\n"
#: winio.c:1436
#, c-format
msgid "line %d of %d (%.0f%%), character %d of %d (%.0f%%)"
msgstr "Riga %d di %d (%.0f%%), carattere %d di %d (%.0f%%)"
msgid "line %d of %d (%.0f%%), character %ld of %ld (%.0f%%)"
msgstr "Riga %d di %d (%.0f%%), carattere %ld di %ld (%.0f%%)"
#: winio.c:1580
msgid "Dumping file buffer to stderr...\n"

View File

@ -1232,8 +1232,8 @@ msgstr "do_cursorpos: linepct = %f, bytepct = %f\n"
#: winio.c:1436
#, c-format
msgid "line %d of %d (%.0f%%), character %d of %d (%.0f%%)"
msgstr "regel %d van %d (%.0f%%), karakter %d van %d (%.0f%%)"
msgid "line %d of %d (%.0f%%), character %ld of %ld (%.0f%%)"
msgstr "regel %d van %d (%.0f%%), karakter %ld van %ld (%.0f%%)"
#: winio.c:1580
msgid "Dumping file buffer to stderr...\n"

View File

@ -1233,8 +1233,8 @@ msgstr "do_cursorpos: linepct = %f, bytepct = %f\n"
#: winio.c:1436
#, c-format
msgid "line %d of %d (%.0f%%), character %d of %d (%.0f%%)"
msgstr "linje %d av %d (%.0f%%), tegn %d av %d (%.0f%%)"
msgid "line %d of %d (%.0f%%), character %ld of %ld (%.0f%%)"
msgstr "linje %d av %d (%.0f%%), tegn %ld av %ld (%.0f%%)"
#: winio.c:1580
msgid "Dumping file buffer to stderr...\n"

View File

@ -1163,8 +1163,8 @@ msgstr "do_cursorpos: linepct = %f, bytepct = %f\n"
#: winio.c:1436
#, c-format
msgid "line %d of %d (%.0f%%), character %d of %d (%.0f%%)"
msgstr "ÓÔÒÏËÁ %d ÉÚ %d (%.0f%%), ÓÉÍ×ÏÌ %d ÉÚ %d (%.0f%%)"
msgid "line %d of %d (%.0f%%), character %ld of %ld (%.0f%%)"
msgstr "ÓÔÒÏËÁ %d ÉÚ %d (%.0f%%), ÓÉÍ×ÏÌ %ld ÉÚ %ld (%.0f%%)"
#: winio.c:1580
msgid "Dumping file buffer to stderr...\n"

View File

@ -1165,8 +1165,8 @@ msgstr "do_cursorpos: linepct = %f, bytepct = %f\n"
#: winio.c:1436
#, c-format
msgid "line %d of %d (%.0f%%), character %d of %d (%.0f%%)"
msgstr "rad %d av %d (%.0f%%), tecken %d av %d (%.0f%%)"
msgid "line %d of %d (%.0f%%), character %ld of %ld (%.0f%%)"
msgstr "rad %d av %d (%.0f%%), tecken %ld av %ld (%.0f%%)"
#: winio.c:1580
msgid "Dumping file buffer to stderr...\n"

View File

@ -1168,8 +1168,8 @@ msgstr "do_cursorpos: linepct = %f, bytepct = %f\n"
#: winio.c:1436
#, c-format
msgid "line %d of %d (%.0f%%), character %d of %d (%.0f%%)"
msgstr "ÒÑÄÏË %d Ú %d (%.0f%%), ̦ÔÅÒÁ %d Ú %d (%.0f%%)"
msgid "line %d of %d (%.0f%%), character %ld of %ld (%.0f%%)"
msgstr "ÒÑÄÏË %d Ú %d (%.0f%%), ̦ÔÅÒÁ %ld Ú %ld (%.0f%%)"
#: winio.c:1580
msgid "Dumping file buffer to stderr...\n"

View File

@ -33,7 +33,8 @@ extern int editwinrows;
extern int current_x, current_y, posible_max, totlines;
extern int placewewant;
extern int mark_beginx, samelinewrap;
extern int totsize, temp_opt;
extern long totsize;
extern int temp_opt;
extern int fill, wrap_at, flags,tabsize;
extern int search_last_line;
extern int currslen;
@ -240,3 +241,7 @@ filestruct *findnextstr(int quiet, int bracket_mode, filestruct * begin,
#ifdef ENABLE_MULTIBUFFER
filestruct *open_file_dup_search(int update);
#endif
#ifndef DISABLE_HELP
void help_init(void);
#endif

View File

@ -39,7 +39,12 @@
#define _(string) (string)
#endif
#define NUM_RCOPTS 18
#ifndef DISABLE_WRAPJUSTIFY
#define NUM_RCOPTS 18
#else
#define NUM_RCOPTS 17
#endif
/* Static stuff for the nanorc file */
rcoption rcopts[NUM_RCOPTS] =
{

46
winio.c
View File

@ -229,6 +229,8 @@ void nanoget_repaint(char *buf, char *inputbuf, int x)
#ifdef ENABLE_COLOR
color_on(bottomwin, COLOR_STATUSBAR);
#else
wattron(bottomwin, A_REVERSE);
#endif
blank_statusbar();
@ -251,6 +253,8 @@ void nanoget_repaint(char *buf, char *inputbuf, int x)
#ifdef ENABLE_COLOR
color_off(bottomwin, COLOR_STATUSBAR);
#else
wattroff(bottomwin, A_REVERSE);
#endif
}
@ -271,7 +275,7 @@ int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen,
x_left = strlen(buf);
x = strlen(def) + x_left;
#ifndef DISABLE_MOUSE
#if !defined(DISABLE_HELP) || !defined(DISABLE_MOUSE)
currshortcut = s;
currslen = slen;
#endif
@ -293,6 +297,15 @@ int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen,
if (kbinput == s[j].val && kbinput < 32) {
#ifndef DISABLE_HELP
/* Have to do this here, it would be too late to do it in statusq */
if (kbinput == NANO_HELP_KEY
|| kbinput == NANO_HELP_FKEY) {
do_help();
break;
}
#endif
/* We shouldn't discard the answer it gave, just because
we hit a keystroke, GEEZ! */
answer = mallocstrcpy(answer, inputbuf);
@ -1058,6 +1071,10 @@ void edit_refresh(void)
editbot = hold;
else
editbot = temp;
/* What the hell are we expecting to update the screen if this isn't
here? luck?? */
wrefresh(edit);
}
/*
@ -1408,7 +1425,7 @@ int do_cursorpos(void)
{
filestruct *fileptr;
float linepct = 0.0, bytepct = 0.0;
int i = 0;
long i = 0;
if (current == NULL || fileage == NULL)
return 0;
@ -1433,7 +1450,7 @@ int do_cursorpos(void)
linepct, bytepct);
#endif
statusbar(_("line %d of %d (%.0f%%), character %d of %d (%.0f%%)"),
statusbar(_("line %d of %d (%.0f%%), character %ld of %ld (%.0f%%)"),
current->lineno, totlines, linepct, i, totsize, bytepct);
reset_cursor();
return 1;
@ -1444,18 +1461,25 @@ int do_cursorpos(void)
int do_help(void)
{
#ifndef DISABLE_HELP
char *ptr = help_text, *end;
char *ptr, *end;
int i, j, row = 0, page = 1, kbinput = 0, no_more = 0, kp, kp2;
int no_help_flag = 0;
shortcut *oldshortcut;
int oldslen;
blank_edit();
curs_set(0);
wattroff(bottomwin, A_REVERSE);
blank_statusbar();
#ifndef DISABLE_MOUSE
help_init();
ptr = help_text;
oldshortcut = currshortcut;
oldslen = currslen;
currshortcut = help_list;
currslen = HELP_LIST_LEN;
#endif
kp = keypad_on(edit, 1);
kp2 = keypad_on(bottomwin, 1);
@ -1550,13 +1574,17 @@ int do_help(void)
} while ((kbinput = wgetch(edit)) != NANO_EXIT_KEY &&
kbinput != NANO_EXIT_FKEY);
currshortcut = oldshortcut;
currslen = oldslen;
if (no_help_flag) {
blank_bottombars();
wrefresh(bottomwin);
SET(NO_HELP);
window_init();
}
display_main_list();
else
bottombars(currshortcut, currslen);
curs_set(1);
edit_refresh();
@ -1585,7 +1613,7 @@ void dump_buffer(filestruct * inptr)
fileptr = inptr;
while (fileptr != NULL) {
fprintf(stderr, "(%ld) %s\n", fileptr->lineno, fileptr->data);
fprintf(stderr, "(%d) %s\n", fileptr->lineno, fileptr->data);
fflush(stderr);
fileptr = fileptr->next;
}
@ -1599,7 +1627,7 @@ void dump_buffer_reverse(filestruct * inptr)
fileptr = filebot;
while (fileptr != NULL) {
fprintf(stderr, "(%ld) %s\n", fileptr->lineno, fileptr->data);
fprintf(stderr, "(%d) %s\n", fileptr->lineno, fileptr->data);
fflush(stderr);
fileptr = fileptr->prev;
}