To: vim-dev@vim.org Subject: Patch 6.1.035 (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.035 (extra, depends on 6.1.016) Problem: Win32: Outputting Hebrew or Arabic text might have a problem with reversing on MS-Windows 95/98/ME. Solution: Restore the RevOut() function and use it in specific situations only. (Ron Aaron) Files: src/gui_w32.c *** ../vim61.034/src/gui_w32.c Wed Apr 10 21:37:12 2002 --- src/gui_w32.c Sat Apr 20 19:54:38 2002 *************** *** 1611,1616 **** --- 1611,1667 ---- } #endif + + #ifdef FEAT_RIGHTLEFT + /* + * What is this for? In the case where you are using Win98 or Win2K or later, + * and you are using a Hebrew font (or Arabic!), Windows does you a favor and + * reverses the string sent to the TextOut... family. This sucks, because we + * go to a lot of effort to do the right thing, and there doesn't seem to be a + * way to tell Windblows not to do this! + * + * The short of it is that this 'RevOut' only gets called if you are running + * one of the new, "improved" MS OSes, and only if you are running in + * 'rightleft' mode. It makes display take *slightly* longer, but not + * noticeably so. + */ + static void + RevOut( HDC s_hdc, + int col, + int row, + UINT foptions, + CONST RECT *pcliprect, + LPCTSTR text, + UINT len, + CONST INT *padding) + { + int ix; + static int special = -1; + + if (special == -1) + { + /* Check windows version: special treatment is needed if it is NT 5 or + * Win98 or higher. */ + if ((os_version.dwPlatformId == VER_PLATFORM_WIN32_NT + && os_version.dwMajorVersion >= 5) + || (os_version.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS + && (os_version.dwMajorVersion > 4 + || (os_version.dwMajorVersion == 4 + && os_version.dwMinorVersion > 0)))) + special = 1; + else + special = 0; + } + + if (special) + for (ix = 0; ix < (int)len; ++ix) + ExtTextOut(s_hdc, col + TEXT_X(ix), row, foptions, + pcliprect, text + ix, 1, padding); + else + ExtTextOut(s_hdc, col, row, foptions, pcliprect, text, len, padding); + } + #endif + void gui_mch_draw_string( int row, *************** *** 1795,1803 **** i += utfc_ptr2len_check_len(text + i, len - i); ++clen; } ! ExtTextOutW(s_hdc, TEXT_X(col), TEXT_Y(row), ! ETO_IGNORELANGUAGE | foptions, pcliprect, ! unicodebuf, clen, NULL); len = cells; /* used for underlining */ } else if (is_funky_dbcs) --- 1846,1858 ---- i += utfc_ptr2len_check_len(text + i, len - i); ++clen; } ! if (os_version.dwPlatformId == VER_PLATFORM_WIN32_NT) ! ExtTextOutW(s_hdc, TEXT_X(col), TEXT_Y(row), ! foptions | ETO_IGNORELANGUAGE, ! pcliprect, unicodebuf, clen, NULL); ! else ! ExtTextOutW(s_hdc, TEXT_X(col), TEXT_Y(row), ! foptions, pcliprect, unicodebuf, clen, NULL); len = cells; /* used for underlining */ } else if (is_funky_dbcs) *************** *** 1811,1826 **** (char *)text, len, (LPWSTR)unicodebuf, unibuflen))) ExtTextOutW(s_hdc, TEXT_X(col), TEXT_Y(row), ! ETO_IGNORELANGUAGE | foptions, pcliprect, ! unicodebuf, len, NULL); } } else #endif { ! ExtTextOut(s_hdc, TEXT_X(col), TEXT_Y(row), ! ETO_IGNORELANGUAGE | foptions, pcliprect, ! (char *)text, len, padding); } } --- 1866,1893 ---- (char *)text, len, (LPWSTR)unicodebuf, unibuflen))) ExtTextOutW(s_hdc, TEXT_X(col), TEXT_Y(row), ! foptions, pcliprect, unicodebuf, len, NULL); } } else #endif { ! #ifdef FEAT_RIGHTLEFT ! /* ron: fixed Hebrew on Win98/Win2000 */ ! if (curwin->w_p_rl) ! { ! if (os_version.dwPlatformId == VER_PLATFORM_WIN32_NT) ! ExtTextOut(s_hdc, TEXT_X(col), TEXT_Y(row), ! foptions | ETO_IGNORELANGUAGE, ! pcliprect, (char *)text, len, padding); ! else ! RevOut(s_hdc, TEXT_X(col), TEXT_Y(row), ! foptions, pcliprect, (char *)text, len, padding); ! } ! else ! #endif ! ExtTextOut(s_hdc, TEXT_X(col), TEXT_Y(row), ! foptions, pcliprect, (char *)text, len, padding); } } *** ../vim61.034/src/version.c Sun Apr 28 22:04:35 2002 --- src/version.c Sun Apr 28 22:06:27 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 35, /**/ -- Q: How many hardware engineers does it take to change a lightbulb? A: None. We'll fix it in software. /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\ /// Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim \\\ \\\ Project leader for A-A-P -- http://www.a-a-p.org /// \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///