To: vim-dev@vim.org Subject: Patch 6.1.434 (extra) Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.1.434 (extra) Problem: Win32: When there are more than 32767 lines, the scrollbar has a roundoff error. Solution: Make a click on an arrow move one line. Also move the code to gui_w48.c, there is hardly any difference between the 16 bit and 32 bit versions. (Walter Briscoe) Files: src/gui_w16.c, src/gui_w32.c, src/gui_w48.c *** ../vim61.433/src/gui_w16.c Tue Oct 15 21:05:16 2002 --- src/gui_w16.c Mon Mar 31 22:36:40 2003 *************** *** 132,257 **** #endif /*FEAT_MENU*/ - static int - _OnScroll( - HWND hwnd, - HWND hwndCtl, - UINT code, - int pos) - { - scrollbar_T *sb, *sb_info; - long val; - int dragging = FALSE; - #ifdef WIN32 - SCROLLINFO si; - #else - int nPos; - #endif - static UINT prev_code = 0; /* code of previous call */ - int dont_scroll_save = dont_scroll; - - sb = gui_mswin_find_scrollbar(hwndCtl); - if (sb == NULL) - return 0; - - if (sb->wp != NULL) /* Left or right scrollbar */ - { - /* - * Careful: need to get scrollbar info out of first (left) scrollbar - * for window, but keep real scrollbar too because we must pass it to - * gui_drag_scrollbar(). - */ - sb_info = &sb->wp->w_scrollbars[0]; - } - else /* Bottom scrollbar */ - sb_info = sb; - val = sb_info->value; - - switch (code) - { - case SB_THUMBTRACK: - val = pos; - dragging = TRUE; - if (sb->scroll_shift > 0) - val <<= sb->scroll_shift; - break; - case SB_LINEDOWN: - /* Because of round-off errors we can't move one line when - * scroll_shift is non-zero. Scroll some extra. */ - if (sb->scroll_shift > 0) - val += (1 << sb->scroll_shift); - else - val++; - break; - case SB_LINEUP: - val--; - break; - case SB_PAGEDOWN: - val += (sb_info->size > 2 ? sb_info->size - 2 : 1); - break; - case SB_PAGEUP: - val -= (sb_info->size > 2 ? sb_info->size - 2 : 1); - break; - case SB_TOP: - val = 0; - break; - case SB_BOTTOM: - val = sb_info->max; - break; - case SB_ENDSCROLL: - if (prev_code == SB_THUMBTRACK) - { - /* - * "pos" only gives us 16-bit data. In case of large file, - * use GetScrollPos() which returns 32-bit. Unfortunately it - * is not valid while the scrollbar is being dragged. - */ - val = GetScrollPos(hwndCtl, SB_CTL); - if (sb->scroll_shift > 0) - val <<= sb->scroll_shift; - } - break; - - default: - /* TRACE("Unknown scrollbar event %d\n", code); */ - return 0; - } - prev_code = code; - - if (sb->scroll_shift > 0) - nPos = val >> sb->scroll_shift; - else - nPos = val; - SetScrollPos(hwndCtl, SB_CTL, nPos, TRUE); - - /* - * When moving a vertical scrollbar, move the other vertical scrollbar too. - */ - if (sb->wp != NULL) - { - if (sb == &sb->wp->w_scrollbars[SBAR_LEFT]) - SetScrollPos(sb->wp->w_scrollbars[SBAR_RIGHT].id, - SB_CTL, nPos, TRUE); - else - SetScrollPos(sb->wp->w_scrollbars[SBAR_LEFT].id, - SB_CTL, nPos, TRUE); - } - - /* Don't let us be interrupted here by another message. */ - s_busy_processing = TRUE; - - /* When "allow_scrollbar" is FALSE still need to remember the new - * position, but don't actually scroll by setting "dont_scroll". */ - dont_scroll = !allow_scrollbar; - - gui_drag_scrollbar(sb, val, dragging); - s_busy_processing = FALSE; - dont_scroll = dont_scroll_save; - - return 0; - } - - /* * Even though we have _DuringSizing() which makes the rubber band a valid * size, we need this for when the user maximises the window. --- 132,137 ---- *** ../vim61.433/src/gui_w32.c Wed Mar 26 22:18:13 2003 --- src/gui_w32.c Mon Mar 31 22:36:51 2003 *************** *** 384,510 **** } #endif /*FEAT_MENU*/ - static int - _OnScroll( - HWND hwnd, - HWND hwndCtl, - UINT code, - int pos) - { - scrollbar_T *sb, *sb_info; - long val; - int dragging = FALSE; - #ifdef WIN3264 - SCROLLINFO si; - #else - int nPos; - #endif - static UINT prev_code = 0; /* code of previous call */ - int dont_scroll_save = dont_scroll; - - sb = gui_mswin_find_scrollbar(hwndCtl); - if (sb == NULL) - return 0; - - if (sb->wp != NULL) /* Left or right scrollbar */ - { - /* - * Careful: need to get scrollbar info out of first (left) scrollbar - * for window, but keep real scrollbar too because we must pass it to - * gui_drag_scrollbar(). - */ - sb_info = &sb->wp->w_scrollbars[0]; - } - else /* Bottom scrollbar */ - sb_info = sb; - val = sb_info->value; - - switch (code) - { - case SB_THUMBTRACK: - val = pos; - dragging = TRUE; - if (sb->scroll_shift > 0) - val <<= sb->scroll_shift; - break; - case SB_LINEDOWN: - /* Because of round-off errors we can't move one line when - * scroll_shift is non-zero. Scroll some extra. */ - if (sb->scroll_shift > 0) - val += (1 << sb->scroll_shift); - else - val++; - break; - case SB_LINEUP: - val--; - break; - case SB_PAGEDOWN: - val += (sb_info->size > 2 ? sb_info->size - 2 : 1); - break; - case SB_PAGEUP: - val -= (sb_info->size > 2 ? sb_info->size - 2 : 1); - break; - case SB_TOP: - val = 0; - break; - case SB_BOTTOM: - val = sb_info->max; - break; - case SB_ENDSCROLL: - if (prev_code == SB_THUMBTRACK) - { - /* - * "pos" only gives us 16-bit data. In case of large file, - * use GetScrollPos() which returns 32-bit. Unfortunately it - * is not valid while the scrollbar is being dragged. - */ - val = GetScrollPos(hwndCtl, SB_CTL); - if (sb->scroll_shift > 0) - val <<= sb->scroll_shift; - } - break; - - default: - /* TRACE("Unknown scrollbar event %d\n", code); */ - return 0; - } - prev_code = code; - - si.cbSize = sizeof(si); - si.fMask = SIF_POS; - if (sb->scroll_shift > 0) - si.nPos = val >> sb->scroll_shift; - else - si.nPos = val; - SetScrollInfo(hwndCtl, SB_CTL, &si, TRUE); - - /* - * When moving a vertical scrollbar, move the other vertical scrollbar too. - */ - if (sb->wp != NULL) - { - if (sb == &sb->wp->w_scrollbars[SBAR_LEFT]) - SetScrollInfo(sb->wp->w_scrollbars[SBAR_RIGHT].id, - SB_CTL, &si, TRUE); - else - SetScrollInfo(sb->wp->w_scrollbars[SBAR_LEFT].id, - SB_CTL, &si, TRUE); - } - - /* Don't let us be interrupted here by another message. */ - s_busy_processing = TRUE; - - /* When "allow_scrollbar" is FALSE still need to remember the new - * position, but don't actually scroll by setting "dont_scroll". */ - dont_scroll = !allow_scrollbar; - - gui_drag_scrollbar(sb, val, dragging); - - s_busy_processing = FALSE; - dont_scroll = dont_scroll_save; - - return 0; - } /* * Setup for the Intellimouse --- 384,389 ---- *** ../vim61.433/src/gui_w48.c Sat Mar 15 16:54:47 2003 --- src/gui_w48.c Mon Mar 31 22:37:11 2003 *************** *** 2829,2831 **** --- 2829,2953 ---- s_need_activate = TRUE; #endif } + + static int + _OnScroll( + HWND hwnd, + HWND hwndCtl, + UINT code, + int pos) + { + static UINT prev_code = 0; /* code of previous call */ + scrollbar_T *sb, *sb_info; + long val; + int dragging = FALSE; + int dont_scroll_save = dont_scroll; + #ifndef WIN3264 + int nPos; + #else + SCROLLINFO si; + + si.cbSize = sizeof(si); + si.fMask = SIF_POS; + #endif + + sb = gui_mswin_find_scrollbar(hwndCtl); + if (sb == NULL) + return 0; + + if (sb->wp != NULL) /* Left or right scrollbar */ + { + /* + * Careful: need to get scrollbar info out of first (left) scrollbar + * for window, but keep real scrollbar too because we must pass it to + * gui_drag_scrollbar(). + */ + sb_info = &sb->wp->w_scrollbars[0]; + } + else /* Bottom scrollbar */ + sb_info = sb; + val = sb_info->value; + + switch (code) + { + case SB_THUMBTRACK: + val = pos; + dragging = TRUE; + if (sb->scroll_shift > 0) + val <<= sb->scroll_shift; + break; + case SB_LINEDOWN: + val++; + break; + case SB_LINEUP: + val--; + break; + case SB_PAGEDOWN: + val += (sb_info->size > 2 ? sb_info->size - 2 : 1); + break; + case SB_PAGEUP: + val -= (sb_info->size > 2 ? sb_info->size - 2 : 1); + break; + case SB_TOP: + val = 0; + break; + case SB_BOTTOM: + val = sb_info->max; + break; + case SB_ENDSCROLL: + if (prev_code == SB_THUMBTRACK) + { + /* + * "pos" only gives us 16-bit data. In case of large file, + * use GetScrollPos() which returns 32-bit. Unfortunately it + * is not valid while the scrollbar is being dragged. + */ + val = GetScrollPos(hwndCtl, SB_CTL); + if (sb->scroll_shift > 0) + val <<= sb->scroll_shift; + } + break; + + default: + /* TRACE("Unknown scrollbar event %d\n", code); */ + return 0; + } + prev_code = code; + + #ifdef WIN3264 + si.nPos = (sb->scroll_shift > 0) ? val >> sb->scroll_shift : val; + SetScrollInfo(hwndCtl, SB_CTL, &si, TRUE); + #else + nPos = (sb->scroll_shift > 0) ? val >> sb->scroll_shift : val; + SetScrollPos(hwndCtl, SB_CTL, nPos, TRUE); + #endif + + /* + * When moving a vertical scrollbar, move the other vertical scrollbar too. + */ + if (sb->wp != NULL) + { + scrollbar_T *sba = sb->wp->w_scrollbars; + HWND id = sba[ (sb == sba + SBAR_LEFT) ? SBAR_RIGHT : SBAR_LEFT].id; + + #ifdef WIN3264 + SetScrollInfo(id, SB_CTL, &si, TRUE); + #else + SetScrollPos(id, SB_CTL, nPos, TRUE); + #endif + } + + /* Don't let us be interrupted here by another message. */ + s_busy_processing = TRUE; + + /* When "allow_scrollbar" is FALSE still need to remember the new + * position, but don't actually scroll by setting "dont_scroll". */ + dont_scroll = !allow_scrollbar; + + gui_drag_scrollbar(sb, val, dragging); + + s_busy_processing = FALSE; + dont_scroll = dont_scroll_save; + + return 0; + } *** ../vim61.433/src/version.c Mon Mar 31 22:05:39 2003 --- src/version.c Mon Mar 31 22:43:02 2003 *************** *** 613,614 **** --- 613,616 ---- { /* Add new patch number below this line */ + /**/ + 434, /**/ -- They now pass three KNIGHTS impaled to a tree. With their feet off the ground, with one lance through the lot of them, they are skewered up like a barbecue. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Help AIDS victims, buy at Amazon -- http://ICCF.nl/click1.html ///