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
Этот коммит содержится в:
родитель
ac840eb42b
Коммит
6b58acd377
@ -1,4 +1,8 @@
|
||||
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
|
||||
|
||||
|
18
files.c
18
files.c
@ -258,6 +258,8 @@ int do_insertfile(void)
|
||||
char *realname = NULL;
|
||||
|
||||
wrap_reset();
|
||||
currshortcut = writefile_list;
|
||||
currslen = WRITEFILE_LIST_LEN;
|
||||
i = statusq(1, writefile_list, WRITEFILE_LIST_LEN, "",
|
||||
_("File to insert [from ./] "));
|
||||
if (i != -1) {
|
||||
@ -276,6 +278,8 @@ int do_insertfile(void)
|
||||
if (i == NANO_TOFILES_KEY) {
|
||||
|
||||
char *tmp = do_browse_from(realname);
|
||||
currshortcut = writefile_list;
|
||||
currslen = WRITEFILE_LIST_LEN;
|
||||
|
||||
#ifdef DISABLE_TABCOMP
|
||||
realname = NULL;
|
||||
@ -503,6 +507,8 @@ int do_writeout(char *path, int exiting)
|
||||
static int did_cred = 0;
|
||||
#endif
|
||||
|
||||
currshortcut = writefile_list;
|
||||
currslen = WRITEFILE_LIST_LEN;
|
||||
answer = mallocstrcpy(answer, path);
|
||||
|
||||
if ((exiting) && (ISSET(TEMP_OPT))) {
|
||||
@ -529,6 +535,8 @@ int do_writeout(char *path, int exiting)
|
||||
if (i == NANO_TOFILES_KEY) {
|
||||
|
||||
char *tmp = do_browse_from(answer);
|
||||
currshortcut = writefile_list;
|
||||
currslen = WRITEFILE_LIST_LEN;
|
||||
|
||||
if (tmp != NULL)
|
||||
answer = mallocstrcpy(answer, tmp);
|
||||
@ -1131,6 +1139,8 @@ char *do_browser(char *inpath)
|
||||
int lineno = 0, kb;
|
||||
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
|
||||
dir as an arg. We free it here so it will be copied from
|
||||
inpath below */
|
||||
@ -1172,6 +1182,14 @@ char *do_browser(char *inpath)
|
||||
lineno = selected / width;
|
||||
|
||||
switch (kbinput) {
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
#ifdef NCURSES_MOUSE_VERSION
|
||||
case KEY_MOUSE:
|
||||
do_mouse();
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
case KEY_UP:
|
||||
case 'u':
|
||||
if (selected - width >= 0)
|
||||
|
3
global.c
3
global.c
@ -82,6 +82,9 @@ shortcut spell_list[SPELL_LIST_LEN];
|
||||
shortcut browser_list[BROWSER_LIST_LEN];
|
||||
#endif
|
||||
|
||||
shortcut *currshortcut = main_list; /* Current shortcut list we're using */
|
||||
int currslen = MAIN_VISIBLE; /* Length of current shortcut list */
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
toggle toggles[TOGGLE_LEN];
|
||||
#endif
|
||||
|
295
nano.c
295
nano.c
@ -72,7 +72,7 @@ struct termios oldterm; /* The user's original term settings */
|
||||
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 */
|
||||
@ -93,7 +93,7 @@ RETSIGTYPE finish(int sigage)
|
||||
mvwaddstr(bottomwin, 2, 0, hblank);
|
||||
} else
|
||||
mvwaddstr(bottomwin, 0, 0, hblank);
|
||||
|
||||
|
||||
wrefresh(bottomwin);
|
||||
endwin();
|
||||
|
||||
@ -120,7 +120,7 @@ void die(char *msg, ...)
|
||||
name = "nano.save";
|
||||
i = write_file(name, 1);
|
||||
} else {
|
||||
|
||||
|
||||
char *buf = nmalloc(strlen(filename) + 6);
|
||||
strcpy(buf, filename);
|
||||
strcat(buf, ".save");
|
||||
@ -254,7 +254,7 @@ void delete_node(filestruct * fileptr)
|
||||
return;
|
||||
|
||||
if (fileptr->data != NULL)
|
||||
free(fileptr->data);
|
||||
free(fileptr->data);
|
||||
free(fileptr);
|
||||
}
|
||||
|
||||
@ -425,7 +425,8 @@ void usage(void)
|
||||
#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
|
||||
@ -456,21 +457,21 @@ void version(void)
|
||||
#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
|
||||
@ -500,7 +501,8 @@ filestruct *make_new_node(filestruct * prevnode)
|
||||
}
|
||||
|
||||
/* 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;
|
||||
@ -818,11 +820,11 @@ void do_wrap(filestruct * inptr, char input_char)
|
||||
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;
|
||||
}
|
||||
@ -871,11 +873,11 @@ void do_wrap(filestruct * inptr, char input_char)
|
||||
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;
|
||||
@ -922,25 +924,26 @@ void do_wrap(filestruct * inptr, char input_char)
|
||||
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);
|
||||
@ -977,7 +980,7 @@ void do_wrap(filestruct * inptr, char input_char)
|
||||
char *t = NULL;
|
||||
int extra = 0;
|
||||
if (spc) {
|
||||
while ((*spc == ' ') || (*spc == '\t')) {
|
||||
while ((*spc == ' ') || (*spc == '\t')) {
|
||||
extra++;
|
||||
spc++;
|
||||
totsize++;
|
||||
@ -996,7 +999,7 @@ void do_wrap(filestruct * inptr, char input_char)
|
||||
/* 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);
|
||||
|
||||
@ -1054,7 +1057,7 @@ void check_wrap(filestruct * inptr, char 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
|
||||
* screen. This doesnt do much right now.
|
||||
@ -1148,8 +1151,8 @@ int do_delete(void)
|
||||
|
||||
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) +
|
||||
@ -1221,13 +1224,12 @@ int do_int_spell_fix(char *word)
|
||||
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);
|
||||
|
||||
@ -1274,7 +1276,7 @@ int do_int_speller(char *tempfile_name)
|
||||
|
||||
/* A new process to run spell in */
|
||||
|
||||
if ( (pid_spell = fork()) == 0) {
|
||||
if ((pid_spell = fork()) == 0) {
|
||||
|
||||
/* Child continues, (i.e. future spell process) */
|
||||
|
||||
@ -1282,7 +1284,7 @@ int do_int_speller(char *tempfile_name)
|
||||
|
||||
/* 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);
|
||||
@ -1328,17 +1330,17 @@ int do_int_speller(char *tempfile_name)
|
||||
|
||||
/* 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;
|
||||
@ -1351,14 +1353,14 @@ int do_int_speller(char *tempfile_name)
|
||||
|
||||
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++;
|
||||
}
|
||||
@ -1377,8 +1379,7 @@ int do_int_speller(char *tempfile_name)
|
||||
if (WIFEXITED(spell_status)) {
|
||||
if (WEXITSTATUS(spell_status) != 0)
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
} else
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
@ -1410,7 +1411,7 @@ int do_alt_speller(char *file_name)
|
||||
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);
|
||||
@ -1431,8 +1432,7 @@ int do_alt_speller(char *file_name)
|
||||
if (WIFEXITED(alt_spell_status)) {
|
||||
if (WEXITSTATUS(alt_spell_status) != 0)
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
} else
|
||||
return FALSE;
|
||||
|
||||
refresh();
|
||||
@ -1459,7 +1459,7 @@ int do_spell(void)
|
||||
|
||||
if ((temp = tempnam(0, "nano.")) == NULL) {
|
||||
statusbar(_("Could not create a temporary filename: %s"),
|
||||
strerror(errno));
|
||||
strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1495,8 +1495,7 @@ int do_exit(void)
|
||||
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) ? "));
|
||||
}
|
||||
@ -1527,66 +1526,87 @@ void do_mouse(void)
|
||||
if (getmouse(&mevent) == ERR)
|
||||
return;
|
||||
|
||||
/* If mouse not in edit window, return (add help selection later). */
|
||||
if (!wenclose(edit, mevent.y, mevent.x))
|
||||
return;
|
||||
/* If mouse not in edit or bottom window, return */
|
||||
if (wenclose(edit, mevent.y, mevent.x)) {
|
||||
|
||||
/* 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();
|
||||
/* 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++;
|
||||
}
|
||||
/* 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);
|
||||
|
||||
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);
|
||||
}
|
||||
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++;
|
||||
|
||||
if (current_x > strlen(current->data))
|
||||
current_x = strlen(current->data);
|
||||
|
||||
update_cursor();
|
||||
edit_refresh();
|
||||
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@ -1750,6 +1770,7 @@ void mouse_init(void)
|
||||
#ifdef NCURSES_MOUSE_VERSION
|
||||
if (ISSET(USE_MOUSE)) {
|
||||
keypad_on(edit, 1);
|
||||
keypad_on(bottomwin, 1);
|
||||
|
||||
mousemask(BUTTON1_RELEASED, NULL);
|
||||
mouseinterval(50);
|
||||
@ -1864,7 +1885,7 @@ int do_justify(void)
|
||||
initial_y = current_y;
|
||||
|
||||
set_modified();
|
||||
cutbak = cutbuffer; /* Got to like cutbak ;) */
|
||||
cutbak = cutbuffer; /* Got to like cutbak ;) */
|
||||
totbak = totsize;
|
||||
cutbuffer = NULL;
|
||||
|
||||
@ -1886,7 +1907,7 @@ int do_justify(void)
|
||||
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);
|
||||
@ -1984,7 +2005,7 @@ int do_justify(void)
|
||||
/* 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!) */
|
||||
@ -1993,7 +2014,7 @@ int do_justify(void)
|
||||
else
|
||||
fileage = current;
|
||||
tmpbot->next->prev = tmptop->prev;
|
||||
current = tmpbot->next;
|
||||
current = tmpbot->next;
|
||||
tmpbot->next = NULL;
|
||||
do_uncut_text();
|
||||
if (tmptop->prev == NULL)
|
||||
@ -2008,7 +2029,7 @@ int do_justify(void)
|
||||
display_main_list();
|
||||
free_filestruct(cutbuffer);
|
||||
cutbuffer = cutbak;
|
||||
|
||||
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
@ -2141,7 +2162,8 @@ void print_numlock_warning(void)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -2151,18 +2173,17 @@ void print_numlock_warning(void)
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2223,7 +2244,8 @@ int main(int argc, char *argv[])
|
||||
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) {
|
||||
@ -2245,8 +2267,8 @@ int main(int argc, char *argv[])
|
||||
case 'b':
|
||||
case 'e':
|
||||
case 'f':
|
||||
/* Pico compatibility flags */
|
||||
break;
|
||||
/* Pico compatibility flags */
|
||||
break;
|
||||
case 'c':
|
||||
SET(CONSTUPDATE);
|
||||
break;
|
||||
@ -2297,7 +2319,7 @@ int main(int argc, char *argv[])
|
||||
#else
|
||||
SET(NO_WRAP);
|
||||
break;
|
||||
#endif /* DISABLE_WRAPPING */
|
||||
#endif /* DISABLE_WRAPPING */
|
||||
case 'x':
|
||||
SET(NO_HELP);
|
||||
break;
|
||||
@ -2394,7 +2416,7 @@ int main(int argc, char *argv[])
|
||||
edit_update(fileage, CENTER);
|
||||
|
||||
/* return here after a sigwinch */
|
||||
sigsetjmp(jmpbuf,1);
|
||||
sigsetjmp(jmpbuf, 1);
|
||||
|
||||
/* Fix clobber-age */
|
||||
kbinput = 0;
|
||||
@ -2406,6 +2428,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
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();
|
||||
@ -2421,7 +2446,7 @@ int main(int argc, char *argv[])
|
||||
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')
|
||||
|
3
proto.h
3
proto.h
@ -36,6 +36,7 @@ extern int mark_beginx, samelinewrap;
|
||||
extern int totsize, temp_opt;
|
||||
extern int fill, flags,tabsize;
|
||||
extern int search_last_line;
|
||||
extern int currslen;
|
||||
|
||||
extern WINDOW *edit, *topwin, *bottomwin;
|
||||
extern char *filename;
|
||||
@ -54,6 +55,7 @@ extern shortcut spell_list[SPELL_LIST_LEN], replace_list_2[REPLACE_LIST_LEN];
|
||||
#ifndef DISABLE_BROWSER
|
||||
extern shortcut browser_list[BROWSER_LIST_LEN];
|
||||
#endif
|
||||
extern shortcut *currshortcut;
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
extern int use_regexp, regexp_compiled;
|
||||
@ -140,6 +142,7 @@ void add_to_cutbuffer(filestruct * inptr);
|
||||
void do_replace_highlight(int highlight_flag, char *word);
|
||||
void nano_disabled_msg(void);
|
||||
void window_init(void);
|
||||
void do_mouse(void);
|
||||
#ifdef NANO_EXTRA
|
||||
void do_credits(void);
|
||||
#endif
|
||||
|
31
winio.c
31
winio.c
@ -262,6 +262,8 @@ int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen,
|
||||
x_left = strlen(buf);
|
||||
x = strlen(def) + x_left;
|
||||
|
||||
currshortcut = s;
|
||||
currslen = slen;
|
||||
/* Get the input! */
|
||||
if (strlen(def) > 0)
|
||||
strcpy(inputbuf, def);
|
||||
@ -273,6 +275,10 @@ int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen,
|
||||
|
||||
while ((kbinput = wgetch(bottomwin)) != 13) {
|
||||
for (j = 0; j <= slen - 1; j++) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, _("Aha! \'%c\' (%d)\n"), kbinput, kbinput);
|
||||
#endif
|
||||
|
||||
if (kbinput == s[j].val) {
|
||||
|
||||
/* 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,
|
||||
tabbed = 0;
|
||||
|
||||
switch (kbinput) {
|
||||
/* Stuff we want to equate with <enter>, ASCII 13 */
|
||||
|
||||
/* Stuff we want to equate with <enter>, ASCII 13 */
|
||||
case 343:
|
||||
ungetch(13); /* Enter on iris-ansi $TERM, sometimes */
|
||||
break;
|
||||
@ -299,8 +306,15 @@ int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen,
|
||||
case 543: /* Right ctrl again */
|
||||
case 544:
|
||||
case 545: /* Right alt again */
|
||||
break;
|
||||
#endif
|
||||
#ifndef NANO_SMALL
|
||||
#ifdef NCURSES_MOUSE_VERSION
|
||||
case KEY_MOUSE:
|
||||
do_mouse();
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
break;
|
||||
case KEY_HOME:
|
||||
x = x_left;
|
||||
nanoget_repaint(buf, inputbuf, x);
|
||||
@ -1217,14 +1231,17 @@ int do_help(void)
|
||||
{
|
||||
#ifndef DISABLE_HELP
|
||||
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;
|
||||
|
||||
blank_edit();
|
||||
curs_set(0);
|
||||
blank_statusbar();
|
||||
|
||||
currshortcut = help_list;
|
||||
currslen = HELP_LIST_LEN;
|
||||
kp = keypad_on(edit, 1);
|
||||
kp2 = keypad_on(bottomwin, 1);
|
||||
|
||||
if (ISSET(NO_HELP)) {
|
||||
|
||||
@ -1241,6 +1258,13 @@ int do_help(void)
|
||||
do {
|
||||
ptr = help_text;
|
||||
switch (kbinput) {
|
||||
#ifndef NANO_SMALL
|
||||
#ifdef NCURSES_MOUSE_VERSION
|
||||
case KEY_MOUSE:
|
||||
do_mouse();
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
case NANO_NEXTPAGE_KEY:
|
||||
case NANO_NEXTPAGE_FKEY:
|
||||
case KEY_NPAGE:
|
||||
@ -1320,6 +1344,7 @@ int do_help(void)
|
||||
curs_set(1);
|
||||
edit_refresh();
|
||||
kp = keypad_on(edit, kp);
|
||||
kp2 = keypad_on(bottomwin, kp2);
|
||||
|
||||
#elif defined(DISABLE_HELP)
|
||||
nano_disabled_msg();
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user