Hello all, While browsing MC's help, I've noticed a strange behaviour of <up> arrow key. After I visit some topic and return back (using <right> arrow key), the behaviour of <up> arrow key weirdly changes: instead of selecting the previous link, it jumps to the top of the window!
Here is a detailed description how to reproduce it: 1) Open the Help Contents (press <F1>, <Tab>, <Enter>) 2) Navigate some lines forward (press <End> or <PageDown> several times) 3) Enter the selected topic (press <Enter>) 4) Return back (press <right arrow>) 5) Move to the top of Contents (press <Home>) 6) Now try navigating the Contents using the <up> and <down> arrow keys. (for example, press <down arrow> for 5 times, then press <up arrow>). You will notice that when you press <up arrow> key the selection jumps to the top of window. The problem is in the help_handle_key() function: case KEY_UP: case ALT ('\t'): /* select previous link */ new_item = select_prev_link (startpoint, selected_item); The 'startpoint' variable should be a pointer to the first byte displayed in the Help window. But here it has a wrong value - that's the problem. That's why select_prev_link() cannot find the link and returns NULL, and the selection moves to the first link in the window. I tried to find out what's wrong with the 'startpoint' variable. I came to the conclusion that 'startpoint' is used here erroneously instead of 'currentpoint' variable. 'currentpoint' always contains a pointer to the first byte displayed, and it should be used here. And by the way, 'startpoint' variable seems to be totally useless. So in my patch I replaced 'startpoint' with 'currentpoint' and removed the 'startpoint' variable completely. Regards, Grigory Trenin
--- help.c.orig 2006-11-29 18:06:27.000000000 +0300 +++ help.c 2006-11-29 18:09:20.000000000 +0300 @@ -72,7 +72,7 @@ static const char *main_node; /* The main node */ static const char *last_shown = NULL; /* Last byte shown in a screen */ static int end_of_node = 0; /* Flag: the last character of the node shown? */ -static const char *currentpoint, *startpoint; +static const char *currentpoint; static const char *selected_item; /* The widget variables */ @@ -489,7 +489,7 @@ event->y -= 2; if (event->buttons & GPM_B_RIGHT){ - currentpoint = startpoint = history [history_ptr].page; + currentpoint = history [history_ptr].page; selected_item = history [history_ptr].link; history_ptr--; if (history_ptr < 0) @@ -527,7 +527,7 @@ history_ptr = (history_ptr+1) % HISTORY_SIZE; history [history_ptr].page = currentpoint; history [history_ptr].link = current_area->link_name; - currentpoint = startpoint = help_follow_link (currentpoint, current_area->link_name); + currentpoint = help_follow_link (currentpoint, current_area->link_name); selected_item = NULL; } else{ if (event->y < 0) @@ -561,7 +561,7 @@ if (p == NULL) return; - currentpoint = startpoint = p + 1; + currentpoint = p + 1; selected_item = NULL; help_callback (h, DLG_DRAW, 0); } @@ -582,7 +582,7 @@ history[history_ptr].page = currentpoint; history[history_ptr].link = selected_item; - currentpoint = startpoint = new_item + 1; + currentpoint = new_item + 1; selected_item = NULL; help_callback (h, DLG_DRAW, 0); } @@ -595,7 +595,7 @@ static void prev_node_cmd (void *vp) { Dlg_head *h = vp; - currentpoint = startpoint = history [history_ptr].page; + currentpoint = history [history_ptr].page; selected_item = history [history_ptr].link; history_ptr--; if (history_ptr < 0) @@ -672,14 +672,14 @@ if (history_ptr < 0) history_ptr = HISTORY_SIZE-1; - currentpoint = startpoint = history [history_ptr].page; + currentpoint = history [history_ptr].page; selected_item = history [history_ptr].link; #endif } else { history_ptr = (history_ptr+1) % HISTORY_SIZE; history [history_ptr].page = currentpoint; history [history_ptr].link = selected_item; - currentpoint = startpoint = help_follow_link (currentpoint, selected_item) + 1; + currentpoint = help_follow_link (currentpoint, selected_item) + 1; } selected_item = NULL; break; @@ -704,7 +704,7 @@ case KEY_UP: case ALT ('\t'): /* select previous link */ - new_item = select_prev_link (startpoint, selected_item); + new_item = select_prev_link (currentpoint, selected_item); selected_item = new_item; if (selected_item < currentpoint || selected_item >= last_shown){ if (c == KEY_UP) @@ -835,7 +835,7 @@ DLG_TRYUP | DLG_CENTER | DLG_WANT_TAB); selected_item = search_string_node (main_node, STRING_LINK_START) - 1; - currentpoint = startpoint = main_node + 1; + currentpoint = main_node + 1; for (history_ptr = HISTORY_SIZE; history_ptr;) { history_ptr--;
_______________________________________________ Mc-devel mailing list http://mail.gnome.org/mailman/listinfo/mc-devel