Commit c08f50d9 authored by Chris Allegretta's avatar Chris Allegretta
Browse files

Back to the drawing board, old keypad code, dont slightly better

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@452 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Showing with 191 additions and 119 deletions
+191 -119
...@@ -4,12 +4,12 @@ General - ...@@ -4,12 +4,12 @@ General -
helper functions browser_init(), tail(), striponedir(), helper functions browser_init(), tail(), striponedir(),
filestat(). New shortcut list browser_list. Some new filestat(). New shortcut list browser_list. Some new
strings to translate. Added function do_browse_from(). strings to translate. Added function do_browse_from().
- We only call keypad() once now for each window, at the beginning. - Keypad code has been changed slightly. Now checks for
FINALLY! No more keypad_on(), no more individual calls in _use_keypad flag in window to see whether or not to turn
main(), do_help(), do_browser(), etc etc etc. Removed call to the keypad() back off when finished (taken from aumix). Moved
timeout(0) in main() (which caused the whole mess), fixes BUG #49. to winio.c where it should probably be anyway. New confgure
Added workarounds for gnome-terminal in main() (Alt-O-key and check for _use_keypad in window sstruct. This will have to do
348-352). for now.
- faq.html: - faq.html:
- Fix typos and small mistakes (Jordi). - Fix typos and small mistakes (Jordi).
- files.c: - files.c:
......
...@@ -3,6 +3,9 @@ ...@@ -3,6 +3,9 @@
/* Define this if you have the wresize function in your ncurses-type library */ /* Define this if you have the wresize function in your ncurses-type library */
#undef HAVE_WRESIZE #undef HAVE_WRESIZE
/* Define this if your curses lib has the _use_keypad flag */
#undef HAVE_USEKEYPAD
/* Define this if you have NLS */ /* Define this if you have NLS */
#undef ENABLE_NLS #undef ENABLE_NLS
......
...@@ -55,6 +55,9 @@ ...@@ -55,6 +55,9 @@
/* Define this if you have the wresize function in your ncurses-type library */ /* Define this if you have the wresize function in your ncurses-type library */
#undef HAVE_WRESIZE #undef HAVE_WRESIZE
/* Define this if your curses lib has the _use_keypad flag */
#undef HAVE_USEKEYPAD
/* Define this if you have NLS */ /* Define this if you have NLS */
#undef ENABLE_NLS #undef ENABLE_NLS
......
This diff is collapsed.
...@@ -208,6 +208,20 @@ fi ...@@ -208,6 +208,20 @@ fi
AC_CHECK_LIB($CURSES_LIB_NAME, wresize, AC_DEFINE(HAVE_WRESIZE)) AC_CHECK_LIB($CURSES_LIB_NAME, wresize, AC_DEFINE(HAVE_WRESIZE))
# Taken from aumix (can't tell form the variable name?)
AC_CACHE_CHECK(for private member _use_keypad in WINDOW,
aumix_cv_struct_window_usekeypad,
[AC_TRY_COMPILE([#ifdef HAVE_NCURSES_H
#include <ncurses.h>
#else
#include <curses.h>
#endif], [WINDOW w; w._use_keypad;],
aumix_cv_struct_window_usekeypad=yes, aumix_cv_struct_window_usekeypad=no)])
if test $aumix_cv_struct_window_usekeypad = yes; then
AC_DEFINE(HAVE_USEKEYPAD)
fi
dnl Parse any configure options dnl Parse any configure options
LIBS="$LIBS $CURSES_LIB" LIBS="$LIBS $CURSES_LIB"
......
...@@ -1194,7 +1194,7 @@ char *do_browser(char *inpath) ...@@ -1194,7 +1194,7 @@ char *do_browser(char *inpath)
static char *path = NULL; static char *path = NULL;
int numents = 0, i = 0, j = 0, kbinput = 0, longest = 0, abort = 0; int numents = 0, i = 0, j = 0, kbinput = 0, longest = 0, abort = 0;
int col = 0, selected = 0, editline = 0, width = 0, filecols = 0; int col = 0, selected = 0, editline = 0, width = 0, filecols = 0;
int lineno = 0; int lineno = 0, kb;
char **filelist = (char **) NULL; char **filelist = (char **) NULL;
/* 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
...@@ -1215,6 +1215,7 @@ char *do_browser(char *inpath) ...@@ -1215,6 +1215,7 @@ char *do_browser(char *inpath)
/* Sort the list by directory first then alphabetically */ /* Sort the list by directory first then alphabetically */
qsort(filelist, numents, sizeof(char *), diralphasort); qsort(filelist, numents, sizeof(char *), diralphasort);
kb = keypad_on(edit, 1);
titlebar(path); titlebar(path);
bottombars(browser_list, BROWSER_LIST_LEN); bottombars(browser_list, BROWSER_LIST_LEN);
curs_set(0); curs_set(0);
...@@ -1395,6 +1396,7 @@ char *do_browser(char *inpath) ...@@ -1395,6 +1396,7 @@ char *do_browser(char *inpath)
blank_edit(); blank_edit();
titlebar(NULL); titlebar(NULL);
edit_refresh(); edit_refresh();
kb = keypad_on(edit, kb);
/* cleanup */ /* cleanup */
free_charptrarray(filelist, numents); free_charptrarray(filelist, numents);
......
...@@ -77,6 +77,10 @@ int search_last_line; /* Is this the last search line? */ ...@@ -77,6 +77,10 @@ int search_last_line; /* Is this the last search line? */
/* What we do when we're all set to exit */ /* What we do when we're all set to exit */
RETSIGTYPE finish(int sigage) RETSIGTYPE finish(int sigage)
{ {
keypad(edit, TRUE);
keypad(bottomwin, TRUE);
if (!ISSET(NO_HELP)) { if (!ISSET(NO_HELP)) {
mvwaddstr(bottomwin, 1, 0, hblank); mvwaddstr(bottomwin, 1, 0, hblank);
mvwaddstr(bottomwin, 2, 0, hblank); mvwaddstr(bottomwin, 2, 0, hblank);
...@@ -1640,9 +1644,6 @@ void window_init(void) ...@@ -1640,9 +1644,6 @@ void window_init(void)
topwin = newwin(2, COLS, 0, 0); topwin = newwin(2, COLS, 0, 0);
bottomwin = newwin(3 - no_help(), COLS, LINES - 3 + no_help(), 0); bottomwin = newwin(3 - no_help(), COLS, LINES - 3 + no_help(), 0);
/* HAHA! Only do this once! */
keypad(edit, TRUE);
keypad(bottomwin, TRUE);
} }
void mouse_init(void) void mouse_init(void)
...@@ -1650,6 +1651,8 @@ void mouse_init(void) ...@@ -1650,6 +1651,8 @@ void mouse_init(void)
#ifndef NANO_SMALL #ifndef NANO_SMALL
#ifdef NCURSES_MOUSE_VERSION #ifdef NCURSES_MOUSE_VERSION
if (ISSET(USE_MOUSE)) { if (ISSET(USE_MOUSE)) {
keypad_on(edit, 1);
mousemask(BUTTON1_RELEASED, NULL); mousemask(BUTTON1_RELEASED, NULL);
mouseinterval(50); mouseinterval(50);
...@@ -2258,6 +2261,9 @@ int main(int argc, char *argv[]) ...@@ -2258,6 +2261,9 @@ int main(int argc, char *argv[])
#endif #endif
kbinput = wgetch(edit); kbinput = wgetch(edit);
#ifdef DEBUG
fprintf(stderr, "AHA! %c (%d)\n", kbinput, kbinput);
#endif
if (kbinput == 27) { /* Grab Alt-key stuff first */ if (kbinput == 27) { /* Grab Alt-key stuff first */
switch (kbinput = wgetch(edit)) { switch (kbinput = wgetch(edit)) {
/* Alt-O, suddenly very important ;) */ /* Alt-O, suddenly very important ;) */
...@@ -2265,8 +2271,6 @@ int main(int argc, char *argv[]) ...@@ -2265,8 +2271,6 @@ int main(int argc, char *argv[])
kbinput = wgetch(edit); kbinput = wgetch(edit);
if (kbinput <= 'S' && kbinput >= 'P') if (kbinput <= 'S' && kbinput >= 'P')
kbinput = KEY_F(kbinput - 79); kbinput = KEY_F(kbinput - 79);
else if (kbinput >= 'j' && kbinput <= 'y')
kbinput = kbinput - 64;
#ifdef DEBUG #ifdef DEBUG
else { else {
fprintf(stderr, _("I got Alt-O-%c! (%d)\n"), fprintf(stderr, _("I got Alt-O-%c! (%d)\n"),
...@@ -2461,23 +2465,6 @@ int main(int argc, char *argv[]) ...@@ -2461,23 +2465,6 @@ int main(int argc, char *argv[])
do_next_word(); do_next_word();
break; break;
/* Stupid gnome-terminal keypad */
case 349:
ungetch('5');
break;
case 348:
ungetch('7');
break;
case 350:
ungetch('9');
break;
case 351:
ungetch('1');
break;
case 352:
ungetch('3');
break;
case 331: /* Stuff that we don't want to do squat */ case 331: /* Stuff that we don't want to do squat */
case -1: case -1:
case 410: /* Must ignore this, it gets sent when we resize */ case 410: /* Must ignore this, it gets sent when we resize */
......
...@@ -151,6 +151,7 @@ int do_home(void), do_end(void), total_refresh(void), do_mark(void); ...@@ -151,6 +151,7 @@ int do_home(void), do_end(void), total_refresh(void), do_mark(void);
int do_delete(void), do_backspace(void), do_tab(void), do_justify(void); int do_delete(void), do_backspace(void), do_tab(void), do_justify(void);
int do_first_line(void), do_last_line(void); int do_first_line(void), do_last_line(void);
int do_replace(void), do_help(void), do_enter_void(void); int do_replace(void), do_help(void), do_enter_void(void);
int keypad_on(WINDOW * win, int new);
#if !defined(DISABLE_BROWSER) && !defined(NANO_SMALL) #if !defined(DISABLE_BROWSER) && !defined(NANO_SMALL)
char *do_browser(char *path); char *do_browser(char *path);
...@@ -158,6 +159,7 @@ struct stat filestat(const char *path); ...@@ -158,6 +159,7 @@ struct stat filestat(const char *path);
char *do_browse_from(char *inpath); char *do_browse_from(char *inpath);
#endif #endif
filestruct *copy_node(filestruct * src); filestruct *copy_node(filestruct * src);
filestruct *copy_filestruct(filestruct * src); filestruct *copy_filestruct(filestruct * src);
filestruct *make_new_node(filestruct * prevnode); filestruct *make_new_node(filestruct * prevnode);
......
...@@ -1180,19 +1180,20 @@ int do_help(void) ...@@ -1180,19 +1180,20 @@ int do_help(void)
{ {
#if !defined(NANO_SMALL) && !defined(DISABLE_HELP) #if !defined(NANO_SMALL) && !defined(DISABLE_HELP)
char *ptr = help_text, *end; char *ptr = help_text, *end;
int i, j, row = 0, page = 1, kbinput = 0, no_more = 0; int i, j, row = 0, page = 1, kbinput = 0, no_more = 0, kp;
int no_help_flag = 0; int no_help_flag = 0;
blank_edit(); blank_edit();
curs_set(0); curs_set(0);
blank_statusbar(); blank_statusbar();
kp = keypad_on(edit, 1);
if (ISSET(NO_HELP)) { if (ISSET(NO_HELP)) {
no_help_flag = 1; no_help_flag = 1;
delwin(bottomwin); delwin(bottomwin);
bottomwin = newwin(3, COLS, LINES - 3, 0); bottomwin = newwin(3, COLS, LINES - 3, 0);
keypad(bottomwin, TRUE);
editwinrows -= no_help(); editwinrows -= no_help();
UNSET(NO_HELP); UNSET(NO_HELP);
...@@ -1277,13 +1278,14 @@ int do_help(void) ...@@ -1277,13 +1278,14 @@ int do_help(void)
delwin(bottomwin); delwin(bottomwin);
SET(NO_HELP); SET(NO_HELP);
bottomwin = newwin(3 - no_help(), COLS, LINES - 3 + no_help(), 0); bottomwin = newwin(3 - no_help(), COLS, LINES - 3 + no_help(), 0);
keypad(bottomwin, TRUE);
editwinrows += no_help(); editwinrows += no_help();
} else } else
display_main_list(); display_main_list();
curs_set(1); curs_set(1);
edit_refresh(); edit_refresh();
kp = keypad_on(edit, kp);
#elif defined(NANO_SMALL) #elif defined(NANO_SMALL)
nano_small_msg(); nano_small_msg();
#elif defined(DISABLE_HELP) #elif defined(DISABLE_HELP)
...@@ -1470,3 +1472,23 @@ void do_credits(void) ...@@ -1470,3 +1472,23 @@ void do_credits(void)
total_refresh(); total_refresh();
} }
#endif #endif
int keypad_on(WINDOW * win, int new)
{
/* This is taken right from aumix. Don't sue me */
#ifdef HAVE_USEKEYPAD
int old;
old = win->_use_keypad;
keypad(win, new);
return old;
#else
keypad(win, new);
return 1;
#endif /* HAVE_USEKEYPAD */
}
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