static struct sigaction act; /* For all out fun signal handlers */
#ifndef DISABLE_HELP
-static char *help_text_init = ""; /* Initial message, not including shortcuts */
+static char *help_text_init = ""; /* Initial message, not including shortcuts */
#endif
char *last_search = NULL; /* Last string we searched for */
mvwaddstr(bottomwin, 2, 0, hblank);
} else
mvwaddstr(bottomwin, 0, 0, hblank);
-
+
wrefresh(bottomwin);
endwin();
name = "nano.save";
i = write_file(name, 1);
} else {
-
+
char *buf = nmalloc(strlen(filename) + 6);
strcpy(buf, filename);
strcat(buf, ".save");
return;
if (fileptr->data != NULL)
- free(fileptr->data);
+ free(fileptr->data);
free(fileptr);
}
#endif
#endif
printf(_(" -p Emulate Pico as closely as possible\n"));
- printf(_(" -r [#cols] Set fill cols to (wrap lines at) #cols\n"));
+ printf(_
+ (" -r [#cols] Set fill cols to (wrap lines at) #cols\n"));
#ifndef DISABLE_SPELLER
printf(_(" -s [prog] Enable alternate speller\n"));
#endif
#ifdef NANO_SMALL
printf(" --enable-tiny");
#else
- #ifdef DISABLE_BROWSER
+#ifdef DISABLE_BROWSER
printf(" --disable-browser");
- #endif
- #ifdef DISABLE_TABCOMP
+#endif
+#ifdef DISABLE_TABCOMP
printf(" --disable-tabcomp");
- #endif
- #ifdef DISABLE_JUSTIFY
+#endif
+#ifdef DISABLE_JUSTIFY
printf(" --disable-justify");
- #endif
- #ifdef DISABLE_SPELLER
+#endif
+#ifdef DISABLE_SPELLER
printf(" --disable-speller");
- #endif
- #ifdef DISABLE_HELP
+#endif
+#ifdef DISABLE_HELP
printf(" --disable-help");
- #endif
+#endif
#endif
#ifdef DISABLE_WRAPPING
}
/* Splice a node into an existing filestruct */
-void splice_node(filestruct * begin, filestruct * newnode, filestruct * end)
+void splice_node(filestruct * begin, filestruct * newnode,
+ filestruct * end)
{
newnode->next = end;
newnode->prev = begin;
current_x = 0;
if (ISSET(AUTOINDENT)) {
int i = 0;
- while ((inptr->next->data[i] == ' '
- || inptr->next->data[i] == '\t')) {
+ while ((inptr->next->data[i] == ' '
+ || inptr->next->data[i] == '\t')) {
i++;
right++;
- }
+ }
}
down = 1;
}
right = current_x - current_word_start;
if (ISSET(AUTOINDENT)) {
int i = 0;
- while ((inptr->next->data[i] == ' '
- || inptr->next->data[i] == '\t')) {
+ while ((inptr->next->data[i] == ' '
+ || inptr->next->data[i] == '\t')) {
i++;
right++;
- }
+ }
}
i = current_word_start - 1;
int old_x = current_x, old_y = current_y;
/* Plus one for the space which concatenates the two lines together plus 1 for \0. */
- char *p = nmalloc((strlen(temp->data) + strlen(inptr->next->data) + 2)
- * sizeof(char));
+ char *p =
+ nmalloc((strlen(temp->data) + strlen(inptr->next->data) + 2)
+ * sizeof(char));
if (ISSET(AUTOINDENT)) {
int non = 0;
- /* Grab the beginning of the next line until it's not a
- space or tab, then null terminate it so we can strcat it
- to hell */
- while ((inptr->next->data[non] == ' '
- || inptr->next->data[non] == '\t'))
- p[non] = inptr->next->data[non++];
+ /* Grab the beginning of the next line until it's not a
+ space or tab, then null terminate it so we can strcat it
+ to hell */
+ while ((inptr->next->data[non] == ' '
+ || inptr->next->data[non] == '\t'))
+ p[non] = inptr->next->data[non++];
p[non] = 0;
strcat(p, temp->data);
strcat(p, " ");
- /* Now tack on the rest of the next line after the spaces and
- tabs */
+ /* Now tack on the rest of the next line after the spaces and
+ tabs */
strcat(p, &inptr->next->data[non]);
} else {
strcpy(p, temp->data);
char *t = NULL;
int extra = 0;
if (spc) {
- while ((*spc == ' ') || (*spc == '\t')) {
+ while ((*spc == ' ') || (*spc == '\t')) {
extra++;
spc++;
totsize++;
/* Everything about it makes me want this line here but it causes
* totsize to be high by one for some reason. Sigh. (Rob) */
/* totsize++; */
-
+
renumber(inptr);
edit_update(edittop, TOP);
do_wrap(inptr, ch);
}
}
-#endif /* DISABLE_WRAPPING */
+#endif /* DISABLE_WRAPPING */
/* Stuff we do when we abort from programs and want to clean up the
* screen. This doesnt do much right now.
align(¤t->data);
- /* Now that we have a magic lnie again, we can check for both being
- on the line before filebot as well as at filebot */
+ /* Now that we have a magic lnie again, we can check for both being
+ on the line before filebot as well as at filebot */
} else if (current->next != NULL && current->next != filebot) {
current->data = nrealloc(current->data,
strlen(current->data) +
edit_update(fileage, TOP);
/* make sure word is still mis-spelt (i.e. when multi-errors) */
- if (findnextstr(TRUE, fileage, beginx_top, prevanswer) != NULL)
- {
+ if (findnextstr(TRUE, fileage, beginx_top, prevanswer) != NULL) {
do_replace_highlight(TRUE, prevanswer);
/* allow replace word to be corrected */
- i = statusq(0, spell_list, SPELL_LIST_LEN, last_replace,
- _("Edit a replacement"));
+ i = statusq(0, spell_list, SPELL_LIST_LEN, last_replace,
+ _("Edit a replacement"));
do_replace_highlight(FALSE, prevanswer);
/* A new process to run spell in */
- if ( (pid_spell = fork()) == 0) {
+ if ((pid_spell = fork()) == 0) {
/* Child continues, (i.e. future spell process) */
/* replace the standard in with the tempfile */
- if ( (tempfile_fd = open(tempfile_name, O_RDONLY)) == -1) {
+ if ((tempfile_fd = open(tempfile_name, O_RDONLY)) == -1) {
close(in_fd[1]);
exit(1);
/* Get system pipe buffer size */
- if ( (pipe_buff_size = fpathconf(in_fd[0], _PC_PIPE_BUF)) < 1) {
+ if ((pipe_buff_size = fpathconf(in_fd[0], _PC_PIPE_BUF)) < 1) {
close(in_fd[0]);
return FALSE;
}
- read_buff = nmalloc( pipe_buff_size + 1 );
+ read_buff = nmalloc(pipe_buff_size + 1);
/* Process the returned spelling errors */
- while ( (bytesread = read(in_fd[0], read_buff, pipe_buff_size)) > 0) {
+ while ((bytesread = read(in_fd[0], read_buff, pipe_buff_size)) > 0) {
read_buff[bytesread] = (char) NULL;
read_buff_word = read_buff_ptr = read_buff;
if (*read_buff_ptr == '\n') {
*read_buff_ptr = (char) NULL;
- if (!do_int_spell_fix(read_buff_word)) {
+ if (!do_int_spell_fix(read_buff_word)) {
close(in_fd[0]);
free(read_buff);
replace_abort();
return TRUE;
- }
+ }
read_buff_word = read_buff_ptr;
read_buff_word++;
}
if (WIFEXITED(spell_status)) {
if (WEXITSTATUS(spell_status) != 0)
return FALSE;
- }
- else
+ } else
return FALSE;
return TRUE;
spellargs[arglen - 2] = file_name;
/* Start a new process for the alternate speller */
- if ( (pid_spell = fork()) == 0) {
+ if ((pid_spell = fork()) == 0) {
/* Start alternate spell program, we are using the PATH here!?!? */
execvp(spellargs[0], spellargs);
if (WIFEXITED(alt_spell_status)) {
if (WEXITSTATUS(alt_spell_status) != 0)
return FALSE;
- }
- else
+ } else
return FALSE;
refresh();
if ((temp = tempnam(0, "nano.")) == NULL) {
statusbar(_("Could not create a temporary filename: %s"),
- strerror(errno));
+ strerror(errno));
return 0;
}
if (ISSET(TEMP_OPT)) {
i = 1;
} else {
- i =
- do_yesno(0, 0,
+ i = do_yesno(0, 0,
_
("Save modified buffer (ANSWERING \"No\" WILL DESTROY CHANGES) ? "));
}
if (getmouse(&mevent) == ERR)
return;
- /* If mouse not in edit window, return (add help selection later). */
- if (!wenclose(edit, mevent.y, mevent.x))
- return;
-
- /* Subtract out size of topwin. Perhaps we need a constant somewhere? */
- mevent.y -= 2;
+ /* If mouse not in edit or bottom window, return */
+ if (wenclose(edit, mevent.y, mevent.x)) {
- /* Selecting where the cursor is sets the mark.
- * Selecting beyond the line length with the cursor at the end of the
- * line sets the mark as well.
- */
- if ((mevent.y == current_y) &&
- ((mevent.x == current_x) || (current_x == strlen(current->data)
- && (mevent.x >
- strlen(current->data))))) {
- if (ISSET(VIEW_MODE)) {
- print_view_warning();
+ /* Don't let people screw with the marker when they're in a
+ subfunction */
+ if (currshortcut != main_list)
return;
+
+ /* Subtract out size of topwin. Perhaps we need a constant somewhere? */
+ mevent.y -= 2;
+
+ /* Selecting where the cursor is sets the mark.
+ * Selecting beyond the line length with the cursor at the end of the
+ * line sets the mark as well.
+ */
+ if ((mevent.y == current_y) &&
+ ((mevent.x == current_x) || (current_x == strlen(current->data)
+ && (mevent.x >
+ strlen(current->data))))) {
+ if (ISSET(VIEW_MODE)) {
+ print_view_warning();
+ return;
+ }
+ do_mark();
+ } else if (mevent.y > current_y) {
+ while (mevent.y > current_y) {
+ if (current->next != NULL)
+ current = current->next;
+ else
+ break;
+ current_y++;
+ }
+ } else if (mevent.y < current_y) {
+ while (mevent.y < current_y) {
+ if (current->prev != NULL)
+ current = current->prev;
+ else
+ break;
+ current_y--;
+ }
}
- do_mark();
- } else if (mevent.y > current_y) {
- while (mevent.y > current_y) {
- if (current->next != NULL)
- current = current->next;
- else
- break;
- current_y++;
- }
- } else if (mevent.y < current_y) {
- while (mevent.y < current_y) {
- if (current->prev != NULL)
- current = current->prev;
- else
- break;
- current_y--;
+ current_x = mevent.x;
+ placewewant = current_x;
+ 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)
+ current_x--;
+ foo++;
}
- }
- current_x = mevent.x;
- placewewant = current_x;
- 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)
- 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)
- current_x++;
+ /* 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)
+ current_x++;
- if (current_x > strlen(current->data))
- current_x = strlen(current->data);
+ if (current_x > strlen(current->data))
+ current_x = strlen(current->data);
- update_cursor();
- edit_refresh();
+ update_cursor();
+ edit_refresh();
+ } else if (wenclose(bottomwin, mevent.y, mevent.x) && !ISSET(NO_HELP)) {
+ int k = COLS / 6, val = 0;
+ /* Determine what shortcut list was clicked */
+ mevent.y -= (editwinrows + 3);
+
+ if (mevent.y < 0) /* They clicked on the statusbar */
+ return;
+
+ /* Don't select stuff beyond list length */
+ if (mevent.x / k >= currslen)
+ return;
+
+ val = currshortcut[(mevent.x / k) * 2 + mevent.y].val;
+
+ /* And ungetch that value */
+ ungetch(val);
+ }
}
#endif
#endif
#ifdef NCURSES_MOUSE_VERSION
if (ISSET(USE_MOUSE)) {
keypad_on(edit, 1);
+ keypad_on(bottomwin, 1);
mousemask(BUTTON1_RELEASED, NULL);
mouseinterval(50);
initial_y = current_y;
set_modified();
- cutbak = cutbuffer; /* Got to like cutbak ;) */
+ cutbak = cutbuffer; /* Got to like cutbak ;) */
totbak = totsize;
cutbuffer = NULL;
add_to_cutbuffer(tmpjust);
/* Wiping out a newline */
- totsize--;
+ totsize--;
/* length of both strings plus space between strings and ending \0. */
current->data = nrealloc(current->data, len + len2 + 2);
/* Now get a keystroke and see if it's unjustify, if not unget the keytroke
and return */
if ((kbinput = wgetch(edit)) != NANO_UNJUSTIFY_KEY) {
- ungetch(kbinput);
+ ungetch(kbinput);
blank_statusbar_refresh();
} else {
/* Else restore the justify we just did (ungrateful user!) */
else
fileage = current;
tmpbot->next->prev = tmptop->prev;
- current = tmpbot->next;
+ current = tmpbot->next;
tmpbot->next = NULL;
do_uncut_text();
if (tmptop->prev == NULL)
display_main_list();
free_filestruct(cutbuffer);
cutbuffer = cutbak;
-
+
return 1;
#endif
}
{
static int didmsg = 0;
if (!didmsg) {
- statusbar(_("NumLock glitch detected. Keypad will malfunction with NumLock off"));
+ statusbar(_
+ ("NumLock glitch detected. Keypad will malfunction with NumLock off"));
didmsg = 1;
}
}
Esc-O-[A-D] or Esc-[-[A-D]. */
int ABCD(int input)
{
- switch(input)
- {
- case 'A':
- return(KEY_UP);
- case 'B':
- return(KEY_DOWN);
- case 'C':
- return(KEY_RIGHT);
- case 'D':
- return(KEY_LEFT);
- default:
- return 0;
+ switch (input) {
+ case 'A':
+ return (KEY_UP);
+ case 'B':
+ return (KEY_DOWN);
+ case 'C':
+ return (KEY_RIGHT);
+ case 'D':
+ return (KEY_LEFT);
+ default:
+ return 0;
}
}
while ((optchr = getopt_long(argc, argv, "?T:RVbcefhiklmpr:s:tvwxz",
long_options, &option_index)) != EOF) {
#else
- while ((optchr = getopt(argc, argv, "h?T:RVbcefiklmpr:s:tvwxz")) != EOF) {
+ while ((optchr =
+ getopt(argc, argv, "h?T:RVbcefiklmpr:s:tvwxz")) != EOF) {
#endif
switch (optchr) {
case 'b':
case 'e':
case 'f':
- /* Pico compatibility flags */
- break;
+ /* Pico compatibility flags */
+ break;
case 'c':
SET(CONSTUPDATE);
break;
#else
SET(NO_WRAP);
break;
-#endif /* DISABLE_WRAPPING */
+#endif /* DISABLE_WRAPPING */
case 'x':
SET(NO_HELP);
break;
edit_update(fileage, CENTER);
/* return here after a sigwinch */
- sigsetjmp(jmpbuf,1);
+ sigsetjmp(jmpbuf, 1);
/* Fix clobber-age */
kbinput = 0;
while (1) {
+ currshortcut = main_list;
+ currslen = MAIN_VISIBLE;
+
#ifndef _POSIX_VDISABLE
/* We're going to have to do it the old way, i.e. on cygwin */
raw();
case 79:
kbinput = wgetch(edit);
if (kbinput <= 'D' && kbinput >= 'A')
- kbinput = ABCD(kbinput);
+ kbinput = ABCD(kbinput);
else if (kbinput <= 'z' && kbinput >= 'j')
print_numlock_warning();
else if (kbinput <= 'S' && kbinput >= 'P')