Commit 6b58acd3 authored by Chris Allegretta's avatar Chris Allegretta
Browse files

More mouse integration, esp with the shortcut lists

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@593 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
parent ac840eb4
No related merge requests found
Showing with 214 additions and 136 deletions
+214 -136
Cvs code - Cvs code -
- General
- New global variables currshortcut and currslen to support using
the mouse with the shortcuts. FIXME - Does not support the
do_yesno function yet as that will have to be done by hand.
nano 1.1 tree forked here 04/07/2001 nano 1.1 tree forked here 04/07/2001
......
...@@ -258,6 +258,8 @@ int do_insertfile(void) ...@@ -258,6 +258,8 @@ int do_insertfile(void)
char *realname = NULL; char *realname = NULL;
wrap_reset(); wrap_reset();
currshortcut = writefile_list;
currslen = WRITEFILE_LIST_LEN;
i = statusq(1, writefile_list, WRITEFILE_LIST_LEN, "", i = statusq(1, writefile_list, WRITEFILE_LIST_LEN, "",
_("File to insert [from ./] ")); _("File to insert [from ./] "));
if (i != -1) { if (i != -1) {
...@@ -276,6 +278,8 @@ int do_insertfile(void) ...@@ -276,6 +278,8 @@ int do_insertfile(void)
if (i == NANO_TOFILES_KEY) { if (i == NANO_TOFILES_KEY) {
char *tmp = do_browse_from(realname); char *tmp = do_browse_from(realname);
currshortcut = writefile_list;
currslen = WRITEFILE_LIST_LEN;
#ifdef DISABLE_TABCOMP #ifdef DISABLE_TABCOMP
realname = NULL; realname = NULL;
...@@ -503,6 +507,8 @@ int do_writeout(char *path, int exiting) ...@@ -503,6 +507,8 @@ int do_writeout(char *path, int exiting)
static int did_cred = 0; static int did_cred = 0;
#endif #endif
currshortcut = writefile_list;
currslen = WRITEFILE_LIST_LEN;
answer = mallocstrcpy(answer, path); answer = mallocstrcpy(answer, path);
if ((exiting) && (ISSET(TEMP_OPT))) { if ((exiting) && (ISSET(TEMP_OPT))) {
...@@ -529,6 +535,8 @@ int do_writeout(char *path, int exiting) ...@@ -529,6 +535,8 @@ int do_writeout(char *path, int exiting)
if (i == NANO_TOFILES_KEY) { if (i == NANO_TOFILES_KEY) {
char *tmp = do_browse_from(answer); char *tmp = do_browse_from(answer);
currshortcut = writefile_list;
currslen = WRITEFILE_LIST_LEN;
if (tmp != NULL) if (tmp != NULL)
answer = mallocstrcpy(answer, tmp); answer = mallocstrcpy(answer, tmp);
...@@ -1131,6 +1139,8 @@ char *do_browser(char *inpath) ...@@ -1131,6 +1139,8 @@ char *do_browser(char *inpath)
int lineno = 0, kb; int lineno = 0, kb;
char **filelist = (char **) NULL; char **filelist = (char **) NULL;
currshortcut = browser_list;
currslen = BROWSER_LIST_LEN;
/* If path isn't the same as inpath, we are being passed a new /* If path isn't the same as inpath, we are being passed a new
dir as an arg. We free it here so it will be copied from dir as an arg. We free it here so it will be copied from
inpath below */ inpath below */
...@@ -1172,6 +1182,14 @@ char *do_browser(char *inpath) ...@@ -1172,6 +1182,14 @@ char *do_browser(char *inpath)
lineno = selected / width; lineno = selected / width;
switch (kbinput) { switch (kbinput) {
#ifndef NANO_SMALL
#ifdef NCURSES_MOUSE_VERSION
case KEY_MOUSE:
do_mouse();
break;
#endif
#endif
case KEY_UP: case KEY_UP:
case 'u': case 'u':
if (selected - width >= 0) if (selected - width >= 0)
......
...@@ -82,6 +82,9 @@ shortcut spell_list[SPELL_LIST_LEN]; ...@@ -82,6 +82,9 @@ shortcut spell_list[SPELL_LIST_LEN];
shortcut browser_list[BROWSER_LIST_LEN]; shortcut browser_list[BROWSER_LIST_LEN];
#endif #endif
shortcut *currshortcut = main_list; /* Current shortcut list we're using */
int currslen = MAIN_VISIBLE; /* Length of current shortcut list */
#ifndef NANO_SMALL #ifndef NANO_SMALL
toggle toggles[TOGGLE_LEN]; toggle toggles[TOGGLE_LEN];
#endif #endif
......
...@@ -72,7 +72,7 @@ struct termios oldterm; /* The user's original term settings */ ...@@ -72,7 +72,7 @@ struct termios oldterm; /* The user's original term settings */
static struct sigaction act; /* For all out fun signal handlers */ static struct sigaction act; /* For all out fun signal handlers */
#ifndef DISABLE_HELP #ifndef DISABLE_HELP
static char *help_text_init = ""; /* Initial message, not including shortcuts */ static char *help_text_init = ""; /* Initial message, not including shortcuts */
#endif #endif
char *last_search = NULL; /* Last string we searched for */ char *last_search = NULL; /* Last string we searched for */
...@@ -93,7 +93,7 @@ RETSIGTYPE finish(int sigage) ...@@ -93,7 +93,7 @@ RETSIGTYPE finish(int sigage)
mvwaddstr(bottomwin, 2, 0, hblank); mvwaddstr(bottomwin, 2, 0, hblank);
} else } else
mvwaddstr(bottomwin, 0, 0, hblank); mvwaddstr(bottomwin, 0, 0, hblank);
wrefresh(bottomwin); wrefresh(bottomwin);
endwin(); endwin();
...@@ -120,7 +120,7 @@ void die(char *msg, ...) ...@@ -120,7 +120,7 @@ void die(char *msg, ...)
name = "nano.save"; name = "nano.save";
i = write_file(name, 1); i = write_file(name, 1);
} else { } else {
char *buf = nmalloc(strlen(filename) + 6); char *buf = nmalloc(strlen(filename) + 6);
strcpy(buf, filename); strcpy(buf, filename);
strcat(buf, ".save"); strcat(buf, ".save");
...@@ -254,7 +254,7 @@ void delete_node(filestruct * fileptr) ...@@ -254,7 +254,7 @@ void delete_node(filestruct * fileptr)
return; return;
if (fileptr->data != NULL) if (fileptr->data != NULL)
free(fileptr->data); free(fileptr->data);
free(fileptr); free(fileptr);
} }
...@@ -425,7 +425,8 @@ void usage(void) ...@@ -425,7 +425,8 @@ void usage(void)
#endif #endif
#endif #endif
printf(_(" -p Emulate Pico as closely as possible\n")); 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 #ifndef DISABLE_SPELLER
printf(_(" -s [prog] Enable alternate speller\n")); printf(_(" -s [prog] Enable alternate speller\n"));
#endif #endif
...@@ -456,21 +457,21 @@ void version(void) ...@@ -456,21 +457,21 @@ void version(void)
#ifdef NANO_SMALL #ifdef NANO_SMALL
printf(" --enable-tiny"); printf(" --enable-tiny");
#else #else
#ifdef DISABLE_BROWSER #ifdef DISABLE_BROWSER
printf(" --disable-browser"); printf(" --disable-browser");
#endif #endif
#ifdef DISABLE_TABCOMP #ifdef DISABLE_TABCOMP
printf(" --disable-tabcomp"); printf(" --disable-tabcomp");
#endif #endif
#ifdef DISABLE_JUSTIFY #ifdef DISABLE_JUSTIFY
printf(" --disable-justify"); printf(" --disable-justify");
#endif #endif
#ifdef DISABLE_SPELLER #ifdef DISABLE_SPELLER
printf(" --disable-speller"); printf(" --disable-speller");
#endif #endif
#ifdef DISABLE_HELP #ifdef DISABLE_HELP
printf(" --disable-help"); printf(" --disable-help");
#endif #endif
#endif #endif
#ifdef DISABLE_WRAPPING #ifdef DISABLE_WRAPPING
...@@ -500,7 +501,8 @@ filestruct *make_new_node(filestruct * prevnode) ...@@ -500,7 +501,8 @@ filestruct *make_new_node(filestruct * prevnode)
} }
/* Splice a node into an existing filestruct */ /* 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->next = end;
newnode->prev = begin; newnode->prev = begin;
...@@ -818,11 +820,11 @@ void do_wrap(filestruct * inptr, char input_char) ...@@ -818,11 +820,11 @@ void do_wrap(filestruct * inptr, char input_char)
current_x = 0; current_x = 0;
if (ISSET(AUTOINDENT)) { if (ISSET(AUTOINDENT)) {
int i = 0; int i = 0;
while ((inptr->next->data[i] == ' ' while ((inptr->next->data[i] == ' '
|| inptr->next->data[i] == '\t')) { || inptr->next->data[i] == '\t')) {
i++; i++;
right++; right++;
} }
} }
down = 1; down = 1;
} }
...@@ -871,11 +873,11 @@ void do_wrap(filestruct * inptr, char input_char) ...@@ -871,11 +873,11 @@ void do_wrap(filestruct * inptr, char input_char)
right = current_x - current_word_start; right = current_x - current_word_start;
if (ISSET(AUTOINDENT)) { if (ISSET(AUTOINDENT)) {
int i = 0; int i = 0;
while ((inptr->next->data[i] == ' ' while ((inptr->next->data[i] == ' '
|| inptr->next->data[i] == '\t')) { || inptr->next->data[i] == '\t')) {
i++; i++;
right++; right++;
} }
} }
i = current_word_start - 1; i = current_word_start - 1;
...@@ -922,25 +924,26 @@ void do_wrap(filestruct * inptr, char input_char) ...@@ -922,25 +924,26 @@ void do_wrap(filestruct * inptr, char input_char)
int old_x = current_x, old_y = current_y; int old_x = current_x, old_y = current_y;
/* Plus one for the space which concatenates the two lines together plus 1 for \0. */ /* 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) char *p =
* sizeof(char)); nmalloc((strlen(temp->data) + strlen(inptr->next->data) + 2)
* sizeof(char));
if (ISSET(AUTOINDENT)) { if (ISSET(AUTOINDENT)) {
int non = 0; int non = 0;
/* Grab the beginning of the next line until it's not a /* Grab the beginning of the next line until it's not a
space or tab, then null terminate it so we can strcat it space or tab, then null terminate it so we can strcat it
to hell */ to hell */
while ((inptr->next->data[non] == ' ' while ((inptr->next->data[non] == ' '
|| inptr->next->data[non] == '\t')) || inptr->next->data[non] == '\t'))
p[non] = inptr->next->data[non++]; p[non] = inptr->next->data[non++];
p[non] = 0; p[non] = 0;
strcat(p, temp->data); strcat(p, temp->data);
strcat(p, " "); strcat(p, " ");
/* Now tack on the rest of the next line after the spaces and /* Now tack on the rest of the next line after the spaces and
tabs */ tabs */
strcat(p, &inptr->next->data[non]); strcat(p, &inptr->next->data[non]);
} else { } else {
strcpy(p, temp->data); strcpy(p, temp->data);
...@@ -977,7 +980,7 @@ void do_wrap(filestruct * inptr, char input_char) ...@@ -977,7 +980,7 @@ void do_wrap(filestruct * inptr, char input_char)
char *t = NULL; char *t = NULL;
int extra = 0; int extra = 0;
if (spc) { if (spc) {
while ((*spc == ' ') || (*spc == '\t')) { while ((*spc == ' ') || (*spc == '\t')) {
extra++; extra++;
spc++; spc++;
totsize++; totsize++;
...@@ -996,7 +999,7 @@ void do_wrap(filestruct * inptr, char input_char) ...@@ -996,7 +999,7 @@ void do_wrap(filestruct * inptr, char input_char)
/* Everything about it makes me want this line here but it causes /* Everything about it makes me want this line here but it causes
* totsize to be high by one for some reason. Sigh. (Rob) */ * totsize to be high by one for some reason. Sigh. (Rob) */
/* totsize++; */ /* totsize++; */
renumber(inptr); renumber(inptr);
edit_update(edittop, TOP); edit_update(edittop, TOP);
...@@ -1054,7 +1057,7 @@ void check_wrap(filestruct * inptr, char ch) ...@@ -1054,7 +1057,7 @@ void check_wrap(filestruct * inptr, char ch)
do_wrap(inptr, ch); do_wrap(inptr, ch);
} }
} }
#endif /* DISABLE_WRAPPING */ #endif /* DISABLE_WRAPPING */
/* Stuff we do when we abort from programs and want to clean up the /* Stuff we do when we abort from programs and want to clean up the
* screen. This doesnt do much right now. * screen. This doesnt do much right now.
...@@ -1148,8 +1151,8 @@ int do_delete(void) ...@@ -1148,8 +1151,8 @@ int do_delete(void)
align(&current->data); align(&current->data);
/* Now that we have a magic lnie again, we can check for both being /* Now that we have a magic lnie again, we can check for both being
on the line before filebot as well as at filebot */ on the line before filebot as well as at filebot */
} else if (current->next != NULL && current->next != filebot) { } else if (current->next != NULL && current->next != filebot) {
current->data = nrealloc(current->data, current->data = nrealloc(current->data,
strlen(current->data) + strlen(current->data) +
...@@ -1221,13 +1224,12 @@ int do_int_spell_fix(char *word) ...@@ -1221,13 +1224,12 @@ int do_int_spell_fix(char *word)
edit_update(fileage, TOP); edit_update(fileage, TOP);
/* make sure word is still mis-spelt (i.e. when multi-errors) */ /* 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); do_replace_highlight(TRUE, prevanswer);
/* allow replace word to be corrected */ /* allow replace word to be corrected */
i = statusq(0, spell_list, SPELL_LIST_LEN, last_replace, i = statusq(0, spell_list, SPELL_LIST_LEN, last_replace,
_("Edit a replacement")); _("Edit a replacement"));
do_replace_highlight(FALSE, prevanswer); do_replace_highlight(FALSE, prevanswer);
...@@ -1274,7 +1276,7 @@ int do_int_speller(char *tempfile_name) ...@@ -1274,7 +1276,7 @@ int do_int_speller(char *tempfile_name)
/* A new process to run spell in */ /* A new process to run spell in */
if ( (pid_spell = fork()) == 0) { if ((pid_spell = fork()) == 0) {
/* Child continues, (i.e. future spell process) */ /* Child continues, (i.e. future spell process) */
...@@ -1282,7 +1284,7 @@ int do_int_speller(char *tempfile_name) ...@@ -1282,7 +1284,7 @@ int do_int_speller(char *tempfile_name)
/* replace the standard in with the tempfile */ /* 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]); close(in_fd[1]);
exit(1); exit(1);
...@@ -1328,17 +1330,17 @@ int do_int_speller(char *tempfile_name) ...@@ -1328,17 +1330,17 @@ int do_int_speller(char *tempfile_name)
/* Get system pipe buffer size */ /* 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]); close(in_fd[0]);
return FALSE; return FALSE;
} }
read_buff = nmalloc( pipe_buff_size + 1 ); read_buff = nmalloc(pipe_buff_size + 1);
/* Process the returned spelling errors */ /* 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[bytesread] = (char) NULL;
read_buff_word = read_buff_ptr = read_buff; read_buff_word = read_buff_ptr = read_buff;
...@@ -1351,14 +1353,14 @@ int do_int_speller(char *tempfile_name) ...@@ -1351,14 +1353,14 @@ int do_int_speller(char *tempfile_name)
if (*read_buff_ptr == '\n') { if (*read_buff_ptr == '\n') {
*read_buff_ptr = (char) NULL; *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]); close(in_fd[0]);
free(read_buff); free(read_buff);
replace_abort(); replace_abort();
return TRUE; return TRUE;
} }
read_buff_word = read_buff_ptr; read_buff_word = read_buff_ptr;
read_buff_word++; read_buff_word++;
} }
...@@ -1377,8 +1379,7 @@ int do_int_speller(char *tempfile_name) ...@@ -1377,8 +1379,7 @@ int do_int_speller(char *tempfile_name)
if (WIFEXITED(spell_status)) { if (WIFEXITED(spell_status)) {
if (WEXITSTATUS(spell_status) != 0) if (WEXITSTATUS(spell_status) != 0)
return FALSE; return FALSE;
} } else
else
return FALSE; return FALSE;
return TRUE; return TRUE;
...@@ -1410,7 +1411,7 @@ int do_alt_speller(char *file_name) ...@@ -1410,7 +1411,7 @@ int do_alt_speller(char *file_name)
spellargs[arglen - 2] = file_name; spellargs[arglen - 2] = file_name;
/* Start a new process for the alternate speller */ /* 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!?!? */ /* Start alternate spell program, we are using the PATH here!?!? */
execvp(spellargs[0], spellargs); execvp(spellargs[0], spellargs);
...@@ -1431,8 +1432,7 @@ int do_alt_speller(char *file_name) ...@@ -1431,8 +1432,7 @@ int do_alt_speller(char *file_name)
if (WIFEXITED(alt_spell_status)) { if (WIFEXITED(alt_spell_status)) {
if (WEXITSTATUS(alt_spell_status) != 0) if (WEXITSTATUS(alt_spell_status) != 0)
return FALSE; return FALSE;
} } else
else
return FALSE; return FALSE;
refresh(); refresh();
...@@ -1459,7 +1459,7 @@ int do_spell(void) ...@@ -1459,7 +1459,7 @@ int do_spell(void)
if ((temp = tempnam(0, "nano.")) == NULL) { if ((temp = tempnam(0, "nano.")) == NULL) {
statusbar(_("Could not create a temporary filename: %s"), statusbar(_("Could not create a temporary filename: %s"),
strerror(errno)); strerror(errno));
return 0; return 0;
} }
...@@ -1495,8 +1495,7 @@ int do_exit(void) ...@@ -1495,8 +1495,7 @@ int do_exit(void)
if (ISSET(TEMP_OPT)) { if (ISSET(TEMP_OPT)) {
i = 1; i = 1;
} else { } else {
i = i = do_yesno(0, 0,
do_yesno(0, 0,
_ _
("Save modified buffer (ANSWERING \"No\" WILL DESTROY CHANGES) ? ")); ("Save modified buffer (ANSWERING \"No\" WILL DESTROY CHANGES) ? "));
} }
...@@ -1527,66 +1526,87 @@ void do_mouse(void) ...@@ -1527,66 +1526,87 @@ void do_mouse(void)
if (getmouse(&mevent) == ERR) if (getmouse(&mevent) == ERR)
return; return;
/* If mouse not in edit window, return (add help selection later). */ /* If mouse not in edit or bottom window, return */
if (!wenclose(edit, mevent.y, mevent.x)) if (wenclose(edit, mevent.y, mevent.x)) {
return;
/* Subtract out size of topwin. Perhaps we need a constant somewhere? */
mevent.y -= 2;
/* Selecting where the cursor is sets the mark. /* Don't let people screw with the marker when they're in a
* Selecting beyond the line length with the cursor at the end of the subfunction */
* line sets the mark as well. if (currshortcut != main_list)
*/
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; 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(); current_x = mevent.x;
} else if (mevent.y > current_y) { placewewant = current_x;
while (mevent.y > current_y) { while (foo < current_x) {
if (current->next != NULL) if (current->data[foo] == NANO_CONTROL_I) {
current = current->next; current_x -= tabsize - (foo % tabsize);
else tab_found = 1;
break; } else if (current->data[foo] & 0x80);
current_y++; else if (current->data[foo] < 32)
} current_x--;
} else if (mevent.y < current_y) { foo++;
while (mevent.y < current_y) {
if (current->prev != NULL)
current = current->prev;
else
break;
current_y--;
} }
} /* This is where tab_found comes in. I can't figure out why,
current_x = mevent.x; * but without it any line with a tab will place the cursor
placewewant = current_x; * one character behind. Whatever, this fixes it. */
while (foo < current_x) { if (tab_found == 1)
if (current->data[foo] == NANO_CONTROL_I) { current_x++;
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++;
if (current_x > strlen(current->data)) if (current_x > strlen(current->data))
current_x = strlen(current->data); current_x = strlen(current->data);
update_cursor(); update_cursor();
edit_refresh(); 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
#endif #endif
...@@ -1750,6 +1770,7 @@ void mouse_init(void) ...@@ -1750,6 +1770,7 @@ void mouse_init(void)
#ifdef NCURSES_MOUSE_VERSION #ifdef NCURSES_MOUSE_VERSION
if (ISSET(USE_MOUSE)) { if (ISSET(USE_MOUSE)) {
keypad_on(edit, 1); keypad_on(edit, 1);
keypad_on(bottomwin, 1);
mousemask(BUTTON1_RELEASED, NULL); mousemask(BUTTON1_RELEASED, NULL);
mouseinterval(50); mouseinterval(50);
...@@ -1864,7 +1885,7 @@ int do_justify(void) ...@@ -1864,7 +1885,7 @@ int do_justify(void)
initial_y = current_y; initial_y = current_y;
set_modified(); set_modified();
cutbak = cutbuffer; /* Got to like cutbak ;) */ cutbak = cutbuffer; /* Got to like cutbak ;) */
totbak = totsize; totbak = totsize;
cutbuffer = NULL; cutbuffer = NULL;
...@@ -1886,7 +1907,7 @@ int do_justify(void) ...@@ -1886,7 +1907,7 @@ int do_justify(void)
add_to_cutbuffer(tmpjust); add_to_cutbuffer(tmpjust);
/* Wiping out a newline */ /* Wiping out a newline */
totsize--; totsize--;
/* length of both strings plus space between strings and ending \0. */ /* length of both strings plus space between strings and ending \0. */
current->data = nrealloc(current->data, len + len2 + 2); current->data = nrealloc(current->data, len + len2 + 2);
...@@ -1984,7 +2005,7 @@ int do_justify(void) ...@@ -1984,7 +2005,7 @@ int do_justify(void)
/* Now get a keystroke and see if it's unjustify, if not unget the keytroke /* Now get a keystroke and see if it's unjustify, if not unget the keytroke
and return */ and return */
if ((kbinput = wgetch(edit)) != NANO_UNJUSTIFY_KEY) { if ((kbinput = wgetch(edit)) != NANO_UNJUSTIFY_KEY) {
ungetch(kbinput); ungetch(kbinput);
blank_statusbar_refresh(); blank_statusbar_refresh();
} else { } else {
/* Else restore the justify we just did (ungrateful user!) */ /* Else restore the justify we just did (ungrateful user!) */
...@@ -1993,7 +2014,7 @@ int do_justify(void) ...@@ -1993,7 +2014,7 @@ int do_justify(void)
else else
fileage = current; fileage = current;
tmpbot->next->prev = tmptop->prev; tmpbot->next->prev = tmptop->prev;
current = tmpbot->next; current = tmpbot->next;
tmpbot->next = NULL; tmpbot->next = NULL;
do_uncut_text(); do_uncut_text();
if (tmptop->prev == NULL) if (tmptop->prev == NULL)
...@@ -2008,7 +2029,7 @@ int do_justify(void) ...@@ -2008,7 +2029,7 @@ int do_justify(void)
display_main_list(); display_main_list();
free_filestruct(cutbuffer); free_filestruct(cutbuffer);
cutbuffer = cutbak; cutbuffer = cutbak;
return 1; return 1;
#endif #endif
} }
...@@ -2141,7 +2162,8 @@ void print_numlock_warning(void) ...@@ -2141,7 +2162,8 @@ void print_numlock_warning(void)
{ {
static int didmsg = 0; static int didmsg = 0;
if (!didmsg) { if (!didmsg) {
statusbar(_("NumLock glitch detected. Keypad will malfunction with NumLock off")); statusbar(_
("NumLock glitch detected. Keypad will malfunction with NumLock off"));
didmsg = 1; didmsg = 1;
} }
} }
...@@ -2151,18 +2173,17 @@ void print_numlock_warning(void) ...@@ -2151,18 +2173,17 @@ void print_numlock_warning(void)
Esc-O-[A-D] or Esc-[-[A-D]. */ Esc-O-[A-D] or Esc-[-[A-D]. */
int ABCD(int input) int ABCD(int input)
{ {
switch(input) switch (input) {
{ case 'A':
case 'A': return (KEY_UP);
return(KEY_UP); case 'B':
case 'B': return (KEY_DOWN);
return(KEY_DOWN); case 'C':
case 'C': return (KEY_RIGHT);
return(KEY_RIGHT); case 'D':
case 'D': return (KEY_LEFT);
return(KEY_LEFT); default:
default: return 0;
return 0;
} }
} }
...@@ -2223,7 +2244,8 @@ int main(int argc, char *argv[]) ...@@ -2223,7 +2244,8 @@ int main(int argc, char *argv[])
while ((optchr = getopt_long(argc, argv, "?T:RVbcefhiklmpr:s:tvwxz", while ((optchr = getopt_long(argc, argv, "?T:RVbcefhiklmpr:s:tvwxz",
long_options, &option_index)) != EOF) { long_options, &option_index)) != EOF) {
#else #else
while ((optchr = getopt(argc, argv, "h?T:RVbcefiklmpr:s:tvwxz")) != EOF) { while ((optchr =
getopt(argc, argv, "h?T:RVbcefiklmpr:s:tvwxz")) != EOF) {
#endif #endif
switch (optchr) { switch (optchr) {
...@@ -2245,8 +2267,8 @@ int main(int argc, char *argv[]) ...@@ -2245,8 +2267,8 @@ int main(int argc, char *argv[])
case 'b': case 'b':
case 'e': case 'e':
case 'f': case 'f':
/* Pico compatibility flags */ /* Pico compatibility flags */
break; break;
case 'c': case 'c':
SET(CONSTUPDATE); SET(CONSTUPDATE);
break; break;
...@@ -2297,7 +2319,7 @@ int main(int argc, char *argv[]) ...@@ -2297,7 +2319,7 @@ int main(int argc, char *argv[])
#else #else
SET(NO_WRAP); SET(NO_WRAP);
break; break;
#endif /* DISABLE_WRAPPING */ #endif /* DISABLE_WRAPPING */
case 'x': case 'x':
SET(NO_HELP); SET(NO_HELP);
break; break;
...@@ -2394,7 +2416,7 @@ int main(int argc, char *argv[]) ...@@ -2394,7 +2416,7 @@ int main(int argc, char *argv[])
edit_update(fileage, CENTER); edit_update(fileage, CENTER);
/* return here after a sigwinch */ /* return here after a sigwinch */
sigsetjmp(jmpbuf,1); sigsetjmp(jmpbuf, 1);
/* Fix clobber-age */ /* Fix clobber-age */
kbinput = 0; kbinput = 0;
...@@ -2406,6 +2428,9 @@ int main(int argc, char *argv[]) ...@@ -2406,6 +2428,9 @@ int main(int argc, char *argv[])
while (1) { while (1) {
currshortcut = main_list;
currslen = MAIN_VISIBLE;
#ifndef _POSIX_VDISABLE #ifndef _POSIX_VDISABLE
/* We're going to have to do it the old way, i.e. on cygwin */ /* We're going to have to do it the old way, i.e. on cygwin */
raw(); raw();
...@@ -2421,7 +2446,7 @@ int main(int argc, char *argv[]) ...@@ -2421,7 +2446,7 @@ int main(int argc, char *argv[])
case 79: case 79:
kbinput = wgetch(edit); kbinput = wgetch(edit);
if (kbinput <= 'D' && kbinput >= 'A') if (kbinput <= 'D' && kbinput >= 'A')
kbinput = ABCD(kbinput); kbinput = ABCD(kbinput);
else if (kbinput <= 'z' && kbinput >= 'j') else if (kbinput <= 'z' && kbinput >= 'j')
print_numlock_warning(); print_numlock_warning();
else if (kbinput <= 'S' && kbinput >= 'P') else if (kbinput <= 'S' && kbinput >= 'P')
......
...@@ -36,6 +36,7 @@ extern int mark_beginx, samelinewrap; ...@@ -36,6 +36,7 @@ extern int mark_beginx, samelinewrap;
extern int totsize, temp_opt; extern int totsize, temp_opt;
extern int fill, flags,tabsize; extern int fill, flags,tabsize;
extern int search_last_line; extern int search_last_line;
extern int currslen;
extern WINDOW *edit, *topwin, *bottomwin; extern WINDOW *edit, *topwin, *bottomwin;
extern char *filename; extern char *filename;
...@@ -54,6 +55,7 @@ extern shortcut spell_list[SPELL_LIST_LEN], replace_list_2[REPLACE_LIST_LEN]; ...@@ -54,6 +55,7 @@ extern shortcut spell_list[SPELL_LIST_LEN], replace_list_2[REPLACE_LIST_LEN];
#ifndef DISABLE_BROWSER #ifndef DISABLE_BROWSER
extern shortcut browser_list[BROWSER_LIST_LEN]; extern shortcut browser_list[BROWSER_LIST_LEN];
#endif #endif
extern shortcut *currshortcut;
#ifdef HAVE_REGEX_H #ifdef HAVE_REGEX_H
extern int use_regexp, regexp_compiled; extern int use_regexp, regexp_compiled;
...@@ -140,6 +142,7 @@ void add_to_cutbuffer(filestruct * inptr); ...@@ -140,6 +142,7 @@ void add_to_cutbuffer(filestruct * inptr);
void do_replace_highlight(int highlight_flag, char *word); void do_replace_highlight(int highlight_flag, char *word);
void nano_disabled_msg(void); void nano_disabled_msg(void);
void window_init(void); void window_init(void);
void do_mouse(void);
#ifdef NANO_EXTRA #ifdef NANO_EXTRA
void do_credits(void); void do_credits(void);
#endif #endif
......
...@@ -262,6 +262,8 @@ int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen, ...@@ -262,6 +262,8 @@ int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen,
x_left = strlen(buf); x_left = strlen(buf);
x = strlen(def) + x_left; x = strlen(def) + x_left;
currshortcut = s;
currslen = slen;
/* Get the input! */ /* Get the input! */
if (strlen(def) > 0) if (strlen(def) > 0)
strcpy(inputbuf, def); strcpy(inputbuf, def);
...@@ -273,6 +275,10 @@ int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen, ...@@ -273,6 +275,10 @@ int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen,
while ((kbinput = wgetch(bottomwin)) != 13) { while ((kbinput = wgetch(bottomwin)) != 13) {
for (j = 0; j <= slen - 1; j++) { for (j = 0; j <= slen - 1; j++) {
#ifdef DEBUG
fprintf(stderr, _("Aha! \'%c\' (%d)\n"), kbinput, kbinput);
#endif
if (kbinput == s[j].val) { if (kbinput == s[j].val) {
/* We shouldn't discard the answer it gave, just because /* We shouldn't discard the answer it gave, just because
...@@ -288,7 +294,8 @@ int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen, ...@@ -288,7 +294,8 @@ int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen,
tabbed = 0; tabbed = 0;
switch (kbinput) { switch (kbinput) {
/* Stuff we want to equate with <enter>, ASCII 13 */
/* Stuff we want to equate with <enter>, ASCII 13 */
case 343: case 343:
ungetch(13); /* Enter on iris-ansi $TERM, sometimes */ ungetch(13); /* Enter on iris-ansi $TERM, sometimes */
break; break;
...@@ -299,8 +306,15 @@ int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen, ...@@ -299,8 +306,15 @@ int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen,
case 543: /* Right ctrl again */ case 543: /* Right ctrl again */
case 544: case 544:
case 545: /* Right alt again */ case 545: /* Right alt again */
break;
#endif
#ifndef NANO_SMALL
#ifdef NCURSES_MOUSE_VERSION
case KEY_MOUSE:
do_mouse();
break;
#endif
#endif #endif
break;
case KEY_HOME: case KEY_HOME:
x = x_left; x = x_left;
nanoget_repaint(buf, inputbuf, x); nanoget_repaint(buf, inputbuf, x);
...@@ -1217,14 +1231,17 @@ int do_help(void) ...@@ -1217,14 +1231,17 @@ int do_help(void)
{ {
#ifndef DISABLE_HELP #ifndef DISABLE_HELP
char *ptr = help_text, *end; char *ptr = help_text, *end;
int i, j, row = 0, page = 1, kbinput = 0, no_more = 0, kp; int i, j, row = 0, page = 1, kbinput = 0, no_more = 0, kp, kp2;
int no_help_flag = 0; int no_help_flag = 0;
blank_edit(); blank_edit();
curs_set(0); curs_set(0);
blank_statusbar(); blank_statusbar();
currshortcut = help_list;
currslen = HELP_LIST_LEN;
kp = keypad_on(edit, 1); kp = keypad_on(edit, 1);
kp2 = keypad_on(bottomwin, 1);
if (ISSET(NO_HELP)) { if (ISSET(NO_HELP)) {
...@@ -1241,6 +1258,13 @@ int do_help(void) ...@@ -1241,6 +1258,13 @@ int do_help(void)
do { do {
ptr = help_text; ptr = help_text;
switch (kbinput) { switch (kbinput) {
#ifndef NANO_SMALL
#ifdef NCURSES_MOUSE_VERSION
case KEY_MOUSE:
do_mouse();
break;
#endif
#endif
case NANO_NEXTPAGE_KEY: case NANO_NEXTPAGE_KEY:
case NANO_NEXTPAGE_FKEY: case NANO_NEXTPAGE_FKEY:
case KEY_NPAGE: case KEY_NPAGE:
...@@ -1320,6 +1344,7 @@ int do_help(void) ...@@ -1320,6 +1344,7 @@ int do_help(void)
curs_set(1); curs_set(1);
edit_refresh(); edit_refresh();
kp = keypad_on(edit, kp); kp = keypad_on(edit, kp);
kp2 = keypad_on(bottomwin, kp2);
#elif defined(DISABLE_HELP) #elif defined(DISABLE_HELP)
nano_disabled_msg(); nano_disabled_msg();
......
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