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
No related merge requests found
Showing with 191 additions and 119 deletions
+191 -119
......@@ -4,12 +4,12 @@ General -
helper functions browser_init(), tail(), striponedir(),
filestat(). New shortcut list browser_list. Some new
strings to translate. Added function do_browse_from().
- We only call keypad() once now for each window, at the beginning.
FINALLY! No more keypad_on(), no more individual calls in
main(), do_help(), do_browser(), etc etc etc. Removed call to
timeout(0) in main() (which caused the whole mess), fixes BUG #49.
Added workarounds for gnome-terminal in main() (Alt-O-key and
348-352).
- Keypad code has been changed slightly. Now checks for
_use_keypad flag in window to see whether or not to turn
the keypad() back off when finished (taken from aumix). Moved
to winio.c where it should probably be anyway. New confgure
check for _use_keypad in window sstruct. This will have to do
for now.
- faq.html:
- Fix typos and small mistakes (Jordi).
- files.c:
......
......@@ -3,6 +3,9 @@
/* Define this if you have the wresize function in your ncurses-type library */
#undef HAVE_WRESIZE
/* Define this if your curses lib has the _use_keypad flag */
#undef HAVE_USEKEYPAD
/* Define this if you have NLS */
#undef ENABLE_NLS
......
......@@ -55,6 +55,9 @@
/* Define this if you have the wresize function in your ncurses-type library */
#undef HAVE_WRESIZE
/* Define this if your curses lib has the _use_keypad flag */
#undef HAVE_USEKEYPAD
/* Define this if you have NLS */
#undef ENABLE_NLS
......
This diff is collapsed.
......@@ -208,6 +208,20 @@ fi
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
LIBS="$LIBS $CURSES_LIB"
......
......@@ -1194,7 +1194,7 @@ char *do_browser(char *inpath)
static char *path = NULL;
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 lineno = 0;
int lineno = 0, kb;
char **filelist = (char **) NULL;
/* If path isn't the same as inpath, we are being passed a new
......@@ -1215,6 +1215,7 @@ char *do_browser(char *inpath)
/* Sort the list by directory first then alphabetically */
qsort(filelist, numents, sizeof(char *), diralphasort);
kb = keypad_on(edit, 1);
titlebar(path);
bottombars(browser_list, BROWSER_LIST_LEN);
curs_set(0);
......@@ -1395,6 +1396,7 @@ char *do_browser(char *inpath)
blank_edit();
titlebar(NULL);
edit_refresh();
kb = keypad_on(edit, kb);
/* cleanup */
free_charptrarray(filelist, numents);
......
......@@ -77,6 +77,10 @@ int search_last_line; /* Is this the last search line? */
/* What we do when we're all set to exit */
RETSIGTYPE finish(int sigage)
{
keypad(edit, TRUE);
keypad(bottomwin, TRUE);
if (!ISSET(NO_HELP)) {
mvwaddstr(bottomwin, 1, 0, hblank);
mvwaddstr(bottomwin, 2, 0, hblank);
......@@ -1640,9 +1644,6 @@ void window_init(void)
topwin = newwin(2, COLS, 0, 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)
......@@ -1650,6 +1651,8 @@ void mouse_init(void)
#ifndef NANO_SMALL
#ifdef NCURSES_MOUSE_VERSION
if (ISSET(USE_MOUSE)) {
keypad_on(edit, 1);
mousemask(BUTTON1_RELEASED, NULL);
mouseinterval(50);
......@@ -2258,6 +2261,9 @@ int main(int argc, char *argv[])
#endif
kbinput = wgetch(edit);
#ifdef DEBUG
fprintf(stderr, "AHA! %c (%d)\n", kbinput, kbinput);
#endif
if (kbinput == 27) { /* Grab Alt-key stuff first */
switch (kbinput = wgetch(edit)) {
/* Alt-O, suddenly very important ;) */
......@@ -2265,8 +2271,6 @@ int main(int argc, char *argv[])
kbinput = wgetch(edit);
if (kbinput <= 'S' && kbinput >= 'P')
kbinput = KEY_F(kbinput - 79);
else if (kbinput >= 'j' && kbinput <= 'y')
kbinput = kbinput - 64;
#ifdef DEBUG
else {
fprintf(stderr, _("I got Alt-O-%c! (%d)\n"),
......@@ -2461,23 +2465,6 @@ int main(int argc, char *argv[])
do_next_word();
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 -1:
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);
int do_delete(void), do_backspace(void), do_tab(void), do_justify(void);
int do_first_line(void), do_last_line(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)
char *do_browser(char *path);
......@@ -158,6 +159,7 @@ struct stat filestat(const char *path);
char *do_browse_from(char *inpath);
#endif
filestruct *copy_node(filestruct * src);
filestruct *copy_filestruct(filestruct * src);
filestruct *make_new_node(filestruct * prevnode);
......
......@@ -1180,19 +1180,20 @@ int do_help(void)
{
#if !defined(NANO_SMALL) && !defined(DISABLE_HELP)
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;
blank_edit();
curs_set(0);
blank_statusbar();
kp = keypad_on(edit, 1);
if (ISSET(NO_HELP)) {
no_help_flag = 1;
delwin(bottomwin);
bottomwin = newwin(3, COLS, LINES - 3, 0);
keypad(bottomwin, TRUE);
editwinrows -= no_help();
UNSET(NO_HELP);
......@@ -1277,13 +1278,14 @@ int do_help(void)
delwin(bottomwin);
SET(NO_HELP);
bottomwin = newwin(3 - no_help(), COLS, LINES - 3 + no_help(), 0);
keypad(bottomwin, TRUE);
editwinrows += no_help();
} else
display_main_list();
curs_set(1);
edit_refresh();
kp = keypad_on(edit, kp);
#elif defined(NANO_SMALL)
nano_small_msg();
#elif defined(DISABLE_HELP)
......@@ -1470,3 +1472,23 @@ void do_credits(void)
total_refresh();
}
#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