To: vim_dev@googlegroups.com Subject: Patch 8.1.2383 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.2383 Problem: Using old C style comments. Solution: Use // comments where appropriate. Files: src/gui_mac.c, src/gui_motif.c, src/gui_photon.c, src/gui_w32.c, src/gui_x11.c, src/gui_xmdlg.c, src/gui_xmebw.c *** ../vim-8.1.2382/src/gui_mac.c 2019-10-13 16:43:35.952359672 +0200 --- src/gui_mac.c 2019-12-02 22:15:16.303285132 +0100 *************** *** 28,52 **** * */ ! /* TODO (Jussi) * * Clipboard does not work (at least some cases) * * ATSU font rendering has some problems * * Investigate and remove dead code (there is still lots of that) */ ! #include /* included first to avoid CR problems */ #include "vim.h" #define USE_CARBONIZED ! #define USE_AEVENT /* Enable AEVENT */ ! #undef USE_OFFSETED_WINDOW /* Debugging feature: start Vim window OFFSETed */ ! /* Compile as CodeWarrior External Editor */ #if defined(FEAT_CW_EDITOR) && !defined(USE_AEVENT) ! # define USE_AEVENT /* Need Apple Event Support */ #endif ! /* Vim's Scrap flavor. */ #define VIMSCRAPFLAVOR 'VIM!' #define SCRAPTEXTFLAVOR kScrapFlavorTypeUnicode --- 28,53 ---- * */ ! /* ! * TODO (Jussi) * * Clipboard does not work (at least some cases) * * ATSU font rendering has some problems * * Investigate and remove dead code (there is still lots of that) */ ! #include // included first to avoid CR problems #include "vim.h" #define USE_CARBONIZED ! #define USE_AEVENT // Enable AEVENT ! #undef USE_OFFSETED_WINDOW // Debugging feature: start Vim window OFFSETed ! // Compile as CodeWarrior External Editor #if defined(FEAT_CW_EDITOR) && !defined(USE_AEVENT) ! # define USE_AEVENT // Need Apple Event Support #endif ! // Vim's Scrap flavor. #define VIMSCRAPFLAVOR 'VIM!' #define SCRAPTEXTFLAVOR kScrapFlavorTypeUnicode *************** *** 58,64 **** static int im_is_active = FALSE; # if 0 ! /* TODO: Implement me! */ static int im_start_row = 0; static int im_start_col = 0; # endif --- 59,65 ---- static int im_is_active = FALSE; # if 0 ! // TODO: Implement me! static int im_start_row = 0; static int im_start_col = 0; # endif *************** *** 86,92 **** #endif ! /* Include some file. TODO: move into os_mac.h */ #include #include #include --- 87,93 ---- #endif ! // Include some file. TODO: move into os_mac.h #include #include #include *************** *** 97,109 **** # include #if UNIVERSAL_INTERFACES_VERSION >= 0x0330 # include ! # include /* Navigation only part of ?? */ #endif ! /* Help Manager (balloon.h, HM prefixed functions) are not supported ! * under Carbon (Jussi) */ # if 0 ! /* New Help Interface for Mac, not implemented yet.*/ # include # endif --- 98,110 ---- # include #if UNIVERSAL_INTERFACES_VERSION >= 0x0330 # include ! # include // Navigation only part of ?? #endif ! // Help Manager (balloon.h, HM prefixed functions) are not supported ! // under Carbon (Jussi) # if 0 ! // New Help Interface for Mac, not implemented yet. # include # endif *************** *** 112,118 **** * headers? (Jussi) */ #define kNothing 0 ! #define kCreateEmpty 2 /*1*/ #define kCreateRect 2 #define kDestroy 3 --- 113,119 ---- * headers? (Jussi) */ #define kNothing 0 ! #define kCreateEmpty 2 //1 #define kCreateRect 2 #define kDestroy 3 *************** *** 123,156 **** #define botRight(r) (((Point*)&(r))[1]) ! /* Time of last mouse click, to detect double-click */ static long lastMouseTick = 0; ! /* ??? */ static RgnHandle cursorRgn; static RgnHandle dragRgn; static Rect dragRect; static short dragRectEnbl; static short dragRectControl; ! /* This variable is set when waiting for an event, which is the only moment ! * scrollbar dragging can be done directly. It's not allowed while commands ! * are executed, because it may move the cursor and that may cause unexpected ! * problems (e.g., while ":s" is working). ! */ static int allow_scrollbar = FALSE; ! /* Last mouse click caused contextual menu, (to provide proper release) */ static short clickIsPopup; ! /* Feedback Action for Scrollbar */ ControlActionUPP gScrollAction; ControlActionUPP gScrollDrag; ! /* Keeping track of which scrollbar is being dragged */ static ControlHandle dragged_sb = NULL; ! /* Vector of char_u --> control index for hotkeys in dialogs */ static short *gDialogHotKeys; static struct --- 124,156 ---- #define botRight(r) (((Point*)&(r))[1]) ! // Time of last mouse click, to detect double-click static long lastMouseTick = 0; ! // ??? static RgnHandle cursorRgn; static RgnHandle dragRgn; static Rect dragRect; static short dragRectEnbl; static short dragRectControl; ! // This variable is set when waiting for an event, which is the only moment ! // scrollbar dragging can be done directly. It's not allowed while commands ! // are executed, because it may move the cursor and that may cause unexpected ! // problems (e.g., while ":s" is working). static int allow_scrollbar = FALSE; ! // Last mouse click caused contextual menu, (to provide proper release) static short clickIsPopup; ! // Feedback Action for Scrollbar ControlActionUPP gScrollAction; ControlActionUPP gScrollDrag; ! // Keeping track of which scrollbar is being dragged static ControlHandle dragged_sb = NULL; ! // Vector of char_u --> control index for hotkeys in dialogs static short *gDialogHotKeys; static struct *************** *** 170,192 **** UInt32 useAntialias_cached = 0x0; #endif ! /* Colors Macros */ #define RGB(r,g,b) ((r) << 16) + ((g) << 8) + (b) #define Red(c) ((c & 0x00FF0000) >> 16) #define Green(c) ((c & 0x0000FF00) >> 8) #define Blue(c) ((c & 0x000000FF) >> 0) ! /* Key mapping */ ! #define vk_Esc 0x35 /* -> 1B */ ! #define vk_F1 0x7A /* -> 10 */ ! #define vk_F2 0x78 /*0x63*/ ! #define vk_F3 0x63 /*0x76*/ ! #define vk_F4 0x76 /*0x60*/ ! #define vk_F5 0x60 /*0x61*/ ! #define vk_F6 0x61 /*0x62*/ ! #define vk_F7 0x62 /*0x63*/ /*?*/ #define vk_F8 0x64 #define vk_F9 0x65 #define vk_F10 0x6D --- 170,192 ---- UInt32 useAntialias_cached = 0x0; #endif ! // Colors Macros #define RGB(r,g,b) ((r) << 16) + ((g) << 8) + (b) #define Red(c) ((c & 0x00FF0000) >> 16) #define Green(c) ((c & 0x0000FF00) >> 8) #define Blue(c) ((c & 0x000000FF) >> 0) ! // Key mapping ! #define vk_Esc 0x35 // -> 1B ! #define vk_F1 0x7A // -> 10 ! #define vk_F2 0x78 //0x63 ! #define vk_F3 0x63 //0x76 ! #define vk_F4 0x76 //0x60 ! #define vk_F5 0x60 //0x61 ! #define vk_F6 0x61 //0x62 ! #define vk_F7 0x62 //0x63 ? #define vk_F8 0x64 #define vk_F9 0x65 #define vk_F10 0x6D *************** *** 196,221 **** #define vk_F14 0x6B #define vk_F15 0x71 ! #define vk_Clr 0x47 /* -> 1B (ESC) */ ! #define vk_Enter 0x4C /* -> 03 */ ! #define vk_Space 0x31 /* -> 20 */ ! #define vk_Tab 0x30 /* -> 09 */ ! #define vk_Return 0x24 /* -> 0D */ ! /* This is wrong for OSX, what is it for? */ ! #define vk_Delete 0X08 /* -> 08 BackSpace */ ! ! #define vk_Help 0x72 /* -> 05 */ ! #define vk_Home 0x73 /* -> 01 */ ! #define vk_PageUp 0x74 /* -> 0D */ ! #define vk_FwdDelete 0x75 /* -> 7F */ ! #define vk_End 0x77 /* -> 04 */ ! #define vk_PageDown 0x79 /* -> 0C */ ! ! #define vk_Up 0x7E /* -> 1E */ ! #define vk_Down 0x7D /* -> 1F */ ! #define vk_Left 0x7B /* -> 1C */ ! #define vk_Right 0x7C /* -> 1D */ #define vk_Undo vk_F1 #define vk_Cut vk_F2 --- 196,221 ---- #define vk_F14 0x6B #define vk_F15 0x71 ! #define vk_Clr 0x47 // -> 1B (ESC) ! #define vk_Enter 0x4C // -> 03 ! #define vk_Space 0x31 // -> 20 ! #define vk_Tab 0x30 // -> 09 ! #define vk_Return 0x24 // -> 0D ! // This is wrong for OSX, what is it for? ! #define vk_Delete 0X08 // -> 08 BackSpace ! ! #define vk_Help 0x72 // -> 05 ! #define vk_Home 0x73 // -> 01 ! #define vk_PageUp 0x74 // -> 0D ! #define vk_FwdDelete 0x75 // -> 7F ! #define vk_End 0x77 // -> 04 ! #define vk_PageDown 0x79 // -> 0C ! ! #define vk_Up 0x7E // -> 1E ! #define vk_Down 0x7D // -> 1F ! #define vk_Left 0x7B // -> 1C ! #define vk_Right 0x7C // -> 1D #define vk_Undo vk_F1 #define vk_Cut vk_F2 *************** *** 258,279 **** {vk_F14, 'F', '4'}, {vk_F15, 'F', '5'}, ! /* {XK_Help, '%', '1'}, */ ! /* {XK_Undo, '&', '8'}, */ ! /* {XK_BackSpace, 'k', 'b'}, */ ! /* {vk_Delete, 'k', 'b'}, */ {vk_Insert, 'k', 'I'}, {vk_FwdDelete, 'k', 'D'}, {vk_Home, 'k', 'h'}, {vk_End, '@', '7'}, ! /* {XK_Prior, 'k', 'P'}, */ ! /* {XK_Next, 'k', 'N'}, */ ! /* {XK_Print, '%', '9'}, */ {vk_PageUp, 'k', 'P'}, {vk_PageDown, 'k', 'N'}, ! /* End of list marker: */ {(KeySym)0, 0, 0} }; --- 258,279 ---- {vk_F14, 'F', '4'}, {vk_F15, 'F', '5'}, ! // {XK_Help, '%', '1'}, ! // {XK_Undo, '&', '8'}, ! // {XK_BackSpace, 'k', 'b'}, ! // {vk_Delete, 'k', 'b'}, {vk_Insert, 'k', 'I'}, {vk_FwdDelete, 'k', 'D'}, {vk_Home, 'k', 'h'}, {vk_End, '@', '7'}, ! // {XK_Prior, 'k', 'P'}, ! // {XK_Next, 'k', 'N'}, ! // {XK_Print, '%', '9'}, {vk_PageUp, 'k', 'P'}, {vk_PageDown, 'k', 'N'}, ! // End of list marker: {(KeySym)0, 0, 0} }; *************** *** 321,327 **** len = STRLEN(Cstring); ! if (len > 255) /* Truncate if necessary */ len = 255; PascalString = alloc(len + 1); --- 321,327 ---- len = STRLEN(Cstring); ! if (len > 255) // Truncate if necessary len = 255; PascalString = alloc(len + 1); *************** *** 351,357 **** len = STRLEN(Cstring); ! if (len > 255) /* Truncate if necessary */ len = 255; PascalString = alloc(len + 1); --- 351,357 ---- len = STRLEN(Cstring); ! if (len > 255) // Truncate if necessary len = 255; PascalString = alloc(len + 1); *************** *** 387,394 **** if (macModifiers & (optionKey | rightOptionKey)) vimModifiers |= MOUSE_ALT; #if 0 ! /* Not yet supported */ ! if (macModifiers & (cmdKey)) /* There's no rightCmdKey */ vimModifiers |= MOUSE_CMD; #endif return (vimModifiers); --- 387,394 ---- if (macModifiers & (optionKey | rightOptionKey)) vimModifiers |= MOUSE_ALT; #if 0 ! // Not yet supported ! if (macModifiers & (cmdKey)) // There's no rightCmdKey vimModifiers |= MOUSE_CMD; #endif return (vimModifiers); *************** *** 410,422 **** if (macModifiers & (optionKey | rightOptionKey)) vimModifiers |= MOD_MASK_ALT; #ifdef USE_CMD_KEY ! if (macModifiers & (cmdKey)) /* There's no rightCmdKey */ vimModifiers |= MOD_MASK_CMD; #endif return (vimModifiers); } ! /* Convert a string representing a point size into pixels. The string should * be a positive decimal number, with an optional decimal point (eg, "12", or * "10.5"). The pixel value is returned, and a pointer to the next unconverted * character is stored in *end. The flag "vertical" says whether this --- 410,423 ---- if (macModifiers & (optionKey | rightOptionKey)) vimModifiers |= MOD_MASK_ALT; #ifdef USE_CMD_KEY ! if (macModifiers & (cmdKey)) // There's no rightCmdKey vimModifiers |= MOD_MASK_CMD; #endif return (vimModifiers); } ! /* ! * Convert a string representing a point size into pixels. The string should * be a positive decimal number, with an optional decimal point (eg, "12", or * "10.5"). The pixel value is returned, and a pointer to the next unconverted * character is stored in *end. The flag "vertical" says whether this *************** *** 435,441 **** { if (*str == '.' && divisor == 0) { ! /* Start keeping a divisor, for later */ divisor = 1; continue; } --- 436,442 ---- { if (*str == '.' && divisor == 0) { ! // Start keeping a divisor, for later divisor = 1; continue; } *************** *** 479,486 **** if (name) { ! /* Simple mnemonic-removal algorithm, assumes single parenthesized ! * mnemonic character towards the end of the menu text */ mnemonicStart = CFStringFind(name, CFSTR("("), kCFCompareBackwards); displayLen = CFStringGetLength(name); --- 480,487 ---- if (name) { ! // Simple mnemonic-removal algorithm, assumes single parenthesized ! // mnemonic character towards the end of the menu text mnemonicStart = CFStringFind(name, CFSTR("("), kCFCompareBackwards); displayLen = CFStringGetLength(name); *************** *** 530,562 **** AEKeyword dummyKeyword; DescType dummyType; ! /* Get number of files in list */ *error = AECountItems(theList, numFiles); if (*error) return fnames; ! /* Allocate the pointer list */ fnames = ALLOC_MULT(char_u *, *numFiles); ! /* Empty out the list */ for (fileCount = 0; fileCount < *numFiles; fileCount++) fnames[fileCount] = NULL; ! /* Scan the list of FSSpec */ for (fileCount = 1; fileCount <= *numFiles; fileCount++) { ! /* Get the alias for the nth file, convert to an FSSpec */ newError = AEGetNthPtr(theList, fileCount, typeFSS, &dummyKeyword, &dummyType, (Ptr) &fileToOpen, sizeof(FSSpec), &actualSize); if (newError) { ! /* Caller is able to clean up */ ! /* TODO: Should be clean up or not? For safety. */ return fnames; } ! /* Convert the FSSpec to a pathname */ fnames[fileCount - 1] = FullPathFromFSSpec_save(fileToOpen); } --- 531,563 ---- AEKeyword dummyKeyword; DescType dummyType; ! // Get number of files in list *error = AECountItems(theList, numFiles); if (*error) return fnames; ! // Allocate the pointer list fnames = ALLOC_MULT(char_u *, *numFiles); ! // Empty out the list for (fileCount = 0; fileCount < *numFiles; fileCount++) fnames[fileCount] = NULL; ! // Scan the list of FSSpec for (fileCount = 1; fileCount <= *numFiles; fileCount++) { ! // Get the alias for the nth file, convert to an FSSpec newError = AEGetNthPtr(theList, fileCount, typeFSS, &dummyKeyword, &dummyType, (Ptr) &fileToOpen, sizeof(FSSpec), &actualSize); if (newError) { ! // Caller is able to clean up ! // TODO: Should be clean up or not? For safety. return fnames; } ! // Convert the FSSpec to a pathname fnames[fileCount - 1] = FullPathFromFSSpec_save(fileToOpen); } *************** *** 595,601 **** */ typedef struct WindowSearch WindowSearch; ! struct WindowSearch /* for handling class 'KAHL', event 'SRCH', keyDirectObject typeChar*/ { FSSpec theFile; // identifies the file long *theDate; // where to put the modification date/time --- 596,602 ---- */ typedef struct WindowSearch WindowSearch; ! struct WindowSearch // for handling class 'KAHL', event 'SRCH', keyDirectObject typeChar { FSSpec theFile; // identifies the file long *theDate; // where to put the modification date/time *************** *** 668,674 **** */ typedef struct ModificationInfo ModificationInfo; ! struct ModificationInfo /* for replying to class 'KAHL', event 'MOD ', keyDirectObject typeAEList*/ { FSSpec theFile; // identifies the file long theDate; // the date/time the file was last modified --- 669,675 ---- */ typedef struct ModificationInfo ModificationInfo; ! struct ModificationInfo // for replying to class 'KAHL', event 'MOD ', keyDirectObject typeAEList { FSSpec theFile; // identifies the file long theDate; // the date/time the file was last modified *************** *** 693,703 **** if (error) return error; ! /* Send the reply */ ! /* replyObject.descriptorType = typeNull; ! replyObject.dataHandle = nil;*/ ! /* AECreateDesc(typeChar, (Ptr)&title[1], title[0], &data) */ error = AECreateList(nil, 0, false, &replyList); if (error) return error; --- 694,704 ---- if (error) return error; ! // Send the reply ! // replyObject.descriptorType = typeNull; ! // replyObject.dataHandle = nil; ! // AECreateDesc(typeChar, (Ptr)&title[1], title[0], &data) error = AECreateList(nil, 0, false, &replyList); if (error) return error; *************** *** 705,726 **** #if 0 error = AECountItems(&replyList, &numFiles); ! /* AEPutKeyDesc(&replyList, keyAEPnject, &aDesc) ! * AEPutKeyPtr(&replyList, keyAEPosition, typeChar, (Ptr)&theType, ! * sizeof(DescType)) ! */ ! /* AEPutDesc */ #endif numFiles = 0; FOR_ALL_BUFFERS(buf) if (buf->b_ml.ml_mfp != NULL) { ! /* Add this file to the list */ theFile.theFile = buf->b_FSSpec; theFile.theDate = buf->b_mtime; ! /* theFile.theDate = time(NULL) & (time_t) 0xFFFFFFF0; */ error = AEPutPtr(&replyList, numFiles, typeChar, (Ptr) &theFile, sizeof(theFile)); }; --- 706,726 ---- #if 0 error = AECountItems(&replyList, &numFiles); ! // AEPutKeyDesc(&replyList, keyAEPnject, &aDesc) ! // AEPutKeyPtr(&replyList, keyAEPosition, typeChar, (Ptr)&theType, ! // sizeof(DescType)) ! // AEPutDesc #endif numFiles = 0; FOR_ALL_BUFFERS(buf) if (buf->b_ml.ml_mfp != NULL) { ! // Add this file to the list theFile.theFile = buf->b_FSSpec; theFile.theDate = buf->b_mtime; ! // theFile.theDate = time(NULL) & (time_t) 0xFFFFFFF0; error = AEPutPtr(&replyList, numFiles, typeChar, (Ptr) &theFile, sizeof(theFile)); }; *************** *** 728,734 **** error = AECountItems(&replyList, &numFiles); #endif ! /* We can add data only if something to reply */ error = AEPutParamDesc(theReply, keyDirectObject, &replyList); if (replyList.dataHandle) --- 728,734 ---- error = AECountItems(&replyList, &numFiles); #endif ! // We can add data only if something to reply error = AEPutParamDesc(theReply, keyDirectObject, &replyList); if (replyList.dataHandle) *************** *** 764,775 **** */ typedef struct CW_GetText CW_GetText; ! struct CW_GetText /* for handling class 'KAHL', event 'GTTX', keyDirectObject typeChar*/ { ! FSSpec theFile; /* identifies the file */ ! Handle theText; /* the location where you return the text (must be resized properly) */ ! long *unused; /* 0 (not used) */ ! long *theDate; /* where to put the modification date/time */ }; pascal OSErr --- 764,775 ---- */ typedef struct CW_GetText CW_GetText; ! struct CW_GetText // for handling class 'KAHL', event 'GTTX', keyDirectObject typeChar { ! FSSpec theFile; // identifies the file ! Handle theText; // the location where you return the text (must be resized properly) ! long *unused; // 0 (not used) ! long *theDate; // where to put the modification date/time }; pascal OSErr *************** *** 806,824 **** if (foundFile) { ! BufferSize = 0; /* GetHandleSize(GetTextData.theText); */ for (lineno = 0; lineno <= buf->b_ml.ml_line_count; lineno++) { ! /* Must use the right buffer */ line = ml_get_buf(buf, (linenr_T) lineno, FALSE); linesize = STRLEN(line) + 1; lineStart = BufferSize; BufferSize += linesize; ! /* Resize handle to linesize+1 to include the linefeed */ SetHandleSize(GetTextData.theText, BufferSize); if (GetHandleSize(GetTextData.theText) != BufferSize) { ! break; /* Simple handling for now */ } else { --- 806,824 ---- if (foundFile) { ! BufferSize = 0; // GetHandleSize(GetTextData.theText); for (lineno = 0; lineno <= buf->b_ml.ml_line_count; lineno++) { ! // Must use the right buffer line = ml_get_buf(buf, (linenr_T) lineno, FALSE); linesize = STRLEN(line) + 1; lineStart = BufferSize; BufferSize += linesize; ! // Resize handle to linesize+1 to include the linefeed SetHandleSize(GetTextData.theText, BufferSize); if (GetHandleSize(GetTextData.theText) != BufferSize) { ! break; // Simple handling for now } else { *************** *** 838,844 **** if (foundFile == false) *GetTextData.theDate = fnfErr; else ! /* *GetTextData.theDate = time(NULL) & (time_t) 0xFFFFFFF0;*/ *GetTextData.theDate = buf->b_mtime; } --- 838,844 ---- if (foundFile == false) *GetTextData.theDate = fnfErr; else ! // *GetTextData.theDate = time(NULL) & (time_t) 0xFFFFFFF0; *GetTextData.theDate = buf->b_mtime; } *************** *** 851,857 **** * */ ! /* Taken from MoreAppleEvents:ProcessHelpers*/ pascal OSErr FindProcessBySignature( const OSType targetType, --- 851,859 ---- * */ ! /* ! * Taken from MoreAppleEvents:ProcessHelpers ! */ pascal OSErr FindProcessBySignature( const OSType targetType, *************** *** 915,921 **** AEDisposeDesc(&targetAppDesc); ! /* Add the parms */ ModData.theFile = buf->b_FSSpec; ModData.theDate = buf->b_mtime; --- 917,923 ---- AEDisposeDesc(&targetAppDesc); ! // Add the parms ModData.theFile = buf->b_FSSpec; ModData.theDate = buf->b_mtime; *************** *** 931,942 **** anErr = AESend(&theEvent, &theReply, sendMode, kAENormalPriority, kNoTimeOut, idleProcUPP, nil); if (anErr == noErr && sendMode == kAEWaitReply) { ! /* anErr = AEHGetHandlerError(&theReply);*/ } (void) AEDisposeDesc(&theReply); } } ! #endif /* FEAT_CW_EDITOR */ /* * ------------------------------------------------------------ --- 933,944 ---- anErr = AESend(&theEvent, &theReply, sendMode, kAENormalPriority, kNoTimeOut, idleProcUPP, nil); if (anErr == noErr && sendMode == kAEWaitReply) { ! // anErr = AEHGetHandlerError(&theReply); } (void) AEDisposeDesc(&theReply); } } ! #endif // FEAT_CW_EDITOR /* * ------------------------------------------------------------ *************** *** 957,969 **** DescType dummyType; AEKeyword missedKeyword; ! /* Get the "missed keyword" attribute from the AppleEvent. */ error = AEGetAttributePtr(theAEvent, keyMissedKeywordAttr, typeKeyword, &dummyType, (Ptr)&missedKeyword, sizeof(missedKeyword), &actualSize); ! /* If the descriptor isn't found, then we got the required parameters. */ if (error == errAEDescNotFound) { error = noErr; --- 959,971 ---- DescType dummyType; AEKeyword missedKeyword; ! // Get the "missed keyword" attribute from the AppleEvent. error = AEGetAttributePtr(theAEvent, keyMissedKeywordAttr, typeKeyword, &dummyType, (Ptr)&missedKeyword, sizeof(missedKeyword), &actualSize); ! // If the descriptor isn't found, then we got the required parameters. if (error == errAEDescNotFound) { error = noErr; *************** *** 971,977 **** else { #if 0 ! /* Why is this removed? */ error = errAEEventNotHandled; #endif } --- 973,979 ---- else { #if 0 ! // Why is this removed? error = errAEEventNotHandled; #endif } *************** *** 988,994 **** */ typedef struct SelectionRange SelectionRange; ! struct SelectionRange /* for handling kCoreClassEvent:kOpenDocuments:keyAEPosition typeChar */ { short unused1; // 0 (not used) short lineNum; // line to select (<0 to specify range) --- 990,996 ---- */ typedef struct SelectionRange SelectionRange; ! struct SelectionRange // for handling kCoreClassEvent:kOpenDocuments:keyAEPosition typeChar { short unused1; // 0 (not used) short lineNum; // line to select (<0 to specify range) *************** *** 1005,1034 **** static void drop_callback(void *cookie UNUSED) { ! /* TODO: Handle the goto/select line more cleanly */ if ((drop_numFiles == 1) & (drop_gotPosition)) { if (drop_thePosition.lineNum >= 0) { lnum = drop_thePosition.lineNum + 1; ! /* oap->motion_type = MLINE; ! setpcmark();*/ if (lnum < 1L) lnum = 1L; else if (lnum > curbuf->b_ml.ml_line_count) lnum = curbuf->b_ml.ml_line_count; curwin->w_cursor.lnum = lnum; curwin->w_cursor.col = 0; ! /* beginline(BL_SOL | BL_FIX);*/ } else goto_byte(drop_thePosition.startRange + 1); } ! /* Update the screen display */ update_screen(NOT_VALID); ! /* Select the text if possible */ if (drop_gotPosition) { VIsual_active = TRUE; --- 1007,1036 ---- static void drop_callback(void *cookie UNUSED) { ! // TODO: Handle the goto/select line more cleanly if ((drop_numFiles == 1) & (drop_gotPosition)) { if (drop_thePosition.lineNum >= 0) { lnum = drop_thePosition.lineNum + 1; ! // oap->motion_type = MLINE; ! // setpcmark(); if (lnum < 1L) lnum = 1L; else if (lnum > curbuf->b_ml.ml_line_count) lnum = curbuf->b_ml.ml_line_count; curwin->w_cursor.lnum = lnum; curwin->w_cursor.col = 0; ! // beginline(BL_SOL | BL_FIX); } else goto_byte(drop_thePosition.startRange + 1); } ! // Update the screen display update_screen(NOT_VALID); ! // Select the text if possible if (drop_gotPosition) { VIsual_active = TRUE; *************** *** 1047,1060 **** } } ! /* The IDE uses the optional keyAEPosition parameter to tell the ed- ! itor the selection range. If lineNum is zero or greater, scroll the text ! to the specified line. If lineNum is less than zero, use the values in ! startRange and endRange to select the specified characters. Scroll ! the text to display the selection. If lineNum, startRange, and ! endRange are all negative, there is no selection range specified. */ - pascal OSErr HandleODocAE(const AppleEvent *theAEvent, AppleEvent *theReply, long refCon) { --- 1049,1062 ---- } } ! /* ! * The IDE uses the optional keyAEPosition parameter to tell the ed- ! * itor the selection range. If lineNum is zero or greater, scroll the text ! * to the specified line. If lineNum is less than zero, use the values in ! * startRange and endRange to select the specified characters. Scroll ! * the text to display the selection. If lineNum, startRange, and ! * endRange are all negative, there is no selection range specified. */ pascal OSErr HandleODocAE(const AppleEvent *theAEvent, AppleEvent *theReply, long refCon) { *************** *** 1076,1082 **** short gotPosition = false; long lnum; ! /* the direct object parameter is the list of aliases to files (one or more) */ error = AEGetParamDesc(theAEvent, keyDirectObject, typeAEList, &theList); if (error) return error; --- 1078,1084 ---- short gotPosition = false; long lnum; ! // the direct object parameter is the list of aliases to files (one or more) error = AEGetParamDesc(theAEvent, keyDirectObject, typeAEList, &theList); if (error) return error; *************** *** 1111,1117 **** if (error) { ! /* TODO: empty fnames[] first */ vim_free(fnames); return (error); } --- 1113,1119 ---- if (error) { ! // TODO: empty fnames[] first vim_free(fnames); return (error); } *************** *** 1122,1128 **** char_u *p; int fnum = -1; ! /* these are the initial files dropped on the Vim icon */ for (i = 0 ; i < numFiles; i++) { if (ga_grow(&global_alist.al_ga, 1) == FAIL --- 1124,1130 ---- char_u *p; int fnum = -1; ! // these are the initial files dropped on the Vim icon for (i = 0 ; i < numFiles; i++) { if (ga_grow(&global_alist.al_ga, 1) == FAIL *************** *** 1134,1141 **** fnum = GARGLIST[GARGCOUNT - 1].ae_fnum; } ! /* If the file name was already in the buffer list we need to switch ! * to it. */ if (curbuf->b_fnum != fnum) { char_u cmd[30]; --- 1136,1143 ---- fnum = GARGLIST[GARGCOUNT - 1].ae_fnum; } ! // If the file name was already in the buffer list we need to switch ! // to it. if (curbuf->b_fnum != fnum) { char_u cmd[30]; *************** *** 1144,1150 **** do_cmdline_cmd(cmd); } ! /* Change directory to the location of the first file. */ if (GARGCOUNT > 0 && vim_chdirfile(alist_name(&GARGLIST[0]), "drop") == OK) shorten_fnames(TRUE); --- 1146,1152 ---- do_cmdline_cmd(cmd); } ! // Change directory to the location of the first file. if (GARGCOUNT > 0 && vim_chdirfile(alist_name(&GARGLIST[0]), "drop") == OK) shorten_fnames(TRUE); *************** *** 1152,1158 **** goto finished; } ! /* Handle the drop, :edit to get to the file */ drop_numFiles = numFiles; drop_gotPosition = gotPosition; drop_thePosition = thePosition; --- 1154,1160 ---- goto finished; } ! // Handle the drop, :edit to get to the file drop_numFiles = numFiles; drop_gotPosition = gotPosition; drop_thePosition = thePosition; *************** *** 1161,1171 **** setcursor(); out_flush(); ! /* Fake mouse event to wake from stall */ PostEvent(mouseUp, 0); finished: ! AEDisposeDesc(&theList); /* dispose what we allocated */ error = HandleUnusedParms(theAEvent); return error; --- 1163,1173 ---- setcursor(); out_flush(); ! // Fake mouse event to wake from stall PostEvent(mouseUp, 0); finished: ! AEDisposeDesc(&theList); // dispose what we allocated error = HandleUnusedParms(theAEvent); return error; *************** *** 1174,1180 **** /* * */ - pascal OSErr Handle_aevt_oapp_AE( const AppleEvent *theAEvent, --- 1176,1181 ---- *************** *** 1190,1196 **** /* * */ - pascal OSErr Handle_aevt_quit_AE( const AppleEvent *theAEvent, --- 1191,1196 ---- *************** *** 1203,1209 **** if (error) return error; ! /* Need to fake a :confirm qa */ do_cmdline_cmd((char_u *)"confirm qa"); return error; --- 1203,1209 ---- if (error) return error; ! // Need to fake a :confirm qa do_cmdline_cmd((char_u *)"confirm qa"); return error; *************** *** 1212,1218 **** /* * */ - pascal OSErr Handle_aevt_pdoc_AE( const AppleEvent *theAEvent, --- 1212,1217 ---- *************** *** 1253,1282 **** { OSErr error; ! /* install open application handler */ error = AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, NewAEEventHandlerUPP(Handle_aevt_oapp_AE), 0, false); if (error) return error; ! /* install quit application handler */ error = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, NewAEEventHandlerUPP(Handle_aevt_quit_AE), 0, false); if (error) return error; ! /* install open document handler */ error = AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, NewAEEventHandlerUPP(HandleODocAE), 0, false); if (error) return error; ! /* install print document handler */ error = AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments, NewAEEventHandlerUPP(Handle_aevt_pdoc_AE), 0, false); ! /* Install Core Suite */ ! /* error = AEInstallEventHandler(kAECoreSuite, kAEClone, NewAEEventHandlerUPP(Handle_unknown_AE), nil, false); error = AEInstallEventHandler(kAECoreSuite, kAEClose, --- 1252,1282 ---- { OSErr error; ! // install open application handler error = AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, NewAEEventHandlerUPP(Handle_aevt_oapp_AE), 0, false); if (error) return error; ! // install quit application handler error = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, NewAEEventHandlerUPP(Handle_aevt_quit_AE), 0, false); if (error) return error; ! // install open document handler error = AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, NewAEEventHandlerUPP(HandleODocAE), 0, false); if (error) return error; ! // install print document handler error = AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments, NewAEEventHandlerUPP(Handle_aevt_pdoc_AE), 0, false); ! // Install Core Suite ! #if 0 ! error = AEInstallEventHandler(kAECoreSuite, kAEClone, NewAEEventHandlerUPP(Handle_unknown_AE), nil, false); error = AEInstallEventHandler(kAECoreSuite, kAEClose, *************** *** 1314,1320 **** error = AEInstallEventHandler(kAECoreSuite, kAESetData, NewAEEventHandlerUPP(Handle_unknown_AE), nil, false); ! */ #ifdef FEAT_CW_EDITOR /* --- 1314,1320 ---- error = AEInstallEventHandler(kAECoreSuite, kAESetData, NewAEEventHandlerUPP(Handle_unknown_AE), nil, false); ! #endif #ifdef FEAT_CW_EDITOR /* *************** *** 1335,1341 **** return error; } ! #endif /* USE_AEVENT */ /* --- 1335,1341 ---- return error; } ! #endif // USE_AEVENT /* *************** *** 1361,1367 **** FMFontSize newSize; FMFontStyle newStyle; ! /* Retrieve the font family ID number. */ status = GetEventParameter(inEvent, kEventParamFMFontFamily, /*inDesiredType=*/typeFMFontFamily, /*outActualType=*/NULL, /*inBufferSize=*/sizeof(FMFontFamily), /*outActualSize=*/NULL, --- 1361,1367 ---- FMFontSize newSize; FMFontStyle newStyle; ! // Retrieve the font family ID number. status = GetEventParameter(inEvent, kEventParamFMFontFamily, /*inDesiredType=*/typeFMFontFamily, /*outActualType=*/NULL, /*inBufferSize=*/sizeof(FMFontFamily), /*outActualSize=*/NULL, *************** *** 1369,1381 **** if (status == noErr) gFontPanelInfo.family = newFamily; ! /* Retrieve the font size. */ status = GetEventParameter(inEvent, kEventParamFMFontSize, typeFMFontSize, NULL, sizeof(FMFontSize), NULL, &newSize); if (status == noErr) gFontPanelInfo.size = newSize; ! /* Retrieve the font style (bold, etc.). Currently unused. */ status = GetEventParameter(inEvent, kEventParamFMFontStyle, typeFMFontStyle, NULL, sizeof(FMFontStyle), NULL, &newStyle); if (status == noErr) --- 1369,1381 ---- if (status == noErr) gFontPanelInfo.family = newFamily; ! // Retrieve the font size. status = GetEventParameter(inEvent, kEventParamFMFontSize, typeFMFontSize, NULL, sizeof(FMFontSize), NULL, &newSize); if (status == noErr) gFontPanelInfo.size = newSize; ! // Retrieve the font style (bold, etc.). Currently unused. status = GetEventParameter(inEvent, kEventParamFMFontStyle, typeFMFontStyle, NULL, sizeof(FMFontStyle), NULL, &newStyle); if (status == noErr) *************** *** 1390,1396 **** { EventTypeSpec eventTypes[2]; EventHandlerUPP handlerUPP; ! /* EventHandlerRef handlerRef; */ eventTypes[0].eventClass = kEventClassFont; eventTypes[0].eventKind = kEventFontSelection; --- 1390,1396 ---- { EventTypeSpec eventTypes[2]; EventHandlerUPP handlerUPP; ! // EventHandlerRef handlerRef; eventTypes[0].eventClass = kEventClassFont; eventTypes[0].eventKind = kEventFontSelection; *************** *** 1422,1441 **** if (FMGetFontFamilyName(gFontPanelInfo.family, buf) == noErr) { ! /* Canonicalize localized font names */ if (FMGetFontFromFontFamilyInstance(gFontPanelInfo.family, gFontPanelInfo.style, &fid, NULL) != noErr) return; ! /* Request font name with Mac encoding (otherwise we could ! * get an unwanted utf-16 name) */ if (ATSUFindFontName(fid, kFontFullName, kFontMacintoshPlatform, kFontNoScriptCode, kFontNoLanguageCode, 255, (char *)outName, &fontNameLen, NULL) != noErr) return; ! /* Only encode font size, because style (bold, italic, etc) is ! * already part of the font full name */ vim_snprintf((char *)styleString, FONT_STYLE_BUFFER_SIZE, ":h%d", gFontPanelInfo.size/*, ((gFontPanelInfo.style & bold)!=0 ? ":b" : ""), --- 1422,1441 ---- if (FMGetFontFamilyName(gFontPanelInfo.family, buf) == noErr) { ! // Canonicalize localized font names if (FMGetFontFromFontFamilyInstance(gFontPanelInfo.family, gFontPanelInfo.style, &fid, NULL) != noErr) return; ! // Request font name with Mac encoding (otherwise we could ! // get an unwanted utf-16 name) if (ATSUFindFontName(fid, kFontFullName, kFontMacintoshPlatform, kFontNoScriptCode, kFontNoLanguageCode, 255, (char *)outName, &fontNameLen, NULL) != noErr) return; ! // Only encode font size, because style (bold, italic, etc) is ! // already part of the font full name vim_snprintf((char *)styleString, FONT_STYLE_BUFFER_SIZE, ":h%d", gFontPanelInfo.size/*, ((gFontPanelInfo.style & bold)!=0 ? ":b" : ""), *************** *** 1463,1485 **** * * Returns the index inside the menu where */ ! short /* Should we return MenuItemIndex? */ gui_mac_get_menu_item_index(vimmenu_T *pMenu) { short index; short itemIndex = -1; vimmenu_T *pBrother; ! /* Only menu without parent are the: ! * -menu in the menubar ! * -popup menu ! * -toolbar (guess) ! * ! * Which are not items anyway. ! */ if (pMenu->parent) { ! /* Start from the Oldest Brother */ pBrother = pMenu->parent->children; index = 1; while ((pBrother) && (itemIndex == -1)) --- 1463,1484 ---- * * Returns the index inside the menu where */ ! short // Should we return MenuItemIndex? gui_mac_get_menu_item_index(vimmenu_T *pMenu) { short index; short itemIndex = -1; vimmenu_T *pBrother; ! // Only menu without parent are the: ! // -menu in the menubar ! // -popup menu ! // -toolbar (guess) ! // ! // Which are not items anyway. if (pMenu->parent) { ! // Start from the Oldest Brother pBrother = pMenu->parent->children; index = 1; while ((pBrother) && (itemIndex == -1)) *************** *** 1501,1513 **** vimmenu_T *pElder = pMenu->parent; ! /* Only menu without parent are the: ! * -menu in the menubar ! * -popup menu ! * -toolbar (guess) ! * ! * Which are not items anyway. ! */ if ((pElder) && (pElder->submenu_id == menuID)) { --- 1500,1511 ---- vimmenu_T *pElder = pMenu->parent; ! // Only menu without parent are the: ! // -menu in the menubar ! // -popup menu ! // -toolbar (guess) ! // ! // Which are not items anyway. if ((pElder) && (pElder->submenu_id == menuID)) { *************** *** 1554,1565 **** if (sb == NULL) return; ! /* Need to find value by diff between Old Poss New Pos */ value = GetControl32BitValue(theControlToUse); dragging = (partCode != 0); ! /* 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, value, dragging); dont_scroll = dont_scroll_save; --- 1552,1563 ---- if (sb == NULL) return; ! // Need to find value by diff between Old Poss New Pos value = GetControl32BitValue(theControlToUse); dragging = (partCode != 0); ! // 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, value, dragging); dont_scroll = dont_scroll_save; *************** *** 1569,1575 **** void gui_mac_scroll_action(ControlHandle theControl, short partCode) { ! /* TODO: have live support */ scrollbar_T *sb, *sb_info; long data; long value; --- 1567,1573 ---- void gui_mac_scroll_action(ControlHandle theControl, short partCode) { ! // TODO: have live support scrollbar_T *sb, *sb_info; long data; long value; *************** *** 1582,1588 **** if (sb == NULL) return; ! if (sb->wp != NULL) /* Left or right scrollbar */ { /* * Careful: need to get scrollbar info out of first (left) scrollbar --- 1580,1586 ---- if (sb == NULL) return; ! if (sb->wp != NULL) // Left or right scrollbar { /* * Careful: need to get scrollbar info out of first (left) scrollbar *************** *** 1592,1602 **** sb_info = &sb->wp->w_scrollbars[0]; if (sb_info->size > 5) ! page = sb_info->size - 2; /* use two lines of context */ else page = sb_info->size; } ! else /* Bottom scrollbar */ { sb_info = sb; page = curwin->w_width - 5; --- 1590,1600 ---- sb_info = &sb->wp->w_scrollbars[0]; if (sb_info->size > 5) ! page = sb_info->size - 2; // use two lines of context else page = sb_info->size; } ! else // Bottom scrollbar { sb_info = sb; page = curwin->w_width - 5; *************** *** 1612,1624 **** } value = sb_info->value + data; ! /* if (value > sb_info->max) ! value = sb_info->max; ! else if (value < 0) ! value = 0;*/ ! /* 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, value, dragging); dont_scroll = dont_scroll_save; --- 1610,1622 ---- } value = sb_info->value + data; ! // if (value > sb_info->max) ! // value = sb_info->max; ! // else if (value < 0) ! // value = 0; ! // 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, value, dragging); dont_scroll = dont_scroll_save; *************** *** 1626,1632 **** out_flush(); gui_mch_set_scrollbar_thumb(sb, value, sb_info->size, sb_info->max); ! /* if (sb_info->wp != NULL) { win_T *wp; int sb_num; --- 1624,1631 ---- out_flush(); gui_mch_set_scrollbar_thumb(sb, value, sb_info->size, sb_info->max); ! #if 0 ! if (sb_info->wp != NULL) { win_T *wp; int sb_num; *************** *** 1642,1648 **** gui_do_scroll(); gui_mch_set_scrollbar_thumb(sb, value, sb_info->size, sb_info->max); } ! }*/ } /* --- 1641,1648 ---- gui_do_scroll(); gui_mch_set_scrollbar_thumb(sb, value, sb_info->size, sb_info->max); } ! } ! #endif } /* *************** *** 1676,1682 **** if (theControl != NUL) { ! /* We hit a scrollbar */ if (thePortion != kControlIndicatorPart) { --- 1676,1682 ---- if (theControl != NUL) { ! // We hit a scrollbar if (thePortion != kControlIndicatorPart) { *************** *** 1692,1715 **** #else TrackControl(theControl, thePoint, NULL); #endif ! /* pass 0 as the part to tell gui_mac_drag_thumb, that the mouse ! * button has been released */ ! gui_mac_drag_thumb(theControl, 0); /* Should it be thePortion ? (Dany) */ dragged_sb = NULL; } } else { ! /* We are inside the contents */ ! /* Convert the CTRL, OPTION, SHIFT and CMD key */ vimModifiers = EventModifiers2VimMouseModifiers(theEvent->modifiers); ! /* Defaults to MOUSE_LEFT as there's only one mouse button */ vimMouseButton = MOUSE_LEFT; ! /* Convert the CTRL_MOUSE_LEFT to MOUSE_RIGHT */ ! /* TODO: NEEDED? */ clickIsPopup = FALSE; if (mouse_model_popup() && IsShowContextualMenuClick(theEvent)) --- 1692,1715 ---- #else TrackControl(theControl, thePoint, NULL); #endif ! // pass 0 as the part to tell gui_mac_drag_thumb, that the mouse ! // button has been released ! gui_mac_drag_thumb(theControl, 0); // Should it be thePortion ? (Dany) dragged_sb = NULL; } } else { ! // We are inside the contents ! // Convert the CTRL, OPTION, SHIFT and CMD key vimModifiers = EventModifiers2VimMouseModifiers(theEvent->modifiers); ! // Defaults to MOUSE_LEFT as there's only one mouse button vimMouseButton = MOUSE_LEFT; ! // Convert the CTRL_MOUSE_LEFT to MOUSE_RIGHT ! // TODO: NEEDED? clickIsPopup = FALSE; if (mouse_model_popup() && IsShowContextualMenuClick(theEvent)) *************** *** 1719,1738 **** clickIsPopup = TRUE; } ! /* Is it a double click ? */ dblClick = ((theEvent->when - lastMouseTick) < GetDblTime()); ! /* Send the mouse click to Vim */ gui_send_mouse_event(vimMouseButton, thePoint.h, thePoint.v, dblClick, vimModifiers); ! /* Create the rectangle around the cursor to detect ! * the mouse dragging ! */ #if 0 ! /* TODO: Do we need to this even for the contextual menu? ! * It may be require for popup_setpos, but for popup? ! */ if (vimMouseButton == MOUSE_LEFT) #endif { --- 1719,1736 ---- clickIsPopup = TRUE; } ! // Is it a double click ? dblClick = ((theEvent->when - lastMouseTick) < GetDblTime()); ! // Send the mouse click to Vim gui_send_mouse_event(vimMouseButton, thePoint.h, thePoint.v, dblClick, vimModifiers); ! // Create the rectangle around the cursor to detect ! // the mouse dragging #if 0 ! // TODO: Do we need to this even for the contextual menu? ! // It may be require for popup_setpos, but for popup? if (vimMouseButton == MOUSE_LEFT) #endif { *************** *** 1756,1762 **** Rect movingLimits; Rect *movingLimitsPtr = &movingLimits; ! /* TODO: may try to prevent move outside screen? */ movingLimitsPtr = GetRegionBounds(GetGrayRgn(), &movingLimits); DragWindow(whichWindow, where, movingLimitsPtr); } --- 1754,1760 ---- Rect movingLimits; Rect *movingLimitsPtr = &movingLimits; ! // TODO: may try to prevent move outside screen? movingLimitsPtr = GetRegionBounds(GetGrayRgn(), &movingLimits); DragWindow(whichWindow, where, movingLimitsPtr); } *************** *** 1777,1784 **** resizeLimitsPtr = GetRegionBounds(GetGrayRgn(), &resizeLimits); ! /* Set the minimum size */ ! /* TODO: Should this come from Vim? */ resizeLimits.top = 100; resizeLimits.left = 100; --- 1775,1782 ---- resizeLimitsPtr = GetRegionBounds(GetGrayRgn(), &resizeLimits); ! // Set the minimum size ! // TODO: Should this come from Vim? resizeLimits.top = 100; resizeLimits.left = 100; *************** *** 1800,1812 **** Point p; short thePart; ! /* ideal width is current */ p.h = Columns * gui.char_width + 2 * gui.border_offset; if (gui.which_scrollbars[SBAR_LEFT]) p.h += gui.scrollbar_width; if (gui.which_scrollbars[SBAR_RIGHT]) p.h += gui.scrollbar_width; ! /* ideal height is as high as we can get */ p.v = 15 * 1024; thePart = IsWindowInStandardState(whichWindow, &p, &r) --- 1798,1810 ---- Point p; short thePart; ! // ideal width is current p.h = Columns * gui.char_width + 2 * gui.border_offset; if (gui.which_scrollbars[SBAR_LEFT]) p.h += gui.scrollbar_width; if (gui.which_scrollbars[SBAR_RIGHT]) p.h += gui.scrollbar_width; ! // ideal height is as high as we can get p.v = 15 * 1024; thePart = IsWindowInStandardState(whichWindow, &p, &r) *************** *** 1815,1823 **** if (!TrackBox(whichWindow, theEvent->where, thePart)) return; ! /* use returned width */ p.h = r.right - r.left; ! /* adjust returned height */ p.v = r.bottom - r.top - 2 * gui.border_offset; if (gui.which_scrollbars[SBAR_BOTTOM]) p.v -= gui.scrollbar_height; --- 1813,1821 ---- if (!TrackBox(whichWindow, theEvent->where, thePart)) return; ! // use returned width p.h = r.right - r.left; ! // adjust returned height p.v = r.bottom - r.top - 2 * gui.border_offset; if (gui.which_scrollbars[SBAR_BOTTOM]) p.v -= gui.scrollbar_height; *************** *** 1861,1906 **** if (updateRgn == NULL) return; ! /* This could be done by the caller as we ! * don't require anything else out of the event ! */ whichWindow = (WindowPtr) event->message; ! /* Save Current Port */ GetPort(&savePort); ! /* Select the Window's Port */ SetPortWindowPort(whichWindow); ! /* Let's update the window */ BeginUpdate(whichWindow); ! /* Redraw the biggest rectangle covering the area ! * to be updated. ! */ GetPortVisibleRegion(GetWindowPort(whichWindow), updateRgn); # if 0 ! /* Would be more appropriate to use the following but doesn't ! * seem to work under MacOS X (Dany) ! */ GetWindowRegion(whichWindow, kWindowUpdateRgn, updateRgn); # endif ! /* Use the HLock useless in Carbon? Is it harmful?*/ HLock((Handle) updateRgn); updateRectPtr = GetRegionBounds(updateRgn, &updateRect); # if 0 ! /* Code from original Carbon Port (using GetWindowRegion. ! * I believe the UpdateRgn is already in local (Dany) ! */ ! GlobalToLocal(&topLeft(updateRect)); /* preCarbon? */ GlobalToLocal(&botRight(updateRect)); # endif ! /* Update the content (i.e. the text) */ gui_redraw(updateRectPtr->left, updateRectPtr->top, updateRectPtr->right - updateRectPtr->left, updateRectPtr->bottom - updateRectPtr->top); ! /* Clear the border areas if needed */ gui_mch_set_bg_color(gui.back_pixel); if (updateRectPtr->left < FILL_X(0)) { --- 1859,1900 ---- if (updateRgn == NULL) return; ! // This could be done by the caller as we ! // don't require anything else out of the event whichWindow = (WindowPtr) event->message; ! // Save Current Port GetPort(&savePort); ! // Select the Window's Port SetPortWindowPort(whichWindow); ! // Let's update the window BeginUpdate(whichWindow); ! // Redraw the biggest rectangle covering the area ! // to be updated. GetPortVisibleRegion(GetWindowPort(whichWindow), updateRgn); # if 0 ! // Would be more appropriate to use the following but doesn't ! // seem to work under MacOS X (Dany) GetWindowRegion(whichWindow, kWindowUpdateRgn, updateRgn); # endif ! // Use the HLock useless in Carbon? Is it harmful? HLock((Handle) updateRgn); updateRectPtr = GetRegionBounds(updateRgn, &updateRect); # if 0 ! // Code from original Carbon Port (using GetWindowRegion. ! // I believe the UpdateRgn is already in local (Dany) ! GlobalToLocal(&topLeft(updateRect)); // preCarbon? GlobalToLocal(&botRight(updateRect)); # endif ! // Update the content (i.e. the text) gui_redraw(updateRectPtr->left, updateRectPtr->top, updateRectPtr->right - updateRectPtr->left, updateRectPtr->bottom - updateRectPtr->top); ! // Clear the border areas if needed gui_mch_set_bg_color(gui.back_pixel); if (updateRectPtr->left < FILL_X(0)) { *************** *** 1927,1937 **** HUnlock((Handle) updateRgn); DisposeRgn(updateRgn); ! /* Update scrollbars */ DrawControls(whichWindow); ! /* Update the GrowBox */ ! /* Taken from FAQ 33-27 */ saveRgn = NewRgn(); GetWindowBounds(whichWindow, kWindowGrowRgn, &growRect); GetClip(saveRgn); --- 1921,1931 ---- HUnlock((Handle) updateRgn); DisposeRgn(updateRgn); ! // Update scrollbars DrawControls(whichWindow); ! // Update the GrowBox ! // Taken from FAQ 33-27 saveRgn = NewRgn(); GetWindowBounds(whichWindow, kWindowGrowRgn, &growRect); GetClip(saveRgn); *************** *** 1941,1947 **** DisposeRgn(saveRgn); EndUpdate(whichWindow); ! /* Restore original Port */ SetPort(savePort); } --- 1935,1941 ---- DisposeRgn(saveRgn); EndUpdate(whichWindow); ! // Restore original Port SetPort(savePort); } *************** *** 1955,1961 **** WindowPtr whichWindow; whichWindow = (WindowPtr) event->message; ! /* Dim scrollbars */ if (whichWindow == gui.VimWindow) { ControlRef rootControl; --- 1949,1955 ---- WindowPtr whichWindow; whichWindow = (WindowPtr) event->message; ! // Dim scrollbars if (whichWindow == gui.VimWindow) { ControlRef rootControl; *************** *** 1966,1972 **** DeactivateControl(rootControl); } ! /* Activate */ gui_focus_change((event->modifiers) & activeFlag); } --- 1960,1966 ---- DeactivateControl(rootControl); } ! // Activate gui_focus_change((event->modifiers) & activeFlag); } *************** *** 1978,1997 **** void gui_mac_doSuspendEvent(EventRecord *event) { ! /* The frontmost application just changed */ ! /* NOTE: the suspend may happen before the deactivate ! * seen on MacOS X ! */ ! /* May not need to change focus as the window will ! * get an activate/deactivate event ! */ if (event->message & 1) ! /* Resume */ gui_focus_change(TRUE); else ! /* Suspend */ gui_focus_change(FALSE); } --- 1972,1989 ---- void gui_mac_doSuspendEvent(EventRecord *event) { ! // The frontmost application just changed ! // NOTE: the suspend may happen before the deactivate ! // seen on MacOS X ! // May not need to change focus as the window will ! // get an activate/deactivate event if (event->message & 1) ! // Resume gui_focus_change(TRUE); else ! // Suspend gui_focus_change(FALSE); } *************** *** 2068,2075 **** return eventNotHandledErr; } ! static int dialog_busy = FALSE; /* TRUE when gui_mch_dialog() wants the ! keys */ # define INLINE_KEY_BUFFER_SIZE 80 static pascal OSStatus --- 2060,2067 ---- return eventNotHandledErr; } ! static int dialog_busy = FALSE; // TRUE when gui_mch_dialog() wants the ! // keys # define INLINE_KEY_BUFFER_SIZE 80 static pascal OSStatus *************** *** 2077,2083 **** EventHandlerCallRef nextHandler, EventRef theEvent) { ! /* Multibyte-friendly key event handler */ OSStatus err = -1; UInt32 actualSize; UniChar *text; --- 2069,2075 ---- EventHandlerCallRef nextHandler, EventRef theEvent) { ! // Multibyte-friendly key event handler OSStatus err = -1; UInt32 actualSize; UniChar *text; *************** *** 2093,2103 **** int i; EventRef keyEvent; ! /* Mask the mouse (as per user setting) */ if (p_mh) ObscureCursor(); ! /* Don't use the keys when the dialog wants them. */ if (dialog_busy) return eventNotHandledErr; --- 2085,2095 ---- int i; EventRef keyEvent; ! // Mask the mouse (as per user setting) if (p_mh) ObscureCursor(); ! // Don't use the keys when the dialog wants them. if (dialog_busy) return eventNotHandledErr; *************** *** 2131,2143 **** #ifndef USE_CMD_KEY if (modifiers & cmdKey) ! goto done; /* Let system handle Cmd+... */ #endif key_char = charcode; vimModifiers = EventModifiers2VimModifiers(modifiers); ! /* Find the special key (eg., for cursor keys) */ if (actualSize <= sizeof(UniChar) && ((text[0] < 0x20) || (text[0] == 0x7f))) { --- 2123,2135 ---- #ifndef USE_CMD_KEY if (modifiers & cmdKey) ! goto done; // Let system handle Cmd+... #endif key_char = charcode; vimModifiers = EventModifiers2VimModifiers(modifiers); ! // Find the special key (eg., for cursor keys) if (actualSize <= sizeof(UniChar) && ((text[0] < 0x20) || (text[0] == 0x7f))) { *************** *** 2153,2182 **** } } ! /* Intercept CMD-. and CTRL-c */ if (((modifiers & controlKey) && key_char == 'c') || ((modifiers & cmdKey) && key_char == '.')) got_int = TRUE; if (!isSpecial) { ! /* remove SHIFT for keys that are already shifted, e.g., ! * '(' and '*' */ if (key_char < 0x100 && !isalpha(key_char) && isprint(key_char)) vimModifiers &= ~MOD_MASK_SHIFT; ! /* remove CTRL from keys that already have it */ if (key_char < 0x20) vimModifiers &= ~MOD_MASK_CTRL; ! /* don't process unicode characters here */ if (!IS_SPECIAL(key_char)) { ! /* Following code to simplify and consolidate vimModifiers ! * taken liberally from gui_w48.c */ key_char = simplify_key(key_char, (int *)&vimModifiers); ! /* Interpret META, include SHIFT, etc. */ key_char = extract_modifiers(key_char, (int *)&vimModifiers, TRUE, NULL); if (key_char == CSI) --- 2145,2174 ---- } } ! // Intercept CMD-. and CTRL-c if (((modifiers & controlKey) && key_char == 'c') || ((modifiers & cmdKey) && key_char == '.')) got_int = TRUE; if (!isSpecial) { ! // remove SHIFT for keys that are already shifted, e.g., ! // '(' and '*' if (key_char < 0x100 && !isalpha(key_char) && isprint(key_char)) vimModifiers &= ~MOD_MASK_SHIFT; ! // remove CTRL from keys that already have it if (key_char < 0x20) vimModifiers &= ~MOD_MASK_CTRL; ! // don't process unicode characters here if (!IS_SPECIAL(key_char)) { ! // Following code to simplify and consolidate vimModifiers ! // taken liberally from gui_w48.c key_char = simplify_key(key_char, (int *)&vimModifiers); ! // Interpret META, include SHIFT, etc. key_char = extract_modifiers(key_char, (int *)&vimModifiers, TRUE, NULL); if (key_char == CSI) *************** *** 2206,2212 **** to = mac_utf16_to_enc(text, actualSize, &encLen); if (to) { ! /* This is basically add_to_input_buf_csi() */ for (i = 0; i < encLen && len < (INLINE_KEY_BUFFER_SIZE-1); ++i) { result[len++] = to[i]; --- 2198,2204 ---- to = mac_utf16_to_enc(text, actualSize, &encLen); if (to) { ! // This is basically add_to_input_buf_csi() for (i = 0; i < encLen && len < (INLINE_KEY_BUFFER_SIZE-1); ++i) { result[len++] = to[i]; *************** *** 2227,2234 **** vim_free(text); if (err == noErr) { ! /* Fake event to wake up WNE (required to get ! * key repeat working */ PostEvent(keyUp, 0); return noErr; } --- 2219,2226 ---- vim_free(text); if (err == noErr) { ! // Fake event to wake up WNE (required to get ! // key repeat working PostEvent(keyUp, 0); return noErr; } *************** *** 2239,2245 **** void gui_mac_doKeyEvent(EventRecord *theEvent) { ! /* TODO: add support for COMMAND KEY */ long menu; unsigned char string[20]; short num, i; --- 2231,2237 ---- void gui_mac_doKeyEvent(EventRecord *theEvent) { ! // TODO: add support for COMMAND KEY long menu; unsigned char string[20]; short num, i; *************** *** 2249,2264 **** int modifiers; int simplify = FALSE; ! /* Mask the mouse (as per user setting) */ if (p_mh) ObscureCursor(); ! /* Get the key code and its ASCII representation */ key_sym = ((theEvent->message & keyCodeMask) >> 8); key_char = theEvent->message & charCodeMask; num = 1; ! /* Intercept CTRL-C */ if (theEvent->modifiers & controlKey) { if (key_char == Ctrl_C && ctrl_c_interrupts) --- 2241,2256 ---- int modifiers; int simplify = FALSE; ! // Mask the mouse (as per user setting) if (p_mh) ObscureCursor(); ! // Get the key code and its ASCII representation key_sym = ((theEvent->message & keyCodeMask) >> 8); key_char = theEvent->message & charCodeMask; num = 1; ! // Intercept CTRL-C if (theEvent->modifiers & controlKey) { if (key_char == Ctrl_C && ctrl_c_interrupts) *************** *** 2266,2272 **** else if ((theEvent->modifiers & ~(controlKey|shiftKey)) == 0 && (key_char == '2' || key_char == '6')) { ! /* CTRL-^ and CTRL-@ don't work in the normal way. */ if (key_char == '2') key_char = Ctrl_AT; else --- 2258,2264 ---- else if ((theEvent->modifiers & ~(controlKey|shiftKey)) == 0 && (key_char == '2' || key_char == '6')) { ! // CTRL-^ and CTRL-@ don't work in the normal way. if (key_char == '2') key_char = Ctrl_AT; else *************** *** 2275,2290 **** } } ! /* Intercept CMD-. */ if (theEvent->modifiers & cmdKey) if (key_char == '.') got_int = TRUE; ! /* Handle command key as per menu */ ! /* TODO: should override be allowed? Require YAO or could use 'winaltkey' */ if (theEvent->modifiers & cmdKey) ! /* Only accept CMD alone or with CAPLOCKS and the mouse button. ! * Why the mouse button? */ if ((theEvent->modifiers & (~(cmdKey | btnState | alphaLock))) == 0) { menu = MenuKey(key_char); --- 2267,2282 ---- } } ! // Intercept CMD-. if (theEvent->modifiers & cmdKey) if (key_char == '.') got_int = TRUE; ! // Handle command key as per menu ! // TODO: should override be allowed? Require YAO or could use 'winaltkey' if (theEvent->modifiers & cmdKey) ! // Only accept CMD alone or with CAPLOCKS and the mouse button. ! // Why the mouse button? if ((theEvent->modifiers & (~(cmdKey | btnState | alphaLock))) == 0) { menu = MenuKey(key_char); *************** *** 2295,2317 **** } } ! /* Convert the modifiers */ modifiers = EventModifiers2VimModifiers(theEvent->modifiers); ! /* Handle special keys. */ #if 0 ! /* Why has this been removed? */ if (!(theEvent->modifiers & (cmdKey | controlKey | rightControlKey))) #endif { ! /* Find the special key (for non-printable keyt_char) */ if ((key_char < 0x20) || (key_char == 0x7f)) for (i = 0; special_keys[i].key_sym != (KeySym)0; i++) if (special_keys[i].key_sym == key_sym) { # if 0 ! /* We currently don't have not so special key */ if (special_keys[i].vim_code1 == NUL) key_char = special_keys[i].vim_code0; else --- 2287,2309 ---- } } ! // Convert the modifiers modifiers = EventModifiers2VimModifiers(theEvent->modifiers); ! // Handle special keys. #if 0 ! // Why has this been removed? if (!(theEvent->modifiers & (cmdKey | controlKey | rightControlKey))) #endif { ! // Find the special key (for non-printable keyt_char) if ((key_char < 0x20) || (key_char == 0x7f)) for (i = 0; special_keys[i].key_sym != (KeySym)0; i++) if (special_keys[i].key_sym == key_sym) { # if 0 ! // We currently don't have not so special key if (special_keys[i].vim_code1 == NUL) key_char = special_keys[i].vim_code0; else *************** *** 2323,2334 **** } } ! /* For some keys the modifier is included in the char itself. */ if (simplify || key_char == TAB || key_char == ' ') key_char = simplify_key(key_char, &modifiers); ! /* Add the modifier to the input bu if needed */ ! /* Do not want SHIFT-A or CTRL-A with modifier */ if (!IS_SPECIAL(key_char) && key_sym != vk_Space && key_sym != vk_Tab --- 2315,2326 ---- } } ! // For some keys the modifier is included in the char itself. if (simplify || key_char == TAB || key_char == ' ') key_char = simplify_key(key_char, &modifiers); ! // Add the modifier to the input bu if needed ! // Do not want SHIFT-A or CTRL-A with modifier if (!IS_SPECIAL(key_char) && key_sym != vk_Space && key_sym != vk_Tab *************** *** 2337,2343 **** && key_sym != vk_Esc) { #if 1 ! /* Clear modifiers when only one modifier is set */ if ((modifiers == MOD_MASK_SHIFT) || (modifiers == MOD_MASK_CTRL) || (modifiers == MOD_MASK_ALT)) --- 2329,2335 ---- && key_sym != vk_Esc) { #if 1 ! // Clear modifiers when only one modifier is set if ((modifiers == MOD_MASK_SHIFT) || (modifiers == MOD_MASK_CTRL) || (modifiers == MOD_MASK_ALT)) *************** *** 2366,2373 **** } else { ! /* Convert characters when needed (e.g., from MacRoman to latin1). ! * This doesn't work for the NUL byte. */ if (input_conv.vc_type != CONV_NONE && key_char > 0) { char_u from[2], *to; --- 2358,2365 ---- } else { ! // Convert characters when needed (e.g., from MacRoman to latin1). ! // This doesn't work for the NUL byte. if (input_conv.vc_type != CONV_NONE && key_char > 0) { char_u from[2], *to; *************** *** 2400,2406 **** if (len == 1 && string[0] == CSI) { ! /* Turn CSI into K_CSI. */ string[ len++ ] = KS_EXTRA; string[ len++ ] = KE_CSI; } --- 2392,2398 ---- if (len == 1 && string[0] == CSI) { ! // Turn CSI into K_CSI. string[ len++ ] = KS_EXTRA; string[ len++ ] = KE_CSI; } *************** *** 2421,2428 **** thePart = FindWindow(theEvent->where, &whichWindow); #ifdef FEAT_GUI_TABLINE ! /* prevent that the vim window size changes if it's activated by a ! click into the tab pane */ if (whichWindow == drawer) return; #endif --- 2413,2420 ---- thePart = FindWindow(theEvent->where, &whichWindow); #ifdef FEAT_GUI_TABLINE ! // prevent that the vim window size changes if it's activated by a ! // click into the tab pane if (whichWindow == drawer) return; #endif *************** *** 2430,2436 **** switch (thePart) { case (inDesk): ! /* TODO: what to do? */ break; case (inMenuBar): --- 2422,2428 ---- switch (thePart) { case (inDesk): ! // TODO: what to do? break; case (inMenuBar): *************** *** 2482,2488 **** gui_send_mouse_event(MOUSE_DRAG, thePoint.h, thePoint.v, FALSE, vimModifiers); ! /* Reset the region from which we move in and out */ SetRect(&dragRect, FILL_X(X_2_COL(thePoint.h)), FILL_Y(Y_2_ROW(thePoint.v)), FILL_X(X_2_COL(thePoint.h)+1), --- 2474,2480 ---- gui_send_mouse_event(MOUSE_DRAG, thePoint.h, thePoint.v, FALSE, vimModifiers); ! // Reset the region from which we move in and out SetRect(&dragRect, FILL_X(X_2_COL(thePoint.h)), FILL_Y(Y_2_ROW(thePoint.v)), FILL_X(X_2_COL(thePoint.h)+1), *************** *** 2502,2509 **** Point thePoint; int_u vimModifiers; ! /* TODO: Properly convert the Contextual menu mouse-up */ ! /* Potential source of the double menu */ lastMouseTick = theEvent->when; dragRectEnbl = FALSE; dragRectControl = kCreateEmpty; --- 2494,2501 ---- Point thePoint; int_u vimModifiers; ! // TODO: Properly convert the Contextual menu mouse-up ! // Potential source of the double menu lastMouseTick = theEvent->when; dragRectEnbl = FALSE; dragRectControl = kCreateEmpty; *************** *** 2533,2539 **** if (noErr == GetEventParameter(theEvent, kEventParamMouseWheelAxis, typeMouseWheelAxis, NULL, sizeof(axis), NULL, &axis) && axis != kEventMouseWheelAxisY) ! goto bail; /* Vim only does up-down scrolling */ if (noErr != GetEventParameter(theEvent, kEventParamMouseWheelDelta, typeSInt32, NULL, sizeof(SInt32), NULL, &delta)) --- 2525,2531 ---- if (noErr == GetEventParameter(theEvent, kEventParamMouseWheelAxis, typeMouseWheelAxis, NULL, sizeof(axis), NULL, &axis) && axis != kEventMouseWheelAxisY) ! goto bail; // Vim only does up-down scrolling if (noErr != GetEventParameter(theEvent, kEventParamMouseWheelDelta, typeSInt32, NULL, sizeof(SInt32), NULL, &delta)) *************** *** 2562,2568 **** gui_send_mouse_event((delta > 0) ? MOUSE_4 : MOUSE_5, point.h, point.v, FALSE, vim_mod); ! /* post a bogus event to wake up WaitNextEvent */ PostEvent(keyUp, 0); return noErr; --- 2554,2560 ---- gui_send_mouse_event((delta > 0) ? MOUSE_4 : MOUSE_5, point.h, point.v, FALSE, vim_mod); ! // post a bogus event to wake up WaitNextEvent PostEvent(keyUp, 0); return noErr; *************** *** 2578,2584 **** void gui_mch_mousehide(int hide) { ! /* TODO */ } #if 0 --- 2570,2576 ---- void gui_mch_mousehide(int hide) { ! // TODO } #if 0 *************** *** 2605,2618 **** if (CntxType == kCMMenuItemSelected) { ! /* Handle the menu CntxMenuID, CntxMenuItem */ ! /* The submenu can be handle directly by gui_mac_handle_menu */ ! /* But what about the current menu, is the many changed by ContextualMenuSelect */ gui_mac_handle_menu((CntxMenuID << 16) + CntxMenuItem); } else if (CntxMenuID == kCMShowHelpSelected) { ! /* Should come up with the help */ } } --- 2597,2610 ---- if (CntxType == kCMMenuItemSelected) { ! // Handle the menu CntxMenuID, CntxMenuItem ! // The submenu can be handle directly by gui_mac_handle_menu ! // But what about the current menu, is the many changed by ContextualMenuSelect gui_mac_handle_menu((CntxMenuID << 16) + CntxMenuItem); } else if (CntxMenuID == kCMShowHelpSelected) { ! // Should come up with the help } } *************** *** 2628,2637 **** short item = LoWord(menuChoice); vimmenu_T *theVimMenu = root_menu; ! if (menu == 256) /* TODO: use constant or gui.xyz */ { if (item == 1) ! gui_mch_beep(); /* TODO: Popup dialog or do :intro */ } else if (item != 0) { --- 2620,2629 ---- short item = LoWord(menuChoice); vimmenu_T *theVimMenu = root_menu; ! if (menu == 256) // TODO: use constant or gui.xyz { if (item == 1) ! gui_mch_beep(); // TODO: Popup dialog or do :intro } else if (item != 0) { *************** *** 2652,2658 **** { OSErr error; ! /* Handle contextual menu right now (if needed) */ if (IsShowContextualMenuClick(event)) { # if 0 --- 2644,2650 ---- { OSErr error; ! // Handle contextual menu right now (if needed) if (IsShowContextualMenuClick(event)) { # if 0 *************** *** 2663,2669 **** return; } ! /* Handle normal event */ switch (event->what) { #ifndef USE_CARBONKEYHANDLER --- 2655,2661 ---- return; } ! // Handle normal event switch (event->what) { #ifndef USE_CARBONKEYHANDLER *************** *** 2673,2679 **** break; #endif case (keyUp): ! /* We don't care about when the key is released */ break; case (mouseDown): --- 2665,2671 ---- break; #endif case (keyUp): ! // We don't care about when the key is released break; case (mouseDown): *************** *** 2689,2695 **** break; case (diskEvt): ! /* We don't need special handling for disk insertion */ break; case (activateEvt): --- 2681,2687 ---- break; case (diskEvt): ! // We don't need special handling for disk insertion break; case (activateEvt): *************** *** 2699,2708 **** case (osEvt): switch ((event->message >> 24) & 0xFF) { ! case (0xFA): /* mouseMovedMessage */ gui_mac_doMouseMovedEvent(event); break; ! case (0x01): /* suspendResumeMessage */ gui_mac_doSuspendEvent(event); break; } --- 2691,2700 ---- case (osEvt): switch ((event->message >> 24) & 0xFF) { ! case (0xFA): // mouseMovedMessage gui_mac_doMouseMovedEvent(event); break; ! case (0x01): // suspendResumeMessage gui_mac_doSuspendEvent(event); break; } *************** *** 2710,2717 **** #ifdef USE_AEVENT case (kHighLevelEvent): ! /* Someone's talking to us, through AppleEvents */ ! error = AEProcessAppleEvent(event); /* TODO: Error Handling */ break; #endif } --- 2702,2709 ---- #ifdef USE_AEVENT case (kHighLevelEvent): ! // Someone's talking to us, through AppleEvents ! error = AEProcessAppleEvent(event); // TODO: Error Handling break; #endif } *************** *** 2749,2755 **** pFontName[0] = STRLEN(font_name); *p = c; ! /* Get the font name, minus the style suffix (:h, etc) */ char_u fontName[256]; char_u *styleStart = vim_strchr(font_name, ':'); size_t fontNameLen = styleStart ? styleStart - font_name : STRLEN(fontName); --- 2741,2747 ---- pFontName[0] = STRLEN(font_name); *p = c; ! // Get the font name, minus the style suffix (:h, etc) char_u fontName[256]; char_u *styleStart = vim_strchr(font_name, ':'); size_t fontNameLen = styleStart ? styleStart - font_name : STRLEN(fontName); *************** *** 2795,2801 **** } #else ! /* name = C2Pascal_save(menu->dname); */ fontNamePtr = C2Pascal_save_and_remove_backslash(font_name); GetFNum(fontNamePtr, &font_id); --- 2787,2793 ---- } #else ! // name = C2Pascal_save(menu->dname); fontNamePtr = C2Pascal_save_and_remove_backslash(font_name); GetFNum(fontNamePtr, &font_id); *************** *** 2804,2810 **** if (font_id == 0) { ! /* Oups, the system font was it the one the user want */ if (FMGetFontFamilyName(systemFont, systemFontname) != noErr) return NOFONT; --- 2796,2802 ---- if (font_id == 0) { ! // Oups, the system font was it the one the user want if (FMGetFontFamilyName(systemFont, systemFontname) != noErr) return NOFONT; *************** *** 2814,2820 **** if (*p == ':') { p++; ! /* Set the values found after ':' */ while (*p) { switch (*p++) --- 2806,2812 ---- if (*p == ':') { p++; ! // Set the values found after ':' while (*p) { switch (*p++) *************** *** 2832,2838 **** } if (size < 1) ! size = 1; /* Avoid having a size of 0 with system font */ font = (size << 16) + ((long) font_id & 0xFFFF); --- 2824,2830 ---- } if (size < 1) ! size = 1; // Avoid having a size of 0 with system font font = (size << 16) + ((long) font_id & 0xFFFF); *************** *** 2853,2859 **** void gui_mch_prepare(int *argc, char **argv) { ! /* TODO: Move most of this stuff toward gui_mch_init */ #ifdef USE_EXE_NAME FSSpec applDir; # ifndef USE_FIND_BUNDLE_PATH --- 2845,2851 ---- void gui_mch_prepare(int *argc, char **argv) { ! // TODO: Move most of this stuff toward gui_mch_init #ifdef USE_EXE_NAME FSSpec applDir; # ifndef USE_FIND_BUNDLE_PATH *************** *** 2875,2881 **** (void) InstallAEHandlers(); #endif ! pomme = NewMenu(256, "\p\024"); /* 0x14= = Apple Menu */ AppendMenu(pomme, "\pAbout VIM"); --- 2867,2873 ---- (void) InstallAEHandlers(); #endif ! pomme = NewMenu(256, "\p\024"); // 0x14= = Apple Menu AppendMenu(pomme, "\pAbout VIM"); *************** *** 2901,2907 **** gui.char_ascent = 6; gui.num_rows = 24; gui.num_cols = 80; ! gui.in_focus = TRUE; /* For the moment -> syn. of front application */ gScrollAction = NewControlActionUPP(gui_mac_scroll_action); gScrollDrag = NewControlActionUPP(gui_mac_drag_thumb); --- 2893,2899 ---- gui.char_ascent = 6; gui.num_rows = 24; gui.num_cols = 80; ! gui.in_focus = TRUE; // For the moment -> syn. of front application gScrollAction = NewControlActionUPP(gui_mac_scroll_action); gScrollDrag = NewControlActionUPP(gui_mac_drag_thumb); *************** *** 2914,2934 **** #ifdef USE_EXE_NAME # ifndef USE_FIND_BUNDLE_PATH HGetVol(volName, &applVRefNum, &applDirID); ! /* TN2015: mention a possible bad VRefNum */ FSMakeFSSpec(applVRefNum, applDirID, "\p", &applDir); # else ! /* OSErr GetApplicationBundleFSSpec(FSSpecPtr theFSSpecPtr) ! * of TN2015 ! */ (void)GetCurrentProcess(&psn); ! /* if (err != noErr) return err; */ (void)GetProcessBundleLocation(&psn, &applFSRef); ! /* if (err != noErr) return err; */ (void)FSGetCatalogInfo(&applFSRef, kFSCatInfoNone, NULL, NULL, &applDir, NULL); ! /* This technic return NIL when we disallow_gui */ # endif exe_name = FullPathFromFSSpec_save(applDir); #endif --- 2906,2925 ---- #ifdef USE_EXE_NAME # ifndef USE_FIND_BUNDLE_PATH HGetVol(volName, &applVRefNum, &applDirID); ! // TN2015: mention a possible bad VRefNum FSMakeFSSpec(applVRefNum, applDirID, "\p", &applDir); # else ! // OSErr GetApplicationBundleFSSpec(FSSpecPtr theFSSpecPtr) ! // of TN2015 (void)GetCurrentProcess(&psn); ! // if (err != noErr) return err; (void)GetProcessBundleLocation(&psn, &applFSRef); ! // if (err != noErr) return err; (void)FSGetCatalogInfo(&applFSRef, kFSCatInfoNone, NULL, NULL, &applDir, NULL); ! // This technic return NIL when we disallow_gui # endif exe_name = FullPathFromFSSpec_save(applDir); #endif *************** *** 2942,2951 **** int gui_mch_init_check(void) { ! /* TODO: For MacOS X find a way to return FAIL, if the user logged in ! * using the >console ! */ ! if (disallow_gui) /* see main.c for reason to disallow */ return FAIL; return OK; } --- 2933,2941 ---- int gui_mch_init_check(void) { ! // TODO: For MacOS X find a way to return FAIL, if the user logged in ! // using the >console ! if (disallow_gui) // see main.c for reason to disallow return FAIL; return OK; } *************** *** 2960,2966 **** int count; int i, j; ! /* Get drop position, modifiers and count of items */ { Point point; SInt16 mouseUpModifiers; --- 2950,2956 ---- int count; int i, j; ! // Get drop position, modifiers and count of items { Point point; SInt16 mouseUpModifiers; *************** *** 2980,2986 **** if (fnames == NULL) return dragNotAcceptedErr; ! /* Get file names dropped */ for (i = j = 0; i < count; ++i) { DragItemRef item; --- 2970,2976 ---- if (fnames == NULL) return dragNotAcceptedErr; ! // Get file names dropped for (i = j = 0; i < count; ++i) { DragItemRef item; *************** *** 3003,3009 **** gui_handle_drop(x, y, modifiers, fnames, count); ! /* Fake mouse event to wake from stall */ PostEvent(mouseUp, 0); return noErr; --- 2993,2999 ---- gui_handle_drop(x, y, modifiers, fnames, count); ! // Fake mouse event to wake from stall PostEvent(mouseUp, 0); return noErr; *************** *** 3016,3022 **** int gui_mch_init(void) { ! /* TODO: Move most of this stuff toward gui_mch_init */ Rect windRect; MenuHandle pomme; EventHandlerRef mouseWheelHandlerRef; --- 3006,3012 ---- int gui_mch_init(void) { ! // TODO: Move most of this stuff toward gui_mch_init Rect windRect; MenuHandle pomme; EventHandlerRef mouseWheelHandlerRef; *************** *** 3024,3030 **** ControlRef rootControl; if (Gestalt(gestaltSystemVersion, &gMacSystemVersion) != noErr) ! gMacSystemVersion = 0x1000; /* TODO: Default to minimum sensible value */ #if 1 InitCursor(); --- 3014,3020 ---- ControlRef rootControl; if (Gestalt(gestaltSystemVersion, &gMacSystemVersion) != noErr) ! gMacSystemVersion = 0x1000; // TODO: Default to minimum sensible value #if 1 InitCursor(); *************** *** 3035,3041 **** (void) InstallAEHandlers(); #endif ! pomme = NewMenu(256, "\p\024"); /* 0x14= = Apple Menu */ AppendMenu(pomme, "\pAbout VIM"); --- 3025,3031 ---- (void) InstallAEHandlers(); #endif ! pomme = NewMenu(256, "\p\024"); // 0x14= = Apple Menu AppendMenu(pomme, "\pAbout VIM"); *************** *** 3063,3074 **** gui.char_ascent = 6; gui.num_rows = 24; gui.num_cols = 80; ! gui.in_focus = TRUE; /* For the moment -> syn. of front application */ gScrollAction = NewControlActionUPP(gui_mac_scroll_action); gScrollDrag = NewControlActionUPP(gui_mac_drag_thumb); ! /* Install Carbon event callbacks. */ (void)InstallFontPanelHandler(); dragRectEnbl = FALSE; --- 3053,3064 ---- gui.char_ascent = 6; gui.num_rows = 24; gui.num_cols = 80; ! gui.in_focus = TRUE; // For the moment -> syn. of front application gScrollAction = NewControlActionUPP(gui_mac_scroll_action); gScrollDrag = NewControlActionUPP(gui_mac_drag_thumb); ! // Install Carbon event callbacks. (void)InstallFontPanelHandler(); dragRectEnbl = FALSE; *************** *** 3076,3091 **** dragRectControl = kCreateEmpty; cursorRgn = NewRgn(); #endif ! /* Display any pending error messages */ display_errors(); ! /* Get background/foreground colors from system */ ! /* TODO: do the appropriate call to get real defaults */ gui.norm_pixel = 0x00000000; gui.back_pixel = 0x00FFFFFF; ! /* Get the colors from the "Normal" group (set in syntax.c or in a vimrc ! * file). */ set_normal_colors(); /* --- 3066,3081 ---- dragRectControl = kCreateEmpty; cursorRgn = NewRgn(); #endif ! // Display any pending error messages display_errors(); ! // Get background/foreground colors from system ! // TODO: do the appropriate call to get real defaults gui.norm_pixel = 0x00000000; gui.back_pixel = 0x00FFFFFF; ! // Get the colors from the "Normal" group (set in syntax.c or in a vimrc ! // file). set_normal_colors(); /* *************** *** 3096,3103 **** gui.def_norm_pixel = gui.norm_pixel; gui.def_back_pixel = gui.back_pixel; ! /* Get the colors for the highlight groups (gui_check_colors() might have ! * changed them) */ highlight_gui_started(); /* --- 3086,3093 ---- gui.def_norm_pixel = gui.norm_pixel; gui.def_back_pixel = gui.back_pixel; ! // Get the colors for the highlight groups (gui_check_colors() might have ! // changed them) highlight_gui_started(); /* *************** *** 3106,3116 **** #ifdef FEAT_MENU gui.menu_height = 0; #endif ! gui.scrollbar_height = gui.scrollbar_width = 15; /* cheat 1 overlap */ gui.border_offset = gui.border_width = 2; ! /* If Quartz-style text anti aliasing is available (see ! gui_mch_draw_string() below), enable it for all font sizes. */ vim_setenv((char_u *)"QDTEXT_MINSIZE", (char_u *)"1"); eventTypeSpec.eventClass = kEventClassMouse; --- 3096,3106 ---- #ifdef FEAT_MENU gui.menu_height = 0; #endif ! gui.scrollbar_height = gui.scrollbar_width = 15; // cheat 1 overlap gui.border_offset = gui.border_width = 2; ! // If Quartz-style text anti aliasing is available (see ! // gui_mch_draw_string() below), enable it for all font sizes. vim_setenv((char_u *)"QDTEXT_MINSIZE", (char_u *)"1"); eventTypeSpec.eventClass = kEventClassMouse; *************** *** 3128,3137 **** InterfaceTypeList supportedServices = { kUnicodeDocument }; NewTSMDocument(1, supportedServices, &gTSMDocument, 0); ! /* We don't support inline input yet, use input window by default */ UseInputWindow(gTSMDocument, TRUE); ! /* Should we activate the document by default? */ // ActivateTSMDocument(gTSMDocument); EventTypeSpec textEventTypes[] = { --- 3118,3127 ---- InterfaceTypeList supportedServices = { kUnicodeDocument }; NewTSMDocument(1, supportedServices, &gTSMDocument, 0); ! // We don't support inline input yet, use input window by default UseInputWindow(gTSMDocument, TRUE); ! // Should we activate the document by default? // ActivateTSMDocument(gTSMDocument); EventTypeSpec textEventTypes[] = { *************** *** 3155,3162 **** { kEventClassWindow, kEventWindowDeactivated }, }; ! /* Install window event handler to support TSMDocument activate and ! * deactivate */ winEventHandlerUPP = NewEventHandlerUPP(gui_mac_handle_window_activate); if (noErr != InstallWindowEventHandler(gui.VimWindow, winEventHandlerUPP, --- 3145,3152 ---- { kEventClassWindow, kEventWindowDeactivated }, }; ! // Install window event handler to support TSMDocument activate and ! // deactivate winEventHandlerUPP = NewEventHandlerUPP(gui_mac_handle_window_activate); if (noErr != InstallWindowEventHandler(gui.VimWindow, winEventHandlerUPP, *************** *** 3175,3181 **** initialise_tabline(); #endif ! /* TODO: Load bitmap if using TOOLBAR */ return OK; } --- 3165,3171 ---- initialise_tabline(); #endif ! // TODO: Load bitmap if using TOOLBAR return OK; } *************** *** 3185,3194 **** void gui_mch_new_colors(void) { ! /* TODO: ! * This proc is called when Normal is set to a value ! * so what must be done? I don't know ! */ } /* --- 3175,3183 ---- void gui_mch_new_colors(void) { ! // TODO: ! // This proc is called when Normal is set to a value ! // so what must be done? I don't know } /* *************** *** 3229,3235 **** void gui_mch_exit(int rc) { ! /* TODO: find out all what is missing here? */ DisposeRgn(cursorRgn); #ifdef USE_CARBONKEYHANDLER --- 3218,3224 ---- void gui_mch_exit(int rc) { ! // TODO: find out all what is missing here? DisposeRgn(cursorRgn); #ifdef USE_CARBONKEYHANDLER *************** *** 3250,3256 **** DeleteTSMDocument(gTSMDocument); #endif ! /* Exit to shell? */ exit(rc); } --- 3239,3245 ---- DeleteTSMDocument(gTSMDocument); #endif ! // Exit to shell? exit(rc); } *************** *** 3260,3270 **** int gui_mch_get_winpos(int *x, int *y) { ! /* TODO */ Rect bounds; OSStatus status; ! /* Carbon >= 1.0.2, MacOS >= 8.5 */ status = GetWindowBounds(gui.VimWindow, kWindowStructureRgn, &bounds); if (status != noErr) --- 3249,3259 ---- int gui_mch_get_winpos(int *x, int *y) { ! // TODO Rect bounds; OSStatus status; ! // Carbon >= 1.0.2, MacOS >= 8.5 status = GetWindowBounds(gui.VimWindow, kWindowStructureRgn, &bounds); if (status != noErr) *************** *** 3281,3289 **** void gui_mch_set_winpos(int x, int y) { ! /* TODO: Should make sure the window is move within range ! * e.g.: y > ~16 [Menu bar], x > 0, x < screen width ! */ MoveWindowStructure(gui.VimWindow, x, y); } --- 3270,3277 ---- void gui_mch_set_winpos(int x, int y) { ! // TODO: Should make sure the window is move within range ! // e.g.: y > ~16 [Menu bar], x > 0, x < screen width MoveWindowStructure(gui.VimWindow, x, y); } *************** *** 3304,3312 **** { VimPort = GetWindowPort(gui.VimWindow); GetPortBounds(VimPort, &VimBound); ! VimBound.left = -gui.scrollbar_width; /* + 1;*/ SetPortBounds(VimPort, &VimBound); ! /* GetWindowBounds(gui.VimWindow, kWindowGlobalPortRgn, &winPortRect); ??*/ } else { --- 3292,3300 ---- { VimPort = GetWindowPort(gui.VimWindow); GetPortBounds(VimPort, &VimBound); ! VimBound.left = -gui.scrollbar_width; // + 1; SetPortBounds(VimPort, &VimBound); ! // GetWindowBounds(gui.VimWindow, kWindowGlobalPortRgn, &winPortRect); ?? } else { *************** *** 3351,3363 **** OSStatus status; FontSelectionQDStyle curr_font; ! /* Initialize the Font Panel with the current font. */ curr_font.instance.fontFamily = gui.norm_font & 0xFFFF; curr_font.size = (gui.norm_font >> 16); ! /* TODO: set fontStyle once styles are supported in gui_mac_find_font() */ curr_font.instance.fontStyle = 0; curr_font.hasColor = false; ! curr_font.version = 0; /* version number of the style structure */ status = SetFontInfoForSelection(kFontSelectionQDType, /*numStyles=*/1, &curr_font, /*eventTarget=*/NULL); --- 3339,3351 ---- OSStatus status; FontSelectionQDStyle curr_font; ! // Initialize the Font Panel with the current font. curr_font.instance.fontFamily = gui.norm_font & 0xFFFF; curr_font.size = (gui.norm_font >> 16); ! // TODO: set fontStyle once styles are supported in gui_mac_find_font() curr_font.instance.fontStyle = 0; curr_font.hasColor = false; ! curr_font.version = 0; // version number of the style structure status = SetFontInfoForSelection(kFontSelectionQDType, /*numStyles=*/1, &curr_font, /*eventTarget=*/NULL); *************** *** 3365,3371 **** gFontPanelInfo.style = curr_font.instance.fontStyle; gFontPanelInfo.size = curr_font.size; ! /* Pop up the Font Panel. */ status = FPShowHideFontPanel(); if (status == noErr) { --- 3353,3359 ---- gFontPanelInfo.style = curr_font.instance.fontStyle; gFontPanelInfo.size = curr_font.size; ! // Pop up the Font Panel. status = FPShowHideFontPanel(); if (status == noErr) { *************** *** 3412,3418 **** int gui_mch_init_font(char_u *font_name, int fontset) { ! /* TODO: Add support for bold italic underline proportional etc... */ Str255 suggestedFont = "\pMonaco"; int suggestedSize = 10; FontInfo font_info; --- 3400,3406 ---- int gui_mch_init_font(char_u *font_name, int fontset) { ! // TODO: Add support for bold italic underline proportional etc... Str255 suggestedFont = "\pMonaco"; int suggestedSize = 10; FontInfo font_info; *************** *** 3426,3437 **** if (font_name == NULL) { ! /* First try to get the suggested font */ GetFNum(suggestedFont, &font_id); if (font_id == 0) { ! /* Then pickup the standard application font */ font_id = GetAppFont(); STRCPY(used_font_name, "default"); } --- 3414,3425 ---- if (font_name == NULL) { ! // First try to get the suggested font GetFNum(suggestedFont, &font_id); if (font_id == 0) { ! // Then pickup the standard application font font_id = GetAppFont(); STRCPY(used_font_name, "default"); } *************** *** 3447,3460 **** if (font == NOFONT) return FAIL; ! /* Set guifont to the name of the selected font. */ new_p_guifont = alloc(STRLEN(used_font_name) + 1); if (new_p_guifont != NULL) { STRCPY(new_p_guifont, used_font_name); vim_free(p_guifont); p_guifont = new_p_guifont; ! /* Replace spaces in the font name with underscores. */ for ( ; *new_p_guifont; ++new_p_guifont) { if (*new_p_guifont == ' ') --- 3435,3448 ---- if (font == NOFONT) return FAIL; ! // Set guifont to the name of the selected font. new_p_guifont = alloc(STRLEN(used_font_name) + 1); if (new_p_guifont != NULL) { STRCPY(new_p_guifont, used_font_name); vim_free(p_guifont); p_guifont = new_p_guifont; ! // Replace spaces in the font name with underscores. for ( ; *new_p_guifont; ++new_p_guifont) { if (*new_p_guifont == ' ') *************** *** 3587,3594 **** if (has_mbyte) { ! /* FIXME: we should use a more mbyte sensitive way to support ! * wide font drawing */ fontWidth = Long2Fix(gui.char_width * 2); if (ATSUSetAttributes(gWideFontStyle, --- 3575,3582 ---- if (has_mbyte) { ! // FIXME: we should use a more mbyte sensitive way to support ! // wide font drawing fontWidth = Long2Fix(gui.char_width * 2); if (ATSUSetAttributes(gWideFontStyle, *************** *** 3615,3621 **** if (p_macatsui && gFontStyle) { ! /* Avoid setting same font again */ if (ATSUGetAttribute(gFontStyle, kATSUMaxATSUITagValue + 1, sizeof(font), &currFont, &actualFontByteCount) == noErr && actualFontByteCount == (sizeof font)) --- 3603,3609 ---- if (p_macatsui && gFontStyle) { ! // Avoid setting same font again if (ATSUGetAttribute(gFontStyle, kATSUMaxATSUITagValue + 1, sizeof(font), &currFont, &actualFontByteCount) == noErr && actualFontByteCount == (sizeof font)) *************** *** 3629,3642 **** if (p_macatsui && !gIsFontFallbackSet) { ! /* Setup automatic font substitution. The user's guifontwide ! * is tried first, then the system tries other fonts. */ ! /* ATSUAttributeTag fallbackTags[] = { kATSULineFontFallbacksTag }; ByteCount fallbackSizes[] = { sizeof(ATSUFontFallbacks) }; ATSUCreateFontFallbacks(&gFontFallbacks); ATSUSetObjFontFallbacks(gFontFallbacks, ); ! */ if (gui.wide_font) { ATSUFontID fallbackFonts; --- 3617,3630 ---- if (p_macatsui && !gIsFontFallbackSet) { ! // Setup automatic font substitution. The user's guifontwide ! // is tried first, then the system tries other fonts. ! #if 0 ATSUAttributeTag fallbackTags[] = { kATSULineFontFallbacksTag }; ByteCount fallbackSizes[] = { sizeof(ATSUFontFallbacks) }; ATSUCreateFontFallbacks(&gFontFallbacks); ATSUSetObjFontFallbacks(gFontFallbacks, ); ! #endif if (gui.wide_font) { ATSUFontID fallbackFonts; *************** *** 3652,3660 **** &fallbackFonts, kATSUSequentialFallbacksPreferred); } ! /* ! ATSUAttributeValuePtr fallbackValues[] = { }; ! */ } } #endif --- 3640,3646 ---- &fallbackFonts, kATSUSequentialFallbacksPreferred); } ! // ATSUAttributeValuePtr fallbackValues[] = { }; } } #endif *************** *** 3684,3691 **** guicolor_T gui_mch_get_color(char_u *name) { ! /* TODO: Add support for the new named color of MacOS 8 ! */ RGBColor MacColor; if (STRICMP(name, "hilite") == 0) --- 3670,3676 ---- guicolor_T gui_mch_get_color(char_u *name) { ! // TODO: Add support for the new named color of MacOS 8 RGBColor MacColor; if (STRICMP(name, "hilite") == 0) *************** *** 3786,3792 **** */ if (gMacSystemVersion >= 0x1020) { ! /* Quartz antialiasing is available only in OS 10.2 and later. */ UInt32 qd_flags = (p_antialias ? kQDUseCGTextRendering | kQDUseCGTextMetrics : 0); QDSwapTextFlags(qd_flags); --- 3771,3777 ---- */ if (gMacSystemVersion >= 0x1020) { ! // Quartz antialiasing is available only in OS 10.2 and later. UInt32 qd_flags = (p_antialias ? kQDUseCGTextRendering | kQDUseCGTextMetrics : 0); QDSwapTextFlags(qd_flags); *************** *** 3808,3817 **** rc.left = FILL_X(col); rc.top = FILL_Y(row); ! /* Multibyte computation taken from gui_w32.c */ if (has_mbyte) { ! /* Compute the length in display cells. */ rc.right = FILL_X(col + mb_string2cells(s, len)); } else --- 3793,3802 ---- rc.left = FILL_X(col); rc.top = FILL_Y(row); ! // Multibyte computation taken from gui_w32.c if (has_mbyte) { ! // Compute the length in display cells. rc.right = FILL_X(col + mb_string2cells(s, len)); } else *************** *** 3831,3837 **** face |= underline; TextFace(face); ! /* Quartz antialiasing works only in srcOr transfer mode. */ TextMode(srcOr); MoveTo(TEXT_X(col), TEXT_Y(row)); --- 3816,3822 ---- face |= underline; TextFace(face); ! // Quartz antialiasing works only in srcOr transfer mode. TextMode(srcOr); MoveTo(TEXT_X(col), TEXT_Y(row)); *************** *** 3839,3849 **** } else { ! /* Use old-style, non-antialiased QuickDraw text rendering. */ TextMode(srcCopy); TextFace(normal); ! /* SelectFont(hdc, gui.currFont); */ if (flags & DRAW_TRANSP) TextMode(srcOr); --- 3824,3834 ---- } else { ! // Use old-style, non-antialiased QuickDraw text rendering. TextMode(srcCopy); TextFace(normal); ! // SelectFont(hdc, gui.currFont); if (flags & DRAW_TRANSP) TextMode(srcOr); *************** *** 3881,3893 **** static void draw_string_ATSUI(int row, int col, char_u *s, int len, int flags) { ! /* ATSUI requires utf-16 strings */ UniCharCount utf16_len; UniChar *tofree = mac_enc_to_utf16(s, len, (size_t *)&utf16_len); utf16_len /= sizeof(UniChar); ! /* - ATSUI automatically antialiases text (Someone) ! * - for some reason it does not work... (Jussi) */ #ifdef MAC_ATSUI_DEBUG fprintf(stderr, "row = %d, col = %d, len = %d: '%c'\n", row, col, len, len == 1 ? s[0] : ' '); --- 3866,3878 ---- static void draw_string_ATSUI(int row, int col, char_u *s, int len, int flags) { ! // ATSUI requires utf-16 strings UniCharCount utf16_len; UniChar *tofree = mac_enc_to_utf16(s, len, (size_t *)&utf16_len); utf16_len /= sizeof(UniChar); ! // - ATSUI automatically antialiases text (Someone) ! // - for some reason it does not work... (Jussi) #ifdef MAC_ATSUI_DEBUG fprintf(stderr, "row = %d, col = %d, len = %d: '%c'\n", row, col, len, len == 1 ? s[0] : ' '); *************** *** 3907,3916 **** rc.left = FILL_X(col); rc.top = FILL_Y(row); ! /* Multibyte computation taken from gui_w32.c */ if (has_mbyte) { ! /* Compute the length in display cells. */ rc.right = FILL_X(col + mb_string2cells(s, len)); } else --- 3892,3901 ---- rc.left = FILL_X(col); rc.top = FILL_Y(row); ! // Multibyte computation taken from gui_w32.c if (has_mbyte) { ! // Compute the length in display cells. rc.right = FILL_X(col + mb_string2cells(s, len)); } else *************** *** 3924,3930 **** TextMode(srcCopy); TextFace(normal); ! /* SelectFont(hdc, gui.currFont); */ if (flags & DRAW_TRANSP) TextMode(srcOr); --- 3909,3915 ---- TextMode(srcCopy); TextFace(normal); ! // SelectFont(hdc, gui.currFont); if (flags & DRAW_TRANSP) TextMode(srcOr); *************** *** 3975,3988 **** ATSUSetRunStyle(textLayout, gFontStyle, kATSUFromTextBeginning, kATSUToTextEnd); */ ! /* Compute the length in display cells. */ for (n = 0; n < len; n += MB_BYTE2LEN(s[n])) { width_in_cell = (*mb_ptr2cells)(s + n); ! /* probably we are switching from single byte character ! * to multibyte characters (which requires more than one ! * cell to draw) */ if (width_in_cell != last_width_in_cell) { #ifdef MAC_ATSUI_DEBUG --- 3960,3973 ---- ATSUSetRunStyle(textLayout, gFontStyle, kATSUFromTextBeginning, kATSUToTextEnd); */ ! // Compute the length in display cells. for (n = 0; n < len; n += MB_BYTE2LEN(s[n])) { width_in_cell = (*mb_ptr2cells)(s + n); ! // probably we are switching from single byte character ! // to multibyte characters (which requires more than one ! // cell to draw) if (width_in_cell != last_width_in_cell) { #ifdef MAC_ATSUI_DEBUG *************** *** 4007,4013 **** fprintf(stderr, "\tn = %2d, (%d-%d), offset = %d, yet_to_draw = %d\n", n, last_width_in_cell, width_in_cell, offset, yet_to_draw); #endif ! /* finish the rest style */ textStyle = width_in_cell > 1 ? gWideFontStyle : gFontStyle; ATSUSetRunStyle(textLayout, textStyle, offset, kATSUToTextEnd); } --- 3992,3998 ---- fprintf(stderr, "\tn = %2d, (%d-%d), offset = %d, yet_to_draw = %d\n", n, last_width_in_cell, width_in_cell, offset, yet_to_draw); #endif ! // finish the rest style textStyle = width_in_cell > 1 ? gWideFontStyle : gFontStyle; ATSUSetRunStyle(textLayout, textStyle, offset, kATSUToTextEnd); } *************** *** 4039,4045 **** } } ! /* drawing is done, now reset bold to normal */ if (gFontStyle && flags & DRAW_BOLD) { Boolean attValue = false; --- 4024,4030 ---- } } ! // drawing is done, now reset bold to normal if (gFontStyle && flags & DRAW_BOLD) { Boolean attValue = false; *************** *** 4065,4074 **** { #if defined(USE_ATSUI_DRAWING) if (p_macatsui == 0 && p_macatsui_last != 0) ! /* switch from macatsui to nomacatsui */ gui_mac_dispose_atsui_style(); else if (p_macatsui != 0 && p_macatsui_last == 0) ! /* switch from nomacatsui to macatsui */ gui_mac_create_atsui_style(); if (p_macatsui) --- 4050,4059 ---- { #if defined(USE_ATSUI_DRAWING) if (p_macatsui == 0 && p_macatsui_last != 0) ! // switch from macatsui to nomacatsui gui_mac_dispose_atsui_style(); else if (p_macatsui != 0 && p_macatsui_last == 0) ! // switch from nomacatsui to macatsui gui_mac_create_atsui_style(); if (p_macatsui) *************** *** 4096,4108 **** void gui_mch_beep(void) { ! SysBeep(1); /* Should this be 0? (????) */ } void gui_mch_flash(int msec) { ! /* Do a visual beep by reversing the foreground and background colors */ Rect rc; /* --- 4081,4093 ---- void gui_mch_beep(void) { ! SysBeep(1); // Should this be 0? (????) } void gui_mch_flash(int msec) { ! // Do a visual beep by reversing the foreground and background colors Rect rc; /* *************** *** 4114,4120 **** rc.bottom = gui.num_rows * gui.char_height; InvertRect(&rc); ! ui_delay((long)msec, TRUE); /* wait for some msec */ InvertRect(&rc); } --- 4099,4105 ---- rc.bottom = gui.num_rows * gui.char_height; InvertRect(&rc); ! ui_delay((long)msec, TRUE); // wait for some msec InvertRect(&rc); } *************** *** 4143,4152 **** void gui_mch_iconify(void) { ! /* TODO: find out what could replace iconify ! * -window shade? ! * -hide application? ! */ } #if defined(FEAT_EVAL) || defined(PROTO) --- 4128,4136 ---- void gui_mch_iconify(void) { ! // TODO: find out what could replace iconify ! // -window shade? ! // -hide application? } #if defined(FEAT_EVAL) || defined(PROTO) *************** *** 4156,4162 **** void gui_mch_set_foreground(void) { ! /* TODO */ } #endif --- 4140,4146 ---- void gui_mch_set_foreground(void) { ! // TODO } #endif *************** *** 4192,4198 **** Rect rc; #ifdef FEAT_RIGHTLEFT ! /* vertical line should be on the right of current point */ if (CURSOR_BAR_RIGHT) rc.left = FILL_X(gui.col + 1) - w; else --- 4176,4182 ---- Rect rc; #ifdef FEAT_RIGHTLEFT ! // vertical line should be on the right of current point if (CURSOR_BAR_RIGHT) rc.left = FILL_X(gui.col + 1) - w; else *************** *** 4219,4232 **** void gui_mch_update(void) { ! /* TODO: find what to do ! * maybe call gui_mch_wait_for_chars (0) ! * more like look at EventQueue then ! * call heart of gui_mch_wait_for_chars; ! * ! * if (eventther) ! * gui_mac_handle_event(&event); ! */ EventRecord theEvent; if (EventAvail(everyEvent, &theEvent)) --- 4203,4215 ---- void gui_mch_update(void) { ! // TODO: find what to do ! // maybe call gui_mch_wait_for_chars (0) ! // more like look at EventQueue then ! // call heart of gui_mch_wait_for_chars; ! // ! // if (eventther) ! // gui_mac_handle_event(&event); EventRecord theEvent; if (EventAvail(everyEvent, &theEvent)) *************** *** 4266,4278 **** long currentTick; long sleeppyTick; ! /* If we are providing life feedback with the scrollbar, ! * we don't want to try to wait for an event, or else ! * there won't be any life feedback. ! */ if (dragged_sb != NULL) return FAIL; ! /* TODO: Check if FAIL is the proper return code */ entryTick = TickCount(); --- 4249,4260 ---- long currentTick; long sleeppyTick; ! // If we are providing life feedback with the scrollbar, ! // we don't want to try to wait for an event, or else ! // there won't be any life feedback. if (dragged_sb != NULL) return FAIL; ! // TODO: Check if FAIL is the proper return code entryTick = TickCount(); *************** *** 4280,4291 **** do { ! /* if (dragRectControl == kCreateEmpty) { dragRgn = NULL; dragRectControl = kNothing; } ! else*/ if (dragRectControl == kCreateRect) { dragRgn = cursorRgn; RectRgn(dragRgn, &dragRect); --- 4262,4276 ---- do { ! #if 0 ! if (dragRectControl == kCreateEmpty) { dragRgn = NULL; dragRectControl = kNothing; } ! else ! #endif ! if (dragRectControl == kCreateRect) { dragRgn = cursorRgn; RectRgn(dragRgn, &dragRect); *************** *** 4297,4303 **** * event arrives. No need to check for input_buf_full because we are * returning as soon as it contains a single char. */ ! /* TODO: reduce wtime accordingly??? */ if (wtime > -1) sleeppyTick = 60 * wtime / 1000; else --- 4282,4288 ---- * event arrives. No need to check for input_buf_full because we are * returning as soon as it contains a single char. */ ! // TODO: reduce wtime accordingly??? if (wtime > -1) sleeppyTick = 60 * wtime / 1000; else *************** *** 4324,4334 **** * Output routines. */ ! /* Flush any output to the screen */ void gui_mch_flush(void) { ! /* TODO: Is anything needed here? */ } /* --- 4309,4321 ---- * Output routines. */ ! /* ! * Flush any output to the screen ! */ void gui_mch_flush(void) { ! // TODO: Is anything needed here? } /* *************** *** 4368,4376 **** gui_mch_set_bg_color(gui.back_pixel); EraseRect(&rc); ! /* gui_mch_set_fg_color(gui.norm_pixel); ! FrameRect(&rc); ! */ } /* --- 4355,4362 ---- gui_mch_set_bg_color(gui.back_pixel); EraseRect(&rc); ! // gui_mch_set_fg_color(gui.norm_pixel); ! // FrameRect(&rc); } /* *************** *** 4382,4388 **** { Rect rc; ! /* changed without checking! */ rc.left = FILL_X(gui.scroll_region_left); rc.right = FILL_X(gui.scroll_region_right + 1); rc.top = FILL_Y(row); --- 4368,4374 ---- { Rect rc; ! // changed without checking! rc.left = FILL_X(gui.scroll_region_left); rc.right = FILL_X(gui.scroll_region_right + 1); rc.top = FILL_Y(row); *************** *** 4414,4420 **** ScrollRect(&rc, 0, gui.char_height * num_lines, (RgnHandle) nil); ! /* Update gui.cursor_row if the cursor scrolled or copied over */ if (gui.cursor_row >= gui.row && gui.cursor_col >= gui.scroll_region_left && gui.cursor_col <= gui.scroll_region_right) --- 4400,4406 ---- ScrollRect(&rc, 0, gui.char_height * num_lines, (RgnHandle) nil); ! // Update gui.cursor_row if the cursor scrolled or copied over if (gui.cursor_row >= gui.row && gui.cursor_col >= gui.scroll_region_left && gui.cursor_col <= gui.scroll_region_right) *************** *** 4474,4483 **** ReserveMem(scrapSize); ! /* In CARBON we don't need a Handle, a pointer is good */ textOfClip = NewHandle(scrapSize); ! /* tempclip = alloc(scrapSize+1); */ HLock(textOfClip); error = GetScrapFlavorData(scrap, flavor ? VIMSCRAPFLAVOR : SCRAPTEXTFLAVOR, --- 4460,4469 ---- ReserveMem(scrapSize); ! // In CARBON we don't need a Handle, a pointer is good textOfClip = NewHandle(scrapSize); ! // tempclip = alloc(scrapSize+1); HLock(textOfClip); error = GetScrapFlavorData(scrap, flavor ? VIMSCRAPFLAVOR : SCRAPTEXTFLAVOR, *************** *** 4495,4501 **** #ifdef MACOS_CONVERT { ! /* Convert from utf-16 (clipboard) */ size_t encLen = 0; char_u *to = mac_utf16_to_enc((UniChar *)tempclip, scrapSize, &encLen); --- 4481,4487 ---- #ifdef MACOS_CONVERT { ! // Convert from utf-16 (clipboard) size_t encLen = 0; char_u *to = mac_utf16_to_enc((UniChar *)tempclip, scrapSize, &encLen); *************** *** 4601,4607 **** { Rect VimBound; ! /* HideWindow(gui.VimWindow); */ GetWindowBounds(gui.VimWindow, kWindowGlobalPortRgn, &VimBound); if (gui.which_scrollbars[SBAR_LEFT]) --- 4587,4593 ---- { Rect VimBound; ! // HideWindow(gui.VimWindow); GetWindowBounds(gui.VimWindow, kWindowGlobalPortRgn, &VimBound); if (gui.which_scrollbars[SBAR_LEFT]) *************** *** 4647,4679 **** * Carbon Help suggest to use only id between 1 and 235 */ static long next_avail_id = 128; ! long menu_after_me = 0; /* Default to the end */ CFStringRef name; short index; vimmenu_T *parent = menu->parent; vimmenu_T *brother = menu->next; ! /* Cannot add a menu if ... */ if ((parent != NULL && parent->submenu_id == 0)) return; ! /* menu ID greater than 1024 are reserved for ??? */ if (next_avail_id == 1024) return; ! /* My brother could be the PopUp, find my real brother */ while ((brother != NULL) && (!menu_is_menubar(brother->name))) brother = brother->next; ! /* Find where to insert the menu (for MenuBar) */ if ((parent == NULL) && (brother != NULL)) menu_after_me = brother->submenu_id; ! /* If the menu is not part of the menubar (and its submenus), add it 'nowhere' */ if (!menu_is_menubar(menu->name)) menu_after_me = hierMenu; ! /* Convert the name */ #ifdef MACOS_CONVERT name = menu_title_removing_mnemonic(menu); #else --- 4633,4665 ---- * Carbon Help suggest to use only id between 1 and 235 */ static long next_avail_id = 128; ! long menu_after_me = 0; // Default to the end CFStringRef name; short index; vimmenu_T *parent = menu->parent; vimmenu_T *brother = menu->next; ! // Cannot add a menu if ... if ((parent != NULL && parent->submenu_id == 0)) return; ! // menu ID greater than 1024 are reserved for ??? if (next_avail_id == 1024) return; ! // My brother could be the PopUp, find my real brother while ((brother != NULL) && (!menu_is_menubar(brother->name))) brother = brother->next; ! // Find where to insert the menu (for MenuBar) if ((parent == NULL) && (brother != NULL)) menu_after_me = brother->submenu_id; ! // If the menu is not part of the menubar (and its submenus), add it 'nowhere' if (!menu_is_menubar(menu->name)) menu_after_me = hierMenu; ! // Convert the name #ifdef MACOS_CONVERT name = menu_title_removing_mnemonic(menu); #else *************** *** 4682,4693 **** if (name == NULL) return; ! /* Create the menu unless it's the help menu */ { ! /* Carbon suggest use of ! * OSStatus CreateNewMenu(MenuID, MenuAttributes, MenuRef *); ! * OSStatus SetMenuTitle(MenuRef, ConstStr255Param title); ! */ menu->submenu_id = next_avail_id; if (CreateNewMenu(menu->submenu_id, 0, (MenuRef *)&menu->submenu_handle) == noErr) SetMenuTitleWithCFString((MenuRef)menu->submenu_handle, name); --- 4668,4678 ---- if (name == NULL) return; ! // Create the menu unless it's the help menu { ! // Carbon suggest use of ! // OSStatus CreateNewMenu(MenuID, MenuAttributes, MenuRef *); ! // OSStatus SetMenuTitle(MenuRef, ConstStr255Param title); menu->submenu_id = next_avail_id; if (CreateNewMenu(menu->submenu_id, 0, (MenuRef *)&menu->submenu_handle) == noErr) SetMenuTitleWithCFString((MenuRef)menu->submenu_handle, name); *************** *** 4696,4724 **** if (parent == NULL) { ! /* Adding a menu to the menubar, or in the no mans land (for PopUp) */ ! /* TODO: Verify if we could only Insert Menu if really part of the ! * menubar The Inserted menu are scanned or the Command-key combos ! */ ! /* Insert the menu */ ! InsertMenu(menu->submenu_handle, menu_after_me); /* insert before */ #if 1 ! /* Vim should normally update it. TODO: verify */ DrawMenuBar(); #endif } else { ! /* Adding as a submenu */ index = gui_mac_get_menu_item_index(menu); ! /* Call InsertMenuItem followed by SetMenuItemText ! * to avoid special character recognition by InsertMenuItem ! */ ! InsertMenuItem(parent->submenu_handle, "\p ", idx); /* afterItem */ SetMenuItemTextWithCFString(parent->submenu_handle, idx+1, name); SetItemCmd(parent->submenu_handle, idx+1, 0x1B); SetItemMark(parent->submenu_handle, idx+1, menu->submenu_id); --- 4681,4707 ---- if (parent == NULL) { ! // Adding a menu to the menubar, or in the no mans land (for PopUp) ! // TODO: Verify if we could only Insert Menu if really part of the ! // menubar The Inserted menu are scanned or the Command-key combos ! // Insert the menu ! InsertMenu(menu->submenu_handle, menu_after_me); // insert before #if 1 ! // Vim should normally update it. TODO: verify DrawMenuBar(); #endif } else { ! // Adding as a submenu index = gui_mac_get_menu_item_index(menu); ! // Call InsertMenuItem followed by SetMenuItemText ! // to avoid special character recognition by InsertMenuItem ! InsertMenuItem(parent->submenu_handle, "\p ", idx); // afterItem SetMenuItemTextWithCFString(parent->submenu_handle, idx+1, name); SetItemCmd(parent->submenu_handle, idx+1, 0x1B); SetItemMark(parent->submenu_handle, idx+1, menu->submenu_id); *************** *** 4728,4734 **** CFRelease(name); #if 0 ! /* Done by Vim later on */ DrawMenuBar(); #endif } --- 4711,4717 ---- CFRelease(name); #if 0 ! // Done by Vim later on DrawMenuBar(); #endif } *************** *** 4743,4773 **** vimmenu_T *parent = menu->parent; int menu_inserted; ! /* Cannot add item, if the menu have not been created */ if (parent->submenu_id == 0) return; ! /* Could call SetMenuRefCon [CARBON] to associate with the Menu, ! for older OS call GetMenuItemData (menu, item, isCommandID?, data) */ ! /* Convert the name */ #ifdef MACOS_CONVERT name = menu_title_removing_mnemonic(menu); #else name = C2Pascal_save(menu->dname); #endif ! /* Where are just a menu item, so no handle, no id */ menu->submenu_id = 0; menu->submenu_handle = NULL; menu_inserted = 0; if (menu->actext) { ! /* If the accelerator text for the menu item looks like it describes ! * a command key (e.g., "" or ""), display it as the ! * item's command equivalent. ! */ int key = 0; int modifiers = 0; char_u *p_actext; --- 4726,4755 ---- vimmenu_T *parent = menu->parent; int menu_inserted; ! // Cannot add item, if the menu have not been created if (parent->submenu_id == 0) return; ! // Could call SetMenuRefCon [CARBON] to associate with the Menu, ! // for older OS call GetMenuItemData (menu, item, isCommandID?, data) ! // Convert the name #ifdef MACOS_CONVERT name = menu_title_removing_mnemonic(menu); #else name = C2Pascal_save(menu->dname); #endif ! // Where are just a menu item, so no handle, no id menu->submenu_id = 0; menu->submenu_handle = NULL; menu_inserted = 0; if (menu->actext) { ! // If the accelerator text for the menu item looks like it describes ! // a command key (e.g., "" or ""), display it as the ! // item's command equivalent. int key = 0; int modifiers = 0; char_u *p_actext; *************** *** 4776,4814 **** key = find_special_key(&p_actext, &modifiers, FALSE, FALSE, FALSE, TRUE, NULL); if (*p_actext != 0) ! key = 0; /* error: trailing text */ ! /* find_special_key() returns a keycode with as many of the ! * specified modifiers as appropriate already applied (e.g., for ! * "" it returns Ctrl-X as the keycode and MOD_MASK_CMD ! * as the only modifier). Since we want to display all of the ! * modifiers, we need to convert the keycode back to a printable ! * character plus modifiers. ! * TODO: Write an alternative find_special_key() that doesn't ! * apply modifiers. ! */ if (key > 0 && key < 32) { ! /* Convert a control key to an uppercase letter. Note that ! * by this point it is no longer possible to distinguish ! * between, e.g., Ctrl-S and Ctrl-Shift-S. ! */ modifiers |= MOD_MASK_CTRL; key += '@'; } ! /* If the keycode is an uppercase letter, set the Shift modifier. ! * If it is a lowercase letter, don't set the modifier, but convert ! * the letter to uppercase for display in the menu. ! */ else if (key >= 'A' && key <= 'Z') modifiers |= MOD_MASK_SHIFT; else if (key >= 'a' && key <= 'z') key += 'A' - 'a'; ! /* Note: keycodes below 0x22 are reserved by Apple. */ if (key >= 0x22 && vim_isprintc_strict(key)) { int valid = 1; char_u mac_mods = kMenuNoModifiers; ! /* Convert Vim modifier codes to Menu Manager equivalents. */ if (modifiers & MOD_MASK_SHIFT) mac_mods |= kMenuShiftModifier; if (modifiers & MOD_MASK_CTRL) --- 4758,4793 ---- key = find_special_key(&p_actext, &modifiers, FALSE, FALSE, FALSE, TRUE, NULL); if (*p_actext != 0) ! key = 0; // error: trailing text ! // find_special_key() returns a keycode with as many of the ! // specified modifiers as appropriate already applied (e.g., for ! // "" it returns Ctrl-X as the keycode and MOD_MASK_CMD ! // as the only modifier). Since we want to display all of the ! // modifiers, we need to convert the keycode back to a printable ! // character plus modifiers. ! // TODO: Write an alternative find_special_key() that doesn't ! // apply modifiers. if (key > 0 && key < 32) { ! // Convert a control key to an uppercase letter. Note that ! // by this point it is no longer possible to distinguish ! // between, e.g., Ctrl-S and Ctrl-Shift-S. modifiers |= MOD_MASK_CTRL; key += '@'; } ! // If the keycode is an uppercase letter, set the Shift modifier. ! // If it is a lowercase letter, don't set the modifier, but convert ! // the letter to uppercase for display in the menu. else if (key >= 'A' && key <= 'Z') modifiers |= MOD_MASK_SHIFT; else if (key >= 'a' && key <= 'z') key += 'A' - 'a'; ! // Note: keycodes below 0x22 are reserved by Apple. if (key >= 0x22 && vim_isprintc_strict(key)) { int valid = 1; char_u mac_mods = kMenuNoModifiers; ! // Convert Vim modifier codes to Menu Manager equivalents. if (modifiers & MOD_MASK_SHIFT) mac_mods |= kMenuShiftModifier; if (modifiers & MOD_MASK_CTRL) *************** *** 4816,4845 **** if (!(modifiers & MOD_MASK_CMD)) mac_mods |= kMenuNoCommandModifier; if (modifiers & MOD_MASK_ALT || modifiers & MOD_MASK_MULTI_CLICK) ! valid = 0; /* TODO: will Alt someday map to Option? */ if (valid) { char_u item_txt[10]; ! /* Insert the menu item after idx, with its command key. */ item_txt[0] = 3; item_txt[1] = ' '; item_txt[2] = '/'; item_txt[3] = key; InsertMenuItem(parent->submenu_handle, item_txt, idx); ! /* Set the modifier keys. */ SetMenuItemModifiers(parent->submenu_handle, idx+1, mac_mods); menu_inserted = 1; } } } ! /* Call InsertMenuItem followed by SetMenuItemText ! * to avoid special character recognition by InsertMenuItem ! */ if (!menu_inserted) ! InsertMenuItem(parent->submenu_handle, "\p ", idx); /* afterItem */ ! /* Set the menu item name. */ SetMenuItemTextWithCFString(parent->submenu_handle, idx+1, name); #if 0 ! /* Called by Vim */ DrawMenuBar(); #endif --- 4795,4823 ---- if (!(modifiers & MOD_MASK_CMD)) mac_mods |= kMenuNoCommandModifier; if (modifiers & MOD_MASK_ALT || modifiers & MOD_MASK_MULTI_CLICK) ! valid = 0; // TODO: will Alt someday map to Option? if (valid) { char_u item_txt[10]; ! // Insert the menu item after idx, with its command key. item_txt[0] = 3; item_txt[1] = ' '; item_txt[2] = '/'; item_txt[3] = key; InsertMenuItem(parent->submenu_handle, item_txt, idx); ! // Set the modifier keys. SetMenuItemModifiers(parent->submenu_handle, idx+1, mac_mods); menu_inserted = 1; } } } ! // Call InsertMenuItem followed by SetMenuItemText ! // to avoid special character recognition by InsertMenuItem if (!menu_inserted) ! InsertMenuItem(parent->submenu_handle, "\p ", idx); // afterItem ! // Set the menu item name. SetMenuItemTextWithCFString(parent->submenu_handle, idx+1, name); #if 0 ! // Called by Vim DrawMenuBar(); #endif *************** *** 4849,4855 **** void gui_mch_toggle_tearoffs(int enable) { ! /* no tearoff menus */ } /* --- 4827,4833 ---- void gui_mch_toggle_tearoffs(int enable) { ! // no tearoff menus } /* *************** *** 4865,4874 **** if (menu->parent) { { ! /* For now just don't delete help menu items. (Huh? Dany) */ DeleteMenuItem(menu->parent->submenu_handle, index); ! /* Delete the Menu if it was a hierarchical Menu */ if (menu->submenu_id != 0) { DeleteMenu(menu->submenu_id); --- 4843,4852 ---- if (menu->parent) { { ! // For now just don't delete help menu items. (Huh? Dany) DeleteMenuItem(menu->parent->submenu_handle, index); ! // Delete the Menu if it was a hierarchical Menu if (menu->submenu_id != 0) { DeleteMenu(menu->submenu_id); *************** *** 4890,4896 **** DisposeMenu(menu->submenu_handle); } } ! /* Shouldn't this be already done by Vim. TODO: Check */ DrawMenuBar(); } --- 4868,4874 ---- DisposeMenu(menu->submenu_handle); } } ! // Shouldn't this be already done by Vim. TODO: Check DrawMenuBar(); } *************** *** 4900,4906 **** void gui_mch_menu_grey(vimmenu_T *menu, int grey) { ! /* TODO: Check if menu really exists */ short index = gui_mac_get_menu_item_index(menu); /* index = menu->index; --- 4878,4884 ---- void gui_mch_menu_grey(vimmenu_T *menu, int grey) { ! // TODO: Check if menu really exists short index = gui_mac_get_menu_item_index(menu); /* index = menu->index; *************** *** 4929,4935 **** void gui_mch_menu_hidden(vimmenu_T *menu, int hidden) { ! /* There's no hidden mode on MacOS */ gui_mch_menu_grey(menu, hidden); } --- 4907,4913 ---- void gui_mch_menu_hidden(vimmenu_T *menu, int hidden) { ! // There's no hidden mode on MacOS gui_mch_menu_grey(menu, hidden); } *************** *** 4988,4994 **** int h) { gui_mch_set_bg_color(gui.back_pixel); ! /* if (gui.which_scrollbars[SBAR_LEFT]) { MoveControl(sb->id, x-16, y); SizeControl(sb->id, w + 1, h); --- 4966,4973 ---- int h) { gui_mch_set_bg_color(gui.back_pixel); ! #if 0 ! if (gui.which_scrollbars[SBAR_LEFT]) { MoveControl(sb->id, x-16, y); SizeControl(sb->id, w + 1, h); *************** *** 4997,5003 **** { MoveControl(sb->id, x, y); SizeControl(sb->id, w + 1, h); ! }*/ if (sb == &gui.bottom_sbar) h += 1; else --- 4976,4983 ---- { MoveControl(sb->id, x, y); SizeControl(sb->id, w + 1, h); ! } ! #endif if (sb == &gui.bottom_sbar) h += 1; else *************** *** 5016,5022 **** void gui_mch_create_scrollbar( scrollbar_T *sb, ! int orient) /* SBAR_VERT or SBAR_HORIZ */ { Rect bounds; --- 4996,5002 ---- void gui_mch_create_scrollbar( scrollbar_T *sb, ! int orient) // SBAR_VERT or SBAR_HORIZ { Rect bounds; *************** *** 5029,5037 **** &bounds, "\pScrollBar", TRUE, ! 0, /* current*/ ! 0, /* top */ ! 0, /* bottom */ kControlScrollBarLiveProc, (long) sb->ident); #ifdef DEBUG_MAC_SB --- 5009,5017 ---- &bounds, "\pScrollBar", TRUE, ! 0, // current ! 0, // top ! 0, // bottom kControlScrollBarLiveProc, (long) sb->ident); #ifdef DEBUG_MAC_SB *************** *** 5072,5081 **** void gui_mch_set_blinking(long wait, long on, long off) { ! /* TODO: TODO: TODO: TODO: */ ! /* blink_waittime = wait; blink_ontime = on; ! blink_offtime = off;*/ } /* --- 5052,5063 ---- void gui_mch_set_blinking(long wait, long on, long off) { ! #if 0 ! // TODO: TODO: TODO: TODO: ! blink_waittime = wait; blink_ontime = on; ! blink_offtime = off; ! #endif } /* *************** *** 5086,5096 **** { if (may_call_gui_update_cursor) gui_update_cursor(TRUE, FALSE); ! /* TODO: TODO: TODO: TODO: */ ! /* gui_w32_rm_blink_timer(); if (blink_state == BLINK_OFF) gui_update_cursor(TRUE, FALSE); ! blink_state = BLINK_NONE;*/ } /* --- 5068,5080 ---- { if (may_call_gui_update_cursor) gui_update_cursor(TRUE, FALSE); ! #if 0 ! // TODO: TODO: TODO: TODO: ! gui_w32_rm_blink_timer(); if (blink_state == BLINK_OFF) gui_update_cursor(TRUE, FALSE); ! blink_state = BLINK_NONE; ! #endif } /* *************** *** 5101,5117 **** gui_mch_start_blink(void) { gui_update_cursor(TRUE, FALSE); ! /* TODO: TODO: TODO: TODO: */ ! /* gui_w32_rm_blink_timer(); */ ! /* Only switch blinking on if none of the times is zero */ ! /* if (blink_waittime && blink_ontime && blink_offtime) { blink_timer = SetTimer(NULL, 0, (UINT)blink_waittime, (TIMERPROC)_OnBlinkTimer); blink_state = BLINK_ON; gui_update_cursor(TRUE, FALSE); ! }*/ } /* --- 5085,5103 ---- gui_mch_start_blink(void) { gui_update_cursor(TRUE, FALSE); ! // TODO: TODO: TODO: TODO: ! // gui_w32_rm_blink_timer(); ! // Only switch blinking on if none of the times is zero ! #if 0 ! if (blink_waittime && blink_ontime && blink_offtime) { blink_timer = SetTimer(NULL, 0, (UINT)blink_waittime, (TIMERPROC)_OnBlinkTimer); blink_state = BLINK_ON; gui_update_cursor(TRUE, FALSE); ! } ! #endif } /* *************** *** 5153,5159 **** char_u *initdir, char_u *filter) { ! /* TODO: Add Ammon's safety check (Dany) */ NavReplyRecord reply; char_u *fname = NULL; char_u **fnames = NULL; --- 5139,5145 ---- char_u *initdir, char_u *filter) { ! // TODO: Add Ammon's safety check (Dany) NavReplyRecord reply; char_u *fname = NULL; char_u **fnames = NULL; *************** *** 5161,5193 **** NavDialogOptions navOptions; OSErr error; ! /* Get Navigation Service Defaults value */ NavGetDefaultDialogOptions(&navOptions); ! /* TODO: If we get a :browse args, set the Multiple bit. */ navOptions.dialogOptionFlags = kNavAllowInvisibleFiles | kNavDontAutoTranslate | kNavDontAddTranslateItems ! /* | kNavAllowMultipleFiles */ | kNavAllowStationery; (void) C2PascalString(title, &navOptions.message); (void) C2PascalString(dflt, &navOptions.savedFileName); ! /* Could set clientName? ! * windowTitle? (there's no title bar?) ! */ if (saving) { ! /* Change first parm AEDesc (typeFSS) *defaultLocation to match dflt */ NavPutFile(NULL, &reply, &navOptions, NULL, 'TEXT', 'VIM!', NULL); if (!reply.validRecord) return NULL; } else { ! /* Change first parm AEDesc (typeFSS) *defaultLocation to match dflt */ NavGetFile(NULL, &reply, &navOptions, NULL, NULL, NULL, NULL, NULL); if (!reply.validRecord) return NULL; --- 5147,5178 ---- NavDialogOptions navOptions; OSErr error; ! // Get Navigation Service Defaults value NavGetDefaultDialogOptions(&navOptions); ! // TODO: If we get a :browse args, set the Multiple bit. navOptions.dialogOptionFlags = kNavAllowInvisibleFiles | kNavDontAutoTranslate | kNavDontAddTranslateItems ! // | kNavAllowMultipleFiles | kNavAllowStationery; (void) C2PascalString(title, &navOptions.message); (void) C2PascalString(dflt, &navOptions.savedFileName); ! // Could set clientName? ! // windowTitle? (there's no title bar?) if (saving) { ! // Change first parm AEDesc (typeFSS) *defaultLocation to match dflt NavPutFile(NULL, &reply, &navOptions, NULL, 'TEXT', 'VIM!', NULL); if (!reply.validRecord) return NULL; } else { ! // Change first parm AEDesc (typeFSS) *defaultLocation to match dflt NavGetFile(NULL, &reply, &navOptions, NULL, NULL, NULL, NULL, NULL); if (!reply.validRecord) return NULL; *************** *** 5203,5212 **** vim_free(fnames); } ! /* TODO: Shorten the file name if possible */ return fname; } ! #endif /* FEAT_BROWSE */ #ifdef FEAT_GUI_DIALOG /* --- 5188,5197 ---- vim_free(fnames); } ! // TODO: Shorten the file name if possible return fname; } ! #endif // FEAT_BROWSE #ifdef FEAT_GUI_DIALOG /* *************** *** 5233,5241 **** typedef struct { short idx; ! short width; /* Size of the text in pixel */ Rect box; ! } vgmDlgItm; /* Vim Gui_Mac.c Dialog Item */ #define MoveRectTo(r,x,y) OffsetRect(r,x-r->left,y-r->top) --- 5218,5226 ---- typedef struct { short idx; ! short width; // Size of the text in pixel Rect box; ! } vgmDlgItm; // Vim Gui_Mac.c Dialog Item #define MoveRectTo(r,x,y) OffsetRect(r,x-r->left,y-r->top) *************** *** 5247,5254 **** short Y, Rect *inBox) { ! #if 0 /* USE_CARBONIZED */ ! /* Untested */ MoveDialogItem(theDialog, itemNumber, X, Y); if (inBox != nil) GetDialogItem(theDialog, itemNumber, &itemType, &itemHandle, inBox); --- 5232,5239 ---- short Y, Rect *inBox) { ! #if 0 // USE_CARBONIZED ! // Untested MoveDialogItem(theDialog, itemNumber, X, Y); if (inBox != nil) GetDialogItem(theDialog, itemNumber, &itemType, &itemHandle, inBox); *************** *** 5264,5272 **** GetDialogItem(theDialog, itemNumber, &itemType, &itemHandle, itemBox); OffsetRect(itemBox, -itemBox->left, -itemBox->top); OffsetRect(itemBox, X, Y); ! /* To move a control (like a button) we need to call both ! * MoveControl and SetDialogItem. FAQ 6-18 */ ! if (1) /*(itemType & kControlDialogItem) */ MoveControl((ControlRef) itemHandle, X, Y); SetDialogItem(theDialog, itemNumber, itemType, itemHandle, itemBox); #endif --- 5249,5257 ---- GetDialogItem(theDialog, itemNumber, &itemType, &itemHandle, itemBox); OffsetRect(itemBox, -itemBox->left, -itemBox->top); OffsetRect(itemBox, X, Y); ! // To move a control (like a button) we need to call both ! // MoveControl and SetDialogItem. FAQ 6-18 ! if (1) //(itemType & kControlDialogItem) MoveControl((ControlRef) itemHandle, X, Y); SetDialogItem(theDialog, itemNumber, itemType, itemHandle, itemBox); #endif *************** *** 5285,5309 **** GetDialogItem(theDialog, itemNumber, &itemType, &itemHandle, &itemBox); ! /* When width or height is zero do not change it */ if (width == 0) width = itemBox.right - itemBox.left; if (height == 0) height = itemBox.bottom - itemBox.top; ! #if 0 /* USE_CARBONIZED */ ! SizeDialogItem(theDialog, itemNumber, width, height); /* Untested */ #else ! /* Resize the bounding box */ itemBox.right = itemBox.left + width; itemBox.bottom = itemBox.top + height; ! /* To resize a control (like a button) we need to call both ! * SizeControl and SetDialogItem. (deducted from FAQ 6-18) */ if (itemType & kControlDialogItem) SizeControl((ControlRef) itemHandle, width, height); ! /* Configure back the item */ SetDialogItem(theDialog, itemNumber, itemType, itemHandle, &itemBox); #endif } --- 5270,5294 ---- GetDialogItem(theDialog, itemNumber, &itemType, &itemHandle, &itemBox); ! // When width or height is zero do not change it if (width == 0) width = itemBox.right - itemBox.left; if (height == 0) height = itemBox.bottom - itemBox.top; ! #if 0 // USE_CARBONIZED ! SizeDialogItem(theDialog, itemNumber, width, height); // Untested #else ! // Resize the bounding box itemBox.right = itemBox.left + width; itemBox.bottom = itemBox.top + height; ! // To resize a control (like a button) we need to call both ! // SizeControl and SetDialogItem. (deducted from FAQ 6-18) if (itemType & kControlDialogItem) SizeControl((ControlRef) itemHandle, width, height); ! // Configure back the item SetDialogItem(theDialog, itemNumber, itemType, itemHandle, &itemBox); #endif } *************** *** 5327,5333 **** } ! /* ModalDialog() handler for message dialogs that have hotkey accelerators. * Expects a mapping of hotkey char to control index in gDialogHotKeys; * setting gDialogHotKeys to NULL disables any hotkey handling. */ --- 5312,5319 ---- } ! /* ! * ModalDialog() handler for message dialogs that have hotkey accelerators. * Expects a mapping of hotkey char to control index in gDialogHotKeys; * setting gDialogHotKeys to NULL disables any hotkey handling. */ *************** *** 5350,5375 **** #endif *itemHit = gDialogHotKeys[keyHit]; ! /* When handing off to StdFilterProc, pretend that the user ! * clicked the control manually. Note that this is also supposed ! * to cause the button to hilite briefly (to give some user ! * feedback), but this seems not to actually work (or it's too ! * fast to be seen). ! */ event->what = kEventControlSimulateHit; ! return true; /* we took care of it */ } ! /* Defer to the OS's standard behavior for this event. ! * This ensures that Enter will still activate the default button. */ return StdFilterProc(theDialog, event, itemHit); } ! return false; /* Let ModalDialog deal with it */ } ! /* TODO: There have been some crashes with dialogs, check your inbox * (Jussi) */ int --- 5336,5361 ---- #endif *itemHit = gDialogHotKeys[keyHit]; ! // When handing off to StdFilterProc, pretend that the user ! // clicked the control manually. Note that this is also supposed ! // to cause the button to hilite briefly (to give some user ! // feedback), but this seems not to actually work (or it's too ! // fast to be seen). event->what = kEventControlSimulateHit; ! return true; // we took care of it } ! // Defer to the OS's standard behavior for this event. ! // This ensures that Enter will still activate the default button. return StdFilterProc(theDialog, event, itemHit); } ! return false; // Let ModalDialog deal with it } ! /* ! * TODO: There have been some crashes with dialogs, check your inbox * (Jussi) */ int *************** *** 5390,5401 **** Handle iconHandle; DialogPtr theDialog; char_u len; ! char_u PascalTitle[256]; /* place holder for the title */ char_u name[256]; GrafPtr oldPort; short itemHit; char_u *buttonChar; ! short hotKeys[256]; /* map of hotkey -> control ID */ char_u aHotKey; Rect box; short button; --- 5376,5387 ---- Handle iconHandle; DialogPtr theDialog; char_u len; ! char_u PascalTitle[256]; // place holder for the title char_u name[256]; GrafPtr oldPort; short itemHit; char_u *buttonChar; ! short hotKeys[256]; // map of hotkey -> control ID char_u aHotKey; Rect box; short button; *************** *** 5403,5416 **** short itemType; short useIcon; short width; ! short totalButtonWidth = 0; /* the width of all buttons together ! including spacing */ short widestButton = 0; ! short dfltButtonEdge = 20; /* gut feeling */ ! short dfltElementSpacing = 13; /* from IM:V.2-29 */ ! short dfltIconSideSpace = 23; /* from IM:V.2-29 */ ! short maximumWidth = 400; /* gut feeling */ ! short maxButtonWidth = 175; /* gut feeling */ short vertical; short dialogHeight; --- 5389,5402 ---- short itemType; short useIcon; short width; ! short totalButtonWidth = 0; // the width of all buttons together ! // including spacing short widestButton = 0; ! short dfltButtonEdge = 20; // gut feeling ! short dfltElementSpacing = 13; // from IM:V.2-29 ! short dfltIconSideSpace = 23; // from IM:V.2-29 ! short maximumWidth = 400; // gut feeling ! short maxButtonWidth = 175; // gut feeling short vertical; short dialogHeight; *************** *** 5426,5476 **** ModalFilterUPP dialogUPP; ! /* Check 'v' flag in 'guioptions': vertical button placement. */ vertical = (vim_strchr(p_go, GO_VERTICAL) != NULL); ! /* Create a new Dialog Box from template. */ theDialog = GetNewDialog(129, nil, (WindowRef) -1); ! /* Get the WindowRef */ theWindow = GetDialogWindow(theDialog); ! /* Hide the window. ! * 1. to avoid seeing slow drawing ! * 2. to prevent a problem seen while moving dialog item ! * within a visible window. (non-Carbon MacOS 9) ! * Could be avoided by changing the resource. ! */ HideWindow(theWindow); ! /* Change the graphical port to the dialog, ! * so we can measure the text with the proper font */ GetPort(&oldPort); SetPortDialogPort(theDialog); ! /* Get the info about the default text, ! * used to calculate the height of the message ! * and of the text field */ GetFontInfo(&textFontInfo); ! /* Set the dialog title */ if (title != NULL) { (void) C2PascalString(title, &PascalTitle); SetWTitle(theWindow, PascalTitle); } ! /* Creates the buttons and add them to the Dialog Box. */ buttonDITL = GetResource('DITL', 130); buttonChar = buttons; button = 0; ! /* initialize the hotkey mapping */ vim_memset(hotKeys, 0, sizeof(hotKeys)); for (;*buttonChar != 0;) { ! /* Get the name of the button */ button++; len = 0; for (;((*buttonChar != DLG_BUTTON_SEP) && (*buttonChar != 0) && (len < 255)); buttonChar++) --- 5412,5461 ---- ModalFilterUPP dialogUPP; ! // Check 'v' flag in 'guioptions': vertical button placement. vertical = (vim_strchr(p_go, GO_VERTICAL) != NULL); ! // Create a new Dialog Box from template. theDialog = GetNewDialog(129, nil, (WindowRef) -1); ! // Get the WindowRef theWindow = GetDialogWindow(theDialog); ! // Hide the window. ! // 1. to avoid seeing slow drawing ! // 2. to prevent a problem seen while moving dialog item ! // within a visible window. (non-Carbon MacOS 9) ! // Could be avoided by changing the resource. HideWindow(theWindow); ! // Change the graphical port to the dialog, ! // so we can measure the text with the proper font GetPort(&oldPort); SetPortDialogPort(theDialog); ! // Get the info about the default text, ! // used to calculate the height of the message ! // and of the text field GetFontInfo(&textFontInfo); ! // Set the dialog title if (title != NULL) { (void) C2PascalString(title, &PascalTitle); SetWTitle(theWindow, PascalTitle); } ! // Creates the buttons and add them to the Dialog Box. buttonDITL = GetResource('DITL', 130); buttonChar = buttons; button = 0; ! // initialize the hotkey mapping vim_memset(hotKeys, 0, sizeof(hotKeys)); for (;*buttonChar != 0;) { ! // Get the name of the button button++; len = 0; for (;((*buttonChar != DLG_BUTTON_SEP) && (*buttonChar != 0) && (len < 255)); buttonChar++) *************** *** 5493,5508 **** buttonChar++; name[0] = len; ! /* Add the button */ ! AppendDITL(theDialog, buttonDITL, overlayDITL); /* appendDITLRight); */ ! /* Change the button's name */ macSetDialogItemText(theDialog, button, name); ! /* Resize the button to fit its name */ width = StringWidth(name) + 2 * dfltButtonEdge; ! /* Limit the size of any button to an acceptable value. */ ! /* TODO: Should be based on the message width */ if (width > maxButtonWidth) width = maxButtonWidth; macSizeDialogItem(theDialog, button, width, 0); --- 5478,5493 ---- buttonChar++; name[0] = len; ! // Add the button ! AppendDITL(theDialog, buttonDITL, overlayDITL); // appendDITLRight); ! // Change the button's name macSetDialogItemText(theDialog, button, name); ! // Resize the button to fit its name width = StringWidth(name) + 2 * dfltButtonEdge; ! // Limit the size of any button to an acceptable value. ! // TODO: Should be based on the message width if (width > maxButtonWidth) width = maxButtonWidth; macSizeDialogItem(theDialog, button, width, 0); *************** *** 5515,5521 **** ReleaseResource(buttonDITL); lastButton = button; ! /* Add the icon to the Dialog Box. */ iconItm.idx = lastButton + 1; iconDITL = GetResource('DITL', 131); switch (type) --- 5500,5506 ---- ReleaseResource(buttonDITL); lastButton = button; ! // Add the icon to the Dialog Box. iconItm.idx = lastButton + 1; iconDITL = GetResource('DITL', 131); switch (type) *************** *** 5530,5540 **** AppendDITL(theDialog, iconDITL, overlayDITL); ReleaseResource(iconDITL); GetDialogItem(theDialog, iconItm.idx, &itemType, &itemHandle, &box); ! /* TODO: Should the item be freed? */ iconHandle = GetIcon(useIcon); SetDialogItem(theDialog, iconItm.idx, itemType, iconHandle, &box); ! /* Add the message to the Dialog box. */ messageItm.idx = lastButton + 2; messageDITL = GetResource('DITL', 132); AppendDITL(theDialog, messageDITL, overlayDITL); --- 5515,5525 ---- AppendDITL(theDialog, iconDITL, overlayDITL); ReleaseResource(iconDITL); GetDialogItem(theDialog, iconItm.idx, &itemType, &itemHandle, &box); ! // TODO: Should the item be freed? iconHandle = GetIcon(useIcon); SetDialogItem(theDialog, iconItm.idx, itemType, iconHandle, &box); ! // Add the message to the Dialog box. messageItm.idx = lastButton + 2; messageDITL = GetResource('DITL', 132); AppendDITL(theDialog, messageDITL, overlayDITL); *************** *** 5544,5605 **** SetDialogItemText(itemHandle, name); messageItm.width = StringWidth(name); ! /* Add the input box if needed */ if (textfield != NULL) { ! /* Cheat for now reuse the message and convert to text edit */ inputItm.idx = lastButton + 3; inputDITL = GetResource('DITL', 132); AppendDITL(theDialog, inputDITL, overlayDITL); ReleaseResource(inputDITL); GetDialogItem(theDialog, inputItm.idx, &itemType, &itemHandle, &box); ! /* SetDialogItem(theDialog, inputItm.idx, kEditTextDialogItem, itemHandle, &box);*/ (void) C2PascalString(textfield, &name); SetDialogItemText(itemHandle, name); inputItm.width = StringWidth(name); ! /* Hotkeys don't make sense if there's a text field */ gDialogHotKeys = NULL; } else ! /* Install hotkey table */ gDialogHotKeys = (short *)&hotKeys; ! /* Set the and button. */ SetDialogDefaultItem(theDialog, dfltbutton); SetDialogCancelItem(theDialog, 0); ! /* Reposition element */ ! /* Check if we need to force vertical */ if (totalButtonWidth > maximumWidth) vertical = TRUE; ! /* Place icon */ macMoveDialogItem(theDialog, iconItm.idx, dfltIconSideSpace, dfltElementSpacing, &box); iconItm.box.right = box.right; iconItm.box.bottom = box.bottom; ! /* Place Message */ messageItm.box.left = iconItm.box.right + dfltIconSideSpace; macSizeDialogItem(theDialog, messageItm.idx, 0, messageLines * (textFontInfo.ascent + textFontInfo.descent)); macMoveDialogItem(theDialog, messageItm.idx, messageItm.box.left, dfltElementSpacing, &messageItm.box); ! /* Place Input */ if (textfield != NULL) { inputItm.box.left = messageItm.box.left; inputItm.box.top = messageItm.box.bottom + dfltElementSpacing; macSizeDialogItem(theDialog, inputItm.idx, 0, textFontInfo.ascent + textFontInfo.descent); macMoveDialogItem(theDialog, inputItm.idx, inputItm.box.left, inputItm.box.top, &inputItm.box); ! /* Convert the static text into a text edit. ! * For some reason this change need to be done last (Dany) */ GetDialogItem(theDialog, inputItm.idx, &itemType, &itemHandle, &inputItm.box); SetDialogItem(theDialog, inputItm.idx, kEditTextDialogItem, itemHandle, &inputItm.box); SelectDialogItemText(theDialog, inputItm.idx, 0, 32767); } ! /* Place Button */ if (textfield != NULL) { buttonItm.box.left = inputItm.box.left; --- 5529,5590 ---- SetDialogItemText(itemHandle, name); messageItm.width = StringWidth(name); ! // Add the input box if needed if (textfield != NULL) { ! // Cheat for now reuse the message and convert to text edit inputItm.idx = lastButton + 3; inputDITL = GetResource('DITL', 132); AppendDITL(theDialog, inputDITL, overlayDITL); ReleaseResource(inputDITL); GetDialogItem(theDialog, inputItm.idx, &itemType, &itemHandle, &box); ! // SetDialogItem(theDialog, inputItm.idx, kEditTextDialogItem, itemHandle, &box); (void) C2PascalString(textfield, &name); SetDialogItemText(itemHandle, name); inputItm.width = StringWidth(name); ! // Hotkeys don't make sense if there's a text field gDialogHotKeys = NULL; } else ! // Install hotkey table gDialogHotKeys = (short *)&hotKeys; ! // Set the and button. SetDialogDefaultItem(theDialog, dfltbutton); SetDialogCancelItem(theDialog, 0); ! // Reposition element ! // Check if we need to force vertical if (totalButtonWidth > maximumWidth) vertical = TRUE; ! // Place icon macMoveDialogItem(theDialog, iconItm.idx, dfltIconSideSpace, dfltElementSpacing, &box); iconItm.box.right = box.right; iconItm.box.bottom = box.bottom; ! // Place Message messageItm.box.left = iconItm.box.right + dfltIconSideSpace; macSizeDialogItem(theDialog, messageItm.idx, 0, messageLines * (textFontInfo.ascent + textFontInfo.descent)); macMoveDialogItem(theDialog, messageItm.idx, messageItm.box.left, dfltElementSpacing, &messageItm.box); ! // Place Input if (textfield != NULL) { inputItm.box.left = messageItm.box.left; inputItm.box.top = messageItm.box.bottom + dfltElementSpacing; macSizeDialogItem(theDialog, inputItm.idx, 0, textFontInfo.ascent + textFontInfo.descent); macMoveDialogItem(theDialog, inputItm.idx, inputItm.box.left, inputItm.box.top, &inputItm.box); ! // Convert the static text into a text edit. ! // For some reason this change need to be done last (Dany) GetDialogItem(theDialog, inputItm.idx, &itemType, &itemHandle, &inputItm.box); SetDialogItem(theDialog, inputItm.idx, kEditTextDialogItem, itemHandle, &inputItm.box); SelectDialogItemText(theDialog, inputItm.idx, 0, 32767); } ! // Place Button if (textfield != NULL) { buttonItm.box.left = inputItm.box.left; *************** *** 5615,5661 **** { macMoveDialogItem(theDialog, button, buttonItm.box.left, buttonItm.box.top, &box); ! /* With vertical, it's better to have all buttons the same length */ if (vertical) { macSizeDialogItem(theDialog, button, widestButton, 0); GetDialogItem(theDialog, button, &itemType, &itemHandle, &box); } ! /* Calculate position of next button */ if (vertical) buttonItm.box.top = box.bottom + dfltElementSpacing; else buttonItm.box.left = box.right + dfltElementSpacing; } ! /* Resize the dialog box */ dialogHeight = box.bottom + dfltElementSpacing; SizeWindow(theWindow, maximumWidth, dialogHeight, TRUE); ! /* Magic resize */ AutoSizeDialog(theDialog); ! /* Need a horizontal resize anyway so not that useful */ ! /* Display it */ ShowWindow(theWindow); ! /* BringToFront(theWindow); */ SelectWindow(theWindow); ! /* DrawDialog(theDialog); */ #if 0 GetPort(&oldPort); SetPortDialogPort(theDialog); #endif #ifdef USE_CARBONKEYHANDLER ! /* Avoid that we use key events for the main window. */ dialog_busy = TRUE; #endif ! /* Prepare the shortcut-handling filterProc for handing to the dialog */ dialogUPP = NewModalFilterUPP(DialogHotkeyFilterProc); ! /* Hang until one of the button is hit */ do ModalDialog(dialogUPP, &itemHit); while ((itemHit < 1) || (itemHit > lastButton)); --- 5600,5646 ---- { macMoveDialogItem(theDialog, button, buttonItm.box.left, buttonItm.box.top, &box); ! // With vertical, it's better to have all buttons the same length if (vertical) { macSizeDialogItem(theDialog, button, widestButton, 0); GetDialogItem(theDialog, button, &itemType, &itemHandle, &box); } ! // Calculate position of next button if (vertical) buttonItm.box.top = box.bottom + dfltElementSpacing; else buttonItm.box.left = box.right + dfltElementSpacing; } ! // Resize the dialog box dialogHeight = box.bottom + dfltElementSpacing; SizeWindow(theWindow, maximumWidth, dialogHeight, TRUE); ! // Magic resize AutoSizeDialog(theDialog); ! // Need a horizontal resize anyway so not that useful ! // Display it ShowWindow(theWindow); ! // BringToFront(theWindow); SelectWindow(theWindow); ! // DrawDialog(theDialog); #if 0 GetPort(&oldPort); SetPortDialogPort(theDialog); #endif #ifdef USE_CARBONKEYHANDLER ! // Avoid that we use key events for the main window. dialog_busy = TRUE; #endif ! // Prepare the shortcut-handling filterProc for handing to the dialog dialogUPP = NewModalFilterUPP(DialogHotkeyFilterProc); ! // Hang until one of the button is hit do ModalDialog(dialogUPP, &itemHit); while ((itemHit < 1) || (itemHit > lastButton)); *************** *** 5664,5689 **** dialog_busy = FALSE; #endif ! /* Copy back the text entered by the user into the param */ if (textfield != NULL) { GetDialogItem(theDialog, inputItm.idx, &itemType, &itemHandle, &box); GetDialogItemText(itemHandle, (char_u *) &name); #if IOSIZE < 256 ! /* Truncate the name to IOSIZE if needed */ if (name[0] > IOSIZE) name[0] = IOSIZE - 1; #endif vim_strncpy(textfield, &name[1], name[0]); } ! /* Restore the original graphical port */ SetPort(oldPort); ! /* Free the modal filterProc */ DisposeRoutineDescriptor(dialogUPP); ! /* Get ride of the dialog (free memory) */ DisposeDialog(theDialog); return itemHit; --- 5649,5674 ---- dialog_busy = FALSE; #endif ! // Copy back the text entered by the user into the param if (textfield != NULL) { GetDialogItem(theDialog, inputItm.idx, &itemType, &itemHandle, &box); GetDialogItemText(itemHandle, (char_u *) &name); #if IOSIZE < 256 ! // Truncate the name to IOSIZE if needed if (name[0] > IOSIZE) name[0] = IOSIZE - 1; #endif vim_strncpy(textfield, &name[1], name[0]); } ! // Restore the original graphical port SetPort(oldPort); ! // Free the modal filterProc DisposeRoutineDescriptor(dialogUPP); ! // Get ride of the dialog (free memory) DisposeDialog(theDialog); return itemHit; *************** *** 5696,5702 **** * AutoSizeDialog(): Magic resize of dialog based on text length */ } ! #endif /* FEAT_DIALOG_GUI */ /* * Display the saved error message(s). --- 5681,5687 ---- * AutoSizeDialog(): Magic resize of dialog based on text length */ } ! #endif // FEAT_DIALOG_GUI /* * Display the saved error message(s). *************** *** 5711,5717 **** if (error_ga.ga_data == NULL) return; ! /* avoid putting up a message box with blanks only */ for (p = (char *)error_ga.ga_data; *p; ++p) if (!isspace(*p)) { --- 5696,5702 ---- if (error_ga.ga_data == NULL) return; ! // avoid putting up a message box with blanks only for (p = (char *)error_ga.ga_data; *p; ++p) if (!isspace(*p)) { *************** *** 5724,5733 **** ParamText(pError, nil, nil, nil); Alert(128, nil); break; ! /* TODO: handled message longer than 256 chars ! * use auto-sizeable alert ! * or dialog with scrollbars (TextEdit zone) ! */ } ga_clear(&error_ga); } --- 5709,5717 ---- ParamText(pError, nil, nil, nil); Alert(128, nil); break; ! // TODO: handled message longer than 256 chars ! // use auto-sizeable alert ! // or dialog with scrollbars (TextEdit zone) } ga_clear(&error_ga); } *************** *** 5750,5758 **** void gui_mch_setmouse(int x, int y) { ! /* TODO */ #if 0 ! /* From FAQ 3-11 */ CursorDevicePtr myMouse; Point where; --- 5734,5742 ---- void gui_mch_setmouse(int x, int y) { ! // TODO #if 0 ! // From FAQ 3-11 CursorDevicePtr myMouse; Point where; *************** *** 5760,5766 **** if ( NGetTrapAddress(_CursorDeviceDispatch, ToolTrap) != NGetTrapAddress(_Unimplemented, ToolTrap)) { ! /* New way */ /* * Get first device with one button. --- 5744,5750 ---- if ( NGetTrapAddress(_CursorDeviceDispatch, ToolTrap) != NGetTrapAddress(_Unimplemented, ToolTrap)) { ! // New way /* * Get first device with one button. *************** *** 5773,5779 **** do { ! /* Get the next cursor device */ CursorDeviceNextDevice(&myMouse); } while ((myMouse != nil) && (myMouse->cntButtons != 1)); --- 5757,5763 ---- do { ! // Get the next cursor device CursorDeviceNextDevice(&myMouse); } while ((myMouse != nil) && (myMouse->cntButtons != 1)); *************** *** 5782,5788 **** } else { ! /* Old way */ where.h = x; where.v = y; --- 5766,5772 ---- } else { ! // Old way where.h = x; where.v = y; *************** *** 5811,5826 **** Str255 HelpName = ""; GrafPtr savePort; ! /* Save Current Port: On MacOS X we seem to lose the port */ ! GetPort(&savePort); /*OSX*/ GetMouse(&where); ! LocalToGlobal(&where); /*OSX*/ CntxMenu = menu->submenu_handle; ! /* TODO: Get the text selection from Vim */ ! /* Call to Handle Popup */ status = ContextualMenuSelect(CntxMenu, where, false, kCMHelpItemRemoveHelp, HelpName, NULL, &CntxType, &CntxMenuID, &CntxMenuItem); --- 5795,5810 ---- Str255 HelpName = ""; GrafPtr savePort; ! // Save Current Port: On MacOS X we seem to lose the port ! GetPort(&savePort); //OSX GetMouse(&where); ! LocalToGlobal(&where); //OSX CntxMenu = menu->submenu_handle; ! // TODO: Get the text selection from Vim ! // Call to Handle Popup status = ContextualMenuSelect(CntxMenu, where, false, kCMHelpItemRemoveHelp, HelpName, NULL, &CntxType, &CntxMenuID, &CntxMenuItem); *************** *** 5828,5851 **** { if (CntxType == kCMMenuItemSelected) { ! /* Handle the menu CntxMenuID, CntxMenuItem */ ! /* The submenu can be handle directly by gui_mac_handle_menu */ ! /* But what about the current menu, is the menu changed by ! * ContextualMenuSelect */ gui_mac_handle_menu((CntxMenuID << 16) + CntxMenuItem); } else if (CntxMenuID == kCMShowHelpSelected) { ! /* Should come up with the help */ } } ! /* Restore original Port */ ! SetPort(savePort); /*OSX*/ } #if defined(FEAT_CW_EDITOR) || defined(PROTO) ! /* TODO: Is it need for MACOS_X? (Dany) */ void mch_post_buffer_write(buf_T *buf) { --- 5812,5835 ---- { if (CntxType == kCMMenuItemSelected) { ! // Handle the menu CntxMenuID, CntxMenuItem ! // The submenu can be handle directly by gui_mac_handle_menu ! // But what about the current menu, is the menu changed by ! // ContextualMenuSelect gui_mac_handle_menu((CntxMenuID << 16) + CntxMenuItem); } else if (CntxMenuID == kCMShowHelpSelected) { ! // Should come up with the help } } ! // Restore original Port ! SetPort(savePort); //OSX } #if defined(FEAT_CW_EDITOR) || defined(PROTO) ! // TODO: Is it need for MACOS_X? (Dany) void mch_post_buffer_write(buf_T *buf) { *************** *** 5862,5870 **** void gui_mch_settitle(char_u *title, char_u *icon) { ! /* TODO: Get vim to make sure maxlen (from p_titlelen) is smaller ! * that 256. Even better get it to fit nicely in the titlebar. ! */ #ifdef MACOS_CONVERT CFStringRef windowTitle; size_t windowTitleLen; --- 5846,5853 ---- void gui_mch_settitle(char_u *title, char_u *icon) { ! // TODO: Get vim to make sure maxlen (from p_titlelen) is smaller ! // that 256. Even better get it to fit nicely in the titlebar. #ifdef MACOS_CONVERT CFStringRef windowTitle; size_t windowTitleLen; *************** *** 5872,5878 **** char_u *pascalTitle; #endif ! if (title == NULL) /* nothing to do */ return; #ifdef MACOS_CONVERT --- 5855,5861 ---- char_u *pascalTitle; #endif ! if (title == NULL) // nothing to do return; #ifdef MACOS_CONVERT *************** *** 5925,5931 **** int GetFSSpecFromPath(char_u *file, FSSpec *fileFSSpec) { ! /* From FAQ 8-12 */ Str255 filePascal; CInfoPBRec myCPB; OSErr err; --- 5908,5914 ---- int GetFSSpecFromPath(char_u *file, FSSpec *fileFSSpec) { ! // From FAQ 8-12 Str255 filePascal; CInfoPBRec myCPB; OSErr err; *************** *** 5939,5948 **** err= PBGetCatInfo(&myCPB, false); ! /* vRefNum, dirID, name */ FSMakeFSSpec(0, 0, filePascal, fileFSSpec); ! /* TODO: Use an error code mechanism */ return 0; } --- 5922,5931 ---- err= PBGetCatInfo(&myCPB, false); ! // vRefNum, dirID, name FSMakeFSSpec(0, 0, filePascal, fileFSSpec); ! // TODO: Use an error code mechanism return 0; } *************** *** 5976,6011 **** #endif #ifdef USE_UNIXFILENAME ! /* Get the default volume */ ! /* TODO: Remove as this only work if Vim is on the Boot Volume*/ error=HGetVol(NULL, &dfltVol_vRefNum, &dfltVol_dirID); if (error) return NULL; #endif ! /* Start filling fname with file.name */ vim_strncpy(filenamePtr, &file.name[1], file.name[0]); ! /* Get the info about the file specified in FSSpec */ theCPB.dirInfo.ioFDirIndex = 0; theCPB.dirInfo.ioNamePtr = file.name; theCPB.dirInfo.ioVRefNum = file.vRefNum; ! /*theCPB.hFileInfo.ioDirID = 0;*/ theCPB.dirInfo.ioDrDirID = file.parID; ! /* As ioFDirIndex = 0, get the info of ioNamePtr, ! which is relative to ioVrefNum, ioDirID */ error = PBGetCatInfo(&theCPB, false); ! /* If we are called for a new file we expect fnfErr */ if ((error) && (error != fnfErr)) return NULL; ! /* Check if it's a file or folder */ ! /* default to file if file don't exist */ if (((theCPB.hFileInfo.ioFlAttrib & ioDirMask) == 0) || (error)) ! folder = 0; /* It's not a folder */ else folder = 1; --- 5959,5994 ---- #endif #ifdef USE_UNIXFILENAME ! // Get the default volume ! // TODO: Remove as this only work if Vim is on the Boot Volume error=HGetVol(NULL, &dfltVol_vRefNum, &dfltVol_dirID); if (error) return NULL; #endif ! // Start filling fname with file.name vim_strncpy(filenamePtr, &file.name[1], file.name[0]); ! // Get the info about the file specified in FSSpec theCPB.dirInfo.ioFDirIndex = 0; theCPB.dirInfo.ioNamePtr = file.name; theCPB.dirInfo.ioVRefNum = file.vRefNum; ! //theCPB.hFileInfo.ioDirID = 0; theCPB.dirInfo.ioDrDirID = file.parID; ! // As ioFDirIndex = 0, get the info of ioNamePtr, ! // which is relative to ioVrefNum, ioDirID error = PBGetCatInfo(&theCPB, false); ! // If we are called for a new file we expect fnfErr if ((error) && (error != fnfErr)) return NULL; ! // Check if it's a file or folder ! // default to file if file don't exist if (((theCPB.hFileInfo.ioFlAttrib & ioDirMask) == 0) || (error)) ! folder = 0; // It's not a folder else folder = 1; *************** *** 6016,6027 **** */ if (error == fnfErr) { ! /* If the file to be saved does not already exist, it isn't possible ! to convert its FSSpec into an FSRef. But we can construct an ! FSSpec for the file's parent folder (since we have its volume and ! directory IDs), and since that folder does exist, we can convert ! that FSSpec into an FSRef, convert the FSRef in turn into a path, ! and, finally, append the filename. */ FSSpec dirSpec; FSRef dirRef; Str255 emptyFilename = "\p"; --- 5999,6010 ---- */ if (error == fnfErr) { ! // If the file to be saved does not already exist, it isn't possible ! // to convert its FSSpec into an FSRef. But we can construct an ! // FSSpec for the file's parent folder (since we have its volume and ! // directory IDs), and since that folder does exist, we can convert ! // that FSSpec into an FSRef, convert the FSRef in turn into a path, ! // and, finally, append the filename. FSSpec dirSpec; FSRef dirRef; Str255 emptyFilename = "\p"; *************** *** 6043,6050 **** } else { ! /* If the file to be saved already exists, we can get its full path ! by converting its FSSpec into an FSRef. */ error=FSpMakeFSRef(&file, &refFile); if (error) return NULL; --- 6026,6033 ---- } else { ! // If the file to be saved already exists, we can get its full path ! // by converting its FSSpec into an FSRef. error=FSpMakeFSRef(&file, &refFile); if (error) return NULL; *************** *** 6054,6071 **** return NULL; } ! /* Add a slash at the end if needed */ if (folder) STRCAT(path, "/"); return (vim_strsave(path)); #else ! /* TODO: Get rid of all USE_UNIXFILENAME below */ ! /* Set ioNamePtr, it's the same area which is always reused. */ theCPB.dirInfo.ioNamePtr = directoryName; ! /* Trick for first entry, set ioDrParID to the first value ! * we want for ioDrDirID*/ theCPB.dirInfo.ioDrParID = file.parID; theCPB.dirInfo.ioDrDirID = file.parID; --- 6037,6054 ---- return NULL; } ! // Add a slash at the end if needed if (folder) STRCAT(path, "/"); return (vim_strsave(path)); #else ! // TODO: Get rid of all USE_UNIXFILENAME below ! // Set ioNamePtr, it's the same area which is always reused. theCPB.dirInfo.ioNamePtr = directoryName; ! // Trick for first entry, set ioDrParID to the first value ! // we want for ioDrDirID theCPB.dirInfo.ioDrParID = file.parID; theCPB.dirInfo.ioDrDirID = file.parID; *************** *** 6073,6125 **** do { theCPB.dirInfo.ioFDirIndex = -1; ! /* theCPB.dirInfo.ioNamePtr = directoryName; Already done above. */ theCPB.dirInfo.ioVRefNum = file.vRefNum; ! /* theCPB.dirInfo.ioDirID = irrelevant when ioFDirIndex = -1 */ theCPB.dirInfo.ioDrDirID = theCPB.dirInfo.ioDrParID; ! /* As ioFDirIndex = -1, get the info of ioDrDirID, */ ! /* *ioNamePtr[0 TO 31] will be updated */ error = PBGetCatInfo(&theCPB,false); if (error) return NULL; ! /* Put the new directoryName in front of the current fname */ STRCPY(temporaryPtr, filenamePtr); vim_strncpy(filenamePtr, &directoryName[1], directoryName[0]); STRCAT(filenamePtr, ":"); STRCAT(filenamePtr, temporaryPtr); } ! #if 1 /* def USE_UNIXFILENAME */ ! while ((theCPB.dirInfo.ioDrParID != fsRtDirID) /* && */ ! /* (theCPB.dirInfo.ioDrDirID != fsRtDirID)*/); #else while (theCPB.dirInfo.ioDrDirID != fsRtDirID); #endif ! /* Get the information about the volume on which the file reside */ theCPB.dirInfo.ioFDirIndex = -1; ! /* theCPB.dirInfo.ioNamePtr = directoryName; Already done above. */ theCPB.dirInfo.ioVRefNum = file.vRefNum; ! /* theCPB.dirInfo.ioDirID = irrelevant when ioFDirIndex = -1 */ theCPB.dirInfo.ioDrDirID = theCPB.dirInfo.ioDrParID; ! /* As ioFDirIndex = -1, get the info of ioDrDirID, */ ! /* *ioNamePtr[0 TO 31] will be updated */ error = PBGetCatInfo(&theCPB,false); if (error) return NULL; ! /* For MacOS Classic always add the volume name */ ! /* For MacOS X add the volume name preceded by "Volumes" */ ! /* when we are not referring to the boot volume */ #ifdef USE_UNIXFILENAME if (file.vRefNum != dfltVol_vRefNum) #endif { ! /* Add the volume name */ STRCPY(temporaryPtr, filenamePtr); vim_strncpy(filenamePtr, &directoryName[1], directoryName[0]); STRCAT(filenamePtr, ":"); --- 6056,6108 ---- do { theCPB.dirInfo.ioFDirIndex = -1; ! // theCPB.dirInfo.ioNamePtr = directoryName; Already done above. theCPB.dirInfo.ioVRefNum = file.vRefNum; ! // theCPB.dirInfo.ioDirID = irrelevant when ioFDirIndex = -1 theCPB.dirInfo.ioDrDirID = theCPB.dirInfo.ioDrParID; ! // As ioFDirIndex = -1, get the info of ioDrDirID, ! // *ioNamePtr[0 TO 31] will be updated error = PBGetCatInfo(&theCPB,false); if (error) return NULL; ! // Put the new directoryName in front of the current fname STRCPY(temporaryPtr, filenamePtr); vim_strncpy(filenamePtr, &directoryName[1], directoryName[0]); STRCAT(filenamePtr, ":"); STRCAT(filenamePtr, temporaryPtr); } ! #if 1 // def USE_UNIXFILENAME ! while ((theCPB.dirInfo.ioDrParID != fsRtDirID) ! /* && (theCPB.dirInfo.ioDrDirID != fsRtDirID)*/); #else while (theCPB.dirInfo.ioDrDirID != fsRtDirID); #endif ! // Get the information about the volume on which the file reside theCPB.dirInfo.ioFDirIndex = -1; ! // theCPB.dirInfo.ioNamePtr = directoryName; Already done above. theCPB.dirInfo.ioVRefNum = file.vRefNum; ! // theCPB.dirInfo.ioDirID = irrelevant when ioFDirIndex = -1 theCPB.dirInfo.ioDrDirID = theCPB.dirInfo.ioDrParID; ! // As ioFDirIndex = -1, get the info of ioDrDirID, ! // *ioNamePtr[0 TO 31] will be updated error = PBGetCatInfo(&theCPB,false); if (error) return NULL; ! // For MacOS Classic always add the volume name ! // For MacOS X add the volume name preceded by "Volumes" ! // when we are not referring to the boot volume #ifdef USE_UNIXFILENAME if (file.vRefNum != dfltVol_vRefNum) #endif { ! // Add the volume name STRCPY(temporaryPtr, filenamePtr); vim_strncpy(filenamePtr, &directoryName[1], directoryName[0]); STRCAT(filenamePtr, ":"); *************** *** 6127,6146 **** #ifdef USE_UNIXFILENAME STRCPY(temporaryPtr, filenamePtr); ! filenamePtr[0] = 0; /* NULL terminate the string */ STRCAT(filenamePtr, "Volumes:"); STRCAT(filenamePtr, temporaryPtr); #endif } ! /* Append final path separator if it's a folder */ if (folder) STRCAT(fname, ":"); ! /* As we use Unix File Name for MacOS X convert it */ #ifdef USE_UNIXFILENAME ! /* Need to insert leading / */ ! /* TODO: get the above code to use directly the / */ STRCPY(&temporaryPtr[1], filenamePtr); temporaryPtr[0] = '/'; STRCPY(filenamePtr, temporaryPtr); --- 6110,6129 ---- #ifdef USE_UNIXFILENAME STRCPY(temporaryPtr, filenamePtr); ! filenamePtr[0] = 0; // NULL terminate the string STRCAT(filenamePtr, "Volumes:"); STRCAT(filenamePtr, temporaryPtr); #endif } ! // Append final path separator if it's a folder if (folder) STRCAT(fname, ":"); ! // As we use Unix File Name for MacOS X convert it #ifdef USE_UNIXFILENAME ! // Need to insert leading / ! // TODO: get the above code to use directly the / STRCPY(&temporaryPtr[1], filenamePtr); temporaryPtr[0] = '/'; STRCPY(filenamePtr, temporaryPtr); *************** *** 6168,6174 **** im_set_position(int row, int col) { # if 0 ! /* TODO: Implement me! */ im_start_row = row; im_start_col = col; # endif --- 6151,6157 ---- im_set_position(int row, int col) { # if 0 ! // TODO: Implement me! im_start_row = row; im_start_col = col; # endif *************** *** 6197,6203 **** { im_initialized = 1; ! /* save default TSM component (should be U.S.) to default */ GetDefaultInputMethodOfClass(&gTSCDefault, &gTSLDefault, kKeyboardInputMethodClass); } --- 6180,6186 ---- { im_initialized = 1; ! // save default TSM component (should be U.S.) to default GetDefaultInputMethodOfClass(&gTSCDefault, &gTSLDefault, kKeyboardInputMethodClass); } *************** *** 6250,6256 **** { im_initialized = 1; ! /* save default TSM component (should be U.S.) to default */ GetDefaultInputMethodOfClass(&gTSCDefault, &gTSLDefault, kKeyboardInputMethodClass); } --- 6233,6239 ---- { im_initialized = 1; ! // save default TSM component (should be U.S.) to default GetDefaultInputMethodOfClass(&gTSCDefault, &gTSLDefault, kKeyboardInputMethodClass); } *************** *** 6282,6289 **** GetDefaultInputMethodOfClass(&gTSCInsert, slptr, kKeyboardInputMethodClass); ! /* restore to default when switch to normal mode, so than we could ! * enter commands easier */ SetDefaultInputMethodOfClass(gTSCDefault, &gTSLDefault, kKeyboardInputMethodClass); SetTextServiceLanguage(&gTSLDefault); --- 6265,6272 ---- GetDefaultInputMethodOfClass(&gTSCInsert, slptr, kKeyboardInputMethodClass); ! // restore to default when switch to normal mode, so than we could ! // enter commands easier SetDefaultInputMethodOfClass(gTSCDefault, &gTSLDefault, kKeyboardInputMethodClass); SetTextServiceLanguage(&gTSLDefault); *** ../vim-8.1.2382/src/gui_motif.c 2019-05-28 23:08:12.064648717 +0200 --- src/gui_motif.c 2019-12-02 22:21:16.265726472 +0100 *************** *** 49,55 **** # include #endif ! #include "gui_xmebw.h" /* for our Enhanced Button Widget */ #if defined(FEAT_GUI_DIALOG) && defined(HAVE_XPM) # include "../pixmaps/alert.xpm" --- 49,55 ---- # include #endif ! #include "gui_xmebw.h" // for our Enhanced Button Widget #if defined(FEAT_GUI_DIALOG) && defined(HAVE_XPM) # include "../pixmaps/alert.xpm" *************** *** 80,86 **** #endif #ifdef FEAT_MENU # if (XmVersion >= 1002) ! /* remember the last set value for the tearoff item */ static int tearoff_val = (int)XmTEAR_OFF_ENABLED; # endif static Widget menuBar; --- 80,86 ---- #endif #ifdef FEAT_MENU # if (XmVersion >= 1002) ! // remember the last set value for the tearoff item static int tearoff_val = (int)XmTEAR_OFF_ENABLED; # endif static Widget menuBar; *************** *** 178,187 **** XtVaGetValues(tab_scroll_w, XmNx, &pos_x, XmNy, &pos_y, XmNwidth, &width, XmNheight, &height, NULL); if (pos_x >= 0) { ! /* Tab scroller (next) is visible */ if ((event->x >= pos_x) && (event->x <= pos_x + width) && (event->y >= pos_y) && (event->y <= pos_y + height)) { ! /* Clicked on the scroller */ return TRUE; } } --- 178,187 ---- XtVaGetValues(tab_scroll_w, XmNx, &pos_x, XmNy, &pos_y, XmNwidth, &width, XmNheight, &height, NULL); if (pos_x >= 0) { ! // Tab scroller (next) is visible if ((event->x >= pos_x) && (event->x <= pos_x + width) && (event->y >= pos_y) && (event->y <= pos_y + height)) { ! // Clicked on the scroller return TRUE; } } *************** *** 238,244 **** if (event->button != Button3) return; ! /* When ignoring events don't show the menu. */ if (hold_gui_events # ifdef FEAT_CMDWIN || cmdwin_type != 0 --- 238,244 ---- if (event->button != Button3) return; ! // When ignoring events don't show the menu. if (hold_gui_events # ifdef FEAT_CMDWIN || cmdwin_type != 0 *************** *** 249,255 **** if (event->subwindow != None) { tab_w = XtWindowToWidget(XtDisplay(w), event->subwindow); ! /* LINTED: avoid warning: dubious operation on enum */ if (tab_w != (Widget)0 && XmIsPushButton(tab_w)) XtVaGetValues(tab_w, XmNpageNumber, &tab_idx, NULL); } --- 249,255 ---- if (event->subwindow != None) { tab_w = XtWindowToWidget(XtDisplay(w), event->subwindow); ! // LINTED: avoid warning: dubious operation on enum if (tab_w != (Widget)0 && XmIsPushButton(tab_w)) XtVaGetValues(tab_w, XmNpageNumber, &tab_idx, NULL); } *************** *** 316,322 **** _XmFontListGetDefaultFont(lw->label.font, &fs); ! /* FIXME: we should be doing the whole drawing ourself here. */ insensitiveGC = lw->label.insensitive_GC; mask = GCForeground | GCBackground | GCGraphicsExposures; --- 316,322 ---- _XmFontListGetDefaultFont(lw->label.font, &fs); ! // FIXME: we should be doing the whole drawing ourself here. insensitiveGC = lw->label.insensitive_GC; mask = GCForeground | GCBackground | GCGraphicsExposures; *************** *** 407,413 **** XmRepTypeInstallTearOffModelConverter(); #endif ! /* Make sure the "Quit" menu entry of the window manager is ignored */ XtVaSetValues(vimShell, XmNdeleteResponse, XmDO_NOTHING, NULL); vimForm = XtVaCreateManagedWidget("vimForm", --- 407,413 ---- XmRepTypeInstallTearOffModelConverter(); #endif ! // Make sure the "Quit" menu entry of the window manager is ignored XtVaSetValues(vimShell, XmNdeleteResponse, XmDO_NOTHING, NULL); vimForm = XtVaCreateManagedWidget("vimForm", *************** *** 423,429 **** #ifdef FEAT_MENU { ! Arg al[7]; /* Make sure there is enough room for arguments! */ int ac = 0; # if (XmVersion >= 1002) --- 423,429 ---- #ifdef FEAT_MENU { ! Arg al[7]; // Make sure there is enough room for arguments! int ac = 0; # if (XmVersion >= 1002) *************** *** 433,446 **** XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++; XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++; # ifndef FEAT_TOOLBAR ! /* Always stick to right hand side. */ XtSetArg(al[ac], XmNrightOffset, 0); ac++; # endif XtSetArg(al[ac], XmNmarginHeight, 0); ac++; menuBar = XmCreateMenuBar(vimForm, "menuBar", al, ac); XtManageChild(menuBar); ! /* Remember the default colors, needed for ":hi clear". */ XtVaGetValues(menuBar, XmNbackground, &gui.menu_def_bg_pixel, XmNforeground, &gui.menu_def_fg_pixel, --- 433,446 ---- XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++; XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++; # ifndef FEAT_TOOLBAR ! // Always stick to right hand side. XtSetArg(al[ac], XmNrightOffset, 0); ac++; # endif XtSetArg(al[ac], XmNmarginHeight, 0); ac++; menuBar = XmCreateMenuBar(vimForm, "menuBar", al, ac); XtManageChild(menuBar); ! // Remember the default colors, needed for ":hi clear". XtVaGetValues(menuBar, XmNbackground, &gui.menu_def_bg_pixel, XmNforeground, &gui.menu_def_fg_pixel, *************** *** 483,489 **** #endif #ifdef FEAT_GUI_TABLINE ! /* Create the Vim GUI tabline */ n = 0; XtSetArg(args[n], XmNbindingType, XmNONE); n++; XtSetArg(args[n], XmNorientation, XmVERTICAL); n++; --- 483,489 ---- #endif #ifdef FEAT_GUI_TABLINE ! // Create the Vim GUI tabline n = 0; XtSetArg(args[n], XmNbindingType, XmNONE); n++; XtSetArg(args[n], XmNorientation, XmVERTICAL); n++; *************** *** 603,609 **** */ gui_x11_callbacks(textArea, vimForm); ! /* Pretend we don't have input focus, we will get an event if we do. */ gui.in_focus = FALSE; } --- 603,609 ---- */ gui_x11_callbacks(textArea, vimForm); ! // Pretend we don't have input focus, we will get an event if we do. gui.in_focus = FALSE; } *************** *** 627,633 **** int h UNUSED) { #ifdef FEAT_TOOLBAR ! /* Give keyboard focus to the textArea instead of the toolbar. */ reset_focus(); #endif } --- 627,633 ---- int h UNUSED) { #ifdef FEAT_TOOLBAR ! // Give keyboard focus to the textArea instead of the toolbar. reset_focus(); #endif } *************** *** 659,677 **** int x, y, win_x, win_y, maxX, maxY; Boolean mappedWhenManaged; ! /* Temporarily set value of XmNmappedWhenManaged ! to stop the dialog from popping up right away */ XtVaGetValues(shell, XmNmappedWhenManaged, &mappedWhenManaged, NULL); XtVaSetValues(shell, XmNmappedWhenManaged, False, NULL); XtManageChild(dialog_child); ! /* Get the pointer position (x, y) */ XQueryPointer(XtDisplay(shell), XtWindow(shell), &root, &child, &x, &y, &win_x, &win_y, &mask); ! /* Translate the pointer position (x, y) into a position for the new ! window that will place the pointer at its center */ XGetGeometry(XtDisplay(shell), XtWindow(shell), &root, &win_x, &win_y, &width, &height, &border_width, &depth); width += 2 * border_width; --- 659,677 ---- int x, y, win_x, win_y, maxX, maxY; Boolean mappedWhenManaged; ! // Temporarily set value of XmNmappedWhenManaged ! // to stop the dialog from popping up right away XtVaGetValues(shell, XmNmappedWhenManaged, &mappedWhenManaged, NULL); XtVaSetValues(shell, XmNmappedWhenManaged, False, NULL); XtManageChild(dialog_child); ! // Get the pointer position (x, y) XQueryPointer(XtDisplay(shell), XtWindow(shell), &root, &child, &x, &y, &win_x, &win_y, &mask); ! // Translate the pointer position (x, y) into a position for the new ! // window that will place the pointer at its center XGetGeometry(XtDisplay(shell), XtWindow(shell), &root, &win_x, &win_y, &width, &height, &border_width, &depth); width += 2 * border_width; *************** *** 679,685 **** x -= width / 2; y -= height / 2; ! /* Ensure that the dialog remains on screen */ maxX = XtScreen(shell)->width - width; maxY = XtScreen(shell)->height - height; if (x < 0) --- 679,685 ---- x -= width / 2; y -= height / 2; ! // Ensure that the dialog remains on screen maxX = XtScreen(shell)->width - width; maxY = XtScreen(shell)->height - height; if (x < 0) *************** *** 691,703 **** if (y > maxY) y = maxY; ! /* Set desired window position in the DialogShell */ XtVaSetValues(shell, XmNx, x, XmNy, y, NULL); ! /* Map the widget */ XtMapWidget(shell); ! /* Restore the value of XmNmappedWhenManaged */ XtVaSetValues(shell, XmNmappedWhenManaged, mappedWhenManaged, NULL); } --- 691,703 ---- if (y > maxY) y = maxY; ! // Set desired window position in the DialogShell XtVaSetValues(shell, XmNx, x, XmNy, y, NULL); ! // Map the widget XtMapWidget(shell); ! // Restore the value of XmNmappedWhenManaged XtVaSetValues(shell, XmNmappedWhenManaged, mappedWhenManaged, NULL); } *************** *** 712,721 **** XmFontList font_list; # if (XmVersion <= 1001) ! /* Motif 1.1 method */ font_list = XmFontListCreate(font, STRING_TAG); # else ! /* Motif 1.2 method */ XmFontListEntry font_list_entry; font_list_entry = XmFontListEntryCreate(STRING_TAG, XmFONT_IS_FONT, --- 712,721 ---- XmFontList font_list; # if (XmVersion <= 1001) ! // Motif 1.1 method font_list = XmFontListCreate(font, STRING_TAG); # else ! // Motif 1.2 method XmFontListEntry font_list_entry; font_list_entry = XmFontListEntryCreate(STRING_TAG, XmFONT_IS_FONT, *************** *** 732,738 **** { XmFontList font_list; ! /* Motif 1.2 method */ XmFontListEntry font_list_entry; font_list_entry = XmFontListEntryCreate(STRING_TAG, --- 732,738 ---- { XmFontList font_list; ! // Motif 1.2 method XmFontListEntry font_list_entry; font_list_entry = XmFontListEntryCreate(STRING_TAG, *************** *** 770,776 **** #ifdef FEAT_TOOLBAR if (XtIsManaged(XtParent(toolBar))) { ! /* toolBar is attached to top form */ XtVaSetValues(XtParent(toolBar), XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, menuBar, --- 770,776 ---- #ifdef FEAT_TOOLBAR if (XtIsManaged(XtParent(toolBar))) { ! // toolBar is attached to top form XtVaSetValues(XtParent(toolBar), XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, menuBar, *************** *** 909,916 **** Arg arg[2]; int n = 0; ! /* Only create the popup menu when it's actually used, otherwise there ! * is a delay when using the right mouse button. */ # if (XmVersion <= 1002) if (mouse_model_popup()) # endif --- 909,916 ---- Arg arg[2]; int n = 0; ! // Only create the popup menu when it's actually used, otherwise there ! // is a delay when using the right mouse button. # if (XmVersion <= 1002) if (mouse_model_popup()) # endif *************** *** 940,946 **** XmNlabelString, label, XmNmnemonic, p_wak[0] == 'n' ? NUL : menu->mnemonic, #if (XmVersion >= 1002) ! /* submenu: count the tearoff item (needed for LessTif) */ XmNpositionIndex, idx + (parent != NULL && tearoff_val == (int)XmTEAR_OFF_ENABLED ? 1 : 0), #endif --- 940,946 ---- XmNlabelString, label, XmNmnemonic, p_wak[0] == 'n' ? NUL : menu->mnemonic, #if (XmVersion >= 1002) ! // submenu: count the tearoff item (needed for LessTif) XmNpositionIndex, idx + (parent != NULL && tearoff_val == (int)XmTEAR_OFF_ENABLED ? 1 : 0), #endif *************** *** 949,958 **** gui_motif_menu_fontlist(menu->id); XmStringFree(label); ! if (menu->id == (Widget)0) /* failed */ return; ! /* add accelerator text */ gui_motif_add_actext(menu); shell = XtVaCreateWidget("subMenuShell", --- 949,958 ---- gui_motif_menu_fontlist(menu->id); XmStringFree(label); ! if (menu->id == (Widget)0) // failed return; ! // add accelerator text gui_motif_add_actext(menu); shell = XtVaCreateWidget("subMenuShell", *************** *** 967,977 **** NULL); gui_motif_menu_colors(menu->submenu_id); ! if (menu->submenu_id == (Widget)0) /* failed */ return; #if (XmVersion >= 1002) ! /* Set the colors for the tear off widget */ toggle_tearoff(menu->submenu_id); #endif --- 967,977 ---- NULL); gui_motif_menu_colors(menu->submenu_id); ! if (menu->submenu_id == (Widget)0) // failed return; #if (XmVersion >= 1002) ! // Set the colors for the tear off widget toggle_tearoff(menu->submenu_id); #endif *************** *** 1005,1011 **** { XmString label; ! /* Add accelerator text, if there is one */ if (menu->actext != NULL && menu->id != (Widget)0) { label = XmStringCreate((char *)menu->actext, STRING_TAG); --- 1005,1011 ---- { XmString label; ! // Add accelerator text, if there is one if (menu->actext != NULL && menu->id != (Widget)0) { label = XmStringCreate((char *)menu->actext, STRING_TAG); *************** *** 1077,1088 **** */ void gui_mch_compute_menu_height( ! Widget id) /* can be NULL when deleting menu */ { Dimension y, maxy; Dimension margin, shadow; vimmenu_T *mp; ! static Dimension height = 21; /* normal height of a menu item */ /* * Get the height of the new item, before managing it, because it will --- 1077,1088 ---- */ void gui_mch_compute_menu_height( ! Widget id) // can be NULL when deleting menu { Dimension y, maxy; Dimension margin, shadow; vimmenu_T *mp; ! static Dimension height = 21; // normal height of a menu item /* * Get the height of the new item, before managing it, because it will *************** *** 1092,1098 **** if (id != (Widget)0) XtVaGetValues(id, XmNheight, &height, NULL); ! /* Find any menu Widget, to be able to call XtManageChild() */ else for (mp = root_menu; mp != NULL; mp = mp->next) if (mp->id != (Widget)0 && menu_is_menubar(mp->name)) --- 1092,1098 ---- if (id != (Widget)0) XtVaGetValues(id, XmNheight, &height, NULL); ! // Find any menu Widget, to be able to call XtManageChild() else for (mp = root_menu; mp != NULL; mp = mp->next) if (mp->id != (Widget)0 && menu_is_menubar(mp->name)) *************** *** 1139,1147 **** */ gui.menu_height = maxy + height - 2 * shadow + 2 * margin + 4; ! /* Somehow the menu bar doesn't resize automatically. Set it here, ! * even though this is a catch 22. Don't do this when starting up, ! * somehow the menu gets very high then. */ if (gui.shell_created) XtVaSetValues(menuBar, XmNheight, gui.menu_height, NULL); } --- 1139,1147 ---- */ gui.menu_height = maxy + height - 2 * shadow + 2 * margin + 4; ! // Somehow the menu bar doesn't resize automatically. Set it here, ! // even though this is a catch 22. Don't do this when starting up, ! // somehow the menu gets very high then. if (gui.shell_created) XtVaSetValues(menuBar, XmNheight, gui.menu_height, NULL); } *************** *** 1168,1174 **** attrs.valuemask = 0; ! /* Create the "sensitive" pixmap */ status = XpmReadFileToPixmap(gui.dpy, RootWindow(gui.dpy, DefaultScreen(gui.dpy)), (char *)path, &map, &mask, &attrs); --- 1168,1174 ---- attrs.valuemask = 0; ! // Create the "sensitive" pixmap status = XpmReadFileToPixmap(gui.dpy, RootWindow(gui.dpy, DefaultScreen(gui.dpy)), (char *)path, &map, &mask, &attrs); *************** *** 1189,1208 **** static char ** get_toolbar_pixmap(vimmenu_T *menu, char **fname) { ! char_u buf[MAXPATHL]; /* buffer storing expanded pathname */ ! char **xpm = NULL; /* xpm array */ int res; *fname = NULL; ! buf[0] = NUL; /* start with NULL path */ if (menu->iconfile != NULL) { ! /* Use the "icon=" argument. */ gui_find_iconfile(menu->iconfile, buf, "xpm"); res = check_xpm(buf); ! /* If it failed, try using the menu name. */ if (res == FAIL && gui_find_bitmap(menu->name, buf, "xpm") == OK) res = check_xpm(buf); if (res == OK) --- 1189,1208 ---- static char ** get_toolbar_pixmap(vimmenu_T *menu, char **fname) { ! char_u buf[MAXPATHL]; // buffer storing expanded pathname ! char **xpm = NULL; // xpm array int res; *fname = NULL; ! buf[0] = NUL; // start with NULL path if (menu->iconfile != NULL) { ! // Use the "icon=" argument. gui_find_iconfile(menu->iconfile, buf, "xpm"); res = check_xpm(buf); ! // If it failed, try using the menu name. if (res == FAIL && gui_find_bitmap(menu->name, buf, "xpm") == OK) res = check_xpm(buf); if (res == OK) *************** *** 1245,1251 **** } return n; } ! #endif /* FEAT_TOOLBAR */ void gui_mch_add_menu_item(vimmenu_T *menu, int idx) --- 1245,1251 ---- } return n; } ! #endif // FEAT_TOOLBAR void gui_mch_add_menu_item(vimmenu_T *menu, int idx) *************** *** 1258,1264 **** # endif # if (XmVersion <= 1002) ! /* Don't add Popup menu items when the popup menu isn't used. */ if (menu_is_child_of_popup(menu) && !mouse_model_popup()) return; # endif --- 1258,1264 ---- # endif # if (XmVersion <= 1002) ! // Don't add Popup menu items when the popup menu isn't used. if (menu_is_child_of_popup(menu) && !mouse_model_popup()) return; # endif *************** *** 1267,1273 **** if (menu_is_toolbar(parent->name)) { WidgetClass type; ! XmString xms = NULL; /* fallback label if pixmap not found */ int n; Arg args[18]; --- 1267,1273 ---- if (menu_is_toolbar(parent->name)) { WidgetClass type; ! XmString xms = NULL; // fallback label if pixmap not found int n; Arg args[18]; *************** *** 1295,1311 **** } else { ! /* Without shadows one can't sense whatever the button has been ! * pressed or not! However we want to save a bit of space... ! * Need the highlightThickness to see the focus. ! */ XtSetArg(args[n], XmNhighlightThickness, 1); n++; XtSetArg(args[n], XmNhighlightOnEnter, True); n++; XtSetArg(args[n], XmNmarginWidth, 0); n++; XtSetArg(args[n], XmNmarginHeight, 0); n++; XtSetArg(args[n], XmNtraversalOn, False); n++; ! /* Set the label here, so that we can switch between icons/text ! * by changing the XmNlabelType resource. */ xms = XmStringCreate((char *)menu->dname, STRING_TAG); XtSetArg(args[n], XmNlabelString, xms); n++; --- 1295,1310 ---- } else { ! // Without shadows one can't sense whatever the button has been ! // pressed or not! However we want to save a bit of space... ! // Need the highlightThickness to see the focus. XtSetArg(args[n], XmNhighlightThickness, 1); n++; XtSetArg(args[n], XmNhighlightOnEnter, True); n++; XtSetArg(args[n], XmNmarginWidth, 0); n++; XtSetArg(args[n], XmNmarginHeight, 0); n++; XtSetArg(args[n], XmNtraversalOn, False); n++; ! // Set the label here, so that we can switch between icons/text ! // by changing the XmNlabelType resource. xms = XmStringCreate((char *)menu->dname, STRING_TAG); XtSetArg(args[n], XmNlabelString, xms); n++; *************** *** 1342,1369 **** menu->parent = parent; menu->submenu_id = NULL; ! /* When adding first item to toolbar it might have to be enabled .*/ if (!XtIsManaged(XtParent(toolBar)) && vim_strchr(p_go, GO_TOOLBAR) != NULL) gui_mch_show_toolbar(TRUE); gui.toolbar_height = gui_mch_compute_toolbar_height(); return; ! } /* toolbar menu item */ # endif ! /* No parent, must be a non-menubar menu */ if (parent->submenu_id == (Widget)0) return; menu->submenu_id = (Widget)0; ! /* Add menu separator */ if (menu_is_separator(menu->name)) { menu->id = XtVaCreateWidget("subMenu", xmSeparatorGadgetClass, parent->submenu_id, #if (XmVersion >= 1002) ! /* count the tearoff item (needed for LessTif) */ XmNpositionIndex, idx + (tearoff_val == (int)XmTEAR_OFF_ENABLED ? 1 : 0), #endif --- 1341,1368 ---- menu->parent = parent; menu->submenu_id = NULL; ! // When adding first item to toolbar it might have to be enabled . if (!XtIsManaged(XtParent(toolBar)) && vim_strchr(p_go, GO_TOOLBAR) != NULL) gui_mch_show_toolbar(TRUE); gui.toolbar_height = gui_mch_compute_toolbar_height(); return; ! } // toolbar menu item # endif ! // No parent, must be a non-menubar menu if (parent->submenu_id == (Widget)0) return; menu->submenu_id = (Widget)0; ! // Add menu separator if (menu_is_separator(menu->name)) { menu->id = XtVaCreateWidget("subMenu", xmSeparatorGadgetClass, parent->submenu_id, #if (XmVersion >= 1002) ! // count the tearoff item (needed for LessTif) XmNpositionIndex, idx + (tearoff_val == (int)XmTEAR_OFF_ENABLED ? 1 : 0), #endif *************** *** 1380,1386 **** XmNlabelString, label, XmNmnemonic, menu->mnemonic, #if (XmVersion >= 1002) ! /* count the tearoff item (needed for LessTif) */ XmNpositionIndex, idx + (tearoff_val == (int)XmTEAR_OFF_ENABLED ? 1 : 0), #endif --- 1379,1385 ---- XmNlabelString, label, XmNmnemonic, menu->mnemonic, #if (XmVersion >= 1002) ! // count the tearoff item (needed for LessTif) XmNpositionIndex, idx + (tearoff_val == (int)XmTEAR_OFF_ENABLED ? 1 : 0), #endif *************** *** 1393,1399 **** { XtAddCallback(menu->id, XmNactivateCallback, gui_x11_menu_cb, (XtPointer)menu); ! /* add accelerator text */ gui_motif_add_actext(menu); } } --- 1392,1398 ---- { XtAddCallback(menu->id, XmNactivateCallback, gui_x11_menu_cb, (XtPointer)menu); ! // add accelerator text gui_motif_add_actext(menu); } } *************** *** 1410,1416 **** { int idx = 0; ! /* When GUI hasn't started the menus have not been created. */ if (!gui.in_use) return; --- 1409,1415 ---- { int idx = 0; ! // When GUI hasn't started the menus have not been created. if (!gui.in_use) return; *************** *** 1422,1434 **** { if (mouse_model_popup()) { ! /* Popup menu will be used. Create the popup menus. */ gui_mch_add_menu(menu, idx); gui_motif_update_mousemodel(menu->children); } else { ! /* Popup menu will not be used. Destroy the popup menus. */ gui_motif_update_mousemodel(menu->children); gui_mch_destroy_menu(menu); } --- 1421,1433 ---- { if (mouse_model_popup()) { ! // Popup menu will be used. Create the popup menus. gui_mch_add_menu(menu, idx); gui_motif_update_mousemodel(menu->children); } else { ! // Popup menu will not be used. Destroy the popup menus. gui_motif_update_mousemodel(menu->children); gui_mch_destroy_menu(menu); } *************** *** 1520,1526 **** static void submenu_change( vimmenu_T *menu, ! int colors) /* TRUE for colors, FALSE for font */ { vimmenu_T *mp; --- 1519,1525 ---- static void submenu_change( vimmenu_T *menu, ! int colors) // TRUE for colors, FALSE for font { vimmenu_T *mp; *************** *** 1532,1539 **** { gui_motif_menu_colors(mp->id); #ifdef FEAT_TOOLBAR ! /* For a toolbar item: Free the pixmap and allocate a new one, ! * so that the background color is right. */ if (mp->xpm != NULL) { int n = 0; --- 1531,1538 ---- { gui_motif_menu_colors(mp->id); #ifdef FEAT_TOOLBAR ! // For a toolbar item: Free the pixmap and allocate a new one, ! // so that the background color is right. if (mp->xpm != NULL) { int n = 0; *************** *** 1543,1549 **** XtSetValues(mp->id, args, n); } # ifdef FEAT_BEVAL_GUI ! /* If we have a tooltip, then we need to change its font */ if (mp->tip != NULL) { Arg args[2]; --- 1542,1548 ---- XtSetValues(mp->id, args, n); } # ifdef FEAT_BEVAL_GUI ! // If we have a tooltip, then we need to change its font if (mp->tip != NULL) { Arg args[2]; *************** *** 1561,1567 **** { gui_motif_menu_fontlist(mp->id); #ifdef FEAT_BEVAL_GUI ! /* If we have a tooltip, then we need to change its font */ if (mp->tip != NULL) { Arg args[1]; --- 1560,1566 ---- { gui_motif_menu_fontlist(mp->id); #ifdef FEAT_BEVAL_GUI ! // If we have a tooltip, then we need to change its font if (mp->tip != NULL) { Arg args[1]; *************** *** 1578,1584 **** if (mp->children != NULL) { #if (XmVersion >= 1002) ! /* Set the colors/font for the tear off widget */ if (mp->submenu_id != (Widget)0) { if (colors) --- 1577,1583 ---- if (mp->children != NULL) { #if (XmVersion >= 1002) ! // Set the colors/font for the tear off widget if (mp->submenu_id != (Widget)0) { if (colors) *************** *** 1588,1594 **** toggle_tearoff(mp->submenu_id); } #endif ! /* Set the colors for the children */ submenu_change(mp->children, colors); } } --- 1587,1593 ---- toggle_tearoff(mp->submenu_id); } #endif ! // Set the colors for the children submenu_change(mp->children, colors); } } *************** *** 1600,1612 **** void gui_mch_destroy_menu(vimmenu_T *menu) { ! /* Please be sure to destroy the parent widget first (i.e. menu->id). ! * On the other hand, problems have been reported that the submenu must be ! * deleted first... ! * ! * This code should be basically identical to that in the file gui_athena.c ! * because they are both Xt based. ! */ if (menu->submenu_id != (Widget)0) { XtDestroyWidget(menu->submenu_id); --- 1599,1610 ---- void gui_mch_destroy_menu(vimmenu_T *menu) { ! // Please be sure to destroy the parent widget first (i.e. menu->id). ! // On the other hand, problems have been reported that the submenu must be ! // deleted first... ! // ! // This code should be basically identical to that in the file gui_athena.c ! // because they are both Xt based. if (menu->submenu_id != (Widget)0) { XtDestroyWidget(menu->submenu_id); *************** *** 1621,1635 **** #if defined(FEAT_TOOLBAR) && defined(FEAT_BEVAL_GUI) if (parent == toolBar && menu->tip != NULL) { ! /* We try to destroy this before the actual menu, because there are ! * callbacks, etc. that will be unregistered during the tooltip ! * destruction. ! * ! * If you call "gui_mch_destroy_beval_area()" after destroying ! * menu->id, then the tooltip's window will have already been ! * deallocated by Xt, and unknown behaviour will ensue (probably ! * a core dump). ! */ gui_mch_destroy_beval_area(menu->tip); menu->tip = NULL; } --- 1619,1632 ---- #if defined(FEAT_TOOLBAR) && defined(FEAT_BEVAL_GUI) if (parent == toolBar && menu->tip != NULL) { ! // We try to destroy this before the actual menu, because there are ! // callbacks, etc. that will be unregistered during the tooltip ! // destruction. ! // ! // If you call "gui_mch_destroy_beval_area()" after destroying ! // menu->id, then the tooltip's window will have already been ! // deallocated by Xt, and unknown behaviour will ensue (probably ! // a core dump). gui_mch_destroy_beval_area(menu->tip); menu->tip = NULL; } *************** *** 1643,1649 **** { Cardinal num_children; ! /* When removing last toolbar item, don't display the toolbar. */ XtVaGetValues(toolBar, XmNnumChildren, &num_children, NULL); if (num_children == 0) gui_mch_show_toolbar(FALSE); --- 1640,1646 ---- { Cardinal num_children; ! // When removing last toolbar item, don't display the toolbar. XtVaGetValues(toolBar, XmNnumChildren, &num_children, NULL); if (num_children == 0) gui_mch_show_toolbar(FALSE); *************** *** 1663,1669 **** #endif } ! #endif /* FEAT_MENU */ /* * Set the menu and scrollbar colors to their default values. --- 1660,1666 ---- #endif } ! #endif // FEAT_MENU /* * Set the menu and scrollbar colors to their default values. *************** *** 1673,1680 **** { if (gui.in_use) { ! /* Use the values saved when starting up. These should come from the ! * window manager or a resources file. */ gui.menu_fg_pixel = gui.menu_def_fg_pixel; gui.menu_bg_pixel = gui.menu_def_bg_pixel; gui.scroll_fg_pixel = gui.scroll_def_fg_pixel; --- 1670,1677 ---- { if (gui.in_use) { ! // Use the values saved when starting up. These should come from the ! // window manager or a resources file. gui.menu_fg_pixel = gui.menu_def_fg_pixel; gui.menu_bg_pixel = gui.menu_def_bg_pixel; gui.scroll_fg_pixel = gui.scroll_def_fg_pixel; *************** *** 1705,1711 **** XmNvalue, val, XmNsliderSize, size, XmNpageIncrement, (size > 2 ? size - 2 : 1), ! XmNmaximum, max + 1, /* Motif has max one past the end */ NULL); } --- 1702,1708 ---- XmNvalue, val, XmNsliderSize, size, XmNpageIncrement, (size > 2 ? size - 2 : 1), ! XmNmaximum, max + 1, // Motif has max one past the end NULL); } *************** *** 1775,1782 **** { if (!gui.which_scrollbars[sb->type]) { ! /* The scrollbars of this type are all disabled, adjust the ! * textArea attachment offset. */ switch (sb->type) { case SBAR_LEFT: --- 1772,1779 ---- { if (!gui.which_scrollbars[sb->type]) { ! // The scrollbars of this type are all disabled, adjust the ! // textArea attachment offset. switch (sb->type) { case SBAR_LEFT: *************** *** 1801,1807 **** void gui_mch_create_scrollbar( scrollbar_T *sb, ! int orient) /* SBAR_VERT or SBAR_HORIZ */ { Arg args[16]; int n; --- 1798,1804 ---- void gui_mch_create_scrollbar( scrollbar_T *sb, ! int orient) // SBAR_VERT or SBAR_HORIZ { Arg args[16]; int n; *************** *** 1835,1841 **** sb->id = XtCreateWidget("scrollBar", xmScrollBarWidgetClass, textAreaForm, args, n); ! /* Remember the default colors, needed for ":hi clear". */ if (gui.scroll_def_bg_pixel == (guicolor_T)0 && gui.scroll_def_fg_pixel == (guicolor_T)0) XtVaGetValues(sb->id, --- 1832,1838 ---- sb->id = XtCreateWidget("scrollBar", xmScrollBarWidgetClass, textAreaForm, args, n); ! // Remember the default colors, needed for ":hi clear". if (gui.scroll_def_bg_pixel == (guicolor_T)0 && gui.scroll_def_fg_pixel == (guicolor_T)0) XtVaGetValues(sb->id, *************** *** 1887,1893 **** NULL); } ! /* This is needed for the rectangle below the vertical scrollbars. */ if (sb == &gui.bottom_sbar && textAreaForm != (Widget)0) gui_motif_scroll_colors(textAreaForm); } --- 1884,1890 ---- NULL); } ! // This is needed for the rectangle below the vertical scrollbars. if (sb == &gui.bottom_sbar && textAreaForm != (Widget)0) gui_motif_scroll_colors(textAreaForm); } *************** *** 2082,2089 **** { XtUnmanageChild(id); XtVaSetValues(id, XmNfontList, fl, NULL); ! /* We should force the widget to recalculate its ! * geometry now. */ XtManageChild(id); } else --- 2079,2086 ---- { XtUnmanageChild(id); XtVaSetValues(id, XmNfontList, fl, NULL); ! // We should force the widget to recalculate its ! // geometry now. XtManageChild(id); } else *************** *** 2101,2108 **** { XtUnmanageChild(id); XtVaSetValues(id, XmNfontList, fl, NULL); ! /* We should force the widget to recalculate its ! * geometry now. */ XtManageChild(id); } else --- 2098,2105 ---- { XtUnmanageChild(id); XtVaSetValues(id, XmNfontList, fl, NULL); ! // We should force the widget to recalculate its ! // geometry now. XtManageChild(id); } else *************** *** 2125,2138 **** typedef struct dialog_callback_arg { ! char * args; /* not used right now */ int id; } dcbarg_T; static Widget dialog_wgt; static char *browse_fname = NULL; static XmStringCharSet charset = (XmStringCharSet) XmSTRING_DEFAULT_CHARSET; ! /* used to set up XmStrings */ static void DialogCancelCB(Widget, XtPointer, XtPointer); static void DialogAcceptCB(Widget, XtPointer, XtPointer); --- 2122,2135 ---- typedef struct dialog_callback_arg { ! char * args; // not used right now int id; } dcbarg_T; static Widget dialog_wgt; static char *browse_fname = NULL; static XmStringCharSet charset = (XmStringCharSet) XmSTRING_DEFAULT_CHARSET; ! // used to set up XmStrings static void DialogCancelCB(Widget, XtPointer, XtPointer); static void DialogAcceptCB(Widget, XtPointer, XtPointer); *************** *** 2208,2229 **** */ char_u * gui_mch_browse( ! int saving UNUSED, /* select file to write */ ! char_u *title, /* title for the window */ ! char_u *dflt, /* default name */ ! char_u *ext UNUSED, /* not used (extension added) */ ! char_u *initdir, /* initial directory, NULL for current dir */ ! char_u *filter) /* file name filter */ { char_u dirbuf[MAXPATHL]; char_u dfltbuf[MAXPATHL]; char_u *pattern; char_u *tofree = NULL; ! /* There a difference between the resource name and value, Therefore, we ! * avoid to (ab-)use the (maybe internationalized!) dialog title as a ! * dialog name. ! */ dialog_wgt = XmCreateFileSelectionDialog(vimShell, "browseDialog", NULL, 0); --- 2205,2225 ---- */ char_u * gui_mch_browse( ! int saving UNUSED, // select file to write ! char_u *title, // title for the window ! char_u *dflt, // default name ! char_u *ext UNUSED, // not used (extension added) ! char_u *initdir, // initial directory, NULL for current dir ! char_u *filter) // file name filter { char_u dirbuf[MAXPATHL]; char_u dfltbuf[MAXPATHL]; char_u *pattern; char_u *tofree = NULL; ! // There a difference between the resource name and value, Therefore, we ! // avoid to (ab-)use the (maybe internationalized!) dialog title as a ! // dialog name. dialog_wgt = XmCreateFileSelectionDialog(vimShell, "browseDialog", NULL, 0); *************** *** 2237,2252 **** dflt = (char_u *)""; else if (STRLEN(initdir) + STRLEN(dflt) + 2 < MAXPATHL) { ! /* The default selection should be the full path, "dflt" is only the ! * file name. */ STRCPY(dfltbuf, initdir); add_pathsep(dfltbuf); STRCAT(dfltbuf, dflt); dflt = dfltbuf; } ! /* Can only use one pattern for a file name. Get the first pattern out of ! * the filter. An empty pattern means everything matches. */ if (filter == NULL) pattern = (char_u *)""; else --- 2233,2248 ---- dflt = (char_u *)""; else if (STRLEN(initdir) + STRLEN(dflt) + 2 < MAXPATHL) { ! // The default selection should be the full path, "dflt" is only the ! // file name. STRCPY(dfltbuf, initdir); add_pathsep(dfltbuf); STRCAT(dfltbuf, dflt); dflt = dfltbuf; } ! // Can only use one pattern for a file name. Get the first pattern out of ! // the filter. An empty pattern means everything matches. if (filter == NULL) pattern = (char_u *)""; else *************** *** 2256,2264 **** s = filter; for (p = filter; *p != NUL; ++p) { ! if (*p == '\t') /* end of description, start of pattern */ s = p + 1; ! if (*p == ';' || *p == '\n') /* end of (first) pattern */ break; } pattern = vim_strnsave(s, p - s); --- 2252,2260 ---- s = filter; for (p = filter; *p != NUL; ++p) { ! if (*p == '\t') // end of description, start of pattern s = p + 1; ! if (*p == ';' || *p == '\n') // end of (first) pattern break; } pattern = vim_strnsave(s, p - s); *************** *** 2287,2295 **** set_predefined_label(dialog_wgt, "OK", _("&OK")); set_predefined_label(dialog_wgt, "Selection", _("Selection")); ! /* This is to save us from silly external settings using not fixed with ! * fonts for file selection. ! */ set_predefined_fontlist(dialog_wgt, "DirListSW.DirList"); set_predefined_fontlist(dialog_wgt, "ItemsListSW.ItemsList"); --- 2283,2290 ---- set_predefined_label(dialog_wgt, "OK", _("&OK")); set_predefined_label(dialog_wgt, "Selection", _("Selection")); ! // This is to save us from silly external settings using not fixed with ! // fonts for file selection. set_predefined_fontlist(dialog_wgt, "DirListSW.DirList"); set_predefined_fontlist(dialog_wgt, "ItemsListSW.ItemsList"); *************** *** 2299,2312 **** XtAddCallback(dialog_wgt, XmNokCallback, DialogAcceptCB, (XtPointer)0); XtAddCallback(dialog_wgt, XmNcancelCallback, DialogCancelCB, (XtPointer)0); ! /* We have no help in this window, so hide help button */ XtUnmanageChild(XmFileSelectionBoxGetChild(dialog_wgt, (unsigned char)XmDIALOG_HELP_BUTTON)); manage_centered(dialog_wgt); activate_dialog_mnemonics(dialog_wgt); ! /* sit in a loop until the dialog box has gone away */ do { XtAppProcessEvent(XtWidgetToApplicationContext(dialog_wgt), --- 2294,2307 ---- XtAddCallback(dialog_wgt, XmNokCallback, DialogAcceptCB, (XtPointer)0); XtAddCallback(dialog_wgt, XmNcancelCallback, DialogCancelCB, (XtPointer)0); ! // We have no help in this window, so hide help button XtUnmanageChild(XmFileSelectionBoxGetChild(dialog_wgt, (unsigned char)XmDIALOG_HELP_BUTTON)); manage_centered(dialog_wgt); activate_dialog_mnemonics(dialog_wgt); ! // sit in a loop until the dialog box has gone away do { XtAppProcessEvent(XtWidgetToApplicationContext(dialog_wgt), *************** *** 2333,2341 **** */ static void DialogCancelCB( ! Widget w UNUSED, /* widget id */ ! XtPointer client_data UNUSED, /* data from application */ ! XtPointer call_data UNUSED) /* data from widget class */ { if (browse_fname != NULL) { --- 2328,2336 ---- */ static void DialogCancelCB( ! Widget w UNUSED, // widget id ! XtPointer client_data UNUSED, // data from application ! XtPointer call_data UNUSED) // data from widget class { if (browse_fname != NULL) { *************** *** 2350,2358 **** */ static void DialogAcceptCB( ! Widget w UNUSED, /* widget id */ ! XtPointer client_data UNUSED, /* data from application */ ! XtPointer call_data) /* data from widget class */ { XmFileSelectionBoxCallbackStruct *fcb; --- 2345,2353 ---- */ static void DialogAcceptCB( ! Widget w UNUSED, // widget id ! XtPointer client_data UNUSED, // data from application ! XtPointer call_data) // data from widget class { XmFileSelectionBoxCallbackStruct *fcb; *************** *** 2363,2376 **** } fcb = (XmFileSelectionBoxCallbackStruct *)call_data; ! /* get the filename from the file selection box */ XmStringGetLtoR(fcb->value, charset, &browse_fname); ! /* popdown the file selection box */ XtUnmanageChild(dialog_wgt); } ! #endif /* FEAT_BROWSE */ #if defined(FEAT_GUI_DIALOG) || defined(PROTO) --- 2358,2371 ---- } fcb = (XmFileSelectionBoxCallbackStruct *)call_data; ! // get the filename from the file selection box XmStringGetLtoR(fcb->value, charset, &browse_fname); ! // popdown the file selection box XtUnmanageChild(dialog_wgt); } ! #endif // FEAT_BROWSE #if defined(FEAT_GUI_DIALOG) || defined(PROTO) *************** *** 2483,2489 **** char_u *message, char_u *button_names, int dfltbutton, ! char_u *textfield, /* buffer of size IOSIZE */ int ex_cmd UNUSED) { char_u *buts; --- 2478,2484 ---- char_u *message, char_u *button_names, int dfltbutton, ! char_u *textfield, // buffer of size IOSIZE int ex_cmd UNUSED) { char_u *buts; *************** *** 2509,2523 **** if (title == NULL) title = (char_u *)_("Vim dialog"); ! /* if our pointer is currently hidden, then we should show it. */ gui_mch_mousehide(FALSE); dialogform = XmCreateFormDialog(vimShell, (char *)"dialog", NULL, 0); ! /* Check 'v' flag in 'guioptions': vertical button placement. */ vertical = (vim_strchr(p_go, GO_VERTICAL) != NULL); ! /* Set the title of the Dialog window */ label = XmStringCreateSimple((char *)title); if (label == NULL) return -1; --- 2504,2518 ---- if (title == NULL) title = (char_u *)_("Vim dialog"); ! // if our pointer is currently hidden, then we should show it. gui_mch_mousehide(FALSE); dialogform = XmCreateFormDialog(vimShell, (char *)"dialog", NULL, 0); ! // Check 'v' flag in 'guioptions': vertical button placement. vertical = (vim_strchr(p_go, GO_VERTICAL) != NULL); ! // Set the title of the Dialog window label = XmStringCreateSimple((char *)title); if (label == NULL) return -1; *************** *** 2528,2539 **** NULL); XmStringFree(label); ! /* make a copy, so that we can insert NULs */ buts = vim_strsave(button_names); if (buts == NULL) return -1; ! /* Count the number of buttons and allocate buttons[]. */ butcount = 1; for (p = buts; *p; ++p) if (*p == DLG_BUTTON_SEP) --- 2523,2534 ---- NULL); XmStringFree(label); ! // make a copy, so that we can insert NULs buts = vim_strsave(button_names); if (buts == NULL) return -1; ! // Count the number of buttons and allocate buttons[]. butcount = 1; for (p = buts; *p; ++p) if (*p == DLG_BUTTON_SEP) *************** *** 2588,2594 **** XmStringFree(label); gui_motif_menu_fontlist(buttons[butcount]); ! /* Layout properly. */ if (butcount > 0) { --- 2583,2589 ---- XmStringFree(label); gui_motif_menu_fontlist(buttons[butcount]); ! // Layout properly. if (butcount > 0) { *************** *** 2605,2611 **** XmNrightOffset, 4, NULL); ! /* fill in a form as invisible separator */ sep_form = XtVaCreateWidget("separatorForm", xmFormWidgetClass, dialogform, XmNleftAttachment, XmATTACH_WIDGET, --- 2600,2606 ---- XmNrightOffset, 4, NULL); ! // fill in a form as invisible separator sep_form = XtVaCreateWidget("separatorForm", xmFormWidgetClass, dialogform, XmNleftAttachment, XmATTACH_WIDGET, *************** *** 2635,2641 **** XmNrightOffset, 4, NULL); ! /* fill in a form as invisible separator */ sep_form = XtVaCreateWidget("separatorForm", xmFormWidgetClass, dialogform, XmNleftAttachment, XmATTACH_FORM, --- 2630,2636 ---- XmNrightOffset, 4, NULL); ! // fill in a form as invisible separator sep_form = XtVaCreateWidget("separatorForm", xmFormWidgetClass, dialogform, XmNleftAttachment, XmATTACH_FORM, *************** *** 2663,2669 **** separator = (Widget) 0; if (butcount > 0) { ! /* Create the separator for beauty. */ n = 0; XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++; --- 2658,2664 ---- separator = (Widget) 0; if (butcount > 0) { ! // Create the separator for beauty. n = 0; XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++; *************** *** 2699,2705 **** (XtEventHandler)keyhit_callback, (XtPointer)NULL); } ! /* Form holding both message and pixmap labels */ form = XtVaCreateWidget("separatorForm", xmFormWidgetClass, dialogform, XmNleftAttachment, XmATTACH_FORM, --- 2694,2700 ---- (XtEventHandler)keyhit_callback, (XtPointer)NULL); } ! // Form holding both message and pixmap labels form = XtVaCreateWidget("separatorForm", xmFormWidgetClass, dialogform, XmNleftAttachment, XmATTACH_FORM, *************** *** 2709,2715 **** XtManageChild(form); #ifdef HAVE_XPM ! /* Add a pixmap, left of the message. */ switch (type) { case VIM_GENERIC: --- 2704,2710 ---- XtManageChild(form); #ifdef HAVE_XPM ! // Add a pixmap, left of the message. switch (type) { case VIM_GENERIC: *************** *** 2744,2755 **** XtManageChild(dialogpixmap); #endif ! /* Create the dialog message. ! * Since LessTif is apparently having problems with the creation of ! * properly localized string, we use LtoR here. The symptom is that the ! * string sill not show properly in multiple lines as it does in native ! * Motif. ! */ label = XmStringCreateLtoR((char *)message, STRING_TAG); if (label == NULL) return -1; --- 2739,2749 ---- XtManageChild(dialogpixmap); #endif ! // Create the dialog message. ! // Since LessTif is apparently having problems with the creation of ! // properly localized string, we use LtoR here. The symptom is that the ! // string sill not show properly in multiple lines as it does in native ! // Motif. label = XmStringCreateLtoR((char *)message, STRING_TAG); if (label == NULL) return -1; *************** *** 2811,2817 **** if (textfield != NULL && *textfield != NUL) { ! /* This only works after the textfield has been realised. */ XmTextFieldSetSelection(dialogtextfield, (XmTextPosition)0, (XmTextPosition)STRLEN(textfield), XtLastTimestampProcessed(gui.dpy)); --- 2805,2811 ---- if (textfield != NULL && *textfield != NUL) { ! // This only works after the textfield has been realised. XmTextFieldSetSelection(dialogtextfield, (XmTextPosition)0, (XmTextPosition)STRLEN(textfield), XtLastTimestampProcessed(gui.dpy)); *************** *** 2821,2827 **** app = XtWidgetToApplicationContext(dialogform); ! /* Loop until a button is pressed or the dialog is killed somehow. */ dialogStatus = -1; for (;;) { --- 2815,2821 ---- app = XtWidgetToApplicationContext(dialogform); ! // Loop until a button is pressed or the dialog is killed somehow. dialogStatus = -1; for (;;) { *************** *** 2847,2863 **** return dialogStatus; } ! #endif /* FEAT_GUI_DIALOG */ #if defined(FEAT_FOOTER) || defined(PROTO) static int gui_mch_compute_footer_height(void) { ! Dimension height; /* total Toolbar height */ ! Dimension top; /* XmNmarginTop */ ! Dimension bottom; /* XmNmarginBottom */ ! Dimension shadow; /* XmNshadowThickness */ XtVaGetValues(footer, XmNheight, &height, --- 2841,2857 ---- return dialogStatus; } ! #endif // FEAT_GUI_DIALOG #if defined(FEAT_FOOTER) || defined(PROTO) static int gui_mch_compute_footer_height(void) { ! Dimension height; // total Toolbar height ! Dimension top; // XmNmarginTop ! Dimension bottom; // XmNmarginBottom ! Dimension shadow; // XmNshadowThickness XtVaGetValues(footer, XmNheight, &height, *************** *** 2905,2920 **** void gui_mch_show_toolbar(int showit) { ! Cardinal numChildren; /* how many children toolBar has */ if (toolBar == (Widget)0) return; XtVaGetValues(toolBar, XmNnumChildren, &numChildren, NULL); if (showit && numChildren > 0) { ! /* Assume that we want to show the toolbar if p_toolbar contains ! * valid option settings, therefore p_toolbar must not be NULL. ! */ WidgetList children; XtVaGetValues(toolBar, XmNchildren, &children, NULL); --- 2899,2913 ---- void gui_mch_show_toolbar(int showit) { ! Cardinal numChildren; // how many children toolBar has if (toolBar == (Widget)0) return; XtVaGetValues(toolBar, XmNnumChildren, &numChildren, NULL); if (showit && numChildren > 0) { ! // Assume that we want to show the toolbar if p_toolbar contains ! // valid option settings, therefore p_toolbar must not be NULL. WidgetList children; XtVaGetValues(toolBar, XmNchildren, &children, NULL); *************** *** 2938,2949 **** for (toolbar = root_menu; toolbar; toolbar = toolbar->next) if (menu_is_toolbar(toolbar->dname)) break; ! /* Assumption: toolbar is NULL if there is no toolbar, ! * otherwise it contains the toolbar menu structure. ! * ! * Assumption: "numChildren" == the number of items in the list ! * of items beginning with toolbar->children. ! */ if (toolbar) { for (cur = toolbar->children; cur; cur = cur->next) --- 2931,2941 ---- for (toolbar = root_menu; toolbar; toolbar = toolbar->next) if (menu_is_toolbar(toolbar->dname)) break; ! // Assumption: toolbar is NULL if there is no toolbar, ! // otherwise it contains the toolbar menu structure. ! // ! // Assumption: "numChildren" == the number of items in the list ! // of items beginning with toolbar->children. if (toolbar) { for (cur = toolbar->children; cur; cur = cur->next) *************** *** 2951,2958 **** Arg args[1]; int n = 0; ! /* Enable/Disable tooltip (OK to enable while ! * currently enabled). */ if (cur->tip != NULL) (*action)(cur->tip); if (!menu_is_separator(cur->name)) --- 2943,2950 ---- Arg args[1]; int n = 0; ! // Enable/Disable tooltip (OK to enable while ! // currently enabled). if (cur->tip != NULL) (*action)(cur->tip); if (!menu_is_separator(cur->name)) *************** *** 3068,3083 **** gui_mch_compute_toolbar_height(void) { Dimension borders; ! Dimension height; /* total Toolbar height */ ! Dimension whgt; /* height of each widget */ ! WidgetList children; /* list of toolBar's children */ ! Cardinal numChildren; /* how many children toolBar has */ int i; borders = 0; height = 0; if (toolBar != (Widget)0 && toolBarFrame != (Widget)0) ! { /* get height of XmFrame parent */ Dimension fst; Dimension fmh; Dimension tst; --- 3060,3075 ---- gui_mch_compute_toolbar_height(void) { Dimension borders; ! Dimension height; // total Toolbar height ! Dimension whgt; // height of each widget ! WidgetList children; // list of toolBar's children ! Cardinal numChildren; // how many children toolBar has int i; borders = 0; height = 0; if (toolBar != (Widget)0 && toolBarFrame != (Widget)0) ! { // get height of XmFrame parent Dimension fst; Dimension fmh; Dimension tst; *************** *** 3103,3109 **** } } #ifdef LESSTIF_VERSION ! /* Hack: When starting up we get wrong dimensions. */ if (height < 10) height = 24; #endif --- 3095,3101 ---- } } #ifdef LESSTIF_VERSION ! // Hack: When starting up we get wrong dimensions. if (height < 10) height = 24; #endif *************** *** 3256,3262 **** if (tabLine == (Widget)0) return; ! /* Add a label for each tab page. They all contain the same text area. */ for (tp = first_tabpage; tp != NULL; tp = tp->tp_next, ++nr) { if (tp == curtab) --- 3248,3254 ---- if (tabLine == (Widget)0) return; ! // Add a label for each tab page. They all contain the same text area. for (tp = first_tabpage; tp != NULL; tp = tp->tp_next, ++nr) { if (tp == curtab) *************** *** 3266,3272 **** if (page_status == XmPAGE_INVALID || page_info.major_tab_widget == (Widget)0) { ! /* Add the tab */ n = 0; XtSetArg(args[n], XmNnotebookChildType, XmMAJOR_TAB); n++; XtSetArg(args[n], XmNtraversalOn, False); n++; --- 3258,3264 ---- if (page_status == XmPAGE_INVALID || page_info.major_tab_widget == (Widget)0) { ! // Add the tab n = 0; XtSetArg(args[n], XmNnotebookChildType, XmMAJOR_TAB); n++; XtSetArg(args[n], XmNtraversalOn, False); n++; *************** *** 3309,3315 **** XtVaGetValues(tabLine, XmNlastPageNumber, &last_page, NULL); ! /* Remove any old labels. */ while (nr <= last_page) { if (XmNotebookGetPageInfo(tabLine, nr, &page_info) != XmPAGE_INVALID --- 3301,3307 ---- XtVaGetValues(tabLine, XmNlastPageNumber, &last_page, NULL); ! // Remove any old labels. while (nr <= last_page) { if (XmNotebookGetPageInfo(tabLine, nr, &page_info) != XmPAGE_INVALID *************** *** 3400,3407 **** { XtUnmanageChild(id); XtVaSetValues(id, XmNfontList, fl, NULL); ! /* We should force the widget to recalculate its ! * geometry now. */ XtManageChild(id); } else --- 3392,3399 ---- { XtUnmanageChild(id); XtVaSetValues(id, XmNfontList, fl, NULL); ! // We should force the widget to recalculate its ! // geometry now. XtManageChild(id); } else *************** *** 3421,3428 **** { XtUnmanageChild(id); XtVaSetValues(id, XmNfontList, fl, NULL); ! /* We should force the widget to recalculate its ! * geometry now. */ XtManageChild(id); } else --- 3413,3420 ---- { XtUnmanageChild(id); XtVaSetValues(id, XmNfontList, fl, NULL); ! // We should force the widget to recalculate its ! // geometry now. XtManageChild(id); } else *************** *** 3441,3457 **** typedef struct _SharedFindReplace { ! Widget dialog; /* the main dialog widget */ ! Widget wword; /* 'Exact match' check button */ ! Widget mcase; /* 'match case' check button */ ! Widget up; /* search direction 'Up' radio button */ ! Widget down; /* search direction 'Down' radio button */ ! Widget what; /* 'Find what' entry text widget */ ! Widget with; /* 'Replace with' entry text widget */ ! Widget find; /* 'Find Next' action button */ ! Widget replace; /* 'Replace With' action button */ ! Widget all; /* 'Replace All' action button */ ! Widget undo; /* 'Undo' action button */ Widget cancel; } SharedFindReplace; --- 3433,3449 ---- typedef struct _SharedFindReplace { ! Widget dialog; // the main dialog widget ! Widget wword; // 'Exact match' check button ! Widget mcase; // 'match case' check button ! Widget up; // search direction 'Up' radio button ! Widget down; // search direction 'Down' radio button ! Widget what; // 'Find what' entry text widget ! Widget with; // 'Replace with' entry text widget ! Widget find; // 'Find Next' action button ! Widget replace; // 'Replace With' action button ! Widget all; // 'Replace All' action button ! Widget undo; // 'Undo' action button Widget cancel; } SharedFindReplace; *************** *** 3468,3474 **** SharedFindReplace *cd = (SharedFindReplace *)client_data; if (cd != NULL) ! /* suppress_dialog_mnemonics(cd->dialog); */ cd->dialog = (Widget)0; } --- 3460,3466 ---- SharedFindReplace *cd = (SharedFindReplace *)client_data; if (cd != NULL) ! // suppress_dialog_mnemonics(cd->dialog); cd->dialog = (Widget)0; } *************** *** 3510,3516 **** { char_u *save_cpo = p_cpo; ! /* No need to be Vi compatible here. */ p_cpo = (char_u *)""; u_undo(1); p_cpo = save_cpo; --- 3502,3508 ---- { char_u *save_cpo = p_cpo; ! // No need to be Vi compatible here. p_cpo = (char_u *)""; u_undo(1); p_cpo = save_cpo; *************** *** 3518,3524 **** return; } ! /* Get the search/replace strings from the dialog */ if (flags == FRD_FINDNEXT) { repl_text = NULL; --- 3510,3516 ---- return; } ! // Get the search/replace strings from the dialog if (flags == FRD_FINDNEXT) { repl_text = NULL; *************** *** 3560,3566 **** keysym = XLookupKeysym(event, 0); ! /* the scape key pops the whole dialog down */ if (keysym == XK_Escape) XtUnmanageChild(frdp->dialog); } --- 3552,3558 ---- keysym = XLookupKeysym(event, 0); ! // the scape key pops the whole dialog down if (keysym == XK_Escape) XtUnmanageChild(frdp->dialog); } *************** *** 3625,3639 **** frdp = do_replace ? &repl_widgets : &find_widgets; ! /* Get the search string to use. */ entry_text = get_find_dialog_text(arg, &wword, &mcase); ! /* If the dialog already exists, just raise it. */ if (frdp->dialog) { gui_motif_synch_fonts(); ! /* If the window is already up, just pop it to the top */ if (XtIsManaged(frdp->dialog)) XMapRaised(XtDisplay(frdp->dialog), XtWindow(XtParent(frdp->dialog))); --- 3617,3631 ---- frdp = do_replace ? &repl_widgets : &find_widgets; ! // Get the search string to use. entry_text = get_find_dialog_text(arg, &wword, &mcase); ! // If the dialog already exists, just raise it. if (frdp->dialog) { gui_motif_synch_fonts(); ! // If the window is already up, just pop it to the top if (XtIsManaged(frdp->dialog)) XMapRaised(XtDisplay(frdp->dialog), XtWindow(XtParent(frdp->dialog))); *************** *** 3650,3656 **** return; } ! /* Create a fresh new dialog window */ if (do_replace) str = XmStringCreateSimple(_("VIM - Search and Replace...")); else --- 3642,3648 ---- return; } ! // Create a fresh new dialog window if (do_replace) str = XmStringCreateSimple(_("VIM - Search and Replace...")); else *************** *** 3832,3839 **** (XtEventHandler)find_replace_keypress, (XtPointer)frdp); ! /* Get the maximum width between the label widgets and line them up. ! */ n = 0; XtSetArg(args[n], XmNwidth, &width); n++; XtGetValues(label_what, args, n); --- 3824,3830 ---- (XtEventHandler)find_replace_keypress, (XtPointer)frdp); ! // Get the maximum width between the label widgets and line them up. n = 0; XtSetArg(args[n], XmNwidth, &width); n++; XtGetValues(label_what, args, n); *************** *** 3990,4004 **** XFontStruct *font; XmFontList font_list; ! /* FIXME: Unless we find out how to create a XmFontList from a XFontSet, ! * we just give up here on font synchronization. */ font = (XFontStruct *)gui.norm_font; if (font == NULL) return; font_list = gui_motif_create_fontlist(font); ! /* OK this loop is a bit tricky... */ for (do_replace = 0; do_replace <= 1; ++do_replace) { frdp = (do_replace) ? (&repl_widgets) : (&find_widgets); --- 3981,3995 ---- XFontStruct *font; XmFontList font_list; ! // FIXME: Unless we find out how to create a XmFontList from a XFontSet, ! // we just give up here on font synchronization. font = (XFontStruct *)gui.norm_font; if (font == NULL) return; font_list = gui_motif_create_fontlist(font); ! // OK this loop is a bit tricky... for (do_replace = 0; do_replace <= 1; ++do_replace) { frdp = (do_replace) ? (&repl_widgets) : (&find_widgets); *** ../vim-8.1.2382/src/gui_photon.c 2019-05-28 23:08:12.064648717 +0200 --- src/gui_photon.c 2019-12-02 22:24:44.100828711 +0100 *************** *** 13,19 **** #include "vim.h" ! /* cproto fails on missing include files */ #ifndef PROTO # ifdef FEAT_TOOLBAR # include --- 13,19 ---- #include "vim.h" ! // cproto fails on missing include files #ifndef PROTO # ifdef FEAT_TOOLBAR # include *************** *** 21,27 **** #endif #if !defined(__QNX__) ! /* Used when generating prototypes. */ # define PgColor_t int # define PhEvent_t int # define PhPoint_t int --- 21,27 ---- #endif #if !defined(__QNX__) ! // Used when generating prototypes. # define PgColor_t int # define PhEvent_t int # define PhPoint_t int *************** *** 39,49 **** #define EVENT_BUFFER_SIZE sizeof(PhEvent_t) + 1000 ! /* Some defines for gui_mch_mousehide() */ #define MOUSE_HIDE TRUE #define MOUSE_SHOW FALSE ! /* Optional support for using a PtPanelGroup widget, needs work */ #undef USE_PANEL_GROUP #ifdef USE_PANEL_GROUP --- 39,49 ---- #define EVENT_BUFFER_SIZE sizeof(PhEvent_t) + 1000 ! // Some defines for gui_mch_mousehide() #define MOUSE_HIDE TRUE #define MOUSE_SHOW FALSE ! // Optional support for using a PtPanelGroup widget, needs work #undef USE_PANEL_GROUP #ifdef USE_PANEL_GROUP *************** *** 53,67 **** static short pg_margin_left, pg_margin_right, pg_margin_top, pg_margin_bottom; #endif ! #define GUI_PH_MARGIN 4 /* Size of the bevel */ #define GUI_PH_MOUSE_TYPE Ph_CURSOR_INSERT static PgColor_t gui_ph_mouse_color = Pg_BLACK; static PhPoint_t gui_ph_raw_offset; ! static PtWidget_t *gui_ph_timer_cursor; /* handle cursor blinking */ ! static PtWidget_t *gui_ph_timer_timeout; /* used in gui_mch_wait_for_chars */ ! static short is_timeout; /* Has the timeout occurred? */ /* * This is set inside the mouse callback for a right mouse --- 53,67 ---- static short pg_margin_left, pg_margin_right, pg_margin_top, pg_margin_bottom; #endif ! #define GUI_PH_MARGIN 4 // Size of the bevel #define GUI_PH_MOUSE_TYPE Ph_CURSOR_INSERT static PgColor_t gui_ph_mouse_color = Pg_BLACK; static PhPoint_t gui_ph_raw_offset; ! static PtWidget_t *gui_ph_timer_cursor; // handle cursor blinking ! static PtWidget_t *gui_ph_timer_timeout; // used in gui_mch_wait_for_chars ! static short is_timeout; // Has the timeout occurred? /* * This is set inside the mouse callback for a right mouse *************** *** 69,78 **** */ static PhPoint_t abs_mouse; ! /* Try and avoid redraws while a resize is in progress */ static int is_ignore_draw = FALSE; ! /* Used for converting to/from utf-8 and other charsets */ static struct PxTransCtrl *charset_translate; /* --- 69,78 ---- */ static PhPoint_t abs_mouse; ! // Try and avoid redraws while a resize is in progress static int is_ignore_draw = FALSE; ! // Used for converting to/from utf-8 and other charsets static struct PxTransCtrl *charset_translate; /* *************** *** 160,182 **** {Pk_KP_Multiply,'K', '9'}, {Pk_KP_Enter, 'K', 'A'}, ! {Pk_KP_0, KS_EXTRA, KE_KINS}, /* Insert */ ! {Pk_KP_Decimal, KS_EXTRA, KE_KDEL}, /* Delete */ ! {Pk_KP_4, 'k', 'l'}, /* Left */ ! {Pk_KP_6, 'k', 'r'}, /* Right */ ! {Pk_KP_8, 'k', 'u'}, /* Up */ ! {Pk_KP_2, 'k', 'd'}, /* Down */ ! {Pk_KP_7, 'K', '1'}, /* Home */ ! {Pk_KP_1, 'K', '4'}, /* End */ ! {Pk_KP_9, 'K', '3'}, /* Page Up */ ! {Pk_KP_3, 'K', '5'}, /* Page Down */ ! {Pk_KP_5, '&', '8'}, /* Undo */ ! /* Keys that we want to be able to use any modifier with: */ {Pk_Return, CAR, NUL}, {Pk_space, ' ', NUL}, {Pk_Tab, TAB, NUL}, --- 160,182 ---- {Pk_KP_Multiply,'K', '9'}, {Pk_KP_Enter, 'K', 'A'}, ! {Pk_KP_0, KS_EXTRA, KE_KINS}, // Insert ! {Pk_KP_Decimal, KS_EXTRA, KE_KDEL}, // Delete ! {Pk_KP_4, 'k', 'l'}, // Left ! {Pk_KP_6, 'k', 'r'}, // Right ! {Pk_KP_8, 'k', 'u'}, // Up ! {Pk_KP_2, 'k', 'd'}, // Down ! {Pk_KP_7, 'K', '1'}, // Home ! {Pk_KP_1, 'K', '4'}, // End ! {Pk_KP_9, 'K', '3'}, // Page Up ! {Pk_KP_3, 'K', '5'}, // Page Down ! {Pk_KP_5, '&', '8'}, // Undo ! // Keys that we want to be able to use any modifier with: {Pk_Return, CAR, NUL}, {Pk_space, ' ', NUL}, {Pk_Tab, TAB, NUL}, *************** *** 184,195 **** {NL, NL, NUL}, {CAR, CAR, NUL}, ! /* End of list marker: */ {0, 0, 0} }; ! /****************************************************************************/ static PtCallbackF_t gui_ph_handle_timer_cursor; static PtCallbackF_t gui_ph_handle_timer_timeout; --- 184,195 ---- {NL, NL, NUL}, {CAR, CAR, NUL}, ! // End of list marker: {0, 0, 0} }; ! //////////////////////////////////////////////////////////////////////////// static PtCallbackF_t gui_ph_handle_timer_cursor; static PtCallbackF_t gui_ph_handle_timer_timeout; *************** *** 201,211 **** static PtCallbackF_t gui_ph_handle_mouse; static PtCallbackF_t gui_ph_handle_pulldown_menu; static PtCallbackF_t gui_ph_handle_menu; ! static PtCallbackF_t gui_ph_handle_focus; /* focus change of text area */ static PtCallbackF_t gui_ph_handle_menu_resize; ! /* When a menu is unrealized, give focus back to vimTextArea */ static PtCallbackF_t gui_ph_handle_menu_unrealized; #ifdef USE_PANEL_GROUP --- 201,211 ---- static PtCallbackF_t gui_ph_handle_mouse; static PtCallbackF_t gui_ph_handle_pulldown_menu; static PtCallbackF_t gui_ph_handle_menu; ! static PtCallbackF_t gui_ph_handle_focus; // focus change of text area static PtCallbackF_t gui_ph_handle_menu_resize; ! // When a menu is unrealized, give focus back to vimTextArea static PtCallbackF_t gui_ph_handle_menu_unrealized; #ifdef USE_PANEL_GROUP *************** *** 215,221 **** static void gui_ph_draw_start(void); static void gui_ph_draw_end(void); ! /* Set the text for the balloon */ static PtWidget_t * gui_ph_show_tooltip(PtWidget_t *window, PtWidget_t *widget, int position, --- 215,221 ---- static void gui_ph_draw_start(void); static void gui_ph_draw_end(void); ! // Set the text for the balloon static PtWidget_t * gui_ph_show_tooltip(PtWidget_t *window, PtWidget_t *widget, int position, *************** *** 224,230 **** PgColor_t fill_color, PgColor_t text_color); ! /****************************************************************************/ static PtWidget_t * gui_ph_show_tooltip(PtWidget_t *window, PtWidget_t *widget, --- 224,230 ---- PgColor_t fill_color, PgColor_t text_color); ! //////////////////////////////////////////////////////////////////////////// static PtWidget_t * gui_ph_show_tooltip(PtWidget_t *window, PtWidget_t *widget, *************** *** 241,247 **** PtSetArg(&arg, Pt_ARG_POINTER, &menu, 0); PtGetResources(widget, 1, &arg); ! /* Override the text and position */ tooltip = text; if (menu != NULL) --- 241,247 ---- PtSetArg(&arg, Pt_ARG_POINTER, &menu, 0); PtGetResources(widget, 1, &arg); ! // Override the text and position tooltip = text; if (menu != NULL) *************** *** 254,261 **** return PtInflateBalloon( window, widget, ! /* Don't put the balloon at the bottom, ! * it gets drawn over by gfx done in the PtRaw */ Pt_BALLOON_TOP, tooltip, font, --- 254,261 ---- return PtInflateBalloon( window, widget, ! // Don't put the balloon at the bottom, ! // it gets drawn over by gfx done in the PtRaw Pt_BALLOON_TOP, tooltip, font, *************** *** 287,295 **** height = sizes->new_dim.h; ! /* Because vim treats the toolbar and menubar separately, ! * and here they're lumped together into a PtToolbarGroup, ! * we only need either menu_height or toolbar_height set at once */ if (gui.menu_is_active) { gui.menu_height = height; --- 287,295 ---- height = sizes->new_dim.h; ! // Because vim treats the toolbar and menubar separately, ! // and here they're lumped together into a PtToolbarGroup, ! // we only need either menu_height or toolbar_height set at once if (gui.menu_is_active) { gui.menu_height = height; *************** *** 368,374 **** break; case Ph_WM_FOCUS: ! /* Just in case it's hidden and needs to be shown */ gui_mch_mousehide(MOUSE_SHOW); if (we->event_state == Ph_WM_EVSTATE_FOCUS) --- 368,374 ---- break; case Ph_WM_FOCUS: ! // Just in case it's hidden and needs to be shown gui_mch_mousehide(MOUSE_SHOW); if (we->event_state == Ph_WM_EVSTATE_FOCUS) *************** *** 424,430 **** break; case Pt_SCROLL_SET: ! /* FIXME: return straight away here? */ return Pt_CONTINUE; break; } --- 424,430 ---- break; case Pt_SCROLL_SET: ! // FIXME: return straight away here? return Pt_CONTINUE; break; } *************** *** 449,455 **** if (p_mh) gui_mch_mousehide(MOUSE_HIDE); ! /* We're a good lil photon program, aren't we? yes we are, yeess wee arrr */ if (key->key_flags & Pk_KF_Compose) return Pt_CONTINUE; --- 449,455 ---- if (p_mh) gui_mch_mousehide(MOUSE_HIDE); ! // We're a good lil photon program, aren't we? yes we are, yeess wee arrr if (key->key_flags & Pk_KF_Compose) return Pt_CONTINUE; *************** *** 469,475 **** (*p_wak == 'm' && gui_is_menu_shortcut(key->key_cap)))) { ! /* Fallthrough and let photon look for the hotkey */ return Pt_CONTINUE; } #endif --- 469,475 ---- (*p_wak == 'm' && gui_is_menu_shortcut(key->key_cap)))) { ! // Fallthrough and let photon look for the hotkey return Pt_CONTINUE; } #endif *************** *** 483,495 **** ch = special_keys[i].vim_code0; else { ! /* Detect if a keypad number key has been pressed ! * and change the key if Num Lock is on */ if (key->key_cap >= Pk_KP_Enter && key->key_cap <= Pk_KP_9 && (key->key_mods & Pk_KM_Num_Lock)) { ! /* FIXME: For now, just map the key to a ascii value ! * (see ) */ ch = key->key_cap - 0xf080; } else --- 483,495 ---- ch = special_keys[i].vim_code0; else { ! // Detect if a keypad number key has been pressed ! // and change the key if Num Lock is on if (key->key_cap >= Pk_KP_Enter && key->key_cap <= Pk_KP_9 && (key->key_mods & Pk_KM_Num_Lock)) { ! // FIXME: For now, just map the key to a ascii value ! // (see ) ch = key->key_cap - 0xf080; } else *************** *** 507,513 **** if (key->key_mods & Pk_KM_Shift) modifiers |= MOD_MASK_SHIFT; ! /* Is this not a special key? */ if (special_keys[i].key_sym == 0) { ch = PhTo8859_1(key); --- 507,513 ---- if (key->key_mods & Pk_KM_Shift) modifiers |= MOD_MASK_SHIFT; ! // Is this not a special key? if (special_keys[i].key_sym == 0) { ch = PhTo8859_1(key); *************** *** 542,548 **** ch = key->key_cap; if (ch < 0xff) { ! /* FIXME: is this the right thing to do? */ if (modifiers & MOD_MASK_CTRL) { modifiers &= ~MOD_MASK_CTRL; --- 542,548 ---- ch = key->key_cap; if (ch < 0xff) { ! // FIXME: is this the right thing to do? if (modifiers & MOD_MASK_CTRL) { modifiers &= ~MOD_MASK_CTRL; *************** *** 605,611 **** if (len == 1 && string[0] == CSI) { ! /* Turn CSI into K_CSI. */ string[ len++ ] = KS_EXTRA; string[ len++ ] = KE_CSI; } --- 605,611 ---- if (len == 1 && string[0] == CSI) { ! // Turn CSI into K_CSI. string[ len++ ] = KS_EXTRA; string[ len++ ] = KE_CSI; } *************** *** 663,669 **** if (pointer->buttons & Ph_BUTTON_MENU) { button = MOUSE_RIGHT; ! /* Need the absolute coordinates for the popup menu */ abs_mouse.x = pointer->pos.x; abs_mouse.y = pointer->pos.y; } --- 663,669 ---- if (pointer->buttons & Ph_BUTTON_MENU) { button = MOUSE_RIGHT; ! // Need the absolute coordinates for the popup menu abs_mouse.x = pointer->pos.x; abs_mouse.y = pointer->pos.y; } *************** *** 671,677 **** if (pointer->buttons & Ph_BUTTON_ADJUST) button = MOUSE_MIDDLE; ! /* Catch a real release (not phantom or other releases */ if (info->event->type == Ph_EV_BUT_RELEASE) button = MOUSE_RELEASE; --- 671,677 ---- if (pointer->buttons & Ph_BUTTON_ADJUST) button = MOUSE_MIDDLE; ! // Catch a real release (not phantom or other releases if (info->event->type == Ph_EV_BUT_RELEASE) button = MOUSE_RELEASE; *************** *** 679,690 **** button = MOUSE_DRAG; #if 0 ! /* Vim doesn't use button repeats */ if (info->event->type & Ph_EV_BUT_REPEAT) button = MOUSE_DRAG; #endif ! /* Don't do anything if it is one of the phantom mouse release events */ if ((button != MOUSE_RELEASE) || (info->event->subtype == Ph_EV_RELEASE_REAL)) { --- 679,690 ---- button = MOUSE_DRAG; #if 0 ! // Vim doesn't use button repeats if (info->event->type & Ph_EV_BUT_REPEAT) button = MOUSE_DRAG; #endif ! // Don't do anything if it is one of the phantom mouse release events if ((button != MOUSE_RELEASE) || (info->event->subtype == Ph_EV_RELEASE_REAL)) { *************** *** 696,702 **** return Pt_CONTINUE; } ! /* Handle a focus change of the PtRaw widget */ static int gui_ph_handle_focus(PtWidget_t *widget, void *data, PtCallbackInfo_t *info) { --- 696,704 ---- return Pt_CONTINUE; } ! /* ! * Handle a focus change of the PtRaw widget ! */ static int gui_ph_handle_focus(PtWidget_t *widget, void *data, PtCallbackInfo_t *info) { *************** *** 745,751 **** PhTranslatePoint(&offset, PtWidgetPos(gui.vimTextArea, NULL)); #if 1 ! /* Redraw individual damage regions */ if (damage->next != NULL) damage = damage->next; --- 747,753 ---- PhTranslatePoint(&offset, PtWidgetPos(gui.vimTextArea, NULL)); #if 1 ! // Redraw individual damage regions if (damage->next != NULL) damage = damage->next; *************** *** 759,765 **** damage = damage->next; } #else ! /* Redraw the rectangle that covers all the damaged regions */ r = &damage->rect; gui_redraw( r->ul.x - offset.x, r->ul.y - offset.y, --- 761,767 ---- damage = damage->next; } #else ! // Redraw the rectangle that covers all the damaged regions r = &damage->rect; gui_redraw( r->ul.x - offset.x, r->ul.y - offset.y, *************** *** 787,793 **** return Pt_CONTINUE; } ! /* This is used for pulldown/popup menus and also toolbar buttons */ static int gui_ph_handle_menu(PtWidget_t *widget, void *data, PtCallbackInfo_t *info) { --- 789,797 ---- return Pt_CONTINUE; } ! /* ! * This is used for pulldown/popup menus and also toolbar buttons ! */ static int gui_ph_handle_menu(PtWidget_t *widget, void *data, PtCallbackInfo_t *info) { *************** *** 799,805 **** return Pt_CONTINUE; } ! /* Stop focus from disappearing into the menubar... */ static int gui_ph_handle_menu_unrealized( PtWidget_t *widget, --- 803,811 ---- return Pt_CONTINUE; } ! /* ! * Stop focus from disappearing into the menubar... ! */ static int gui_ph_handle_menu_unrealized( PtWidget_t *widget, *************** *** 820,831 **** return Pt_CONTINUE; } ! /****************************************************************************/ #define DRAW_START gui_ph_draw_start() #define DRAW_END gui_ph_draw_end() ! /* TODO: Set a clipping rect? */ static void gui_ph_draw_start(void) { --- 826,839 ---- return Pt_CONTINUE; } ! //////////////////////////////////////////////////////////////////////////// #define DRAW_START gui_ph_draw_start() #define DRAW_END gui_ph_draw_end() ! /* ! * TODO: Set a clipping rect? ! */ static void gui_ph_draw_start(void) { *************** *** 888,895 **** for (i = 0; i < num_panels; i++) { ! /* find the last "(" in the panel title and see if the buffer ! * number in the title matches the one we're looking for */ mark = STRRCHR(panel_titles[ i ], '('); if (mark != NULL && STRCMP(mark, search) == 0) { --- 896,903 ---- for (i = 0; i < num_panels; i++) { ! // find the last "(" in the panel title and see if the buffer ! // number in the title matches the one we're looking for mark = STRRCHR(panel_titles[ i ], '('); if (mark != NULL && STRCMP(mark, search) == 0) { *************** *** 948,954 **** *right = *margin_right; } ! /* Used for the tabs for PtPanelGroup */ static int gui_ph_is_buffer_item(vimmenu_T *menu, vimmenu_T *parent) { --- 956,964 ---- *right = *margin_right; } ! /* ! * Used for the tabs for PtPanelGroup ! */ static int gui_ph_is_buffer_item(vimmenu_T *menu, vimmenu_T *parent) { *************** *** 956,962 **** if (STRCMP(parent->dname, "Buffers") == 0) { ! /* Look for '(' digits ')' */ mark = vim_strchr(menu->dname, '('); if (mark != NULL) { --- 966,972 ---- if (STRCMP(parent->dname, "Buffers") == 0) { ! // Look for '(' digits ')' mark = vim_strchr(menu->dname, '('); if (mark != NULL) { *************** *** 998,1011 **** int i; char **new_titles = NULL; ! /* If there is only 1 panel, we just use the temporary place holder */ if (num_panels > 1) { new_titles = ALLOC_MULT(char *, num_panels - 1); if (new_titles != NULL) { char **s = new_titles; ! /* Copy all the titles except the one we're removing */ for (i = 0; i < num_panels; i++) { if (STRCMP(panel_titles[ i ], name) != 0) --- 1008,1021 ---- int i; char **new_titles = NULL; ! // If there is only 1 panel, we just use the temporary place holder if (num_panels > 1) { new_titles = ALLOC_MULT(char *, num_panels - 1); if (new_titles != NULL) { char **s = new_titles; ! // Copy all the titles except the one we're removing for (i = 0; i < num_panels; i++) { if (STRCMP(panel_titles[ i ], name) != 0) *************** *** 1030,1036 **** } } ! /* When a buffer item is deleted from the buffer menu */ static int gui_ph_handle_buffer_remove( PtWidget_t *widget, --- 1040,1048 ---- } } ! /* ! * When a buffer item is deleted from the buffer menu ! */ static int gui_ph_handle_buffer_remove( PtWidget_t *widget, *************** *** 1062,1073 **** return Pt_CONTINUE; } ! /****************************************************************************/ void gui_ph_encoding_changed(int new_encoding) { ! /* Default encoding is latin1 */ char *charset = "latin1"; int i; --- 1074,1085 ---- return Pt_CONTINUE; } ! //////////////////////////////////////////////////////////////////////////// void gui_ph_encoding_changed(int new_encoding) { ! // Default encoding is latin1 char *charset = "latin1"; int i; *************** *** 1090,1097 **** charset_translate = PxTranslateSet(charset_translate, charset); } ! /****************************************************************************/ ! /****************************************************************************/ void gui_mch_prepare(int *argc, char **argv) --- 1102,1108 ---- charset_translate = PxTranslateSet(charset_translate, charset); } ! //////////////////////////////////////////////////////////////////////////// void gui_mch_prepare(int *argc, char **argv) *************** *** 1105,1124 **** PtArg_t args[10]; int flags = 0, n = 0; ! PhDim_t window_size = {100, 100}; /* Arbitrary values */ PhPoint_t pos = {0, 0}; gui.event_buffer = alloc(EVENT_BUFFER_SIZE); if (gui.event_buffer == NULL) return FAIL; ! /* Get a translation so we can convert from ISO Latin-1 to UTF */ charset_translate = PxTranslateSet(NULL, "latin1"); ! /* The +2 is for the 1 pixel dark line on each side */ gui.border_offset = gui.border_width = GUI_PH_MARGIN + 2; ! /* Handle close events ourselves */ PtSetArg(&args[ n++ ], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_CLOSE); PtSetArg(&args[ n++ ], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, Ph_WM_CLOSE | Ph_WM_RESIZE | Ph_WM_FOCUS); --- 1116,1135 ---- PtArg_t args[10]; int flags = 0, n = 0; ! PhDim_t window_size = {100, 100}; // Arbitrary values PhPoint_t pos = {0, 0}; gui.event_buffer = alloc(EVENT_BUFFER_SIZE); if (gui.event_buffer == NULL) return FAIL; ! // Get a translation so we can convert from ISO Latin-1 to UTF charset_translate = PxTranslateSet(NULL, "latin1"); ! // The +2 is for the 1 pixel dark line on each side gui.border_offset = gui.border_width = GUI_PH_MARGIN + 2; ! // Handle close events ourselves PtSetArg(&args[ n++ ], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_CLOSE); PtSetArg(&args[ n++ ], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, Ph_WM_CLOSE | Ph_WM_RESIZE | Ph_WM_FOCUS); *************** *** 1137,1143 **** PtSetArg(&args[ n++ ], Pt_ARG_POS, &pos, 0); #ifdef USE_PANEL_GROUP ! /* Put in a temporary place holder title */ PtSetArg(&args[ n++ ], Pt_ARG_PG_PANEL_TITLES, &empty_title, 1); gui.vimPanelGroup = PtCreateWidget(PtPanelGroup, gui.vimWindow, n, args); --- 1148,1154 ---- PtSetArg(&args[ n++ ], Pt_ARG_POS, &pos, 0); #ifdef USE_PANEL_GROUP ! // Put in a temporary place holder title PtSetArg(&args[ n++ ], Pt_ARG_PG_PANEL_TITLES, &empty_title, 1); gui.vimPanelGroup = PtCreateWidget(PtPanelGroup, gui.vimWindow, n, args); *************** *** 1147,1153 **** PtAddCallback(gui.vimPanelGroup, Pt_CB_PG_PANEL_SWITCHING, gui_ph_handle_pg_change, NULL); #else ! /* Turn off all edge decorations */ PtSetArg(&args[ n++ ], Pt_ARG_BASIC_FLAGS, Pt_FALSE, Pt_ALL); PtSetArg(&args[ n++ ], Pt_ARG_BEVEL_WIDTH, 0, 0); PtSetArg(&args[ n++ ], Pt_ARG_MARGIN_WIDTH, 0, 0); --- 1158,1164 ---- PtAddCallback(gui.vimPanelGroup, Pt_CB_PG_PANEL_SWITCHING, gui_ph_handle_pg_change, NULL); #else ! // Turn off all edge decorations PtSetArg(&args[ n++ ], Pt_ARG_BASIC_FLAGS, Pt_FALSE, Pt_ALL); PtSetArg(&args[ n++ ], Pt_ARG_BEVEL_WIDTH, 0, 0); PtSetArg(&args[ n++ ], Pt_ARG_MARGIN_WIDTH, 0, 0); *************** *** 1161,1167 **** PtAddCallback(gui.vimContainer, Pt_CB_RESIZE, gui_ph_pane_resize, NULL); #endif ! /* Size for the text area is set in gui_mch_set_text_area_pos */ n = 0; PtSetArg(&args[ n++ ], Pt_ARG_RAW_DRAW_F, gui_ph_handle_raw_draw, 1); --- 1172,1178 ---- PtAddCallback(gui.vimContainer, Pt_CB_RESIZE, gui_ph_pane_resize, NULL); #endif ! // Size for the text area is set in gui_mch_set_text_area_pos n = 0; PtSetArg(&args[ n++ ], Pt_ARG_RAW_DRAW_F, gui_ph_handle_raw_draw, 1); *************** *** 1181,1188 **** if (gui.vimTextArea == NULL) return FAIL; ! /* TODO: use PtAddEventHandlers instead? */ ! /* Not using Ph_EV_BUT_REPEAT because vim wouldn't use it anyway */ PtAddEventHandler(gui.vimTextArea, Ph_EV_BUT_PRESS | Ph_EV_BUT_RELEASE | Ph_EV_PTR_MOTION_BUTTON, gui_ph_handle_mouse, NULL); --- 1192,1199 ---- if (gui.vimTextArea == NULL) return FAIL; ! // TODO: use PtAddEventHandlers instead? ! // Not using Ph_EV_BUT_REPEAT because vim wouldn't use it anyway PtAddEventHandler(gui.vimTextArea, Ph_EV_BUT_PRESS | Ph_EV_BUT_RELEASE | Ph_EV_PTR_MOTION_BUTTON, gui_ph_handle_mouse, NULL); *************** *** 1311,1321 **** #endif } ! /****************************************************************************/ ! /* events */ ! /* When no events are available, photon will call this function, working is ! * set to FALSE, and the gui_mch_update loop will exit. */ static int exit_gui_mch_update(void *data) { --- 1322,1334 ---- #endif } ! //////////////////////////////////////////////////////////////////////////// ! // events ! /* ! * When no events are available, photon will call this function, working is ! * set to FALSE, and the gui_mch_update loop will exit. ! */ static int exit_gui_mch_update(void *data) { *************** *** 1388,1399 **** { if (saving == TRUE) { ! /* Don't need Pt_FSR_CONFIRM_EXISTING, vim will ask anyway */ flags |= Pt_FSR_NO_FCHECK; open_text = "&Save"; } ! /* combine the directory and filename into a single path */ if (initdir == NULL || *initdir == NUL) { mch_dirname(default_path, MAXPATHL); --- 1401,1412 ---- { if (saving == TRUE) { ! // Don't need Pt_FSR_CONFIRM_EXISTING, vim will ask anyway flags |= Pt_FSR_NO_FCHECK; open_text = "&Save"; } ! // combine the directory and filename into a single path if (initdir == NULL || *initdir == NUL) { mch_dirname(default_path, MAXPATHL); *************** *** 1413,1419 **** STRCAT(default_path, default_name); } ! /* TODO: add a filter? */ PtFileSelection( gui.vimWindow, NULL, --- 1426,1432 ---- STRCAT(default_path, default_name); } ! // TODO: add a filter? PtFileSelection( gui.vimWindow, NULL, *************** *** 1496,1513 **** int i, len; int dialog_result = -1; ! /* FIXME: the vertical option in guioptions is blatantly ignored */ ! /* FIXME: so is the type */ button_count = len = i = 0; if (buttons == NULL || *buttons == NUL) return -1; ! /* There is one less separator than buttons, so bump up the button count */ button_count = 1; ! /* Count string length and number of separators */ for (str = buttons; *str; str++) { len++; --- 1509,1526 ---- int i, len; int dialog_result = -1; ! // FIXME: the vertical option in guioptions is blatantly ignored ! // FIXME: so is the type button_count = len = i = 0; if (buttons == NULL || *buttons == NUL) return -1; ! // There is one less separator than buttons, so bump up the button count button_count = 1; ! // Count string length and number of separators for (str = buttons; *str; str++) { len++; *************** *** 1550,1557 **** button_count, (const char **) button_array, NULL, default_button, 0, Pt_MODAL); #else ! /* Writing the dialog ourselves lets us add extra features, like ! * trapping the escape key and returning 0 to vim */ { int n; PtArg_t args[5]; --- 1563,1570 ---- button_count, (const char **) button_array, NULL, default_button, 0, Pt_MODAL); #else ! // Writing the dialog ourselves lets us add extra features, like ! // trapping the escape key and returning 0 to vim { int n; PtArg_t args[5]; *************** *** 1593,1600 **** di.buttons = (const char **) button_array; di.nbtns = button_count; di.def_btn = default_button; ! /* This is just to give the dialog the close button. ! * We check for the Escape key ourselves and return 0 */ di.esc_btn = button_count; di.callback = gui_ph_dialog_close; di.data = &modal_ctrl; --- 1606,1613 ---- di.buttons = (const char **) button_array; di.nbtns = button_count; di.def_btn = default_button; ! // This is just to give the dialog the close button. ! // We check for the Escape key ourselves and return 0 di.esc_btn = button_count; di.callback = gui_ph_dialog_close; di.data = &modal_ctrl; *************** *** 1606,1612 **** if (gui_ph_dialog_text != NULL) PtGiveFocus(gui_ph_dialog_text, NULL); ! /* Open dialog, block the vim window and wait for the dialog to close */ PtRealizeWidget(dialog); PtMakeModal(dialog, Ph_CURSOR_NOINPUT, Ph_CURSOR_DEFAULT_COLOR); dialog_result = (int) PtModalBlock(&modal_ctrl, 0); --- 1619,1625 ---- if (gui_ph_dialog_text != NULL) PtGiveFocus(gui_ph_dialog_text, NULL); ! // Open dialog, block the vim window and wait for the dialog to close PtRealizeWidget(dialog); PtMakeModal(dialog, Ph_CURSOR_NOINPUT, Ph_CURSOR_DEFAULT_COLOR); dialog_result = (int) PtModalBlock(&modal_ctrl, 0); *************** *** 1623,1630 **** return dialog_result; } #endif ! /****************************************************************************/ ! /* window size/position/state */ int gui_mch_get_winpos(int *x, int *y) --- 1636,1643 ---- return dialog_result; } #endif ! //////////////////////////////////////////////////////////////////////////// ! // window size/position/state int gui_mch_get_winpos(int *x, int *y) *************** *** 1719,1729 **** gui_ph_pg_set_buffer_num(curwin->w_buffer->b_fnum); #endif PtSetResource(gui.vimWindow, Pt_ARG_WINDOW_TITLE, title, 0); ! /* Not sure what to do with the icon text, set balloon text somehow? */ } ! /****************************************************************************/ ! /* Scrollbar */ void gui_mch_set_scrollbar_thumb(scrollbar_T *sb, int val, int size, int max) --- 1732,1742 ---- gui_ph_pg_set_buffer_num(curwin->w_buffer->b_fnum); #endif PtSetResource(gui.vimWindow, Pt_ARG_WINDOW_TITLE, title, 0); ! // Not sure what to do with the icon text, set balloon text somehow? } ! //////////////////////////////////////////////////////////////////////////// ! // Scrollbar void gui_mch_set_scrollbar_thumb(scrollbar_T *sb, int val, int size, int max) *************** *** 1749,1755 **** gui_mch_create_scrollbar(scrollbar_T *sb, int orient) { int n = 0; ! /* int anchor_flags = 0;*/ PtArg_t args[4]; /* --- 1762,1768 ---- gui_mch_create_scrollbar(scrollbar_T *sb, int orient) { int n = 0; ! // int anchor_flags = 0; PtArg_t args[4]; /* *************** *** 1762,1768 **** Pt_DELAY_REALIZE | Pt_GETS_FOCUS); PtSetArg(&args[ n++ ], Pt_ARG_SCROLLBAR_FLAGS, Pt_SCROLLBAR_SHOW_ARROWS, 0); #if 0 ! /* Don't need this anchoring for the scrollbars */ if (orient == SBAR_HORIZ) { anchor_flags = Pt_BOTTOM_ANCHORED_BOTTOM | --- 1775,1781 ---- Pt_DELAY_REALIZE | Pt_GETS_FOCUS); PtSetArg(&args[ n++ ], Pt_ARG_SCROLLBAR_FLAGS, Pt_SCROLLBAR_SHOW_ARROWS, 0); #if 0 ! // Don't need this anchoring for the scrollbars if (orient == SBAR_HORIZ) { anchor_flags = Pt_BOTTOM_ANCHORED_BOTTOM | *************** *** 1808,1842 **** sb->id = NULL; } ! /****************************************************************************/ ! /* Mouse functions */ #if defined(FEAT_MOUSESHAPE) || defined(PROTO) ! /* The last set mouse pointer shape is remembered, to be used when it goes ! * from hidden to not hidden. */ static int last_shape = 0; ! /* Table for shape IDs. Keep in sync with the mshape_names[] table in ! * misc2.c! */ static int mshape_ids[] = { ! Ph_CURSOR_POINTER, /* arrow */ ! Ph_CURSOR_NONE, /* blank */ ! Ph_CURSOR_INSERT, /* beam */ ! Ph_CURSOR_DRAG_VERTICAL, /* updown */ ! Ph_CURSOR_DRAG_VERTICAL, /* udsizing */ ! Ph_CURSOR_DRAG_HORIZONTAL, /* leftright */ ! Ph_CURSOR_DRAG_HORIZONTAL, /* lrsizing */ ! Ph_CURSOR_WAIT, /* busy */ ! Ph_CURSOR_DONT, /* no */ ! Ph_CURSOR_CROSSHAIR, /* crosshair */ ! Ph_CURSOR_FINGER, /* hand1 */ ! Ph_CURSOR_FINGER, /* hand2 */ ! Ph_CURSOR_FINGER, /* pencil */ ! Ph_CURSOR_QUESTION_POINT, /* question */ ! Ph_CURSOR_POINTER, /* right-arrow */ ! Ph_CURSOR_POINTER, /* up-arrow */ ! Ph_CURSOR_POINTER /* last one */ }; void --- 1821,1855 ---- sb->id = NULL; } ! //////////////////////////////////////////////////////////////////////////// ! // Mouse functions #if defined(FEAT_MOUSESHAPE) || defined(PROTO) ! // The last set mouse pointer shape is remembered, to be used when it goes ! // from hidden to not hidden. static int last_shape = 0; ! // Table for shape IDs. Keep in sync with the mshape_names[] table in ! // misc2.c! static int mshape_ids[] = { ! Ph_CURSOR_POINTER, // arrow ! Ph_CURSOR_NONE, // blank ! Ph_CURSOR_INSERT, // beam ! Ph_CURSOR_DRAG_VERTICAL, // updown ! Ph_CURSOR_DRAG_VERTICAL, // udsizing ! Ph_CURSOR_DRAG_HORIZONTAL, // leftright ! Ph_CURSOR_DRAG_HORIZONTAL, // lrsizing ! Ph_CURSOR_WAIT, // busy ! Ph_CURSOR_DONT, // no ! Ph_CURSOR_CROSSHAIR, // crosshair ! Ph_CURSOR_FINGER, // hand1 ! Ph_CURSOR_FINGER, // hand2 ! Ph_CURSOR_FINGER, // pencil ! Ph_CURSOR_QUESTION_POINT, // question ! Ph_CURSOR_POINTER, // right-arrow ! Ph_CURSOR_POINTER, // up-arrow ! Ph_CURSOR_POINTER // last one }; void *************** *** 1890,1897 **** PhCursorInfo_t info; short ix, iy; ! /* FIXME: does this return the correct position, ! * with respect to the border? */ PhQueryCursor(PhInputGroup(NULL), &info); PtGetAbsPosition(gui.vimTextArea , &ix, &iy); --- 1903,1910 ---- PhCursorInfo_t info; short ix, iy; ! // FIXME: does this return the correct position, ! // with respect to the border? PhQueryCursor(PhInputGroup(NULL), &info); PtGetAbsPosition(gui.vimTextArea , &ix, &iy); *************** *** 1905,1916 **** short abs_x, abs_y; PtGetAbsPosition(gui.vimTextArea, &abs_x, &abs_y); ! /* Add the border offset? */ PhMoveCursorAbs(PhInputGroup(NULL), abs_x + x, abs_y + y); } ! /****************************************************************************/ ! /* Colours */ /* * Return the RGB value of a pixel as a long. --- 1918,1929 ---- short abs_x, abs_y; PtGetAbsPosition(gui.vimTextArea, &abs_x, &abs_y); ! // Add the border offset? PhMoveCursorAbs(PhInputGroup(NULL), abs_x + x, abs_y + y); } ! //////////////////////////////////////////////////////////////////////////// ! // Colours /* * Return the RGB value of a pixel as a long. *************** *** 1925,1931 **** void gui_mch_new_colors(void) { ! #if 0 /* Don't bother changing the cursor colour */ short color_diff; /* --- 1938,1944 ---- void gui_mch_new_colors(void) { ! #if 0 // Don't bother changing the cursor colour short color_diff; /* *************** *** 1938,1944 **** if (abs(color_diff) < 64) { short r, g, b; ! /* not a great algorithm... */ r = PgRedValue(gui_ph_mouse_color) ^ 255; g = PgGreenValue(gui_ph_mouse_color) ^ 255; b = PgBlueValue(gui_ph_mouse_color) ^ 255; --- 1951,1957 ---- if (abs(color_diff) < 64) { short r, g, b; ! // not a great algorithm... r = PgRedValue(gui_ph_mouse_color) ^ 255; g = PgGreenValue(gui_ph_mouse_color) ^ 255; b = PgBlueValue(gui_ph_mouse_color) ^ 255; *************** *** 1999,2005 **** rect.ul.x = FILL_X(col); rect.ul.y = FILL_Y(row); ! /* FIXME: This has an off by one pixel problem */ rect.lr.x = rect.ul.x + nc * gui.char_width; rect.lr.y = rect.ul.y + nr * gui.char_height; if (nc > 0) --- 2012,2018 ---- rect.ul.x = FILL_X(col); rect.ul.y = FILL_Y(row); ! // FIXME: This has an off by one pixel problem rect.lr.x = rect.ul.x + nc * gui.char_width; rect.lr.y = rect.ul.y + nr * gui.char_height; if (nc > 0) *************** *** 2132,2138 **** { int src_taken, dst_made; ! /* Use a static buffer to avoid large amounts of de/allocations */ if (utf8_len < len) { utf8_buffer = realloc(utf8_buffer, len * MB_LEN_MAX); --- 2145,2151 ---- { int src_taken, dst_made; ! // Use a static buffer to avoid large amounts of de/allocations if (utf8_len < len) { utf8_buffer = realloc(utf8_buffer, len * MB_LEN_MAX); *************** *** 2155,2166 **** if (flags & DRAW_BOLD) { ! /* FIXME: try and only calculate these values once... */ rect.ul.x = FILL_X(col) + 1; rect.ul.y = FILL_Y(row); rect.lr.x = FILL_X(col + len) - 1; rect.lr.y = FILL_Y(row + 1) - 1; ! /* PgSetUserClip(NULL) causes the scrollbar to not redraw... */ #if 0 pos.x++; --- 2168,2179 ---- if (flags & DRAW_BOLD) { ! // FIXME: try and only calculate these values once... rect.ul.x = FILL_X(col) + 1; rect.ul.y = FILL_Y(row); rect.lr.x = FILL_X(col + len) - 1; rect.lr.y = FILL_Y(row + 1) - 1; ! // PgSetUserClip(NULL) causes the scrollbar to not redraw... #if 0 pos.x++; *************** *** 2169,2175 **** PgSetUserClip(NULL); #else rect.lr.y -= (p_linespace + 1) / 2; ! /* XXX: DrawTextArea doesn't work with phditto */ PgDrawTextArea(s, len, &rect, Pg_TEXT_BOTTOM); #endif } --- 2182,2188 ---- PgSetUserClip(NULL); #else rect.lr.y -= (p_linespace + 1) / 2; ! // XXX: DrawTextArea doesn't work with phditto PgDrawTextArea(s, len, &rect, Pg_TEXT_BOTTOM); #endif } *************** *** 2180,2194 **** DRAW_END; } ! /****************************************************************************/ ! /* Cursor */ void gui_mch_draw_hollow_cursor(guicolor_T color) { PhRect_t r; ! /* FIXME: Double width characters */ r.ul.x = FILL_X(gui.col); r.ul.y = FILL_Y(gui.row); --- 2193,2207 ---- DRAW_END; } ! //////////////////////////////////////////////////////////////////////////// ! // Cursor void gui_mch_draw_hollow_cursor(guicolor_T color) { PhRect_t r; ! // FIXME: Double width characters r.ul.x = FILL_X(gui.col); r.ul.y = FILL_Y(gui.row); *************** *** 2240,2246 **** void gui_mch_start_blink(void) { ! /* Only turn on the timer on if none of the times are zero */ if (blink_waittime && blink_ontime && blink_offtime && gui.in_focus) { PtSetResource(gui_ph_timer_cursor, Pt_ARG_TIMER_INITIAL, --- 2253,2259 ---- void gui_mch_start_blink(void) { ! // Only turn on the timer on if none of the times are zero if (blink_waittime && blink_ontime && blink_offtime && gui.in_focus) { PtSetResource(gui_ph_timer_cursor, Pt_ARG_TIMER_INITIAL, *************** *** 2261,2268 **** blink_state = BLINK_NONE; } ! /****************************************************************************/ ! /* miscellaneous functions */ void gui_mch_beep(void) --- 2274,2281 ---- blink_state = BLINK_NONE; } ! //////////////////////////////////////////////////////////////////////////// ! // miscellaneous functions void gui_mch_beep(void) *************** *** 2311,2318 **** return FAIL; } ! /****************************************************************************/ ! /* Menu */ #ifdef FEAT_TOOLBAR #include "toolbar.phi" --- 2324,2331 ---- return FAIL; } ! //////////////////////////////////////////////////////////////////////////// ! // Menu #ifdef FEAT_TOOLBAR #include "toolbar.phi" *************** *** 2360,2367 **** temp_phi = PxLoadImage(iconfile, NULL); if (temp_phi != NULL) { ! /* The label widget will free the image/palette/etc. for us when ! * it's destroyed */ temp_phi->flags |= Ph_RELEASE_IMAGE_ALL; memcpy(&external_icon, temp_phi, sizeof(external_icon)); free(temp_phi); --- 2373,2380 ---- temp_phi = PxLoadImage(iconfile, NULL); if (temp_phi != NULL) { ! // The label widget will free the image/palette/etc. for us when ! // it's destroyed temp_phi->flags |= Ph_RELEASE_IMAGE_ALL; memcpy(&external_icon, temp_phi, sizeof(external_icon)); free(temp_phi); *************** *** 2387,2396 **** if (menu->icon_builtin == FALSE) { if (menu->iconfile != NULL) ! /* TODO: use gui_find_iconfile() */ icon = gui_ph_toolbar_load_icon(menu->iconfile); ! /* TODO: Restrict loading to just .png? Search for any format? */ if ((icon == NULL) && ((gui_find_bitmap(menu->name, full_pathname, "gif") == OK) || (gui_find_bitmap(menu->name, full_pathname, "png") == OK))) --- 2400,2409 ---- if (menu->icon_builtin == FALSE) { if (menu->iconfile != NULL) ! // TODO: use gui_find_iconfile() icon = gui_ph_toolbar_load_icon(menu->iconfile); ! // TODO: Restrict loading to just .png? Search for any format? if ((icon == NULL) && ((gui_find_bitmap(menu->name, full_pathname, "gif") == OK) || (gui_find_bitmap(menu->name, full_pathname, "png") == OK))) *************** *** 2421,2430 **** void gui_mch_set_menu_pos(int x, int y, int w, int h) { ! /* Nothing */ } ! /* Change the position of a menu button in the parent */ static void gui_ph_position_menu(PtWidget_t *widget, int priority) { --- 2434,2445 ---- void gui_mch_set_menu_pos(int x, int y, int w, int h) { ! // Nothing } ! /* ! * Change the position of a menu button in the parent ! */ static void gui_ph_position_menu(PtWidget_t *widget, int priority) { *************** *** 2433,2441 **** traverse = PtWidgetChildBack(PtWidgetParent(widget)); ! /* Iterate through the list of widgets in traverse, until ! * we find the position we want to insert our widget into */ ! /* TODO: traverse from front to back, possible speedup? */ while (traverse != NULL) { PtGetResource(traverse, Pt_ARG_POINTER, &menu, 0); --- 2448,2456 ---- traverse = PtWidgetChildBack(PtWidgetParent(widget)); ! // Iterate through the list of widgets in traverse, until ! // we find the position we want to insert our widget into ! // TODO: traverse from front to back, possible speedup? while (traverse != NULL) { PtGetResource(traverse, Pt_ARG_POINTER, &menu, 0); *************** *** 2444,2450 **** priority < menu->priority && widget != traverse) { ! /* Insert the widget before the current traverse widget */ PtWidgetInsert(widget, traverse, 1); return; } --- 2459,2465 ---- priority < menu->priority && widget != traverse) { ! // Insert the widget before the current traverse widget PtWidgetInsert(widget, traverse, 1); return; } *************** *** 2453,2459 **** } } ! /* the index is ignored because it's not useful for our purposes */ void gui_mch_add_menu(vimmenu_T *menu, int index) { --- 2468,2476 ---- } } ! /* ! * the index is ignored because it's not useful for our purposes ! */ void gui_mch_add_menu(vimmenu_T *menu, int index) { *************** *** 2475,2481 **** mnemonic_str[1] = NUL; } ! /* Create the menu button */ n = 0; PtSetArg(&args[ n++ ], Pt_ARG_TEXT_STRING, menu->dname, 0); PtSetArg(&args[ n++ ], Pt_ARG_ACCEL_TEXT, menu->actext, 0); --- 2492,2498 ---- mnemonic_str[1] = NUL; } ! // Create the menu button n = 0; PtSetArg(&args[ n++ ], Pt_ARG_TEXT_STRING, menu->dname, 0); PtSetArg(&args[ n++ ], Pt_ARG_ACCEL_TEXT, menu->actext, 0); *************** *** 2492,2498 **** PtAddCallback(menu->id, Pt_CB_ARM, gui_ph_handle_pulldown_menu, menu); ! /* Create the actual menu */ n = 0; if (parent != NULL) PtSetArg(&args[ n++ ], Pt_ARG_MENU_FLAGS, Pt_TRUE, Pt_MENU_CHILD); --- 2509,2515 ---- PtAddCallback(menu->id, Pt_CB_ARM, gui_ph_handle_pulldown_menu, menu); ! // Create the actual menu n = 0; if (parent != NULL) PtSetArg(&args[ n++ ], Pt_ARG_MENU_FLAGS, Pt_TRUE, Pt_MENU_CHILD); *************** *** 2513,2519 **** gui_ph_position_menu(menu->id, menu->priority); ! /* Redraw menubar here instead of gui_mch_draw_menubar */ if (gui.menu_is_active) PtRealizeWidget(menu->id); } --- 2530,2536 ---- gui_ph_position_menu(menu->id, menu->priority); ! // Redraw menubar here instead of gui_mch_draw_menubar if (gui.menu_is_active) PtRealizeWidget(menu->id); } *************** *** 2583,2589 **** PtAddCallback(menu->id, Pt_CB_ACTIVATE, gui_ph_handle_menu, menu); } ! /* Update toolbar if it's open */ if (PtWidgetIsRealized(gui.vimToolBar)) PtRealizeWidget(menu->id); } --- 2600,2606 ---- PtAddCallback(menu->id, Pt_CB_ACTIVATE, gui_ph_handle_menu, menu); } ! // Update toolbar if it's open if (PtWidgetIsRealized(gui.vimToolBar)) PtRealizeWidget(menu->id); } *************** *** 2669,2684 **** void gui_mch_menu_hidden(vimmenu_T *menu, int hidden) { ! /* TODO: [un]realize the widget? */ } void gui_mch_draw_menubar(void) { ! /* The only time a redraw is needed is when a menu button ! * is added to the menubar, and that is detected and the bar ! * redrawn in gui_mch_add_menu_item ! */ } void --- 2686,2700 ---- void gui_mch_menu_hidden(vimmenu_T *menu, int hidden) { ! // TODO: [un]realize the widget? } void gui_mch_draw_menubar(void) { ! // The only time a redraw is needed is when a menu button ! // is added to the menubar, and that is detected and the bar ! // redrawn in gui_mch_add_menu_item } void *************** *** 2691,2697 **** void gui_mch_toggle_tearoffs(int enable) { ! /* No tearoffs yet */ } #endif --- 2707,2713 ---- void gui_mch_toggle_tearoffs(int enable) { ! // No tearoffs yet } #endif *************** *** 2707,2722 **** } #endif ! /****************************************************************************/ ! /* Fonts */ static GuiFont gui_ph_get_font( char_u *font_name, int_u font_flags, int_u font_size, ! /* Check whether the resulting font has the font flags and size that ! * was asked for */ int_u enforce ) { --- 2723,2738 ---- } #endif ! //////////////////////////////////////////////////////////////////////////// ! // Fonts static GuiFont gui_ph_get_font( char_u *font_name, int_u font_flags, int_u font_size, ! // Check whether the resulting font has the font flags and size that ! // was asked for int_u enforce ) { *************** *** 2730,2736 **** if (PfGenerateFontName(font_name, font_flags, font_size, font_tag) != NULL) { ! /* Enforce some limits on the font used */ style = PHFONT_INFO_FIXED; if (enforce & PF_STYLE_BOLD) --- 2746,2752 ---- if (PfGenerateFontName(font_name, font_flags, font_size, font_tag) != NULL) { ! // Enforce some limits on the font used style = PHFONT_INFO_FIXED; if (enforce & PF_STYLE_BOLD) *************** *** 2745,2752 **** if (info.size == 0) font_size = 0; ! /* Make sure font size matches, and that the font style ! * at least has the bits we're checking for */ if (font_size == info.size && style == (info.style & style)) return (GuiFont)font_tag; --- 2761,2768 ---- if (info.size == 0) font_size = 0; ! // Make sure font size matches, and that the font style ! // at least has the bits we're checking for if (font_size == info.size && style == (info.style & style)) return (GuiFont)font_tag; *************** *** 2799,2805 **** case 's': size = getdigits(&mark); ! /* Restrict the size to some vague limits */ if (size < 1 || size > 100) size = 8; --- 2815,2821 ---- case 's': size = getdigits(&mark); ! // Restrict the size to some vague limits if (size < 1 || size > 100) size = 8; *************** *** 2829,2835 **** if (vim_font_name == NULL) { ! /* Default font */ vim_font_name = "PC Terminal"; } --- 2845,2851 ---- if (vim_font_name == NULL) { ! // Default font vim_font_name = "PC Terminal"; } *************** *** 2872,2878 **** gui.ital_font = gui_ph_get_font(font_name, font_flags | PF_STYLE_ITALIC, font_size, PF_STYLE_ITALIC); ! /* This extent was brought to you by the letter 'g' */ PfExtentText(&extent, NULL, font_tag, "g", 1); gui.char_width = extent.lr.x - extent.ul.x + 1; --- 2888,2894 ---- gui.ital_font = gui_ph_get_font(font_name, font_flags | PF_STYLE_ITALIC, font_size, PF_STYLE_ITALIC); ! // This extent was brought to you by the letter 'g' PfExtentText(&extent, NULL, font_tag, "g", 1); gui.char_width = extent.lr.x - extent.ul.x + 1; *** ../vim-8.1.2382/src/gui_w32.c 2019-12-01 18:58:07.610835613 +0100 --- src/gui_w32.c 2019-12-02 22:32:33.702807510 +0100 *************** *** 58,64 **** int dx_renmode = 0; int dx_taamode = 0; ! /* parse string as rendering options. */ for (p = s; p != NULL && *p != NUL; ) { char_u item[256]; --- 58,64 ---- int dx_renmode = 0; int dx_taamode = 0; ! // parse string as rendering options. for (p = s; p != NULL && *p != NUL; ) { char_u item[256]; *************** *** 119,134 **** } else if (STRCMP(name, "scrlines") == 0) { ! /* Deprecated. Simply ignore it. */ } else return FAIL; } if (!gui.in_use) ! return OK; /* only checking the syntax of the value */ ! /* Enable DirectX/DirectWrite */ if (dx_enable) { if (!directx_enabled()) --- 119,134 ---- } else if (STRCMP(name, "scrlines") == 0) { ! // Deprecated. Simply ignore it. } else return FAIL; } if (!gui.in_use) ! return OK; // only checking the syntax of the value ! // Enable DirectX/DirectWrite if (dx_enable) { if (!directx_enabled()) *************** *** 179,190 **** #endif ! #include "version.h" /* used by dialog box routine for default title */ #ifdef DEBUG # include #endif ! /* cproto fails on missing include files */ #ifndef PROTO # ifndef __MINGW32__ --- 179,190 ---- #endif ! #include "version.h" // used by dialog box routine for default title #ifdef DEBUG # include #endif ! // cproto fails on missing include files #ifndef PROTO # ifndef __MINGW32__ *************** *** 199,216 **** # include "glbl_ime.h" # endif ! #endif /* PROTO */ #ifdef FEAT_MENU ! # define MENUHINTS /* show menu hints in command line */ #endif ! /* Some parameters for dialog boxes. All in pixels. */ #define DLG_PADDING_X 10 #define DLG_PADDING_Y 10 #define DLG_OLD_STYLE_PADDING_X 5 #define DLG_OLD_STYLE_PADDING_Y 5 ! #define DLG_VERT_PADDING_X 4 /* For vertical buttons */ #define DLG_VERT_PADDING_Y 4 #define DLG_ICON_WIDTH 34 #define DLG_ICON_HEIGHT 34 --- 199,216 ---- # include "glbl_ime.h" # endif ! #endif // PROTO #ifdef FEAT_MENU ! # define MENUHINTS // show menu hints in command line #endif ! // Some parameters for dialog boxes. All in pixels. #define DLG_PADDING_X 10 #define DLG_PADDING_Y 10 #define DLG_OLD_STYLE_PADDING_X 5 #define DLG_OLD_STYLE_PADDING_Y 5 ! #define DLG_VERT_PADDING_X 4 // For vertical buttons #define DLG_VERT_PADDING_Y 4 #define DLG_ICON_WIDTH 34 #define DLG_ICON_HEIGHT 34 *************** *** 220,228 **** #define DLG_MIN_MAX_WIDTH 400 #define DLG_MIN_MAX_HEIGHT 400 ! #define DLG_NONBUTTON_CONTROL 5000 /* First ID of non-button controls */ ! #ifndef WM_XBUTTONDOWN /* For Win2K / winME ONLY */ # define WM_XBUTTONDOWN 0x020B # define WM_XBUTTONUP 0x020C # define WM_XBUTTONDBLCLK 0x020D --- 220,228 ---- #define DLG_MIN_MAX_WIDTH 400 #define DLG_MIN_MAX_HEIGHT 400 ! #define DLG_NONBUTTON_CONTROL 5000 // First ID of non-button controls ! #ifndef WM_XBUTTONDOWN // For Win2K / winME ONLY # define WM_XBUTTONDOWN 0x020B # define WM_XBUTTONUP 0x020C # define WM_XBUTTONDBLCLK 0x020D *************** *** 295,316 **** static void fill_rect(const RECT *rcp, HBRUSH hbr, COLORREF color); static void clear_rect(RECT *rcp); ! static WORD s_dlgfntheight; /* height of the dialog font */ ! static WORD s_dlgfntwidth; /* width of the dialog font */ #ifdef FEAT_MENU static HMENU s_menuBar = NULL; #endif #ifdef FEAT_TEAROFF static void rebuild_tearoff(vimmenu_T *menu); ! static HBITMAP s_htearbitmap; /* bitmap used to indicate tearoff */ #endif ! /* Flag that is set while processing a message that must not be interrupted by ! * processing another message. */ static int s_busy_processing = FALSE; ! static int destroying = FALSE; /* call DestroyWindow() ourselves */ #ifdef MSWIN_FIND_REPLACE static UINT s_findrep_msg = 0; // set in gui_w[16/32].c --- 295,316 ---- static void fill_rect(const RECT *rcp, HBRUSH hbr, COLORREF color); static void clear_rect(RECT *rcp); ! static WORD s_dlgfntheight; // height of the dialog font ! static WORD s_dlgfntwidth; // width of the dialog font #ifdef FEAT_MENU static HMENU s_menuBar = NULL; #endif #ifdef FEAT_TEAROFF static void rebuild_tearoff(vimmenu_T *menu); ! static HBITMAP s_htearbitmap; // bitmap used to indicate tearoff #endif ! // Flag that is set while processing a message that must not be interrupted by ! // processing another message. static int s_busy_processing = FALSE; ! static int destroying = FALSE; // call DestroyWindow() ourselves #ifdef MSWIN_FIND_REPLACE static UINT s_findrep_msg = 0; // set in gui_w[16/32].c *************** *** 344,358 **** static HWND s_textArea = NULL; static UINT s_uMsg = 0; ! static char_u *s_textfield; /* Used by dialogs to pass back strings */ static int s_need_activate = FALSE; ! /* This variable is set when waiting for an event, which is the only moment ! * scrollbar dragging can be done directly. It's not allowed while commands ! * are executed, because it may move the cursor and that may cause unexpected ! * problems (e.g., while ":s" is working). ! */ static int allow_scrollbar = FALSE; #ifdef GLOBAL_IME --- 344,357 ---- static HWND s_textArea = NULL; static UINT s_uMsg = 0; ! static char_u *s_textfield; // Used by dialogs to pass back strings static int s_need_activate = FALSE; ! // This variable is set when waiting for an event, which is the only moment ! // scrollbar dragging can be done directly. It's not allowed while commands ! // are executed, because it may move the cursor and that may cause unexpected ! // problems (e.g., while ":s" is working). static int allow_scrollbar = FALSE; #ifdef GLOBAL_IME *************** *** 369,375 **** return 1; else if (s_directx_load_attempted) return 0; ! /* load DirectX */ DWrite_Init(); s_directx_load_attempted = 1; s_dwc = DWriteContext_Open(); --- 368,374 ---- return 1; else if (s_directx_load_attempted) return 0; ! // load DirectX DWrite_Init(); s_directx_load_attempted = 1; s_dwc = DWriteContext_Open(); *************** *** 389,398 **** } #endif ! /* use of WindowProc depends on Global IME */ #define MyWindowProc vim_WindowProc ! extern int current_font_height; /* this is in os_mswin.c */ static struct { --- 388,397 ---- } #endif ! // use of WindowProc depends on Global IME #define MyWindowProc vim_WindowProc ! extern int current_font_height; // this is in os_mswin.c static struct { *************** *** 430,440 **** {VK_F21, 'F', 'B'}, #ifdef FEAT_NETBEANS_INTG ! {VK_PAUSE, 'F', 'B'}, /* Pause == F21 (see gui_gtk_x11.c) */ #endif {VK_F22, 'F', 'C'}, {VK_F23, 'F', 'D'}, ! {VK_F24, 'F', 'E'}, /* winuser.h defines up to F24 */ {VK_HELP, '%', '1'}, {VK_BACK, 'k', 'b'}, --- 429,439 ---- {VK_F21, 'F', 'B'}, #ifdef FEAT_NETBEANS_INTG ! {VK_PAUSE, 'F', 'B'}, // Pause == F21 (see gui_gtk_x11.c) #endif {VK_F22, 'F', 'C'}, {VK_F23, 'F', 'D'}, ! {VK_F24, 'F', 'E'}, // winuser.h defines up to F24 {VK_HELP, '%', '1'}, {VK_BACK, 'k', 'b'}, *************** *** 449,455 **** {VK_SUBTRACT, 'K', '7'}, {VK_DIVIDE, 'K', '8'}, {VK_MULTIPLY, 'K', '9'}, ! {VK_SEPARATOR, 'K', 'A'}, /* Keypad Enter */ {VK_DECIMAL, 'K', 'B'}, {VK_NUMPAD0, 'K', 'C'}, --- 448,454 ---- {VK_SUBTRACT, 'K', '7'}, {VK_DIVIDE, 'K', '8'}, {VK_MULTIPLY, 'K', '9'}, ! {VK_SEPARATOR, 'K', 'A'}, // Keypad Enter {VK_DECIMAL, 'K', 'B'}, {VK_NUMPAD0, 'K', 'C'}, *************** *** 463,484 **** {VK_NUMPAD8, 'K', 'K'}, {VK_NUMPAD9, 'K', 'L'}, ! /* Keys that we want to be able to use any modifier with: */ {VK_SPACE, ' ', NUL}, {VK_TAB, TAB, NUL}, {VK_ESCAPE, ESC, NUL}, {NL, NL, NUL}, {CAR, CAR, NUL}, ! /* End of list marker: */ {0, 0, 0} }; ! /* Local variables */ static int s_button_pending = -1; ! /* s_getting_focus is set when we got focus but didn't see mouse-up event yet, ! * so don't reset s_button_pending. */ static int s_getting_focus = FALSE; static int s_x_pending; --- 462,483 ---- {VK_NUMPAD8, 'K', 'K'}, {VK_NUMPAD9, 'K', 'L'}, ! // Keys that we want to be able to use any modifier with: {VK_SPACE, ' ', NUL}, {VK_TAB, TAB, NUL}, {VK_ESCAPE, ESC, NUL}, {NL, NL, NUL}, {CAR, CAR, NUL}, ! // End of list marker: {0, 0, 0} }; ! // Local variables static int s_button_pending = -1; ! // s_getting_focus is set when we got focus but didn't see mouse-up event yet, ! // so don't reset s_button_pending. static int s_getting_focus = FALSE; static int s_x_pending; *************** *** 491,497 **** // else a high surrogate #ifdef FEAT_BEVAL_GUI ! /* balloon-eval WM_NOTIFY_HANDLER */ static void Handle_WM_Notify(HWND hwnd, LPNMHDR pnmh); static void TrackUserActivity(UINT uMsg); #endif --- 490,496 ---- // else a high surrogate #ifdef FEAT_BEVAL_GUI ! // balloon-eval WM_NOTIFY_HANDLER static void Handle_WM_Notify(HWND hwnd, LPNMHDR pnmh); static void TrackUserActivity(UINT uMsg); #endif *************** *** 502,512 **** * These LOGFONTW used for IME. */ #if defined(FEAT_MBYTE_IME) || defined(GLOBAL_IME) ! /* holds LOGFONTW for 'guifontwide' if available, otherwise 'guifont' */ static LOGFONTW norm_logfont; #endif #ifdef FEAT_MBYTE_IME ! /* holds LOGFONTW for 'guifont' always. */ static LOGFONTW sub_logfont; #endif --- 501,511 ---- * These LOGFONTW used for IME. */ #if defined(FEAT_MBYTE_IME) || defined(GLOBAL_IME) ! // holds LOGFONTW for 'guifontwide' if available, otherwise 'guifont' static LOGFONTW norm_logfont; #endif #ifdef FEAT_MBYTE_IME ! // holds LOGFONTW for 'guifont' always. static LOGFONTW sub_logfont; #endif *************** *** 590,596 **** KillTimer(NULL, idEvent); ! /* Eat spurious WM_TIMER messages */ while (pPeekMessage(&msg, hwnd, WM_TIMER, WM_TIMER, PM_REMOVE)) ; --- 589,595 ---- KillTimer(NULL, idEvent); ! // Eat spurious WM_TIMER messages while (pPeekMessage(&msg, hwnd, WM_TIMER, WM_TIMER, PM_REMOVE)) ; *************** *** 619,625 **** if (blink_timer != 0) { KillTimer(NULL, blink_timer); ! /* Eat spurious WM_TIMER messages */ while (pPeekMessage(&msg, s_hwnd, WM_TIMER, WM_TIMER, PM_REMOVE)) ; blink_timer = 0; --- 618,624 ---- if (blink_timer != 0) { KillTimer(NULL, blink_timer); ! // Eat spurious WM_TIMER messages while (pPeekMessage(&msg, s_hwnd, WM_TIMER, WM_TIMER, PM_REMOVE)) ; blink_timer = 0; *************** *** 650,656 **** { gui_mswin_rm_blink_timer(); ! /* Only switch blinking on if none of the times is zero */ if (blink_waittime && blink_ontime && blink_offtime && gui.in_focus) { blink_timer = (UINT)SetTimer(NULL, 0, (UINT)blink_waittime, --- 649,655 ---- { gui_mswin_rm_blink_timer(); ! // Only switch blinking on if none of the times is zero if (blink_waittime && blink_ontime && blink_offtime && gui.in_focus) { blink_timer = (UINT)SetTimer(NULL, 0, (UINT)blink_waittime, *************** *** 680,686 **** KillTimer(NULL, idEvent); s_timed_out = TRUE; ! /* Eat spurious WM_TIMER messages */ while (pPeekMessage(&msg, hwnd, WM_TIMER, WM_TIMER, PM_REMOVE)) ; if (idEvent == s_wait_timer) --- 679,685 ---- KillTimer(NULL, idEvent); s_timed_out = TRUE; ! // Eat spurious WM_TIMER messages while (pPeekMessage(&msg, hwnd, WM_TIMER, WM_TIMER, PM_REMOVE)) ; if (idEvent == s_wait_timer) *************** *** 717,733 **** if (surrogate_pending_ch != 0) { ! /* We don't guarantee ch is a low surrogate to match the high surrogate ! * we already have; it should be, but if it isn't, tough luck. */ wstring[0] = surrogate_pending_ch; wstring[1] = ch; surrogate_pending_ch = 0; len = 2; } ! else if (ch >= 0xD800 && ch <= 0xDBFF) /* high surrogate */ { ! /* We don't have the entire code point yet, only the first UTF-16 code ! * unit; so just remember it and use it in the next call. */ surrogate_pending_ch = ch; return 0; } --- 716,732 ---- if (surrogate_pending_ch != 0) { ! // We don't guarantee ch is a low surrogate to match the high surrogate ! // we already have; it should be, but if it isn't, tough luck. wstring[0] = surrogate_pending_ch; wstring[1] = ch; surrogate_pending_ch = 0; len = 2; } ! else if (ch >= 0xD800 && ch <= 0xDBFF) // high surrogate { ! // We don't have the entire code point yet, only the first UTF-16 code ! // unit; so just remember it and use it in the next call. surrogate_pending_ch = ch; return 0; } *************** *** 737,759 **** len = 1; } ! /* "ch" is a UTF-16 character. Convert it to a string of bytes. When ! * "enc_codepage" is non-zero use the standard Win32 function, ! * otherwise use our own conversion function (e.g., for UTF-8). */ if (enc_codepage > 0) { len = WideCharToMultiByte(enc_codepage, 0, wstring, len, (LPSTR)string, slen, 0, NULL); ! /* If we had included the ALT key into the character but now the ! * upper bit is no longer set, that probably means the conversion ! * failed. Convert the original character and set the upper bit ! * afterwards. */ if (had_alt && len == 1 && ch >= 0x80 && string[0] < 0x80) { wstring[0] = ch & 0x7f; len = WideCharToMultiByte(enc_codepage, 0, wstring, len, (LPSTR)string, slen, 0, NULL); ! if (len == 1) /* safety check */ string[0] |= 0x80; } } --- 736,758 ---- len = 1; } ! // "ch" is a UTF-16 character. Convert it to a string of bytes. When ! // "enc_codepage" is non-zero use the standard Win32 function, ! // otherwise use our own conversion function (e.g., for UTF-8). if (enc_codepage > 0) { len = WideCharToMultiByte(enc_codepage, 0, wstring, len, (LPSTR)string, slen, 0, NULL); ! // If we had included the ALT key into the character but now the ! // upper bit is no longer set, that probably means the conversion ! // failed. Convert the original character and set the upper bit ! // afterwards. if (had_alt && len == 1 && ch >= 0x80 && string[0] < 0x80) { wstring[0] = ch & 0x7f; len = WideCharToMultiByte(enc_codepage, 0, wstring, len, (LPSTR)string, slen, 0, NULL); ! if (len == 1) // safety check string[0] |= 0x80; } } *************** *** 764,770 **** len = 0; else { ! if (len > slen) /* just in case */ len = slen; mch_memmove(string, ws, len); vim_free(ws); --- 763,769 ---- len = 0; else { ! if (len > slen) // just in case len = slen; mch_memmove(string, ws, len); vim_free(ws); *************** *** 780,786 **** for (i = 0; i < len; ++i) if (string[i] == CSI && len <= slen - 2) { ! /* Insert CSI as K_CSI. */ mch_memmove(string + i + 3, string + i + 1, len - i - 1); string[++i] = KS_EXTRA; string[++i] = (int)KE_CSI; --- 779,785 ---- for (i = 0; i < len; ++i) if (string[i] == CSI && len <= slen - 2) { ! // Insert CSI as K_CSI. mch_memmove(string + i + 3, string + i + 1, len - i - 1); string[++i] = KS_EXTRA; string[++i] = (int)KE_CSI; *************** *** 823,842 **** UINT cch, int cRepeat UNUSED) { ! char_u string[40]; /* Enough for multibyte character */ int len; int modifiers; ! int ch = cch; /* special keys are negative */ dead_key = 0; ! /* TRACE("OnSysChar(%d, %c)\n", ch, ch); */ ! /* OK, we have a character key (given by ch) which was entered with the ! * ALT key pressed. Eg, if the user presses Alt-A, then ch == 'A'. Note ! * that the system distinguishes Alt-a and Alt-A (Alt-Shift-a unless ! * CAPSLOCK is pressed) at this point. ! */ modifiers = MOD_MASK_ALT; if (GetKeyState(VK_SHIFT) & 0x8000) modifiers |= MOD_MASK_SHIFT; --- 822,840 ---- UINT cch, int cRepeat UNUSED) { ! char_u string[40]; // Enough for multibyte character int len; int modifiers; ! int ch = cch; // special keys are negative dead_key = 0; ! // TRACE("OnSysChar(%d, %c)\n", ch, ch); ! // OK, we have a character key (given by ch) which was entered with the ! // ALT key pressed. Eg, if the user presses Alt-A, then ch == 'A'. Note ! // that the system distinguishes Alt-a and Alt-A (Alt-Shift-a unless ! // CAPSLOCK is pressed) at this point. modifiers = MOD_MASK_ALT; if (GetKeyState(VK_SHIFT) & 0x8000) modifiers |= MOD_MASK_SHIFT; *************** *** 844,855 **** modifiers |= MOD_MASK_CTRL; ch = simplify_key(ch, &modifiers); ! /* remove the SHIFT modifier for keys where it's already included, e.g., ! * '(' and '*' */ if (ch < 0x100 && !isalpha(ch) && isprint(ch)) modifiers &= ~MOD_MASK_SHIFT; ! /* Interpret the ALT key as making the key META, include SHIFT, etc. */ ch = extract_modifiers(ch, &modifiers, TRUE, NULL); if (ch == CSI) ch = K_CSI; --- 842,853 ---- modifiers |= MOD_MASK_CTRL; ch = simplify_key(ch, &modifiers); ! // remove the SHIFT modifier for keys where it's already included, e.g., ! // '(' and '*' if (ch < 0x100 && !isalpha(ch) && isprint(ch)) modifiers &= ~MOD_MASK_SHIFT; ! // Interpret the ALT key as making the key META, include SHIFT, etc. ch = extract_modifiers(ch, &modifiers, TRUE, NULL); if (ch == CSI) ch = K_CSI; *************** *** 870,877 **** } else { ! /* Although the documentation isn't clear about it, we assume "ch" is ! * a Unicode character. */ len += char_to_string(ch, string + len, 40 - len, TRUE); } --- 868,875 ---- } else { ! // Although the documentation isn't clear about it, we assume "ch" is ! // a Unicode character. len += char_to_string(ch, string + len, 40 - len, TRUE); } *************** *** 914,920 **** int button = -1; int repeated_click; ! /* Give main window the focus: this is so the cursor isn't hollow. */ (void)SetFocus(s_hwnd); if (s_uMsg == WM_LBUTTONDOWN || s_uMsg == WM_LBUTTONDBLCLK) --- 912,918 ---- int button = -1; int repeated_click; ! // Give main window the focus: this is so the cursor isn't hollow. (void)SetFocus(s_hwnd); if (s_uMsg == WM_LBUTTONDOWN || s_uMsg == WM_LBUTTONDBLCLK) *************** *** 932,939 **** } else if (s_uMsg == WM_CAPTURECHANGED) { ! /* on W95/NT4, somehow you get in here with an odd Msg ! * if you press one button while holding down the other..*/ if (s_button_pending == MOUSE_LEFT) button = MOUSE_RIGHT; else --- 930,937 ---- } else if (s_uMsg == WM_CAPTURECHANGED) { ! // on W95/NT4, somehow you get in here with an odd Msg ! // if you press one button while holding down the other.. if (s_button_pending == MOUSE_LEFT) button = MOUSE_RIGHT; else *************** *** 970,976 **** _OnMouseEvent(s_button_pending, x, y, FALSE, keyFlags); s_button_pending = -1; } ! /* TRACE("Button down at x %d, y %d\n", x, y); */ _OnMouseEvent(button, x, y, repeated_click, keyFlags); } else --- 968,974 ---- _OnMouseEvent(s_button_pending, x, y, FALSE, keyFlags); s_button_pending = -1; } ! // TRACE("Button down at x %d, y %d\n", x, y); _OnMouseEvent(button, x, y, repeated_click, keyFlags); } else *************** *** 1010,1016 **** s_getting_focus = FALSE; if (s_button_pending > -1) { ! /* Delayed action for mouse down event */ _OnMouseEvent(s_button_pending, s_x_pending, s_y_pending, FALSE, s_kFlags_pending); s_button_pending = -1; --- 1008,1014 ---- s_getting_focus = FALSE; if (s_button_pending > -1) { ! // Delayed action for mouse down event _OnMouseEvent(s_button_pending, s_x_pending, s_y_pending, FALSE, s_kFlags_pending); s_button_pending = -1; *************** *** 1034,1046 **** */ SetCapture(s_textArea); button = MOUSE_DRAG; ! /* TRACE(" move at x %d, y %d\n", x, y); */ } else { ReleaseCapture(); button = MOUSE_RELEASE; ! /* TRACE(" up at x %d, y %d\n", x, y); */ } _OnMouseEvent(button, x, y, FALSE, keyFlags); --- 1032,1044 ---- */ SetCapture(s_textArea); button = MOUSE_DRAG; ! // TRACE(" move at x %d, y %d\n", x, y); } else { ReleaseCapture(); button = MOUSE_RELEASE; ! // TRACE(" up at x %d, y %d\n", x, y); } _OnMouseEvent(button, x, y, FALSE, keyFlags); *************** *** 1114,1136 **** int down; if (s_findrep_struct.Flags & FR_DIALOGTERM) ! /* Give main window the focus back. */ (void)SetFocus(s_hwnd); if (s_findrep_struct.Flags & FR_FINDNEXT) { flags = FRD_FINDNEXT; ! /* Give main window the focus back: this is so the cursor isn't ! * hollow. */ (void)SetFocus(s_hwnd); } else if (s_findrep_struct.Flags & FR_REPLACE) { flags = FRD_REPLACE; ! /* Give main window the focus back: this is so the cursor isn't ! * hollow. */ (void)SetFocus(s_hwnd); } else if (s_findrep_struct.Flags & FR_REPLACEALL) --- 1112,1134 ---- int down; if (s_findrep_struct.Flags & FR_DIALOGTERM) ! // Give main window the focus back. (void)SetFocus(s_hwnd); if (s_findrep_struct.Flags & FR_FINDNEXT) { flags = FRD_FINDNEXT; ! // Give main window the focus back: this is so the cursor isn't ! // hollow. (void)SetFocus(s_hwnd); } else if (s_findrep_struct.Flags & FR_REPLACE) { flags = FRD_REPLACE; ! // Give main window the focus back: this is so the cursor isn't ! // hollow. (void)SetFocus(s_hwnd); } else if (s_findrep_struct.Flags & FR_REPLACEALL) *************** *** 1142,1148 **** { char_u *p, *q; ! /* Call the generic GUI function to do the actual work. */ if (s_findrep_struct.Flags & FR_WHOLEWORD) flags |= FRD_WHOLE_WORD; if (s_findrep_struct.Flags & FR_MATCHCASE) --- 1140,1146 ---- { char_u *p, *q; ! // Call the generic GUI function to do the actual work. if (s_findrep_struct.Flags & FR_WHOLEWORD) flags |= FRD_WHOLE_WORD; if (s_findrep_struct.Flags & FR_MATCHCASE) *************** *** 1163,1169 **** { static LPARAM last_lParam = 0L; ! /* We sometimes get a mousemove when the mouse didn't move... */ if (uMsg == WM_MOUSEMOVE || uMsg == WM_NCMOUSEMOVE) { if (lParam == last_lParam) --- 1161,1167 ---- { static LPARAM last_lParam = 0L; ! // We sometimes get a mousemove when the mouse didn't move... if (uMsg == WM_MOUSEMOVE || uMsg == WM_NCMOUSEMOVE) { if (lParam == last_lParam) *************** *** 1171,1180 **** last_lParam = lParam; } ! /* Handle specially, to centralise coding. We need to be sure we catch all ! * possible events which should cause us to restore the cursor (as it is a ! * shared resource, we take full responsibility for it). ! */ switch (uMsg) { case WM_KEYUP: --- 1169,1177 ---- last_lParam = lParam; } ! // Handle specially, to centralise coding. We need to be sure we catch all ! // possible events which should cause us to restore the cursor (as it is a ! // shared resource, we take full responsibility for it). switch (uMsg) { case WM_KEYUP: *************** *** 1186,1194 **** gui_mch_mousehide(TRUE); break; ! case WM_SYSKEYUP: /* show the pointer when a system-key is pressed */ case WM_SYSCHAR: ! case WM_MOUSEMOVE: /* show the pointer on any mouse action */ case WM_LBUTTONDOWN: case WM_LBUTTONUP: case WM_MBUTTONDOWN: --- 1183,1191 ---- gui_mch_mousehide(TRUE); break; ! case WM_SYSKEYUP: // show the pointer when a system-key is pressed case WM_SYSCHAR: ! case WM_MOUSEMOVE: // show the pointer on any mouse action case WM_LBUTTONDOWN: case WM_LBUTTONUP: case WM_MBUTTONDOWN: *************** *** 1309,1322 **** int gui_mch_open(void) { ! /* Actually open the window, if not already visible ! * (may be done already in gui_mch_set_shellsize) */ if (!IsWindowVisible(s_hwnd)) ShowWindow(s_hwnd, SW_SHOWDEFAULT); #ifdef MSWIN_FIND_REPLACE ! /* Init replace string here, so that we keep it when re-opening the ! * dialog. */ s_findrep_struct.lpstrReplaceWith[0] = NUL; #endif --- 1306,1319 ---- int gui_mch_open(void) { ! // Actually open the window, if not already visible ! // (may be done already in gui_mch_set_shellsize) if (!IsWindowVisible(s_hwnd)) ShowWindow(s_hwnd, SW_SHOWDEFAULT); #ifdef MSWIN_FIND_REPLACE ! // Init replace string here, so that we keep it when re-opening the ! // dialog. s_findrep_struct.lpstrReplaceWith[0] = NUL; #endif *************** *** 1375,1383 **** } #endif ! /* When side scroll bar is unshown, the size of window will change. ! * then, the text area move left or right. thus client rect should be ! * forcedly redrawn. (Yasuhiro Matsumoto) */ if (oldx != x || oldy != y) { InvalidateRect(s_hwnd, NULL, FALSE); --- 1372,1380 ---- } #endif ! // When side scroll bar is unshown, the size of window will change. ! // then, the text area move left or right. thus client rect should be ! // forcedly redrawn. (Yasuhiro Matsumoto) if (oldx != x || oldy != y) { InvalidateRect(s_hwnd, NULL, FALSE); *************** *** 1398,1406 **** { ShowScrollBar(sb->id, SB_CTL, flag); ! /* TODO: When the window is maximized, the size of the window stays the ! * same, thus the size of the text area changes. On Win98 it's OK, on Win ! * NT 4.0 it's not... */ } void --- 1395,1403 ---- { ShowScrollBar(sb->id, SB_CTL, flag); ! // TODO: When the window is maximized, the size of the window stays the ! // same, thus the size of the text area changes. On Win98 it's OK, on Win ! // NT 4.0 it's not... } void *************** *** 1418,1430 **** void gui_mch_create_scrollbar( scrollbar_T *sb, ! int orient) /* SBAR_VERT or SBAR_HORIZ */ { sb->id = CreateWindow( "SCROLLBAR", "Scrollbar", WS_CHILD | ((orient == SBAR_VERT) ? SBS_VERT : SBS_HORZ), 0, 0, ! 10, /* Any value will do for now */ ! 10, /* Any value will do for now */ s_hwnd, NULL, g_hinst, NULL); } --- 1415,1427 ---- void gui_mch_create_scrollbar( scrollbar_T *sb, ! int orient) // SBAR_VERT or SBAR_HORIZ { sb->id = CreateWindow( "SCROLLBAR", "Scrollbar", WS_CHILD | ((orient == SBAR_VERT) ? SBS_VERT : SBS_HORZ), 0, 0, ! 10, // Any value will do for now ! 10, // Any value will do for now s_hwnd, NULL, g_hinst, NULL); } *************** *** 1491,1497 **** { HFONT font = NULL; ! /* Load the font */ font = CreateFontIndirectW(lf); if (font == NULL) --- 1488,1494 ---- { HFONT font = NULL; ! // Load the font font = CreateFontIndirectW(lf); if (font == NULL) *************** *** 1722,1728 **** */ rc.left = #ifdef FEAT_RIGHTLEFT ! /* vertical line should be on the right of current point */ CURSOR_BAR_RIGHT ? FILL_X(gui.col + 1) - w : #endif FILL_X(gui.col); --- 1719,1725 ---- */ rc.left = #ifdef FEAT_RIGHTLEFT ! // vertical line should be on the right of current point CURSOR_BAR_RIGHT ? FILL_X(gui.col + 1) - w : #endif FILL_X(gui.col); *************** *** 1748,1761 **** dead_key = 0; ! /* Make Windows generate the dead key's character */ deadCharExpel.message = originalMsg.message; deadCharExpel.hwnd = originalMsg.hwnd; deadCharExpel.wParam = VK_SPACE; MyTranslateMessage(&deadCharExpel); ! /* re-generate the current character free of the dead char influence */ PostMessage(originalMsg.hwnd, originalMsg.message, originalMsg.wParam, originalMsg.lParam); } --- 1745,1758 ---- dead_key = 0; ! // Make Windows generate the dead key's character deadCharExpel.message = originalMsg.message; deadCharExpel.hwnd = originalMsg.hwnd; deadCharExpel.wParam = VK_SPACE; MyTranslateMessage(&deadCharExpel); ! // re-generate the current character free of the dead char influence PostMessage(originalMsg.hwnd, originalMsg.message, originalMsg.wParam, originalMsg.lParam); } *************** *** 1769,1775 **** process_message(void) { MSG msg; ! UINT vk = 0; /* Virtual key */ char_u string[40]; int i; int modifiers = 0; --- 1766,1772 ---- process_message(void) { MSG msg; ! UINT vk = 0; // Virtual key char_u string[40]; int i; int modifiers = 0; *************** *** 1781,1807 **** pGetMessage(&msg, NULL, 0, 0); #ifdef FEAT_OLE ! /* Look after OLE Automation commands */ if (msg.message == WM_OLE) { char_u *str = (char_u *)msg.lParam; if (str == NULL || *str == NUL) { ! /* Message can't be ours, forward it. Fixes problem with Ultramon ! * 3.0.4 */ pDispatchMessage(&msg); } else { add_to_input_buf(str, (int)STRLEN(str)); ! vim_free(str); /* was allocated in CVim::SendKeys() */ } return; } #endif #ifdef MSWIN_FIND_REPLACE ! /* Don't process messages used by the dialog */ if (s_findrep_hwnd != NULL && pIsDialogMessage(s_findrep_hwnd, &msg)) { HandleMouseHide(msg.message, msg.lParam); --- 1778,1804 ---- pGetMessage(&msg, NULL, 0, 0); #ifdef FEAT_OLE ! // Look after OLE Automation commands if (msg.message == WM_OLE) { char_u *str = (char_u *)msg.lParam; if (str == NULL || *str == NUL) { ! // Message can't be ours, forward it. Fixes problem with Ultramon ! // 3.0.4 pDispatchMessage(&msg); } else { add_to_input_buf(str, (int)STRLEN(str)); ! vim_free(str); // was allocated in CVim::SendKeys() } return; } #endif #ifdef MSWIN_FIND_REPLACE ! // Don't process messages used by the dialog if (s_findrep_hwnd != NULL && pIsDialogMessage(s_findrep_hwnd, &msg)) { HandleMouseHide(msg.message, msg.lParam); *************** *** 1851,1858 **** MyTranslateMessage(&msg); return; } ! /* In modes where we are not typing, dead keys should behave ! * normally */ else if (!(get_real_state() & (INSERT | CMDLINE | SELECTMODE))) { outputDeadKey_rePost(msg); --- 1848,1855 ---- MyTranslateMessage(&msg); return; } ! // In modes where we are not typing, dead keys should behave ! // normally else if (!(get_real_state() & (INSERT | CMDLINE | SELECTMODE))) { outputDeadKey_rePost(msg); *************** *** 1860,1866 **** } } ! /* Check for CTRL-BREAK */ if (vk == VK_CANCEL) { trash_input_buf(); --- 1857,1863 ---- } } ! // Check for CTRL-BREAK if (vk == VK_CANCEL) { trash_input_buf(); *************** *** 1872,1878 **** for (i = 0; special_keys[i].key_sym != 0; i++) { ! /* ignore VK_SPACE when ALT key pressed: system menu */ if (special_keys[i].key_sym == vk && (vk != VK_SPACE || !(GetKeyState(VK_MENU) & 0x8000))) { --- 1869,1875 ---- for (i = 0; special_keys[i].key_sym != 0; i++) { ! // ignore VK_SPACE when ALT key pressed: system menu if (special_keys[i].key_sym == vk && (vk != VK_SPACE || !(GetKeyState(VK_MENU) & 0x8000))) { *************** *** 1890,1897 **** } #ifdef FEAT_MENU ! /* Check for : Windows selects the menu. When is ! * mapped we want to use the mapping instead. */ if (vk == VK_F10 && gui.menu_is_active && check_map(k10, State, FALSE, TRUE, FALSE, --- 1887,1894 ---- } #ifdef FEAT_MENU ! // Check for : Windows selects the menu. When is ! // mapped we want to use the mapping instead. if (vk == VK_F10 && gui.menu_is_active && check_map(k10, State, FALSE, TRUE, FALSE, *************** *** 1942,1948 **** { int len; ! /* Handle "key" as a Unicode character. */ len = char_to_string(key, string, 40, FALSE); add_to_input_buf(string, len); } --- 1939,1945 ---- { int len; ! // Handle "key" as a Unicode character. len = char_to_string(key, string, 40, FALSE); add_to_input_buf(string, len); } *************** *** 1951,1977 **** } if (special_keys[i].key_sym == 0) { ! /* Some keys need C-S- where they should only need C-. ! * Ignore 0xff, Windows XP sends it when NUMLOCK has changed since ! * system startup (Helmut Stiegler, 2003 Oct 3). */ if (vk != 0xff && (GetKeyState(VK_CONTROL) & 0x8000) && !(GetKeyState(VK_SHIFT) & 0x8000) && !(GetKeyState(VK_MENU) & 0x8000)) { ! /* CTRL-6 is '^'; Japanese keyboard maps '^' to vk == 0xDE */ if (vk == '6' || MapVirtualKey(vk, 2) == (UINT)'^') { string[0] = Ctrl_HAT; add_to_input_buf(string, 1); } ! /* vk == 0xBD AZERTY for CTRL-'-', but CTRL-[ for * QWERTY! */ ! else if (vk == 0xBD) /* QWERTY for CTRL-'-' */ { string[0] = Ctrl__; add_to_input_buf(string, 1); } ! /* CTRL-2 is '@'; Japanese keyboard maps '@' to vk == 0xC0 */ else if (vk == '2' || MapVirtualKey(vk, 2) == (UINT)'@') { string[0] = Ctrl_AT; --- 1948,1974 ---- } if (special_keys[i].key_sym == 0) { ! // Some keys need C-S- where they should only need C-. ! // Ignore 0xff, Windows XP sends it when NUMLOCK has changed since ! // system startup (Helmut Stiegler, 2003 Oct 3). if (vk != 0xff && (GetKeyState(VK_CONTROL) & 0x8000) && !(GetKeyState(VK_SHIFT) & 0x8000) && !(GetKeyState(VK_MENU) & 0x8000)) { ! // CTRL-6 is '^'; Japanese keyboard maps '^' to vk == 0xDE if (vk == '6' || MapVirtualKey(vk, 2) == (UINT)'^') { string[0] = Ctrl_HAT; add_to_input_buf(string, 1); } ! // vk == 0xBD AZERTY for CTRL-'-', but CTRL-[ for * QWERTY! ! else if (vk == 0xBD) // QWERTY for CTRL-'-' { string[0] = Ctrl__; add_to_input_buf(string, 1); } ! // CTRL-2 is '@'; Japanese keyboard maps '@' to vk == 0xC0 else if (vk == '2' || MapVirtualKey(vk, 2) == (UINT)'@') { string[0] = Ctrl_AT; *************** *** 1988,1998 **** else if (msg.message == WM_IME_NOTIFY) _OnImeNotify(msg.hwnd, (DWORD)msg.wParam, (DWORD)msg.lParam); else if (msg.message == WM_KEYUP && im_get_status()) ! /* added for non-MS IME (Yasuhiro Matsumoto) */ MyTranslateMessage(&msg); #endif #if !defined(FEAT_MBYTE_IME) && defined(GLOBAL_IME) ! /* GIME_TEST */ else if (msg.message == WM_IME_STARTCOMPOSITION) { POINT point; --- 1985,1995 ---- else if (msg.message == WM_IME_NOTIFY) _OnImeNotify(msg.hwnd, (DWORD)msg.wParam, (DWORD)msg.lParam); else if (msg.message == WM_KEYUP && im_get_status()) ! // added for non-MS IME (Yasuhiro Matsumoto) MyTranslateMessage(&msg); #endif #if !defined(FEAT_MBYTE_IME) && defined(GLOBAL_IME) ! // GIME_TEST else if (msg.message == WM_IME_STARTCOMPOSITION) { POINT point; *************** *** 2006,2014 **** #endif #ifdef FEAT_MENU ! /* Check for : Default effect is to select the menu. When is ! * mapped we need to stop it here to avoid strange effects (e.g., for the ! * key-up event) */ if (vk != VK_F10 || check_map(k10, State, FALSE, TRUE, FALSE, NULL, NULL) == NULL) #endif --- 2003,2011 ---- #endif #ifdef FEAT_MENU ! // Check for : Default effect is to select the menu. When is ! // mapped we need to stop it here to avoid strange effects (e.g., for the ! // key-up event) if (vk != VK_F10 || check_map(k10, State, FALSE, TRUE, FALSE, NULL, NULL) == NULL) #endif *************** *** 2041,2047 **** { KillTimer(NULL, s_wait_timer); ! /* Eat spurious WM_TIMER messages */ while (pPeekMessage(&msg, s_hwnd, WM_TIMER, WM_TIMER, PM_REMOVE)) ; s_wait_timer = 0; --- 2038,2044 ---- { KillTimer(NULL, s_wait_timer); ! // Eat spurious WM_TIMER messages while (pPeekMessage(&msg, s_hwnd, WM_TIMER, WM_TIMER, PM_REMOVE)) ; s_wait_timer = 0; *************** *** 2213,2219 **** int w UNUSED, int h UNUSED) { ! /* It will be in the right place anyway */ } #if defined(FEAT_MENU) || defined(PROTO) --- 2210,2216 ---- int w UNUSED, int h UNUSED) { ! // It will be in the right place anyway } #if defined(FEAT_MENU) || defined(PROTO) *************** *** 2245,2251 **** { DrawMenuBar(s_hwnd); } ! #endif /*FEAT_MENU*/ /* * Return the RGB value of a pixel as a long. --- 2242,2248 ---- { DrawMenuBar(s_hwnd); } ! #endif // FEAT_MENU /* * Return the RGB value of a pixel as a long. *************** *** 2258,2278 **** } #if defined(FEAT_GUI_DIALOG) || defined(PROTO) ! /* Convert pixels in X to dialog units */ static WORD PixelToDialogX(int numPixels) { return (WORD)((numPixels * 4) / s_dlgfntwidth); } ! /* Convert pixels in Y to dialog units */ static WORD PixelToDialogY(int numPixels) { return (WORD)((numPixels * 8) / s_dlgfntheight); } ! /* Return the width in pixels of the given text in the given DC. */ static int GetTextWidth(HDC hdc, char_u *str, int len) { --- 2255,2281 ---- } #if defined(FEAT_GUI_DIALOG) || defined(PROTO) ! /* ! * Convert pixels in X to dialog units ! */ static WORD PixelToDialogX(int numPixels) { return (WORD)((numPixels * 4) / s_dlgfntwidth); } ! /* ! * Convert pixels in Y to dialog units ! */ static WORD PixelToDialogY(int numPixels) { return (WORD)((numPixels * 8) / s_dlgfntheight); } ! /* ! * Return the width in pixels of the given text in the given DC. ! */ static int GetTextWidth(HDC hdc, char_u *str, int len) { *************** *** 2328,2334 **** wChild = rChild.right - rChild.left; hChild = rChild.bottom - rChild.top; ! /* If Vim is minimized put the window in the middle of the screen. */ if (hwndParent == NULL || IsMinimized(hwndParent)) get_work_area(&rParent); else --- 2331,2337 ---- wChild = rChild.right - rChild.left; hChild = rChild.bottom - rChild.top; ! // If Vim is minimized put the window in the middle of the screen. if (hwndParent == NULL || IsMinimized(hwndParent)) get_work_area(&rParent); else *************** *** 2367,2373 **** return SetWindowPos(hwndChild, NULL, xNew, yNew, 0, 0, SWP_NOSIZE | SWP_NOZORDER); } ! #endif /* FEAT_GUI_DIALOG */ #if defined(FEAT_TOOLBAR) || defined(PROTO) void --- 2370,2376 ---- return SetWindowPos(hwndChild, NULL, xNew, yNew, 0, 0, SWP_NOSIZE | SWP_NOZORDER); } ! #endif // FEAT_GUI_DIALOG #if defined(FEAT_TOOLBAR) || defined(PROTO) void *************** *** 2391,2397 **** ShowWindow(s_toolbarhwnd, SW_HIDE); } ! /* The number of bitmaps is fixed. Exit is missing! */ # define TOOLBAR_BITMAP_COUNT 31 #endif --- 2394,2400 ---- ShowWindow(s_toolbarhwnd, SW_HIDE); } ! // The number of bitmaps is fixed. Exit is missing! # define TOOLBAR_BITMAP_COUNT 31 #endif *************** *** 2424,2430 **** long rval; POINT pt; ! /* When ignoring events don't show the menu. */ if (hold_gui_events # ifdef FEAT_CMDWIN || cmdwin_type != 0 --- 2427,2433 ---- long rval; POINT pt; ! // When ignoring events don't show the menu. if (hold_gui_events # ifdef FEAT_CMDWIN || cmdwin_type != 0 *************** *** 2450,2456 **** DestroyMenu(tab_pmenu); ! /* Add the string cmd into input buffer */ if (rval > 0) { TCHITTESTINFO htinfo; --- 2453,2459 ---- DestroyMenu(tab_pmenu); ! // Add the string cmd into input buffer if (rval > 0) { TCHITTESTINFO htinfo; *************** *** 2516,2522 **** return; # ifndef CCM_SETUNICODEFORMAT ! /* For older compilers. We assume this never changes. */ # define CCM_SETUNICODEFORMAT 0x2005 # endif // Enable unicode support --- 2519,2525 ---- return; # ifndef CCM_SETUNICODEFORMAT ! // For older compilers. We assume this never changes. # define CCM_SETUNICODEFORMAT 0x2005 # endif // Enable unicode support *************** *** 2525,2534 **** tie.mask = TCIF_TEXT; tie.iImage = -1; ! /* Disable redraw for tab updates to eliminate O(N^2) draws. */ SendMessage(s_tabhwnd, WM_SETREDRAW, (WPARAM)FALSE, 0); ! /* Add a label for each tab page. They all contain the same text area. */ for (tp = first_tabpage; tp != NULL; tp = tp->tp_next, ++nr) { if (tp == curtab) --- 2528,2537 ---- tie.mask = TCIF_TEXT; tie.iImage = -1; ! // Disable redraw for tab updates to eliminate O(N^2) draws. SendMessage(s_tabhwnd, WM_SETREDRAW, (WPARAM)FALSE, 0); ! // Add a label for each tab page. They all contain the same text area. for (tp = first_tabpage; tp != NULL; tp = tp->tp_next, ++nr) { if (tp == curtab) *************** *** 2536,2542 **** if (nr >= TabCtrl_GetItemCount(s_tabhwnd)) { ! /* Add the tab */ tie.pszText = "-Empty-"; TabCtrl_InsertItem(s_tabhwnd, nr, &tie); tabadded = 1; --- 2539,2545 ---- if (nr >= TabCtrl_GetItemCount(s_tabhwnd)) { ! // Add the tab tie.pszText = "-Empty-"; TabCtrl_InsertItem(s_tabhwnd, nr, &tie); tabadded = 1; *************** *** 2558,2571 **** } } ! /* Remove any old labels. */ while (nr < TabCtrl_GetItemCount(s_tabhwnd)) TabCtrl_DeleteItem(s_tabhwnd, nr); if (!tabadded && TabCtrl_GetCurSel(s_tabhwnd) != curtabidx) TabCtrl_SetCurSel(s_tabhwnd, curtabidx); ! /* Re-enable redraw and redraw. */ SendMessage(s_tabhwnd, WM_SETREDRAW, (WPARAM)TRUE, 0); RedrawWindow(s_tabhwnd, NULL, NULL, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN); --- 2561,2574 ---- } } ! // Remove any old labels. while (nr < TabCtrl_GetItemCount(s_tabhwnd)) TabCtrl_DeleteItem(s_tabhwnd, nr); if (!tabadded && TabCtrl_GetCurSel(s_tabhwnd) != curtabidx) TabCtrl_SetCurSel(s_tabhwnd, curtabidx); ! // Re-enable redraw and redraw. SendMessage(s_tabhwnd, WM_SETREDRAW, (WPARAM)TRUE, 0); RedrawWindow(s_tabhwnd, NULL, NULL, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN); *************** *** 2603,2617 **** while (*keys) { if (*keys == '~') ! *keys = ' '; /* for showing system menu */ PostMessage(s_hwnd, WM_CHAR, (WPARAM)*keys, (LPARAM)0); keys++; fill_typebuf = TRUE; } if (fill_typebuf) { ! /* Put a NOP in the typeahead buffer so that the message will get ! * processed. */ key_name[0] = K_SPECIAL; key_name[1] = KS_EXTRA; key_name[2] = KE_NOP; --- 2606,2620 ---- while (*keys) { if (*keys == '~') ! *keys = ' '; // for showing system menu PostMessage(s_hwnd, WM_CHAR, (WPARAM)*keys, (LPARAM)0); keys++; fill_typebuf = TRUE; } if (fill_typebuf) { ! // Put a NOP in the typeahead buffer so that the message will get ! // processed. key_name[0] = K_SPECIAL; key_name[1] = KS_EXTRA; key_name[2] = KE_NOP; *************** *** 2636,2642 **** int mcase = !p_ic; char_u *entry_text; ! /* Get the search string to use. */ entry_text = get_find_dialog_text(initial_string, &wword, &mcase); s_findrep_struct.hwndOwner = s_hwnd; --- 2639,2645 ---- int mcase = !p_ic; char_u *entry_text; ! // Get the search string to use. entry_text = get_find_dialog_text(initial_string, &wword, &mcase); s_findrep_struct.hwndOwner = s_hwnd; *************** *** 2668,2674 **** { WCHAR *wbuf; ! /* Convert the title from 'encoding' to UTF-16. */ wbuf = (WCHAR *)enc_to_utf16((char_u *)title, NULL); if (wbuf != NULL) { --- 2671,2677 ---- { WCHAR *wbuf; ! // Convert the title from 'encoding' to UTF-16. wbuf = (WCHAR *)enc_to_utf16((char_u *)title, NULL); if (wbuf != NULL) { *************** *** 2745,2758 **** static void gui_mch_show_popupmenu_at(vimmenu_T *menu, int x, int y) { ! /* Unhide the mouse, we don't get move events here. */ gui_mch_mousehide(FALSE); (void)TrackPopupMenu( (HMENU)menu->submenu_id, TPM_LEFTALIGN | TPM_LEFTBUTTON, x, y, ! (int)0, /*reserved param*/ s_hwnd, NULL); /* --- 2748,2761 ---- static void gui_mch_show_popupmenu_at(vimmenu_T *menu, int x, int y) { ! // Unhide the mouse, we don't get move events here. gui_mch_mousehide(FALSE); (void)TrackPopupMenu( (HMENU)menu->submenu_id, TPM_LEFTALIGN | TPM_LEFTBUTTON, x, y, ! (int)0, //reserved param s_hwnd, NULL); /* *************** *** 2799,2809 **** { PAINTSTRUCT ps; ! out_flush(); /* make sure all output has been processed */ (void)BeginPaint(hwnd, &ps); ! /* prevent multi-byte characters from misprinting on an invalid ! * rectangle */ if (has_mbyte) { RECT rect; --- 2802,2812 ---- { PAINTSTRUCT ps; ! out_flush(); // make sure all output has been processed (void)BeginPaint(hwnd, &ps); ! // prevent multi-byte characters from misprinting on an invalid ! // rectangle if (has_mbyte) { RECT rect; *************** *** 2836,2842 **** gui_resize_shell(cx, cy); #ifdef FEAT_MENU ! /* Menu bar may wrap differently now */ gui_mswin_get_menu_height(TRUE); #endif } --- 2839,2845 ---- gui_resize_shell(cx, cy); #ifdef FEAT_MENU ! // Menu bar may wrap differently now gui_mswin_get_menu_height(TRUE); #endif } *************** *** 2871,2878 **** BOOL fActivate, DWORD dwThreadId) { ! /* we call gui_focus_change() in _OnSetFocus() */ ! /* gui_focus_change((int)fActivate); */ return MyWindowProc(hwnd, WM_ACTIVATEAPP, fActivate, (DWORD)dwThreadId); } --- 2874,2881 ---- BOOL fActivate, DWORD dwThreadId) { ! // we call gui_focus_change() in _OnSetFocus() ! // gui_focus_change((int)fActivate); return MyWindowProc(hwnd, WM_ACTIVATEAPP, fActivate, (DWORD)dwThreadId); } *************** *** 2954,2962 **** rc.right = gui.num_cols * gui.char_width; rc.bottom = gui.num_rows * gui.char_height; InvertRect(s_hdc, &rc); ! gui_mch_flush(); /* make sure it's displayed */ ! ui_delay((long)msec, TRUE); /* wait for a few msec */ InvertRect(s_hdc, &rc); } --- 2957,2965 ---- rc.right = gui.num_cols * gui.char_width; rc.bottom = gui.num_rows * gui.char_height; InvertRect(s_hdc, &rc); ! gui_mch_flush(); // make sure it's displayed ! ui_delay((long)msec, TRUE); // wait for a few msec InvertRect(s_hdc, &rc); } *************** *** 2974,2986 **** GetWindowRect(s_hwnd, &rcVim); ! /* Check if the window is partly above or below the screen. We don't care ! * about partly left or right of the screen, it is not relevant when ! * scrolling up or down. */ if (rcVim.top < 0 || rcVim.bottom > GetSystemMetrics(SM_CYFULLSCREEN)) return SW_INVALIDATE; ! /* Check if there is an window (partly) on top of us. */ for (hwnd = s_hwnd; (hwnd = GetWindow(hwnd, GW_HWNDPREV)) != (HWND)0; ) if (IsWindowVisible(hwnd)) { --- 2977,2989 ---- GetWindowRect(s_hwnd, &rcVim); ! // Check if the window is partly above or below the screen. We don't care ! // about partly left or right of the screen, it is not relevant when ! // scrolling up or down. if (rcVim.top < 0 || rcVim.bottom > GetSystemMetrics(SM_CYFULLSCREEN)) return SW_INVALIDATE; ! // Check if there is an window (partly) on top of us. for (hwnd = s_hwnd; (hwnd = GetWindow(hwnd, GW_HWNDPREV)) != (HWND)0; ) if (IsWindowVisible(hwnd)) { *************** *** 3036,3046 **** UpdateWindow(s_textArea); } ! /* This seems to be required to avoid the cursor disappearing when ! * scrolling such that the cursor ends up in the top-left character on ! * the screen... But why? (Webb) */ ! /* It's probably fixed by disabling drawing the cursor while scrolling. */ ! /* gui.cursor_is_valid = FALSE; */ gui_clear_block(gui.scroll_region_bot - num_lines + 1, gui.scroll_region_left, --- 3039,3049 ---- UpdateWindow(s_textArea); } ! // This seems to be required to avoid the cursor disappearing when ! // scrolling such that the cursor ends up in the top-left character on ! // the screen... But why? (Webb) ! // It's probably fixed by disabling drawing the cursor while scrolling. ! // gui.cursor_is_valid = FALSE; gui_clear_block(gui.scroll_region_bot - num_lines + 1, gui.scroll_region_left, *************** *** 3073,3080 **** #endif { intel_gpu_workaround(); ! /* The SW_INVALIDATE is required when part of the window is covered or ! * off-screen. How do we avoid it when it's not needed? */ ScrollWindowEx(s_textArea, 0, num_lines * gui.char_height, &rc, &rc, NULL, NULL, get_scroll_flags()); UpdateWindow(s_textArea); --- 3076,3083 ---- #endif { intel_gpu_workaround(); ! // The SW_INVALIDATE is required when part of the window is covered or ! // off-screen. How do we avoid it when it's not needed? ScrollWindowEx(s_textArea, 0, num_lines * gui.char_height, &rc, &rc, NULL, NULL, get_scroll_flags()); UpdateWindow(s_textArea); *************** *** 3098,3111 **** DeleteObject(s_brush); #ifdef FEAT_TEAROFF ! /* Unload the tearoff bitmap */ (void)DeleteObject((HGDIOBJ)s_htearbitmap); #endif ! /* Destroy our window (if we have one). */ if (s_hwnd != NULL) { ! destroying = TRUE; /* ignore WM_DESTROY message now */ DestroyWindow(s_hwnd); } --- 3101,3114 ---- DeleteObject(s_brush); #ifdef FEAT_TEAROFF ! // Unload the tearoff bitmap (void)DeleteObject((HGDIOBJ)s_htearbitmap); #endif ! // Destroy our window (if we have one). if (s_hwnd != NULL) { ! destroying = TRUE; // ignore WM_DESTROY message now DestroyWindow(s_hwnd); } *************** *** 3246,3252 **** GuiFont font = NOFONT; char_u *p; ! /* Load the font */ if (get_logfont(&lf, font_name, NULL, TRUE) == OK) font = get_font_handle(&lf); if (font == NOFONT) --- 3249,3255 ---- GuiFont font = NOFONT; char_u *p; ! // Load the font if (get_logfont(&lf, font_name, NULL, TRUE) == OK) font = get_font_handle(&lf); if (font == NOFONT) *************** *** 3273,3280 **** { hl_set_font_name(p); ! /* When setting 'guifont' to "*" replace it with the actual font name. ! * */ if (STRCMP(font_name, "*") == 0 && STRCMP(p_guifont, "*") == 0) { vim_free(p_guifont); --- 3276,3283 ---- { hl_set_font_name(p); ! // When setting 'guifont' to "*" replace it with the actual font name. ! // if (STRCMP(font_name, "*") == 0 && STRCMP(p_guifont, "*") == 0) { vim_free(p_guifont); *************** *** 3312,3318 **** } #ifndef WPF_RESTORETOMAXIMIZED ! # define WPF_RESTORETOMAXIMIZED 2 /* just in case someone doesn't have it */ #endif /* --- 3315,3321 ---- } #ifndef WPF_RESTORETOMAXIMIZED ! # define WPF_RESTORETOMAXIMIZED 2 // just in case someone doesn't have it #endif /* *************** *** 3359,3365 **** } else { ! /* Inside another window, don't use the frame and border. */ gui_resize_shell(rect.right - rect.left, rect.bottom - rect.top #ifdef FEAT_MENU --- 3362,3368 ---- } else { ! // Inside another window, don't use the frame and border. gui_resize_shell(rect.right - rect.left, rect.bottom - rect.top #ifdef FEAT_MENU *************** *** 3381,3407 **** } #if defined(FEAT_MOUSESHAPE) || defined(PROTO) ! /* Table for shape IDCs. Keep in sync with the mshape_names[] table in ! * misc2.c! */ static LPCSTR mshape_idcs[] = { ! IDC_ARROW, /* arrow */ ! MAKEINTRESOURCE(0), /* blank */ ! IDC_IBEAM, /* beam */ ! IDC_SIZENS, /* updown */ ! IDC_SIZENS, /* udsizing */ ! IDC_SIZEWE, /* leftright */ ! IDC_SIZEWE, /* lrsizing */ ! IDC_WAIT, /* busy */ ! IDC_NO, /* no */ ! IDC_ARROW, /* crosshair */ ! IDC_ARROW, /* hand1 */ ! IDC_ARROW, /* hand2 */ ! IDC_ARROW, /* pencil */ ! IDC_ARROW, /* question */ ! IDC_ARROW, /* right-arrow */ ! IDC_UPARROW, /* up-arrow */ ! IDC_ARROW /* last one */ }; void --- 3384,3410 ---- } #if defined(FEAT_MOUSESHAPE) || defined(PROTO) ! // Table for shape IDCs. Keep in sync with the mshape_names[] table in ! // misc2.c! static LPCSTR mshape_idcs[] = { ! IDC_ARROW, // arrow ! MAKEINTRESOURCE(0), // blank ! IDC_IBEAM, // beam ! IDC_SIZENS, // updown ! IDC_SIZENS, // udsizing ! IDC_SIZEWE, // leftright ! IDC_SIZEWE, // lrsizing ! IDC_WAIT, // busy ! IDC_NO, // no ! IDC_ARROW, // crosshair ! IDC_ARROW, // hand1 ! IDC_ARROW, // hand2 ! IDC_ARROW, // pencil ! IDC_ARROW, // question ! IDC_ARROW, // right-arrow ! IDC_UPARROW, // up-arrow ! IDC_ARROW // last one }; void *************** *** 3422,3428 **** { POINT mp; ! /* Set the position to make it redrawn with the new shape. */ (void)GetCursorPos((LPPOINT)&mp); (void)SetCursorPos(mp.x, mp.y); ShowCursor(TRUE); --- 3425,3431 ---- { POINT mp; ! // Set the position to make it redrawn with the new shape. (void)GetCursorPos((LPPOINT)&mp); (void)SetCursorPos(mp.x, mp.y); ShowCursor(TRUE); *************** *** 3470,3477 **** char_u *initdir, char_u *filter) { ! /* We always use the wide function. This means enc_to_utf16() must work, ! * otherwise it fails miserably! */ OPENFILENAMEW fileStruct; WCHAR fileBuf[MAXPATHL]; WCHAR *wp; --- 3473,3480 ---- char_u *initdir, char_u *filter) { ! // We always use the wide function. This means enc_to_utf16() must work, ! // otherwise it fails miserably! OPENFILENAMEW fileStruct; WCHAR fileBuf[MAXPATHL]; WCHAR *wp; *************** *** 3498,3509 **** } } ! /* Convert the filter to Windows format. */ filterp = convert_filterW(filter); vim_memset(&fileStruct, 0, sizeof(OPENFILENAMEW)); # ifdef OPENFILENAME_SIZE_VERSION_400W ! /* be compatible with Windows NT 4.0 */ fileStruct.lStructSize = OPENFILENAME_SIZE_VERSION_400W; # else fileStruct.lStructSize = sizeof(fileStruct); --- 3501,3512 ---- } } ! // Convert the filter to Windows format. filterp = convert_filterW(filter); vim_memset(&fileStruct, 0, sizeof(OPENFILENAMEW)); # ifdef OPENFILENAME_SIZE_VERSION_400W ! // be compatible with Windows NT 4.0 fileStruct.lStructSize = OPENFILENAME_SIZE_VERSION_400W; # else fileStruct.lStructSize = sizeof(fileStruct); *************** *** 3520,3530 **** fileStruct.lpstrFile = fileBuf; fileStruct.nMaxFile = MAXPATHL; fileStruct.lpstrFilter = filterp; ! fileStruct.hwndOwner = s_hwnd; /* main Vim window is owner*/ ! /* has an initial dir been specified? */ if (initdir != NULL && *initdir != NUL) { ! /* Must have backslashes here, no matter what 'shellslash' says */ initdirp = enc_to_utf16(initdir, NULL); if (initdirp != NULL) { --- 3523,3533 ---- fileStruct.lpstrFile = fileBuf; fileStruct.nMaxFile = MAXPATHL; fileStruct.lpstrFilter = filterp; ! fileStruct.hwndOwner = s_hwnd; // main Vim window is owner ! // has an initial dir been specified? if (initdir != NULL && *initdir != NUL) { ! // Must have backslashes here, no matter what 'shellslash' says initdirp = enc_to_utf16(initdir, NULL); if (initdirp != NULL) { *************** *** 3564,3578 **** vim_free(titlep); vim_free(extp); ! /* Convert from UCS2 to 'encoding'. */ p = utf16_to_enc(fileBuf, NULL); if (p == NULL) return NULL; ! /* Give focus back to main window (when using MDI). */ SetFocus(s_hwnd); ! /* Shorten the file name if possible */ q = vim_strsave(shorten_fname1(p)); vim_free(p); return q; --- 3567,3581 ---- vim_free(titlep); vim_free(extp); ! // Convert from UCS2 to 'encoding'. p = utf16_to_enc(fileBuf, NULL); if (p == NULL) return NULL; ! // Give focus back to main window (when using MDI). SetFocus(s_hwnd); ! // Shorten the file name if possible q = vim_strsave(shorten_fname1(p)); vim_free(p); return q; *************** *** 3602,3608 **** else res[i] = s[i]; res[s_len] = NUL; ! /* Add two extra NULs to make sure it's properly terminated. */ res[s_len + 1] = NUL; res[s_len + 2] = NUL; } --- 3605,3611 ---- else res[i] = s[i]; res[s_len] = NUL; ! // Add two extra NULs to make sure it's properly terminated. res[s_len + 1] = NUL; res[s_len + 2] = NUL; } *************** *** 3615,3626 **** char_u * gui_mch_browsedir(char_u *title, char_u *initdir) { ! /* We fake this: Use a filter that doesn't select anything and a default ! * file name that won't be used. */ return gui_mch_browse(0, title, (char_u *)_("Not Used"), NULL, initdir, (char_u *)_("Directory\t*.nothing\n")); } ! #endif /* FEAT_BROWSE */ static void _OnDropFiles( --- 3618,3629 ---- char_u * gui_mch_browsedir(char_u *title, char_u *initdir) { ! // We fake this: Use a filter that doesn't select anything and a default ! // file name that won't be used. return gui_mch_browse(0, title, (char_u *)_("Not Used"), NULL, initdir, (char_u *)_("Directory\t*.nothing\n")); } ! #endif // FEAT_BROWSE static void _OnDropFiles( *************** *** 3637,3645 **** POINT pt; int_u modifiers = 0; ! /* TRACE("_OnDropFiles: %d files dropped\n", cFiles); */ ! /* Obtain dropped position */ DragQueryPoint(hDrop, &pt); MapWindowPoints(s_hwnd, s_textArea, &pt, 1); --- 3640,3648 ---- POINT pt; int_u modifiers = 0; ! // TRACE("_OnDropFiles: %d files dropped\n", cFiles); ! // Obtain dropped position DragQueryPoint(hDrop, &pt); MapWindowPoints(s_hwnd, s_textArea, &pt, 1); *************** *** 3683,3689 **** UINT code, int pos) { ! static UINT prev_code = 0; /* code of previous call */ scrollbar_T *sb, *sb_info; long val; int dragging = FALSE; --- 3686,3692 ---- UINT code, int pos) { ! static UINT prev_code = 0; // code of previous call scrollbar_T *sb, *sb_info; long val; int dragging = FALSE; *************** *** 3697,3703 **** if (sb == NULL) return 0; ! if (sb->wp != NULL) /* Left or right scrollbar */ { /* * Careful: need to get scrollbar info out of first (left) scrollbar --- 3700,3706 ---- if (sb == NULL) return 0; ! if (sb->wp != NULL) // Left or right scrollbar { /* * Careful: need to get scrollbar info out of first (left) scrollbar *************** *** 3706,3712 **** */ sb_info = &sb->wp->w_scrollbars[0]; } ! else /* Bottom scrollbar */ sb_info = sb; val = sb_info->value; --- 3709,3715 ---- */ sb_info = &sb->wp->w_scrollbars[0]; } ! else // Bottom scrollbar sb_info = sb; val = sb_info->value; *************** *** 3751,3757 **** break; default: ! /* TRACE("Unknown scrollbar event %d\n", code); */ return 0; } prev_code = code; --- 3754,3760 ---- break; default: ! // TRACE("Unknown scrollbar event %d\n", code); return 0; } prev_code = code; *************** *** 3770,3780 **** SetScrollInfo(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; mch_disable_flush(); --- 3773,3783 ---- SetScrollInfo(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; mch_disable_flush(); *************** *** 3902,3911 **** # define HANDLE_WM_DEADCHAR(hwnd, wParam, lParam, fn) \ ((fn)((hwnd), (TCHAR)(wParam), (int)(short)LOWORD(lParam)), 0L) # endif ! #endif /* __MINGW32__ */ ! /* Some parameters for tearoff menus. All in pixels. */ #define TEAROFF_PADDING_X 2 #define TEAROFF_BUTTON_PAD_X 8 #define TEAROFF_MIN_WIDTH 200 --- 3905,3914 ---- # define HANDLE_WM_DEADCHAR(hwnd, wParam, lParam, fn) \ ((fn)((hwnd), (TCHAR)(wParam), (int)(short)LOWORD(lParam)), 0L) # endif ! #endif // __MINGW32__ ! // Some parameters for tearoff menus. All in pixels. #define TEAROFF_PADDING_X 2 #define TEAROFF_BUTTON_PAD_X 8 #define TEAROFF_MIN_WIDTH 200 *************** *** 3913,3919 **** #define TEAROFF_COLUMN_PADDING 3 // # spaces to pad column with. ! /* For the Intellimouse: */ #ifndef WM_MOUSEWHEEL # define WM_MOUSEWHEEL 0x20a #endif --- 3916,3922 ---- #define TEAROFF_COLUMN_PADDING 3 // # spaces to pad column with. ! // For the Intellimouse: #ifndef WM_MOUSEWHEEL # define WM_MOUSEWHEEL 0x20a #endif *************** *** 3924,3931 **** # define BEVAL_TEXT_LEN MAXPATHL # if (defined(_MSC_VER) && _MSC_VER < 1300) || !defined(MAXULONG_PTR) ! /* Work around old versions of basetsd.h which wrongly declares ! * UINT_PTR as unsigned long. */ # undef UINT_PTR # define UINT_PTR UINT # endif --- 3927,3934 ---- # define BEVAL_TEXT_LEN MAXPATHL # if (defined(_MSC_VER) && _MSC_VER < 1300) || !defined(MAXULONG_PTR) ! // Work around old versions of basetsd.h which wrongly declares ! // UINT_PTR as unsigned long. # undef UINT_PTR # define UINT_PTR UINT # endif *************** *** 3935,3941 **** static DWORD LastActivity = 0; ! /* cproto fails on missing include files */ # ifndef PROTO /* --- 3938,3944 ---- static DWORD LastActivity = 0; ! // cproto fails on missing include files # ifndef PROTO /* *************** *** 4018,4030 **** # define TTN_GETDISPINFO (TTN_FIRST - 0) # endif ! #endif /* defined(FEAT_BEVAL_GUI) */ #if defined(FEAT_TOOLBAR) || defined(FEAT_GUI_TABLINE) ! /* Older MSVC compilers don't have LPNMTTDISPINFO[AW] thus we need to define ! * it here if LPNMTTDISPINFO isn't defined. ! * MingW doesn't define LPNMTTDISPINFO but typedefs it. Thus we need to check ! * _MSC_VER. */ # if !defined(LPNMTTDISPINFO) && defined(_MSC_VER) typedef struct tagNMTTDISPINFOA { NMHDR hdr; --- 4021,4033 ---- # define TTN_GETDISPINFO (TTN_FIRST - 0) # endif ! #endif // defined(FEAT_BEVAL_GUI) #if defined(FEAT_TOOLBAR) || defined(FEAT_GUI_TABLINE) ! // Older MSVC compilers don't have LPNMTTDISPINFO[AW] thus we need to define ! // it here if LPNMTTDISPINFO isn't defined. ! // MingW doesn't define LPNMTTDISPINFO but typedefs it. Thus we need to check ! // _MSC_VER. # if !defined(LPNMTTDISPINFO) && defined(_MSC_VER) typedef struct tagNMTTDISPINFOA { NMHDR hdr; *************** *** 4051,4057 **** # define TTN_GETDISPINFOW (TTN_FIRST - 10) #endif ! /* Local variables: */ #ifdef FEAT_MENU static UINT s_menu_id = 100; --- 4054,4060 ---- # define TTN_GETDISPINFOW (TTN_FIRST - 10) #endif ! // Local variables: #ifdef FEAT_MENU static UINT s_menu_id = 100; *************** *** 4066,4074 **** #define VIM_NAME "vim" #define VIM_CLASSW L"Vim" ! /* Initial size for the dialog template. For gui_mch_dialog() it's fixed, ! * thus there should be room for every dialog. For tearoffs it's made bigger ! * when needed. */ #define DLG_ALLOC_SIZE 16 * 1024 /* --- 4069,4077 ---- #define VIM_NAME "vim" #define VIM_CLASSW L"Vim" ! // Initial size for the dialog template. For gui_mch_dialog() it's fixed, ! // thus there should be room for every dialog. For tearoffs it's made bigger ! // when needed. #define DLG_ALLOC_SIZE 16 * 1024 /* *************** *** 4094,4103 **** static int dialog_default_button = -1; ! /* Intellimouse support */ static int mouse_scroll_lines = 0; ! static int s_usenewlook; /* emulate W95/NT4 non-bold dialogs */ #ifdef FEAT_TOOLBAR static void initialise_toolbar(void); static LRESULT CALLBACK toolbar_wndproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); --- 4097,4106 ---- static int dialog_default_button = -1; ! // Intellimouse support static int mouse_scroll_lines = 0; ! static int s_usenewlook; // emulate W95/NT4 non-bold dialogs #ifdef FEAT_TOOLBAR static void initialise_toolbar(void); static LRESULT CALLBACK toolbar_wndproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); *************** *** 4158,4164 **** */ static int gui_mswin_get_menu_height( ! int fix_window) /* If TRUE, resize window if menu height changed */ { static int old_menu_height = -1; --- 4161,4167 ---- */ static int gui_mswin_get_menu_height( ! int fix_window) // If TRUE, resize window if menu height changed { static int old_menu_height = -1; *************** *** 4175,4184 **** menu_height = 0; else if (IsMinimized(s_hwnd)) { ! /* The height of the menu cannot be determined while the window is ! * minimized. Take the previous height if the menu is changed in that ! * state, to avoid that Vim's vertical window size accidentally ! * increases due to the unaccounted-for menu height. */ menu_height = old_menu_height == -1 ? 0 : old_menu_height; } else --- 4178,4187 ---- menu_height = 0; else if (IsMinimized(s_hwnd)) { ! // The height of the menu cannot be determined while the window is ! // minimized. Take the previous height if the menu is changed in that ! // state, to avoid that Vim's vertical window size accidentally ! // increases due to the unaccounted-for menu height. menu_height = old_menu_height == -1 ? 0 : old_menu_height; } else *************** *** 4206,4212 **** return menu_height; } ! #endif /*FEAT_MENU*/ /* --- 4209,4215 ---- return menu_height; } ! #endif // FEAT_MENU /* *************** *** 4223,4236 **** # define SPI_SETWHEELSCROLLLINES 105 #endif ! #define VMOUSEZ_CLASSNAME "MouseZ" /* hidden wheel window class */ ! #define VMOUSEZ_TITLE "Magellan MSWHEEL" /* hidden wheel window title */ #define VMSH_MOUSEWHEEL "MSWHEEL_ROLLMSG" #define VMSH_SCROLL_LINES "MSH_SCROLL_LINES_MSG" ! mouse_scroll_lines = 3; /* reasonable default */ ! /* if NT 4.0+ (or Win98) get scroll lines directly from system */ SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &mouse_scroll_lines, 0); } --- 4226,4239 ---- # define SPI_SETWHEELSCROLLLINES 105 #endif ! #define VMOUSEZ_CLASSNAME "MouseZ" // hidden wheel window class ! #define VMOUSEZ_TITLE "Magellan MSWHEEL" // hidden wheel window title #define VMSH_MOUSEWHEEL "MSWHEEL_ROLLMSG" #define VMSH_SCROLL_LINES "MSH_SCROLL_LINES_MSG" ! mouse_scroll_lines = 3; // reasonable default ! // if NT 4.0+ (or Win98) get scroll lines directly from system SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &mouse_scroll_lines, 0); } *************** *** 4399,4405 **** cy = lpwpos->cy; netbeans_frame_moved(x, y); } ! /* Allow to send WM_SIZE and WM_MOVE */ FORWARD_WM_WINDOWPOSCHANGED(hwnd, lpwpos, MyWindowProc); } #endif --- 4402,4408 ---- cy = lpwpos->cy; netbeans_frame_moved(x, y); } ! // Allow to send WM_SIZE and WM_MOVE FORWARD_WM_WINDOWPOSCHANGED(hwnd, lpwpos, MyWindowProc); } #endif *************** *** 4459,4467 **** { HANDLE_MSG(hwnd, WM_DEADCHAR, _OnDeadChar); HANDLE_MSG(hwnd, WM_SYSDEADCHAR, _OnDeadChar); ! /* HANDLE_MSG(hwnd, WM_ACTIVATE, _OnActivate); */ HANDLE_MSG(hwnd, WM_CLOSE, _OnClose); ! /* HANDLE_MSG(hwnd, WM_COMMAND, _OnCommand); */ HANDLE_MSG(hwnd, WM_DESTROY, _OnDestroy); HANDLE_MSG(hwnd, WM_DROPFILES, _OnDropFiles); HANDLE_MSG(hwnd, WM_HSCROLL, _OnScroll); --- 4462,4470 ---- { HANDLE_MSG(hwnd, WM_DEADCHAR, _OnDeadChar); HANDLE_MSG(hwnd, WM_SYSDEADCHAR, _OnDeadChar); ! // HANDLE_MSG(hwnd, WM_ACTIVATE, _OnActivate); HANDLE_MSG(hwnd, WM_CLOSE, _OnClose); ! // HANDLE_MSG(hwnd, WM_COMMAND, _OnCommand); HANDLE_MSG(hwnd, WM_DESTROY, _OnDestroy); HANDLE_MSG(hwnd, WM_DROPFILES, _OnDropFiles); HANDLE_MSG(hwnd, WM_HSCROLL, _OnScroll); *************** *** 4469,4480 **** #ifdef FEAT_MENU HANDLE_MSG(hwnd, WM_COMMAND, _OnMenu); #endif ! /* HANDLE_MSG(hwnd, WM_MOVE, _OnMove); */ ! /* HANDLE_MSG(hwnd, WM_NCACTIVATE, _OnNCActivate); */ HANDLE_MSG(hwnd, WM_SETFOCUS, _OnSetFocus); HANDLE_MSG(hwnd, WM_SIZE, _OnSize); ! /* HANDLE_MSG(hwnd, WM_SYSCOMMAND, _OnSysCommand); */ ! /* HANDLE_MSG(hwnd, WM_SYSKEYDOWN, _OnAltKey); */ HANDLE_MSG(hwnd, WM_VSCROLL, _OnScroll); // HANDLE_MSG(hwnd, WM_WINDOWPOSCHANGING, _OnWindowPosChanging); HANDLE_MSG(hwnd, WM_ACTIVATEAPP, _OnActivateApp); --- 4472,4483 ---- #ifdef FEAT_MENU HANDLE_MSG(hwnd, WM_COMMAND, _OnMenu); #endif ! // HANDLE_MSG(hwnd, WM_MOVE, _OnMove); ! // HANDLE_MSG(hwnd, WM_NCACTIVATE, _OnNCActivate); HANDLE_MSG(hwnd, WM_SETFOCUS, _OnSetFocus); HANDLE_MSG(hwnd, WM_SIZE, _OnSize); ! // HANDLE_MSG(hwnd, WM_SYSCOMMAND, _OnSysCommand); ! // HANDLE_MSG(hwnd, WM_SYSKEYDOWN, _OnAltKey); HANDLE_MSG(hwnd, WM_VSCROLL, _OnScroll); // HANDLE_MSG(hwnd, WM_WINDOWPOSCHANGING, _OnWindowPosChanging); HANDLE_MSG(hwnd, WM_ACTIVATEAPP, _OnActivateApp); *************** *** 4522,4533 **** } #endif ! case WM_QUERYENDSESSION: /* System wants to go down. */ ! gui_shell_closed(); /* Will exit when no changed buffers. */ ! return FALSE; /* Do NOT allow system to go down. */ case WM_ENDSESSION: ! if (wParam) /* system only really goes down when wParam is TRUE */ { _OnEndSession(); return 0L; --- 4525,4536 ---- } #endif ! case WM_QUERYENDSESSION: // System wants to go down. ! gui_shell_closed(); // Will exit when no changed buffers. ! return FALSE; // Do NOT allow system to go down. case WM_ENDSESSION: ! if (wParam) // system only really goes down when wParam is TRUE { _OnEndSession(); return 0L; *************** *** 4535,4542 **** break; case WM_CHAR: ! /* Don't use HANDLE_MSG() for WM_CHAR, it truncates wParam to a single ! * byte while we want the UTF-16 character value. */ _OnChar(hwnd, (UINT)wParam, (int)(short)LOWORD(lParam)); return 0L; --- 4538,4545 ---- break; case WM_CHAR: ! // Don't use HANDLE_MSG() for WM_CHAR, it truncates wParam to a single ! // byte while we want the UTF-16 character value. _OnChar(hwnd, (UINT)wParam, (int)(short)LOWORD(lParam)); return 0L; *************** *** 4563,4585 **** case WM_SYSKEYUP: #ifdef FEAT_MENU ! /* This used to be done only when menu is active: ALT key is used for ! * that. But that caused problems when menu is disabled and using ! * Alt-Tab-Esc: get into a strange state where no mouse-moved events ! * are received, mouse pointer remains hidden. */ return MyWindowProc(hwnd, uMsg, wParam, lParam); #else return 0L; #endif ! case WM_SIZING: /* HANDLE_MSG doesn't seem to handle this one */ return _DuringSizing((UINT)wParam, (LPRECT)lParam); case WM_MOUSEWHEEL: _OnMouseWheel(hwnd, HIWORD(wParam)); return 0L; ! /* Notification for change in SystemParametersInfo() */ case WM_SETTINGCHANGE: return _OnSettingChange((UINT)wParam); --- 4566,4588 ---- case WM_SYSKEYUP: #ifdef FEAT_MENU ! // This used to be done only when menu is active: ALT key is used for ! // that. But that caused problems when menu is disabled and using ! // Alt-Tab-Esc: get into a strange state where no mouse-moved events ! // are received, mouse pointer remains hidden. return MyWindowProc(hwnd, uMsg, wParam, lParam); #else return 0L; #endif ! case WM_SIZING: // HANDLE_MSG doesn't seem to handle this one return _DuringSizing((UINT)wParam, (LPRECT)lParam); case WM_MOUSEWHEEL: _OnMouseWheel(hwnd, HIWORD(wParam)); return 0L; ! // Notification for change in SystemParametersInfo() case WM_SETTINGCHANGE: return _OnSettingChange((UINT)wParam); *************** *** 4653,4673 **** { LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam; ! /* Set the maximum width, this also enables using ! * \n for line break. */ SendMessage(lpdi->hdr.hwndFrom, TTM_SETMAXTIPWIDTH, 0, 500); tt_text = enc_to_utf16(str, NULL); lpdi->lpszText = tt_text; ! /* can't show tooltip if failed */ } else { LPNMTTDISPINFO lpdi = (LPNMTTDISPINFO)lParam; ! /* Set the maximum width, this also enables using ! * \n for line break. */ SendMessage(lpdi->hdr.hwndFrom, TTM_SETMAXTIPWIDTH, 0, 500); --- 4656,4676 ---- { LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam; ! // Set the maximum width, this also enables using ! // \n for line break. SendMessage(lpdi->hdr.hwndFrom, TTM_SETMAXTIPWIDTH, 0, 500); tt_text = enc_to_utf16(str, NULL); lpdi->lpszText = tt_text; ! // can't show tooltip if failed } else { LPNMTTDISPINFO lpdi = (LPNMTTDISPINFO)lParam; ! // Set the maximum width, this also enables using ! // \n for line break. SendMessage(lpdi->hdr.hwndFrom, TTM_SETMAXTIPWIDTH, 0, 500); *************** *** 4760,4767 **** int yPos = GET_Y_LPARAM(lParam); RECT rct; ! /* If the cursor is on the GUI tabline, don't process this ! * event */ GetWindowRect(s_textArea, &rct); if (yPos < rct.top) return result; --- 4763,4770 ---- int yPos = GET_Y_LPARAM(lParam); RECT rct; ! // If the cursor is on the GUI tabline, don't process this ! // event GetWindowRect(s_textArea, &rct); if (yPos < rct.top) return result; *************** *** 4770,4776 **** (void)gui_mch_get_winpos(&x, &y); xPos -= x; ! if (xPos < 48) /* TODO should use system metric? */ return HTBOTTOMLEFT; else return HTBOTTOMRIGHT; --- 4773,4779 ---- (void)gui_mch_get_winpos(&x, &y); xPos -= x; ! if (xPos < 48) // TODO should use system metric? return HTBOTTOMLEFT; else return HTBOTTOMRIGHT; *************** *** 4778,4784 **** else return result; } ! /* break; notreached */ #ifdef FEAT_MBYTE_IME case WM_IME_NOTIFY: --- 4781,4787 ---- else return result; } ! // break; notreached #ifdef FEAT_MBYTE_IME case WM_IME_NOTIFY: *************** *** 4807,4813 **** * End of call-back routines */ ! /* parent window, if specified with -P */ HWND vim_parent_hwnd = NULL; static BOOL CALLBACK --- 4810,4816 ---- * End of call-back routines */ ! // parent window, if specified with -P HWND vim_parent_hwnd = NULL; static BOOL CALLBACK *************** *** 4820,4833 **** { if (strstr(buf, title) != NULL) { ! /* Found it. Store the window ref. and quit searching if MDI ! * works. */ vim_parent_hwnd = FindWindowEx(hwnd, NULL, "MDIClient", NULL); if (vim_parent_hwnd != NULL) return FALSE; } } ! return TRUE; /* continue searching */ } /* --- 4823,4836 ---- { if (strstr(buf, title) != NULL) { ! // Found it. Store the window ref. and quit searching if MDI ! // works. vim_parent_hwnd = FindWindowEx(hwnd, NULL, "MDIClient", NULL); if (vim_parent_hwnd != NULL) return FALSE; } } ! return TRUE; // continue searching } /* *************** *** 4855,4861 **** gui.in_use = mch_is_gui_executable(); # endif ! /* Can't use emsg() here, we have not finished initialisation yet. */ vim_snprintf(buf, IOSIZE, _("E243: Argument not supported: \"-%s\"; Use the OLE version."), arg); --- 4858,4864 ---- gui.in_use = mch_is_gui_executable(); # endif ! // Can't use emsg() here, we have not finished initialisation yet. vim_snprintf(buf, IOSIZE, _("E243: Argument not supported: \"-%s\"; Use the OLE version."), arg); *************** *** 5009,5018 **** int silent = FALSE; int idx; ! /* Check for special OLE command line parameters */ if ((*argc == 2 || *argc == 3) && (argv[1][0] == '-' || argv[1][0] == '/')) { ! /* Check for a "-silent" argument first. */ if (*argc == 3 && STRICMP(argv[1] + 1, "silent") == 0 && (argv[2][0] == '-' || argv[2][0] == '/')) { --- 5012,5021 ---- int silent = FALSE; int idx; ! // Check for special OLE command line parameters if ((*argc == 2 || *argc == 3) && (argv[1][0] == '-' || argv[1][0] == '/')) { ! // Check for a "-silent" argument first. if (*argc == 3 && STRICMP(argv[1] + 1, "silent") == 0 && (argv[2][0] == '-' || argv[2][0] == '/')) { *************** *** 5022,5028 **** else idx = 1; ! /* Register Vim as an OLE Automation server */ if (STRICMP(argv[idx] + 1, "register") == 0) { #ifdef FEAT_OLE --- 5025,5031 ---- else idx = 1; ! // Register Vim as an OLE Automation server if (STRICMP(argv[idx] + 1, "register") == 0) { #ifdef FEAT_OLE *************** *** 5035,5041 **** #endif } ! /* Unregister Vim as an OLE Automation server */ if (STRICMP(argv[idx] + 1, "unregister") == 0) { #ifdef FEAT_OLE --- 5038,5044 ---- #endif } ! // Unregister Vim as an OLE Automation server if (STRICMP(argv[idx] + 1, "unregister") == 0) { #ifdef FEAT_OLE *************** *** 5048,5058 **** #endif } ! /* Ignore an -embedding argument. It is only relevant if the ! * application wants to treat the case when it is started manually ! * differently from the case where it is started via automation (and ! * we don't). ! */ if (STRICMP(argv[idx] + 1, "embedding") == 0) { #ifdef FEAT_OLE --- 5051,5060 ---- #endif } ! // Ignore an -embedding argument. It is only relevant if the ! // application wants to treat the case when it is started manually ! // differently from the case where it is started via automation (and ! // we don't). if (STRICMP(argv[idx] + 1, "embedding") == 0) { #ifdef FEAT_OLE *************** *** 5069,5075 **** int bDoRestart = FALSE; InitOLE(&bDoRestart); ! /* automatically exit after registering */ if (bDoRestart) mch_exit(0); } --- 5071,5077 ---- int bDoRestart = FALSE; InitOLE(&bDoRestart); ! // automatically exit after registering if (bDoRestart) mch_exit(0); } *************** *** 5077,5083 **** #ifdef FEAT_NETBEANS_INTG { ! /* stolen from gui_x11.c */ int arg; for (arg = 1; arg < *argc; arg++) --- 5079,5085 ---- #ifdef FEAT_NETBEANS_INTG { ! // stolen from gui_x11.c int arg; for (arg = 1; arg < *argc; arg++) *************** *** 5087,5093 **** mch_memmove(&argv[arg], &argv[arg + 1], (--*argc - arg) * sizeof(char *)); argv[*argc] = NULL; ! break; /* enough? */ } } #endif --- 5089,5095 ---- mch_memmove(&argv[arg], &argv[arg + 1], (--*argc - arg) * sizeof(char *)); argv[*argc] = NULL; ! break; // enough? } } #endif *************** *** 5107,5114 **** ATOM atom; #endif ! /* Return here if the window was already opened (happens when ! * gui_mch_dialog() is called early). */ if (s_hwnd != NULL) goto theend; --- 5109,5116 ---- ATOM atom; #endif ! // Return here if the window was already opened (happens when ! // gui_mch_dialog() is called early). if (s_hwnd != NULL) goto theend; *************** *** 5122,5135 **** gui.scrollbar_width = GetSystemMetrics(SM_CXVSCROLL); gui.scrollbar_height = GetSystemMetrics(SM_CYHSCROLL); #ifdef FEAT_MENU ! gui.menu_height = 0; /* Windows takes care of this */ #endif gui.border_width = 0; s_brush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE)); ! /* First try using the wide version, so that we can use any title. ! * Otherwise only characters in the active codepage will work. */ if (GetClassInfoW(g_hinst, szVimWndClassW, &wndclassw) == 0) { wndclassw.style = CS_DBLCLKS; --- 5124,5137 ---- gui.scrollbar_width = GetSystemMetrics(SM_CXVSCROLL); gui.scrollbar_height = GetSystemMetrics(SM_CYHSCROLL); #ifdef FEAT_MENU ! gui.menu_height = 0; // Windows takes care of this #endif gui.border_width = 0; s_brush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE)); ! // First try using the wide version, so that we can use any title. ! // Otherwise only characters in the active codepage will work. if (GetClassInfoW(g_hinst, szVimWndClassW, &wndclassw) == 0) { wndclassw.style = CS_DBLCLKS; *************** *** 5175,5181 **** } __except(EXCEPTION_EXECUTE_HANDLER) { ! /* NOP */ } #endif if (s_hwnd == NULL) --- 5177,5183 ---- } __except(EXCEPTION_EXECUTE_HANDLER) { ! // NOP } #endif if (s_hwnd == NULL) *************** *** 5186,5206 **** } else { ! /* If the provided windowid is not valid reset it to zero, so that it ! * is ignored and we open our own window. */ if (IsWindow((HWND)win_socket_id) <= 0) win_socket_id = 0; ! /* Create a window. If win_socket_id is not zero without border and ! * titlebar, it will be reparented below. */ s_hwnd = CreateWindowW( szVimWndClassW, L"Vim MSWindows GUI", (win_socket_id == 0 ? WS_OVERLAPPEDWINDOW : WS_POPUP) | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, gui_win_x == -1 ? CW_USEDEFAULT : gui_win_x, gui_win_y == -1 ? CW_USEDEFAULT : gui_win_y, ! 100, /* Any value will do */ ! 100, /* Any value will do */ NULL, NULL, g_hinst, NULL); if (s_hwnd != NULL && win_socket_id != 0) --- 5188,5208 ---- } else { ! // If the provided windowid is not valid reset it to zero, so that it ! // is ignored and we open our own window. if (IsWindow((HWND)win_socket_id) <= 0) win_socket_id = 0; ! // Create a window. If win_socket_id is not zero without border and ! // titlebar, it will be reparented below. s_hwnd = CreateWindowW( szVimWndClassW, L"Vim MSWindows GUI", (win_socket_id == 0 ? WS_OVERLAPPEDWINDOW : WS_POPUP) | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, gui_win_x == -1 ? CW_USEDEFAULT : gui_win_x, gui_win_y == -1 ? CW_USEDEFAULT : gui_win_y, ! 100, // Any value will do ! 100, // Any value will do NULL, NULL, g_hinst, NULL); if (s_hwnd != NULL && win_socket_id != 0) *************** *** 5220,5226 **** dyn_imm_load(); #endif ! /* Create the text area window */ if (GetClassInfoW(g_hinst, szTextAreaClassW, &wndclassw) == 0) { wndclassw.style = CS_OWNDC; --- 5222,5228 ---- dyn_imm_load(); #endif ! // Create the text area window if (GetClassInfoW(g_hinst, szTextAreaClassW, &wndclassw) == 0) { wndclassw.style = CS_OWNDC; *************** *** 5251,5257 **** return FAIL; #ifdef FEAT_LIBCALL ! /* Try loading an icon from $RUNTIMEPATH/bitmaps/vim.ico. */ { HANDLE hIcon = NULL; --- 5253,5259 ---- return FAIL; #ifdef FEAT_LIBCALL ! // Try loading an icon from $RUNTIMEPATH/bitmaps/vim.ico. { HANDLE hIcon = NULL; *************** *** 5267,5280 **** DragAcceptFiles(s_hwnd, TRUE); ! /* Do we need to bother with this? */ ! /* m_fMouseAvail = GetSystemMetrics(SM_MOUSEPRESENT); */ ! /* Get background/foreground colors from the system */ gui_mch_def_colors(); ! /* Get the colors from the "Normal" group (set in syntax.c or in a vimrc ! * file) */ set_normal_colors(); /* --- 5269,5282 ---- DragAcceptFiles(s_hwnd, TRUE); ! // Do we need to bother with this? ! // m_fMouseAvail = GetSystemMetrics(SM_MOUSEPRESENT); ! // Get background/foreground colors from the system gui_mch_def_colors(); ! // Get the colors from the "Normal" group (set in syntax.c or in a vimrc ! // file) set_normal_colors(); /* *************** *** 5285,5292 **** gui.def_norm_pixel = gui.norm_pixel; gui.def_back_pixel = gui.back_pixel; ! /* Get the colors for the highlight groups (gui_check_colors() might have ! * changed them) */ highlight_gui_started(); /* --- 5287,5294 ---- gui.def_norm_pixel = gui.norm_pixel; gui.def_back_pixel = gui.back_pixel; ! // Get the colors for the highlight groups (gui_check_colors() might have ! // changed them) highlight_gui_started(); /* *************** *** 5321,5327 **** */ s_findrep_msg = RegisterWindowMessage(FINDMSGSTRING); ! /* Initialise the struct */ s_findrep_struct.lStructSize = sizeof(s_findrep_struct); s_findrep_struct.lpstrFindWhat = ALLOC_MULT(WCHAR, MSWIN_FR_BUFSIZE); s_findrep_struct.lpstrFindWhat[0] = NUL; --- 5323,5329 ---- */ s_findrep_msg = RegisterWindowMessage(FINDMSGSTRING); ! // Initialise the struct s_findrep_struct.lStructSize = sizeof(s_findrep_struct); s_findrep_struct.lpstrFindWhat = ALLOC_MULT(WCHAR, MSWIN_FR_BUFSIZE); s_findrep_struct.lpstrFindWhat[0] = NUL; *************** *** 5333,5344 **** #ifdef FEAT_EVAL # if !defined(_MSC_VER) || (_MSC_VER < 1400) ! /* Define HandleToLong for old MS and non-MS compilers if not defined. */ # ifndef HandleToLong # define HandleToLong(h) ((long)(intptr_t)(h)) # endif # endif ! /* set the v:windowid variable */ set_vim_var_nr(VV_WINDOWID, HandleToLong(s_hwnd)); #endif --- 5335,5346 ---- #ifdef FEAT_EVAL # if !defined(_MSC_VER) || (_MSC_VER < 1400) ! // Define HandleToLong for old MS and non-MS compilers if not defined. # ifndef HandleToLong # define HandleToLong(h) ((long)(intptr_t)(h)) # endif # endif ! // set the v:windowid variable set_vim_var_nr(VV_WINDOWID, HandleToLong(s_hwnd)); #endif *************** *** 5348,5354 **** #endif theend: ! /* Display any pending error messages */ display_errors(); return OK; --- 5350,5356 ---- #endif theend: ! // Display any pending error messages display_errors(); return OK; *************** *** 5364,5370 **** HMONITOR mon; MONITORINFO moninfo; ! /* work out which monitor the window is on, and get *its* work area */ mon = MonitorFromWindow(s_hwnd, MONITOR_DEFAULTTOPRIMARY); if (mon != NULL) { --- 5366,5372 ---- HMONITOR mon; MONITORINFO moninfo; ! // work out which monitor the window is on, and get *its* work area mon = MonitorFromWindow(s_hwnd, MONITOR_DEFAULTTOPRIMARY); if (mon != NULL) { *************** *** 5375,5381 **** return; } } ! /* this is the old method... */ SystemParametersInfo(SPI_GETWORKAREA, 0, spi_rect, 0); } --- 5377,5383 ---- return; } } ! // this is the old method... SystemParametersInfo(SPI_GETWORKAREA, 0, spi_rect, 0); } *************** *** 5396,5422 **** int win_width, win_height; WINDOWPLACEMENT wndpl; ! /* Try to keep window completely on screen. */ ! /* Get position of the screen work area. This is the part that is not ! * used by the taskbar or appbars. */ get_work_area(&workarea_rect); ! /* Get current position of our window. Note that the .left and .top are ! * relative to the work area. */ wndpl.length = sizeof(WINDOWPLACEMENT); GetWindowPlacement(s_hwnd, &wndpl); ! /* Resizing a maximized window looks very strange, unzoom it first. ! * But don't do it when still starting up, it may have been requested in ! * the shortcut. */ if (wndpl.showCmd == SW_SHOWMAXIMIZED && starting == 0) { ShowWindow(s_hwnd, SW_SHOWNORMAL); ! /* Need to get the settings of the normal window. */ GetWindowPlacement(s_hwnd, &wndpl); } ! /* compute the size of the outside of the window */ win_width = width + (GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXPADDEDBORDER)) * 2; win_height = height + (GetSystemMetrics(SM_CYFRAME) + --- 5398,5424 ---- int win_width, win_height; WINDOWPLACEMENT wndpl; ! // Try to keep window completely on screen. ! // Get position of the screen work area. This is the part that is not ! // used by the taskbar or appbars. get_work_area(&workarea_rect); ! // Get current position of our window. Note that the .left and .top are ! // relative to the work area. wndpl.length = sizeof(WINDOWPLACEMENT); GetWindowPlacement(s_hwnd, &wndpl); ! // Resizing a maximized window looks very strange, unzoom it first. ! // But don't do it when still starting up, it may have been requested in ! // the shortcut. if (wndpl.showCmd == SW_SHOWMAXIMIZED && starting == 0) { ShowWindow(s_hwnd, SW_SHOWNORMAL); ! // Need to get the settings of the normal window. GetWindowPlacement(s_hwnd, &wndpl); } ! // compute the size of the outside of the window win_width = width + (GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXPADDEDBORDER)) * 2; win_height = height + (GetSystemMetrics(SM_CYFRAME) + *************** *** 5427,5439 **** #endif ; ! /* The following should take care of keeping Vim on the same monitor, no ! * matter if the secondary monitor is left or right of the primary ! * monitor. */ wndpl.rcNormalPosition.right = wndpl.rcNormalPosition.left + win_width; wndpl.rcNormalPosition.bottom = wndpl.rcNormalPosition.top + win_height; ! /* If the window is going off the screen, move it on to the screen. */ if ((direction & RESIZE_HOR) && wndpl.rcNormalPosition.right > workarea_rect.right) OffsetRect(&wndpl.rcNormalPosition, --- 5429,5441 ---- #endif ; ! // The following should take care of keeping Vim on the same monitor, no ! // matter if the secondary monitor is left or right of the primary ! // monitor. wndpl.rcNormalPosition.right = wndpl.rcNormalPosition.left + win_width; wndpl.rcNormalPosition.bottom = wndpl.rcNormalPosition.top + win_height; ! // If the window is going off the screen, move it on to the screen. if ((direction & RESIZE_HOR) && wndpl.rcNormalPosition.right > workarea_rect.right) OffsetRect(&wndpl.rcNormalPosition, *************** *** 5454,5469 **** OffsetRect(&wndpl.rcNormalPosition, 0, workarea_rect.top - wndpl.rcNormalPosition.top); ! /* set window position - we should use SetWindowPlacement rather than ! * SetWindowPos as the MSDN docs say the coord systems returned by ! * these two are not compatible. */ SetWindowPlacement(s_hwnd, &wndpl); SetActiveWindow(s_hwnd); SetFocus(s_hwnd); #ifdef FEAT_MENU ! /* Menu may wrap differently now */ gui_mswin_get_menu_height(!gui.starting); #endif } --- 5456,5471 ---- OffsetRect(&wndpl.rcNormalPosition, 0, workarea_rect.top - wndpl.rcNormalPosition.top); ! // set window position - we should use SetWindowPlacement rather than ! // SetWindowPos as the MSDN docs say the coord systems returned by ! // these two are not compatible. SetWindowPlacement(s_hwnd, &wndpl); SetActiveWindow(s_hwnd); SetFocus(s_hwnd); #ifdef FEAT_MENU ! // Menu may wrap differently now gui_mswin_get_menu_height(!gui.starting); #endif } *************** *** 5543,5549 **** * First static functions (no prototypes generated). */ # ifdef _MSC_VER ! # include /* Apparently not needed for Cygwin or MinGW. */ # endif # include --- 5545,5551 ---- * First static functions (no prototypes generated). */ # ifdef _MSC_VER ! # include // Apparently not needed for Cygwin or MinGW. # endif # include *************** *** 5566,5580 **** pImmSetCompositionFontW(hImc, &norm_logfont); im_set_position(gui.row, gui.col); ! /* Disable langmap */ State &= ~LANGMAP; if (State & INSERT) { # if defined(FEAT_KEYMAP) ! /* Unshown 'keymap' in status lines */ if (curbuf->b_p_iminsert == B_IMODE_LMAP) { ! /* Save cursor position */ int old_row = gui.row; int old_col = gui.col; --- 5568,5582 ---- pImmSetCompositionFontW(hImc, &norm_logfont); im_set_position(gui.row, gui.col); ! // Disable langmap State &= ~LANGMAP; if (State & INSERT) { # if defined(FEAT_KEYMAP) ! // Unshown 'keymap' in status lines if (curbuf->b_p_iminsert == B_IMODE_LMAP) { ! // Save cursor position int old_row = gui.row; int old_col = gui.col; *************** *** 5584,5590 **** showmode(); status_redraw_curbuf(); update_screen(0); ! /* Restore cursor position */ gui.row = old_row; gui.col = old_col; } --- 5586,5592 ---- showmode(); status_redraw_curbuf(); update_screen(0); ! // Restore cursor position gui.row = old_row; gui.col = old_col; } *************** *** 5606,5612 **** char_u *ret; int len; ! if ((param & GCS_RESULTSTR) == 0) /* Composition unfinished. */ return 0; ret = GetResultStr(hwnd, GCS_RESULTSTR, &len); --- 5608,5614 ---- char_u *ret; int len; ! if ((param & GCS_RESULTSTR) == 0) // Composition unfinished. return 0; ret = GetResultStr(hwnd, GCS_RESULTSTR, &len); *************** *** 5631,5646 **** char_u *buf; if (!pImmGetContext) ! return NULL; /* no imm32.dll */ ! /* Try Unicode; this'll always work on NT regardless of codepage. */ ret = pImmGetCompositionStringW(hIMC, GCS, NULL, 0); if (ret == 0) ! return NULL; /* empty */ if (ret > 0) { ! /* Allocate the requested buffer plus space for the NUL character. */ wbuf = alloc(ret + sizeof(WCHAR)); if (wbuf != NULL) { --- 5633,5648 ---- char_u *buf; if (!pImmGetContext) ! return NULL; // no imm32.dll ! // Try Unicode; this'll always work on NT regardless of codepage. ret = pImmGetCompositionStringW(hIMC, GCS, NULL, 0); if (ret == 0) ! return NULL; // empty if (ret > 0) { ! // Allocate the requested buffer plus space for the NUL character. wbuf = alloc(ret + sizeof(WCHAR)); if (wbuf != NULL) { *************** *** 5650,5668 **** return (short_u *)wbuf; } ! /* ret < 0; we got an error, so try the ANSI version. This'll work ! * on 9x/ME, but only if the codepage happens to be set to whatever ! * we're inputting. */ ret = pImmGetCompositionStringA(hIMC, GCS, NULL, 0); if (ret <= 0) ! return NULL; /* empty or error */ buf = alloc(ret); if (buf == NULL) return NULL; pImmGetCompositionStringA(hIMC, GCS, buf, ret); ! /* convert from codepage to UCS-2 */ MultiByteToWideChar_alloc(GetACP(), 0, (LPCSTR)buf, ret, &wbuf, lenp); vim_free(buf); --- 5652,5670 ---- return (short_u *)wbuf; } ! // ret < 0; we got an error, so try the ANSI version. This'll work ! // on 9x/ME, but only if the codepage happens to be set to whatever ! // we're inputting. ret = pImmGetCompositionStringA(hIMC, GCS, NULL, 0); if (ret <= 0) ! return NULL; // empty or error buf = alloc(ret); if (buf == NULL) return NULL; pImmGetCompositionStringA(hIMC, GCS, buf, ret); ! // convert from codepage to UCS-2 MultiByteToWideChar_alloc(GetACP(), 0, (LPCSTR)buf, ret, &wbuf, lenp); vim_free(buf); *************** *** 5678,5691 **** static char_u * GetResultStr(HWND hwnd, int GCS, int *lenp) { ! HIMC hIMC; /* Input context handle. */ short_u *buf = NULL; char_u *convbuf = NULL; if (!pImmGetContext || (hIMC = pImmGetContext(hwnd)) == (HIMC)0) return NULL; ! /* Reads in the composition string. */ buf = GetCompositionString_inUCS2(hIMC, GCS, lenp); if (buf == NULL) return NULL; --- 5680,5693 ---- static char_u * GetResultStr(HWND hwnd, int GCS, int *lenp) { ! HIMC hIMC; // Input context handle. short_u *buf = NULL; char_u *convbuf = NULL; if (!pImmGetContext || (hIMC = pImmGetContext(hwnd)) == (HIMC)0) return NULL; ! // Reads in the composition string. buf = GetCompositionString_inUCS2(hIMC, GCS, lenp); if (buf == NULL) return NULL; *************** *** 5697,5703 **** } #endif ! /* For global functions we need prototypes. */ #if defined(FEAT_MBYTE_IME) || defined(PROTO) /* --- 5699,5705 ---- } #endif ! // For global functions we need prototypes. #if defined(FEAT_MBYTE_IME) || defined(PROTO) /* *************** *** 5754,5760 **** } # endif ! if (pImmGetContext) /* if NULL imm32.dll wasn't loaded (yet) */ { if (p_imdisable) { --- 5756,5762 ---- } # endif ! if (pImmGetContext) // if NULL imm32.dll wasn't loaded (yet) { if (p_imdisable) { *************** *** 5787,5793 **** if (active) { ! /* if we have a saved conversion status, restore it */ if (bSaved) pImmSetConversionStatus(hImc, dwConversionSaved, dwSentenceSaved); --- 5789,5795 ---- if (active) { ! // if we have a saved conversion status, restore it if (bSaved) pImmSetConversionStatus(hImc, dwConversionSaved, dwSentenceSaved); *************** *** 5795,5801 **** } else { ! /* save conversion status and disable korean */ if (pImmGetConversionStatus(hImc, &dwConversionSaved, &dwSentenceSaved)) { --- 5797,5803 ---- } else { ! // save conversion status and disable korean if (pImmGetConversionStatus(hImc, &dwConversionSaved, &dwSentenceSaved)) { *************** *** 5836,5845 **** return status; } ! #endif /* FEAT_MBYTE_IME */ #if !defined(FEAT_MBYTE_IME) && defined(GLOBAL_IME) ! /* Win32 with GLOBAL IME */ /* * Notify cursor position to IM. --- 5838,5847 ---- return status; } ! #endif // FEAT_MBYTE_IME #if !defined(FEAT_MBYTE_IME) && defined(GLOBAL_IME) ! // Win32 with GLOBAL IME /* * Notify cursor position to IM. *************** *** 5847,5853 **** void im_set_position(int row, int col) { ! /* Win32 with GLOBAL IME */ POINT p; p.x = FILL_X(col); --- 5849,5855 ---- void im_set_position(int row, int col) { ! // Win32 with GLOBAL IME POINT p; p.x = FILL_X(col); *************** *** 5888,5901 **** c = *text++; switch (c) { ! case 0xa4: c = 0x20ac; break; /* euro */ ! case 0xa6: c = 0x0160; break; /* S hat */ ! case 0xa8: c = 0x0161; break; /* S -hat */ ! case 0xb4: c = 0x017d; break; /* Z hat */ ! case 0xb8: c = 0x017e; break; /* Z -hat */ ! case 0xbc: c = 0x0152; break; /* OE */ ! case 0xbd: c = 0x0153; break; /* oe */ ! case 0xbe: c = 0x0178; break; /* Y */ } *unicodebuf++ = c; } --- 5890,5903 ---- c = *text++; switch (c) { ! case 0xa4: c = 0x20ac; break; // euro ! case 0xa6: c = 0x0160; break; // S hat ! case 0xa8: c = 0x0161; break; // S -hat ! case 0xb4: c = 0x017d; break; // Z hat ! case 0xb8: c = 0x017e; break; // Z -hat ! case 0xbc: c = 0x0152; break; // OE ! case 0xbd: c = 0x0153; break; // oe ! case 0xbe: c = 0x0178; break; // Y } *unicodebuf++ = c; } *************** *** 5949,5955 **** HPEN hpen = CreatePen(PS_SOLID, 1, color); HPEN old_pen = SelectObject(s_hdc, hpen); MoveToEx(s_hdc, x1, y1, NULL); ! /* Note: LineTo() excludes the last pixel in the line. */ LineTo(s_hdc, x2, y2); DeleteObject(SelectObject(s_hdc, old_pen)); } --- 5951,5957 ---- HPEN hpen = CreatePen(PS_SOLID, 1, color); HPEN old_pen = SelectObject(s_hdc, hpen); MoveToEx(s_hdc, x1, y1, NULL); ! // Note: LineTo() excludes the last pixel in the line. LineTo(s_hdc, x2, y2); DeleteObject(SelectObject(s_hdc, old_pen)); } *************** *** 6041,6055 **** rc.top = FILL_Y(row); if (has_mbyte) { ! /* Compute the length in display cells. */ rc.right = FILL_X(col + mb_string2cells(text, len)); } else rc.right = FILL_X(col + len); rc.bottom = FILL_Y(row + 1); ! /* Cache the created brush, that saves a lot of time. We need two: ! * one for cursor background and one for the normal background. */ if (gui.currBgColor == brush_color[0]) { hbr = hbr_cache[0]; --- 6043,6057 ---- rc.top = FILL_Y(row); if (has_mbyte) { ! // Compute the length in display cells. rc.right = FILL_X(col + mb_string2cells(text, len)); } else rc.right = FILL_X(col + len); rc.bottom = FILL_Y(row + 1); ! // Cache the created brush, that saves a lot of time. We need two: ! // one for cursor background and one for the normal background. if (gui.currBgColor == brush_color[0]) { hbr = hbr_cache[0]; *************** *** 6097,6104 **** vim_free(padding); pad_size = Columns; ! /* Don't give an out-of-memory message here, it would call us ! * recursively. */ padding = LALLOC_MULT(int, pad_size); if (padding != NULL) for (i = 0; i < pad_size; i++) --- 6099,6106 ---- vim_free(padding); pad_size = Columns; ! // Don't give an out-of-memory message here, it would call us ! // recursively. padding = LALLOC_MULT(int, pad_size); if (padding != NULL) for (i = 0; i < pad_size; i++) *************** *** 6112,6135 **** * No check for DRAW_BOLD, Windows will have done it already. */ ! /* Check if there are any UTF-8 characters. If not, use normal text ! * output to speed up output. */ if (enc_utf8) for (n = 0; n < len; ++n) if (text[n] >= 0x80) break; #if defined(FEAT_DIRECTX) ! /* Quick hack to enable DirectWrite. To use DirectWrite (antialias), it is ! * required that unicode drawing routine, currently. So this forces it ! * enabled. */ if (IS_ENABLE_DIRECTX()) ! n = 0; /* Keep n < len, to enter block for unicode. */ #endif ! /* Check if the Unicode buffer exists and is big enough. Create it ! * with the same length as the multi-byte string, the number of wide ! * characters is always equal or smaller. */ if ((enc_utf8 || (enc_codepage > 0 && (int)GetACP() != enc_codepage) || enc_latin9) --- 6114,6137 ---- * No check for DRAW_BOLD, Windows will have done it already. */ ! // Check if there are any UTF-8 characters. If not, use normal text ! // output to speed up output. if (enc_utf8) for (n = 0; n < len; ++n) if (text[n] >= 0x80) break; #if defined(FEAT_DIRECTX) ! // Quick hack to enable DirectWrite. To use DirectWrite (antialias), it is ! // required that unicode drawing routine, currently. So this forces it ! // enabled. if (IS_ENABLE_DIRECTX()) ! n = 0; // Keep n < len, to enter block for unicode. #endif ! // Check if the Unicode buffer exists and is big enough. Create it ! // with the same length as the multi-byte string, the number of wide ! // characters is always equal or smaller. if ((enc_utf8 || (enc_codepage > 0 && (int)GetACP() != enc_codepage) || enc_latin9) *************** *** 6146,6158 **** if (enc_utf8 && n < len && unicodebuf != NULL) { ! /* Output UTF-8 characters. Composing characters should be ! * handled here. */ int i; ! int wlen; /* string length in words */ ! int clen; /* string length in characters */ ! int cells; /* cell width of string up to composing char */ ! int cw; /* width of current cell */ int c; wlen = 0; --- 6148,6160 ---- if (enc_utf8 && n < len && unicodebuf != NULL) { ! // Output UTF-8 characters. Composing characters should be ! // handled here. int i; ! int wlen; // string length in words ! int clen; // string length in characters ! int cells; // cell width of string up to composing char ! int cw; // width of current cell int c; wlen = 0; *************** *** 6163,6169 **** c = utf_ptr2char(text + i); if (c >= 0x10000) { ! /* Turn into UTF-16 encoding. */ unicodebuf[wlen++] = ((c - 0x10000) >> 10) + 0xD800; unicodebuf[wlen++] = ((c - 0x10000) & 0x3ff) + 0xDC00; } --- 6165,6171 ---- c = utf_ptr2char(text + i); if (c >= 0x10000) { ! // Turn into UTF-16 encoding. unicodebuf[wlen++] = ((c - 0x10000) >> 10) + 0xD800; unicodebuf[wlen++] = ((c - 0x10000) & 0x3ff) + 0xDC00; } *************** *** 6177,6191 **** else { cw = utf_char2cells(c); ! if (cw > 2) /* don't use 4 for unprintable char */ cw = 1; } if (unicodepdy != NULL) { ! /* Use unicodepdy to make characters fit as we expect, even ! * when the font uses different widths (e.g., bold character ! * is wider). */ if (c >= 0x10000) { unicodepdy[wlen - 2] = cw * gui.char_width; --- 6179,6193 ---- else { cw = utf_char2cells(c); ! if (cw > 2) // don't use 4 for unprintable char cw = 1; } if (unicodepdy != NULL) { ! // Use unicodepdy to make characters fit as we expect, even ! // when the font uses different widths (e.g., bold character ! // is wider). if (c >= 0x10000) { unicodepdy[wlen - 2] = cw * gui.char_width; *************** *** 6201,6207 **** #if defined(FEAT_DIRECTX) if (IS_ENABLE_DIRECTX()) { ! /* Add one to "cells" for italics. */ DWriteContext_DrawText(s_dwc, unicodebuf, wlen, TEXT_X(col), TEXT_Y(row), FILL_X(cells + 1), FILL_Y(1) - p_linespace, --- 6203,6209 ---- #if defined(FEAT_DIRECTX) if (IS_ENABLE_DIRECTX()) { ! // Add one to "cells" for italics. DWriteContext_DrawText(s_dwc, unicodebuf, wlen, TEXT_X(col), TEXT_Y(row), FILL_X(cells + 1), FILL_Y(1) - p_linespace, *************** *** 6212,6223 **** #endif ExtTextOutW(s_hdc, TEXT_X(col), TEXT_Y(row), foptions, pcliprect, unicodebuf, wlen, unicodepdy); ! len = cells; /* used for underlining */ } else if ((enc_codepage > 0 && (int)GetACP() != enc_codepage) || enc_latin9) { ! /* If we want to display codepage data, and the current CP is not the ! * ANSI one, we need to go via Unicode. */ if (unicodebuf != NULL) { if (enc_latin9) --- 6214,6225 ---- #endif ExtTextOutW(s_hdc, TEXT_X(col), TEXT_Y(row), foptions, pcliprect, unicodebuf, wlen, unicodepdy); ! len = cells; // used for underlining } else if ((enc_codepage > 0 && (int)GetACP() != enc_codepage) || enc_latin9) { ! // If we want to display codepage data, and the current CP is not the ! // ANSI one, we need to go via Unicode. if (unicodebuf != NULL) { if (enc_latin9) *************** *** 6229,6237 **** (LPWSTR)unicodebuf, unibuflen); if (len != 0) { ! /* Use unicodepdy to make characters fit as we expect, even ! * when the font uses different widths (e.g., bold character ! * is wider). */ if (unicodepdy != NULL) { int i; --- 6231,6239 ---- (LPWSTR)unicodebuf, unibuflen); if (len != 0) { ! // Use unicodepdy to make characters fit as we expect, even ! // when the font uses different widths (e.g., bold character ! // is wider). if (unicodepdy != NULL) { int i; *************** *** 6253,6260 **** else { #ifdef FEAT_RIGHTLEFT ! /* Windows will mess up RL text, so we have to draw it character by ! * character. Only do this if RL is on, since it's slow. */ if (curwin->w_p_rl) RevOut(s_hdc, TEXT_X(col), TEXT_Y(row), foptions, pcliprect, (char *)text, len, padding); --- 6255,6262 ---- else { #ifdef FEAT_RIGHTLEFT ! // Windows will mess up RL text, so we have to draw it character by ! // character. Only do this if RL is on, since it's slow. if (curwin->w_p_rl) RevOut(s_hdc, TEXT_X(col), TEXT_Y(row), foptions, pcliprect, (char *)text, len, padding); *************** *** 6264,6288 **** foptions, pcliprect, (char *)text, len, padding); } ! /* Underline */ if (flags & DRAW_UNDERL) { ! /* When p_linespace is 0, overwrite the bottom row of pixels. ! * Otherwise put the line just below the character. */ y = FILL_Y(row + 1) - 1; if (p_linespace > 1) y -= p_linespace - 1; draw_line(FILL_X(col), y, FILL_X(col + len), y, gui.currFgColor); } ! /* Strikethrough */ if (flags & DRAW_STRIKE) { y = FILL_Y(row + 1) - gui.char_height/2; draw_line(FILL_X(col), y, FILL_X(col + len), y, gui.currSpColor); } ! /* Undercurl */ if (flags & DRAW_UNDERC) { int x; --- 6266,6290 ---- foptions, pcliprect, (char *)text, len, padding); } ! // Underline if (flags & DRAW_UNDERL) { ! // When p_linespace is 0, overwrite the bottom row of pixels. ! // Otherwise put the line just below the character. y = FILL_Y(row + 1) - 1; if (p_linespace > 1) y -= p_linespace - 1; draw_line(FILL_X(col), y, FILL_X(col + len), y, gui.currFgColor); } ! // Strikethrough if (flags & DRAW_STRIKE) { y = FILL_Y(row + 1) - gui.char_height/2; draw_line(FILL_X(col), y, FILL_X(col + len), y, gui.currSpColor); } ! // Undercurl if (flags & DRAW_UNDERC) { int x; *************** *** 6303,6309 **** * Output routines. */ ! /* Flush any output to the screen */ void gui_mch_flush(void) { --- 6305,6313 ---- * Output routines. */ ! /* ! * Flush any output to the screen ! */ void gui_mch_flush(void) { *************** *** 6333,6341 **** - (GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXPADDEDBORDER)) * 2; ! /* FIXME: dirty trick: Because the gui_get_base_height() doesn't include ! * the menubar for MSwin, we subtract it from the screen height, so that ! * the window size can be made to fit on the screen. */ *screen_h = workarea_rect.bottom - workarea_rect.top - (GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CXPADDEDBORDER)) * 2 --- 6337,6345 ---- - (GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXPADDEDBORDER)) * 2; ! // FIXME: dirty trick: Because the gui_get_base_height() doesn't include ! // the menubar for MSwin, we subtract it from the screen height, so that ! // the window size can be made to fit on the screen. *screen_h = workarea_rect.bottom - workarea_rect.top - (GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CXPADDEDBORDER)) * 2 *************** *** 6385,6391 **** vim_free(wn); } ! /* Fix window size if menu may have wrapped */ if (parent == NULL) gui_mswin_get_menu_height(!gui.starting); # ifdef FEAT_TEAROFF --- 6389,6395 ---- vim_free(wn); } ! // Fix window size if menu may have wrapped if (parent == NULL) gui_mswin_get_menu_height(!gui.starting); # ifdef FEAT_TEAROFF *************** *** 6412,6418 **** { POINT p; ! /* Find the position of the current cursor */ GetDCOrgEx(s_hdc, &p); if (mouse_pos) { --- 6416,6422 ---- { POINT p; ! // Find the position of the current cursor GetDCOrgEx(s_hdc, &p); if (mouse_pos) { *************** *** 6442,6448 **** { vimmenu_T *menu = gui_find_menu(path_name); ! /* Found the menu, so tear it off. */ if (menu != NULL) gui_mch_tearoff(menu->dname, menu, 0xffffL, 0xffffL); } --- 6446,6452 ---- { vimmenu_T *menu = gui_find_menu(path_name); ! // Found the menu, so tear it off. if (menu != NULL) gui_mch_tearoff(menu->dname, menu, 0xffffL, 0xffffL); } *************** *** 6549,6555 **** && menu->parent->children != NULL && IsWindow(menu->parent->tearoff_handle)) { ! /* This menu must not show up when rebuilding the tearoff window. */ menu->modes = 0; rebuild_tearoff(menu->parent); } --- 6553,6559 ---- && menu->parent->children != NULL && IsWindow(menu->parent->tearoff_handle)) { ! // This menu must not show up when rebuilding the tearoff window. menu->modes = 0; rebuild_tearoff(menu->parent); } *************** *** 6561,6567 **** static void rebuild_tearoff(vimmenu_T *menu) { ! /*hackish*/ char_u tbuf[128]; RECT trect; RECT rct; --- 6565,6571 ---- static void rebuild_tearoff(vimmenu_T *menu) { ! //hackish char_u tbuf[128]; RECT trect; RECT rct; *************** *** 6595,6601 **** SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); } } ! # endif /* FEAT_TEAROFF */ /* * Make a menu either grey or not grey. --- 6599,6605 ---- SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); } } ! # endif // FEAT_TEAROFF /* * Make a menu either grey or not grey. *************** *** 6640,6649 **** # endif } ! #endif /* FEAT_MENU */ ! /* define some macros used to make the dialogue creation more readable */ #define add_string(s) strcpy((LPSTR)p, s); (LPSTR)p += (strlen((LPSTR)p) + 1) #define add_word(x) *p++ = (x) --- 6644,6653 ---- # endif } ! #endif // FEAT_MENU ! // define some macros used to make the dialogue creation more readable #define add_string(s) strcpy((LPSTR)p, s); (LPSTR)p += (strlen((LPSTR)p) + 1) #define add_word(x) *p++ = (x) *************** *** 6671,6683 **** if (message == WM_INITDIALOG) { CenterWindow(hwnd, GetWindow(hwnd, GW_OWNER)); ! /* Set focus to the dialog. Set the default button, if specified. */ (void)SetFocus(hwnd); if (dialog_default_button > IDCANCEL) (void)SetFocus(GetDlgItem(hwnd, dialog_default_button)); else ! /* We don't have a default, set focus on another element of the ! * dialog window, probably the icon */ (void)SetFocus(GetDlgItem(hwnd, DLG_NONBUTTON_CONTROL)); return FALSE; } --- 6675,6687 ---- if (message == WM_INITDIALOG) { CenterWindow(hwnd, GetWindow(hwnd, GW_OWNER)); ! // Set focus to the dialog. Set the default button, if specified. (void)SetFocus(hwnd); if (dialog_default_button > IDCANCEL) (void)SetFocus(GetDlgItem(hwnd, dialog_default_button)); else ! // We don't have a default, set focus on another element of the ! // dialog window, probably the icon (void)SetFocus(GetDlgItem(hwnd, DLG_NONBUTTON_CONTROL)); return FALSE; } *************** *** 6686,6698 **** { int button = LOWORD(wParam); ! /* Don't end the dialog if something was selected that was ! * not a button. ! */ if (button >= DLG_NONBUTTON_CONTROL) return TRUE; ! /* If the edit box exists, copy the string. */ if (s_textfield != NULL) { WCHAR *wp = ALLOC_MULT(WCHAR, IOSIZE); --- 6690,6701 ---- { int button = LOWORD(wParam); ! // Don't end the dialog if something was selected that was ! // not a button. if (button >= DLG_NONBUTTON_CONTROL) return TRUE; ! // If the edit box exists, copy the string. if (s_textfield != NULL) { WCHAR *wp = ALLOC_MULT(WCHAR, IOSIZE); *************** *** 6744,6750 **** * If stubbing out this fn, return 1. */ ! static const char *dlg_icons[] = /* must match names in resource file */ { "IDR_VIM", "IDR_VIM_ERROR", --- 6747,6753 ---- * If stubbing out this fn, return 1. */ ! static const char *dlg_icons[] = // must match names in resource file { "IDR_VIM", "IDR_VIM_ERROR", *************** *** 6800,6811 **** int l; # ifndef NO_CONSOLE ! /* Don't output anything in silent mode ("ex -s") */ # ifdef VIMDLL if (!(gui.in_use || gui.starting)) # endif if (silent_mode) ! return dfltbutton; /* return default option */ # endif if (s_hwnd == NULL) --- 6803,6814 ---- int l; # ifndef NO_CONSOLE ! // Don't output anything in silent mode ("ex -s") # ifdef VIMDLL if (!(gui.in_use || gui.starting)) # endif if (silent_mode) ! return dfltbutton; // return default option # endif if (s_hwnd == NULL) *************** *** 6814,6821 **** if ((type < 0) || (type > VIM_LAST_TYPE)) type = 0; ! /* allocate some memory for dialog template */ ! /* TODO should compute this really */ pdlgtemplate = p = (PWORD)LocalAlloc(LPTR, DLG_ALLOC_SIZE + STRLEN(message) * 2); --- 6817,6824 ---- if ((type < 0) || (type > VIM_LAST_TYPE)) type = 0; ! // allocate some memory for dialog template ! // TODO should compute this really pdlgtemplate = p = (PWORD)LocalAlloc(LPTR, DLG_ALLOC_SIZE + STRLEN(message) * 2); *************** *** 6831,6839 **** if (tbuffer == NULL) return -1; ! --dfltbutton; /* Change from one-based to zero-based */ ! /* Count buttons */ numButtons = 1; for (i = 0; tbuffer[i] != '\0'; i++) { --- 6834,6842 ---- if (tbuffer == NULL) return -1; ! --dfltbutton; // Change from one-based to zero-based ! // Count buttons numButtons = 1; for (i = 0; tbuffer[i] != '\0'; i++) { *************** *** 6843,6854 **** if (dfltbutton >= numButtons) dfltbutton = -1; ! /* Allocate array to hold the width of each button */ buttonWidths = ALLOC_MULT(int, numButtons); if (buttonWidths == NULL) return -1; ! /* Allocate array to hold the X position of each button */ buttonPositions = ALLOC_MULT(int, numButtons); if (buttonPositions == NULL) return -1; --- 6846,6857 ---- if (dfltbutton >= numButtons) dfltbutton = -1; ! // Allocate array to hold the width of each button buttonWidths = ALLOC_MULT(int, numButtons); if (buttonWidths == NULL) return -1; ! // Allocate array to hold the X position of each button buttonPositions = ALLOC_MULT(int, numButtons); if (buttonPositions == NULL) return -1; *************** *** 6883,6907 **** GetTextMetrics(hdc, &fontInfo); fontHeight = fontInfo.tmHeight; ! /* Minimum width for horizontal button */ minButtonWidth = GetTextWidth(hdc, (char_u *)"Cancel", 6); ! /* Maximum width of a dialog, if possible */ if (s_hwnd == NULL) { RECT workarea_rect; ! /* We don't have a window, use the desktop area. */ get_work_area(&workarea_rect); maxDialogWidth = workarea_rect.right - workarea_rect.left - 100; if (maxDialogWidth > 600) maxDialogWidth = 600; ! /* Leave some room for the taskbar. */ maxDialogHeight = workarea_rect.bottom - workarea_rect.top - 150; } else { ! /* Use our own window for the size, unless it's very small. */ GetWindowRect(s_hwnd, &rect); maxDialogWidth = rect.right - rect.left - (GetSystemMetrics(SM_CXFRAME) + --- 6886,6910 ---- GetTextMetrics(hdc, &fontInfo); fontHeight = fontInfo.tmHeight; ! // Minimum width for horizontal button minButtonWidth = GetTextWidth(hdc, (char_u *)"Cancel", 6); ! // Maximum width of a dialog, if possible if (s_hwnd == NULL) { RECT workarea_rect; ! // We don't have a window, use the desktop area. get_work_area(&workarea_rect); maxDialogWidth = workarea_rect.right - workarea_rect.left - 100; if (maxDialogWidth > 600) maxDialogWidth = 600; ! // Leave some room for the taskbar. maxDialogHeight = workarea_rect.bottom - workarea_rect.top - 150; } else { ! // Use our own window for the size, unless it's very small. GetWindowRect(s_hwnd, &rect); maxDialogWidth = rect.right - rect.left - (GetSystemMetrics(SM_CXFRAME) + *************** *** 6917,6936 **** maxDialogHeight = DLG_MIN_MAX_HEIGHT; } ! /* Set dlgwidth to width of message. ! * Copy the message into "ga", changing NL to CR-NL and inserting line ! * breaks where needed. */ pstart = message; messageWidth = 0; msgheight = 0; ga_init2(&ga, sizeof(char), 500); do { ! msgheight += fontHeight; /* at least one line */ ! /* Need to figure out where to break the string. The system does it ! * at a word boundary, which would mean we can't compute the number of ! * wrapped lines. */ textWidth = 0; last_white = NULL; for (pend = pstart; *pend != NUL && *pend != '\n'; ) --- 6920,6939 ---- maxDialogHeight = DLG_MIN_MAX_HEIGHT; } ! // Set dlgwidth to width of message. ! // Copy the message into "ga", changing NL to CR-NL and inserting line ! // breaks where needed. pstart = message; messageWidth = 0; msgheight = 0; ga_init2(&ga, sizeof(char), 500); do { ! msgheight += fontHeight; // at least one line ! // Need to figure out where to break the string. The system does it ! // at a word boundary, which would mean we can't compute the number of ! // wrapped lines. textWidth = 0; last_white = NULL; for (pend = pstart; *pend != NUL && *pend != '\n'; ) *************** *** 6942,6955 **** textWidth += GetTextWidthEnc(hdc, pend, l); if (textWidth >= maxDialogWidth) { ! /* Line will wrap. */ messageWidth = maxDialogWidth; msgheight += fontHeight; textWidth = 0; if (last_white != NULL) { ! /* break the line just after a space */ ga.ga_len -= (int)(pend - (last_white + 1)); pend = last_white + 1; last_white = NULL; --- 6945,6958 ---- textWidth += GetTextWidthEnc(hdc, pend, l); if (textWidth >= maxDialogWidth) { ! // Line will wrap. messageWidth = maxDialogWidth; msgheight += fontHeight; textWidth = 0; if (last_white != NULL) { ! // break the line just after a space ga.ga_len -= (int)(pend - (last_white + 1)); pend = last_white + 1; last_white = NULL; *************** *** 6973,6981 **** if (ga.ga_data != NULL) message = ga.ga_data; ! messageWidth += 10; /* roundoff space */ ! /* Add width of icon to dlgwidth, and some space */ dlgwidth = messageWidth + DLG_ICON_WIDTH + 3 * dlgPaddingX + GetSystemMetrics(SM_CXVSCROLL); --- 6976,6984 ---- if (ga.ga_data != NULL) message = ga.ga_data; ! messageWidth += 10; // roundoff space ! // Add width of icon to dlgwidth, and some space dlgwidth = messageWidth + DLG_ICON_WIDTH + 3 * dlgPaddingX + GetSystemMetrics(SM_CXVSCROLL); *************** *** 7001,7010 **** textWidth = GetTextWidthEnc(hdc, pstart, (int)(pend - pstart)); if (textWidth < minButtonWidth) textWidth = minButtonWidth; ! textWidth += dlgPaddingX; /* Padding within button */ buttonWidths[i] = textWidth; buttonPositions[i++] = horizWidth; ! horizWidth += textWidth + dlgPaddingX; /* Pad between buttons */ pstart = pend + 1; } while (*pend != NUL); --- 7004,7013 ---- textWidth = GetTextWidthEnc(hdc, pstart, (int)(pend - pstart)); if (textWidth < minButtonWidth) textWidth = minButtonWidth; ! textWidth += dlgPaddingX; // Padding within button buttonWidths[i] = textWidth; buttonPositions[i++] = horizWidth; ! horizWidth += textWidth + dlgPaddingX; // Pad between buttons pstart = pend + 1; } while (*pend != NUL); *************** *** 7024,7031 **** if (pend == NULL) pend = pstart + STRLEN(pstart); // Last button name. textWidth = GetTextWidthEnc(hdc, pstart, (int)(pend - pstart)); ! textWidth += dlgPaddingX; /* Padding within button */ ! textWidth += DLG_VERT_PADDING_X * 2; /* Padding around button */ if (textWidth > dlgwidth) dlgwidth = textWidth; pstart = pend + 1; --- 7027,7034 ---- if (pend == NULL) pend = pstart + STRLEN(pstart); // Last button name. textWidth = GetTextWidthEnc(hdc, pstart, (int)(pend - pstart)); ! textWidth += dlgPaddingX; // Padding within button ! textWidth += DLG_VERT_PADDING_X * 2; // Padding around button if (textWidth > dlgwidth) dlgwidth = textWidth; pstart = pend + 1; *************** *** 7033,7041 **** } if (dlgwidth < DLG_MIN_WIDTH) ! dlgwidth = DLG_MIN_WIDTH; /* Don't allow a really thin dialog!*/ ! /* start to fill in the dlgtemplate information. addressing by WORDs */ if (s_usenewlook) lStyle = DS_MODALFRAME | WS_CAPTION |DS_3DLOOK| WS_VISIBLE |DS_SETFONT; else --- 7036,7044 ---- } if (dlgwidth < DLG_MIN_WIDTH) ! dlgwidth = DLG_MIN_WIDTH; // Don't allow a really thin dialog! ! // start to fill in the dlgtemplate information. addressing by WORDs if (s_usenewlook) lStyle = DS_MODALFRAME | WS_CAPTION |DS_3DLOOK| WS_VISIBLE |DS_SETFONT; else *************** *** 7043,7049 **** add_long(lStyle); add_long(0); // (lExtendedStyle) ! pnumitems = p; /*save where the number of items must be stored*/ add_word(0); // NumberOfItems(will change later) add_word(10); // x add_word(10); // y --- 7046,7052 ---- add_long(lStyle); add_long(0); // (lExtendedStyle) ! pnumitems = p; //save where the number of items must be stored add_word(0); // NumberOfItems(will change later) add_word(10); // x add_word(10); // y *************** *** 7061,7073 **** if (textfield != NULL) dlgheight += editboxheight; ! /* Restrict the size to a maximum. Causes a scrollbar to show up. */ if (dlgheight > maxDialogHeight) { msgheight = msgheight - (dlgheight - maxDialogHeight); dlgheight = maxDialogHeight; scroll_flag = WS_VSCROLL; ! /* Make sure scrollbar doesn't appear in the middle of the dialog */ messageWidth = dlgwidth - DLG_ICON_WIDTH - 3 * dlgPaddingX; } --- 7064,7076 ---- if (textfield != NULL) dlgheight += editboxheight; ! // Restrict the size to a maximum. Causes a scrollbar to show up. if (dlgheight > maxDialogHeight) { msgheight = msgheight - (dlgheight - maxDialogHeight); dlgheight = maxDialogHeight; scroll_flag = WS_VSCROLL; ! // Make sure scrollbar doesn't appear in the middle of the dialog messageWidth = dlgwidth - DLG_ICON_WIDTH - 3 * dlgPaddingX; } *************** *** 7076,7093 **** add_word(0); // Menu add_word(0); // Class ! /* copy the title of the dialog */ nchar = nCopyAnsiToWideChar(p, (title ? (LPSTR)title : (LPSTR)("Vim "VIM_VERSION_MEDIUM)), TRUE); p += nchar; if (s_usenewlook) { ! /* do the font, since DS_3DLOOK doesn't work properly */ # ifdef USE_SYSMENU_FONT if (use_lfSysmenu) { ! /* point size */ *p++ = -MulDiv(lfSysmenu.lfHeight, 72, GetDeviceCaps(hdc, LOGPIXELSY)); wcscpy(p, lfSysmenu.lfFaceName); --- 7079,7096 ---- add_word(0); // Menu add_word(0); // Class ! // copy the title of the dialog nchar = nCopyAnsiToWideChar(p, (title ? (LPSTR)title : (LPSTR)("Vim "VIM_VERSION_MEDIUM)), TRUE); p += nchar; if (s_usenewlook) { ! // do the font, since DS_3DLOOK doesn't work properly # ifdef USE_SYSMENU_FONT if (use_lfSysmenu) { ! // point size *p++ = -MulDiv(lfSysmenu.lfHeight, 72, GetDeviceCaps(hdc, LOGPIXELSY)); wcscpy(p, lfSysmenu.lfFaceName); *************** *** 7109,7118 **** pstart = tbuffer; if (!vertical) ! horizWidth = (dlgwidth - horizWidth) / 2; /* Now it's X offset */ for (i = 0; i < numButtons; i++) { ! /* get end of this button. */ for ( pend = pstart; *pend && (*pend != DLG_BUTTON_SEP); pend++) --- 7112,7121 ---- pstart = tbuffer; if (!vertical) ! horizWidth = (dlgwidth - horizWidth) / 2; // Now it's X offset for (i = 0; i < numButtons; i++) { ! // get end of this button. for ( pend = pstart; *pend && (*pend != DLG_BUTTON_SEP); pend++) *************** *** 7140,7146 **** (i == dfltbutton ? BS_DEFPUSHBUTTON : BS_PUSHBUTTON) | WS_TABSTOP, PixelToDialogX(DLG_VERT_PADDING_X), ! PixelToDialogY(buttonYpos /* TBK */ + 2 * fontHeight * i), PixelToDialogX(dlgwidth - 2 * DLG_VERT_PADDING_X), (WORD)(PixelToDialogY(2 * fontHeight) - 1), --- 7143,7149 ---- (i == dfltbutton ? BS_DEFPUSHBUTTON : BS_PUSHBUTTON) | WS_TABSTOP, PixelToDialogX(DLG_VERT_PADDING_X), ! PixelToDialogY(buttonYpos // TBK + 2 * fontHeight * i), PixelToDialogX(dlgwidth - 2 * DLG_VERT_PADDING_X), (WORD)(PixelToDialogY(2 * fontHeight) - 1), *************** *** 7152,7167 **** (i == dfltbutton ? BS_DEFPUSHBUTTON : BS_PUSHBUTTON) | WS_TABSTOP, PixelToDialogX(horizWidth + buttonPositions[i]), ! PixelToDialogY(buttonYpos), /* TBK */ PixelToDialogX(buttonWidths[i]), (WORD)(PixelToDialogY(2 * fontHeight) - 1), (WORD)(IDCANCEL + 1 + i), (WORD)0x0080, (char *)pstart); } ! pstart = pend + 1; /*next button*/ } *pnumitems += numButtons; ! /* Vim icon */ p = add_dialog_element(p, SS_ICON, PixelToDialogX(dlgPaddingX), PixelToDialogY(dlgPaddingY), --- 7155,7170 ---- (i == dfltbutton ? BS_DEFPUSHBUTTON : BS_PUSHBUTTON) | WS_TABSTOP, PixelToDialogX(horizWidth + buttonPositions[i]), ! PixelToDialogY(buttonYpos), // TBK PixelToDialogX(buttonWidths[i]), (WORD)(PixelToDialogY(2 * fontHeight) - 1), (WORD)(IDCANCEL + 1 + i), (WORD)0x0080, (char *)pstart); } ! pstart = pend + 1; //next button } *pnumitems += numButtons; ! // Vim icon p = add_dialog_element(p, SS_ICON, PixelToDialogX(dlgPaddingX), PixelToDialogY(dlgPaddingY), *************** *** 7170,7176 **** DLG_NONBUTTON_CONTROL + 0, (WORD)0x0082, dlg_icons[type]); ! /* Dialog message */ p = add_dialog_element(p, ES_LEFT|scroll_flag|ES_MULTILINE|ES_READONLY, PixelToDialogX(2 * dlgPaddingX + DLG_ICON_WIDTH), PixelToDialogY(dlgPaddingY), --- 7173,7179 ---- DLG_NONBUTTON_CONTROL + 0, (WORD)0x0082, dlg_icons[type]); ! // Dialog message p = add_dialog_element(p, ES_LEFT|scroll_flag|ES_MULTILINE|ES_READONLY, PixelToDialogX(2 * dlgPaddingX + DLG_ICON_WIDTH), PixelToDialogY(dlgPaddingY), *************** *** 7178,7184 **** PixelToDialogY(msgheight), DLG_NONBUTTON_CONTROL + 1, (WORD)0x0081, (char *)message); ! /* Edit box */ if (textfield != NULL) { p = add_dialog_element(p, ES_LEFT|ES_AUTOHSCROLL|WS_TABSTOP|WS_BORDER, --- 7181,7187 ---- PixelToDialogY(msgheight), DLG_NONBUTTON_CONTROL + 1, (WORD)0x0081, (char *)message); ! // Edit box if (textfield != NULL) { p = add_dialog_element(p, ES_LEFT|ES_AUTOHSCROLL|WS_TABSTOP|WS_BORDER, *************** *** 7196,7206 **** DeleteObject(font); ReleaseDC(hwnd, hdc); ! /* Let the dialog_callback() function know which button to make default ! * If we have an edit box, make that the default. We also need to tell ! * dialog_callback() if this dialog contains an edit box or not. We do ! * this by setting s_textfield if it does. ! */ if (textfield != NULL) { dialog_default_button = DLG_NONBUTTON_CONTROL + 2; --- 7199,7208 ---- DeleteObject(font); ReleaseDC(hwnd, hdc); ! // Let the dialog_callback() function know which button to make default ! // If we have an edit box, make that the default. We also need to tell ! // dialog_callback() if this dialog contains an edit box or not. We do ! // this by setting s_textfield if it does. if (textfield != NULL) { dialog_default_button = DLG_NONBUTTON_CONTROL + 2; *************** *** 7212,7218 **** s_textfield = NULL; } ! /* show the dialog box modally and get a return value */ nchar = (int)DialogBoxIndirect( g_hinst, (LPDLGTEMPLATE)pdlgtemplate, --- 7214,7220 ---- s_textfield = NULL; } ! // show the dialog box modally and get a return value nchar = (int)DialogBoxIndirect( g_hinst, (LPDLGTEMPLATE)pdlgtemplate, *************** *** 7225,7237 **** vim_free(buttonPositions); vim_free(ga.ga_data); ! /* Focus back to our window (for when MDI is used). */ (void)SetFocus(s_hwnd); return nchar; } ! #endif /* FEAT_GUI_DIALOG */ /* * Put a simple element (basic class) onto a dialog template in memory. --- 7227,7239 ---- vim_free(buttonPositions); vim_free(ga.ga_data); ! // Focus back to our window (for when MDI is used). (void)SetFocus(s_hwnd); return nchar; } ! #endif // FEAT_GUI_DIALOG /* * Put a simple element (basic class) onto a dialog template in memory. *************** *** 7263,7269 **** { int nchar; ! p = lpwAlign(p); /* Align to dword boundary*/ lStyle = lStyle | WS_VISIBLE | WS_CHILD; *p++ = LOWORD(lStyle); *p++ = HIWORD(lStyle); --- 7265,7271 ---- { int nchar; ! p = lpwAlign(p); // Align to dword boundary lStyle = lStyle | WS_VISIBLE | WS_CHILD; *p++ = LOWORD(lStyle); *p++ = HIWORD(lStyle); *************** *** 7319,7331 **** BOOL use_enc) { int nChar = 0; ! int len = lstrlen(lpAnsiIn) + 1; /* include NUL character */ int i; WCHAR *wn; if (use_enc && enc_codepage >= 0 && (int)GetACP() != enc_codepage) { ! /* Not a codepage, use our own conversion function. */ wn = enc_to_utf16((char_u *)lpAnsiIn, NULL); if (wn != NULL) { --- 7321,7333 ---- BOOL use_enc) { int nChar = 0; ! int len = lstrlen(lpAnsiIn) + 1; // include NUL character int i; WCHAR *wn; if (use_enc && enc_codepage >= 0 && (int)GetACP() != enc_codepage) { ! // Not a codepage, use our own conversion function. wn = enc_to_utf16((char_u *)lpAnsiIn, NULL); if (wn != NULL) { *************** *** 7335,7348 **** } } if (nChar == 0) ! /* Use Win32 conversion function. */ nChar = MultiByteToWideChar( enc_codepage > 0 ? enc_codepage : CP_ACP, MB_PRECOMPOSED, lpAnsiIn, len, lpWCStr, len); for (i = 0; i < nChar; ++i) ! if (lpWCStr[i] == (WORD)'\t') /* replace tabs with spaces */ lpWCStr[i] = (WORD)' '; return nChar; --- 7337,7350 ---- } } if (nChar == 0) ! // Use Win32 conversion function. nChar = MultiByteToWideChar( enc_codepage > 0 ? enc_codepage : CP_ACP, MB_PRECOMPOSED, lpAnsiIn, len, lpWCStr, len); for (i = 0; i < nChar; ++i) ! if (lpWCStr[i] == (WORD)'\t') // replace tabs with spaces lpWCStr[i] = (WORD)' '; return nChar; *************** *** 7360,7366 **** { for ( ; menu != NULL; menu = menu->next) { ! if (menu->modes == 0) /* this menu has just been deleted */ continue; if (menu_is_separator(menu->dname)) continue; --- 7362,7368 ---- { for ( ; menu != NULL; menu = menu->next) { ! if (menu->modes == 0) // this menu has just been deleted continue; if (menu_is_separator(menu->dname)) continue; *************** *** 7388,7394 **** return (TRUE); } ! /* May show the mouse pointer again. */ HandleMouseHide(message, lParam); if (message == WM_COMMAND) --- 7390,7396 ---- return (TRUE); } ! // May show the mouse pointer again. HandleMouseHide(message, lParam); if (message == WM_COMMAND) *************** *** 7408,7414 **** TPM_LEFTALIGN | TPM_LEFTBUTTON, (int)rect.right - 8, (int)mp.y, ! (int)0, /*reserved param*/ s_hwnd, NULL); /* --- 7410,7416 ---- TPM_LEFTALIGN | TPM_LEFTBUTTON, (int)rect.right - 8, (int)mp.y, ! (int)0, // reserved param s_hwnd, NULL); /* *************** *** 7418,7424 **** } } else ! /* Pass on messages to the main Vim window */ PostMessage(s_hwnd, WM_COMMAND, LOWORD(wParam), 0); /* * Give main window the focus back: this is so after --- 7420,7426 ---- } } else ! // Pass on messages to the main Vim window PostMessage(s_hwnd, WM_COMMAND, LOWORD(wParam), 0); /* * Give main window the focus back: this is so after *************** *** 7434,7440 **** return TRUE; } ! /* When moved around, give main window the focus back. */ if (message == WM_EXITSIZEMOVE) (void)SetActiveWindow(s_hwnd); --- 7436,7442 ---- return TRUE; } ! // When moved around, give main window the focus back. if (message == WM_EXITSIZEMOVE) (void)SetActiveWindow(s_hwnd); *************** *** 7490,7496 **** if (!s_usenewlook) { ! dlgFontSize = GetDialogBaseUnits(); /* fall back to big old system*/ s_dlgfntwidth = LOWORD(dlgFontSize); s_dlgfntheight = HIWORD(dlgFontSize); } --- 7492,7498 ---- if (!s_usenewlook) { ! dlgFontSize = GetDialogBaseUnits(); // fall back to big old system s_dlgfntwidth = LOWORD(dlgFontSize); s_dlgfntheight = HIWORD(dlgFontSize); } *************** *** 7555,7562 **** if (*title == MNU_HIDDEN_CHAR) title++; ! /* Allocate memory to store the dialog template. It's made bigger when ! * needed. */ template_len = DLG_ALLOC_SIZE; pdlgtemplate = p = (WORD *)LocalAlloc(LPTR, template_len); if (p == NULL) --- 7557,7564 ---- if (*title == MNU_HIDDEN_CHAR) title++; ! // Allocate memory to store the dialog template. It's made bigger when ! // needed. template_len = DLG_ALLOC_SIZE; pdlgtemplate = p = (WORD *)LocalAlloc(LPTR, template_len); if (p == NULL) *************** *** 7579,7597 **** else oldFont = SelectFont(hdc, GetStockObject(SYSTEM_FONT)); ! /* Calculate width of a single space. Used for padding columns to the ! * right width. */ spaceWidth = GetTextWidth(hdc, (char_u *)" ", 1); ! /* Figure out max width of the text column, the accelerator column and the ! * optional submenu column. */ submenuWidth = 0; for (col = 0; col < 2; col++) { columnWidths[col] = 0; for (pmenu = menu->children; pmenu != NULL; pmenu = pmenu->next) { ! /* Use "dname" here to compute the width of the visible text. */ text = (col == 0) ? pmenu->dname : pmenu->actext; if (text != NULL && *text != NUL) { --- 7581,7599 ---- else oldFont = SelectFont(hdc, GetStockObject(SYSTEM_FONT)); ! // Calculate width of a single space. Used for padding columns to the ! // right width. spaceWidth = GetTextWidth(hdc, (char_u *)" ", 1); ! // Figure out max width of the text column, the accelerator column and the ! // optional submenu column. submenuWidth = 0; for (col = 0; col < 2; col++) { columnWidths[col] = 0; for (pmenu = menu->children; pmenu != NULL; pmenu = pmenu->next) { ! // Use "dname" here to compute the width of the visible text. text = (col == 0) ? pmenu->dname : pmenu->actext; if (text != NULL && *text != NUL) { *************** *** 7605,7611 **** } if (columnWidths[1] == 0) { ! /* no accelerators */ if (submenuWidth != 0) columnWidths[0] += submenuWidth; else --- 7607,7613 ---- } if (columnWidths[1] == 0) { ! // no accelerators if (submenuWidth != 0) columnWidths[0] += submenuWidth; else *************** *** 7613,7619 **** } else { ! /* there is an accelerator column */ columnWidths[0] += TEAROFF_COLUMN_PADDING * spaceWidth; columnWidths[1] += submenuWidth; } --- 7615,7621 ---- } else { ! // there is an accelerator column columnWidths[0] += TEAROFF_COLUMN_PADDING * spaceWidth; columnWidths[1] += submenuWidth; } *************** *** 7633,7639 **** dlgwidth = textWidth; dlgwidth += 2 * TEAROFF_PADDING_X + TEAROFF_BUTTON_PAD_X; ! /* start to fill in the dlgtemplate information. addressing by WORDs */ if (s_usenewlook) lStyle = DS_MODALFRAME | WS_CAPTION| WS_SYSMENU |DS_SETFONT| WS_VISIBLE; else --- 7635,7641 ---- dlgwidth = textWidth; dlgwidth += 2 * TEAROFF_PADDING_X + TEAROFF_BUTTON_PAD_X; ! // start to fill in the dlgtemplate information. addressing by WORDs if (s_usenewlook) lStyle = DS_MODALFRAME | WS_CAPTION| WS_SYSMENU |DS_SETFONT| WS_VISIBLE; else *************** *** 7644,7650 **** *p++ = HIWORD(lStyle); *p++ = LOWORD(lExtendedStyle); *p++ = HIWORD(lExtendedStyle); ! pnumitems = p; /* save where the number of items must be stored */ *p++ = 0; // NumberOfItems(will change later) gui_mch_getmouse(&x, &y); if (initX == 0xffffL) --- 7646,7652 ---- *p++ = HIWORD(lStyle); *p++ = LOWORD(lExtendedStyle); *p++ = HIWORD(lExtendedStyle); ! pnumitems = p; // save where the number of items must be stored *p++ = 0; // NumberOfItems(will change later) gui_mch_getmouse(&x, &y); if (initX == 0xffffL) *************** *** 7661,7667 **** *p++ = 0; // Menu *p++ = 0; // Class ! /* copy the title of the dialog */ nchar = nCopyAnsiToWideChar(p, ((*title) ? (LPSTR)title : (LPSTR)("Vim "VIM_VERSION_MEDIUM)), TRUE); --- 7663,7669 ---- *p++ = 0; // Menu *p++ = 0; // Class ! // copy the title of the dialog nchar = nCopyAnsiToWideChar(p, ((*title) ? (LPSTR)title : (LPSTR)("Vim "VIM_VERSION_MEDIUM)), TRUE); *************** *** 7669,7679 **** if (s_usenewlook) { ! /* do the font, since DS_3DLOOK doesn't work properly */ # ifdef USE_SYSMENU_FONT if (use_lfSysmenu) { ! /* point size */ *p++ = -MulDiv(lfSysmenu.lfHeight, 72, GetDeviceCaps(hdc, LOGPIXELSY)); wcscpy(p, lfSysmenu.lfFaceName); --- 7671,7681 ---- if (s_usenewlook) { ! // do the font, since DS_3DLOOK doesn't work properly # ifdef USE_SYSMENU_FONT if (use_lfSysmenu) { ! // point size *p++ = -MulDiv(lfSysmenu.lfHeight, 72, GetDeviceCaps(hdc, LOGPIXELSY)); wcscpy(p, lfSysmenu.lfFaceName); *************** *** 7699,7705 **** top_menu = menu; for ( ; menu != NULL; menu = menu->next) { ! if (menu->modes == 0) /* this menu has just been deleted */ continue; if (menu_is_separator(menu->dname)) { --- 7701,7707 ---- top_menu = menu; for ( ; menu != NULL; menu = menu->next) { ! if (menu->modes == 0) // this menu has just been deleted continue; if (menu_is_separator(menu->dname)) { *************** *** 7707,7714 **** continue; } ! /* Check if there still is plenty of room in the template. Make it ! * larger when needed. */ if (((char *)p - (char *)pdlgtemplate) + 1000 > template_len) { WORD *newp; --- 7709,7716 ---- continue; } ! // Check if there still is plenty of room in the template. Make it ! // larger when needed. if (((char *)p - (char *)pdlgtemplate) + 1000 > template_len) { WORD *newp; *************** *** 7727,7735 **** } } ! /* Figure out minimal length of this menu label. Use "name" for the ! * actual text, "dname" for estimating the displayed size. "name" ! * has "&a" for mnemonic and includes the accelerator. */ len = nameLen = (int)STRLEN(menu->name); padding0 = (columnWidths[0] - GetTextWidthEnc(hdc, menu->dname, (int)STRLEN(menu->dname))) / spaceWidth; --- 7729,7737 ---- } } ! // Figure out minimal length of this menu label. Use "name" for the ! // actual text, "dname" for estimating the displayed size. "name" ! // has "&a" for mnemonic and includes the accelerator. len = nameLen = (int)STRLEN(menu->name); padding0 = (columnWidths[0] - GetTextWidthEnc(hdc, menu->dname, (int)STRLEN(menu->dname))) / spaceWidth; *************** *** 7758,7772 **** menuID = (WORD)((long_u)(menu->submenu_id) | (DWORD)0x8000); } ! /* Allocate menu label and fill it in */ text = label = alloc(len + 1); if (label == NULL) break; vim_strncpy(text, menu->name, nameLen); ! text = vim_strchr(text, TAB); /* stop at TAB before actext */ if (text == NULL) ! text = label + nameLen; /* no actext, use whole name */ while (padding0-- > 0) *text++ = ' '; if (menu->actext != NULL) --- 7760,7774 ---- menuID = (WORD)((long_u)(menu->submenu_id) | (DWORD)0x8000); } ! // Allocate menu label and fill it in text = label = alloc(len + 1); if (label == NULL) break; vim_strncpy(text, menu->name, nameLen); ! text = vim_strchr(text, TAB); // stop at TAB before actext if (text == NULL) ! text = label + nameLen; // no actext, use whole name while (padding0-- > 0) *text++ = ' '; if (menu->actext != NULL) *************** *** 7806,7812 **** *ptrueheight = (WORD)(sepPadding + 1 + 13 * (*pnumitems)); ! /* show modelessly */ the_menu->tearoff_handle = CreateDialogIndirectParam( g_hinst, (LPDLGTEMPLATE)pdlgtemplate, --- 7808,7814 ---- *ptrueheight = (WORD)(sepPadding + 1 + 13 * (*pnumitems)); ! // show modelessly the_menu->tearoff_handle = CreateDialogIndirectParam( g_hinst, (LPDLGTEMPLATE)pdlgtemplate, *************** *** 7826,7832 **** */ (void)SetActiveWindow(s_hwnd); ! /* make sure the right buttons are enabled */ force_menu_update = TRUE; } #endif --- 7828,7834 ---- */ (void)SetActiveWindow(s_hwnd); ! // make sure the right buttons are enabled force_menu_update = TRUE; } #endif *************** *** 7834,7840 **** #if defined(FEAT_TOOLBAR) || defined(PROTO) # include "gui_w32_rc.h" ! /* This not defined in older SDKs */ # ifndef TBSTYLE_FLAT # define TBSTYLE_FLAT 0x0800 # endif --- 7836,7842 ---- #if defined(FEAT_TOOLBAR) || defined(PROTO) # include "gui_w32_rc.h" ! // This not defined in older SDKs # ifndef TBSTYLE_FLAT # define TBSTYLE_FLAT 0x0800 # endif *************** *** 7941,7947 **** i = (int)SendMessage(s_toolbarhwnd, TB_ADDBITMAP, (WPARAM)1, (LPARAM)&tbAddBitmap); ! /* i will be set to -1 if it fails */ } } if (i == -1 && menu->iconidx >= 0 && menu->iconidx < TOOLBAR_BITMAP_COUNT) --- 7943,7949 ---- i = (int)SendMessage(s_toolbarhwnd, TB_ADDBITMAP, (WPARAM)1, (LPARAM)&tbAddBitmap); ! // i will be set to -1 if it fails } } if (i == -1 && menu->iconidx >= 0 && menu->iconidx < TOOLBAR_BITMAP_COUNT) *************** *** 7984,7990 **** { TCHITTESTINFO htinfo; htinfo.pt = pt; ! /* ignore if a window under cusor is not tabcontrol. */ if (s_tabhwnd == hWnd) { int idx = TabCtrl_HitTest(s_tabhwnd, &htinfo); --- 7986,7992 ---- { TCHITTESTINFO htinfo; htinfo.pt = pt; ! // ignore if a window under cusor is not tabcontrol. if (s_tabhwnd == hWnd) { int idx = TabCtrl_HitTest(s_tabhwnd, &htinfo); *************** *** 8021,8027 **** s_pt.x = GET_X_LPARAM(lParam); s_pt.y = GET_Y_LPARAM(lParam); SetCapture(hwnd); ! s_hCursor = GetCursor(); /* backup default cursor */ break; } case WM_MOUSEMOVE: --- 8023,8029 ---- s_pt.x = GET_X_LPARAM(lParam); s_pt.y = GET_Y_LPARAM(lParam); SetCapture(hwnd); ! s_hCursor = GetCursor(); // backup default cursor break; } case WM_MOUSEMOVE: *************** *** 8043,8050 **** TabCtrl_GetItemRect(hwnd, idx1, &rect); nCenter = rect.left + (rect.right - rect.left) / 2; ! /* Check if the mouse cursor goes over the center of ! * the next tab to prevent "flickering". */ if ((idx0 < idx1) && (nCenter < pt.x)) { tabpage_move(idx1 + 1); --- 8045,8052 ---- TabCtrl_GetItemRect(hwnd, idx1, &rect); nCenter = rect.left + (rect.right - rect.left) / 2; ! // Check if the mouse cursor goes over the center of ! // the next tab to prevent "flickering". if ((idx0 < idx1) && (nCenter < pt.x)) { tabpage_move(idx1 + 1); *************** *** 8157,8163 **** HANDLE hImage; UINT uType; # ifdef FEAT_XPM_W32 ! HANDLE hShape; /* Mask bitmap handle */ # endif } signicon_t; --- 8159,8165 ---- HANDLE hImage; UINT uType; # ifdef FEAT_XPM_W32 ! HANDLE hShape; // Mask bitmap handle # endif } signicon_t; *************** *** 8205,8215 **** hdcMem = CreateCompatibleDC(s_hdc); hbmpOld = (HBITMAP)SelectObject(hdcMem, sign->hShape); ! /* Make hole */ BitBlt(s_hdc, x, y, w, h, hdcMem, 0, 0, SRCAND); SelectObject(hdcMem, sign->hImage); ! /* Paint sign */ BitBlt(s_hdc, x, y, w, h, hdcMem, 0, 0, SRCPAINT); SelectObject(hdcMem, hbmpOld); DeleteDC(hdcMem); --- 8207,8217 ---- hdcMem = CreateCompatibleDC(s_hdc); hbmpOld = (HBITMAP)SelectObject(hdcMem, sign->hShape); ! // Make hole BitBlt(s_hdc, x, y, w, h, hdcMem, 0, 0, SRCAND); SelectObject(hdcMem, sign->hImage); ! // Paint sign BitBlt(s_hdc, x, y, w, h, hdcMem, 0, 0, SRCPAINT); SelectObject(hdcMem, hbmpOld); DeleteDC(hdcMem); *************** *** 8250,8256 **** char_u *ext; sign.hImage = NULL; ! ext = signfile + STRLEN(signfile) - 4; /* get extension */ if (ext > signfile) { int do_load = 1; --- 8252,8258 ---- char_u *ext; sign.hImage = NULL; ! ext = signfile + STRLEN(signfile) - 4; // get extension if (ext > signfile) { int do_load = 1; *************** *** 8305,8311 **** #if defined(FEAT_BEVAL_GUI) || defined(PROTO) ! /* BALLOON-EVAL IMPLEMENTATION FOR WINDOWS. * Added by Sergey Khorev * * The only reused thing is beval.h and get_beval_info() --- 8307,8314 ---- #if defined(FEAT_BEVAL_GUI) || defined(PROTO) ! /* ! * BALLOON-EVAL IMPLEMENTATION FOR WINDOWS. * Added by Sergey Khorev * * The only reused thing is beval.h and get_beval_info() *************** *** 8366,8373 **** } else { ! /* there is chance we have ancient CommCtl 4.70 ! which doesn't export DllGetVersion */ DWORD dwHandle = 0; DWORD len = GetFileVersionInfoSize(comctl_dll, &dwHandle); if (len > 0) --- 8369,8376 ---- } else { ! // there is chance we have ancient CommCtl 4.70 ! // which doesn't export DllGetVersion DWORD dwHandle = 0; DWORD len = GetFileVersionInfoSize(comctl_dll, &dwHandle); if (len > 0) *************** *** 8500,8507 **** || abs(cur_beval->x - pt.x) > 3 || abs(cur_beval->y - pt.y) > 3)) { ! /* Pointer resting in one place long enough, it's time to show ! * the tooltip. */ cur_beval->showState = ShS_PENDING; cur_beval->x = pt.x; cur_beval->y = pt.y; --- 8503,8510 ---- || abs(cur_beval->x - pt.x) > 3 || abs(cur_beval->y - pt.y) > 3)) { ! // Pointer resting in one place long enough, it's time to show ! // the tooltip. cur_beval->showState = ShS_PENDING; cur_beval->x = pt.x; cur_beval->y = pt.y; *************** *** 8554,8560 **** if (abs(beval->x - pt.x) < 3 && abs(beval->y - pt.y) < 3) { ! /* cursor is still here */ gui_mch_disable_beval_area(cur_beval); beval->showState = ShS_SHOWING; make_tooltip(beval, (char *)mesg, pt); --- 8557,8563 ---- if (abs(beval->x - pt.x) < 3 && abs(beval->y - pt.y) < 3) { ! // cursor is still here gui_mch_disable_beval_area(cur_beval); beval->showState = ShS_SHOWING; make_tooltip(beval, (char *)mesg, pt); *************** *** 8564,8575 **** BalloonEval * gui_mch_create_beval_area( ! void *target UNUSED, /* ignored, always use s_textArea */ char_u *mesg, void (*mesgCB)(BalloonEval *, int), void *clientData) { ! /* partially stolen from gui_beval.c */ BalloonEval *beval; if (mesg != NULL && mesgCB != NULL) --- 8567,8578 ---- BalloonEval * gui_mch_create_beval_area( ! void *target UNUSED, // ignored, always use s_textArea char_u *mesg, void (*mesgCB)(BalloonEval *, int), void *clientData) { ! // partially stolen from gui_beval.c BalloonEval *beval; if (mesg != NULL && mesgCB != NULL) *************** *** 8600,8606 **** static void Handle_WM_Notify(HWND hwnd UNUSED, LPNMHDR pnmh) { ! if (pnmh->idFrom != ID_BEVAL_TOOLTIP) /* it is not our tooltip */ return; if (cur_beval != NULL) --- 8603,8609 ---- static void Handle_WM_Notify(HWND hwnd UNUSED, LPNMHDR pnmh) { ! if (pnmh->idFrom != ID_BEVAL_TOOLTIP) // it is not our tooltip return; if (cur_beval != NULL) *************** *** 8611,8617 **** // TRACE0("TTN_SHOW {{{"); // TRACE0("TTN_SHOW }}}"); break; ! case TTN_POP: /* Before tooltip disappear */ // TRACE0("TTN_POP {{{"); delete_tooltip(cur_beval); gui_mch_enable_beval_area(cur_beval); --- 8614,8620 ---- // TRACE0("TTN_SHOW {{{"); // TRACE0("TTN_SHOW }}}"); break; ! case TTN_POP: // Before tooltip disappear // TRACE0("TTN_POP {{{"); delete_tooltip(cur_beval); gui_mch_enable_beval_area(cur_beval); *************** *** 8621,8627 **** break; case TTN_GETDISPINFO: { ! /* if you get there then we have new common controls */ NMTTDISPINFO_NEW *info = (NMTTDISPINFO_NEW *)pnmh; info->lpszText = (LPSTR)info->lParam; info->uFlags |= TTF_DI_SETITEM; --- 8624,8630 ---- break; case TTN_GETDISPINFO: { ! // if you get there then we have new common controls NMTTDISPINFO_NEW *info = (NMTTDISPINFO_NEW *)pnmh; info->lpszText = (LPSTR)info->lParam; info->uFlags |= TTF_DI_SETITEM; *************** *** 8656,8662 **** vim_free(beval->tofree); vim_free(beval); } ! #endif /* FEAT_BEVAL_GUI */ #if defined(FEAT_NETBEANS_INTG) || defined(PROTO) /* --- 8659,8665 ---- vim_free(beval->tofree); vim_free(beval); } ! #endif // FEAT_BEVAL_GUI #if defined(FEAT_NETBEANS_INTG) || defined(PROTO) /* *** ../vim-8.1.2382/src/gui_x11.c 2019-11-21 17:13:12.624361334 +0100 --- src/gui_x11.c 2019-12-02 22:46:51.555125429 +0100 *************** *** 57,63 **** #define VIM_NAME "vim" #define VIM_CLASS "Vim" ! /* Default resource values */ #define DFLT_FONT "7x13" #ifdef FONTSET_ALWAYS # define DFLT_MENU_FONT XtDefaultFontSet --- 57,63 ---- #define VIM_NAME "vim" #define VIM_CLASS "Vim" ! // Default resource values #define DFLT_FONT "7x13" #ifdef FONTSET_ALWAYS # define DFLT_MENU_FONT XtDefaultFontSet *************** *** 74,80 **** # define DFLT_TOOLTIP_BG_COLOR "#ffff91" # define DFLT_TOOLTIP_FG_COLOR "#000000" #else ! /* use the default (CDE) colors */ # define DFLT_MENU_BG_COLOR "" # define DFLT_MENU_FG_COLOR "" # define DFLT_SCROLL_BG_COLOR "" --- 74,80 ---- # define DFLT_TOOLTIP_BG_COLOR "#ffff91" # define DFLT_TOOLTIP_FG_COLOR "#000000" #else ! // use the default (CDE) colors # define DFLT_MENU_BG_COLOR "" # define DFLT_MENU_FG_COLOR "" # define DFLT_SCROLL_BG_COLOR "" *************** *** 85,93 **** Widget vimShell = (Widget)0; ! static Atom wm_atoms[2]; /* Window Manager Atoms */ ! #define DELETE_WINDOW_IDX 0 /* index in wm_atoms[] for WM_DELETE_WINDOW */ ! #define SAVE_YOURSELF_IDX 1 /* index in wm_atoms[] for WM_SAVE_YOURSELF */ #ifdef FEAT_XFONTSET /* --- 85,93 ---- Widget vimShell = (Widget)0; ! static Atom wm_atoms[2]; // Window Manager Atoms ! #define DELETE_WINDOW_IDX 0 // index in wm_atoms[] for WM_DELETE_WINDOW ! #define SAVE_YOURSELF_IDX 1 // index in wm_atoms[] for WM_SAVE_YOURSELF #ifdef FEAT_XFONTSET /* *************** *** 198,204 **** {XK_F32, 'F', 'M'}, {XK_F33, 'F', 'N'}, {XK_F34, 'F', 'O'}, ! {XK_F35, 'F', 'P'}, /* keysymdef.h defines up to F35 */ #ifdef SunXK_F36 {SunXK_F36, 'F', 'Q'}, {SunXK_F37, 'F', 'R'}, --- 198,204 ---- {XK_F32, 'F', 'M'}, {XK_F33, 'F', 'N'}, {XK_F34, 'F', 'O'}, ! {XK_F35, 'F', 'P'}, // keysymdef.h defines up to F35 #ifdef SunXK_F36 {SunXK_F36, 'F', 'Q'}, {SunXK_F37, 'F', 'R'}, *************** *** 215,221 **** {XK_Next, 'k', 'N'}, {XK_Print, '%', '9'}, ! /* Keypad keys: */ #ifdef XK_KP_Left {XK_KP_Left, 'k', 'l'}, {XK_KP_Right, 'k', 'r'}, --- 215,221 ---- {XK_Next, 'k', 'N'}, {XK_Print, '%', '9'}, ! // Keypad keys: #ifdef XK_KP_Left {XK_KP_Left, 'k', 'l'}, {XK_KP_Right, 'k', 'r'}, *************** *** 247,253 **** {XK_KP_9, 'K', 'L'}, #endif ! /* End of list marker: */ {(KeySym)0, 0, 0} }; --- 247,253 ---- {XK_KP_9, 'K', 'L'}, #endif ! // End of list marker: {(KeySym)0, 0, 0} }; *************** *** 267,285 **** #define XtCMenuFontSet "MenuFontSet" ! /* Resources for setting the foreground and background colors of menus */ #define XtNmenuBackground "menuBackground" #define XtCMenuBackground "MenuBackground" #define XtNmenuForeground "menuForeground" #define XtCMenuForeground "MenuForeground" ! /* Resources for setting the foreground and background colors of scrollbars */ #define XtNscrollBackground "scrollBackground" #define XtCScrollBackground "ScrollBackground" #define XtNscrollForeground "scrollForeground" #define XtCScrollForeground "ScrollForeground" ! /* Resources for setting the foreground and background colors of tooltip */ #define XtNtooltipBackground "tooltipBackground" #define XtCTooltipBackground "TooltipBackground" #define XtNtooltipForeground "tooltipForeground" --- 267,285 ---- #define XtCMenuFontSet "MenuFontSet" ! // Resources for setting the foreground and background colors of menus #define XtNmenuBackground "menuBackground" #define XtCMenuBackground "MenuBackground" #define XtNmenuForeground "menuForeground" #define XtCMenuForeground "MenuForeground" ! // Resources for setting the foreground and background colors of scrollbars #define XtNscrollBackground "scrollBackground" #define XtCScrollBackground "ScrollBackground" #define XtNscrollForeground "scrollForeground" #define XtCScrollForeground "ScrollForeground" ! // Resources for setting the foreground and background colors of tooltip #define XtNtooltipBackground "tooltipBackground" #define XtCTooltipBackground "TooltipBackground" #define XtNtooltipForeground "tooltipForeground" *************** *** 383,389 **** (XtPointer)SB_DEFAULT_WIDTH }, #ifdef FEAT_MENU ! # ifdef FEAT_GUI_ATHENA /* with Motif the height is always computed */ { XtNmenuHeight, XtCMenuHeight, --- 383,389 ---- (XtPointer)SB_DEFAULT_WIDTH }, #ifdef FEAT_MENU ! # ifdef FEAT_GUI_ATHENA // with Motif the height is always computed { XtNmenuHeight, XtCMenuHeight, *************** *** 391,397 **** sizeof(int), XtOffsetOf(gui_T, menu_height), XtRImmediate, ! (XtPointer)MENU_DEFAULT_HEIGHT /* Should figure out at run time */ }, # endif { --- 391,397 ---- sizeof(int), XtOffsetOf(gui_T, menu_height), XtRImmediate, ! (XtPointer)MENU_DEFAULT_HEIGHT // Should figure out at run time }, # endif { *************** *** 473,479 **** XtRString, DFLT_TOOLTIP_FONT }, ! /* This one may not be really needed? */ { "balloonEvalFontSet", XtCFontSet, --- 473,479 ---- XtRString, DFLT_TOOLTIP_FONT }, ! // This one may not be really needed? { "balloonEvalFontSet", XtCFontSet, *************** *** 483,489 **** XtRImmediate, (XtPointer)NOFONTSET }, ! #endif /* FEAT_BEVAL_GUI */ #ifdef FEAT_XIM { "preeditType", --- 483,489 ---- XtRImmediate, (XtPointer)NOFONTSET }, ! #endif // FEAT_BEVAL_GUI #ifdef FEAT_XIM { "preeditType", *************** *** 503,509 **** XtRString, NULL }, ! #endif /* FEAT_XIM */ }; /* --- 503,509 ---- XtRString, NULL }, ! #endif // FEAT_XIM }; /* *************** *** 514,520 **** */ static XrmOptionDescRec cmdline_options[] = { ! /* We handle these options ourselves */ {"-bg", ".background", XrmoptionSepArg, NULL}, {"-background", ".background", XrmoptionSepArg, NULL}, {"-fg", ".foreground", XrmoptionSepArg, NULL}, --- 514,520 ---- */ static XrmOptionDescRec cmdline_options[] = { ! // We handle these options ourselves {"-bg", ".background", XrmoptionSepArg, NULL}, {"-background", ".background", XrmoptionSepArg, NULL}, {"-fg", ".foreground", XrmoptionSepArg, NULL}, *************** *** 572,583 **** { XtIntervalId *channel_timer = (XtIntervalId *)client_data; ! /* Using an event handler for a channel that may be disconnected does ! * not work, it hangs. Instead poll for messages. */ channel_handle_events(TRUE); parse_queued_messages(); ! /* repeat */ *channel_timer = XtAppAddTimeOut(app_context, (long_u)20, channel_poll_cb, client_data); } --- 572,583 ---- { XtIntervalId *channel_timer = (XtIntervalId *)client_data; ! // Using an event handler for a channel that may be disconnected does ! // not work, it hangs. Instead poll for messages. channel_handle_events(TRUE); parse_queued_messages(); ! // repeat *channel_timer = XtAppAddTimeOut(app_context, (long_u)20, channel_poll_cb, client_data); } *************** *** 602,608 **** XSetGraphicsExposures(gui.dpy, gui.text_gc, gui.visibility != VisibilityUnobscured); ! /* This is needed for when redrawing is slow. */ gui_mch_update(); } --- 602,608 ---- XSetGraphicsExposures(gui.dpy, gui.text_gc, gui.visibility != VisibilityUnobscured); ! // This is needed for when redrawing is slow. gui_mch_update(); } *************** *** 619,632 **** if (event->type != Expose) return; ! out_flush(); /* make sure all output has been processed */ gevent = (XExposeEvent *)event; gui_redraw(gevent->x, gevent->y, gevent->width, gevent->height); new_x = FILL_X(0); ! /* Clear the border areas if needed */ if (gevent->x < new_x) XClearArea(gui.dpy, gui.wid, 0, 0, new_x, 0, False); if (gevent->y < FILL_Y(0)) --- 619,632 ---- if (event->type != Expose) return; ! out_flush(); // make sure all output has been processed gevent = (XExposeEvent *)event; gui_redraw(gevent->x, gevent->y, gevent->width, gevent->height); new_x = FILL_X(0); ! // Clear the border areas if needed if (gevent->x < new_x) XClearArea(gui.dpy, gui.wid, 0, 0, new_x, 0, False); if (gevent->y < FILL_Y(0)) *************** *** 636,642 **** if (gevent->y > FILL_Y(Rows)) XClearArea(gui.dpy, gui.wid, 0, FILL_Y((int)Rows), 0, 0, False); ! /* This is needed for when redrawing is slow. */ gui_mch_update(); } --- 636,642 ---- if (gevent->y > FILL_Y(Rows)) XClearArea(gui.dpy, gui.wid, 0, FILL_Y((int)Rows), 0, 0, False); ! // This is needed for when redrawing is slow. gui_mch_update(); } *************** *** 783,790 **** if (xic) { # ifdef USE_UTF8LOOKUP ! /* XFree86 4.0.2 or newer: Be able to get UTF-8 characters even when ! * the locale isn't utf-8. */ if (enc_utf8) len = Xutf8LookupString(xic, ev_press, (char *)string, sizeof(string_shortbuf), &key_sym, &status); --- 783,790 ---- if (xic) { # ifdef USE_UTF8LOOKUP ! // XFree86 4.0.2 or newer: Be able to get UTF-8 characters even when ! // the locale isn't utf-8. if (enc_utf8) len = Xutf8LookupString(xic, ev_press, (char *)string, sizeof(string_shortbuf), &key_sym, &status); *************** *** 797,804 **** string = (char_u *)XtMalloc(len + 1); string_alloced = True; # ifdef USE_UTF8LOOKUP ! /* XFree86 4.0.2 or newer: Be able to get UTF-8 characters even ! * when the locale isn't utf-8. */ if (enc_utf8) len = Xutf8LookupString(xic, ev_press, (char *)string, len, &key_sym, &status); --- 797,804 ---- string = (char_u *)XtMalloc(len + 1); string_alloced = True; # ifdef USE_UTF8LOOKUP ! // XFree86 4.0.2 or newer: Be able to get UTF-8 characters even ! // when the locale isn't utf-8. if (enc_utf8) len = Xutf8LookupString(xic, ev_press, (char *)string, len, &key_sym, &status); *************** *** 810,824 **** if (status == XLookupNone || status == XLookupChars) key_sym = XK_VoidSymbol; ! /* Do conversion from 'termencoding' to 'encoding'. When using ! * Xutf8LookupString() it has already been done. */ if (len > 0 && input_conv.vc_type != CONV_NONE # ifdef USE_UTF8LOOKUP && !enc_utf8 # endif ) { ! int maxlen = len * 4 + 40; /* guessed */ char_u *p = (char_u *)XtMalloc(maxlen); mch_memmove(p, string, len); --- 810,824 ---- if (status == XLookupNone || status == XLookupChars) key_sym = XK_VoidSymbol; ! // Do conversion from 'termencoding' to 'encoding'. When using ! // Xutf8LookupString() it has already been done. if (len > 0 && input_conv.vc_type != CONV_NONE # ifdef USE_UTF8LOOKUP && !enc_utf8 # endif ) { ! int maxlen = len * 4 + 40; // guessed char_u *p = (char_u *)XtMalloc(maxlen); mch_memmove(p, string, len); *************** *** 829,836 **** len = convert_input(p, len, maxlen); } ! /* Translate CSI to K_CSI, otherwise it could be recognized as the ! * start of a special key. */ for (i = 0; i < len; ++i) if (string[i] == CSI) { --- 829,836 ---- len = convert_input(p, len, maxlen); } ! // Translate CSI to K_CSI, otherwise it could be recognized as the ! // start of a special key. for (i = 0; i < len; ++i) if (string[i] == CSI) { *************** *** 864,870 **** #endif if (key_sym == XK_space) ! string[0] = ' '; /* Otherwise Ctrl-Space doesn't work */ /* * Only on some machines ^_ requires Ctrl+Shift+minus. For consistency, --- 864,870 ---- #endif if (key_sym == XK_space) ! string[0] = ' '; // Otherwise Ctrl-Space doesn't work /* * Only on some machines ^_ requires Ctrl+Shift+minus. For consistency, *************** *** 874,880 **** string[0] = Ctrl__; #ifdef XK_ISO_Left_Tab ! /* why do we get XK_ISO_Left_Tab instead of XK_Tab for shift-tab? */ if (key_sym == XK_ISO_Left_Tab) { key_sym = XK_Tab; --- 874,880 ---- string[0] = Ctrl__; #ifdef XK_ISO_Left_Tab ! // why do we get XK_ISO_Left_Tab instead of XK_Tab for shift-tab? if (key_sym == XK_ISO_Left_Tab) { key_sym = XK_Tab; *************** *** 883,892 **** } #endif ! /* Check for Alt/Meta key (Mod1Mask), but not for a BS, DEL or character ! * that already has the 8th bit set. And not when using a double-byte ! * encoding, setting the 8th bit may make it the lead byte of a ! * double-byte character. */ if (len == 1 && (ev_press->state & Mod1Mask) && !(key_sym == XK_BackSpace || key_sym == XK_Delete) --- 883,892 ---- } #endif ! // Check for Alt/Meta key (Mod1Mask), but not for a BS, DEL or character ! // that already has the 8th bit set. And not when using a double-byte ! // encoding, setting the 8th bit may make it the lead byte of a ! // double-byte character. if (len == 1 && (ev_press->state & Mod1Mask) && !(key_sym == XK_BackSpace || key_sym == XK_Delete) *************** *** 894,900 **** && !enc_dbcs) { #if defined(FEAT_MENU) && defined(FEAT_GUI_MOTIF) ! /* Ignore ALT keys when they are used for the menu only */ if (gui.menu_is_active && (p_wak[0] == 'y' || (p_wak[0] == 'm' && gui_is_menu_shortcut(string[0])))) --- 894,900 ---- && !enc_dbcs) { #if defined(FEAT_MENU) && defined(FEAT_GUI_MOTIF) ! // Ignore ALT keys when they are used for the menu only if (gui.menu_is_active && (p_wak[0] == 'y' || (p_wak[0] == 'm' && gui_is_menu_shortcut(string[0])))) *************** *** 911,923 **** len2 = XLookupString(ev_press, (char *)string2, sizeof(string2), &key_sym2, NULL); if (key_sym2 == XK_space) ! string2[0] = ' '; /* Otherwise Meta-Ctrl-Space doesn't work */ if ( len2 == 1 && string[0] == string2[0] && !(key_sym == XK_Tab && (ev_press->state & ShiftMask))) { string[0] |= 0x80; ! if (enc_utf8) /* convert to utf-8 */ { string[1] = string[0] & 0xbf; string[0] = ((unsigned)string[0] >> 6) + 0xc0; --- 911,923 ---- len2 = XLookupString(ev_press, (char *)string2, sizeof(string2), &key_sym2, NULL); if (key_sym2 == XK_space) ! string2[0] = ' '; // Otherwise Meta-Ctrl-Space doesn't work if ( len2 == 1 && string[0] == string2[0] && !(key_sym == XK_Tab && (ev_press->state & ShiftMask))) { string[0] |= 0x80; ! if (enc_utf8) // convert to utf-8 { string[1] = string[0] & 0xbf; string[0] = ((unsigned)string[0] >> 6) + 0xc0; *************** *** 942,949 **** len = -3; } ! /* Check for special keys. Also do this when len == 1 (key has an ASCII ! * value) to detect backspace, delete and keypad keys. */ if (len == 0 || len == 1) { for (i = 0; special_keys[i].key_sym != (KeySym)0; i++) --- 942,949 ---- len = -3; } ! // Check for special keys. Also do this when len == 1 (key has an ASCII ! // value) to detect backspace, delete and keypad keys. if (len == 0 || len == 1) { for (i = 0; special_keys[i].key_sym != (KeySym)0; i++) *************** *** 959,970 **** } } ! /* Unrecognised key is ignored. */ if (len == 0) goto theend; ! /* Special keys (and a few others) may have modifiers. Also when using a ! * double-byte encoding (can't set the 8th bit). */ if (len == -3 || key_sym == XK_space || key_sym == XK_Tab || key_sym == XK_Return || key_sym == XK_Linefeed || key_sym == XK_Escape --- 959,970 ---- } } ! // Unrecognised key is ignored. if (len == 0) goto theend; ! // Special keys (and a few others) may have modifiers. Also when using a ! // double-byte encoding (can't set the 8th bit). if (len == -3 || key_sym == XK_space || key_sym == XK_Tab || key_sym == XK_Return || key_sym == XK_Linefeed || key_sym == XK_Escape *************** *** 1040,1046 **** } #endif theend: ! {} /* some compilers need a statement here */ #ifdef FEAT_XIM if (string_alloced) XtFree((char *)string); --- 1040,1046 ---- } #endif theend: ! {} // some compilers need a statement here #ifdef FEAT_XIM if (string_alloced) XtFree((char *)string); *************** *** 1065,1071 **** if (event->type == MotionNotify) { ! /* Get the latest position, avoids lagging behind on a drag. */ x = event->xmotion.x; y = event->xmotion.y; x_modifiers = event->xmotion.state; --- 1065,1071 ---- if (event->type == MotionNotify) { ! // Get the latest position, avoids lagging behind on a drag. x = event->xmotion.x; y = event->xmotion.y; x_modifiers = event->xmotion.state; *************** *** 1077,1086 **** */ gui_mch_mousehide(FALSE); ! if (button != MOUSE_DRAG) /* just moving the rodent */ { #ifdef FEAT_MENU ! if (dud) /* moved in vimForm */ y -= gui.menu_height; #endif gui_mouse_moved(x, y); --- 1077,1086 ---- */ gui_mch_mousehide(FALSE); ! if (button != MOUSE_DRAG) // just moving the rodent { #ifdef FEAT_MENU ! if (dud) // moved in vimForm y -= gui.menu_height; #endif gui_mouse_moved(x, y); *************** *** 1093,1099 **** y = event->xbutton.y; if (event->type == ButtonPress) { ! /* Handle multiple clicks */ if (!timed_out) { XtRemoveTimeOut(timer); --- 1093,1099 ---- y = event->xbutton.y; if (event->type == ButtonPress) { ! // Handle multiple clicks if (!timed_out) { XtRemoveTimeOut(timer); *************** *** 1104,1110 **** gui_x11_timer_cb, &timed_out); switch (event->xbutton.button) { ! /* keep in sync with gui_gtk_x11.c */ case Button1: button = MOUSE_LEFT; break; case Button2: button = MOUSE_MIDDLE; break; case Button3: button = MOUSE_RIGHT; break; --- 1104,1110 ---- gui_x11_timer_cb, &timed_out); switch (event->xbutton.button) { ! // keep in sync with gui_gtk_x11.c case Button1: button = MOUSE_LEFT; break; case Button2: button = MOUSE_MIDDLE; break; case Button3: button = MOUSE_RIGHT; break; *************** *** 1115,1127 **** case 8: button = MOUSE_X1; break; case 9: button = MOUSE_X2; break; default: ! return; /* Unknown button */ } } else if (event->type == ButtonRelease) button = MOUSE_RELEASE; else ! return; /* Unknown mouse event type */ x_modifiers = event->xbutton.state; #if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) --- 1115,1127 ---- case 8: button = MOUSE_X1; break; case 9: button = MOUSE_X2; break; default: ! return; // Unknown button } } else if (event->type == ButtonRelease) button = MOUSE_RELEASE; else ! return; // Unknown mouse event type x_modifiers = event->xbutton.state; #if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) *************** *** 1134,1140 **** vim_modifiers |= MOUSE_SHIFT; if (x_modifiers & ControlMask) vim_modifiers |= MOUSE_CTRL; ! if (x_modifiers & Mod1Mask) /* Alt or Meta key */ vim_modifiers |= MOUSE_ALT; gui_send_mouse_event(button, x, y, repeated_click, vim_modifiers); --- 1134,1140 ---- vim_modifiers |= MOUSE_SHIFT; if (x_modifiers & ControlMask) vim_modifiers |= MOUSE_CTRL; ! if (x_modifiers & Mod1Mask) // Alt or Meta key vim_modifiers |= MOUSE_ALT; gui_send_mouse_event(button, x, y, repeated_click, vim_modifiers); *************** *** 1166,1179 **** arg = 1; while (arg < *argc) { ! /* Look for argv[arg] in cmdline_options[] table */ for (i = 0; i < (int)XtNumber(cmdline_options); i++) if (strcmp(argv[arg], cmdline_options[i].option) == 0) break; if (i < (int)XtNumber(cmdline_options)) { ! /* Remember finding "-rv" or "-reverse" */ if (strcmp("-rv", argv[arg]) == 0 || strcmp("-reverse", argv[arg]) == 0) found_reverse_arg = TRUE; --- 1166,1179 ---- arg = 1; while (arg < *argc) { ! // Look for argv[arg] in cmdline_options[] table for (i = 0; i < (int)XtNumber(cmdline_options); i++) if (strcmp(argv[arg], cmdline_options[i].option) == 0) break; if (i < (int)XtNumber(cmdline_options)) { ! // Remember finding "-rv" or "-reverse" if (strcmp("-rv", argv[arg]) == 0 || strcmp("-reverse", argv[arg]) == 0) found_reverse_arg = TRUE; *************** *** 1182,1188 **** && arg + 1 < *argc) font_argument = argv[arg + 1]; ! /* Found match in table, so move it into gui_argv */ gui_argv[gui_argc++] = argv[arg]; if (--*argc > arg) { --- 1182,1188 ---- && arg + 1 < *argc) font_argument = argv[arg + 1]; ! // Found match in table, so move it into gui_argv gui_argv[gui_argc++] = argv[arg]; if (--*argc > arg) { *************** *** 1190,1196 **** * sizeof(char *)); if (cmdline_options[i].argKind != XrmoptionNoArg) { ! /* Move the options argument as well */ gui_argv[gui_argc++] = argv[arg]; if (--*argc > arg) mch_memmove(&argv[arg], &argv[arg + 1], (*argc - arg) --- 1190,1196 ---- * sizeof(char *)); if (cmdline_options[i].argKind != XrmoptionNoArg) { ! // Move the options argument as well gui_argv[gui_argc++] = argv[arg]; if (--*argc > arg) mch_memmove(&argv[arg], &argv[arg + 1], (*argc - arg) *************** *** 1203,1209 **** #ifdef FEAT_NETBEANS_INTG if (strncmp("-nb", argv[arg], 3) == 0) { ! gui.dofork = FALSE; /* don't fork() when starting GUI */ netbeansArg = argv[arg]; mch_memmove(&argv[arg], &argv[arg + 1], (--*argc - arg) * sizeof(char *)); --- 1203,1209 ---- #ifdef FEAT_NETBEANS_INTG if (strncmp("-nb", argv[arg], 3) == 0) { ! gui.dofork = FALSE; // don't fork() when starting GUI netbeansArg = argv[arg]; mch_memmove(&argv[arg], &argv[arg + 1], (--*argc - arg) * sizeof(char *)); *************** *** 1243,1251 **** # if defined(FEAT_FLOAT) && defined(LC_NUMERIC) { ! /* The call to XtOpenDisplay() may have set the locale from the ! * environment. Set LC_NUMERIC to "C" to make sure that strtod() uses a ! * decimal point, not a comma. */ char *p = setlocale(LC_NUMERIC, NULL); if (p == NULL || strcmp(p, "C") != 0) --- 1243,1251 ---- # if defined(FEAT_FLOAT) && defined(LC_NUMERIC) { ! // The call to XtOpenDisplay() may have set the locale from the ! // environment. Set LC_NUMERIC to "C" to make sure that strtod() uses a ! // decimal point, not a comma. char *p = setlocale(LC_NUMERIC, NULL); if (p == NULL || strcmp(p, "C") != 0) *************** *** 1293,1299 **** unsigned w, h; #if 0 ! /* Uncomment this to enable synchronous mode for debugging */ XSynchronize(gui.dpy, True); #endif --- 1293,1299 ---- unsigned w, h; #if 0 ! // Uncomment this to enable synchronous mode for debugging XSynchronize(gui.dpy, True); #endif *************** *** 1312,1320 **** * Get the colors ourselves. Using the automatic conversion doesn't * handle looking for approximate colors. */ ! /* NOTE: These next few lines are an exact duplicate of gui_athena.c's ! * gui_mch_def_colors(). Why? ! */ gui.menu_fg_pixel = gui_get_color((char_u *)gui.rsrc_menu_fg_name); gui.menu_bg_pixel = gui_get_color((char_u *)gui.rsrc_menu_bg_name); gui.scroll_fg_pixel = gui_get_color((char_u *)gui.rsrc_scroll_fg_name); --- 1312,1319 ---- * Get the colors ourselves. Using the automatic conversion doesn't * handle looking for approximate colors. */ ! // NOTE: These next few lines are an exact duplicate of gui_athena.c's ! // gui_mch_def_colors(). Why? gui.menu_fg_pixel = gui_get_color((char_u *)gui.rsrc_menu_fg_name); gui.menu_bg_pixel = gui_get_color((char_u *)gui.rsrc_menu_bg_name); gui.scroll_fg_pixel = gui_get_color((char_u *)gui.rsrc_scroll_fg_name); *************** *** 1325,1340 **** #endif #if defined(FEAT_MENU) && defined(FEAT_GUI_ATHENA) ! /* If the menu height was set, don't change it at runtime */ if (gui.menu_height != MENU_DEFAULT_HEIGHT) gui.menu_height_fixed = TRUE; #endif ! /* Set default foreground and background colours */ gui.norm_pixel = gui.def_norm_pixel; gui.back_pixel = gui.def_back_pixel; ! /* Check if reverse video needs to be applied (on Sun it's done by X) */ if (gui.rsrc_rev_video && gui_get_lightness(gui.back_pixel) > gui_get_lightness(gui.norm_pixel)) { --- 1324,1339 ---- #endif #if defined(FEAT_MENU) && defined(FEAT_GUI_ATHENA) ! // If the menu height was set, don't change it at runtime if (gui.menu_height != MENU_DEFAULT_HEIGHT) gui.menu_height_fixed = TRUE; #endif ! // Set default foreground and background colours gui.norm_pixel = gui.def_norm_pixel; gui.back_pixel = gui.def_back_pixel; ! // Check if reverse video needs to be applied (on Sun it's done by X) if (gui.rsrc_rev_video && gui_get_lightness(gui.back_pixel) > gui_get_lightness(gui.norm_pixel)) { *************** *** 1344,1351 **** gui.def_back_pixel = gui.back_pixel; } ! /* Get the colors from the "Normal", "Tooltip", "Scrollbar" and "Menu" ! * group (set in syntax.c or in a vimrc file) */ set_normal_colors(); /* --- 1343,1350 ---- gui.def_back_pixel = gui.back_pixel; } ! // Get the colors from the "Normal", "Tooltip", "Scrollbar" and "Menu" ! // group (set in syntax.c or in a vimrc file) set_normal_colors(); /* *************** *** 1377,1384 **** if (gui_win_x != -1 && gui_win_y != -1) gui_mch_set_winpos(gui_win_x, gui_win_y); ! /* Now adapt the supplied(?) geometry-settings */ ! /* Added by Kjetil Jacobsen */ if (gui.geom != NULL && *gui.geom != NUL) { mask = XParseGeometry((char *)gui.geom, &x, &y, &w, &h); --- 1376,1383 ---- if (gui_win_x != -1 && gui_win_y != -1) gui_mch_set_winpos(gui_win_x, gui_win_y); ! // Now adapt the supplied(?) geometry-settings ! // Added by Kjetil Jacobsen if (gui.geom != NULL && *gui.geom != NUL) { mask = XParseGeometry((char *)gui.geom, &x, &y, &w, &h); *************** *** 1427,1436 **** vim_mask_icon_height)); XtSetValues(vimShell, arg, (Cardinal)2); #else ! /* Use Pixmaps, looking much nicer. */ ! /* If you get an error message here, you still need to unpack the runtime ! * archive! */ # ifdef magick # undef magick # endif --- 1426,1435 ---- vim_mask_icon_height)); XtSetValues(vimShell, arg, (Cardinal)2); #else ! // Use Pixmaps, looking much nicer. ! // If you get an error message here, you still need to unpack the runtime ! // archive! # ifdef magick # undef magick # endif *************** *** 1481,1487 **** attr.valuemask = 0L; attr.valuemask = XpmCloseness | XpmReturnPixels | XpmColormap | XpmDepth; ! attr.closeness = 65535; /* accuracy isn't crucial */ attr.colormap = cmap; attr.depth = DefaultDepthOfScreen(scr); --- 1480,1486 ---- attr.valuemask = 0L; attr.valuemask = XpmCloseness | XpmReturnPixels | XpmColormap | XpmDepth; ! attr.closeness = 65535; // accuracy isn't crucial attr.colormap = cmap; attr.depth = DefaultDepthOfScreen(scr); *************** *** 1511,1517 **** #endif #ifdef USE_XSMP ! /* Attach listener on ICE connection */ if (-1 != xsmp_icefd) _xsmp_xtinputid = XtAppAddInput(app_context, xsmp_icefd, (XtPointer)XtInputReadMask, local_xsmp_handle_requests, NULL); --- 1510,1516 ---- #endif #ifdef USE_XSMP ! // Attach listener on ICE connection if (-1 != xsmp_icefd) _xsmp_xtinputid = XtAppAddInput(app_context, xsmp_icefd, (XtPointer)XtInputReadMask, local_xsmp_handle_requests, NULL); *************** *** 1569,1575 **** int gui_mch_open(void) { ! /* Actually open the window */ XtRealizeWidget(vimShell); XtManageChild(XtNameToWidget(vimShell, "*vimForm")); --- 1568,1574 ---- int gui_mch_open(void) { ! // Actually open the window XtRealizeWidget(vimShell); XtManageChild(XtNameToWidget(vimShell, "*vimForm")); *************** *** 1599,1605 **** #ifdef FEAT_CLIENTSERVER if (serverName == NULL && serverDelayedStartName != NULL) { ! /* This is a :gui command in a plain vim with no previous server */ commWindow = XtWindow(vimShell); (void)serverRegisterName(gui.dpy, serverDelayedStartName); } --- 1598,1604 ---- #ifdef FEAT_CLIENTSERVER if (serverName == NULL && serverDelayedStartName != NULL) { ! // This is a :gui command in a plain vim with no previous server commWindow = XtWindow(vimShell); (void)serverRegisterName(gui.dpy, serverDelayedStartName); } *************** *** 1618,1624 **** #if defined(FEAT_MENU) && defined(FEAT_GUI_ATHENA) ! /* The Athena GUI needs this again after opening the window */ gui_position_menu(); # ifdef FEAT_TOOLBAR gui_mch_set_toolbar_pos(0, gui.menu_height, gui.menu_width, --- 1617,1623 ---- #if defined(FEAT_MENU) && defined(FEAT_GUI_ATHENA) ! // The Athena GUI needs this again after opening the window gui_position_menu(); # ifdef FEAT_TOOLBAR gui_mch_set_toolbar_pos(0, gui.menu_height, gui.menu_width, *************** *** 1626,1634 **** # endif #endif ! /* Get the colors for the highlight groups (gui_check_colors() might have ! * changed them) */ ! highlight_gui_started(); /* re-init colors and fonts */ #ifdef FEAT_XIM xim_init(); --- 1625,1633 ---- # endif #endif ! // Get the colors for the highlight groups (gui_check_colors() might have ! // changed them) ! highlight_gui_started(); // re-init colors and fonts #ifdef FEAT_XIM xim_init(); *************** *** 1653,1665 **** if (XtConvertAndStore(vimShell, XtRString, &from, XtRFontSet, &to) == False) { ! /* Failed. What to do? */ } } #endif #if defined(FEAT_MENU) || defined(PROTO) ! /* Convert the menu font/fontset name to an XFontStruct/XFontset */ void gui_init_menu_font(void) { --- 1652,1664 ---- if (XtConvertAndStore(vimShell, XtRString, &from, XtRFontSet, &to) == False) { ! // Failed. What to do? } } #endif #if defined(FEAT_MENU) || defined(PROTO) ! // Convert the menu font/fontset name to an XFontStruct/XFontset void gui_init_menu_font(void) { *************** *** 1673,1679 **** if (XtConvertAndStore(vimShell, XtRString, &from, XtRFontSet, &to) == False) { ! /* Failed. What to do? */ } #else from.addr = (char *)gui.rsrc_menu_font_name; --- 1672,1678 ---- if (XtConvertAndStore(vimShell, XtRString, &from, XtRFontSet, &to) == False) { ! // Failed. What to do? } #else from.addr = (char *)gui.rsrc_menu_font_name; *************** *** 1683,1689 **** if (XtConvertAndStore(vimShell, XtRString, &from, XtRFontStruct, &to) == False) { ! /* Failed. What to do? */ } #endif } --- 1682,1688 ---- if (XtConvertAndStore(vimShell, XtRString, &from, XtRFontStruct, &to) == False) { ! // Failed. What to do? } #endif } *************** *** 1693,1700 **** gui_mch_exit(int rc UNUSED) { #if 0 ! /* Lesstif gives an error message here, and so does Solaris. The man page ! * says that this isn't needed when exiting, so just skip it. */ XtCloseDisplay(gui.dpy); #endif VIM_CLEAR(gui_argv); --- 1692,1699 ---- gui_mch_exit(int rc UNUSED) { #if 0 ! // Lesstif gives an error message here, and so does Solaris. The man page ! // says that this isn't needed when exiting, so just skip it. XtCloseDisplay(gui.dpy); #endif VIM_CLEAR(gui_argv); *************** *** 1788,1795 **** #endif #ifdef FEAT_GUI_MOTIF ! /* A font name equal "*" is indicating, that we should activate the font ! * selection dialogue to get a new font name. So let us do it here. */ if (font_name != NULL && STRCMP(font_name, "*") == 0) font_name = gui_xm_select_font(hl_get_font_name()); #endif --- 1787,1794 ---- #endif #ifdef FEAT_GUI_MOTIF ! // A font name equal "*" is indicating, that we should activate the font ! // selection dialogue to get a new font name. So let us do it here. if (font_name != NULL && STRCMP(font_name, "*") == 0) font_name = gui_xm_select_font(hl_get_font_name()); #endif *************** *** 1797,1804 **** #ifdef FEAT_XFONTSET if (do_fontset) { ! /* If 'guifontset' is set, VIM treats all font specifications as if ! * they were fontsets, and 'guifontset' becomes the default. */ if (font_name != NULL) { fontset = (XFontSet)gui_mch_get_fontset(font_name, FALSE, TRUE); --- 1796,1803 ---- #ifdef FEAT_XFONTSET if (do_fontset) { ! // If 'guifontset' is set, VIM treats all font specifications as if ! // they were fontsets, and 'guifontset' becomes the default. if (font_name != NULL) { fontset = (XFontSet)gui_mch_get_fontset(font_name, FALSE, TRUE); *************** *** 1876,1884 **** } else { ! /* When not using the font specified by the resources, also don't use ! * the bold/italic fonts, otherwise setting 'guifont' will look very ! * strange. */ if (gui.bold_font != NOFONT) { XFreeFont(gui.dpy, (XFontStruct *)gui.bold_font); --- 1875,1883 ---- } else { ! // When not using the font specified by the resources, also don't use ! // the bold/italic fonts, otherwise setting 'guifont' will look very ! // strange. if (gui.bold_font != NOFONT) { XFreeFont(gui.dpy, (XFontStruct *)gui.bold_font); *************** *** 1911,1917 **** { XFontStruct *font; ! if (!gui.in_use || name == NULL) /* can't do this when GUI not running */ return NOFONT; font = XLoadQueryFont(gui.dpy, (char *)name); --- 1910,1916 ---- { XFontStruct *font; ! if (!gui.in_use || name == NULL) // can't do this when GUI not running return NOFONT; font = XLoadQueryFont(gui.dpy, (char *)name); *************** *** 1961,1973 **** if (name != NULL && font == NULL) { ! /* In this case, there's no way other than doing this. */ ret = vim_strsave(name); } else if (font != NULL) { ! /* In this case, try to retrieve the XLFD corresponding to 'font'->fid; ! * if failed, use 'name' unless it's NULL. */ unsigned long value = 0L; if (XGetFontProperty(font, XA_FONT, &value)) --- 1960,1972 ---- if (name != NULL && font == NULL) { ! // In this case, there's no way other than doing this. ret = vim_strsave(name); } else if (font != NULL) { ! // In this case, try to retrieve the XLFD corresponding to 'font'->fid; ! // if failed, use 'name' unless it's NULL. unsigned long value = 0L; if (XGetFontProperty(font, XA_FONT, &value)) *************** *** 2141,2147 **** return FAIL; } } ! /* scan base font width */ min_width = 32767; for (i = 0; i < fn; i++) { --- 2140,2146 ---- return FAIL; } } ! // scan base font width min_width = 32767; for (i = 0; i < fn; i++) { *************** *** 2166,2172 **** return FAIL; } } ! /* it seems ok. Good Luck!! */ return OK; } --- 2165,2171 ---- return FAIL; } } ! // it seems ok. Good Luck!! return OK; } *************** *** 2202,2208 **** } #endif ! /* NOT USED YET static int fontset_descent(XFontSet fs) { --- 2201,2208 ---- } #endif ! #if 0 ! // NOT USED YET static int fontset_descent(XFontSet fs) { *************** *** 2211,2217 **** extents = XExtentsOfFontSet (fs); return extents->max_logical_extent.height + extents->max_logical_extent.y; } ! */ static int fontset_ascent(XFontSet fs) --- 2211,2217 ---- extents = XExtentsOfFontSet (fs); return extents->max_logical_extent.height + extents->max_logical_extent.y; } ! #endif static int fontset_ascent(XFontSet fs) *************** *** 2222,2228 **** return -extents->max_logical_extent.y; } ! #endif /* FEAT_XFONTSET */ /* * Return the Pixel value (color) for the given color name. --- 2222,2228 ---- return -extents->max_logical_extent.y; } ! #endif // FEAT_XFONTSET /* * Return the Pixel value (color) for the given color name. *************** *** 2233,2239 **** { guicolor_T requested; ! /* can't do this when GUI not running */ if (!gui.in_use || name == NULL || *name == NUL) return INVALCOLOR; --- 2233,2239 ---- { guicolor_T requested; ! // can't do this when GUI not running if (!gui.in_use || name == NULL || *name == NUL) return INVALCOLOR; *************** *** 2257,2270 **** XColor available; Colormap colormap; ! /* Using XParseColor() is very slow, put rgb in XColor directly. char spec[8]; // space enough to hold "#RRGGBB" vim_snprintf(spec, sizeof(spec), "#%.2x%.2x%.2x", r, g, b); if (XParseColor(gui.dpy, colormap, (char *)spec, &available) != 0 && XAllocColor(gui.dpy, colormap, &available) != 0) return (guicolor_T)available.pixel; ! */ colormap = DefaultColormap(gui.dpy, DefaultScreen(gui.dpy)); vim_memset(&available, 0, sizeof(XColor)); available.red = r << 8; --- 2257,2271 ---- XColor available; Colormap colormap; ! #if 0 ! // Using XParseColor() is very slow, put rgb in XColor directly. char spec[8]; // space enough to hold "#RRGGBB" vim_snprintf(spec, sizeof(spec), "#%.2x%.2x%.2x", r, g, b); if (XParseColor(gui.dpy, colormap, (char *)spec, &available) != 0 && XAllocColor(gui.dpy, colormap, &available) != 0) return (guicolor_T)available.pixel; ! #endif colormap = DefaultColormap(gui.dpy, DefaultScreen(gui.dpy)); vim_memset(&available, 0, sizeof(XColor)); available.red = r << 8; *************** *** 2362,2370 **** if (enc_utf8) { ! /* Convert UTF-8 byte sequence to 16 bit characters for the X ! * functions. Need a buffer for the 16 bit characters. Keep it ! * between calls, because allocating it each time is slow. */ if (buflen < len) { XtFree((char *)buf); --- 2363,2371 ---- if (enc_utf8) { ! // Convert UTF-8 byte sequence to 16 bit characters for the X ! // functions. Need a buffer for the 16 bit characters. Keep it ! // between calls, because allocating it each time is slow. if (buflen < len) { XtFree((char *)buf); *************** *** 2382,2388 **** { # ifdef SMALL_WCHAR_T if (c >= 0x10000) ! c = 0xbf; /* show chars > 0xffff as ? */ # endif ((wchar_t *)buf)[wlen] = c; } --- 2383,2389 ---- { # ifdef SMALL_WCHAR_T if (c >= 0x10000) ! c = 0xbf; // show chars > 0xffff as ? # endif ((wchar_t *)buf)[wlen] = c; } *************** *** 2390,2396 **** #endif { if (c >= 0x10000) ! c = 0xbf; /* show chars > 0xffff as ? */ ((XChar2b *)buf)[wlen].byte1 = (unsigned)c >> 8; ((XChar2b *)buf)[wlen].byte2 = c; } --- 2391,2397 ---- #endif { if (c >= 0x10000) ! c = 0xbf; // show chars > 0xffff as ? ((XChar2b *)buf)[wlen].byte1 = (unsigned)c >> 8; ((XChar2b *)buf)[wlen].byte2 = c; } *************** *** 2412,2420 **** #ifdef FEAT_XFONTSET if (current_fontset != NULL) { ! /* Setup a clip rectangle to avoid spilling over in the next or ! * previous line. This is apparently needed for some fonts which are ! * used in a fontset. */ XRectangle clip; clip.x = 0; --- 2413,2421 ---- #ifdef FEAT_XFONTSET if (current_fontset != NULL) { ! // Setup a clip rectangle to avoid spilling over in the next or ! // previous line. This is apparently needed for some fonts which are ! // used in a fontset. XRectangle clip; clip.x = 0; *************** *** 2455,2461 **** } else { ! /* XmbDrawImageString has bug, don't use it for fontset. */ if (enc_utf8) XDrawImageString16(gui.dpy, gui.wid, gui.text_gc, TEXT_X(col), TEXT_Y(row), buf, wlen); --- 2456,2462 ---- } else { ! // XmbDrawImageString has bug, don't use it for fontset. if (enc_utf8) XDrawImageString16(gui.dpy, gui.wid, gui.text_gc, TEXT_X(col), TEXT_Y(row), buf, wlen); *************** *** 2464,2470 **** TEXT_Y(row), (char *)s, len); } ! /* Bold trick: draw the text again with a one-pixel offset. */ if (flags & DRAW_BOLD) { if (enc_utf8) --- 2465,2471 ---- TEXT_Y(row), (char *)s, len); } ! // Bold trick: draw the text again with a one-pixel offset. if (flags & DRAW_BOLD) { if (enc_utf8) *************** *** 2475,2491 **** TEXT_Y(row), (char *)s, len); } ! /* Undercurl: draw curl at the bottom of the character cell. */ if (flags & DRAW_UNDERC) draw_curl(row, col, cells); ! /* Underline: draw a line at the bottom of the character cell. */ if (flags & DRAW_UNDERL) { int y = FILL_Y(row + 1) - 1; ! /* When p_linespace is 0, overwrite the bottom row of pixels. ! * Otherwise put the line just below the character. */ if (p_linespace > 1) y -= p_linespace - 1; XDrawLine(gui.dpy, gui.wid, gui.text_gc, FILL_X(col), --- 2476,2492 ---- TEXT_Y(row), (char *)s, len); } ! // Undercurl: draw curl at the bottom of the character cell. if (flags & DRAW_UNDERC) draw_curl(row, col, cells); ! // Underline: draw a line at the bottom of the character cell. if (flags & DRAW_UNDERL) { int y = FILL_Y(row + 1) - 1; ! // When p_linespace is 0, overwrite the bottom row of pixels. ! // Otherwise put the line just below the character. if (p_linespace > 1) y -= p_linespace - 1; XDrawLine(gui.dpy, gui.wid, gui.text_gc, FILL_X(col), *************** *** 2543,2554 **** void gui_mch_flash(int msec) { ! /* Do a visual beep by reversing the foreground and background colors */ XFillRectangle(gui.dpy, gui.wid, gui.invert_gc, 0, 0, FILL_X((int)Columns) + gui.border_offset, FILL_Y((int)Rows) + gui.border_offset); XSync(gui.dpy, False); ! ui_delay((long)msec, TRUE); /* wait for a few msec */ XFillRectangle(gui.dpy, gui.wid, gui.invert_gc, 0, 0, FILL_X((int)Columns) + gui.border_offset, FILL_Y((int)Rows) + gui.border_offset); --- 2544,2555 ---- void gui_mch_flash(int msec) { ! // Do a visual beep by reversing the foreground and background colors XFillRectangle(gui.dpy, gui.wid, gui.invert_gc, 0, 0, FILL_X((int)Columns) + gui.border_offset, FILL_Y((int)Rows) + gui.border_offset); XSync(gui.dpy, False); ! ui_delay((long)msec, TRUE); // wait for a few msec XFillRectangle(gui.dpy, gui.wid, gui.invert_gc, 0, 0, FILL_X((int)Columns) + gui.border_offset, FILL_Y((int)Rows) + gui.border_offset); *************** *** 2614,2620 **** XFillRectangle(gui.dpy, gui.wid, gui.text_gc, #ifdef FEAT_RIGHTLEFT ! /* vertical line should be on the right of current point */ CURSOR_BAR_RIGHT ? FILL_X(gui.col + 1) - w : #endif FILL_X(gui.col), --- 2615,2621 ---- XFillRectangle(gui.dpy, gui.wid, gui.text_gc, #ifdef FEAT_RIGHTLEFT ! // vertical line should be on the right of current point CURSOR_BAR_RIGHT ? FILL_X(gui.col + 1) - w : #endif FILL_X(gui.col), *************** *** 2677,2684 **** (long_u)(wtime == 0 ? 1L : wtime), gui_x11_timer_cb, &timed_out); #ifdef FEAT_JOB_CHANNEL ! /* If there is a channel with the keep_open flag we need to poll for input ! * on them. */ if (channel_any_keep_open()) channel_timer = XtAppAddTimeOut(app_context, (long_u)20, channel_poll_cb, (XtPointer)&channel_timer); --- 2678,2685 ---- (long_u)(wtime == 0 ? 1L : wtime), gui_x11_timer_cb, &timed_out); #ifdef FEAT_JOB_CHANNEL ! // If there is a channel with the keep_open flag we need to poll for input ! // on them. if (channel_any_keep_open()) channel_timer = XtAppAddTimeOut(app_context, (long_u)20, channel_poll_cb, (XtPointer)&channel_timer); *************** *** 2688,2694 **** desired = (XtIMAll); while (!timed_out) { ! /* Stop or start blinking when focus changes */ if (gui.in_focus != focus) { if (gui.in_focus) --- 2689,2695 ---- desired = (XtIMAll); while (!timed_out) { ! // Stop or start blinking when focus changes if (gui.in_focus != focus) { if (gui.in_focus) *************** *** 2705,2711 **** parse_queued_messages(); # ifdef FEAT_TIMERS if (did_add_timer) ! /* Need to recompute the waiting time. */ break; # endif #endif --- 2706,2712 ---- parse_queued_messages(); # ifdef FEAT_TIMERS if (did_add_timer) ! // Need to recompute the waiting time. break; # endif #endif *************** *** 2741,2747 **** * Output routines. */ ! /* Flush any output to the screen */ void gui_mch_flush(void) { --- 2742,2750 ---- * Output routines. */ ! /* ! * Flush any output to the screen ! */ void gui_mch_flush(void) { *************** *** 2763,2770 **** x = FILL_X(col1); ! /* Clear one extra pixel at the far right, for when bold characters have ! * spilled over to the next column. */ XFillRectangle(gui.dpy, gui.wid, gui.back_gc, x, FILL_Y(row1), (col2 - col1 + 1) * gui.char_width + (col2 == Columns - 1), (row2 - row1 + 1) * gui.char_height); --- 2766,2773 ---- x = FILL_X(col1); ! // Clear one extra pixel at the far right, for when bold characters have ! // spilled over to the next column. XFillRectangle(gui.dpy, gui.wid, gui.back_gc, x, FILL_Y(row1), (col2 - col1 + 1) * gui.char_width + (col2 == Columns - 1), (row2 - row1 + 1) * gui.char_height); *************** *** 2784,2793 **** gui_mch_delete_lines(int row, int num_lines) { if (gui.visibility == VisibilityFullyObscured) ! return; /* Can't see the window */ ! /* copy one extra pixel at the far right, for when bold has spilled ! * over */ XCopyArea(gui.dpy, gui.wid, gui.wid, gui.text_gc, FILL_X(gui.scroll_region_left), FILL_Y(row + num_lines), gui.char_width * (gui.scroll_region_right - gui.scroll_region_left + 1) --- 2787,2796 ---- gui_mch_delete_lines(int row, int num_lines) { if (gui.visibility == VisibilityFullyObscured) ! return; // Can't see the window ! // copy one extra pixel at the far right, for when bold has spilled ! // over XCopyArea(gui.dpy, gui.wid, gui.wid, gui.text_gc, FILL_X(gui.scroll_region_left), FILL_Y(row + num_lines), gui.char_width * (gui.scroll_region_right - gui.scroll_region_left + 1) *************** *** 2809,2818 **** gui_mch_insert_lines(int row, int num_lines) { if (gui.visibility == VisibilityFullyObscured) ! return; /* Can't see the window */ ! /* copy one extra pixel at the far right, for when bold has spilled ! * over */ XCopyArea(gui.dpy, gui.wid, gui.wid, gui.text_gc, FILL_X(gui.scroll_region_left), FILL_Y(row), gui.char_width * (gui.scroll_region_right - gui.scroll_region_left + 1) --- 2812,2821 ---- gui_mch_insert_lines(int row, int num_lines) { if (gui.visibility == VisibilityFullyObscured) ! return; // Can't see the window ! // copy one extra pixel at the far right, for when bold has spilled ! // over XCopyArea(gui.dpy, gui.wid, gui.wid, gui.text_gc, FILL_X(gui.scroll_region_left), FILL_Y(row), gui.char_width * (gui.scroll_region_right - gui.scroll_region_left + 1) *************** *** 2839,2856 **** XFlush(gui.dpy); ! /* Wait to check whether the scroll worked or not */ for (;;) { if (XCheckTypedEvent(gui.dpy, NoExpose, &event)) ! return; /* The scroll worked. */ if (XCheckTypedEvent(gui.dpy, GraphicsExpose, &event)) { gevent = (XGraphicsExposeEvent *)&event; gui_redraw(gevent->x, gevent->y, gevent->width, gevent->height); if (gevent->count == 0) ! return; /* This was the last expose event */ } XSync(gui.dpy, False); } --- 2842,2859 ---- XFlush(gui.dpy); ! // Wait to check whether the scroll worked or not for (;;) { if (XCheckTypedEvent(gui.dpy, NoExpose, &event)) ! return; // The scroll worked. if (XCheckTypedEvent(gui.dpy, GraphicsExpose, &event)) { gevent = (XGraphicsExposeEvent *)&event; gui_redraw(gevent->x, gevent->y, gevent->width, gevent->height); if (gevent->count == 0) ! return; // This was the last expose event } XSync(gui.dpy, False); } *************** *** 2931,2937 **** void gui_mch_draw_menubar(void) { ! /* Nothing to do in X */ } void --- 2934,2940 ---- void gui_mch_draw_menubar(void) { ! // Nothing to do in X } void *************** *** 2943,2949 **** gui_menu_cb((vimmenu_T *)client_data); } ! #endif /* FEAT_MENU */ --- 2946,2952 ---- gui_menu_cb((vimmenu_T *)client_data); } ! #endif // FEAT_MENU *************** *** 2973,2983 **** wm_atoms[SAVE_YOURSELF_IDX]) { out_flush(); ! ml_sync_all(FALSE, FALSE); /* preserve all swap files */ ! /* Set the window's WM_COMMAND property, to let the window manager ! * know we are done saving ourselves. We don't want to be restarted, ! * thus set argv to NULL. */ XSetCommand(gui.dpy, XtWindow(vimShell), NULL, 0); return; } --- 2976,2986 ---- wm_atoms[SAVE_YOURSELF_IDX]) { out_flush(); ! ml_sync_all(FALSE, FALSE); // preserve all swap files ! // Set the window's WM_COMMAND property, to let the window manager ! // know we are done saving ourselves. We don't want to be restarted, ! // thus set argv to NULL. XSetCommand(gui.dpy, XtWindow(vimShell), NULL, 0); return; } *************** *** 3093,3099 **** { if (blink_timer != (XtIntervalId)0) XtRemoveTimeOut(blink_timer); ! /* Only switch blinking on if none of the times is zero */ if (blink_waittime && blink_ontime && blink_offtime && gui.in_focus) { blink_timer = XtAppAddTimeOut(app_context, blink_waittime, --- 3096,3102 ---- { if (blink_timer != (XtIntervalId)0) XtRemoveTimeOut(blink_timer); ! // Only switch blinking on if none of the times is zero if (blink_waittime && blink_ontime && blink_offtime && gui.in_focus) { blink_timer = XtAppAddTimeOut(app_context, blink_waittime, *************** *** 3158,3164 **** XtAddEventHandler(textArea, KeyPressMask, FALSE, gui_x11_key_hit_cb, (XtPointer)0); ! /* get pointer moved events from scrollbar, needed for 'mousefocus' */ XtAddEventHandler(vimForm, PointerMotionMask, FALSE, gui_x11_mouse_cb, (XtPointer)1); XtAddEventHandler(textArea, ButtonPressMask | ButtonReleaseMask | --- 3161,3167 ---- XtAddEventHandler(textArea, KeyPressMask, FALSE, gui_x11_key_hit_cb, (XtPointer)0); ! // get pointer moved events from scrollbar, needed for 'mousefocus' XtAddEventHandler(vimForm, PointerMotionMask, FALSE, gui_x11_mouse_cb, (XtPointer)1); XtAddEventHandler(textArea, ButtonPressMask | ButtonReleaseMask | *************** *** 3203,3210 **** #if defined(FEAT_SIGN_ICONS) || defined(PROTO) ! /* Signs are currently always 2 chars wide. Hopefully the font is big enough ! * to provide room for the bitmap! */ # define SIGN_WIDTH (gui.char_width * 2) void --- 3206,3213 ---- #if defined(FEAT_SIGN_ICONS) || defined(PROTO) ! // Signs are currently always 2 chars wide. Hopefully the font is big enough ! // to provide room for the bitmap! # define SIGN_WIDTH (gui.char_width * 2) void *************** *** 3252,3260 **** &sign, NULL, &attrs); if (status == 0) { ! /* Sign width is fixed at two columns now. ! if (sign->width > gui.sign_width) ! gui.sign_width = sign->width + 8; */ } else emsg(_(e_signdata)); --- 3255,3263 ---- &sign, NULL, &attrs); if (status == 0) { ! // Sign width is fixed at two columns now. ! // if (sign->width > gui.sign_width) ! // gui.sign_width = sign->width + 8; } else emsg(_(e_signdata)); *************** *** 3272,3279 **** #ifdef FEAT_MOUSESHAPE ! /* The last set mouse pointer shape is remembered, to be used when it goes ! * from hidden to not hidden. */ static int last_shape = 0; #endif --- 3275,3282 ---- #ifdef FEAT_MOUSESHAPE ! // The last set mouse pointer shape is remembered, to be used when it goes ! // from hidden to not hidden. static int last_shape = 0; #endif *************** *** 3282,3288 **** */ void gui_mch_mousehide( ! int hide) /* TRUE = use blank ptr, FALSE = use parent ptr */ { if (gui.pointer_hidden != hide) { --- 3285,3291 ---- */ void gui_mch_mousehide( ! int hide) // TRUE = use blank ptr, FALSE = use parent ptr { if (gui.pointer_hidden != hide) { *************** *** 3300,3326 **** #if defined(FEAT_MOUSESHAPE) || defined(PROTO) ! /* Table for shape IDs. Keep in sync with the mshape_names[] table in ! * misc2.c! */ static int mshape_ids[] = { ! XC_left_ptr, /* arrow */ ! 0, /* blank */ ! XC_xterm, /* beam */ ! XC_sb_v_double_arrow, /* updown */ ! XC_sizing, /* udsizing */ ! XC_sb_h_double_arrow, /* leftright */ ! XC_sizing, /* lrsizing */ ! XC_watch, /* busy */ ! XC_X_cursor, /* no */ ! XC_crosshair, /* crosshair */ ! XC_hand1, /* hand1 */ ! XC_hand2, /* hand2 */ ! XC_pencil, /* pencil */ ! XC_question_arrow, /* question */ ! XC_right_ptr, /* right-arrow */ ! XC_center_ptr, /* up-arrow */ ! XC_left_ptr /* last one */ }; void --- 3303,3329 ---- #if defined(FEAT_MOUSESHAPE) || defined(PROTO) ! // Table for shape IDs. Keep in sync with the mshape_names[] table in ! // misc2.c! static int mshape_ids[] = { ! XC_left_ptr, // arrow ! 0, // blank ! XC_xterm, // beam ! XC_sb_v_double_arrow, // updown ! XC_sizing, // udsizing ! XC_sb_h_double_arrow, // leftright ! XC_sizing, // lrsizing ! XC_watch, // busy ! XC_X_cursor, // no ! XC_crosshair, // crosshair ! XC_hand1, // hand1 ! XC_hand2, // hand2 ! XC_pencil, // pencil ! XC_question_arrow, // question ! XC_right_ptr, // right-arrow ! XC_center_ptr, // up-arrow ! XC_left_ptr // last one }; void *************** *** 3341,3347 **** if (id >= XC_num_glyphs) id = XC_left_ptr; else ! id &= ~1; /* they are always even (why?) */ } else id = mshape_ids[shape]; --- 3344,3350 ---- if (id >= XC_num_glyphs) id = XC_left_ptr; else ! id &= ~1; // they are always even (why?) } else id = mshape_ids[shape]; *************** *** 3365,3372 **** if (menu->id != NULL && menu->parent != NULL && menu_is_toolbar(menu->parent->name)) { ! /* Always destroy and create the balloon, in case the string was ! * changed. */ if (menu->tip != NULL) { gui_mch_destroy_beval_area(menu->tip); --- 3368,3375 ---- if (menu->id != NULL && menu->parent != NULL && menu_is_toolbar(menu->parent->name)) { ! // Always destroy and create the balloon, in case the string was ! // changed. if (menu->tip != NULL) { gui_mch_destroy_beval_area(menu->tip); *** ../vim-8.1.2382/src/gui_xmdlg.c 2017-02-25 15:53:35.000000000 +0100 --- src/gui_xmdlg.c 2019-12-02 22:47:38.970922048 +0100 *************** *** 46,54 **** # define apply_fontlist(w) #endif ! /**************************************************************************** ! * Font selection dialogue implementation. ! */ static char wild[3] = "*"; --- 46,53 ---- # define apply_fontlist(w) #endif ! ///////////////////////////////////////////////////////////////////////////// ! // Font selection dialogue implementation. static char wild[3] = "*"; *************** *** 68,77 **** static Atom dw_atom = 0; Display *display = XtDisplay(shell); ! /* deactivate the built-in delete response of killing the application */ XtVaSetValues(shell, XmNdeleteResponse, XmDO_NOTHING, NULL); ! /* add a delete window protocol callback instead */ if (!dw_atom) { wmp_atom = XmInternAtom(display, "WM_PROTOCOLS", True); --- 67,76 ---- static Atom dw_atom = 0; Display *display = XtDisplay(shell); ! // deactivate the built-in delete response of killing the application XtVaSetValues(shell, XmNdeleteResponse, XmDO_NOTHING, NULL); ! // add a delete window protocol callback instead if (!dw_atom) { wmp_atom = XmInternAtom(display, "WM_PROTOCOLS", True); *************** *** 105,118 **** Widget list[NONE]; Widget name; Widget sample; ! char **names; /* font name array of arrays */ ! int num; /* number of font names */ ! String sel[NONE]; /* selection category */ ! Boolean in_pixels; /* toggle state - size in pixels */ ! char *font_name; /* current font name */ ! XFontStruct *old; /* font data structure for sample display */ ! XmFontList old_list; /* font data structure for sample display */ ! Boolean exit; /* used for program exit control */ } SharedFontSelData; /* --- 104,117 ---- Widget list[NONE]; Widget name; Widget sample; ! char **names; // font name array of arrays ! int num; // number of font names ! String sel[NONE]; // selection category ! Boolean in_pixels; // toggle state - size in pixels ! char *font_name; // current font name ! XFontStruct *old; // font data structure for sample display ! XmFontList old_list; // font data structure for sample display ! Boolean exit; // used for program exit control } SharedFontSelData; /* *************** *** 121,127 **** static char * fn(SharedFontSelData *data, int i) { ! /* Assertion checks: */ if (data->num < 0) abort(); if (i >= data->num) --- 120,126 ---- static char * fn(SharedFontSelData *data, int i) { ! // Assertion checks: if (data->num < 0) abort(); if (i >= data->num) *************** *** 279,292 **** if (*count == MAX_ENTRIES_IN_LIST) return; ! /* avoid duplication */ for (i = 0; i < *count; ++i) { if (!strcmp(buf[i], item)) return; } ! /* find order place, but make sure that wild card comes first */ if (!strcmp(item, wild)) i = 0; else --- 278,291 ---- if (*count == MAX_ENTRIES_IN_LIST) return; ! // avoid duplication for (i = 0; i < *count; ++i) { if (!strcmp(buf[i], item)) return; } ! // find order place, but make sure that wild card comes first if (!strcmp(item, wild)) i = 0; else *************** *** 294,300 **** if (strcmp(buf[i], item) > 0 && strcmp(buf[i], wild)) break; ! /* now insert the item */ for (j = *count; j > i; --j) buf[j] = buf[j-1]; buf[i] = XtNewString(item); --- 293,299 ---- if (strcmp(buf[i], item) > 0 && strcmp(buf[i], wild)) break; ! // now insert the item for (j = *count; j > i; --j) buf[j] = buf[j-1]; buf[i] = XtNewString(item); *************** *** 310,321 **** { char buf[TEMP_BUF_SIZE]; ! /* An empty selection or a wild card matches anything. ! */ if (!data->sel[l] || !strcmp(data->sel[l], wild)) return True; ! /* chunk out the desired part... */ switch (l) { case ENCODING: --- 309,319 ---- { char buf[TEMP_BUF_SIZE]; ! // An empty selection or a wild card matches anything. if (!data->sel[l] || !strcmp(data->sel[l], wild)) return True; ! // chunk out the desired part... switch (l) { case ENCODING: *************** *** 337,343 **** ; } ! /* ...and chew it now */ return !strcmp(buf, data->sel[l]); } --- 335,341 ---- ; } ! // ...and chew it now return !strcmp(buf, data->sel[l]); } *************** *** 374,380 **** for (idx = (int)ENCODING; idx < (int)NONE; ++idx) count[idx] = 0; ! /* First we insert the wild char into every single list. */ if (fix != ENCODING) add_to_list(list[ENCODING], wild, &count[ENCODING]); if (fix != NAME) --- 372,378 ---- for (idx = (int)ENCODING; idx < (int)NONE; ++idx) count[idx] = 0; ! // First we insert the wild char into every single list. if (fix != ENCODING) add_to_list(list[ENCODING], wild, &count[ENCODING]); if (fix != NAME) *************** *** 436,442 **** WidgetList children; Widget selected_button = 0; ! /* Get and update the current button list. */ XtVaGetValues(data->encoding_pulldown, XmNchildren, &children, XmNnumChildren, &n_items, --- 434,440 ---- WidgetList children; Widget selected_button = 0; ! // Get and update the current button list. XtVaGetValues(data->encoding_pulldown, XmNchildren, &children, XmNnumChildren, &n_items, *************** *** 450,456 **** if (i < (int)n_items) { ! /* recycle old button */ XtVaSetValues(children[i], XmNlabelString, items[i], XmNuserData, i, --- 448,454 ---- if (i < (int)n_items) { ! // recycle old button XtVaSetValues(children[i], XmNlabelString, items[i], XmNuserData, i, *************** *** 459,465 **** } else { ! /* create a new button */ button = XtVaCreateManagedWidget("button", xmPushButtonGadgetClass, data->encoding_pulldown, --- 457,463 ---- } else { ! // create a new button button = XtVaCreateManagedWidget("button", xmPushButtonGadgetClass, data->encoding_pulldown, *************** *** 479,494 **** XtFree(list[ENCODING][i]); } ! /* Destroy all the outstanding menu items. ! */ for (i = count[ENCODING]; i < (int)n_items; ++i) { XtUnmanageChild(children[i]); XtDestroyWidget(children[i]); } ! /* Preserve the current selection visually. ! */ if (selected_button) { XtVaSetValues(data->encoding_menu, --- 477,490 ---- XtFree(list[ENCODING][i]); } ! // Destroy all the outstanding menu items. for (i = count[ENCODING]; i < (int)n_items; ++i) { XtUnmanageChild(children[i]); XtDestroyWidget(children[i]); } ! // Preserve the current selection visually. if (selected_button) { XtVaSetValues(data->encoding_menu, *************** *** 522,528 **** w = data->list[SIZE]; break; default: ! w = (Widget)0; /* for lint */ } for (i = 0; i < count[idx]; ++i) --- 518,524 ---- w = data->list[SIZE]; break; default: ! w = (Widget)0; // for lint } for (i = 0; i < count[idx]; ++i) *************** *** 635,641 **** { if (!strcmp(data->sel[which], sel)) { ! /* unselecting current selection */ XtFree(data->sel[which]); data->sel[which] = NULL; if (w) --- 631,637 ---- { if (!strcmp(data->sel[which], sel)) { ! // unselecting current selection XtFree(data->sel[which]); data->sel[which] = NULL; if (w) *************** *** 651,657 **** fill_lists(which, data); ! /* If there is a font selection, we display it. */ if (data->sel[ENCODING] && data->sel[NAME] && data->sel[STYLE] --- 647,653 ---- fill_lists(which, data); ! // If there is a font selection, we display it. if (data->sel[ENCODING] && data->sel[NAME] && data->sel[STYLE] *************** *** 904,914 **** data->old = XLoadQueryFont(XtDisplay(parent), big_font); data->old_list = gui_motif_create_fontlist(data->old); ! /* Set the title of the Dialog window. */ data->dialog = XmCreateDialogShell(parent, "fontSelector", NULL, 0); str = XmStringCreateLocalized(_("Vim - Font Selector")); ! /* Create form popup dialog widget. */ form = XtVaCreateWidget("form", xmFormWidgetClass, data->dialog, XmNdialogTitle, str, --- 900,910 ---- data->old = XLoadQueryFont(XtDisplay(parent), big_font); data->old_list = gui_motif_create_fontlist(data->old); ! // Set the title of the Dialog window. data->dialog = XmCreateDialogShell(parent, "fontSelector", NULL, 0); str = XmStringCreateLocalized(_("Vim - Font Selector")); ! // Create form popup dialog widget. form = XtVaCreateWidget("form", xmFormWidgetClass, data->dialog, XmNdialogTitle, str, *************** *** 948,954 **** NULL); apply_fontlist(data->cancel); ! /* Create the separator for beauty. */ n = 0; XtSetArg(args[n], XmNorientation, XmVERTICAL); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++; --- 944,950 ---- NULL); apply_fontlist(data->cancel); ! // Create the separator for beauty. n = 0; XtSetArg(args[n], XmNorientation, XmVERTICAL); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++; *************** *** 959,965 **** separator = XmCreateSeparatorGadget(form, "separator", args, n); XtManageChild(separator); ! /* Create font name text widget and the corresponding label. */ data->name = XtVaCreateManagedWidget("fontName", xmTextWidgetClass, form, XmNbottomAttachment, XmATTACH_FORM, --- 955,961 ---- separator = XmCreateSeparatorGadget(form, "separator", args, n); XtManageChild(separator); ! // Create font name text widget and the corresponding label. data->name = XtVaCreateManagedWidget("fontName", xmTextWidgetClass, form, XmNbottomAttachment, XmATTACH_FORM, *************** *** 989,995 **** XmStringFree(str); apply_fontlist(name); ! /* create sample display label widget */ disp_frame = XtVaCreateManagedWidget("sampleFrame", xmFrameWidgetClass, form, XmNshadowType, XmSHADOW_ETCHED_IN, --- 985,991 ---- XmStringFree(str); apply_fontlist(name); ! // create sample display label widget disp_frame = XtVaCreateManagedWidget("sampleFrame", xmFrameWidgetClass, form, XmNshadowType, XmSHADOW_ETCHED_IN, *************** *** 1014,1020 **** XmNfontList, data->old_list, NULL); ! /* create toggle button */ str = XmStringCreateLocalized(_("Show size in Points")); size_toggle = XtVaCreateManagedWidget("sizeToggle", xmToggleButtonGadgetClass, form, --- 1010,1016 ---- XmNfontList, data->old_list, NULL); ! // create toggle button str = XmStringCreateLocalized(_("Show size in Points")); size_toggle = XtVaCreateManagedWidget("sizeToggle", xmToggleButtonGadgetClass, form, *************** *** 1029,1036 **** apply_fontlist(size_toggle); XtManageChild(size_toggle); ! /* Encoding pulldown menu. ! */ data->encoding_pulldown = XmCreatePulldownMenu(form, "encodingPulldown", NULL, 0); --- 1025,1031 ---- apply_fontlist(size_toggle); XtManageChild(size_toggle); ! // Encoding pulldown menu. data->encoding_pulldown = XmCreatePulldownMenu(form, "encodingPulldown", NULL, 0); *************** *** 1070,1076 **** XmNorientation, XmVERTICAL, NULL); ! /* font list */ frame = XtVaCreateManagedWidget("frame", xmFrameWidgetClass, sub_form, XmNshadowThickness, 0, XmNtopAttachment, XmATTACH_FORM, --- 1065,1071 ---- XmNorientation, XmVERTICAL, NULL); ! // font list frame = XtVaCreateManagedWidget("frame", xmFrameWidgetClass, sub_form, XmNshadowThickness, 0, XmNtopAttachment, XmATTACH_FORM, *************** *** 1101,1107 **** data->list[NAME] = XmCreateScrolledList(frame, "fontList", args, n); XtVaSetValues(name, XmNuserData, data->list[NAME], NULL); ! /* style list */ frame = XtVaCreateManagedWidget("frame", xmFrameWidgetClass, sub_form, XmNshadowThickness, 0, XmNtopAttachment, XmATTACH_FORM, --- 1096,1102 ---- data->list[NAME] = XmCreateScrolledList(frame, "fontList", args, n); XtVaSetValues(name, XmNuserData, data->list[NAME], NULL); ! // style list frame = XtVaCreateManagedWidget("frame", xmFrameWidgetClass, sub_form, XmNshadowThickness, 0, XmNtopAttachment, XmATTACH_FORM, *************** *** 1134,1140 **** data->list[STYLE] = XmCreateScrolledList(frame, "styleList", args, n); XtVaSetValues(name, XmNuserData, data->list[STYLE], NULL); ! /* size list */ frame = XtVaCreateManagedWidget("frame", xmFrameWidgetClass, sub_form, XmNshadowThickness, 0, XmNtopAttachment, XmATTACH_FORM, --- 1129,1135 ---- data->list[STYLE] = XmCreateScrolledList(frame, "styleList", args, n); XtVaSetValues(name, XmNuserData, data->list[STYLE], NULL); ! // size list frame = XtVaCreateManagedWidget("frame", xmFrameWidgetClass, sub_form, XmNshadowThickness, 0, XmNtopAttachment, XmATTACH_FORM, *************** *** 1166,1172 **** data->list[SIZE] = XmCreateScrolledList(frame, "sizeList", args, n); XtVaSetValues(name, XmNuserData, data->list[SIZE], NULL); ! /* update form widgets cancel button */ XtVaSetValues(form, XmNcancelButton, data->cancel, NULL); XtAddCallback(size_toggle, XmNvalueChangedCallback, --- 1161,1167 ---- data->list[SIZE] = XmCreateScrolledList(frame, "sizeList", args, n); XtVaSetValues(name, XmNuserData, data->list[SIZE], NULL); ! // update form widgets cancel button XtVaSetValues(form, XmNcancelButton, data->cancel, NULL); XtAddCallback(size_toggle, XmNvalueChangedCallback, *************** *** 1184,1190 **** XmProcessTraversal(data->list[NAME], XmTRAVERSE_CURRENT); ! /* setup tabgroups */ XmAddTabGroup(data->list[NAME]); XmAddTabGroup(data->list[STYLE]); --- 1179,1185 ---- XmProcessTraversal(data->list[NAME], XmTRAVERSE_CURRENT); ! // setup tabgroups XmAddTabGroup(data->list[NAME]); XmAddTabGroup(data->list[STYLE]); *************** *** 1196,1202 **** add_cancel_action(data->dialog, (XtCallbackProc)cancel_callback, data); ! /* Preset selection data. */ data->exit = False; data->in_pixels= True; --- 1191,1197 ---- add_cancel_action(data->dialog, (XtCallbackProc)cancel_callback, data); ! // Preset selection data. data->exit = False; data->in_pixels= True; *************** *** 1206,1212 **** data->sel[SIZE] = NULL; data->font_name = NULL; ! /* set up current font parameters */ if (current && current[0] != '\0') { int i; --- 1201,1207 ---- data->sel[SIZE] = NULL; data->font_name = NULL; ! // set up current font parameters if (current && current[0] != '\0') { int i; *************** *** 1244,1257 **** } else { ! /* We can't preset a symbolic name, which isn't a full font ! * description. Therefore we just behave the same way as if the ! * user didn't have selected anything thus far. ! * ! * Unfortunately there is no known way to expand an abbreviated ! * font name. ! */ ! data->font_name = NULL; } } --- 1239,1250 ---- } else { ! // We can't preset a symbolic name, which isn't a full font ! // description. Therefore we just behave the same way as if the ! // user didn't have selected anything thus far. ! // ! // Unfortunately there is no known way to expand an abbreviated ! // font name. data->font_name = NULL; } } *************** *** 1260,1275 **** fill_lists(NONE, data); ! /* Unfortunately LessTif doesn't align the list widget's properly. I don't ! * have currently any idea how to fix this problem. ! */ XtManageChild(data->list[NAME]); XtManageChild(data->list[STYLE]); XtManageChild(data->list[SIZE]); XtManageChild(data->encoding_menu); manage_centered(form); ! /* modal event loop */ while (!data->exit) XtAppProcessEvent(XtWidgetToApplicationContext(data->dialog), (XtInputMask)XtIMAll); --- 1253,1267 ---- fill_lists(NONE, data); ! // Unfortunately LessTif doesn't align the list widget's properly. I don't ! // have currently any idea how to fix this problem. XtManageChild(data->list[NAME]); XtManageChild(data->list[STYLE]); XtManageChild(data->list[SIZE]); XtManageChild(data->encoding_menu); manage_centered(form); ! // modal event loop while (!data->exit) XtAppProcessEvent(XtWidgetToApplicationContext(data->dialog), (XtInputMask)XtIMAll); *** ../vim-8.1.2382/src/gui_xmebw.c 2019-01-17 17:13:25.920984090 +0100 --- src/gui_xmebw.c 2019-12-02 22:48:55.990591763 +0100 *************** *** 52,64 **** #include "gui_xmebwp.h" ! /* Provide some missing wrappers, which are missed from the LessTif ! * implementation. Also missing in Motif 1.2 and earlier. ! * ! * We neither use XmeGetPixmapData or _XmGetPixmapData, since with LessTif the ! * pixmap will not appear in its caches properly. We cache the interesting ! * values in XmEnhancedButtonPart instead ourself. ! */ #if defined(LESSTIF_VERSION) || (XmVersion <= 1002) # ifndef Lab_IsMenupane # define Lab_IsMenupane(w) (Lab_MenuType(w) == (int)XmMENU_POPUP || \ --- 52,63 ---- #include "gui_xmebwp.h" ! // Provide some missing wrappers, which are missed from the LessTif ! // implementation. Also missing in Motif 1.2 and earlier. ! // ! // We neither use XmeGetPixmapData or _XmGetPixmapData, since with LessTif the ! // pixmap will not appear in its caches properly. We cache the interesting ! // values in XmEnhancedButtonPart instead ourself. #if defined(LESSTIF_VERSION) || (XmVersion <= 1002) # ifndef Lab_IsMenupane # define Lab_IsMenupane(w) (Lab_MenuType(w) == (int)XmMENU_POPUP || \ *************** *** 74,80 **** * Motif internals we have to cheat around with. */ ! /* Hopefully this will never change... */ #ifndef XmFOCUS_IGNORE # define XmFOCUS_IGNORE 1<<1 #endif --- 73,79 ---- * Motif internals we have to cheat around with. */ ! // Hopefully this will never change... #ifndef XmFOCUS_IGNORE # define XmFOCUS_IGNORE 1<<1 #endif *************** *** 144,151 **** } }; ! /* This is needed to work around a bug in Lesstif 2, leaving the extension ! * NULL somehow results in getting it set to an invalid pointer. */ XmPrimitiveClassExtRec xmEnhancedButtonPrimClassExtRec = { /* next_extension */ NULL, --- 143,150 ---- } }; ! // This is needed to work around a bug in Lesstif 2, leaving the extension ! // NULL somehow results in getting it set to an invalid pointer. XmPrimitiveClassExtRec xmEnhancedButtonPrimClassExtRec = { /* next_extension */ NULL, *************** *** 160,166 **** XmEnhancedButtonClassRec xmEnhancedButtonClassRec = { { ! /* core_class fields */ /* superclass */ (WidgetClass) & xmPushButtonClassRec, /* class_name */ "XmEnhancedButton", /* widget_size */ sizeof(XmEnhancedButtonRec), --- 159,165 ---- XmEnhancedButtonClassRec xmEnhancedButtonClassRec = { { ! // core_class fields /* superclass */ (WidgetClass) & xmPushButtonClassRec, /* class_name */ "XmEnhancedButton", /* widget_size */ sizeof(XmEnhancedButtonRec), *************** *** 195,201 **** /* extension */ NULL }, ! /* primitive_class fields */ { /* border highlight */ BorderHighlight, /* border_unhighlight */ BorderUnhighlight, --- 194,200 ---- /* extension */ NULL }, ! // primitive_class fields { /* border highlight */ BorderHighlight, /* border_unhighlight */ BorderUnhighlight, *************** *** 206,212 **** /* extension */ (XtPointer)&xmEnhancedButtonPrimClassExtRec, }, ! /* label_class fields */ { /* setOverrideCallback */ XmInheritSetOverrideCallback, /* menuProcs */ XmInheritMenuProc, --- 205,211 ---- /* extension */ (XtPointer)&xmEnhancedButtonPrimClassExtRec, }, ! // label_class fields { /* setOverrideCallback */ XmInheritSetOverrideCallback, /* menuProcs */ XmInheritMenuProc, *************** *** 214,225 **** /* extension */ NULL, }, ! /* pushbutton_class record */ { /* extension */ (XtPointer) NULL, }, ! /* enhancedbutton_class fields */ { /* stipple_bitmap */ None } --- 213,224 ---- /* extension */ NULL, }, ! // pushbutton_class record { /* extension */ (XtPointer) NULL, }, ! // enhancedbutton_class fields { /* stipple_bitmap */ None } *************** *** 262,278 **** return status != 0 ? 1 : 0; } ! /* XPM */ static char * blank_xpm[] = { ! /* width height ncolors cpp [x_hot y_hot] */ "12 12 4 1 0 0", ! /* colors */ " s iconColor1 m black c #000000", ". s none m none c none", "X s topShadowColor m none c #DCDEE5", "o s bottomShadowColor m black c #5D6069", ! /* pixels */ " ..", " XXXXXXXX ..", " X....... o.", --- 261,277 ---- return status != 0 ? 1 : 0; } ! // XPM static char * blank_xpm[] = { ! // width height ncolors cpp [x_hot y_hot] "12 12 4 1 0 0", ! // colors " s iconColor1 m black c #000000", ". s none m none c none", "X s topShadowColor m none c #DCDEE5", "o s bottomShadowColor m black c #5D6069", ! // pixels " ..", " XXXXXXXX ..", " X....... o.", *************** *** 292,299 **** static void set_pixmap(XmEnhancedButtonWidget eb) { ! /* Configure defines XPMATTRIBUTES_TYPE as XpmAttributes or as ! * XpmAttributes_21, depending on what is in Xm/XpmP.h. */ XPMATTRIBUTES_TYPE attr; Pixmap sen_pix; Window root; --- 291,298 ---- static void set_pixmap(XmEnhancedButtonWidget eb) { ! // Configure defines XPMATTRIBUTES_TYPE as XpmAttributes or as ! // XpmAttributes_21, depending on what is in Xm/XpmP.h. XPMATTRIBUTES_TYPE attr; Pixmap sen_pix; Window root; *************** *** 323,330 **** int shift; GC gc; ! /* Make sure there is a default value for the pixmap. ! */ if (!data) return; --- 322,328 ---- int shift; GC gc; ! // Make sure there is a default value for the pixmap. if (!data) return; *************** *** 343,349 **** eb->enhancedbutton.highlight_pixmap = None; eb->enhancedbutton.insensitive_pixmap = None; ! /* We use dynamic colors, get them now. */ motif_get_toolbar_colors( &eb->core.background_pixel, &eb->primitive.foreground, --- 341,347 ---- eb->enhancedbutton.highlight_pixmap = None; eb->enhancedbutton.insensitive_pixmap = None; ! // We use dynamic colors, get them now. motif_get_toolbar_colors( &eb->core.background_pixel, &eb->primitive.foreground, *************** *** 351,357 **** &eb->primitive.top_shadow_color, &eb->primitive.highlight_color); ! /* Setup color substitution table. */ color[0].pixel = eb->core.background_pixel; color[1].pixel = eb->core.background_pixel; color[2].pixel = eb->core.background_pixel; --- 349,355 ---- &eb->primitive.top_shadow_color, &eb->primitive.highlight_color); ! // Setup color substitution table. color[0].pixel = eb->core.background_pixel; color[1].pixel = eb->core.background_pixel; color[2].pixel = eb->core.background_pixel; *************** *** 361,369 **** color[6].pixel = eb->primitive.highlight_color; color[7].pixel = eb->pushbutton.arm_color; ! /* Create the "sensitive" pixmap. */ attr.valuemask = XpmColorSymbols | XpmCloseness; ! attr.closeness = 65535; /* accuracy isn't crucial */ attr.colorsymbols = color; attr.numsymbols = XtNumber(color); --- 359,367 ---- color[6].pixel = eb->primitive.highlight_color; color[7].pixel = eb->pushbutton.arm_color; ! // Create the "sensitive" pixmap. attr.valuemask = XpmColorSymbols | XpmCloseness; ! attr.closeness = 65535; // accuracy isn't crucial attr.colorsymbols = color; attr.numsymbols = XtNumber(color); *************** *** 372,378 **** if (!fname || status != XpmSuccess) status = XpmCreatePixmapFromData(dpy, root, data, &pix, &mask, &attr); ! /* If something failed, we will fill in the default pixmap. */ if (status != XpmSuccess) status = XpmCreatePixmapFromData(dpy, root, blank_xpm, &pix, &mask, &attr); --- 370,376 ---- if (!fname || status != XpmSuccess) status = XpmCreatePixmapFromData(dpy, root, data, &pix, &mask, &attr); ! // If something failed, we will fill in the default pixmap. if (status != XpmSuccess) status = XpmCreatePixmapFromData(dpy, root, blank_xpm, &pix, &mask, &attr); *************** *** 381,387 **** XGetGeometry(dpy, pix, &root, &x, &y, &width, &height, &border, &depth); ! /* TODO: does the shift depend on label_location somehow? */ shift = eb->primitive.shadow_thickness / 2; if (shift < 1) --- 379,385 ---- XGetGeometry(dpy, pix, &root, &x, &y, &width, &height, &border, &depth); ! // TODO: does the shift depend on label_location somehow? shift = eb->primitive.shadow_thickness / 2; if (shift < 1) *************** *** 395,409 **** XSetClipOrigin(dpy, gc, shift, shift); XCopyArea(dpy, pix, sen_pix, gc, 0, 0, width, height, shift, shift); ! /* Create the "highlight" pixmap. */ color[4].pixel = eb->primitive.bottom_shadow_color; ! #ifdef XpmAllocColor /* SGI doesn't have it */ attr.valuemask = XpmColorSymbols | XpmCloseness | XpmAllocColor; attr.alloc_color = alloc_color; #else attr.valuemask = XpmColorSymbols | XpmCloseness; #endif ! attr.closeness = 65535; /* accuracy isn't crucial */ attr.colorsymbols = color; attr.numsymbols = XtNumber(color); --- 393,407 ---- XSetClipOrigin(dpy, gc, shift, shift); XCopyArea(dpy, pix, sen_pix, gc, 0, 0, width, height, shift, shift); ! // Create the "highlight" pixmap. color[4].pixel = eb->primitive.bottom_shadow_color; ! #ifdef XpmAllocColor // SGI doesn't have it attr.valuemask = XpmColorSymbols | XpmCloseness | XpmAllocColor; attr.alloc_color = alloc_color; #else attr.valuemask = XpmColorSymbols | XpmCloseness; #endif ! attr.closeness = 65535; // accuracy isn't crucial attr.colorsymbols = color; attr.numsymbols = XtNumber(color); *************** *** 439,453 **** XFreePixmap(dpy, pix); XFreePixmap(dpy, mask); ! /* Create the "insensitive" pixmap. */ attr.valuemask = XpmColorSymbols | XpmCloseness | XpmColorKey; ! attr.closeness = 65535; /* accuracy isn't crucial */ attr.colorsymbols = color; attr.numsymbols = sizeof(color) / sizeof(color[0]); attr.color_key = XPM_MONO; status = XpmCreatePixmapFromData(dpy, root, data, &pix, &mask, &attr); ! /* Need to create new Pixmaps with the mask applied. */ ins_pix = XCreatePixmap(dpy, root, width + shift, height + shift, depth); --- 437,451 ---- XFreePixmap(dpy, pix); XFreePixmap(dpy, mask); ! // Create the "insensitive" pixmap. attr.valuemask = XpmColorSymbols | XpmCloseness | XpmColorKey; ! attr.closeness = 65535; // accuracy isn't crucial attr.colorsymbols = color; attr.numsymbols = sizeof(color) / sizeof(color[0]); attr.color_key = XPM_MONO; status = XpmCreatePixmapFromData(dpy, root, data, &pix, &mask, &attr); ! // Need to create new Pixmaps with the mask applied. ins_pix = XCreatePixmap(dpy, root, width + shift, height + shift, depth); *************** *** 566,578 **** XtClass(eb->core.parent), XmQTspecifyUnhighlight)) != NULL) && (UnhighlightT->getUnhighlightGC != NULL)) { ! /* if unhighlight trait in parent use specified GC... */ manager_background_GC = UnhighlightT->getUnhighlightGC(eb->core.parent, (Widget) eb); } else { ! /* ...otherwise, use parent's background GC */ manager_background_GC = ((XmManagerWidget) (eb->core.parent))->manager.background_GC; } --- 564,576 ---- XtClass(eb->core.parent), XmQTspecifyUnhighlight)) != NULL) && (UnhighlightT->getUnhighlightGC != NULL)) { ! // if unhighlight trait in parent use specified GC... manager_background_GC = UnhighlightT->getUnhighlightGC(eb->core.parent, (Widget) eb); } else { ! // ...otherwise, use parent's background GC manager_background_GC = ((XmManagerWidget) (eb->core.parent))->manager.background_GC; } *************** *** 696,702 **** eb->label.pixmap = eb->pushbutton.unarm_pixmap; } else ! /* pushbutton is not armed */ eb->label.pixmap = eb->pushbutton.unarm_pixmap; } --- 694,700 ---- eb->label.pixmap = eb->pushbutton.unarm_pixmap; } else ! // pushbutton is not armed eb->label.pixmap = eb->pushbutton.unarm_pixmap; } *************** *** 758,764 **** if (eb->pushbutton.armed) return; ! /* ...so KHelp event is delivered correctly. */ _XmSetFocusFlag(XtParent(XtParent(eb)), XmFOCUS_IGNORE, TRUE); XtSetKeyboardFocus(XtParent(XtParent(eb)), (Widget) eb); _XmSetFocusFlag(XtParent(XtParent(eb)), XmFOCUS_IGNORE, FALSE); --- 756,762 ---- if (eb->pushbutton.armed) return; ! // ...so KHelp event is delivered correctly. _XmSetFocusFlag(XtParent(XtParent(eb)), XmFOCUS_IGNORE, TRUE); XtSetKeyboardFocus(XtParent(XtParent(eb)), (Widget) eb); _XmSetFocusFlag(XtParent(XtParent(eb)), XmFOCUS_IGNORE, FALSE); *************** *** 767,773 **** ((XmManagerWidget) XtParent(wid))->manager.active_child = wid; ! /* etched in menu button */ if (etched_in && !XmIsTearOffButton(eb)) { XFillRectangle(XtDisplay(eb), XtWindow(eb), --- 765,771 ---- ((XmManagerWidget) XtParent(wid))->manager.active_child = wid; ! // etched in menu button if (etched_in && !XmIsTearOffButton(eb)) { XFillRectangle(XtDisplay(eb), XtWindow(eb), *************** *** 843,849 **** if (_XmGetInDragMode((Widget)eb) && eb->pushbutton.armed ! && ( /* !ActiveTearOff || */ event->xcrossing.mode == NotifyNormal)) { eb->pushbutton.armed = FALSE; --- 841,847 ---- if (_XmGetInDragMode((Widget)eb) && eb->pushbutton.armed ! && ( // !ActiveTearOff || event->xcrossing.mode == NotifyNormal)) { eb->pushbutton.armed = FALSE; *************** *** 915,921 **** _XmCalcLabelDimensions((Widget) newtb); ! /* Find out how big the pixmap is */ if (newtb->enhancedbutton.pixmap_data && !IsNull(newtb->label.pixmap) && !IsNull(newtb->enhancedbutton.normal_pixmap)) --- 913,919 ---- _XmCalcLabelDimensions((Widget) newtb); ! // Find out how big the pixmap is if (newtb->enhancedbutton.pixmap_data && !IsNull(newtb->label.pixmap) && !IsNull(newtb->enhancedbutton.normal_pixmap)) *************** *** 958,965 **** } else { ! /* FIXME: We should calculate an drawing offset for the pixmap here to ! * adjust it. */ } #if 0 --- 956,963 ---- } else { ! // FIXME: We should calculate an drawing offset for the pixmap here to ! // adjust it. } #if 0 *************** *** 972,978 **** newtb->core.height); #endif ! /* Invoke Label's Resize procedure. */ { XtWidgetProc resize; XtProcessLock(); --- 970,976 ---- newtb->core.height); #endif ! // Invoke Label's Resize procedure. { XtWidgetProc resize; XtProcessLock(); *************** *** 994,1000 **** resize = xmLabelClassRec.core_class.resize; XtProcessUnlock(); ! /* Create a bitmap for stippling (Drawable resources are cheap). */ if (STIPPLE_BITMAP == None) { Display *dpy = XtDisplay((Widget) request); --- 992,998 ---- resize = xmLabelClassRec.core_class.resize; XtProcessUnlock(); ! // Create a bitmap for stippling (Drawable resources are cheap). if (STIPPLE_BITMAP == None) { Display *dpy = XtDisplay((Widget) request); *************** *** 1005,1019 **** } eb->enhancedbutton.doing_setvalues = False; ! /* First see what type of extended label this is. ! */ if (eb->enhancedbutton.pixmap_data) { XmString str; set_pixmap(eb); ! /* FIXME: this is not the perfect way to deal with menus, which do not ! * have any string set right now. */ str = XmStringCreateLocalized(""); XtVaSetValues((Widget) eb, XmNlabelString, str, NULL); XmStringFree(str); --- 1003,1016 ---- } eb->enhancedbutton.doing_setvalues = False; ! // First see what type of extended label this is. if (eb->enhancedbutton.pixmap_data) { XmString str; set_pixmap(eb); ! // FIXME: this is not the perfect way to deal with menus, which do not ! // have any string set right now. str = XmStringCreateLocalized(""); XtVaSetValues((Widget) eb, XmNlabelString, str, NULL); XmStringFree(str); *************** *** 1106,1112 **** /* * Artificially let the highlight appear if the mouse is over us. */ ! /* Best way to get the root window of object: */ XGetGeometry(dpy, XtWindow(cur), &root, &r_x, &r_y, &r_width, &r_height, &r_border, &r_depth); XQueryPointer(XtDisplay(cur), XtWindow(cur), &root_q, &child, --- 1103,1109 ---- /* * Artificially let the highlight appear if the mouse is over us. */ ! // Best way to get the root window of object: XGetGeometry(dpy, XtWindow(cur), &root, &r_x, &r_y, &r_width, &r_height, &r_border, &r_depth); XQueryPointer(XtDisplay(cur), XtWindow(cur), &root_q, &child, *************** *** 1133,1139 **** if (NOT_EQUAL(primitive.shadow_thickness)) { redraw = True; ! /* Don't change the pixmaps */ change = False; } --- 1130,1136 ---- if (NOT_EQUAL(primitive.shadow_thickness)) { redraw = True; ! // Don't change the pixmaps change = False; } *************** *** 1230,1239 **** { GC gc; ! /* Don't shade if the button contains a label with a pixmap, since ! * there is no variant of the label available with the needed ! * background. ! */ if (eb->pushbutton.armed && eb->pushbutton.fill_on_arm) { if (eb->label.label_type == (int)XmPIXMAP) --- 1227,1235 ---- { GC gc; ! // Don't shade if the button contains a label with a pixmap, since ! // there is no variant of the label available with the needed ! // background. if (eb->pushbutton.armed && eb->pushbutton.fill_on_arm) { if (eb->label.label_type == (int)XmPIXMAP) *************** *** 1248,1254 **** } else gc = eb->pushbutton.background_gc; ! /* really need to fill with background if not armed ? */ if (gc) XFillRectangle(XtDisplay(eb), XtWindow(eb), gc, box.x, box.y, box.width, box.height); --- 1244,1250 ---- } else gc = eb->pushbutton.background_gc; ! // really need to fill with background if not armed ? if (gc) XFillRectangle(XtDisplay(eb), XtWindow(eb), gc, box.x, box.y, box.width, box.height); *************** *** 1318,1324 **** switch (default_button_emphasis) { case XmINTERNAL_HIGHLIGHT: ! /* The call above erases the border highlighting. */ if (eb->primitive.highlight_drawn) (*(((XmPushButtonWidgetClass) XtClass (eb)) ->primitive_class.border_highlight)) ((Widget) eb) ; --- 1314,1320 ---- switch (default_button_emphasis) { case XmINTERNAL_HIGHLIGHT: ! // The call above erases the border highlighting. if (eb->primitive.highlight_drawn) (*(((XmPushButtonWidgetClass) XtClass (eb)) ->primitive_class.border_highlight)) ((Widget) eb) ; *************** *** 1368,1380 **** parent = XtParent(eb); if (XmIsManager(parent)) { ! /* Use the parent's GC so monochrome works. */ bottom_gc = XmParentTopShadowGC(eb); top_gc = XmParentBottomShadowGC(eb); } else { ! /* Use your own pixel for drawing. */ bottom_gc = eb->primitive.top_shadow_GC; top_gc = eb->primitive.bottom_shadow_GC; } --- 1364,1376 ---- parent = XtParent(eb); if (XmIsManager(parent)) { ! // Use the parent's GC so monochrome works. bottom_gc = XmParentTopShadowGC(eb); top_gc = XmParentBottomShadowGC(eb); } else { ! // Use your own pixel for drawing. bottom_gc = eb->primitive.top_shadow_GC; top_gc = eb->primitive.bottom_shadow_GC; } *************** *** 1447,1450 **** draw_pixmap(eb, NULL, NULL); } ! #endif /* FEAT_TOOLBAR */ --- 1443,1446 ---- draw_pixmap(eb, NULL, NULL); } ! #endif // FEAT_TOOLBAR *** ../vim-8.1.2382/src/version.c 2019-12-02 21:35:28.013111203 +0100 --- src/version.c 2019-12-02 22:49:16.578503493 +0100 *************** *** 744,745 **** --- 744,747 ---- { /* Add new patch number below this line */ + /**/ + 2383, /**/ -- I'm so disorganized my keyboard isn't even in alphabetical order! /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///