annotate src/gui_mac.c @ 6791:1805e45ce4d6 v7.4.717

patch 7.4.717 Problem: ":let list += list" can change a locked list. Solution: Check for the lock earlier. (Olaf Dabrunz)
author Bram Moolenaar <bram@vim.org>
date Mon, 04 May 2015 11:10:27 +0200
parents 50dbef5e774a
children 5f24d6d51333
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 * GUI/Motif support by Robert Webb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 * Macintosh port by Dany St-Amant
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 * and Axel Kielhorn
1106
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
7 * Port to MPW by Bernhard Pruemmer
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 * Initial Carbon port by Ammon Skidmore
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 * Do ":help uganda" in Vim to read copying and usage conditions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 * Do ":help credits" in Vim to see a list of people who contributed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 * See README.txt for an overview of the Vim source code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 /*
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
16 * NOTES: - Vim 7+ does not support classic MacOS. Please use Vim 6.x
856
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
17 * - Comments mentioning FAQ refer to the book:
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
18 * "Macworld Mac Programming FAQs" from "IDG Books"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 * TODO: Change still to merge from the macvim's iDisk
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 * error_ga, mch_errmsg, Navigation's changes in gui_mch_browse
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 * uses of MenuItemIndex, changes in gui_mch_set_shellsize,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 * ScrapManager error handling.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 * Comments about function remaining to Carbonize.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30
1107
2ced59eaf1e5 updated for version 7.0-233
vimboss
parents: 1106
diff changeset
31 /* TODO (Jussi)
2ced59eaf1e5 updated for version 7.0-233
vimboss
parents: 1106
diff changeset
32 * * Clipboard does not work (at least some cases)
2ced59eaf1e5 updated for version 7.0-233
vimboss
parents: 1106
diff changeset
33 * * ATSU font rendering has some problems
2ced59eaf1e5 updated for version 7.0-233
vimboss
parents: 1106
diff changeset
34 * * Investigate and remove dead code (there is still lots of that)
2ced59eaf1e5 updated for version 7.0-233
vimboss
parents: 1106
diff changeset
35 */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 #include <Devices.h> /* included first to avoid CR problems */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 #include "vim.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
40 #define USE_CARBONIZED
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
41 #define USE_AEVENT /* Enable AEVENT */
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
42 #undef USE_OFFSETED_WINDOW /* Debugging feature: start Vim window OFFSETed */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43
4352
04736b4030ec updated for version 7.3.925
Bram Moolenaar <bram@vim.org>
parents: 3935
diff changeset
44 /* Compile as CodeWarrior External Editor */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 #if defined(FEAT_CW_EDITOR) && !defined(USE_AEVENT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 # define USE_AEVENT /* Need Apple Event Support */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
49 /* Vim's Scrap flavor. */
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
50 #define VIMSCRAPFLAVOR 'VIM!'
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
51 #ifdef FEAT_MBYTE
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
52 # define SCRAPTEXTFLAVOR kScrapFlavorTypeUnicode
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
53 #else
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
54 # define SCRAPTEXTFLAVOR kScrapFlavorTypeText
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
55 #endif
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
56
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 static EventHandlerUPP mouseWheelHandlerUPP = NULL;
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
58 SInt32 gMacSystemVersion;
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
59
766
f0d0d3d3a1e2 updated for version 7.0225
vimboss
parents: 719
diff changeset
60 #ifdef MACOS_CONVERT
f0d0d3d3a1e2 updated for version 7.0225
vimboss
parents: 719
diff changeset
61 # define USE_CARBONKEYHANDLER
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
62
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
63 static int im_is_active = FALSE;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
64 #if 0
1702
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1668
diff changeset
65 /* TODO: Implement me! */
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
66 static int im_start_row = 0;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
67 static int im_start_col = 0;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
68 #endif
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
69
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
70 #define NR_ELEMS(x) (sizeof(x) / sizeof(x[0]))
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
71
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
72 static TSMDocumentID gTSMDocument;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
73
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
74 static void im_on_window_switch(int active);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
75 static EventHandlerUPP keyEventHandlerUPP = NULL;
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
76 static EventHandlerUPP winEventHandlerUPP = NULL;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
77
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
78 static pascal OSStatus gui_mac_handle_window_activate(
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
79 EventHandlerCallRef nextHandler, EventRef theEvent, void *data);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
80
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
81 static pascal OSStatus gui_mac_handle_text_input(
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
82 EventHandlerCallRef nextHandler, EventRef theEvent, void *data);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
83
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
84 static pascal OSStatus gui_mac_update_input_area(
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
85 EventHandlerCallRef nextHandler, EventRef theEvent);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
86
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
87 static pascal OSStatus gui_mac_unicode_key_event(
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
88 EventHandlerCallRef nextHandler, EventRef theEvent);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
89
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
90 #endif
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
91
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 /* Include some file. TODO: move into os_mac.h */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 #include <Menus.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 #include <Resources.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 #include <Processes.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 #ifdef USE_AEVENT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 # include <AppleEvents.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 # include <AERegistry.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 # include <Gestalt.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 #if UNIVERSAL_INTERFACES_VERSION >= 0x0330
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 # include <ControlDefinitions.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 # include <Navigation.h> /* Navigation only part of ?? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
107 /* Help Manager (balloon.h, HM prefixed functions) are not supported
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
108 * under Carbon (Jussi) */
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
109 # if 0
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 /* New Help Interface for Mac, not implemented yet.*/
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
111 # include <MacHelp.h>
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
112 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 /*
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
115 * These seem to be rectangle options. Why are they not found in
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
116 * headers? (Jussi)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 #define kNothing 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 #define kCreateEmpty 2 /*1*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 #define kCreateRect 2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 #define kDestroy 3
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 * Dany: Don't like those...
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 #define topLeft(r) (((Point*)&(r))[0])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 #define botRight(r) (((Point*)&(r))[1])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 /* Time of last mouse click, to detect double-click */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 static long lastMouseTick = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 /* ??? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 static RgnHandle cursorRgn;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 static RgnHandle dragRgn;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 static Rect dragRect;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 static short dragRectEnbl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 static short dragRectControl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 /* This variable is set when waiting for an event, which is the only moment
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 * scrollbar dragging can be done directly. It's not allowed while commands
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 * are executed, because it may move the cursor and that may cause unexpected
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 * problems (e.g., while ":s" is working).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 static int allow_scrollbar = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 /* Last mouse click caused contextual menu, (to provide proper release) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 static short clickIsPopup;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 /* Feedback Action for Scrollbar */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 ControlActionUPP gScrollAction;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 ControlActionUPP gScrollDrag;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 /* Keeping track of which scrollbar is being dragged */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 static ControlHandle dragged_sb = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156
1572
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
157 /* Vector of char_u --> control index for hotkeys in dialogs */
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
158 static short *gDialogHotKeys;
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
159
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
160 static struct
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
161 {
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
162 FMFontFamily family;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
163 FMFontSize size;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
164 FMFontStyle style;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
165 Boolean isPanelVisible;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
166 } gFontPanelInfo = { 0, 0, 0, false };
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
167
766
f0d0d3d3a1e2 updated for version 7.0225
vimboss
parents: 719
diff changeset
168 #ifdef MACOS_CONVERT
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
169 # define USE_ATSUI_DRAWING
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
170 int p_macatsui_last;
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
171 ATSUStyle gFontStyle;
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
172 # ifdef FEAT_MBYTE
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
173 ATSUStyle gWideFontStyle;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
174 # endif
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
175 Boolean gIsFontFallbackSet;
2327
02cf6d461e3f Mac: Support disabling antialias. (LC Mi)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
176 UInt32 useAntialias_cached = 0x0;
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
177 #endif
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
178
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 /* Colors Macros */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 #define RGB(r,g,b) ((r) << 16) + ((g) << 8) + (b)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 #define Red(c) ((c & 0x00FF0000) >> 16)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 #define Green(c) ((c & 0x0000FF00) >> 8)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 #define Blue(c) ((c & 0x000000FF) >> 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 /* Key mapping */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 #define vk_Esc 0x35 /* -> 1B */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 #define vk_F1 0x7A /* -> 10 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 #define vk_F2 0x78 /*0x63*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 #define vk_F3 0x63 /*0x76*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 #define vk_F4 0x76 /*0x60*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 #define vk_F5 0x60 /*0x61*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 #define vk_F6 0x61 /*0x62*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 #define vk_F7 0x62 /*0x63*/ /*?*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 #define vk_F8 0x64
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 #define vk_F9 0x65
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 #define vk_F10 0x6D
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 #define vk_F11 0x67
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 #define vk_F12 0x6F
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 #define vk_F13 0x69
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 #define vk_F14 0x6B
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 #define vk_F15 0x71
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 #define vk_Clr 0x47 /* -> 1B (ESC) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 #define vk_Enter 0x4C /* -> 03 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 #define vk_Space 0x31 /* -> 20 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 #define vk_Tab 0x30 /* -> 09 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 #define vk_Return 0x24 /* -> 0D */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211 /* This is wrong for OSX, what is it for? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 #define vk_Delete 0X08 /* -> 08 BackSpace */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 #define vk_Help 0x72 /* -> 05 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 #define vk_Home 0x73 /* -> 01 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 #define vk_PageUp 0x74 /* -> 0D */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 #define vk_FwdDelete 0x75 /* -> 7F */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218 #define vk_End 0x77 /* -> 04 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 #define vk_PageDown 0x79 /* -> 0C */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221 #define vk_Up 0x7E /* -> 1E */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 #define vk_Down 0x7D /* -> 1F */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 #define vk_Left 0x7B /* -> 1C */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 #define vk_Right 0x7C /* -> 1D */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226 #define vk_Undo vk_F1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 #define vk_Cut vk_F2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 #define vk_Copy vk_F3
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229 #define vk_Paste vk_F4
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 #define vk_PrintScreen vk_F13
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231 #define vk_SCrollLock vk_F14
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 #define vk_Pause vk_F15
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233 #define vk_NumLock vk_Clr
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 #define vk_Insert vk_Help
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 #define KeySym char
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238 static struct
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 KeySym key_sym;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 char_u vim_code0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 char_u vim_code1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 } special_keys[] =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245 {vk_Up, 'k', 'u'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 {vk_Down, 'k', 'd'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 {vk_Left, 'k', 'l'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248 {vk_Right, 'k', 'r'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250 {vk_F1, 'k', '1'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251 {vk_F2, 'k', '2'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 {vk_F3, 'k', '3'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 {vk_F4, 'k', '4'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254 {vk_F5, 'k', '5'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 {vk_F6, 'k', '6'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 {vk_F7, 'k', '7'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257 {vk_F8, 'k', '8'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258 {vk_F9, 'k', '9'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259 {vk_F10, 'k', ';'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 {vk_F11, 'F', '1'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 {vk_F12, 'F', '2'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263 {vk_F13, 'F', '3'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264 {vk_F14, 'F', '4'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 {vk_F15, 'F', '5'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
266
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
267 /* {XK_Help, '%', '1'}, */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268 /* {XK_Undo, '&', '8'}, */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269 /* {XK_BackSpace, 'k', 'b'}, */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270 #ifndef MACOS_X
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271 {vk_Delete, 'k', 'b'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273 {vk_Insert, 'k', 'I'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274 {vk_FwdDelete, 'k', 'D'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
275 {vk_Home, 'k', 'h'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
276 {vk_End, '@', '7'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
277 /* {XK_Prior, 'k', 'P'}, */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278 /* {XK_Next, 'k', 'N'}, */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279 /* {XK_Print, '%', '9'}, */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281 {vk_PageUp, 'k', 'P'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282 {vk_PageDown, 'k', 'N'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284 /* End of list marker: */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285 {(KeySym)0, 0, 0}
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290 * Forward declaration (for those needed)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
291 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294 #ifdef USE_AEVENT
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
295 OSErr HandleUnusedParms(const AppleEvent *theAEvent);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
296 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
297
1106
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
298 #ifdef FEAT_GUI_TABLINE
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
299 static void initialise_tabline(void);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
300 static WindowRef drawer = NULL; // TODO: put into gui.h
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
301 #endif
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
302
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
303 #ifdef USE_ATSUI_DRAWING
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
304 static void gui_mac_set_font_attributes(GuiFont font);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
305 static void gui_mac_dispose_atsui_style(void);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
306 #endif
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
307
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
308 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
309 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
310 * Conversion Utility
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
311 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
312 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
313
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
314 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
315 * C2Pascal_save
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
316 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
317 * Allocate memory and convert the C-String passed in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
318 * into a pascal string
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
319 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
320 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
321
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
322 char_u *
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
323 C2Pascal_save(char_u *Cstring)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
324 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
325 char_u *PascalString;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
326 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
327
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
328 if (Cstring == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
329 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
330
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
331 len = STRLEN(Cstring);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
332
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
333 if (len > 255) /* Truncate if necessary */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
334 len = 255;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
335
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
336 PascalString = alloc(len + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
337 if (PascalString != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
338 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
339 mch_memmove(PascalString + 1, Cstring, len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
340 PascalString[0] = len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
341 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
342
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
343 return PascalString;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
344 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
345
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
346 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347 * C2Pascal_save_and_remove_backslash
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349 * Allocate memory and convert the C-String passed in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350 * into a pascal string. Also remove the backslash at the same time
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
354 char_u *
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
355 C2Pascal_save_and_remove_backslash(char_u *Cstring)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
357 char_u *PascalString;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359 char_u *p, *c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361 len = STRLEN(Cstring);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
363 if (len > 255) /* Truncate if necessary */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364 len = 255;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
365
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366 PascalString = alloc(len + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
367 if (PascalString != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
368 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
369 for (c = Cstring, p = PascalString+1, len = 0; (*c != 0) && (len < 255); c++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
370 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
371 if ((*c == '\\') && (c[1] != 0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
372 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373 c++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375 *p = *c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376 p++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
377 len++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
378 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
379 PascalString[0] = len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
380 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
381
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
382 return PascalString;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
383 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
384
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
385 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
386 * Convert the modifiers of an Event into vim's modifiers (mouse)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
387 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
388
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
389 int_u
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390 EventModifiers2VimMouseModifiers(EventModifiers macModifiers)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
391 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
392 int_u vimModifiers = 0x00;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
394 if (macModifiers & (shiftKey | rightShiftKey))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395 vimModifiers |= MOUSE_SHIFT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396 if (macModifiers & (controlKey | rightControlKey))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397 vimModifiers |= MOUSE_CTRL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
398 if (macModifiers & (optionKey | rightOptionKey))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399 vimModifiers |= MOUSE_ALT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
400 #if 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401 /* Not yet supported */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
402 if (macModifiers & (cmdKey)) /* There's no rightCmdKey */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403 vimModifiers |= MOUSE_CMD;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405 return (vimModifiers);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
406 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
407
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
408 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
409 * Convert the modifiers of an Event into vim's modifiers (keys)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
410 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
411
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
412 static int_u
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
413 EventModifiers2VimModifiers(EventModifiers macModifiers)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
414 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
415 int_u vimModifiers = 0x00;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
416
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
417 if (macModifiers & (shiftKey | rightShiftKey))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
418 vimModifiers |= MOD_MASK_SHIFT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
419 if (macModifiers & (controlKey | rightControlKey))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
420 vimModifiers |= MOD_MASK_CTRL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
421 if (macModifiers & (optionKey | rightOptionKey))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
422 vimModifiers |= MOD_MASK_ALT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
423 #ifdef USE_CMD_KEY
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
424 if (macModifiers & (cmdKey)) /* There's no rightCmdKey */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
425 vimModifiers |= MOD_MASK_CMD;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
426 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
427 return (vimModifiers);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
428 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
429
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
430 /* Convert a string representing a point size into pixels. The string should
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
431 * be a positive decimal number, with an optional decimal point (eg, "12", or
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
432 * "10.5"). The pixel value is returned, and a pointer to the next unconverted
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
433 * character is stored in *end. The flag "vertical" says whether this
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
434 * calculation is for a vertical (height) size or a horizontal (width) one.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
435 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
436 * From gui_w48.c
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
437 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
438 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
439 points_to_pixels(char_u *str, char_u **end, int vertical)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
440 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
441 int pixels;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
442 int points = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
443 int divisor = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
444
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
445 while (*str)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
446 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
447 if (*str == '.' && divisor == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
448 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
449 /* Start keeping a divisor, for later */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
450 divisor = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
451 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
452 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
453
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
454 if (!isdigit(*str))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
455 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
456
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
457 points *= 10;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
458 points += *str - '0';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
459 divisor *= 10;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
460
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
461 ++str;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
462 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
463
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
464 if (divisor == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
465 divisor = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
466
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
467 pixels = points/divisor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
468 *end = str;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
469 return pixels;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
470 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
471
766
f0d0d3d3a1e2 updated for version 7.0225
vimboss
parents: 719
diff changeset
472 #ifdef MACOS_CONVERT
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
473 /*
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
474 * Deletes all traces of any Windows-style mnemonic text (including any
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
475 * parentheses) from a menu item and returns the cleaned menu item title.
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
476 * The caller is responsible for releasing the returned string.
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
477 */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
478 static CFStringRef
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
479 menu_title_removing_mnemonic(vimmenu_T *menu)
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
480 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
481 CFStringRef name;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
482 size_t menuTitleLen;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
483 CFIndex displayLen;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
484 CFRange mnemonicStart;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
485 CFRange mnemonicEnd;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
486 CFMutableStringRef cleanedName;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
487
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
488 menuTitleLen = STRLEN(menu->dname);
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1572
diff changeset
489 name = (CFStringRef) mac_enc_to_cfstring(menu->dname, menuTitleLen);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
490
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
491 if (name)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
492 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
493 /* Simple mnemonic-removal algorithm, assumes single parenthesized
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
494 * mnemonic character towards the end of the menu text */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
495 mnemonicStart = CFStringFind(name, CFSTR("("), kCFCompareBackwards);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
496 displayLen = CFStringGetLength(name);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
497
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
498 if (mnemonicStart.location != kCFNotFound
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
499 && (mnemonicStart.location + 2) < displayLen
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
500 && CFStringGetCharacterAtIndex(name,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
501 mnemonicStart.location + 1) == (UniChar)menu->mnemonic)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
502 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
503 if (CFStringFindWithOptions(name, CFSTR(")"),
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
504 CFRangeMake(mnemonicStart.location + 1,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
505 displayLen - mnemonicStart.location - 1),
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
506 kCFCompareBackwards, &mnemonicEnd) &&
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
507 (mnemonicStart.location + 2) == mnemonicEnd.location)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
508 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
509 cleanedName = CFStringCreateMutableCopy(NULL, 0, name);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
510 if (cleanedName)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
511 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
512 CFStringDelete(cleanedName,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
513 CFRangeMake(mnemonicStart.location,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
514 mnemonicEnd.location + 1 -
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
515 mnemonicStart.location));
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
516
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
517 CFRelease(name);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
518 name = cleanedName;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
519 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
520 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
521 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
522 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
523
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
524 return name;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
525 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
526 #endif
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
527
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
528 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
529 * Convert a list of FSSpec aliases into a list of fullpathname
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
530 * character strings.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
531 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
532
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
533 char_u **
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
534 new_fnames_from_AEDesc(AEDesc *theList, long *numFiles, OSErr *error)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
535 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
536 char_u **fnames = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
537 OSErr newError;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
538 long fileCount;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
539 FSSpec fileToOpen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
540 long actualSize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
541 AEKeyword dummyKeyword;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
542 DescType dummyType;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
543
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
544 /* Get number of files in list */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
545 *error = AECountItems(theList, numFiles);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
546 if (*error)
1107
2ced59eaf1e5 updated for version 7.0-233
vimboss
parents: 1106
diff changeset
547 return fnames;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
548
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
549 /* Allocate the pointer list */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
550 fnames = (char_u **) alloc(*numFiles * sizeof(char_u *));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
551
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
552 /* Empty out the list */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
553 for (fileCount = 0; fileCount < *numFiles; fileCount++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
554 fnames[fileCount] = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
555
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
556 /* Scan the list of FSSpec */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
557 for (fileCount = 1; fileCount <= *numFiles; fileCount++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
558 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
559 /* Get the alias for the nth file, convert to an FSSpec */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
560 newError = AEGetNthPtr(theList, fileCount, typeFSS,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
561 &dummyKeyword, &dummyType,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
562 (Ptr) &fileToOpen, sizeof(FSSpec), &actualSize);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
563 if (newError)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
564 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
565 /* Caller is able to clean up */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
566 /* TODO: Should be clean up or not? For safety. */
1107
2ced59eaf1e5 updated for version 7.0-233
vimboss
parents: 1106
diff changeset
567 return fnames;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
568 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
569
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
570 /* Convert the FSSpec to a pathname */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
571 fnames[fileCount - 1] = FullPathFromFSSpec_save(fileToOpen);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
572 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
573
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
574 return (fnames);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
575 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
576
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
577 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
578 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
579 * CodeWarrior External Editor Support
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
580 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
581 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
582 #ifdef FEAT_CW_EDITOR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
583
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
584 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585 * Handle the Window Search event from CodeWarrior
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
586 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
587 * Description
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
588 * -----------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
590 * The IDE sends the Window Search AppleEvent to the editor when it
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
591 * needs to know whether a particular file is open in the editor.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
592 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
593 * Event Reply
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
594 * -----------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
595 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
596 * None. Put data in the location specified in the structure received.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
597 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
598 * Remarks
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
599 * -------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
600 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
601 * When the editor receives this event, determine whether the specified
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
602 * file is open. If it is, return the modification date/time for that file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
603 * in the appropriate location specified in the structure. If the file is
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
604 * not opened, put the value fnfErr(file not found) in that location.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
605 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
606 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
607
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
608 typedef struct WindowSearch WindowSearch;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609 struct WindowSearch /* for handling class 'KAHL', event 'SRCH', keyDirectObject typeChar*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
610 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611 FSSpec theFile; // identifies the file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
612 long *theDate; // where to put the modification date/time
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
613 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
614
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
615 pascal OSErr
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
616 Handle_KAHL_SRCH_AE(
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
617 const AppleEvent *theAEvent,
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
618 AppleEvent *theReply,
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
619 long refCon)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
620 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
621 OSErr error = noErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
622 buf_T *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
623 int foundFile = false;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
624 DescType typeCode;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
625 WindowSearch SearchData;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
626 Size actualSize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
627
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
628 error = AEGetParamPtr(theAEvent, keyDirectObject, typeChar, &typeCode, (Ptr) &SearchData, sizeof(WindowSearch), &actualSize);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
629 if (error)
1107
2ced59eaf1e5 updated for version 7.0-233
vimboss
parents: 1106
diff changeset
630 return error;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
631
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
632 error = HandleUnusedParms(theAEvent);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
633 if (error)
1107
2ced59eaf1e5 updated for version 7.0-233
vimboss
parents: 1106
diff changeset
634 return error;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
635
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
636 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
637 if (buf->b_ml.ml_mfp != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
638 && SearchData.theFile.parID == buf->b_FSSpec.parID
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
639 && SearchData.theFile.name[0] == buf->b_FSSpec.name[0]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
640 && STRNCMP(SearchData.theFile.name, buf->b_FSSpec.name, buf->b_FSSpec.name[0] + 1) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
641 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
642 foundFile = true;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
643 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
644 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
645
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
646 if (foundFile == false)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
647 *SearchData.theDate = fnfErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
648 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
649 *SearchData.theDate = buf->b_mtime;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
650
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
651 return error;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
652 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
653
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
654 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
655 * Handle the Modified (from IDE to Editor) event from CodeWarrior
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
656 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
657 * Description
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
658 * -----------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
659 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
660 * The IDE sends this event to the external editor when it wants to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
661 * know which files that are open in the editor have been modified.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
662 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
663 * Parameters None.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
664 * ----------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
665 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
666 * Event Reply
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
667 * -----------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
668 * The reply for this event is:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
669 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
670 * keyDirectObject typeAEList required
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
671 * each element in the list is a structure of typeChar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
672 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
673 * Remarks
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
674 * -------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
675 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
676 * When building the reply event, include one element in the list for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
677 * each open file that has been modified.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
678 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
679 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
680
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
681 typedef struct ModificationInfo ModificationInfo;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
682 struct ModificationInfo /* for replying to class 'KAHL', event 'MOD ', keyDirectObject typeAEList*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
683 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
684 FSSpec theFile; // identifies the file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
685 long theDate; // the date/time the file was last modified
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
686 short saved; // set this to zero when replying, unused
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
687 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
688
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
689 pascal OSErr
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
690 Handle_KAHL_MOD_AE(
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
691 const AppleEvent *theAEvent,
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
692 AppleEvent *theReply,
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
693 long refCon)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
694 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
695 OSErr error = noErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
696 AEDescList replyList;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
697 long numFiles;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
698 ModificationInfo theFile;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
699 buf_T *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
700
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
701 theFile.saved = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
702
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
703 error = HandleUnusedParms(theAEvent);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
704 if (error)
1107
2ced59eaf1e5 updated for version 7.0-233
vimboss
parents: 1106
diff changeset
705 return error;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
706
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
707 /* Send the reply */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
708 /* replyObject.descriptorType = typeNull;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
709 replyObject.dataHandle = nil;*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
710
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
711 /* AECreateDesc(typeChar, (Ptr)&title[1], title[0], &data) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
712 error = AECreateList(nil, 0, false, &replyList);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
713 if (error)
1107
2ced59eaf1e5 updated for version 7.0-233
vimboss
parents: 1106
diff changeset
714 return error;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
715
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
716 #if 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
717 error = AECountItems(&replyList, &numFiles);
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
718
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
719 /* AEPutKeyDesc(&replyList, keyAEPnject, &aDesc)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
720 * AEPutKeyPtr(&replyList, keyAEPosition, typeChar, (Ptr)&theType,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
721 * sizeof(DescType))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
722 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
723
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
724 /* AEPutDesc */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
725 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
726
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
727 numFiles = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
728 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
729 if (buf->b_ml.ml_mfp != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
730 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
731 /* Add this file to the list */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
732 theFile.theFile = buf->b_FSSpec;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
733 theFile.theDate = buf->b_mtime;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
734 /* theFile.theDate = time(NULL) & (time_t) 0xFFFFFFF0; */
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
735 error = AEPutPtr(&replyList, numFiles, typeChar, (Ptr) &theFile, sizeof(theFile));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
736 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
737
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
738 #if 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
739 error = AECountItems(&replyList, &numFiles);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
740 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
741
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
742 /* We can add data only if something to reply */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
743 error = AEPutParamDesc(theReply, keyDirectObject, &replyList);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
744
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
745 if (replyList.dataHandle)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
746 AEDisposeDesc(&replyList);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
747
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
748 return error;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
749 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
750
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
751 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
752 * Handle the Get Text event from CodeWarrior
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
753 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
754 * Description
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
755 * -----------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
756 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
757 * The IDE sends the Get Text AppleEvent to the editor when it needs
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
758 * the source code from a file. For example, when the user issues a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
759 * Check Syntax or Compile command, the compiler needs access to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
760 * the source code contained in the file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
761 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
762 * Event Reply
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
763 * -----------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
764 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
765 * None. Put data in locations specified in the structure received.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
766 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
767 * Remarks
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
768 * -------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
769 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
770 * When the editor receives this event, it must set the size of the handle
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
771 * in theText to fit the data in the file. It must then copy the entire
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
772 * contents of the specified file into the memory location specified in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
773 * theText.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
774 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
775 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
776
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
777 typedef struct CW_GetText CW_GetText;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
778 struct CW_GetText /* for handling class 'KAHL', event 'GTTX', keyDirectObject typeChar*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
779 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
780 FSSpec theFile; /* identifies the file */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
781 Handle theText; /* the location where you return the text (must be resized properly) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
782 long *unused; /* 0 (not used) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
783 long *theDate; /* where to put the modification date/time */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
784 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
785
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
786 pascal OSErr
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
787 Handle_KAHL_GTTX_AE(
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
788 const AppleEvent *theAEvent,
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
789 AppleEvent *theReply,
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
790 long refCon)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
791 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
792 OSErr error = noErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
793 buf_T *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
794 int foundFile = false;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
795 DescType typeCode;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
796 CW_GetText GetTextData;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
797 Size actualSize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
798 char_u *line;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
799 char_u *fullbuffer = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
800 long linesize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
801 long lineStart;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
802 long BufferSize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
803 long lineno;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
804
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
805 error = AEGetParamPtr(theAEvent, keyDirectObject, typeChar, &typeCode, (Ptr) &GetTextData, sizeof(GetTextData), &actualSize);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
806
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
807 if (error)
1107
2ced59eaf1e5 updated for version 7.0-233
vimboss
parents: 1106
diff changeset
808 return error;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
809
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
810 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
811 if (buf->b_ml.ml_mfp != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
812 if (GetTextData.theFile.parID == buf->b_FSSpec.parID)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
813 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
814 foundFile = true;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
815 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
816 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
817
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
818 if (foundFile)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
819 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
820 BufferSize = 0; /* GetHandleSize(GetTextData.theText); */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
821 for (lineno = 0; lineno <= buf->b_ml.ml_line_count; lineno++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
822 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
823 /* Must use the right buffer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
824 line = ml_get_buf(buf, (linenr_T) lineno, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
825 linesize = STRLEN(line) + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
826 lineStart = BufferSize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
827 BufferSize += linesize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
828 /* Resize handle to linesize+1 to include the linefeed */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
829 SetHandleSize(GetTextData.theText, BufferSize);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
830 if (GetHandleSize(GetTextData.theText) != BufferSize)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
831 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
832 break; /* Simple handling for now */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
833 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
834 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
835 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
836 HLock(GetTextData.theText);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
837 fullbuffer = (char_u *) *GetTextData.theText;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
838 STRCPY((char_u *)(fullbuffer + lineStart), line);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
839 fullbuffer[BufferSize-1] = '\r';
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
840 HUnlock(GetTextData.theText);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
841 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
842 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
843 if (fullbuffer != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
844 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
845 HLock(GetTextData.theText);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
846 fullbuffer[BufferSize-1] = 0;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
847 HUnlock(GetTextData.theText);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
848 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
849 if (foundFile == false)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
850 *GetTextData.theDate = fnfErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
851 else
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
852 /* *GetTextData.theDate = time(NULL) & (time_t) 0xFFFFFFF0;*/
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
853 *GetTextData.theDate = buf->b_mtime;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
854 }
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
855
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
856 error = HandleUnusedParms(theAEvent);
1107
2ced59eaf1e5 updated for version 7.0-233
vimboss
parents: 1106
diff changeset
857
2ced59eaf1e5 updated for version 7.0-233
vimboss
parents: 1106
diff changeset
858 return error;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
859 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
860
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
861 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
862 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
863 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
864
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
865 /* Taken from MoreAppleEvents:ProcessHelpers*/
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
866 pascal OSErr
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
867 FindProcessBySignature(
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
868 const OSType targetType,
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
869 const OSType targetCreator,
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
870 ProcessSerialNumberPtr psnPtr)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
871 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
872 OSErr anErr = noErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
873 Boolean lookingForProcess = true;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
874
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
875 ProcessInfoRec infoRec;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
876
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
877 infoRec.processInfoLength = sizeof(ProcessInfoRec);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
878 infoRec.processName = nil;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
879 infoRec.processAppSpec = nil;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
880
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
881 psnPtr->lowLongOfPSN = kNoProcess;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
882 psnPtr->highLongOfPSN = kNoProcess;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
883
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
884 while (lookingForProcess)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
885 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
886 anErr = GetNextProcess(psnPtr);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
887 if (anErr != noErr)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
888 lookingForProcess = false;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
889 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
890 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
891 anErr = GetProcessInformation(psnPtr, &infoRec);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
892 if ((anErr == noErr)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
893 && (infoRec.processType == targetType)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
894 && (infoRec.processSignature == targetCreator))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
895 lookingForProcess = false;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
896 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
897 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
898
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
899 return anErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
900 }//end FindProcessBySignature
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
901
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
902 void
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
903 Send_KAHL_MOD_AE(buf_T *buf)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
904 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
905 OSErr anErr = noErr;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
906 AEDesc targetAppDesc = { typeNull, nil };
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
907 ProcessSerialNumber psn = { kNoProcess, kNoProcess };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
908 AppleEvent theReply = { typeNull, nil };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
909 AESendMode sendMode;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
910 AppleEvent theEvent = {typeNull, nil };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
911 AEIdleUPP idleProcUPP = nil;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
912 ModificationInfo ModData;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
913
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
914
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
915 anErr = FindProcessBySignature('APPL', 'CWIE', &psn);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
916 if (anErr == noErr)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
917 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
918 anErr = AECreateDesc(typeProcessSerialNumber, &psn,
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
919 sizeof(ProcessSerialNumber), &targetAppDesc);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
920
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
921 if (anErr == noErr)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
922 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
923 anErr = AECreateAppleEvent( 'KAHL', 'MOD ', &targetAppDesc,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
924 kAutoGenerateReturnID, kAnyTransactionID, &theEvent);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
925 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
926
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
927 AEDisposeDesc(&targetAppDesc);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
928
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
929 /* Add the parms */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
930 ModData.theFile = buf->b_FSSpec;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
931 ModData.theDate = buf->b_mtime;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
932
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
933 if (anErr == noErr)
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
934 anErr = AEPutParamPtr(&theEvent, keyDirectObject, typeChar, &ModData, sizeof(ModData));
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
935
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
936 if (idleProcUPP == nil)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
937 sendMode = kAENoReply;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
938 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
939 sendMode = kAEWaitReply;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
940
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
941 if (anErr == noErr)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
942 anErr = AESend(&theEvent, &theReply, sendMode, kAENormalPriority, kNoTimeOut, idleProcUPP, nil);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
943 if (anErr == noErr && sendMode == kAEWaitReply)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
944 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
945 /* anErr = AEHGetHandlerError(&theReply);*/
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
946 }
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
947 (void) AEDisposeDesc(&theReply);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
948 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
949 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
950 #endif /* FEAT_CW_EDITOR */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
951
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
952 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
953 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
954 * Apple Event Handling procedure
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
955 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
956 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
957 #ifdef USE_AEVENT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
958
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
959 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
960 * Handle the Unused parms of an AppleEvent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
961 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
962
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
963 OSErr
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
964 HandleUnusedParms(const AppleEvent *theAEvent)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
965 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
966 OSErr error;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
967 long actualSize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
968 DescType dummyType;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
969 AEKeyword missedKeyword;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
970
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
971 /* Get the "missed keyword" attribute from the AppleEvent. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
972 error = AEGetAttributePtr(theAEvent, keyMissedKeywordAttr,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
973 typeKeyword, &dummyType,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
974 (Ptr)&missedKeyword, sizeof(missedKeyword),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
975 &actualSize);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
976
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
977 /* If the descriptor isn't found, then we got the required parameters. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
978 if (error == errAEDescNotFound)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
979 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
980 error = noErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
981 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
982 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
983 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
984 #if 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
985 /* Why is this removed? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
986 error = errAEEventNotHandled;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
987 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
988 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
989
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
990 return error;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
991 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
992
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
993
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
994 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
995 * Handle the ODoc AppleEvent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
996 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
997 * Deals with all files dragged to the application icon.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
998 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
999 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1000
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1001 typedef struct SelectionRange SelectionRange;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1002 struct SelectionRange /* for handling kCoreClassEvent:kOpenDocuments:keyAEPosition typeChar */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1003 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1004 short unused1; // 0 (not used)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1005 short lineNum; // line to select (<0 to specify range)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1006 long startRange; // start of selection range (if line < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1007 long endRange; // end of selection range (if line < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1008 long unused2; // 0 (not used)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1009 long theDate; // modification date/time
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1010 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1011
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1012 /* The IDE uses the optional keyAEPosition parameter to tell the ed-
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1013 itor the selection range. If lineNum is zero or greater, scroll the text
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1014 to the specified line. If lineNum is less than zero, use the values in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1015 startRange and endRange to select the specified characters. Scroll
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1016 the text to display the selection. If lineNum, startRange, and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1017 endRange are all negative, there is no selection range specified.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1018 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1019
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1020 pascal OSErr
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1021 HandleODocAE(const AppleEvent *theAEvent, AppleEvent *theReply, long refCon)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1022 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1023 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1024 * TODO: Clean up the code with convert the AppleEvent into
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1025 * a ":args"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1026 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1027 OSErr error = noErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1028 // OSErr firstError = noErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1029 // short numErrors = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1030 AEDesc theList;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1031 DescType typeCode;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1032 long numFiles;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1033 // long fileCount;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1034 char_u **fnames;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1035 // char_u fname[256];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1036 Size actualSize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1037 SelectionRange thePosition;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1038 short gotPosition = false;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1039 long lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1040
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1041 /* the direct object parameter is the list of aliases to files (one or more) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1042 error = AEGetParamDesc(theAEvent, keyDirectObject, typeAEList, &theList);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1043 if (error)
1107
2ced59eaf1e5 updated for version 7.0-233
vimboss
parents: 1106
diff changeset
1044 return error;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1045
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1046
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1047 error = AEGetParamPtr(theAEvent, keyAEPosition, typeChar, &typeCode, (Ptr) &thePosition, sizeof(SelectionRange), &actualSize);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1048 if (error == noErr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1049 gotPosition = true;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1050 if (error == errAEDescNotFound)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1051 error = noErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1052 if (error)
1107
2ced59eaf1e5 updated for version 7.0-233
vimboss
parents: 1106
diff changeset
1053 return error;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1054
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1055 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1056 error = AEGetParamDesc(theAEvent, keyAEPosition, typeChar, &thePosition);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1057
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1058 if (^error) then
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1059 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1060 if (thePosition.lineNum >= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1061 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1062 // Goto this line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1063 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1064 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1065 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1066 // Set the range char wise
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1067 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1068 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1069 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1070
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1071 reset_VIsual();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1072 fnames = new_fnames_from_AEDesc(&theList, &numFiles, &error);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1073
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1074 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1075 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1076 /* TODO: empty fnames[] first */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1077 vim_free(fnames);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1078 return (error);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1079 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1080
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1081 if (starting > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1082 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1083 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1084 char_u *p;
1409
4ee809acd1ab updated for version 7.1-124
vimboss
parents: 1377
diff changeset
1085 int fnum = -1;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1086
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1087 /* these are the initial files dropped on the Vim icon */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1088 for (i = 0 ; i < numFiles; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1089 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1090 if (ga_grow(&global_alist.al_ga, 1) == FAIL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1091 || (p = vim_strsave(fnames[i])) == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1092 mch_exit(2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1093 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1094 alist_add(&global_alist, p, 2);
1409
4ee809acd1ab updated for version 7.1-124
vimboss
parents: 1377
diff changeset
1095 if (fnum == -1)
4ee809acd1ab updated for version 7.1-124
vimboss
parents: 1377
diff changeset
1096 fnum = GARGLIST[GARGCOUNT - 1].ae_fnum;
4ee809acd1ab updated for version 7.1-124
vimboss
parents: 1377
diff changeset
1097 }
4ee809acd1ab updated for version 7.1-124
vimboss
parents: 1377
diff changeset
1098
4ee809acd1ab updated for version 7.1-124
vimboss
parents: 1377
diff changeset
1099 /* If the file name was already in the buffer list we need to switch
4ee809acd1ab updated for version 7.1-124
vimboss
parents: 1377
diff changeset
1100 * to it. */
4ee809acd1ab updated for version 7.1-124
vimboss
parents: 1377
diff changeset
1101 if (curbuf->b_fnum != fnum)
4ee809acd1ab updated for version 7.1-124
vimboss
parents: 1377
diff changeset
1102 {
4ee809acd1ab updated for version 7.1-124
vimboss
parents: 1377
diff changeset
1103 char_u cmd[30];
4ee809acd1ab updated for version 7.1-124
vimboss
parents: 1377
diff changeset
1104
4ee809acd1ab updated for version 7.1-124
vimboss
parents: 1377
diff changeset
1105 vim_snprintf((char *)cmd, 30, "silent %dbuffer", fnum);
4ee809acd1ab updated for version 7.1-124
vimboss
parents: 1377
diff changeset
1106 do_cmdline_cmd(cmd);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1107 }
816
4a79d6d376f0 updated for version 7.0c02
vimboss
parents: 812
diff changeset
1108
4a79d6d376f0 updated for version 7.0c02
vimboss
parents: 812
diff changeset
1109 /* Change directory to the location of the first file. */
4a79d6d376f0 updated for version 7.0c02
vimboss
parents: 812
diff changeset
1110 if (GARGCOUNT > 0 && vim_chdirfile(alist_name(&GARGLIST[0])) == OK)
4a79d6d376f0 updated for version 7.0c02
vimboss
parents: 812
diff changeset
1111 shorten_fnames(TRUE);
4a79d6d376f0 updated for version 7.0c02
vimboss
parents: 812
diff changeset
1112
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1113 goto finished;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1114 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1115
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1116 /* Handle the drop, :edit to get to the file */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1117 handle_drop(numFiles, fnames, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1118
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1119 /* TODO: Handle the goto/select line more cleanly */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1120 if ((numFiles == 1) & (gotPosition))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1121 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1122 if (thePosition.lineNum >= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1123 {
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
1124 lnum = thePosition.lineNum + 1;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1125 /* oap->motion_type = MLINE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1126 setpcmark();*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1127 if (lnum < 1L)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1128 lnum = 1L;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1129 else if (lnum > curbuf->b_ml.ml_line_count)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1130 lnum = curbuf->b_ml.ml_line_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1131 curwin->w_cursor.lnum = lnum;
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
1132 curwin->w_cursor.col = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1133 /* beginline(BL_SOL | BL_FIX);*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1134 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1135 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1136 goto_byte(thePosition.startRange + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1137 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1138
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1139 /* Update the screen display */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1140 update_screen(NOT_VALID);
5735
50dbef5e774a updated for version 7.4.212
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
1141
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
1142 /* Select the text if possible */
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
1143 if (gotPosition)
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
1144 {
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1145 VIsual_active = TRUE;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1146 VIsual_select = FALSE;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1147 VIsual = curwin->w_cursor;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1148 if (thePosition.lineNum < 0)
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
1149 {
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1150 VIsual_mode = 'v';
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1151 goto_byte(thePosition.endRange);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1152 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1153 else
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
1154 {
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1155 VIsual_mode = 'V';
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1156 VIsual.col = 0;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1157 }
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
1158 }
5735
50dbef5e774a updated for version 7.4.212
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
1159
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1160 setcursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1161 out_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1162
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
1163 /* Fake mouse event to wake from stall */
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
1164 PostEvent(mouseUp, 0);
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
1165
1107
2ced59eaf1e5 updated for version 7.0-233
vimboss
parents: 1106
diff changeset
1166 finished:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1167 AEDisposeDesc(&theList); /* dispose what we allocated */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1168
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1169 error = HandleUnusedParms(theAEvent);
1107
2ced59eaf1e5 updated for version 7.0-233
vimboss
parents: 1106
diff changeset
1170 return error;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1171 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1172
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1173 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1174 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1175 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1176
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1177 pascal OSErr
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1178 Handle_aevt_oapp_AE(
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1179 const AppleEvent *theAEvent,
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1180 AppleEvent *theReply,
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1181 long refCon)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1182 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1183 OSErr error = noErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1184
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1185 error = HandleUnusedParms(theAEvent);
1107
2ced59eaf1e5 updated for version 7.0-233
vimboss
parents: 1106
diff changeset
1186 return error;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1187 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1188
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1189 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1190 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1191 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1192
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1193 pascal OSErr
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1194 Handle_aevt_quit_AE(
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1195 const AppleEvent *theAEvent,
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1196 AppleEvent *theReply,
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1197 long refCon)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1198 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1199 OSErr error = noErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1200
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1201 error = HandleUnusedParms(theAEvent);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1202 if (error)
1107
2ced59eaf1e5 updated for version 7.0-233
vimboss
parents: 1106
diff changeset
1203 return error;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1204
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1205 /* Need to fake a :confirm qa */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1206 do_cmdline_cmd((char_u *)"confirm qa");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1207
1107
2ced59eaf1e5 updated for version 7.0-233
vimboss
parents: 1106
diff changeset
1208 return error;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1209 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1210
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1211 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1212 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1213 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1214
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1215 pascal OSErr
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1216 Handle_aevt_pdoc_AE(
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1217 const AppleEvent *theAEvent,
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1218 AppleEvent *theReply,
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1219 long refCon)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1220 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1221 OSErr error = noErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1222
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1223 error = HandleUnusedParms(theAEvent);
1107
2ced59eaf1e5 updated for version 7.0-233
vimboss
parents: 1106
diff changeset
1224
2ced59eaf1e5 updated for version 7.0-233
vimboss
parents: 1106
diff changeset
1225 return error;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1226 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1227
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1228 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1229 * Handling of unknown AppleEvent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1230 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1231 * (Just get rid of all the parms)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1232 */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1233 pascal OSErr
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1234 Handle_unknown_AE(
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1235 const AppleEvent *theAEvent,
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1236 AppleEvent *theReply,
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1237 long refCon)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1238 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1239 OSErr error = noErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1240
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1241 error = HandleUnusedParms(theAEvent);
1107
2ced59eaf1e5 updated for version 7.0-233
vimboss
parents: 1106
diff changeset
1242
2ced59eaf1e5 updated for version 7.0-233
vimboss
parents: 1106
diff changeset
1243 return error;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1244 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1245
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1246
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1247 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1248 * Install the various AppleEvent Handlers
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1249 */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1250 OSErr
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1251 InstallAEHandlers(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1252 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1253 OSErr error;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1254
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1255 /* install open application handler */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1256 error = AEInstallEventHandler(kCoreEventClass, kAEOpenApplication,
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1257 NewAEEventHandlerUPP(Handle_aevt_oapp_AE), 0, false);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1258 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1259 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1260 return error;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1261 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1262
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1263 /* install quit application handler */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1264 error = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication,
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1265 NewAEEventHandlerUPP(Handle_aevt_quit_AE), 0, false);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1266 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1267 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1268 return error;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1269 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1270
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1271 /* install open document handler */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1272 error = AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments,
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1273 NewAEEventHandlerUPP(HandleODocAE), 0, false);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1274 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1275 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1276 return error;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1277 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1278
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1279 /* install print document handler */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1280 error = AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments,
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1281 NewAEEventHandlerUPP(Handle_aevt_pdoc_AE), 0, false);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1282
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1283 /* Install Core Suite */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1284 /* error = AEInstallEventHandler(kAECoreSuite, kAEClone,
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1285 NewAEEventHandlerUPP(Handle_unknown_AE), nil, false);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1286
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1287 error = AEInstallEventHandler(kAECoreSuite, kAEClose,
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1288 NewAEEventHandlerUPP(Handle_unknown_AE), nil, false);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1289
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1290 error = AEInstallEventHandler(kAECoreSuite, kAECountElements,
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1291 NewAEEventHandlerUPP(Handle_unknown_AE), nil, false);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1292
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1293 error = AEInstallEventHandler(kAECoreSuite, kAECreateElement,
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1294 NewAEEventHandlerUPP(Handle_unknown_AE), nil, false);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1295
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1296 error = AEInstallEventHandler(kAECoreSuite, kAEDelete,
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1297 NewAEEventHandlerUPP(Handle_unknown_AE), nil, false);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1298
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1299 error = AEInstallEventHandler(kAECoreSuite, kAEDoObjectsExist,
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1300 NewAEEventHandlerUPP(Handle_unknown_AE), nil, false);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1301
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1302 error = AEInstallEventHandler(kAECoreSuite, kAEGetData,
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1303 NewAEEventHandlerUPP(Handle_unknown_AE), kAEGetData, false);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1304
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1305 error = AEInstallEventHandler(kAECoreSuite, kAEGetDataSize,
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1306 NewAEEventHandlerUPP(Handle_unknown_AE), kAEGetDataSize, false);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1307
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1308 error = AEInstallEventHandler(kAECoreSuite, kAEGetClassInfo,
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1309 NewAEEventHandlerUPP(Handle_unknown_AE), nil, false);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1310
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1311 error = AEInstallEventHandler(kAECoreSuite, kAEGetEventInfo,
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1312 NewAEEventHandlerUPP(Handle_unknown_AE), nil, false);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1313
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1314 error = AEInstallEventHandler(kAECoreSuite, kAEMove,
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1315 NewAEEventHandlerUPP(Handle_unknown_AE), nil, false);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1316
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1317 error = AEInstallEventHandler(kAECoreSuite, kAESave,
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1318 NewAEEventHandlerUPP(Handle_unknown_AE), nil, false);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1319
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1320 error = AEInstallEventHandler(kAECoreSuite, kAESetData,
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1321 NewAEEventHandlerUPP(Handle_unknown_AE), nil, false);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1322 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1323
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1324 #ifdef FEAT_CW_EDITOR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1325 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1326 * Bind codewarrior support handlers
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1327 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1328 error = AEInstallEventHandler('KAHL', 'GTTX',
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1329 NewAEEventHandlerUPP(Handle_KAHL_GTTX_AE), 0, false);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1330 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1331 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1332 return error;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1333 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1334 error = AEInstallEventHandler('KAHL', 'SRCH',
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1335 NewAEEventHandlerUPP(Handle_KAHL_SRCH_AE), 0, false);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1336 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1337 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1338 return error;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1339 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1340 error = AEInstallEventHandler('KAHL', 'MOD ',
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1341 NewAEEventHandlerUPP(Handle_KAHL_MOD_AE), 0, false);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1342 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1343 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1344 return error;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1345 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1346 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1347
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1348 return error;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1349
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1350 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1351 #endif /* USE_AEVENT */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1352
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1353
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1354 /*
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1355 * Callback function, installed by InstallFontPanelHandler(), below,
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1356 * to handle Font Panel events.
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1357 */
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1358 static OSStatus
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1359 FontPanelHandler(
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1360 EventHandlerCallRef inHandlerCallRef,
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1361 EventRef inEvent,
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1362 void *inUserData)
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1363 {
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1364 if (GetEventKind(inEvent) == kEventFontPanelClosed)
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1365 {
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1366 gFontPanelInfo.isPanelVisible = false;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1367 return noErr;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1368 }
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1369
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1370 if (GetEventKind(inEvent) == kEventFontSelection)
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1371 {
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1372 OSStatus status;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1373 FMFontFamily newFamily;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1374 FMFontSize newSize;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1375 FMFontStyle newStyle;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1376
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1377 /* Retrieve the font family ID number. */
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1378 status = GetEventParameter(inEvent, kEventParamFMFontFamily,
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1379 /*inDesiredType=*/typeFMFontFamily, /*outActualType=*/NULL,
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1380 /*inBufferSize=*/sizeof(FMFontFamily), /*outActualSize=*/NULL,
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1381 &newFamily);
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1382 if (status == noErr)
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1383 gFontPanelInfo.family = newFamily;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1384
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1385 /* Retrieve the font size. */
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1386 status = GetEventParameter(inEvent, kEventParamFMFontSize,
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1387 typeFMFontSize, NULL, sizeof(FMFontSize), NULL, &newSize);
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1388 if (status == noErr)
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1389 gFontPanelInfo.size = newSize;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1390
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1391 /* Retrieve the font style (bold, etc.). Currently unused. */
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1392 status = GetEventParameter(inEvent, kEventParamFMFontStyle,
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1393 typeFMFontStyle, NULL, sizeof(FMFontStyle), NULL, &newStyle);
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1394 if (status == noErr)
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1395 gFontPanelInfo.style = newStyle;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1396 }
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1397 return noErr;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1398 }
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1399
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1400
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1401 static void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1402 InstallFontPanelHandler(void)
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1403 {
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1404 EventTypeSpec eventTypes[2];
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1405 EventHandlerUPP handlerUPP;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1406 /* EventHandlerRef handlerRef; */
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1407
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1408 eventTypes[0].eventClass = kEventClassFont;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1409 eventTypes[0].eventKind = kEventFontSelection;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1410 eventTypes[1].eventClass = kEventClassFont;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1411 eventTypes[1].eventKind = kEventFontPanelClosed;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1412
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1413 handlerUPP = NewEventHandlerUPP(FontPanelHandler);
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1414
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1415 InstallApplicationEventHandler(handlerUPP, /*numTypes=*/2, eventTypes,
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1416 /*userData=*/NULL, /*handlerRef=*/NULL);
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1417 }
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1418
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1419
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1420 /*
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1421 * Fill the buffer pointed to by outName with the name and size
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1422 * of the font currently selected in the Font Panel.
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1423 */
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1424 #define FONT_STYLE_BUFFER_SIZE 32
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1425 static void
501
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 444
diff changeset
1426 GetFontPanelSelection(char_u *outName)
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1427 {
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1428 Str255 buf;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1429 ByteCount fontNameLen = 0;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1430 ATSUFontID fid;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1431 char_u styleString[FONT_STYLE_BUFFER_SIZE];
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1432
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1433 if (!outName)
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1434 return;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1435
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1436 if (FMGetFontFamilyName(gFontPanelInfo.family, buf) == noErr)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1437 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1438 /* Canonicalize localized font names */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1439 if (FMGetFontFromFontFamilyInstance(gFontPanelInfo.family,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1440 gFontPanelInfo.style, &fid, NULL) != noErr)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1441 return;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1442
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1443 /* Request font name with Mac encoding (otherwise we could
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1444 * get an unwanted utf-16 name) */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1445 if (ATSUFindFontName(fid, kFontFullName, kFontMacintoshPlatform,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1446 kFontNoScriptCode, kFontNoLanguageCode,
501
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 444
diff changeset
1447 255, (char *)outName, &fontNameLen, NULL) != noErr)
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1448 return;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1449
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1450 /* Only encode font size, because style (bold, italic, etc) is
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1451 * already part of the font full name */
501
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 444
diff changeset
1452 vim_snprintf((char *)styleString, FONT_STYLE_BUFFER_SIZE, ":h%d",
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1453 gFontPanelInfo.size/*,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1454 ((gFontPanelInfo.style & bold)!=0 ? ":b" : ""),
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1455 ((gFontPanelInfo.style & italic)!=0 ? ":i" : ""),
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1456 ((gFontPanelInfo.style & underline)!=0 ? ":u" : "")*/);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1457
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1458 if ((fontNameLen + STRLEN(styleString)) < 255)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1459 STRCPY(outName + fontNameLen, styleString);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1460 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1461 else
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1462 {
501
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 444
diff changeset
1463 *outName = NUL;
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1464 }
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1465 }
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1466
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1467
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1468 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1469 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1470 * Unfiled yet
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1471 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1472 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1473
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1474 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1475 * gui_mac_get_menu_item_index
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1476 *
4352
04736b4030ec updated for version 7.3.925
Bram Moolenaar <bram@vim.org>
parents: 3935
diff changeset
1477 * Returns the index inside the menu where
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1478 */
2585
03d49a7c8319 updated for version 7.3.010
Bram Moolenaar <bram@vim.org>
parents: 2565
diff changeset
1479 short /* Should we return MenuItemIndex? */
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1480 gui_mac_get_menu_item_index(vimmenu_T *pMenu)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1481 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1482 short index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1483 short itemIndex = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1484 vimmenu_T *pBrother;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1485
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1486 /* Only menu without parent are the:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1487 * -menu in the menubar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1488 * -popup menu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1489 * -toolbar (guess)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1490 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1491 * Which are not items anyway.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1492 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1493 if (pMenu->parent)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1494 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1495 /* Start from the Oldest Brother */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1496 pBrother = pMenu->parent->children;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1497 index = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1498 while ((pBrother) && (itemIndex == -1))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1499 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1500 if (pBrother == pMenu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1501 itemIndex = index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1502 index++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1503 pBrother = pBrother->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1504 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1505 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1506 return itemIndex;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1507 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1508
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1509 static vimmenu_T *
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1510 gui_mac_get_vim_menu(short menuID, short itemIndex, vimmenu_T *pMenu)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1511 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1512 short index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1513 vimmenu_T *pChildMenu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1514 vimmenu_T *pElder = pMenu->parent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1515
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1516
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1517 /* Only menu without parent are the:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1518 * -menu in the menubar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1519 * -popup menu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1520 * -toolbar (guess)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1521 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1522 * Which are not items anyway.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1523 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1524
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1525 if ((pElder) && (pElder->submenu_id == menuID))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1526 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1527 for (index = 1; (index != itemIndex) && (pMenu != NULL); index++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1528 pMenu = pMenu->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1529 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1530 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1531 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1532 for (; pMenu != NULL; pMenu = pMenu->next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1533 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1534 if (pMenu->children != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1535 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1536 pChildMenu = gui_mac_get_vim_menu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1537 (menuID, itemIndex, pMenu->children);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1538 if (pChildMenu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1539 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1540 pMenu = pChildMenu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1541 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1542 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1543 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1544 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1545 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1546 return pMenu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1547 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1548
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1549 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1550 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1551 * MacOS Feedback procedures
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1552 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1553 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1554 pascal
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1555 void
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1556 gui_mac_drag_thumb(ControlHandle theControl, short partCode)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1557 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1558 scrollbar_T *sb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1559 int value, dragging;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1560 ControlHandle theControlToUse;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1561 int dont_scroll_save = dont_scroll;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1562
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1563 theControlToUse = dragged_sb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1564
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1565 sb = gui_find_scrollbar((long) GetControlReference(theControlToUse));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1566
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1567 if (sb == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1568 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1569
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1570 /* Need to find value by diff between Old Poss New Pos */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1571 value = GetControl32BitValue(theControlToUse);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1572 dragging = (partCode != 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1573
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1574 /* When "allow_scrollbar" is FALSE still need to remember the new
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1575 * position, but don't actually scroll by setting "dont_scroll". */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1576 dont_scroll = !allow_scrollbar;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1577 gui_drag_scrollbar(sb, value, dragging);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1578 dont_scroll = dont_scroll_save;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1579 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1580
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1581 pascal
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1582 void
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1583 gui_mac_scroll_action(ControlHandle theControl, short partCode)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1584 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1585 /* TODO: have live support */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1586 scrollbar_T *sb, *sb_info;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1587 long data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1588 long value;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1589 int page;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1590 int dragging = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1591 int dont_scroll_save = dont_scroll;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1592
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1593 sb = gui_find_scrollbar((long)GetControlReference(theControl));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1594
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1595 if (sb == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1596 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1597
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1598 if (sb->wp != NULL) /* Left or right scrollbar */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1599 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1600 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1601 * Careful: need to get scrollbar info out of first (left) scrollbar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1602 * for window, but keep real scrollbar too because we must pass it to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1603 * gui_drag_scrollbar().
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1604 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1605 sb_info = &sb->wp->w_scrollbars[0];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1606
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1607 if (sb_info->size > 5)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1608 page = sb_info->size - 2; /* use two lines of context */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1609 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1610 page = sb_info->size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1611 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1612 else /* Bottom scrollbar */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1613 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1614 sb_info = sb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1615 page = W_WIDTH(curwin) - 5;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1616 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1617
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1618 switch (partCode)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1619 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1620 case kControlUpButtonPart: data = -1; break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1621 case kControlDownButtonPart: data = 1; break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1622 case kControlPageDownPart: data = page; break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1623 case kControlPageUpPart: data = -page; break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1624 default: data = 0; break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1625 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1626
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1627 value = sb_info->value + data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1628 /* if (value > sb_info->max)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1629 value = sb_info->max;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1630 else if (value < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1631 value = 0;*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1632
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1633 /* When "allow_scrollbar" is FALSE still need to remember the new
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1634 * position, but don't actually scroll by setting "dont_scroll". */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1635 dont_scroll = !allow_scrollbar;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1636 gui_drag_scrollbar(sb, value, dragging);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1637 dont_scroll = dont_scroll_save;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1638
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1639 out_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1640 gui_mch_set_scrollbar_thumb(sb, value, sb_info->size, sb_info->max);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1641
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1642 /* if (sb_info->wp != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1643 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1644 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1645 int sb_num;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1646
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1647 sb_num = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1648 for (wp = firstwin; wp != sb->wp && wp != NULL; wp = W_NEXT(wp))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1649 sb_num++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1650
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1651 if (wp != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1652 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1653 current_scrollbar = sb_num;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1654 scrollbar_value = value;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1655 gui_do_scroll();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1656 gui_mch_set_scrollbar_thumb(sb, value, sb_info->size, sb_info->max);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1657 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1658 }*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1659 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1660
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1661 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1662 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1663 * MacOS Click Handling procedures
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1664 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1665 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1666
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1667
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1668 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1669 * Handle a click inside the window, it may happens in the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1670 * scrollbar or the contents.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1671 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1672 * TODO: Add support for potential TOOLBAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1673 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1674 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1675 gui_mac_doInContentClick(EventRecord *theEvent, WindowPtr whichWindow)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1676 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1677 Point thePoint;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1678 int_u vimModifiers;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1679 short thePortion;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1680 ControlHandle theControl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1681 int vimMouseButton;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1682 short dblClick;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1683
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1684 thePoint = theEvent->where;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1685 GlobalToLocal(&thePoint);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1686 SelectWindow(whichWindow);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1687
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1688 thePortion = FindControl(thePoint, whichWindow, &theControl);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1689
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1690 if (theControl != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1691 {
4352
04736b4030ec updated for version 7.3.925
Bram Moolenaar <bram@vim.org>
parents: 3935
diff changeset
1692 /* We hit a scrollbar */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1693
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1694 if (thePortion != kControlIndicatorPart)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1695 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1696 dragged_sb = theControl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1697 TrackControl(theControl, thePoint, gScrollAction);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1698 dragged_sb = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1699 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1700 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1701 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1702 dragged_sb = theControl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1703 #if 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1704 TrackControl(theControl, thePoint, gScrollDrag);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1705 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1706 TrackControl(theControl, thePoint, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1707 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1708 /* pass 0 as the part to tell gui_mac_drag_thumb, that the mouse
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1709 * button has been released */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1710 gui_mac_drag_thumb(theControl, 0); /* Should it be thePortion ? (Dany) */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1711 dragged_sb = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1712 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1713 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1714 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1715 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1716 /* We are inside the contents */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1717
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1718 /* Convert the CTRL, OPTION, SHIFT and CMD key */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1719 vimModifiers = EventModifiers2VimMouseModifiers(theEvent->modifiers);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1720
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1721 /* Defaults to MOUSE_LEFT as there's only one mouse button */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1722 vimMouseButton = MOUSE_LEFT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1723
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1724 /* Convert the CTRL_MOUSE_LEFT to MOUSE_RIGHT */
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1725 /* TODO: NEEDED? */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1726 clickIsPopup = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1727
1292
66e40876590b updated for version 7.1-007
vimboss
parents: 1212
diff changeset
1728 if (mouse_model_popup() && IsShowContextualMenuClick(theEvent))
66e40876590b updated for version 7.1-007
vimboss
parents: 1212
diff changeset
1729 {
66e40876590b updated for version 7.1-007
vimboss
parents: 1212
diff changeset
1730 vimMouseButton = MOUSE_RIGHT;
66e40876590b updated for version 7.1-007
vimboss
parents: 1212
diff changeset
1731 vimModifiers &= ~MOUSE_CTRL;
66e40876590b updated for version 7.1-007
vimboss
parents: 1212
diff changeset
1732 clickIsPopup = TRUE;
66e40876590b updated for version 7.1-007
vimboss
parents: 1212
diff changeset
1733 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1734
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1735 /* Is it a double click ? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1736 dblClick = ((theEvent->when - lastMouseTick) < GetDblTime());
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1737
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1738 /* Send the mouse click to Vim */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1739 gui_send_mouse_event(vimMouseButton, thePoint.h,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1740 thePoint.v, dblClick, vimModifiers);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1741
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1742 /* Create the rectangle around the cursor to detect
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1743 * the mouse dragging
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1744 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1745 #if 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1746 /* TODO: Do we need to this even for the contextual menu?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1747 * It may be require for popup_setpos, but for popup?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1748 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1749 if (vimMouseButton == MOUSE_LEFT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1750 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1751 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1752 SetRect(&dragRect, FILL_X(X_2_COL(thePoint.h)),
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1753 FILL_Y(Y_2_ROW(thePoint.v)),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1754 FILL_X(X_2_COL(thePoint.h)+1),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1755 FILL_Y(Y_2_ROW(thePoint.v)+1));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1756
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1757 dragRectEnbl = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1758 dragRectControl = kCreateRect;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1759 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1760 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1761 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1762
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1763 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1764 * Handle the click in the titlebar (to move the window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1765 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1766 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1767 gui_mac_doInDragClick(Point where, WindowPtr whichWindow)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1768 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1769 Rect movingLimits;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1770 Rect *movingLimitsPtr = &movingLimits;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1771
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1772 /* TODO: may try to prevent move outside screen? */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1773 movingLimitsPtr = GetRegionBounds(GetGrayRgn(), &movingLimits);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1774 DragWindow(whichWindow, where, movingLimitsPtr);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1775 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1776
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1777 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1778 * Handle the click in the grow box
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1779 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1780 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1781 gui_mac_doInGrowClick(Point where, WindowPtr whichWindow)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1782 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1783
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1784 long newSize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1785 unsigned short newWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1786 unsigned short newHeight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1787 Rect resizeLimits;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1788 Rect *resizeLimitsPtr = &resizeLimits;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1789 Rect NewContentRect;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1790
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1791 resizeLimitsPtr = GetRegionBounds(GetGrayRgn(), &resizeLimits);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1792
1212
e085b0f7b036 updated for version 7.1b
vimboss
parents: 1107
diff changeset
1793 /* Set the minimum size */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1794 /* TODO: Should this come from Vim? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1795 resizeLimits.top = 100;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1796 resizeLimits.left = 100;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1797
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1798 newSize = ResizeWindow(whichWindow, where, &resizeLimits, &NewContentRect);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1799 newWidth = NewContentRect.right - NewContentRect.left;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1800 newHeight = NewContentRect.bottom - NewContentRect.top;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1801 gui_resize_shell(newWidth, newHeight);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1802 gui_mch_set_bg_color(gui.back_pixel);
812
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 766
diff changeset
1803 gui_set_shellsize(TRUE, FALSE, RESIZE_BOTH);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1804 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1805
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1806 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1807 * Handle the click in the zoom box
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1808 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1809 static void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1810 gui_mac_doInZoomClick(EventRecord *theEvent, WindowPtr whichWindow)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1811 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1812 Rect r;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1813 Point p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1814 short thePart;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1815
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1816 /* ideal width is current */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1817 p.h = Columns * gui.char_width + 2 * gui.border_offset;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1818 if (gui.which_scrollbars[SBAR_LEFT])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1819 p.h += gui.scrollbar_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1820 if (gui.which_scrollbars[SBAR_RIGHT])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1821 p.h += gui.scrollbar_width;
2585
03d49a7c8319 updated for version 7.3.010
Bram Moolenaar <bram@vim.org>
parents: 2565
diff changeset
1822 /* ideal height is as high as we can get */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1823 p.v = 15 * 1024;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1824
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1825 thePart = IsWindowInStandardState(whichWindow, &p, &r)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1826 ? inZoomIn : inZoomOut;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1827
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1828 if (!TrackBox(whichWindow, theEvent->where, thePart))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1829 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1830
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1831 /* use returned width */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1832 p.h = r.right - r.left;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1833 /* adjust returned height */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1834 p.v = r.bottom - r.top - 2 * gui.border_offset;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1835 if (gui.which_scrollbars[SBAR_BOTTOM])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1836 p.v -= gui.scrollbar_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1837 p.v -= p.v % gui.char_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1838 p.v += 2 * gui.border_width;
2869
205adc87d579 updated for version 7.3.208
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
1839 if (gui.which_scrollbars[SBAR_BOTTOM])
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1840 p.v += gui.scrollbar_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1841
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1842 ZoomWindowIdeal(whichWindow, thePart, &p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1843
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1844 GetWindowBounds(whichWindow, kWindowContentRgn, &r);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1845 gui_resize_shell(r.right - r.left, r.bottom - r.top);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1846 gui_mch_set_bg_color(gui.back_pixel);
812
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 766
diff changeset
1847 gui_set_shellsize(TRUE, FALSE, RESIZE_BOTH);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1848 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1849
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1850 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1851 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1852 * MacOS Event Handling procedure
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1853 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1854 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1855
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1856 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1857 * Handle the Update Event
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1858 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1859
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1860 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1861 gui_mac_doUpdateEvent(EventRecord *event)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1862 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1863 WindowPtr whichWindow;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1864 GrafPtr savePort;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1865 RgnHandle updateRgn;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1866 Rect updateRect;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1867 Rect *updateRectPtr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1868 Rect rc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1869 Rect growRect;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1870 RgnHandle saveRgn;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1871
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1872
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1873 updateRgn = NewRgn();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1874 if (updateRgn == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1875 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1876
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1877 /* This could be done by the caller as we
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1878 * don't require anything else out of the event
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1879 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1880 whichWindow = (WindowPtr) event->message;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1881
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1882 /* Save Current Port */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1883 GetPort(&savePort);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1884
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1885 /* Select the Window's Port */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1886 SetPortWindowPort(whichWindow);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1887
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1888 /* Let's update the window */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1889 BeginUpdate(whichWindow);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1890 /* Redraw the biggest rectangle covering the area
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1891 * to be updated.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1892 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1893 GetPortVisibleRegion(GetWindowPort(whichWindow), updateRgn);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1894 # if 0
1212
e085b0f7b036 updated for version 7.1b
vimboss
parents: 1107
diff changeset
1895 /* Would be more appropriate to use the following but doesn't
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1896 * seem to work under MacOS X (Dany)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1897 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1898 GetWindowRegion(whichWindow, kWindowUpdateRgn, updateRgn);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1899 # endif
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1900
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1901 /* Use the HLock useless in Carbon? Is it harmful?*/
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1902 HLock((Handle) updateRgn);
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1903
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1904 updateRectPtr = GetRegionBounds(updateRgn, &updateRect);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1905 # if 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1906 /* Code from original Carbon Port (using GetWindowRegion.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1907 * I believe the UpdateRgn is already in local (Dany)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1908 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1909 GlobalToLocal(&topLeft(updateRect)); /* preCarbon? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1910 GlobalToLocal(&botRight(updateRect));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1911 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1912 /* Update the content (i.e. the text) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1913 gui_redraw(updateRectPtr->left, updateRectPtr->top,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1914 updateRectPtr->right - updateRectPtr->left,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1915 updateRectPtr->bottom - updateRectPtr->top);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1916 /* Clear the border areas if needed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1917 gui_mch_set_bg_color(gui.back_pixel);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1918 if (updateRectPtr->left < FILL_X(0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1919 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1920 SetRect(&rc, 0, 0, FILL_X(0), FILL_Y(Rows));
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1921 EraseRect(&rc);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1922 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1923 if (updateRectPtr->top < FILL_Y(0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1924 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1925 SetRect(&rc, 0, 0, FILL_X(Columns), FILL_Y(0));
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1926 EraseRect(&rc);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1927 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1928 if (updateRectPtr->right > FILL_X(Columns))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1929 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1930 SetRect(&rc, FILL_X(Columns), 0,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1931 FILL_X(Columns) + gui.border_offset, FILL_Y(Rows));
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1932 EraseRect(&rc);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1933 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1934 if (updateRectPtr->bottom > FILL_Y(Rows))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1935 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1936 SetRect(&rc, 0, FILL_Y(Rows), FILL_X(Columns) + gui.border_offset,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1937 FILL_Y(Rows) + gui.border_offset);
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1938 EraseRect(&rc);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1939 }
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1940 HUnlock((Handle) updateRgn);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1941 DisposeRgn(updateRgn);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1942
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1943 /* Update scrollbars */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1944 DrawControls(whichWindow);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1945
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1946 /* Update the GrowBox */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1947 /* Taken from FAQ 33-27 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1948 saveRgn = NewRgn();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1949 GetWindowBounds(whichWindow, kWindowGrowRgn, &growRect);
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1950 GetClip(saveRgn);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1951 ClipRect(&growRect);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1952 DrawGrowIcon(whichWindow);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1953 SetClip(saveRgn);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1954 DisposeRgn(saveRgn);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1955 EndUpdate(whichWindow);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1956
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1957 /* Restore original Port */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1958 SetPort(savePort);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1959 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1960
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1961 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1962 * Handle the activate/deactivate event
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1963 * (apply to a window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1964 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1965 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1966 gui_mac_doActivateEvent(EventRecord *event)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1967 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1968 WindowPtr whichWindow;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1969
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1970 whichWindow = (WindowPtr) event->message;
1292
66e40876590b updated for version 7.1-007
vimboss
parents: 1212
diff changeset
1971 /* Dim scrollbars */
66e40876590b updated for version 7.1-007
vimboss
parents: 1212
diff changeset
1972 if (whichWindow == gui.VimWindow)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1973 {
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
1974 ControlRef rootControl;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
1975 GetRootControl(gui.VimWindow, &rootControl);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
1976 if ((event->modifiers) & activeFlag)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
1977 ActivateControl(rootControl);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
1978 else
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
1979 DeactivateControl(rootControl);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1980 }
1292
66e40876590b updated for version 7.1-007
vimboss
parents: 1212
diff changeset
1981
66e40876590b updated for version 7.1-007
vimboss
parents: 1212
diff changeset
1982 /* Activate */
66e40876590b updated for version 7.1-007
vimboss
parents: 1212
diff changeset
1983 gui_focus_change((event->modifiers) & activeFlag);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1984 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1985
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1986
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1987 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1988 * Handle the suspend/resume event
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1989 * (apply to the application)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1990 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1991 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
1992 gui_mac_doSuspendEvent(EventRecord *event)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1993 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1994 /* The frontmost application just changed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1995
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1996 /* NOTE: the suspend may happen before the deactivate
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1997 * seen on MacOS X
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1998 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1999
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2000 /* May not need to change focus as the window will
1212
e085b0f7b036 updated for version 7.1b
vimboss
parents: 1107
diff changeset
2001 * get an activate/deactivate event
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2002 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2003 if (event->message & 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2004 /* Resume */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2005 gui_focus_change(TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2006 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2007 /* Suspend */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2008 gui_focus_change(FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2009 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2010
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2011 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2012 * Handle the key
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2013 */
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2014 #ifdef USE_CARBONKEYHANDLER
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2015 static pascal OSStatus
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2016 gui_mac_handle_window_activate(
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2017 EventHandlerCallRef nextHandler,
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2018 EventRef theEvent,
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2019 void *data)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2020 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2021 UInt32 eventClass = GetEventClass(theEvent);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2022 UInt32 eventKind = GetEventKind(theEvent);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2023
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2024 if (eventClass == kEventClassWindow)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2025 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2026 switch (eventKind)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2027 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2028 case kEventWindowActivated:
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2029 #if defined(USE_IM_CONTROL)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2030 im_on_window_switch(TRUE);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2031 #endif
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2032 return noErr;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2033
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2034 case kEventWindowDeactivated:
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2035 #if defined(USE_IM_CONTROL)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2036 im_on_window_switch(FALSE);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2037 #endif
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2038 return noErr;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2039 }
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2040 }
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2041
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2042 return eventNotHandledErr;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2043 }
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2044
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2045 static pascal OSStatus
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2046 gui_mac_handle_text_input(
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2047 EventHandlerCallRef nextHandler,
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2048 EventRef theEvent,
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2049 void *data)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2050 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2051 UInt32 eventClass = GetEventClass(theEvent);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2052 UInt32 eventKind = GetEventKind(theEvent);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2053
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2054 if (eventClass != kEventClassTextInput)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2055 return eventNotHandledErr;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2056
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2057 if ((kEventTextInputUpdateActiveInputArea != eventKind) &&
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2058 (kEventTextInputUnicodeForKeyEvent != eventKind) &&
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2059 (kEventTextInputOffsetToPos != eventKind) &&
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2060 (kEventTextInputPosToOffset != eventKind) &&
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2061 (kEventTextInputGetSelectedText != eventKind))
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2062 return eventNotHandledErr;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2063
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2064 switch (eventKind)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2065 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2066 case kEventTextInputUpdateActiveInputArea:
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2067 return gui_mac_update_input_area(nextHandler, theEvent);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2068 case kEventTextInputUnicodeForKeyEvent:
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2069 return gui_mac_unicode_key_event(nextHandler, theEvent);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2070
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2071 case kEventTextInputOffsetToPos:
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2072 case kEventTextInputPosToOffset:
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2073 case kEventTextInputGetSelectedText:
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2074 break;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2075 }
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2076
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2077 return eventNotHandledErr;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2078 }
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2079
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2080 static pascal
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2081 OSStatus gui_mac_update_input_area(
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2082 EventHandlerCallRef nextHandler,
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2083 EventRef theEvent)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2084 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2085 return eventNotHandledErr;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2086 }
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2087
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2088 static int dialog_busy = FALSE; /* TRUE when gui_mch_dialog() wants the
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2089 keys */
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
2090
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2091 # define INLINE_KEY_BUFFER_SIZE 80
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2092 static pascal OSStatus
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2093 gui_mac_unicode_key_event(
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
2094 EventHandlerCallRef nextHandler,
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2095 EventRef theEvent)
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2096 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2097 /* Multibyte-friendly key event handler */
1012
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2098 OSStatus err = -1;
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2099 UInt32 actualSize;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2100 UniChar *text;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2101 char_u result[INLINE_KEY_BUFFER_SIZE];
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2102 short len = 0;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2103 UInt32 key_sym;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2104 char charcode;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2105 int key_char;
1012
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2106 UInt32 modifiers, vimModifiers;
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2107 size_t encLen;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2108 char_u *to = NULL;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2109 Boolean isSpecial = FALSE;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2110 int i;
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2111 EventRef keyEvent;
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2112
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2113 /* Mask the mouse (as per user setting) */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2114 if (p_mh)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2115 ObscureCursor();
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2116
1012
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2117 /* Don't use the keys when the dialog wants them. */
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2118 if (dialog_busy)
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2119 return eventNotHandledErr;
1012
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2120
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2121 if (noErr != GetEventParameter(theEvent, kEventParamTextInputSendText,
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2122 typeUnicodeText, NULL, 0, &actualSize, NULL))
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2123 return eventNotHandledErr;
1012
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2124
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2125 text = (UniChar *)alloc(actualSize);
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2126 if (!text)
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2127 return eventNotHandledErr;
1012
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2128
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2129 err = GetEventParameter(theEvent, kEventParamTextInputSendText,
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2130 typeUnicodeText, NULL, actualSize, NULL, text);
1012
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2131 require_noerr(err, done);
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2132
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2133 err = GetEventParameter(theEvent, kEventParamTextInputSendKeyboardEvent,
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2134 typeEventRef, NULL, sizeof(EventRef), NULL, &keyEvent);
1012
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2135 require_noerr(err, done);
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2136
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2137 err = GetEventParameter(keyEvent, kEventParamKeyModifiers,
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2138 typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
1012
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2139 require_noerr(err, done);
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2140
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2141 err = GetEventParameter(keyEvent, kEventParamKeyCode,
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2142 typeUInt32, NULL, sizeof(UInt32), NULL, &key_sym);
1012
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2143 require_noerr(err, done);
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2144
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2145 err = GetEventParameter(keyEvent, kEventParamKeyMacCharCodes,
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2146 typeChar, NULL, sizeof(char), NULL, &charcode);
1012
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2147 require_noerr(err, done);
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2148
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2149 #ifndef USE_CMD_KEY
1012
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2150 if (modifiers & cmdKey)
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2151 goto done; /* Let system handle Cmd+... */
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2152 #endif
1012
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2153
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2154 key_char = charcode;
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2155 vimModifiers = EventModifiers2VimModifiers(modifiers);
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2156
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2157 /* Find the special key (eg., for cursor keys) */
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2158 if (actualSize <= sizeof(UniChar) &&
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2159 ((text[0] < 0x20) || (text[0] == 0x7f)))
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2160 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2161 for (i = 0; special_keys[i].key_sym != (KeySym)0; ++i)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2162 if (special_keys[i].key_sym == key_sym)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2163 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2164 key_char = TO_SPECIAL(special_keys[i].vim_code0,
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2165 special_keys[i].vim_code1);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2166 key_char = simplify_key(key_char,
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2167 (int *)&vimModifiers);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2168 isSpecial = TRUE;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2169 break;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2170 }
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2171 }
1012
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2172
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2173 /* Intercept CMD-. and CTRL-c */
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2174 if (((modifiers & controlKey) && key_char == 'c') ||
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2175 ((modifiers & cmdKey) && key_char == '.'))
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2176 got_int = TRUE;
1012
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2177
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2178 if (!isSpecial)
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2179 {
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2180 /* remove SHIFT for keys that are already shifted, e.g.,
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2181 * '(' and '*' */
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2182 if (key_char < 0x100 && !isalpha(key_char) && isprint(key_char))
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2183 vimModifiers &= ~MOD_MASK_SHIFT;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2184
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2185 /* remove CTRL from keys that already have it */
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2186 if (key_char < 0x20)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2187 vimModifiers &= ~MOD_MASK_CTRL;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2188
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2189 /* don't process unicode characters here */
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2190 if (!IS_SPECIAL(key_char))
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2191 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2192 /* Following code to simplify and consolidate vimModifiers
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2193 * taken liberally from gui_w48.c */
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2194 key_char = simplify_key(key_char, (int *)&vimModifiers);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2195
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2196 /* Interpret META, include SHIFT, etc. */
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2197 key_char = extract_modifiers(key_char, (int *)&vimModifiers);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2198 if (key_char == CSI)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2199 key_char = K_CSI;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2200
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2201 if (IS_SPECIAL(key_char))
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2202 isSpecial = TRUE;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2203 }
1012
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2204 }
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2205
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2206 if (vimModifiers)
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2207 {
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2208 result[len++] = CSI;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2209 result[len++] = KS_MODIFIER;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2210 result[len++] = vimModifiers;
1012
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2211 }
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2212
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2213 if (isSpecial && IS_SPECIAL(key_char))
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2214 {
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2215 result[len++] = CSI;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2216 result[len++] = K_SECOND(key_char);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2217 result[len++] = K_THIRD(key_char);
1012
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2218 }
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2219 else
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2220 {
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2221 encLen = actualSize;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2222 to = mac_utf16_to_enc(text, actualSize, &encLen);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2223 if (to)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2224 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2225 /* This is basically add_to_input_buf_csi() */
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2226 for (i = 0; i < encLen && len < (INLINE_KEY_BUFFER_SIZE-1); ++i)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2227 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2228 result[len++] = to[i];
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2229 if (to[i] == CSI)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2230 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2231 result[len++] = KS_EXTRA;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2232 result[len++] = (int)KE_CSI;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2233 }
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2234 }
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2235 vim_free(to);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2236 }
1012
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2237 }
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2238
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2239 add_to_input_buf(result, len);
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2240 err = noErr;
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2241
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2242 done:
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2243 vim_free(text);
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2244 if (err == noErr)
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2245 {
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2246 /* Fake event to wake up WNE (required to get
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2247 * key repeat working */
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2248 PostEvent(keyUp, 0);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2249 return noErr;
1012
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2250 }
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2251
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
2252 return eventNotHandledErr;
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2253 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2254 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2255 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2256 gui_mac_doKeyEvent(EventRecord *theEvent)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2257 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2258 /* TODO: add support for COMMAND KEY */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2259 long menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2260 unsigned char string[20];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2261 short num, i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2262 short len = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2263 KeySym key_sym;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2264 int key_char;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2265 int modifiers;
26
404aac550f35 updated for version 7.0017
vimboss
parents: 19
diff changeset
2266 int simplify = FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2267
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2268 /* Mask the mouse (as per user setting) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2269 if (p_mh)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2270 ObscureCursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2271
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2272 /* Get the key code and it's ASCII representation */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2273 key_sym = ((theEvent->message & keyCodeMask) >> 8);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2274 key_char = theEvent->message & charCodeMask;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2275 num = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2276
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2277 /* Intercept CTRL-C */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2278 if (theEvent->modifiers & controlKey)
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2279 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2280 if (key_char == Ctrl_C && ctrl_c_interrupts)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2281 got_int = TRUE;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2282 else if ((theEvent->modifiers & ~(controlKey|shiftKey)) == 0
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2283 && (key_char == '2' || key_char == '6'))
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2284 {
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2285 /* CTRL-^ and CTRL-@ don't work in the normal way. */
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2286 if (key_char == '2')
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2287 key_char = Ctrl_AT;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2288 else
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2289 key_char = Ctrl_HAT;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2290 theEvent->modifiers = 0;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2291 }
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2292 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2293
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2294 /* Intercept CMD-. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2295 if (theEvent->modifiers & cmdKey)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2296 if (key_char == '.')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2297 got_int = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2298
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2299 /* Handle command key as per menu */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2300 /* TODO: should override be allowed? Require YAO or could use 'winaltkey' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2301 if (theEvent->modifiers & cmdKey)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2302 /* Only accept CMD alone or with CAPLOCKS and the mouse button.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2303 * Why the mouse button? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2304 if ((theEvent->modifiers & (~(cmdKey | btnState | alphaLock))) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2305 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2306 menu = MenuKey(key_char);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2307 if (HiWord(menu))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2308 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2309 gui_mac_handle_menu(menu);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2310 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2311 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2312 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2313
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2314 /* Convert the modifiers */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2315 modifiers = EventModifiers2VimModifiers(theEvent->modifiers);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2316
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2317
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2318 /* Handle special keys. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2319 #if 0
26
404aac550f35 updated for version 7.0017
vimboss
parents: 19
diff changeset
2320 /* Why has this been removed? */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2321 if (!(theEvent->modifiers & (cmdKey | controlKey | rightControlKey)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2322 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2323 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2324 /* Find the special key (for non-printable keyt_char) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2325 if ((key_char < 0x20) || (key_char == 0x7f))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2326 for (i = 0; special_keys[i].key_sym != (KeySym)0; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2327 if (special_keys[i].key_sym == key_sym)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2328 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2329 # if 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2330 /* We currently don't have not so special key */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2331 if (special_keys[i].vim_code1 == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2332 key_char = special_keys[i].vim_code0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2333 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2334 # endif
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2335 key_char = TO_SPECIAL(special_keys[i].vim_code0,
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2336 special_keys[i].vim_code1);
26
404aac550f35 updated for version 7.0017
vimboss
parents: 19
diff changeset
2337 simplify = TRUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2338 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2339 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2340 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2341
26
404aac550f35 updated for version 7.0017
vimboss
parents: 19
diff changeset
2342 /* For some keys the modifier is included in the char itself. */
404aac550f35 updated for version 7.0017
vimboss
parents: 19
diff changeset
2343 if (simplify || key_char == TAB || key_char == ' ')
404aac550f35 updated for version 7.0017
vimboss
parents: 19
diff changeset
2344 key_char = simplify_key(key_char, &modifiers);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2345
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2346 /* Add the modifier to the input bu if needed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2347 /* Do not want SHIFT-A or CTRL-A with modifier */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2348 if (!IS_SPECIAL(key_char)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2349 && key_sym != vk_Space
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2350 && key_sym != vk_Tab
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2351 && key_sym != vk_Return
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2352 && key_sym != vk_Enter
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2353 && key_sym != vk_Esc)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2354 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2355 #if 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2356 /* Clear modifiers when only one modifier is set */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2357 if ((modifiers == MOD_MASK_SHIFT)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2358 || (modifiers == MOD_MASK_CTRL)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2359 || (modifiers == MOD_MASK_ALT))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2360 modifiers = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2361 #else
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2362 if (modifiers & MOD_MASK_CTRL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2363 modifiers = modifiers & ~MOD_MASK_CTRL;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2364 if (modifiers & MOD_MASK_ALT)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2365 modifiers = modifiers & ~MOD_MASK_ALT;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2366 if (modifiers & MOD_MASK_SHIFT)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2367 modifiers = modifiers & ~MOD_MASK_SHIFT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2368 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2369 }
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2370 if (modifiers)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2371 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2372 string[len++] = CSI;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2373 string[len++] = KS_MODIFIER;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2374 string[len++] = modifiers;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2375 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2376
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2377 if (IS_SPECIAL(key_char))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2378 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2379 string[len++] = CSI;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2380 string[len++] = K_SECOND(key_char);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2381 string[len++] = K_THIRD(key_char);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2382 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2383 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2384 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2385 #ifdef FEAT_MBYTE
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2386 /* Convert characters when needed (e.g., from MacRoman to latin1).
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2387 * This doesn't work for the NUL byte. */
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2388 if (input_conv.vc_type != CONV_NONE && key_char > 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2389 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2390 char_u from[2], *to;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2391 int l;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2392
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2393 from[0] = key_char;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2394 from[1] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2395 l = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2396 to = string_convert(&input_conv, from, &l);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2397 if (to != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2398 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2399 for (i = 0; i < l && len < 19; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2400 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2401 if (to[i] == CSI)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2402 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2403 string[len++] = KS_EXTRA;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2404 string[len++] = KE_CSI;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2405 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2406 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2407 string[len++] = to[i];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2408 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2409 vim_free(to);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2410 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2411 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2412 string[len++] = key_char;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2413 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2414 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2415 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2416 string[len++] = key_char;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2417 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2418
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2419 if (len == 1 && string[0] == CSI)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2420 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2421 /* Turn CSI into K_CSI. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2422 string[ len++ ] = KS_EXTRA;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2423 string[ len++ ] = KE_CSI;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2424 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2425
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2426 add_to_input_buf(string, len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2427 }
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2428 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2429
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2430 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2431 * Handle MouseClick
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2432 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2433 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
2434 gui_mac_doMouseDownEvent(EventRecord *theEvent)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2435 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2436 short thePart;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2437 WindowPtr whichWindow;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2438
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2439 thePart = FindWindow(theEvent->where, &whichWindow);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2440
1106
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
2441 #ifdef FEAT_GUI_TABLINE
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
2442 /* prevent that the vim window size changes if it's activated by a
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
2443 click into the tab pane */
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
2444 if (whichWindow == drawer)
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2445 return;
1106
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
2446 #endif
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
2447
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2448 switch (thePart)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2449 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2450 case (inDesk):
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2451 /* TODO: what to do? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2452 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2453
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2454 case (inMenuBar):
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2455 gui_mac_handle_menu(MenuSelect(theEvent->where));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2456 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2457
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2458 case (inContent):
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2459 gui_mac_doInContentClick(theEvent, whichWindow);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2460 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2461
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2462 case (inDrag):
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2463 gui_mac_doInDragClick(theEvent->where, whichWindow);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2464 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2465
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2466 case (inGrow):
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2467 gui_mac_doInGrowClick(theEvent->where, whichWindow);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2468 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2469
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2470 case (inGoAway):
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2471 if (TrackGoAway(whichWindow, theEvent->where))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2472 gui_shell_closed();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2473 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2474
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2475 case (inZoomIn):
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2476 case (inZoomOut):
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2477 gui_mac_doInZoomClick(theEvent, whichWindow);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2478 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2479 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2480 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2481
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2482 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2483 * Handle MouseMoved
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2484 * [this event is a moving in and out of a region]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2485 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2486 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
2487 gui_mac_doMouseMovedEvent(EventRecord *event)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2488 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2489 Point thePoint;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2490 int_u vimModifiers;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2491
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2492 thePoint = event->where;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2493 GlobalToLocal(&thePoint);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2494 vimModifiers = EventModifiers2VimMouseModifiers(event->modifiers);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2495
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2496 if (!Button())
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2497 gui_mouse_moved(thePoint.h, thePoint.v);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2498 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2499 if (!clickIsPopup)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2500 gui_send_mouse_event(MOUSE_DRAG, thePoint.h,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2501 thePoint.v, FALSE, vimModifiers);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2502
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2503 /* Reset the region from which we move in and out */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2504 SetRect(&dragRect, FILL_X(X_2_COL(thePoint.h)),
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2505 FILL_Y(Y_2_ROW(thePoint.v)),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2506 FILL_X(X_2_COL(thePoint.h)+1),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2507 FILL_Y(Y_2_ROW(thePoint.v)+1));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2508
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2509 if (dragRectEnbl)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2510 dragRectControl = kCreateRect;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2511
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2512 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2513
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2514 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2515 * Handle the mouse release
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2516 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2517 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
2518 gui_mac_doMouseUpEvent(EventRecord *theEvent)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2519 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2520 Point thePoint;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2521 int_u vimModifiers;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2522
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2523 /* TODO: Properly convert the Contextual menu mouse-up */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2524 /* Potential source of the double menu */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2525 lastMouseTick = theEvent->when;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2526 dragRectEnbl = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2527 dragRectControl = kCreateEmpty;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2528 thePoint = theEvent->where;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2529 GlobalToLocal(&thePoint);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2530
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2531 vimModifiers = EventModifiers2VimMouseModifiers(theEvent->modifiers);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2532 if (clickIsPopup)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2533 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2534 vimModifiers &= ~MOUSE_CTRL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2535 clickIsPopup = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2536 }
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2537 gui_send_mouse_event(MOUSE_RELEASE, thePoint.h, thePoint.v, FALSE, vimModifiers);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2538 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2539
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2540 static pascal OSStatus
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2541 gui_mac_mouse_wheel(EventHandlerCallRef nextHandler, EventRef theEvent,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2542 void *data)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2543 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2544 Point point;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2545 Rect bounds;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2546 UInt32 mod;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2547 SInt32 delta;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2548 int_u vim_mod;
939
31208ed42de9 updated for version 7.0-065
vimboss
parents: 857
diff changeset
2549 EventMouseWheelAxis axis;
31208ed42de9 updated for version 7.0-065
vimboss
parents: 857
diff changeset
2550
31208ed42de9 updated for version 7.0-065
vimboss
parents: 857
diff changeset
2551 if (noErr == GetEventParameter(theEvent, kEventParamMouseWheelAxis,
31208ed42de9 updated for version 7.0-065
vimboss
parents: 857
diff changeset
2552 typeMouseWheelAxis, NULL, sizeof(axis), NULL, &axis)
31208ed42de9 updated for version 7.0-065
vimboss
parents: 857
diff changeset
2553 && axis != kEventMouseWheelAxisY)
31208ed42de9 updated for version 7.0-065
vimboss
parents: 857
diff changeset
2554 goto bail; /* Vim only does up-down scrolling */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2555
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2556 if (noErr != GetEventParameter(theEvent, kEventParamMouseWheelDelta,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2557 typeSInt32, NULL, sizeof(SInt32), NULL, &delta))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2558 goto bail;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2559 if (noErr != GetEventParameter(theEvent, kEventParamMouseLocation,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2560 typeQDPoint, NULL, sizeof(Point), NULL, &point))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2561 goto bail;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2562 if (noErr != GetEventParameter(theEvent, kEventParamKeyModifiers,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2563 typeUInt32, NULL, sizeof(UInt32), NULL, &mod))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2564 goto bail;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2565
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2566 vim_mod = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2567 if (mod & shiftKey)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2568 vim_mod |= MOUSE_SHIFT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2569 if (mod & controlKey)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2570 vim_mod |= MOUSE_CTRL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2571 if (mod & optionKey)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2572 vim_mod |= MOUSE_ALT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2573
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2574 if (noErr == GetWindowBounds(gui.VimWindow, kWindowContentRgn, &bounds))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2575 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2576 point.h -= bounds.left;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2577 point.v -= bounds.top;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2578 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2579
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2580 gui_send_mouse_event((delta > 0) ? MOUSE_4 : MOUSE_5,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2581 point.h, point.v, FALSE, vim_mod);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2582
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1621
diff changeset
2583 /* post a bogus event to wake up WaitNextEvent */
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1621
diff changeset
2584 PostEvent(keyUp, 0);
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1621
diff changeset
2585
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2586 return noErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2587
1107
2ced59eaf1e5 updated for version 7.0-233
vimboss
parents: 1106
diff changeset
2588 bail:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2589 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2590 * when we fail give any additional callback handler a chance to perform
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2591 * it's actions
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2592 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2593 return CallNextEventHandler(nextHandler, theEvent);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2594 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2595
2565
4b7929dad28a Fix building the Mac version with GUI.
Bram Moolenaar <bram@vim.org>
parents: 2338
diff changeset
2596 void
4b7929dad28a Fix building the Mac version with GUI.
Bram Moolenaar <bram@vim.org>
parents: 2338
diff changeset
2597 gui_mch_mousehide(int hide)
4b7929dad28a Fix building the Mac version with GUI.
Bram Moolenaar <bram@vim.org>
parents: 2338
diff changeset
2598 {
4b7929dad28a Fix building the Mac version with GUI.
Bram Moolenaar <bram@vim.org>
parents: 2338
diff changeset
2599 /* TODO */
4b7929dad28a Fix building the Mac version with GUI.
Bram Moolenaar <bram@vim.org>
parents: 2338
diff changeset
2600 }
4b7929dad28a Fix building the Mac version with GUI.
Bram Moolenaar <bram@vim.org>
parents: 2338
diff changeset
2601
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2602 #if 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2603
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2604 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2605 * This would be the normal way of invoking the contextual menu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2606 * but the Vim API doesn't seem to a support a request to get
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2607 * the menu that we should display
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2608 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2609 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2610 gui_mac_handle_contextual_menu(event)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2611 EventRecord *event;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2612 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2613 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2614 * Clone PopUp to use menu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2615 * Create a object descriptor for the current selection
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2616 * Call the procedure
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2617 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2618
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2619 // Call to Handle Popup
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2620 OSStatus status = ContextualMenuSelect(CntxMenu, event->where, false, kCMHelpItemNoHelp, "", NULL, &CntxType, &CntxMenuID, &CntxMenuItem);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2621
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2622 if (status != noErr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2623 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2624
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2625 if (CntxType == kCMMenuItemSelected)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2626 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2627 /* Handle the menu CntxMenuID, CntxMenuItem */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2628 /* The submenu can be handle directly by gui_mac_handle_menu */
4352
04736b4030ec updated for version 7.3.925
Bram Moolenaar <bram@vim.org>
parents: 3935
diff changeset
2629 /* But what about the current menu, is the many changed by ContextualMenuSelect */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2630 gui_mac_handle_menu((CntxMenuID << 16) + CntxMenuItem);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2631 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2632 else if (CntxMenuID == kCMShowHelpSelected)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2633 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2634 /* Should come up with the help */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2635 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2636
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2637 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2638 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2639
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2640 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2641 * Handle menubar selection
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2642 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2643 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
2644 gui_mac_handle_menu(long menuChoice)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2645 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2646 short menu = HiWord(menuChoice);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2647 short item = LoWord(menuChoice);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2648 vimmenu_T *theVimMenu = root_menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2649
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2650 if (menu == 256) /* TODO: use constant or gui.xyz */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2651 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2652 if (item == 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2653 gui_mch_beep(); /* TODO: Popup dialog or do :intro */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2654 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2655 else if (item != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2656 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2657 theVimMenu = gui_mac_get_vim_menu(menu, item, root_menu);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2658
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2659 if (theVimMenu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2660 gui_menu_cb(theVimMenu);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2661 }
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2662 HiliteMenu(0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2663 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2664
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2665 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2666 * Dispatch the event to proper handler
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2667 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2668
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2669 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
2670 gui_mac_handle_event(EventRecord *event)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2671 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2672 OSErr error;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2673
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2674 /* Handle contextual menu right now (if needed) */
1292
66e40876590b updated for version 7.1-007
vimboss
parents: 1212
diff changeset
2675 if (IsShowContextualMenuClick(event))
66e40876590b updated for version 7.1-007
vimboss
parents: 1212
diff changeset
2676 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2677 # if 0
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2678 gui_mac_handle_contextual_menu(event);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2679 # else
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2680 gui_mac_doMouseDownEvent(event);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2681 # endif
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
2682 return;
1292
66e40876590b updated for version 7.1-007
vimboss
parents: 1212
diff changeset
2683 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2684
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2685 /* Handle normal event */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2686 switch (event->what)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2687 {
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2688 #ifndef USE_CARBONKEYHANDLER
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2689 case (keyDown):
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2690 case (autoKey):
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2691 gui_mac_doKeyEvent(event);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2692 break;
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2693 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2694 case (keyUp):
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
2695 /* We don't care about when the key is released */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2696 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2697
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2698 case (mouseDown):
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2699 gui_mac_doMouseDownEvent(event);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2700 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2701
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2702 case (mouseUp):
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2703 gui_mac_doMouseUpEvent(event);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2704 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2705
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2706 case (updateEvt):
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2707 gui_mac_doUpdateEvent(event);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2708 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2709
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2710 case (diskEvt):
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2711 /* We don't need special handling for disk insertion */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2712 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2713
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2714 case (activateEvt):
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2715 gui_mac_doActivateEvent(event);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2716 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2717
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2718 case (osEvt):
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2719 switch ((event->message >> 24) & 0xFF)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2720 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2721 case (0xFA): /* mouseMovedMessage */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2722 gui_mac_doMouseMovedEvent(event);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2723 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2724 case (0x01): /* suspendResumeMessage */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2725 gui_mac_doSuspendEvent(event);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2726 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2727 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2728 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2729
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2730 #ifdef USE_AEVENT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2731 case (kHighLevelEvent):
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2732 /* Someone's talking to us, through AppleEvents */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2733 error = AEProcessAppleEvent(event); /* TODO: Error Handling */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2734 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2735 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2736 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2737 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2738
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2739 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2740 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2741 * Unknown Stuff
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2742 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2743 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2744
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2745
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2746 GuiFont
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
2747 gui_mac_find_font(char_u *font_name)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2748 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2749 char_u c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2750 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2751 char_u pFontName[256];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2752 Str255 systemFontname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2753 short font_id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2754 short size=9;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2755 GuiFont font;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2756 #if 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2757 char_u *fontNamePtr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2758 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2759
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2760 for (p = font_name; ((*p != 0) && (*p != ':')); p++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2761 ;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2762
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2763 c = *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2764 *p = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2765
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2766 #if 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2767 STRCPY(&pFontName[1], font_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2768 pFontName[0] = STRLEN(font_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2769 *p = c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2770
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2771 /* Get the font name, minus the style suffix (:h, etc) */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2772 char_u fontName[256];
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2773 char_u *styleStart = vim_strchr(font_name, ':');
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2774 size_t fontNameLen = styleStart ? styleStart - font_name : STRLEN(fontName);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2775 vim_strncpy(fontName, font_name, fontNameLen);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2776
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2777 ATSUFontID fontRef;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2778 FMFontStyle fontStyle;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2779 font_id = 0;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2780
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2781 if (ATSUFindFontFromName(&pFontName[1], pFontName[0], kFontFullName,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2782 kFontMacintoshPlatform, kFontNoScriptCode, kFontNoLanguageCode,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2783 &fontRef) == noErr)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2784 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2785 if (FMGetFontFamilyInstanceFromFont(fontRef, &font_id, &fontStyle) != noErr)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2786 font_id = 0;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2787 }
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
2788
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
2789 if (font_id == 0)
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
2790 {
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
2791 /*
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
2792 * Try again, this time replacing underscores in the font name
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
2793 * with spaces (:set guifont allows the two to be used
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
2794 * interchangeably; the Font Manager doesn't).
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
2795 */
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
2796 int i, changed = FALSE;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
2797
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
2798 for (i = pFontName[0]; i > 0; --i)
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
2799 {
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
2800 if (pFontName[i] == '_')
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
2801 {
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
2802 pFontName[i] = ' ';
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
2803 changed = TRUE;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
2804 }
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
2805 }
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
2806 if (changed)
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2807 if (ATSUFindFontFromName(&pFontName[1], pFontName[0],
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2808 kFontFullName, kFontNoPlatformCode, kFontNoScriptCode,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2809 kFontNoLanguageCode, &fontRef) == noErr)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2810 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2811 if (FMGetFontFamilyInstanceFromFont(fontRef, &font_id, &fontStyle) != noErr)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2812 font_id = 0;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2813 }
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
2814 }
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
2815
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2816 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2817 /* name = C2Pascal_save(menu->dname); */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2818 fontNamePtr = C2Pascal_save_and_remove_backslash(font_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2819
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2820 GetFNum(fontNamePtr, &font_id);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2821 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2822
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2823
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2824 if (font_id == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2825 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2826 /* Oups, the system font was it the one the user want */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2827
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2828 if (FMGetFontFamilyName(systemFont, systemFontname) != noErr)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2829 return NOFONT;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2830 if (!EqualString(pFontName, systemFontname, false, false))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2831 return NOFONT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2832 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2833 if (*p == ':')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2834 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2835 p++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2836 /* Set the values found after ':' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2837 while (*p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2838 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2839 switch (*p++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2840 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2841 case 'h':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2842 size = points_to_pixels(p, &p, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2843 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2844 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2845 * TODO: Maybe accept width and styles
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2846 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2847 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2848 while (*p == ':')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2849 p++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2850 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2851 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2852
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2853 if (size < 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2854 size = 1; /* Avoid having a size of 0 with system font */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2855
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2856 font = (size << 16) + ((long) font_id & 0xFFFF);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2857
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2858 return font;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2859 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2860
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2861 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2862 * ------------------------------------------------------------
1212
e085b0f7b036 updated for version 7.1b
vimboss
parents: 1107
diff changeset
2863 * GUI_MCH functionality
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2864 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2865 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2866
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2867 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2868 * Parse the GUI related command-line arguments. Any arguments used are
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2869 * deleted from argv, and *argc is decremented accordingly. This is called
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2870 * when vim is started, whether or not the GUI has been started.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2871 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2872 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
2873 gui_mch_prepare(int *argc, char **argv)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2874 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2875 /* TODO: Move most of this stuff toward gui_mch_init */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2876 #ifdef USE_EXE_NAME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2877 FSSpec applDir;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2878 # ifndef USE_FIND_BUNDLE_PATH
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2879 short applVRefNum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2880 long applDirID;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2881 Str255 volName;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2882 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2883 ProcessSerialNumber psn;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2884 FSRef applFSRef;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2885 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2886 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2887
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2888 #if 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2889 InitCursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2890
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2891 RegisterAppearanceClient();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2892
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2893 #ifdef USE_AEVENT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2894 (void) InstallAEHandlers();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2895 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2896
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2897 pomme = NewMenu(256, "\p\024"); /* 0x14= = Apple Menu */
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2898
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2899 AppendMenu(pomme, "\pAbout VIM");
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2900
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2901 InsertMenu(pomme, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2902
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2903 DrawMenuBar();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2904
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2905
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2906 #ifndef USE_OFFSETED_WINDOW
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2907 SetRect(&windRect, 10, 48, 10+80*7 + 16, 48+24*11);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2908 #else
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2909 SetRect(&windRect, 300, 40, 300+80*7 + 16, 40+24*11);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2910 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2911
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2912
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2913 CreateNewWindow(kDocumentWindowClass,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2914 kWindowResizableAttribute | kWindowCollapseBoxAttribute,
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2915 &windRect, &gui.VimWindow);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2916 SetPortWindowPort(gui.VimWindow);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2917
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2918 gui.char_width = 7;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2919 gui.char_height = 11;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2920 gui.char_ascent = 6;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2921 gui.num_rows = 24;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2922 gui.num_cols = 80;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2923 gui.in_focus = TRUE; /* For the moment -> syn. of front application */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2924
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2925 gScrollAction = NewControlActionUPP(gui_mac_scroll_action);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2926 gScrollDrag = NewControlActionUPP(gui_mac_drag_thumb);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2927
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2928 dragRectEnbl = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2929 dragRgn = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2930 dragRectControl = kCreateEmpty;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2931 cursorRgn = NewRgn();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2932 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2933 #ifdef USE_EXE_NAME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2934 # ifndef USE_FIND_BUNDLE_PATH
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2935 HGetVol(volName, &applVRefNum, &applDirID);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2936 /* TN2015: mention a possible bad VRefNum */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2937 FSMakeFSSpec(applVRefNum, applDirID, "\p", &applDir);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2938 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2939 /* OSErr GetApplicationBundleFSSpec(FSSpecPtr theFSSpecPtr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2940 * of TN2015
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2941 */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2942 (void)GetCurrentProcess(&psn);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2943 /* if (err != noErr) return err; */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2944
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2945 (void)GetProcessBundleLocation(&psn, &applFSRef);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2946 /* if (err != noErr) return err; */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2947
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2948 (void)FSGetCatalogInfo(&applFSRef, kFSCatInfoNone, NULL, NULL, &applDir, NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2949
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2950 /* This technic return NIL when we disallow_gui */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2951 # endif
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2952 exe_name = FullPathFromFSSpec_save(applDir);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2953 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2954 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2955
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2956 #ifndef ALWAYS_USE_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2957 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2958 * Check if the GUI can be started. Called before gvimrc is sourced.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2959 * Return OK or FAIL.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2960 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2961 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2962 gui_mch_init_check(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2963 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2964 /* TODO: For MacOS X find a way to return FAIL, if the user logged in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2965 * using the >console
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2966 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2967 if (disallow_gui) /* see main.c for reason to disallow */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2968 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2969 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2970 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2971 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2972
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2973 static OSErr
1107
2ced59eaf1e5 updated for version 7.0-233
vimboss
parents: 1106
diff changeset
2974 receiveHandler(WindowRef theWindow, void *handlerRefCon, DragRef theDrag)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2975 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2976 int x, y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2977 int_u modifiers;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2978 char_u **fnames = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2979 int count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2980 int i, j;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2981
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2982 /* Get drop position, modifiers and count of items */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2983 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2984 Point point;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2985 SInt16 mouseUpModifiers;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2986 UInt16 countItem;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2987
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2988 GetDragMouse(theDrag, &point, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2989 GlobalToLocal(&point);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2990 x = point.h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2991 y = point.v;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2992 GetDragModifiers(theDrag, NULL, NULL, &mouseUpModifiers);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2993 modifiers = EventModifiers2VimMouseModifiers(mouseUpModifiers);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2994 CountDragItems(theDrag, &countItem);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2995 count = countItem;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2996 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2997
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2998 fnames = (char_u **)alloc(count * sizeof(char_u *));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2999 if (fnames == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3000 return dragNotAcceptedErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3001
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3002 /* Get file names dropped */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3003 for (i = j = 0; i < count; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3004 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3005 DragItemRef item;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3006 OSErr err;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3007 Size size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3008 FlavorType type = flavorTypeHFS;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3009 HFSFlavor hfsFlavor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3010
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3011 fnames[i] = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3012 GetDragItemReferenceNumber(theDrag, i + 1, &item);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3013 err = GetFlavorDataSize(theDrag, item, type, &size);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3014 if (err != noErr || size > sizeof(hfsFlavor))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3015 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3016 err = GetFlavorData(theDrag, item, type, &hfsFlavor, &size, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3017 if (err != noErr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3018 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3019 fnames[j++] = FullPathFromFSSpec_save(hfsFlavor.fileSpec);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3020 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3021 count = j;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3022
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3023 gui_handle_drop(x, y, modifiers, fnames, count);
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3024
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3025 /* Fake mouse event to wake from stall */
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3026 PostEvent(mouseUp, 0);
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3027
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3028 return noErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3029 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3030
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3031 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3032 * Initialise the GUI. Create all the windows, set up all the call-backs
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3033 * etc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3034 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3035 int
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
3036 gui_mch_init(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3037 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3038 /* TODO: Move most of this stuff toward gui_mch_init */
1565
1dd4e0ccd822 updated for version 7.1-278
vimboss
parents: 1562
diff changeset
3039 Rect windRect;
1dd4e0ccd822 updated for version 7.1-278
vimboss
parents: 1562
diff changeset
3040 MenuHandle pomme;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3041 EventHandlerRef mouseWheelHandlerRef;
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3042 EventTypeSpec eventTypeSpec;
1565
1dd4e0ccd822 updated for version 7.1-278
vimboss
parents: 1562
diff changeset
3043 ControlRef rootControl;
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3044
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3045 if (Gestalt(gestaltSystemVersion, &gMacSystemVersion) != noErr)
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
3046 gMacSystemVersion = 0x1000; /* TODO: Default to minimum sensible value */
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3047
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3048 #if 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3049 InitCursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3050
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3051 RegisterAppearanceClient();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3052
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3053 #ifdef USE_AEVENT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3054 (void) InstallAEHandlers();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3055 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3056
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3057 pomme = NewMenu(256, "\p\024"); /* 0x14= = Apple Menu */
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3058
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3059 AppendMenu(pomme, "\pAbout VIM");
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3060
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3061 InsertMenu(pomme, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3062
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3063 DrawMenuBar();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3064
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3065
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3066 #ifndef USE_OFFSETED_WINDOW
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3067 SetRect(&windRect, 10, 48, 10+80*7 + 16, 48+24*11);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3068 #else
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3069 SetRect(&windRect, 300, 40, 300+80*7 + 16, 40+24*11);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3070 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3071
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3072 gui.VimWindow = NewCWindow(nil, &windRect, "\pgVim on Macintosh", true,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3073 zoomDocProc,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3074 (WindowPtr)-1L, true, 0);
1292
66e40876590b updated for version 7.1-007
vimboss
parents: 1212
diff changeset
3075 CreateRootControl(gui.VimWindow, &rootControl);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3076 InstallReceiveHandler((DragReceiveHandlerUPP)receiveHandler,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3077 gui.VimWindow, NULL);
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3078 SetPortWindowPort(gui.VimWindow);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3079
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3080 gui.char_width = 7;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3081 gui.char_height = 11;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3082 gui.char_ascent = 6;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3083 gui.num_rows = 24;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3084 gui.num_cols = 80;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3085 gui.in_focus = TRUE; /* For the moment -> syn. of front application */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3086
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3087 gScrollAction = NewControlActionUPP(gui_mac_scroll_action);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3088 gScrollDrag = NewControlActionUPP(gui_mac_drag_thumb);
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
3089
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3090 /* Install Carbon event callbacks. */
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3091 (void)InstallFontPanelHandler();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3092
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3093 dragRectEnbl = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3094 dragRgn = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3095 dragRectControl = kCreateEmpty;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3096 cursorRgn = NewRgn();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3097 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3098 /* Display any pending error messages */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3099 display_errors();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3100
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3101 /* Get background/foreground colors from system */
1212
e085b0f7b036 updated for version 7.1b
vimboss
parents: 1107
diff changeset
3102 /* TODO: do the appropriate call to get real defaults */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3103 gui.norm_pixel = 0x00000000;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3104 gui.back_pixel = 0x00FFFFFF;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3105
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3106 /* Get the colors from the "Normal" group (set in syntax.c or in a vimrc
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3107 * file). */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3108 set_normal_colors();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3109
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3110 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3111 * Check that none of the colors are the same as the background color.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3112 * Then store the current values as the defaults.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3113 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3114 gui_check_colors();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3115 gui.def_norm_pixel = gui.norm_pixel;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3116 gui.def_back_pixel = gui.back_pixel;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3117
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3118 /* Get the colors for the highlight groups (gui_check_colors() might have
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3119 * changed them) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3120 highlight_gui_started();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3121
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3122 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3123 * Setting the gui constants
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3124 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3125 #ifdef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3126 gui.menu_height = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3127 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3128 gui.scrollbar_height = gui.scrollbar_width = 15; /* cheat 1 overlap */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3129 gui.border_offset = gui.border_width = 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3130
1212
e085b0f7b036 updated for version 7.1b
vimboss
parents: 1107
diff changeset
3131 /* If Quartz-style text anti aliasing is available (see
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3132 gui_mch_draw_string() below), enable it for all font sizes. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3133 vim_setenv((char_u *)"QDTEXT_MINSIZE", (char_u *)"1");
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
3134
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3135 eventTypeSpec.eventClass = kEventClassMouse;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3136 eventTypeSpec.eventKind = kEventMouseWheelMoved;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3137 mouseWheelHandlerUPP = NewEventHandlerUPP(gui_mac_mouse_wheel);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3138 if (noErr != InstallApplicationEventHandler(mouseWheelHandlerUPP, 1,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3139 &eventTypeSpec, NULL, &mouseWheelHandlerRef))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3140 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3141 mouseWheelHandlerRef = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3142 DisposeEventHandlerUPP(mouseWheelHandlerUPP);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3143 mouseWheelHandlerUPP = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3144 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3145
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3146 #ifdef USE_CARBONKEYHANDLER
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3147 InterfaceTypeList supportedServices = { kUnicodeDocument };
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3148 NewTSMDocument(1, supportedServices, &gTSMDocument, 0);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3149
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3150 /* We don't support inline input yet, use input window by default */
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3151 UseInputWindow(gTSMDocument, TRUE);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3152
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3153 /* Should we activate the document by default? */
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3154 // ActivateTSMDocument(gTSMDocument);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3155
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3156 EventTypeSpec textEventTypes[] = {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3157 { kEventClassTextInput, kEventTextInputUpdateActiveInputArea },
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3158 { kEventClassTextInput, kEventTextInputUnicodeForKeyEvent },
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3159 { kEventClassTextInput, kEventTextInputPosToOffset },
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3160 { kEventClassTextInput, kEventTextInputOffsetToPos },
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3161 };
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3162
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3163 keyEventHandlerUPP = NewEventHandlerUPP(gui_mac_handle_text_input);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3164 if (noErr != InstallApplicationEventHandler(keyEventHandlerUPP,
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3165 NR_ELEMS(textEventTypes),
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3166 textEventTypes, NULL, NULL))
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3167 {
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3168 DisposeEventHandlerUPP(keyEventHandlerUPP);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3169 keyEventHandlerUPP = NULL;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3170 }
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3171
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3172 EventTypeSpec windowEventTypes[] = {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3173 { kEventClassWindow, kEventWindowActivated },
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3174 { kEventClassWindow, kEventWindowDeactivated },
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3175 };
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3176
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3177 /* Install window event handler to support TSMDocument activate and
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3178 * deactivate */
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3179 winEventHandlerUPP = NewEventHandlerUPP(gui_mac_handle_window_activate);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3180 if (noErr != InstallWindowEventHandler(gui.VimWindow,
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3181 winEventHandlerUPP,
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3182 NR_ELEMS(windowEventTypes),
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3183 windowEventTypes, NULL, NULL))
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3184 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3185 DisposeEventHandlerUPP(winEventHandlerUPP);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3186 winEventHandlerUPP = NULL;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3187 }
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3188 #endif
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3189
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3190 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3191 #ifdef FEAT_MBYTE
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3192 set_option_value((char_u *)"encoding", 0L, (char_u *)"utf-8", 0);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3193 #endif
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3194 */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3195
1106
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
3196 #ifdef FEAT_GUI_TABLINE
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
3197 /*
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
3198 * Create the tabline
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
3199 */
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
3200 initialise_tabline();
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
3201 #endif
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
3202
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3203 /* TODO: Load bitmap if using TOOLBAR */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3204 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3205 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3206
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3207 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3208 * Called when the foreground or background color has been changed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3209 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3210 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
3211 gui_mch_new_colors(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3212 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3213 /* TODO:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3214 * This proc is called when Normal is set to a value
3210
767bb493e7d3 updated for version 7.3.375
Bram Moolenaar <bram@vim.org>
parents: 2896
diff changeset
3215 * so what must be done? I don't know
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3216 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3217 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3218
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3219 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3220 * Open the GUI window which was created by a call to gui_mch_init().
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3221 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3222 int
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
3223 gui_mch_open(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3224 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3225 ShowWindow(gui.VimWindow);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3226
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3227 if (gui_win_x != -1 && gui_win_y != -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3228 gui_mch_set_winpos(gui_win_x, gui_win_y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3229
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3230 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3231 * Make the GUI the foreground process (in case it was launched
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3232 * from the Terminal or via :gui).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3233 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3234 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3235 ProcessSerialNumber psn;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3236 if (GetCurrentProcess(&psn) == noErr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3237 SetFrontProcess(&psn);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3238 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3239
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3240 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3241 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3242
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3243 #ifdef USE_ATSUI_DRAWING
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3244 static void
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3245 gui_mac_dispose_atsui_style(void)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3246 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3247 if (p_macatsui && gFontStyle)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3248 ATSUDisposeStyle(gFontStyle);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3249 #ifdef FEAT_MBYTE
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3250 if (p_macatsui && gWideFontStyle)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3251 ATSUDisposeStyle(gWideFontStyle);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3252 #endif
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3253 }
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3254 #endif
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3255
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3256 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3257 gui_mch_exit(int rc)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3258 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3259 /* TODO: find out all what is missing here? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3260 DisposeRgn(cursorRgn);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3261
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3262 #ifdef USE_CARBONKEYHANDLER
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3263 if (keyEventHandlerUPP)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3264 DisposeEventHandlerUPP(keyEventHandlerUPP);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3265 #endif
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3266
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3267 if (mouseWheelHandlerUPP != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3268 DisposeEventHandlerUPP(mouseWheelHandlerUPP);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3269
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3270 #ifdef USE_ATSUI_DRAWING
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3271 gui_mac_dispose_atsui_style();
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3272 #endif
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3273
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3274 #ifdef USE_CARBONKEYHANDLER
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3275 FixTSMDocument(gTSMDocument);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3276 DeactivateTSMDocument(gTSMDocument);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3277 DeleteTSMDocument(gTSMDocument);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3278 #endif
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3279
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3280 /* Exit to shell? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3281 exit(rc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3282 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3283
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3284 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3285 * Get the position of the top left corner of the window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3286 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3287 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3288 gui_mch_get_winpos(int *x, int *y)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3289 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3290 /* TODO */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3291 Rect bounds;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3292 OSStatus status;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3293
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3294 /* Carbon >= 1.0.2, MacOS >= 8.5 */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3295 status = GetWindowBounds(gui.VimWindow, kWindowStructureRgn, &bounds);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3296
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3297 if (status != noErr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3298 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3299 *x = bounds.left;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3300 *y = bounds.top;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3301 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3302 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3303
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3304 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3305 * Set the position of the top left corner of the window to the given
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3306 * coordinates.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3307 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3308 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3309 gui_mch_set_winpos(int x, int y)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3310 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3311 /* TODO: Should make sure the window is move within range
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3312 * e.g.: y > ~16 [Menu bar], x > 0, x < screen width
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3313 */
1377
e2f5c1597829 updated for version 7.1-092
vimboss
parents: 1373
diff changeset
3314 MoveWindowStructure(gui.VimWindow, x, y);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3315 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3316
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3317 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3318 gui_mch_set_shellsize(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3319 int width,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3320 int height,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3321 int min_width,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3322 int min_height,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3323 int base_width,
812
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 766
diff changeset
3324 int base_height,
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 766
diff changeset
3325 int direction)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3326 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3327 CGrafPtr VimPort;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3328 Rect VimBound;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3329
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3330 if (gui.which_scrollbars[SBAR_LEFT])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3331 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3332 VimPort = GetWindowPort(gui.VimWindow);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3333 GetPortBounds(VimPort, &VimBound);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3334 VimBound.left = -gui.scrollbar_width; /* + 1;*/
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3335 SetPortBounds(VimPort, &VimBound);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3336 /* GetWindowBounds(gui.VimWindow, kWindowGlobalPortRgn, &winPortRect); ??*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3337 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3338 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3339 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3340 VimPort = GetWindowPort(gui.VimWindow);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3341 GetPortBounds(VimPort, &VimBound);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3342 VimBound.left = 0;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3343 SetPortBounds(VimPort, &VimBound);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3344 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3345
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3346 SizeWindow(gui.VimWindow, width, height, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3347
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3348 gui_resize_shell(width, height);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3349 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3350
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3351 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3352 * Get the screen dimensions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3353 * Allow 10 pixels for horizontal borders, 40 for vertical borders.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3354 * Is there no way to find out how wide the borders really are?
1212
e085b0f7b036 updated for version 7.1b
vimboss
parents: 1107
diff changeset
3355 * TODO: Add live update of those value on suspend/resume.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3356 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3357 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
3358 gui_mch_get_screen_dimensions(int *screen_w, int *screen_h)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3359 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3360 GDHandle dominantDevice = GetMainDevice();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3361 Rect screenRect = (**dominantDevice).gdRect;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3362
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3363 *screen_w = screenRect.right - 10;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3364 *screen_h = screenRect.bottom - 40;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3365 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3366
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3367
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3368 /*
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3369 * Open the Font Panel and wait for the user to select a font and
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3370 * close the panel. Then fill the buffer pointed to by font_name with
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3371 * the name and size of the selected font and return the font's handle,
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3372 * or NOFONT in case of an error.
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3373 */
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3374 static GuiFont
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3375 gui_mac_select_font(char_u *font_name)
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3376 {
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3377 GuiFont selected_font = NOFONT;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3378 OSStatus status;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3379 FontSelectionQDStyle curr_font;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3380
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3381 /* Initialize the Font Panel with the current font. */
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3382 curr_font.instance.fontFamily = gui.norm_font & 0xFFFF;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3383 curr_font.size = (gui.norm_font >> 16);
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3384 /* TODO: set fontStyle once styles are supported in gui_mac_find_font() */
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3385 curr_font.instance.fontStyle = 0;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3386 curr_font.hasColor = false;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3387 curr_font.version = 0; /* version number of the style structure */
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3388 status = SetFontInfoForSelection(kFontSelectionQDType,
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3389 /*numStyles=*/1, &curr_font, /*eventTarget=*/NULL);
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3390
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3391 gFontPanelInfo.family = curr_font.instance.fontFamily;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3392 gFontPanelInfo.style = curr_font.instance.fontStyle;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3393 gFontPanelInfo.size = curr_font.size;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3394
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3395 /* Pop up the Font Panel. */
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3396 status = FPShowHideFontPanel();
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3397 if (status == noErr)
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3398 {
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3399 /*
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3400 * The Font Panel is modeless. We really need it to be modal,
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3401 * so we spin in an event loop until the panel is closed.
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3402 */
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3403 gFontPanelInfo.isPanelVisible = true;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3404 while (gFontPanelInfo.isPanelVisible)
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3405 {
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3406 EventRecord e;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3407 WaitNextEvent(everyEvent, &e, /*sleep=*/20, /*mouseRgn=*/NULL);
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3408 }
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3409
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3410 GetFontPanelSelection(font_name);
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3411 selected_font = gui_mac_find_font(font_name);
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3412 }
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3413 return selected_font;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3414 }
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3415
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3416 #ifdef USE_ATSUI_DRAWING
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3417 static void
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3418 gui_mac_create_atsui_style(void)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3419 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3420 if (p_macatsui && gFontStyle == NULL)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3421 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3422 if (ATSUCreateStyle(&gFontStyle) != noErr)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3423 gFontStyle = NULL;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3424 }
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3425 #ifdef FEAT_MBYTE
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3426 if (p_macatsui && gWideFontStyle == NULL)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3427 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3428 if (ATSUCreateStyle(&gWideFontStyle) != noErr)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3429 gWideFontStyle = NULL;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3430 }
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3431 #endif
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3432
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3433 p_macatsui_last = p_macatsui;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3434 }
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3435 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3436
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3437 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3438 * Initialise vim to use the font with the given name. Return FAIL if the font
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3439 * could not be loaded, OK otherwise.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3440 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3441 int
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
3442 gui_mch_init_font(char_u *font_name, int fontset)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3443 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3444 /* TODO: Add support for bold italic underline proportional etc... */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3445 Str255 suggestedFont = "\pMonaco";
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 168
diff changeset
3446 int suggestedSize = 10;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3447 FontInfo font_info;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3448 short font_id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3449 GuiFont font;
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3450 char_u used_font_name[512];
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3451
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3452 #ifdef USE_ATSUI_DRAWING
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3453 gui_mac_create_atsui_style();
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3454 #endif
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3455
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3456 if (font_name == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3457 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3458 /* First try to get the suggested font */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3459 GetFNum(suggestedFont, &font_id);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3460
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3461 if (font_id == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3462 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3463 /* Then pickup the standard application font */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3464 font_id = GetAppFont();
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3465 STRCPY(used_font_name, "default");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3466 }
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3467 else
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3468 STRCPY(used_font_name, "Monaco");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3469 font = (suggestedSize << 16) + ((long) font_id & 0xFFFF);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3470 }
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3471 else if (STRCMP(font_name, "*") == 0)
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3472 {
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3473 char_u *new_p_guifont;
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3474
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3475 font = gui_mac_select_font(used_font_name);
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3476 if (font == NOFONT)
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3477 return FAIL;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3478
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3479 /* Set guifont to the name of the selected font. */
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3480 new_p_guifont = alloc(STRLEN(used_font_name) + 1);
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3481 if (new_p_guifont != NULL)
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3482 {
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3483 STRCPY(new_p_guifont, used_font_name);
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3484 vim_free(p_guifont);
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3485 p_guifont = new_p_guifont;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3486 /* Replace spaces in the font name with underscores. */
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3487 for ( ; *new_p_guifont; ++new_p_guifont)
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3488 {
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3489 if (*new_p_guifont == ' ')
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3490 *new_p_guifont = '_';
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3491 }
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3492 }
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3493 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3494 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3495 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3496 font = gui_mac_find_font(font_name);
418
84825cc6f049 updated for version 7.0109
vimboss
parents: 308
diff changeset
3497 vim_strncpy(used_font_name, font_name, sizeof(used_font_name) - 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3498
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3499 if (font == NOFONT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3500 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3501 }
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3502
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3503 gui.norm_font = font;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3504
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3505 hl_set_font_name(used_font_name);
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3506
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3507 TextSize(font >> 16);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3508 TextFont(font & 0xFFFF);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3509
189
504c627f7474 updated for version 7.0057
vimboss
parents: 170
diff changeset
3510 GetFontInfo(&font_info);
504c627f7474 updated for version 7.0057
vimboss
parents: 170
diff changeset
3511
504c627f7474 updated for version 7.0057
vimboss
parents: 170
diff changeset
3512 gui.char_ascent = font_info.ascent;
504c627f7474 updated for version 7.0057
vimboss
parents: 170
diff changeset
3513 gui.char_width = CharWidth('_');
504c627f7474 updated for version 7.0057
vimboss
parents: 170
diff changeset
3514 gui.char_height = font_info.ascent + font_info.descent + p_linespace;
504c627f7474 updated for version 7.0057
vimboss
parents: 170
diff changeset
3515
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3516 #ifdef USE_ATSUI_DRAWING
842
a209672376fd updated for version 7.0f
vimboss
parents: 838
diff changeset
3517 if (p_macatsui && gFontStyle)
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3518 gui_mac_set_font_attributes(font);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3519 #endif
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3520
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3521 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3522 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3523
444
d0d15b184c56 updated for version 7.0116
vimboss
parents: 418
diff changeset
3524 /*
d0d15b184c56 updated for version 7.0116
vimboss
parents: 418
diff changeset
3525 * Adjust gui.char_height (after 'linespace' was changed).
d0d15b184c56 updated for version 7.0116
vimboss
parents: 418
diff changeset
3526 */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3527 int
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
3528 gui_mch_adjust_charheight(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3529 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3530 FontInfo font_info;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3531
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3532 GetFontInfo(&font_info);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3533 gui.char_height = font_info.ascent + font_info.descent + p_linespace;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3534 gui.char_ascent = font_info.ascent + p_linespace / 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3535 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3536 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3537
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3538 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3539 * Get a font structure for highlighting.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3540 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3541 GuiFont
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
3542 gui_mch_get_font(char_u *name, int giveErrorIfMissing)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3543 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3544 GuiFont font;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3545
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3546 font = gui_mac_find_font(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3547
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3548 if (font == NOFONT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3549 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3550 if (giveErrorIfMissing)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3551 EMSG2(_(e_font), name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3552 return NOFONT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3553 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3554 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3555 * TODO : Accept only monospace
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3556 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3557
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3558 return font;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3559 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3560
44
af1bcb9a13c0 updated for version 7.0027
vimboss
parents: 37
diff changeset
3561 #if defined(FEAT_EVAL) || defined(PROTO)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3562 /*
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3563 * Return the name of font "font" in allocated memory.
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3564 * Don't know how to get the actual name, thus use the provided name.
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3565 */
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3566 char_u *
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
3567 gui_mch_get_fontname(GuiFont font, char_u *name)
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3568 {
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3569 if (name == NULL)
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3570 return NULL;
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3571 return vim_strsave(name);
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3572 }
44
af1bcb9a13c0 updated for version 7.0027
vimboss
parents: 37
diff changeset
3573 #endif
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3574
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3575 #ifdef USE_ATSUI_DRAWING
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3576 static void
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3577 gui_mac_set_font_attributes(GuiFont font)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3578 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3579 ATSUFontID fontID;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3580 Fixed fontSize;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3581 Fixed fontWidth;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3582
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3583 fontID = font & 0xFFFF;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3584 fontSize = Long2Fix(font >> 16);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3585 fontWidth = Long2Fix(gui.char_width);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3586
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3587 ATSUAttributeTag attribTags[] =
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3588 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3589 kATSUFontTag, kATSUSizeTag, kATSUImposeWidthTag,
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3590 kATSUMaxATSUITagValue + 1
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3591 };
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3592
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3593 ByteCount attribSizes[] =
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3594 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3595 sizeof(ATSUFontID), sizeof(Fixed), sizeof(fontWidth),
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3596 sizeof(font)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3597 };
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3598
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3599 ATSUAttributeValuePtr attribValues[] =
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3600 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3601 &fontID, &fontSize, &fontWidth, &font
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3602 };
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3603
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3604 if (FMGetFontFromFontFamilyInstance(fontID, 0, &fontID, NULL) == noErr)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3605 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3606 if (ATSUSetAttributes(gFontStyle,
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3607 (sizeof attribTags) / sizeof(ATSUAttributeTag),
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3608 attribTags, attribSizes, attribValues) != noErr)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3609 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3610 # ifndef NDEBUG
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3611 fprintf(stderr, "couldn't set font style\n");
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3612 # endif
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3613 ATSUDisposeStyle(gFontStyle);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3614 gFontStyle = NULL;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3615 }
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3616
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3617 #ifdef FEAT_MBYTE
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3618 if (has_mbyte)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3619 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3620 /* FIXME: we should use a more mbyte sensitive way to support
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3621 * wide font drawing */
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3622 fontWidth = Long2Fix(gui.char_width * 2);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3623
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3624 if (ATSUSetAttributes(gWideFontStyle,
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3625 (sizeof attribTags) / sizeof(ATSUAttributeTag),
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3626 attribTags, attribSizes, attribValues) != noErr)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3627 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3628 ATSUDisposeStyle(gWideFontStyle);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3629 gWideFontStyle = NULL;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3630 }
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3631 }
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3632 #endif
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3633 }
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3634 }
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3635 #endif
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3636
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3637 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3638 * Set the current text font.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3639 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3640 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
3641 gui_mch_set_font(GuiFont font)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3642 {
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3643 #ifdef USE_ATSUI_DRAWING
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3644 GuiFont currFont;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3645 ByteCount actualFontByteCount;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3646
842
a209672376fd updated for version 7.0f
vimboss
parents: 838
diff changeset
3647 if (p_macatsui && gFontStyle)
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3648 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3649 /* Avoid setting same font again */
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3650 if (ATSUGetAttribute(gFontStyle, kATSUMaxATSUITagValue + 1,
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3651 sizeof(font), &currFont, &actualFontByteCount) == noErr
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3652 && actualFontByteCount == (sizeof font))
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3653 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3654 if (currFont == font)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3655 return;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3656 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3657
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3658 gui_mac_set_font_attributes(font);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3659 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3660
842
a209672376fd updated for version 7.0f
vimboss
parents: 838
diff changeset
3661 if (p_macatsui && !gIsFontFallbackSet)
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3662 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3663 /* Setup automatic font substitution. The user's guifontwide
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3664 * is tried first, then the system tries other fonts. */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3665 /*
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3666 ATSUAttributeTag fallbackTags[] = { kATSULineFontFallbacksTag };
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3667 ByteCount fallbackSizes[] = { sizeof(ATSUFontFallbacks) };
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3668 ATSUCreateFontFallbacks(&gFontFallbacks);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3669 ATSUSetObjFontFallbacks(gFontFallbacks, );
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3670 */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3671 if (gui.wide_font)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3672 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3673 ATSUFontID fallbackFonts;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3674 gIsFontFallbackSet = TRUE;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3675
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3676 if (FMGetFontFromFontFamilyInstance(
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3677 (gui.wide_font & 0xFFFF),
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3678 0,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3679 &fallbackFonts,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3680 NULL) == noErr)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3681 {
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3682 ATSUSetFontFallbacks((sizeof fallbackFonts)/sizeof(ATSUFontID),
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3683 &fallbackFonts,
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
3684 kATSUSequentialFallbacksPreferred);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3685 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3686 /*
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3687 ATSUAttributeValuePtr fallbackValues[] = { };
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3688 */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3689 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3690 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3691 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3692 TextSize(font >> 16);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3693 TextFont(font & 0xFFFF);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3694 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3695
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3696 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3697 * If a font is not going to be used, free its structure.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3698 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3699 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3700 gui_mch_free_font(font)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3701 GuiFont font;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3702 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3703 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3704 * Free font when "font" is not 0.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3705 * Nothing to do in the current implementation, since
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3706 * nothing is allocated for each font used.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3707 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3708 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3709
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3710 static int
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
3711 hex_digit(int c)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3712 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3713 if (isdigit(c))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3714 return c - '0';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3715 c = TOLOWER_ASC(c);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3716 if (c >= 'a' && c <= 'f')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3717 return c - 'a' + 10;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3718 return -1000;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3719 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3720
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3721 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3722 * Return the Pixel value (color) for the given color name. This routine was
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3723 * pretty much taken from example code in the Silicon Graphics OSF/Motif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3724 * Programmer's Guide.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3725 * Return INVALCOLOR when failed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3726 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3727 guicolor_T
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
3728 gui_mch_get_color(char_u *name)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3729 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3730 /* TODO: Add support for the new named color of MacOS 8
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3731 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3732 RGBColor MacColor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3733 // guicolor_T color = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3734
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3735 typedef struct guicolor_tTable
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3736 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3737 char *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3738 guicolor_T color;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3739 } guicolor_tTable;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3740
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3741 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3742 * The comment at the end of each line is the source
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3743 * (Mac, Window, Unix) and the number is the unix rgb.txt value
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3744 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3745 static guicolor_tTable table[] =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3746 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3747 {"Black", RGB(0x00, 0x00, 0x00)},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3748 {"darkgray", RGB(0x80, 0x80, 0x80)}, /*W*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3749 {"darkgrey", RGB(0x80, 0x80, 0x80)}, /*W*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3750 {"Gray", RGB(0xC0, 0xC0, 0xC0)}, /*W*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3751 {"Grey", RGB(0xC0, 0xC0, 0xC0)}, /*W*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3752 {"lightgray", RGB(0xE0, 0xE0, 0xE0)}, /*W*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3753 {"lightgrey", RGB(0xE0, 0xE0, 0xE0)}, /*W*/
834
5117153003bd updated for version 7.0e
vimboss
parents: 818
diff changeset
3754 {"gray10", RGB(0x1A, 0x1A, 0x1A)}, /*W*/
5117153003bd updated for version 7.0e
vimboss
parents: 818
diff changeset
3755 {"grey10", RGB(0x1A, 0x1A, 0x1A)}, /*W*/
5117153003bd updated for version 7.0e
vimboss
parents: 818
diff changeset
3756 {"gray20", RGB(0x33, 0x33, 0x33)}, /*W*/
5117153003bd updated for version 7.0e
vimboss
parents: 818
diff changeset
3757 {"grey20", RGB(0x33, 0x33, 0x33)}, /*W*/
5117153003bd updated for version 7.0e
vimboss
parents: 818
diff changeset
3758 {"gray30", RGB(0x4D, 0x4D, 0x4D)}, /*W*/
5117153003bd updated for version 7.0e
vimboss
parents: 818
diff changeset
3759 {"grey30", RGB(0x4D, 0x4D, 0x4D)}, /*W*/
5117153003bd updated for version 7.0e
vimboss
parents: 818
diff changeset
3760 {"gray40", RGB(0x66, 0x66, 0x66)}, /*W*/
5117153003bd updated for version 7.0e
vimboss
parents: 818
diff changeset
3761 {"grey40", RGB(0x66, 0x66, 0x66)}, /*W*/
5117153003bd updated for version 7.0e
vimboss
parents: 818
diff changeset
3762 {"gray50", RGB(0x7F, 0x7F, 0x7F)}, /*W*/
5117153003bd updated for version 7.0e
vimboss
parents: 818
diff changeset
3763 {"grey50", RGB(0x7F, 0x7F, 0x7F)}, /*W*/
5117153003bd updated for version 7.0e
vimboss
parents: 818
diff changeset
3764 {"gray60", RGB(0x99, 0x99, 0x99)}, /*W*/
5117153003bd updated for version 7.0e
vimboss
parents: 818
diff changeset
3765 {"grey60", RGB(0x99, 0x99, 0x99)}, /*W*/
5117153003bd updated for version 7.0e
vimboss
parents: 818
diff changeset
3766 {"gray70", RGB(0xB3, 0xB3, 0xB3)}, /*W*/
5117153003bd updated for version 7.0e
vimboss
parents: 818
diff changeset
3767 {"grey70", RGB(0xB3, 0xB3, 0xB3)}, /*W*/
5117153003bd updated for version 7.0e
vimboss
parents: 818
diff changeset
3768 {"gray80", RGB(0xCC, 0xCC, 0xCC)}, /*W*/
5117153003bd updated for version 7.0e
vimboss
parents: 818
diff changeset
3769 {"grey80", RGB(0xCC, 0xCC, 0xCC)}, /*W*/
818
1f929f3ca806 updated for version 7.0c03
vimboss
parents: 816
diff changeset
3770 {"gray90", RGB(0xE5, 0xE5, 0xE5)}, /*W*/
1f929f3ca806 updated for version 7.0c03
vimboss
parents: 816
diff changeset
3771 {"grey90", RGB(0xE5, 0xE5, 0xE5)}, /*W*/
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3772 {"white", RGB(0xFF, 0xFF, 0xFF)},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3773 {"darkred", RGB(0x80, 0x00, 0x00)}, /*W*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3774 {"red", RGB(0xDD, 0x08, 0x06)}, /*M*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3775 {"lightred", RGB(0xFF, 0xA0, 0xA0)}, /*W*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3776 {"DarkBlue", RGB(0x00, 0x00, 0x80)}, /*W*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3777 {"Blue", RGB(0x00, 0x00, 0xD4)}, /*M*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3778 {"lightblue", RGB(0xA0, 0xA0, 0xFF)}, /*W*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3779 {"DarkGreen", RGB(0x00, 0x80, 0x00)}, /*W*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3780 {"Green", RGB(0x00, 0x64, 0x11)}, /*M*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3781 {"lightgreen", RGB(0xA0, 0xFF, 0xA0)}, /*W*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3782 {"DarkCyan", RGB(0x00, 0x80, 0x80)}, /*W ?0x307D7E */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3783 {"cyan", RGB(0x02, 0xAB, 0xEA)}, /*M*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3784 {"lightcyan", RGB(0xA0, 0xFF, 0xFF)}, /*W*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3785 {"darkmagenta", RGB(0x80, 0x00, 0x80)}, /*W*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3786 {"magenta", RGB(0xF2, 0x08, 0x84)}, /*M*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3787 {"lightmagenta",RGB(0xF0, 0xA0, 0xF0)}, /*W*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3788 {"brown", RGB(0x80, 0x40, 0x40)}, /*W*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3789 {"yellow", RGB(0xFC, 0xF3, 0x05)}, /*M*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3790 {"lightyellow", RGB(0xFF, 0xFF, 0xA0)}, /*M*/
308
74e9d19831c2 updated for version 7.0081
vimboss
parents: 273
diff changeset
3791 {"darkyellow", RGB(0xBB, 0xBB, 0x00)}, /*U*/
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3792 {"SeaGreen", RGB(0x2E, 0x8B, 0x57)}, /*W 0x4E8975 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3793 {"orange", RGB(0xFC, 0x80, 0x00)}, /*W 0xF87A17 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3794 {"Purple", RGB(0xA0, 0x20, 0xF0)}, /*W 0x8e35e5 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3795 {"SlateBlue", RGB(0x6A, 0x5A, 0xCD)}, /*W 0x737CA1 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3796 {"Violet", RGB(0x8D, 0x38, 0xC9)}, /*U*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3797 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3798
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3799 int r, g, b;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3800 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3801
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3802 if (name[0] == '#' && strlen((char *) name) == 7)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3803 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3804 /* Name is in "#rrggbb" format */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3805 r = hex_digit(name[1]) * 16 + hex_digit(name[2]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3806 g = hex_digit(name[3]) * 16 + hex_digit(name[4]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3807 b = hex_digit(name[5]) * 16 + hex_digit(name[6]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3808 if (r < 0 || g < 0 || b < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3809 return INVALCOLOR;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3810 return RGB(r, g, b);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3811 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3812 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3813 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3814 if (STRICMP(name, "hilite") == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3815 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3816 LMGetHiliteRGB(&MacColor);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3817 return (RGB(MacColor.red >> 8, MacColor.green >> 8, MacColor.blue >> 8));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3818 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3819 /* Check if the name is one of the colors we know */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3820 for (i = 0; i < sizeof(table) / sizeof(table[0]); i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3821 if (STRICMP(name, table[i].name) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3822 return table[i].color;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3823 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3824
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3825 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3826 * Last attempt. Look in the file "$VIM/rgb.txt".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3827 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3828 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3829 #define LINE_LEN 100
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3830 FILE *fd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3831 char line[LINE_LEN];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3832 char_u *fname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3833
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3834 fname = expand_env_save((char_u *)"$VIMRUNTIME/rgb.txt");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3835 if (fname == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3836 return INVALCOLOR;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3837
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3838 fd = fopen((char *)fname, "rt");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3839 vim_free(fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3840 if (fd == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3841 return INVALCOLOR;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3842
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3843 while (!feof(fd))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3844 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3845 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3846 int pos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3847 char *color;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3848
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3849 fgets(line, LINE_LEN, fd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3850 len = strlen(line);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3851
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3852 if (len <= 1 || line[len-1] != '\n')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3853 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3854
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3855 line[len-1] = '\0';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3856
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3857 i = sscanf(line, "%d %d %d %n", &r, &g, &b, &pos);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3858 if (i != 3)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3859 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3860
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3861 color = line + pos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3862
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3863 if (STRICMP(color, name) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3864 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3865 fclose(fd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3866 return (guicolor_T) RGB(r, g, b);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3867 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3868 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3869 fclose(fd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3870 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3871
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3872 return INVALCOLOR;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3873 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3874
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3875 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3876 * Set the current text foreground color.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3877 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3878 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
3879 gui_mch_set_fg_color(guicolor_T color)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3880 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3881 RGBColor TheColor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3882
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3883 TheColor.red = Red(color) * 0x0101;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3884 TheColor.green = Green(color) * 0x0101;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3885 TheColor.blue = Blue(color) * 0x0101;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3886
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3887 RGBForeColor(&TheColor);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3888 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3889
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3890 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3891 * Set the current text background color.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3892 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3893 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
3894 gui_mch_set_bg_color(guicolor_T color)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3895 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3896 RGBColor TheColor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3897
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3898 TheColor.red = Red(color) * 0x0101;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3899 TheColor.green = Green(color) * 0x0101;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3900 TheColor.blue = Blue(color) * 0x0101;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3901
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3902 RGBBackColor(&TheColor);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3903 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3904
563
1325fab089fd updated for version 7.0160
vimboss
parents: 502
diff changeset
3905 RGBColor specialColor;
1325fab089fd updated for version 7.0160
vimboss
parents: 502
diff changeset
3906
212
e39657bbbb98 updated for version 7.0060
vimboss
parents: 189
diff changeset
3907 /*
563
1325fab089fd updated for version 7.0160
vimboss
parents: 502
diff changeset
3908 * Set the current text special color.
212
e39657bbbb98 updated for version 7.0060
vimboss
parents: 189
diff changeset
3909 */
e39657bbbb98 updated for version 7.0060
vimboss
parents: 189
diff changeset
3910 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
3911 gui_mch_set_sp_color(guicolor_T color)
212
e39657bbbb98 updated for version 7.0060
vimboss
parents: 189
diff changeset
3912 {
563
1325fab089fd updated for version 7.0160
vimboss
parents: 502
diff changeset
3913 specialColor.red = Red(color) * 0x0101;
1325fab089fd updated for version 7.0160
vimboss
parents: 502
diff changeset
3914 specialColor.green = Green(color) * 0x0101;
1325fab089fd updated for version 7.0160
vimboss
parents: 502
diff changeset
3915 specialColor.blue = Blue(color) * 0x0101;
1325fab089fd updated for version 7.0160
vimboss
parents: 502
diff changeset
3916 }
1325fab089fd updated for version 7.0160
vimboss
parents: 502
diff changeset
3917
1325fab089fd updated for version 7.0160
vimboss
parents: 502
diff changeset
3918 /*
1325fab089fd updated for version 7.0160
vimboss
parents: 502
diff changeset
3919 * Draw undercurl at the bottom of the character cell.
1325fab089fd updated for version 7.0160
vimboss
parents: 502
diff changeset
3920 */
1325fab089fd updated for version 7.0160
vimboss
parents: 502
diff changeset
3921 static void
1325fab089fd updated for version 7.0160
vimboss
parents: 502
diff changeset
3922 draw_undercurl(int flags, int row, int col, int cells)
1325fab089fd updated for version 7.0160
vimboss
parents: 502
diff changeset
3923 {
856
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
3924 int x;
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
3925 int offset;
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
3926 const static int val[8] = {1, 0, 0, 0, 1, 2, 2, 2 };
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
3927 int y = FILL_Y(row + 1) - 1;
563
1325fab089fd updated for version 7.0160
vimboss
parents: 502
diff changeset
3928
1325fab089fd updated for version 7.0160
vimboss
parents: 502
diff changeset
3929 RGBForeColor(&specialColor);
1325fab089fd updated for version 7.0160
vimboss
parents: 502
diff changeset
3930
1325fab089fd updated for version 7.0160
vimboss
parents: 502
diff changeset
3931 offset = val[FILL_X(col) % 8];
1325fab089fd updated for version 7.0160
vimboss
parents: 502
diff changeset
3932 MoveTo(FILL_X(col), y - offset);
1325fab089fd updated for version 7.0160
vimboss
parents: 502
diff changeset
3933
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
3934 for (x = FILL_X(col); x < FILL_X(col + cells); ++x)
563
1325fab089fd updated for version 7.0160
vimboss
parents: 502
diff changeset
3935 {
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
3936 offset = val[x % 8];
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
3937 LineTo(x, y - offset);
563
1325fab089fd updated for version 7.0160
vimboss
parents: 502
diff changeset
3938 }
212
e39657bbbb98 updated for version 7.0060
vimboss
parents: 189
diff changeset
3939 }
e39657bbbb98 updated for version 7.0060
vimboss
parents: 189
diff changeset
3940
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
3941
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
3942 static void
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
3943 draw_string_QD(int row, int col, char_u *s, int len, int flags)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3944 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3945 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3946 char_u *tofree = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3947
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3948 if (output_conv.vc_type != CONV_NONE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3949 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3950 tofree = string_convert(&output_conv, s, &len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3951 if (tofree != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3952 s = tofree;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3953 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3954 #endif
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
3955
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3956 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3957 * On OS X, try using Quartz-style text antialiasing.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3958 */
189
504c627f7474 updated for version 7.0057
vimboss
parents: 170
diff changeset
3959 if (gMacSystemVersion >= 0x1020)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3960 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3961 /* Quartz antialiasing is available only in OS 10.2 and later. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3962 UInt32 qd_flags = (p_antialias ?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3963 kQDUseCGTextRendering | kQDUseCGTextMetrics : 0);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3964 QDSwapTextFlags(qd_flags);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3965 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3966
36
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
3967 /*
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
3968 * When antialiasing we're using srcOr mode, we have to clear the block
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
3969 * before drawing the text.
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
3970 * Also needed when 'linespace' is non-zero to remove the cursor and
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
3971 * underlining.
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
3972 * But not when drawing transparently.
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
3973 * The following is like calling gui_mch_clear_block(row, col, row, col +
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
3974 * len - 1), but without setting the bg color to gui.back_pixel.
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
3975 */
189
504c627f7474 updated for version 7.0057
vimboss
parents: 170
diff changeset
3976 if (((gMacSystemVersion >= 0x1020 && p_antialias) || p_linespace != 0)
36
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
3977 && !(flags & DRAW_TRANSP))
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
3978 {
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
3979 Rect rc;
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
3980
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
3981 rc.left = FILL_X(col);
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
3982 rc.top = FILL_Y(row);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3983 #ifdef FEAT_MBYTE
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3984 /* Multibyte computation taken from gui_w32.c */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3985 if (has_mbyte)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3986 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3987 /* Compute the length in display cells. */
2338
da6ec32d8d8f Added strwidth() and strchars() functions.
Bram Moolenaar <bram@vim.org>
parents: 2327
diff changeset
3988 rc.right = FILL_X(col + mb_string2cells(s, len));
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3989 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3990 else
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3991 #endif
36
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
3992 rc.right = FILL_X(col + len) + (col + len == Columns);
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
3993 rc.bottom = FILL_Y(row + 1);
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
3994 EraseRect(&rc);
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
3995 }
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
3996
189
504c627f7474 updated for version 7.0057
vimboss
parents: 170
diff changeset
3997 if (gMacSystemVersion >= 0x1020 && p_antialias)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3998 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3999 StyleParameter face;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4000
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4001 face = normal;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4002 if (flags & DRAW_BOLD)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4003 face |= bold;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4004 if (flags & DRAW_UNDERL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4005 face |= underline;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4006 TextFace(face);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4007
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4008 /* Quartz antialiasing works only in srcOr transfer mode. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4009 TextMode(srcOr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4010
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4011 MoveTo(TEXT_X(col), TEXT_Y(row));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4012 DrawText((char*)s, 0, len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4013 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4014 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4015 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4016 /* Use old-style, non-antialiased QuickDraw text rendering. */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4017 TextMode(srcCopy);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4018 TextFace(normal);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4019
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4020 /* SelectFont(hdc, gui.currFont); */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4021
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4022 if (flags & DRAW_TRANSP)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4023 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4024 TextMode(srcOr);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4025 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4026
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4027 MoveTo(TEXT_X(col), TEXT_Y(row));
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4028 DrawText((char *)s, 0, len);
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4029
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4030 if (flags & DRAW_BOLD)
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4031 {
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4032 TextMode(srcOr);
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4033 MoveTo(TEXT_X(col) + 1, TEXT_Y(row));
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4034 DrawText((char *)s, 0, len);
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4035 }
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4036
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4037 if (flags & DRAW_UNDERL)
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4038 {
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4039 MoveTo(FILL_X(col), FILL_Y(row + 1) - 1);
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4040 LineTo(FILL_X(col + len) - 1, FILL_Y(row + 1) - 1);
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4041 }
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4042 }
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4043
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4044 if (flags & DRAW_UNDERC)
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4045 draw_undercurl(flags, row, col, len);
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4046
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4047 #ifdef FEAT_MBYTE
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4048 vim_free(tofree);
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4049 #endif
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4050 }
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4051
842
a209672376fd updated for version 7.0f
vimboss
parents: 838
diff changeset
4052 #ifdef USE_ATSUI_DRAWING
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4053
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4054 static void
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4055 draw_string_ATSUI(int row, int col, char_u *s, int len, int flags)
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4056 {
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4057 /* ATSUI requires utf-16 strings */
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4058 UniCharCount utf16_len;
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4059 UniChar *tofree = mac_enc_to_utf16(s, len, (size_t *)&utf16_len);
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4060 utf16_len /= sizeof(UniChar);
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4061
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4062 /* - ATSUI automatically antialiases text (Someone)
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4063 * - for some reason it does not work... (Jussi) */
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4064 #ifdef MAC_ATSUI_DEBUG
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4065 fprintf(stderr, "row = %d, col = %d, len = %d: '%c'\n",
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4066 row, col, len, len == 1 ? s[0] : ' ');
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4067 #endif
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4068 /*
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4069 * When antialiasing we're using srcOr mode, we have to clear the block
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4070 * before drawing the text.
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4071 * Also needed when 'linespace' is non-zero to remove the cursor and
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4072 * underlining.
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4073 * But not when drawing transparently.
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4074 * The following is like calling gui_mch_clear_block(row, col, row, col +
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4075 * len - 1), but without setting the bg color to gui.back_pixel.
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4076 */
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4077 if ((flags & DRAW_TRANSP) == 0)
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4078 {
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4079 Rect rc;
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4080
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4081 rc.left = FILL_X(col);
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4082 rc.top = FILL_Y(row);
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4083 /* Multibyte computation taken from gui_w32.c */
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4084 if (has_mbyte)
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4085 {
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4086 /* Compute the length in display cells. */
2338
da6ec32d8d8f Added strwidth() and strchars() functions.
Bram Moolenaar <bram@vim.org>
parents: 2327
diff changeset
4087 rc.right = FILL_X(col + mb_string2cells(s, len));
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4088 }
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4089 else
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4090 rc.right = FILL_X(col + len) + (col + len == Columns);
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4091
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4092 rc.bottom = FILL_Y(row + 1);
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4093 EraseRect(&rc);
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4094 }
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4095
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4096 {
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4097 TextMode(srcCopy);
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4098 TextFace(normal);
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4099
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4100 /* SelectFont(hdc, gui.currFont); */
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4101 if (flags & DRAW_TRANSP)
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4102 {
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4103 TextMode(srcOr);
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4104 }
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4105
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4106 MoveTo(TEXT_X(col), TEXT_Y(row));
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4107
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4108 if (gFontStyle && flags & DRAW_BOLD)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4109 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4110 Boolean attValue = true;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4111 ATSUAttributeTag attribTags[] = { kATSUQDBoldfaceTag };
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4112 ByteCount attribSizes[] = { sizeof(Boolean) };
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4113 ATSUAttributeValuePtr attribValues[] = { &attValue };
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4114
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4115 ATSUSetAttributes(gFontStyle, 1, attribTags, attribSizes, attribValues);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4116 }
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4117
2327
02cf6d461e3f Mac: Support disabling antialias. (LC Mi)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4118 UInt32 useAntialias = p_antialias ? kATSStyleApplyAntiAliasing
02cf6d461e3f Mac: Support disabling antialias. (LC Mi)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4119 : kATSStyleNoAntiAliasing;
02cf6d461e3f Mac: Support disabling antialias. (LC Mi)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4120 if (useAntialias != useAntialias_cached)
02cf6d461e3f Mac: Support disabling antialias. (LC Mi)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4121 {
02cf6d461e3f Mac: Support disabling antialias. (LC Mi)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4122 ATSUAttributeTag attribTags[] = { kATSUStyleRenderingOptionsTag };
02cf6d461e3f Mac: Support disabling antialias. (LC Mi)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4123 ByteCount attribSizes[] = { sizeof(UInt32) };
02cf6d461e3f Mac: Support disabling antialias. (LC Mi)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4124 ATSUAttributeValuePtr attribValues[] = { &useAntialias };
02cf6d461e3f Mac: Support disabling antialias. (LC Mi)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4125
02cf6d461e3f Mac: Support disabling antialias. (LC Mi)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4126 if (gFontStyle)
02cf6d461e3f Mac: Support disabling antialias. (LC Mi)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4127 ATSUSetAttributes(gFontStyle, 1, attribTags,
02cf6d461e3f Mac: Support disabling antialias. (LC Mi)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4128 attribSizes, attribValues);
02cf6d461e3f Mac: Support disabling antialias. (LC Mi)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4129 if (gWideFontStyle)
02cf6d461e3f Mac: Support disabling antialias. (LC Mi)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4130 ATSUSetAttributes(gWideFontStyle, 1, attribTags,
02cf6d461e3f Mac: Support disabling antialias. (LC Mi)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4131 attribSizes, attribValues);
02cf6d461e3f Mac: Support disabling antialias. (LC Mi)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4132
02cf6d461e3f Mac: Support disabling antialias. (LC Mi)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4133 useAntialias_cached = useAntialias;
02cf6d461e3f Mac: Support disabling antialias. (LC Mi)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4134 }
02cf6d461e3f Mac: Support disabling antialias. (LC Mi)
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
4135
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4136 #ifdef FEAT_MBYTE
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4137 if (has_mbyte)
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4138 {
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4139 int n, width_in_cell, last_width_in_cell;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4140 UniCharArrayOffset offset = 0;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4141 UniCharCount yet_to_draw = 0;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4142 ATSUTextLayout textLayout;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4143 ATSUStyle textStyle;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4144
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4145 last_width_in_cell = 1;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4146 ATSUCreateTextLayout(&textLayout);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4147 ATSUSetTextPointerLocation(textLayout, tofree,
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4148 kATSUFromTextBeginning,
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4149 kATSUToTextEnd, utf16_len);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4150 /*
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4151 ATSUSetRunStyle(textLayout, gFontStyle,
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4152 kATSUFromTextBeginning, kATSUToTextEnd); */
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4153
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4154 /* Compute the length in display cells. */
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4155 for (n = 0; n < len; n += MB_BYTE2LEN(s[n]))
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4156 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4157 width_in_cell = (*mb_ptr2cells)(s + n);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4158
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4159 /* probably we are switching from single byte character
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4160 * to multibyte characters (which requires more than one
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4161 * cell to draw) */
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4162 if (width_in_cell != last_width_in_cell)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4163 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4164 #ifdef MAC_ATSUI_DEBUG
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4165 fprintf(stderr, "\tn = %2d, (%d-%d), offset = %d, yet_to_draw = %d\n",
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4166 n, last_width_in_cell, width_in_cell, offset, yet_to_draw);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4167 #endif
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4168 textStyle = last_width_in_cell > 1 ? gWideFontStyle
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4169 : gFontStyle;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4170
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4171 ATSUSetRunStyle(textLayout, textStyle, offset, yet_to_draw);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4172 offset += yet_to_draw;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4173 yet_to_draw = 0;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4174 last_width_in_cell = width_in_cell;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4175 }
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4176
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4177 yet_to_draw++;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4178 }
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4179
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4180 if (yet_to_draw)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4181 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4182 #ifdef MAC_ATSUI_DEBUG
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4183 fprintf(stderr, "\tn = %2d, (%d-%d), offset = %d, yet_to_draw = %d\n",
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4184 n, last_width_in_cell, width_in_cell, offset, yet_to_draw);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4185 #endif
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4186 /* finish the rest style */
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4187 textStyle = width_in_cell > 1 ? gWideFontStyle : gFontStyle;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4188 ATSUSetRunStyle(textLayout, textStyle, offset, kATSUToTextEnd);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4189 }
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4190
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4191 ATSUSetTransientFontMatching(textLayout, TRUE);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4192 ATSUDrawText(textLayout,
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4193 kATSUFromTextBeginning, kATSUToTextEnd,
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4194 kATSUUseGrafPortPenLoc, kATSUUseGrafPortPenLoc);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4195 ATSUDisposeTextLayout(textLayout);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4196 }
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4197 else
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4198 #endif
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4199 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4200 ATSUTextLayout textLayout;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4201
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4202 if (ATSUCreateTextLayoutWithTextPtr(tofree,
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4203 kATSUFromTextBeginning, kATSUToTextEnd,
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4204 utf16_len,
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4205 (gFontStyle ? 1 : 0), &utf16_len,
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4206 (gFontStyle ? &gFontStyle : NULL),
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4207 &textLayout) == noErr)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4208 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4209 ATSUSetTransientFontMatching(textLayout, TRUE);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4210
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4211 ATSUDrawText(textLayout,
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4212 kATSUFromTextBeginning, kATSUToTextEnd,
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4213 kATSUUseGrafPortPenLoc, kATSUUseGrafPortPenLoc);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4214
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4215 ATSUDisposeTextLayout(textLayout);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4216 }
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4217 }
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4218
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4219 /* drawing is done, now reset bold to normal */
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4220 if (gFontStyle && flags & DRAW_BOLD)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4221 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4222 Boolean attValue = false;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4223
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4224 ATSUAttributeTag attribTags[] = { kATSUQDBoldfaceTag };
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4225 ByteCount attribSizes[] = { sizeof(Boolean) };
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4226 ATSUAttributeValuePtr attribValues[] = { &attValue };
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4227
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4228 ATSUSetAttributes(gFontStyle, 1, attribTags, attribSizes,
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4229 attribValues);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4230 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4231 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4232
563
1325fab089fd updated for version 7.0160
vimboss
parents: 502
diff changeset
4233 if (flags & DRAW_UNDERC)
1325fab089fd updated for version 7.0160
vimboss
parents: 502
diff changeset
4234 draw_undercurl(flags, row, col, len);
1325fab089fd updated for version 7.0160
vimboss
parents: 502
diff changeset
4235
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4236 vim_free(tofree);
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4237 }
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4238 #endif
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4239
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4240 void
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4241 gui_mch_draw_string(int row, int col, char_u *s, int len, int flags)
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4242 {
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4243 #if defined(USE_ATSUI_DRAWING)
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4244 if (p_macatsui == 0 && p_macatsui_last != 0)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4245 /* switch from macatsui to nomacatsui */
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4246 gui_mac_dispose_atsui_style();
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4247 else if (p_macatsui != 0 && p_macatsui_last == 0)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4248 /* switch from nomacatsui to macatsui */
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4249 gui_mac_create_atsui_style();
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4250
842
a209672376fd updated for version 7.0f
vimboss
parents: 838
diff changeset
4251 if (p_macatsui)
a209672376fd updated for version 7.0f
vimboss
parents: 838
diff changeset
4252 draw_string_ATSUI(row, col, s, len, flags);
a209672376fd updated for version 7.0f
vimboss
parents: 838
diff changeset
4253 else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4254 #endif
842
a209672376fd updated for version 7.0f
vimboss
parents: 838
diff changeset
4255 draw_string_QD(row, col, s, len, flags);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4256 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4257
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4258 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4259 * Return OK if the key with the termcap name "name" is supported.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4260 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4261 int
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4262 gui_mch_haskey(char_u *name)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4263 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4264 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4265
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4266 for (i = 0; special_keys[i].key_sym != (KeySym)0; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4267 if (name[0] == special_keys[i].vim_code0 &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4268 name[1] == special_keys[i].vim_code1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4269 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4270 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4271 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4272
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4273 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4274 gui_mch_beep(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4275 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4276 SysBeep(1); /* Should this be 0? (????) */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4277 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4278
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4279 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4280 gui_mch_flash(int msec)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4281 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4282 /* Do a visual beep by reversing the foreground and background colors */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4283 Rect rc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4284
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4285 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4286 * Note: InvertRect() excludes right and bottom of rectangle.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4287 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4288 rc.left = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4289 rc.top = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4290 rc.right = gui.num_cols * gui.char_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4291 rc.bottom = gui.num_rows * gui.char_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4292 InvertRect(&rc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4293
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4294 ui_delay((long)msec, TRUE); /* wait for some msec */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4295
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4296 InvertRect(&rc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4297 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4298
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4299 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4300 * Invert a rectangle from row r, column c, for nr rows and nc columns.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4301 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4302 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4303 gui_mch_invert_rectangle(int r, int c, int nr, int nc)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4304 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4305 Rect rc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4306
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4307 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4308 * Note: InvertRect() excludes right and bottom of rectangle.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4309 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4310 rc.left = FILL_X(c);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4311 rc.top = FILL_Y(r);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4312 rc.right = rc.left + nc * gui.char_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4313 rc.bottom = rc.top + nr * gui.char_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4314 InvertRect(&rc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4315 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4316
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4317 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4318 * Iconify the GUI window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4319 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4320 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4321 gui_mch_iconify(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4322 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4323 /* TODO: find out what could replace iconify
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4324 * -window shade?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4325 * -hide application?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4326 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4327 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4328
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4329 #if defined(FEAT_EVAL) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4330 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4331 * Bring the Vim window to the foreground.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4332 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4333 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4334 gui_mch_set_foreground(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4335 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4336 /* TODO */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4337 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4338 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4339
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4340 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4341 * Draw a cursor without focus.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4342 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4343 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4344 gui_mch_draw_hollow_cursor(guicolor_T color)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4345 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4346 Rect rc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4347
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4348 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4349 * Note: FrameRect() excludes right and bottom of rectangle.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4350 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4351 rc.left = FILL_X(gui.col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4352 rc.top = FILL_Y(gui.row);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4353 rc.right = rc.left + gui.char_width;
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4354 #ifdef FEAT_MBYTE
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4355 if (mb_lefthalve(gui.row, gui.col))
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4356 rc.right += gui.char_width;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4357 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4358 rc.bottom = rc.top + gui.char_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4359
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4360 gui_mch_set_fg_color(color);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4361
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4362 FrameRect(&rc);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4363 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4364
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4365 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4366 * Draw part of a cursor, only w pixels wide, and h pixels high.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4367 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4368 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4369 gui_mch_draw_part_cursor(int w, int h, guicolor_T color)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4370 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4371 Rect rc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4372
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4373 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4374 /* vertical line should be on the right of current point */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4375 if (CURSOR_BAR_RIGHT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4376 rc.left = FILL_X(gui.col + 1) - w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4377 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4378 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4379 rc.left = FILL_X(gui.col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4380 rc.top = FILL_Y(gui.row) + gui.char_height - h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4381 rc.right = rc.left + w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4382 rc.bottom = rc.top + h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4383
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4384 gui_mch_set_fg_color(color);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4385
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4386 FrameRect(&rc);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4387 // PaintRect(&rc);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4388 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4389
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4390
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4391
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4392 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4393 * Catch up with any queued X events. This may put keyboard input into the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4394 * input buffer, call resize call-backs, trigger timers etc. If there is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4395 * nothing in the X event queue (& no timers pending), then we return
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4396 * immediately.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4397 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4398 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4399 gui_mch_update(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4400 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4401 /* TODO: find what to do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4402 * maybe call gui_mch_wait_for_chars (0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4403 * more like look at EventQueue then
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4404 * call heart of gui_mch_wait_for_chars;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4405 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4406 * if (eventther)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4407 * gui_mac_handle_event(&event);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4408 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4409 EventRecord theEvent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4410
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4411 if (EventAvail(everyEvent, &theEvent))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4412 if (theEvent.what != nullEvent)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4413 gui_mch_wait_for_chars(0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4414 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4415
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4416 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4417 * Simple wrapper to neglect more easily the time
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4418 * spent inside WaitNextEvent while profiling.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4419 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4420
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4421 pascal
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4422 Boolean
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4423 WaitNextEventWrp(EventMask eventMask, EventRecord *theEvent, UInt32 sleep, RgnHandle mouseRgn)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4424 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4425 if (((long) sleep) < -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4426 sleep = 32767;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4427 return WaitNextEvent(eventMask, theEvent, sleep, mouseRgn);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4428 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4429
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4430 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4431 * GUI input routine called by gui_wait_for_chars(). Waits for a character
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4432 * from the keyboard.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4433 * wtime == -1 Wait forever.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4434 * wtime == 0 This should never happen.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4435 * wtime > 0 Wait wtime milliseconds for a character.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4436 * Returns OK if a character was found to be available within the given time,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4437 * or FAIL otherwise.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4438 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4439 int
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4440 gui_mch_wait_for_chars(int wtime)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4441 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4442 EventMask mask = (everyEvent);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4443 EventRecord event;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4444 long entryTick;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4445 long currentTick;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4446 long sleeppyTick;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4447
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4448 /* If we are providing life feedback with the scrollbar,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4449 * we don't want to try to wait for an event, or else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4450 * there won't be any life feedback.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4451 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4452 if (dragged_sb != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4453 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4454 /* TODO: Check if FAIL is the proper return code */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4455
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4456 entryTick = TickCount();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4457
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4458 allow_scrollbar = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4459
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4460 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4461 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4462 /* if (dragRectControl == kCreateEmpty)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4463 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4464 dragRgn = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4465 dragRectControl = kNothing;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4466 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4467 else*/ if (dragRectControl == kCreateRect)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4468 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4469 dragRgn = cursorRgn;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4470 RectRgn(dragRgn, &dragRect);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4471 dragRectControl = kNothing;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4472 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4473 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4474 * Don't use gui_mch_update() because then we will spin-lock until a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4475 * char arrives, instead we use WaitNextEventWrp() to hang until an
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4476 * event arrives. No need to check for input_buf_full because we are
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4477 * returning as soon as it contains a single char.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4478 */
2585
03d49a7c8319 updated for version 7.3.010
Bram Moolenaar <bram@vim.org>
parents: 2565
diff changeset
4479 /* TODO: reduce wtime accordingly??? */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4480 if (wtime > -1)
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4481 sleeppyTick = 60 * wtime / 1000;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4482 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4483 sleeppyTick = 32767;
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4484
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4485 if (WaitNextEventWrp(mask, &event, sleeppyTick, dragRgn))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4486 {
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
4487 gui_mac_handle_event(&event);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4488 if (input_available())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4489 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4490 allow_scrollbar = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4491 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4492 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4493 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4494 currentTick = TickCount();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4495 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4496 while ((wtime == -1) || ((currentTick - entryTick) < 60*wtime/1000));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4497
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4498 allow_scrollbar = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4499 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4500 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4501
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4502 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4503 * Output routines.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4504 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4505
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4506 /* Flush any output to the screen */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4507 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4508 gui_mch_flush(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4509 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4510 /* TODO: Is anything needed here? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4511 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4512
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4513 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4514 * Clear a rectangular region of the screen from text pos (row1, col1) to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4515 * (row2, col2) inclusive.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4516 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4517 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4518 gui_mch_clear_block(int row1, int col1, int row2, int col2)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4519 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4520 Rect rc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4521
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4522 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4523 * Clear one extra pixel at the far right, for when bold characters have
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4524 * spilled over to the next column.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4525 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4526 rc.left = FILL_X(col1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4527 rc.top = FILL_Y(row1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4528 rc.right = FILL_X(col2 + 1) + (col2 == Columns - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4529 rc.bottom = FILL_Y(row2 + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4530
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4531 gui_mch_set_bg_color(gui.back_pixel);
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4532 EraseRect(&rc);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4533 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4534
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4535 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4536 * Clear the whole text window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4537 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4538 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4539 gui_mch_clear_all(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4540 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4541 Rect rc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4542
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4543 rc.left = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4544 rc.top = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4545 rc.right = Columns * gui.char_width + 2 * gui.border_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4546 rc.bottom = Rows * gui.char_height + 2 * gui.border_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4547
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4548 gui_mch_set_bg_color(gui.back_pixel);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4549 EraseRect(&rc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4550 /* gui_mch_set_fg_color(gui.norm_pixel);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4551 FrameRect(&rc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4552 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4553 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4554
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4555 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4556 * Delete the given number of lines from the given row, scrolling up any
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4557 * text further down within the scroll region.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4558 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4559 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4560 gui_mch_delete_lines(int row, int num_lines)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4561 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4562 Rect rc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4563
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4564 /* changed without checking! */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4565 rc.left = FILL_X(gui.scroll_region_left);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4566 rc.right = FILL_X(gui.scroll_region_right + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4567 rc.top = FILL_Y(row);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4568 rc.bottom = FILL_Y(gui.scroll_region_bot + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4569
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4570 gui_mch_set_bg_color(gui.back_pixel);
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4571 ScrollRect(&rc, 0, -num_lines * gui.char_height, (RgnHandle) nil);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4572
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4573 gui_clear_block(gui.scroll_region_bot - num_lines + 1,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4574 gui.scroll_region_left,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4575 gui.scroll_region_bot, gui.scroll_region_right);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4576 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4577
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4578 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4579 * Insert the given number of lines before the given row, scrolling down any
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4580 * following text within the scroll region.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4581 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4582 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4583 gui_mch_insert_lines(int row, int num_lines)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4584 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4585 Rect rc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4586
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4587 rc.left = FILL_X(gui.scroll_region_left);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4588 rc.right = FILL_X(gui.scroll_region_right + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4589 rc.top = FILL_Y(row);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4590 rc.bottom = FILL_Y(gui.scroll_region_bot + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4591
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4592 gui_mch_set_bg_color(gui.back_pixel);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4593
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4594 ScrollRect(&rc, 0, gui.char_height * num_lines, (RgnHandle) nil);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4595
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4596 /* Update gui.cursor_row if the cursor scrolled or copied over */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4597 if (gui.cursor_row >= gui.row
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4598 && gui.cursor_col >= gui.scroll_region_left
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4599 && gui.cursor_col <= gui.scroll_region_right)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4600 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4601 if (gui.cursor_row <= gui.scroll_region_bot - num_lines)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4602 gui.cursor_row += num_lines;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4603 else if (gui.cursor_row <= gui.scroll_region_bot)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4604 gui.cursor_is_valid = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4605 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4606
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4607 gui_clear_block(row, gui.scroll_region_left,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4608 row + num_lines - 1, gui.scroll_region_right);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4609 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4610
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4611 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4612 * TODO: add a vim format to the clipboard which remember
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4613 * LINEWISE, CHARWISE, BLOCKWISE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4614 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4615
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4616 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4617 clip_mch_request_selection(VimClipboard *cbd)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4618 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4619
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4620 Handle textOfClip;
19
a81bc802c17c updated for version 7.0011
vimboss
parents: 13
diff changeset
4621 int flavor = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4622 Size scrapSize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4623 ScrapFlavorFlags scrapFlags;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4624 ScrapRef scrap = nil;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4625 OSStatus error;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4626 int type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4627 char *searchCR;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4628 char_u *tempclip;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4629
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4630
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4631 error = GetCurrentScrap(&scrap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4632 if (error != noErr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4633 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4634
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4635 error = GetScrapFlavorFlags(scrap, VIMSCRAPFLAVOR, &scrapFlags);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4636 if (error == noErr)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4637 {
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4638 error = GetScrapFlavorSize(scrap, VIMSCRAPFLAVOR, &scrapSize);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4639 if (error == noErr && scrapSize > 1)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4640 flavor = 1;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4641 }
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4642
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4643 if (flavor == 0)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4644 {
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4645 error = GetScrapFlavorFlags(scrap, SCRAPTEXTFLAVOR, &scrapFlags);
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4646 if (error != noErr)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4647 return;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4648
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4649 error = GetScrapFlavorSize(scrap, SCRAPTEXTFLAVOR, &scrapSize);
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4650 if (error != noErr)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4651 return;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4652 }
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4653
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4654 ReserveMem(scrapSize);
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4655
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4656 /* In CARBON we don't need a Handle, a pointer is good */
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4657 textOfClip = NewHandle(scrapSize);
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4658
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4659 /* tempclip = lalloc(scrapSize+1, TRUE); */
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4660 HLock(textOfClip);
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4661 error = GetScrapFlavorData(scrap,
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4662 flavor ? VIMSCRAPFLAVOR : SCRAPTEXTFLAVOR,
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4663 &scrapSize, *textOfClip);
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4664 scrapSize -= flavor;
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4665
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4666 if (flavor)
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4667 type = **textOfClip;
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4668 else
2896
fd4224d9ee09 updated for version 7.3.221
Bram Moolenaar <bram@vim.org>
parents: 2869
diff changeset
4669 type = MAUTO;
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4670
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4671 tempclip = lalloc(scrapSize + 1, TRUE);
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4672 mch_memmove(tempclip, *textOfClip + flavor, scrapSize);
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4673 tempclip[scrapSize] = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4674
766
f0d0d3d3a1e2 updated for version 7.0225
vimboss
parents: 719
diff changeset
4675 #ifdef MACOS_CONVERT
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4676 {
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4677 /* Convert from utf-16 (clipboard) */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4678 size_t encLen = 0;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4679 char_u *to = mac_utf16_to_enc((UniChar *)tempclip, scrapSize, &encLen);
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4680
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4681 if (to != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4682 {
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4683 scrapSize = encLen;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4684 vim_free(tempclip);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4685 tempclip = to;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4686 }
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4687 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4688 #endif
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
4689
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4690 searchCR = (char *)tempclip;
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4691 while (searchCR != NULL)
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4692 {
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4693 searchCR = strchr(searchCR, '\r');
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4694 if (searchCR != NULL)
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4695 *searchCR = '\n';
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4696 }
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4697
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4698 clip_yank_selection(type, tempclip, scrapSize, cbd);
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4699
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4700 vim_free(tempclip);
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4701 HUnlock(textOfClip);
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4702
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4703 DisposeHandle(textOfClip);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4704 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4705
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4706 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4707 clip_mch_lose_selection(VimClipboard *cbd)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4708 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4709 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4710 * TODO: Really nothing to do?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4711 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4712 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4713
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4714 int
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4715 clip_mch_own_selection(VimClipboard *cbd)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4716 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4717 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4718 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4719
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4720 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4721 * Send the current selection to the clipboard.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4722 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4723 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4724 clip_mch_set_selection(VimClipboard *cbd)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4725 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4726 Handle textOfClip;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4727 long scrapSize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4728 int type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4729 ScrapRef scrap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4730
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4731 char_u *str = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4732
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4733 if (!cbd->owned)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4734 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4735
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4736 clip_get_selection(cbd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4737
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4738 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4739 * Once we set the clipboard, lose ownership. If another application sets
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4740 * the clipboard, we don't want to think that we still own it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4741 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4742 cbd->owned = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4743
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4744 type = clip_convert_selection(&str, (long_u *)&scrapSize, cbd);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4745
766
f0d0d3d3a1e2 updated for version 7.0225
vimboss
parents: 719
diff changeset
4746 #ifdef MACOS_CONVERT
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4747 size_t utf16_len = 0;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4748 UniChar *to = mac_enc_to_utf16(str, scrapSize, &utf16_len);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4749 if (to)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4750 {
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4751 scrapSize = utf16_len;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4752 vim_free(str);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4753 str = (char_u *)to;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4754 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4755 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4756
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4757 if (type >= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4758 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4759 ClearCurrentScrap();
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4760
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4761 textOfClip = NewHandle(scrapSize + 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4762 HLock(textOfClip);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4763
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4764 **textOfClip = type;
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4765 mch_memmove(*textOfClip + 1, str, scrapSize);
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4766 GetCurrentScrap(&scrap);
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 834
diff changeset
4767 PutScrapFlavor(scrap, SCRAPTEXTFLAVOR, kScrapFlavorMaskNone,
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4768 scrapSize, *textOfClip + 1);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4769 PutScrapFlavor(scrap, VIMSCRAPFLAVOR, kScrapFlavorMaskNone,
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4770 scrapSize + 1, *textOfClip);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4771 HUnlock(textOfClip);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4772 DisposeHandle(textOfClip);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4773 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4774
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4775 vim_free(str);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4776 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4777
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4778 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4779 gui_mch_set_text_area_pos(int x, int y, int w, int h)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4780 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4781 Rect VimBound;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4782
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4783 /* HideWindow(gui.VimWindow); */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4784 GetWindowBounds(gui.VimWindow, kWindowGlobalPortRgn, &VimBound);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4785
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4786 if (gui.which_scrollbars[SBAR_LEFT])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4787 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4788 VimBound.left = -gui.scrollbar_width + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4789 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4790 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4791 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4792 VimBound.left = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4793 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4794
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4795 SetWindowBounds(gui.VimWindow, kWindowGlobalPortRgn, &VimBound);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4796
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4797 ShowWindow(gui.VimWindow);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4798 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4799
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4800 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4801 * Menu stuff.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4802 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4803
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4804 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4805 gui_mch_enable_menu(int flag)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4806 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4807 /*
444
d0d15b184c56 updated for version 7.0116
vimboss
parents: 418
diff changeset
4808 * Menu is always active.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4809 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4810 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4811
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4812 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4813 gui_mch_set_menu_pos(int x, int y, int w, int h)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4814 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4815 /*
444
d0d15b184c56 updated for version 7.0116
vimboss
parents: 418
diff changeset
4816 * The menu is always at the top of the screen.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4817 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4818 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4819
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4820 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4821 * Add a sub menu to the menu bar.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4822 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4823 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4824 gui_mch_add_menu(vimmenu_T *menu, int idx)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4825 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4826 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4827 * TODO: Try to use only menu_id instead of both menu_id and menu_handle.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4828 * TODO: use menu->mnemonic and menu->actext
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4829 * TODO: Try to reuse menu id
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4830 * Carbon Help suggest to use only id between 1 and 235
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4831 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4832 static long next_avail_id = 128;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4833 long menu_after_me = 0; /* Default to the end */
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4834 #if defined(FEAT_MBYTE)
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4835 CFStringRef name;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4836 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4837 char_u *name;
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4838 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4839 short index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4840 vimmenu_T *parent = menu->parent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4841 vimmenu_T *brother = menu->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4842
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4843 /* Cannot add a menu if ... */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4844 if ((parent != NULL && parent->submenu_id == 0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4845 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4846
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4847 /* menu ID greater than 1024 are reserved for ??? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4848 if (next_avail_id == 1024)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4849 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4850
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4851 /* My brother could be the PopUp, find my real brother */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4852 while ((brother != NULL) && (!menu_is_menubar(brother->name)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4853 brother = brother->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4854
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4855 /* Find where to insert the menu (for MenuBar) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4856 if ((parent == NULL) && (brother != NULL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4857 menu_after_me = brother->submenu_id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4858
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4859 /* If the menu is not part of the menubar (and its submenus), add it 'nowhere' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4860 if (!menu_is_menubar(menu->name))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4861 menu_after_me = hierMenu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4862
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4863 /* Convert the name */
766
f0d0d3d3a1e2 updated for version 7.0225
vimboss
parents: 719
diff changeset
4864 #ifdef MACOS_CONVERT
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4865 name = menu_title_removing_mnemonic(menu);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4866 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4867 name = C2Pascal_save(menu->dname);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4868 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4869 if (name == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4870 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4871
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4872 /* Create the menu unless it's the help menu */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4873 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4874 /* Carbon suggest use of
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4875 * OSStatus CreateNewMenu(MenuID, MenuAttributes, MenuRef *);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4876 * OSStatus SetMenuTitle(MenuRef, ConstStr255Param title);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4877 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4878 menu->submenu_id = next_avail_id;
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4879 #if defined(FEAT_MBYTE)
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4880 if (CreateNewMenu(menu->submenu_id, 0, (MenuRef *)&menu->submenu_handle) == noErr)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4881 SetMenuTitleWithCFString((MenuRef)menu->submenu_handle, name);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4882 #else
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4883 menu->submenu_handle = NewMenu(menu->submenu_id, name);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4884 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4885 next_avail_id++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4886 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4887
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4888 if (parent == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4889 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4890 /* Adding a menu to the menubar, or in the no mans land (for PopUp) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4891
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4892 /* TODO: Verify if we could only Insert Menu if really part of the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4893 * menubar The Inserted menu are scanned or the Command-key combos
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4894 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4895
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4896 /* Insert the menu */
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4897 InsertMenu(menu->submenu_handle, menu_after_me); /* insert before */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4898 #if 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4899 /* Vim should normally update it. TODO: verify */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4900 DrawMenuBar();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4901 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4902 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4903 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4904 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4905 /* Adding as a submenu */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4906
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4907 index = gui_mac_get_menu_item_index(menu);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4908
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4909 /* Call InsertMenuItem followed by SetMenuItemText
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4910 * to avoid special character recognition by InsertMenuItem
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4911 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4912 InsertMenuItem(parent->submenu_handle, "\p ", idx); /* afterItem */
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4913 #if defined(FEAT_MBYTE)
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4914 SetMenuItemTextWithCFString(parent->submenu_handle, idx+1, name);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4915 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4916 SetMenuItemText(parent->submenu_handle, idx+1, name);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4917 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4918 SetItemCmd(parent->submenu_handle, idx+1, 0x1B);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4919 SetItemMark(parent->submenu_handle, idx+1, menu->submenu_id);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4920 InsertMenu(menu->submenu_handle, hierMenu);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4921 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4922
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4923 #if defined(FEAT_MBYTE)
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4924 CFRelease(name);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4925 #else
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4926 vim_free(name);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4927 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4928
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4929 #if 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4930 /* Done by Vim later on */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4931 DrawMenuBar();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4932 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4933 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4934
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4935 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4936 * Add a menu item to a menu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4937 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4938 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4939 gui_mch_add_menu_item(vimmenu_T *menu, int idx)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4940 {
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
4941 #if defined(FEAT_MBYTE)
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4942 CFStringRef name;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4943 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4944 char_u *name;
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4945 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4946 vimmenu_T *parent = menu->parent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4947 int menu_inserted;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4948
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4949 /* Cannot add item, if the menu have not been created */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4950 if (parent->submenu_id == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4951 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4952
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4953 /* Could call SetMenuRefCon [CARBON] to associate with the Menu,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4954 for older OS call GetMenuItemData (menu, item, isCommandID?, data) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4955
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4956 /* Convert the name */
766
f0d0d3d3a1e2 updated for version 7.0225
vimboss
parents: 719
diff changeset
4957 #ifdef MACOS_CONVERT
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4958 name = menu_title_removing_mnemonic(menu);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4959 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4960 name = C2Pascal_save(menu->dname);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4961 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4962
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4963 /* Where are just a menu item, so no handle, no id */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4964 menu->submenu_id = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4965 menu->submenu_handle = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4966
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4967 menu_inserted = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4968 if (menu->actext)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4969 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4970 /* If the accelerator text for the menu item looks like it describes
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4971 * a command key (e.g., "<D-S-t>" or "<C-7>"), display it as the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4972 * item's command equivalent.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4973 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4974 int key = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4975 int modifiers = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4976 char_u *p_actext;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4977
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4978 p_actext = menu->actext;
1776
a9f814054152 updated for version 7.2-074
vimboss
parents: 1702
diff changeset
4979 key = find_special_key(&p_actext, &modifiers, FALSE, FALSE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4980 if (*p_actext != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4981 key = 0; /* error: trailing text */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4982 /* find_special_key() returns a keycode with as many of the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4983 * specified modifiers as appropriate already applied (e.g., for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4984 * "<D-C-x>" it returns Ctrl-X as the keycode and MOD_MASK_CMD
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4985 * as the only modifier). Since we want to display all of the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4986 * modifiers, we need to convert the keycode back to a printable
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4987 * character plus modifiers.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4988 * TODO: Write an alternative find_special_key() that doesn't
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4989 * apply modifiers.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4990 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4991 if (key > 0 && key < 32)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4992 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4993 /* Convert a control key to an uppercase letter. Note that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4994 * by this point it is no longer possible to distinguish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4995 * between, e.g., Ctrl-S and Ctrl-Shift-S.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4996 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4997 modifiers |= MOD_MASK_CTRL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4998 key += '@';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4999 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5000 /* If the keycode is an uppercase letter, set the Shift modifier.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5001 * If it is a lowercase letter, don't set the modifier, but convert
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5002 * the letter to uppercase for display in the menu.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5003 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5004 else if (key >= 'A' && key <= 'Z')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5005 modifiers |= MOD_MASK_SHIFT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5006 else if (key >= 'a' && key <= 'z')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5007 key += 'A' - 'a';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5008 /* Note: keycodes below 0x22 are reserved by Apple. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5009 if (key >= 0x22 && vim_isprintc_strict(key))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5010 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5011 int valid = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5012 char_u mac_mods = kMenuNoModifiers;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5013 /* Convert Vim modifier codes to Menu Manager equivalents. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5014 if (modifiers & MOD_MASK_SHIFT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5015 mac_mods |= kMenuShiftModifier;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5016 if (modifiers & MOD_MASK_CTRL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5017 mac_mods |= kMenuControlModifier;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5018 if (!(modifiers & MOD_MASK_CMD))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5019 mac_mods |= kMenuNoCommandModifier;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5020 if (modifiers & MOD_MASK_ALT || modifiers & MOD_MASK_MULTI_CLICK)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5021 valid = 0; /* TODO: will Alt someday map to Option? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5022 if (valid)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5023 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5024 char_u item_txt[10];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5025 /* Insert the menu item after idx, with its command key. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5026 item_txt[0] = 3; item_txt[1] = ' '; item_txt[2] = '/';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5027 item_txt[3] = key;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5028 InsertMenuItem(parent->submenu_handle, item_txt, idx);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5029 /* Set the modifier keys. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5030 SetMenuItemModifiers(parent->submenu_handle, idx+1, mac_mods);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5031 menu_inserted = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5032 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5033 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5034 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5035 /* Call InsertMenuItem followed by SetMenuItemText
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5036 * to avoid special character recognition by InsertMenuItem
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5037 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5038 if (!menu_inserted)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5039 InsertMenuItem(parent->submenu_handle, "\p ", idx); /* afterItem */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5040 /* Set the menu item name. */
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5041 #if defined(FEAT_MBYTE)
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5042 SetMenuItemTextWithCFString(parent->submenu_handle, idx+1, name);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5043 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5044 SetMenuItemText(parent->submenu_handle, idx+1, name);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5045 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5046
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5047 #if 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5048 /* Called by Vim */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5049 DrawMenuBar();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5050 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5051
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5052 #if defined(FEAT_MBYTE)
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5053 CFRelease(name);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5054 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5055 /* TODO: Can name be freed? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5056 vim_free(name);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5057 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5058 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5059
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5060 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5061 gui_mch_toggle_tearoffs(int enable)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5062 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5063 /* no tearoff menus */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5064 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5065
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5066 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5067 * Destroy the machine specific menu widget.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5068 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5069 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5070 gui_mch_destroy_menu(vimmenu_T *menu)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5071 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5072 short index = gui_mac_get_menu_item_index(menu);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5073
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5074 if (index > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5075 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5076 if (menu->parent)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5077 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5078 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5079 /* For now just don't delete help menu items. (Huh? Dany) */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5080 DeleteMenuItem(menu->parent->submenu_handle, index);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5081
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5082 /* Delete the Menu if it was a hierarchical Menu */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5083 if (menu->submenu_id != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5084 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5085 DeleteMenu(menu->submenu_id);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5086 DisposeMenu(menu->submenu_handle);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5087 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5088 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5089 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5090 #ifdef DEBUG_MAC_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5091 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5092 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5093 printf("gmdm 2\n");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5094 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5095 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5096 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5097 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5098 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5099 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5100 DeleteMenu(menu->submenu_id);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5101 DisposeMenu(menu->submenu_handle);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5102 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5103 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5104 /* Shouldn't this be already done by Vim. TODO: Check */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5105 DrawMenuBar();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5106 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5107
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5108 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5109 * Make a menu either grey or not grey.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5110 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5111 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5112 gui_mch_menu_grey(vimmenu_T *menu, int grey)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5113 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5114 /* TODO: Check if menu really exists */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5115 short index = gui_mac_get_menu_item_index(menu);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5116 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5117 index = menu->index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5118 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5119 if (grey)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5120 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5121 if (menu->children)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5122 DisableMenuItem(menu->submenu_handle, index);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5123 if (menu->parent)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5124 if (menu->parent->submenu_handle)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5125 DisableMenuItem(menu->parent->submenu_handle, index);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5126 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5127 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5128 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5129 if (menu->children)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5130 EnableMenuItem(menu->submenu_handle, index);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5131 if (menu->parent)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5132 if (menu->parent->submenu_handle)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5133 EnableMenuItem(menu->parent->submenu_handle, index);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5134 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5135 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5136
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5137 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5138 * Make menu item hidden or not hidden
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5139 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5140 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5141 gui_mch_menu_hidden(vimmenu_T *menu, int hidden)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5142 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5143 /* There's no hidden mode on MacOS */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5144 gui_mch_menu_grey(menu, hidden);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5145 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5146
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5147
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5148 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5149 * This is called after setting all the menus to grey/hidden or not.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5150 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5151 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5152 gui_mch_draw_menubar(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5153 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5154 DrawMenuBar();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5155 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5156
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5157
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5158 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5159 * Scrollbar stuff.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5160 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5161
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5162 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5163 gui_mch_enable_scrollbar(
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5164 scrollbar_T *sb,
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5165 int flag)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5166 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5167 if (flag)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5168 ShowControl(sb->id);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5169 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5170 HideControl(sb->id);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5171
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5172 #ifdef DEBUG_MAC_SB
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5173 printf("enb_sb (%x) %x\n",sb->id, flag);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5174 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5175 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5176
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5177 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5178 gui_mch_set_scrollbar_thumb(
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5179 scrollbar_T *sb,
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5180 long val,
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5181 long size,
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5182 long max)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5183 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5184 SetControl32BitMaximum (sb->id, max);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5185 SetControl32BitMinimum (sb->id, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5186 SetControl32BitValue (sb->id, val);
1107
2ced59eaf1e5 updated for version 7.0-233
vimboss
parents: 1106
diff changeset
5187 SetControlViewSize (sb->id, size);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5188 #ifdef DEBUG_MAC_SB
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5189 printf("thumb_sb (%x) %x, %x,%x\n",sb->id, val, size, max);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5190 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5191 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5192
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5193 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5194 gui_mch_set_scrollbar_pos(
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5195 scrollbar_T *sb,
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5196 int x,
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5197 int y,
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5198 int w,
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5199 int h)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5200 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5201 gui_mch_set_bg_color(gui.back_pixel);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5202 /* if (gui.which_scrollbars[SBAR_LEFT])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5203 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5204 MoveControl(sb->id, x-16, y);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5205 SizeControl(sb->id, w + 1, h);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5206 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5207 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5208 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5209 MoveControl(sb->id, x, y);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5210 SizeControl(sb->id, w + 1, h);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5211 }*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5212 if (sb == &gui.bottom_sbar)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5213 h += 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5214 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5215 w += 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5216
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5217 if (gui.which_scrollbars[SBAR_LEFT])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5218 x -= 15;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5219
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5220 MoveControl(sb->id, x, y);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5221 SizeControl(sb->id, w, h);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5222 #ifdef DEBUG_MAC_SB
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5223 printf("size_sb (%x) %x, %x, %x, %x\n",sb->id, x, y, w, h);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5224 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5225 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5226
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5227 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5228 gui_mch_create_scrollbar(
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5229 scrollbar_T *sb,
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5230 int orient) /* SBAR_VERT or SBAR_HORIZ */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5231 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5232 Rect bounds;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5233
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5234 bounds.top = -16;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5235 bounds.bottom = -10;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5236 bounds.right = -10;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5237 bounds.left = -16;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5238
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5239 sb->id = NewControl(gui.VimWindow,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5240 &bounds,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5241 "\pScrollBar",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5242 TRUE,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5243 0, /* current*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5244 0, /* top */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5245 0, /* bottom */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5246 kControlScrollBarLiveProc,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5247 (long) sb->ident);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5248 #ifdef DEBUG_MAC_SB
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5249 printf("create_sb (%x) %x\n",sb->id, orient);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5250 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5251 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5252
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5253 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5254 gui_mch_destroy_scrollbar(scrollbar_T *sb)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5255 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5256 gui_mch_set_bg_color(gui.back_pixel);
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5257 DisposeControl(sb->id);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5258 #ifdef DEBUG_MAC_SB
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5259 printf("dest_sb (%x) \n",sb->id);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5260 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5261 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5262
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5263
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5264 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5265 * Cursor blink functions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5266 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5267 * This is a simple state machine:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5268 * BLINK_NONE not blinking at all
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5269 * BLINK_OFF blinking, cursor is not shown
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5270 * BLINK_ON blinking, cursor is shown
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5271 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5272 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5273 gui_mch_set_blinking(long wait, long on, long off)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5274 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5275 /* TODO: TODO: TODO: TODO: */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5276 /* blink_waittime = wait;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5277 blink_ontime = on;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5278 blink_offtime = off;*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5279 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5280
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5281 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5282 * Stop the cursor blinking. Show the cursor if it wasn't shown.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5283 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5284 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5285 gui_mch_stop_blink(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5286 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5287 gui_update_cursor(TRUE, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5288 /* TODO: TODO: TODO: TODO: */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5289 /* gui_w32_rm_blink_timer();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5290 if (blink_state == BLINK_OFF)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5291 gui_update_cursor(TRUE, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5292 blink_state = BLINK_NONE;*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5293 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5294
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5295 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5296 * Start the cursor blinking. If it was already blinking, this restarts the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5297 * waiting time and shows the cursor.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5298 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5299 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5300 gui_mch_start_blink(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5301 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5302 gui_update_cursor(TRUE, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5303 /* TODO: TODO: TODO: TODO: */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5304 /* gui_w32_rm_blink_timer(); */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5305
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5306 /* Only switch blinking on if none of the times is zero */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5307 /* if (blink_waittime && blink_ontime && blink_offtime)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5308 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5309 blink_timer = SetTimer(NULL, 0, (UINT)blink_waittime,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5310 (TIMERPROC)_OnBlinkTimer);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5311 blink_state = BLINK_ON;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5312 gui_update_cursor(TRUE, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5313 }*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5314 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5315
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5316 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5317 * Return the RGB value of a pixel as long.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5318 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5319 long_u
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5320 gui_mch_get_rgb(guicolor_T pixel)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5321 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5322 return (Red(pixel) << 16) + (Green(pixel) << 8) + Blue(pixel);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5323 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5324
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5325
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5326
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5327 #ifdef FEAT_BROWSE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5328 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5329 * Pop open a file browser and return the file selected, in allocated memory,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5330 * or NULL if Cancel is hit.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5331 * saving - TRUE if the file will be saved to, FALSE if it will be opened.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5332 * title - Title message for the file browser dialog.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5333 * dflt - Default name of file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5334 * ext - Default extension to be added to files without extensions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5335 * initdir - directory in which to open the browser (NULL = current dir)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5336 * filter - Filter for matched files to choose from.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5337 * Has a format like this:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5338 * "C Files (*.c)\0*.c\0"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5339 * "All Files\0*.*\0\0"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5340 * If these two strings were concatenated, then a choice of two file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5341 * filters will be selectable to the user. Then only matching files will
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5342 * be shown in the browser. If NULL, the default allows all files.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5343 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5344 * *NOTE* - the filter string must be terminated with TWO nulls.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5345 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5346 char_u *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5347 gui_mch_browse(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5348 int saving,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5349 char_u *title,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5350 char_u *dflt,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5351 char_u *ext,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5352 char_u *initdir,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5353 char_u *filter)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5354 {
4352
04736b4030ec updated for version 7.3.925
Bram Moolenaar <bram@vim.org>
parents: 3935
diff changeset
5355 /* TODO: Add Ammon's safety check (Dany) */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5356 NavReplyRecord reply;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5357 char_u *fname = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5358 char_u **fnames = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5359 long numFiles;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5360 NavDialogOptions navOptions;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5361 OSErr error;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5362
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5363 /* Get Navigation Service Defaults value */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5364 NavGetDefaultDialogOptions(&navOptions);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5365
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5366
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5367 /* TODO: If we get a :browse args, set the Multiple bit. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5368 navOptions.dialogOptionFlags = kNavAllowInvisibleFiles
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5369 | kNavDontAutoTranslate
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5370 | kNavDontAddTranslateItems
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5371 /* | kNavAllowMultipleFiles */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5372 | kNavAllowStationery;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5373
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5374 (void) C2PascalString(title, &navOptions.message);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5375 (void) C2PascalString(dflt, &navOptions.savedFileName);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5376 /* Could set clientName?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5377 * windowTitle? (there's no title bar?)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5378 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5379
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5380 if (saving)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5381 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5382 /* Change first parm AEDesc (typeFSS) *defaultLocation to match dflt */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5383 NavPutFile(NULL, &reply, &navOptions, NULL, 'TEXT', 'VIM!', NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5384 if (!reply.validRecord)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5385 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5386 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5387 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5388 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5389 /* Change first parm AEDesc (typeFSS) *defaultLocation to match dflt */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5390 NavGetFile(NULL, &reply, &navOptions, NULL, NULL, NULL, NULL, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5391 if (!reply.validRecord)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5392 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5393 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5394
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5395 fnames = new_fnames_from_AEDesc(&reply.selection, &numFiles, &error);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5396
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5397 NavDisposeReply(&reply);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5398
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5399 if (fnames)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5400 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5401 fname = fnames[0];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5402 vim_free(fnames);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5403 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5404
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5405 /* TODO: Shorten the file name if possible */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5406 return fname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5407 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5408 #endif /* FEAT_BROWSE */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5409
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5410 #ifdef FEAT_GUI_DIALOG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5411 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5412 * Stuff for dialogues
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5413 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5414
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5415 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5416 * Create a dialogue dynamically from the parameter strings.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5417 * type = type of dialogue (question, alert, etc.)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5418 * title = dialogue title. may be NULL for default title.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5419 * message = text to display. Dialogue sizes to accommodate it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5420 * buttons = '\n' separated list of button captions, default first.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5421 * dfltbutton = number of default button.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5422 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5423 * This routine returns 1 if the first button is pressed,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5424 * 2 for the second, etc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5425 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5426 * 0 indicates Esc was pressed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5427 * -1 for unexpected error
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5428 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5429 * If stubbing out this fn, return 1.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5430 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5431
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5432 typedef struct
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5433 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5434 short idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5435 short width; /* Size of the text in pixel */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5436 Rect box;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5437 } vgmDlgItm; /* Vim Gui_Mac.c Dialog Item */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5438
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5439 #define MoveRectTo(r,x,y) OffsetRect(r,x-r->left,y-r->top)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5440
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5441 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5442 macMoveDialogItem(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5443 DialogRef theDialog,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5444 short itemNumber,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5445 short X,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5446 short Y,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5447 Rect *inBox)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5448 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5449 #if 0 /* USE_CARBONIZED */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5450 /* Untested */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5451 MoveDialogItem(theDialog, itemNumber, X, Y);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5452 if (inBox != nil)
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5453 GetDialogItem(theDialog, itemNumber, &itemType, &itemHandle, inBox);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5454 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5455 short itemType;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5456 Handle itemHandle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5457 Rect localBox;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5458 Rect *itemBox = &localBox;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5459
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5460 if (inBox != nil)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5461 itemBox = inBox;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5462
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5463 GetDialogItem(theDialog, itemNumber, &itemType, &itemHandle, itemBox);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5464 OffsetRect(itemBox, -itemBox->left, -itemBox->top);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5465 OffsetRect(itemBox, X, Y);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5466 /* To move a control (like a button) we need to call both
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5467 * MoveControl and SetDialogItem. FAQ 6-18 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5468 if (1) /*(itemType & kControlDialogItem) */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5469 MoveControl((ControlRef) itemHandle, X, Y);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5470 SetDialogItem(theDialog, itemNumber, itemType, itemHandle, itemBox);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5471 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5472 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5473
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5474 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5475 macSizeDialogItem(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5476 DialogRef theDialog,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5477 short itemNumber,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5478 short width,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5479 short height)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5480 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5481 short itemType;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5482 Handle itemHandle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5483 Rect itemBox;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5484
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5485 GetDialogItem(theDialog, itemNumber, &itemType, &itemHandle, &itemBox);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5486
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5487 /* When width or height is zero do not change it */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5488 if (width == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5489 width = itemBox.right - itemBox.left;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5490 if (height == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5491 height = itemBox.bottom - itemBox.top;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5492
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5493 #if 0 /* USE_CARBONIZED */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5494 SizeDialogItem(theDialog, itemNumber, width, height); /* Untested */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5495 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5496 /* Resize the bounding box */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5497 itemBox.right = itemBox.left + width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5498 itemBox.bottom = itemBox.top + height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5499
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5500 /* To resize a control (like a button) we need to call both
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5501 * SizeControl and SetDialogItem. (deducted from FAQ 6-18) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5502 if (itemType & kControlDialogItem)
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5503 SizeControl((ControlRef) itemHandle, width, height);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5504
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5505 /* Configure back the item */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5506 SetDialogItem(theDialog, itemNumber, itemType, itemHandle, &itemBox);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5507 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5508 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5509
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5510 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5511 macSetDialogItemText(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5512 DialogRef theDialog,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5513 short itemNumber,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5514 Str255 itemName)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5515 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5516 short itemType;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5517 Handle itemHandle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5518 Rect itemBox;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5519
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5520 GetDialogItem(theDialog, itemNumber, &itemType, &itemHandle, &itemBox);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5521
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5522 if (itemType & kControlDialogItem)
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5523 SetControlTitle((ControlRef) itemHandle, itemName);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5524 else
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5525 SetDialogItemText(itemHandle, itemName);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5526 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5527
1572
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5528
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5529 /* ModalDialog() handler for message dialogs that have hotkey accelerators.
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5530 * Expects a mapping of hotkey char to control index in gDialogHotKeys;
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5531 * setting gDialogHotKeys to NULL disables any hotkey handling.
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5532 */
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5533 static pascal Boolean
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5534 DialogHotkeyFilterProc (
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5535 DialogRef theDialog,
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5536 EventRecord *event,
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5537 DialogItemIndex *itemHit)
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5538 {
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5539 char_u keyHit;
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5540
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5541 if (event->what == keyDown || event->what == autoKey)
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5542 {
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5543 keyHit = (event->message & charCodeMask);
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5544
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5545 if (gDialogHotKeys && gDialogHotKeys[keyHit])
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5546 {
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5547 #ifdef DEBUG_MAC_DIALOG_HOTKEYS
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5548 printf("user pressed hotkey '%c' --> item %d\n", keyHit, gDialogHotKeys[keyHit]);
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5549 #endif
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5550 *itemHit = gDialogHotKeys[keyHit];
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5551
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5552 /* When handing off to StdFilterProc, pretend that the user
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5553 * clicked the control manually. Note that this is also supposed
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5554 * to cause the button to hilite briefly (to give some user
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5555 * feedback), but this seems not to actually work (or it's too
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5556 * fast to be seen).
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5557 */
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5558 event->what = kEventControlSimulateHit;
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5559
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5560 return true; /* we took care of it */
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5561 }
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5562
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5563 /* Defer to the OS's standard behavior for this event.
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5564 * This ensures that Enter will still activate the default button. */
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5565 return StdFilterProc(theDialog, event, itemHit);
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5566 }
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5567 return false; /* Let ModalDialog deal with it */
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5568 }
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5569
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5570
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5571 /* TODO: There have been some crashes with dialogs, check your inbox
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5572 * (Jussi)
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5573 */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5574 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5575 gui_mch_dialog(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5576 int type,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5577 char_u *title,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5578 char_u *message,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5579 char_u *buttons,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5580 int dfltbutton,
2684
951641b8784d updated for version 7.3.102
Bram Moolenaar <bram@vim.org>
parents: 2585
diff changeset
5581 char_u *textfield,
951641b8784d updated for version 7.3.102
Bram Moolenaar <bram@vim.org>
parents: 2585
diff changeset
5582 int ex_cmd)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5583 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5584 Handle buttonDITL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5585 Handle iconDITL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5586 Handle inputDITL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5587 Handle messageDITL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5588 Handle itemHandle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5589 Handle iconHandle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5590 DialogPtr theDialog;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5591 char_u len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5592 char_u PascalTitle[256]; /* place holder for the title */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5593 char_u name[256];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5594 GrafPtr oldPort;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5595 short itemHit;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5596 char_u *buttonChar;
1572
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5597 short hotKeys[256]; /* map of hotkey -> control ID */
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5598 char_u aHotKey;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5599 Rect box;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5600 short button;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5601 short lastButton;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5602 short itemType;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5603 short useIcon;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5604 short width;
1377
e2f5c1597829 updated for version 7.1-092
vimboss
parents: 1373
diff changeset
5605 short totalButtonWidth = 0; /* the width of all buttons together
1212
e085b0f7b036 updated for version 7.1b
vimboss
parents: 1107
diff changeset
5606 including spacing */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5607 short widestButton = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5608 short dfltButtonEdge = 20; /* gut feeling */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5609 short dfltElementSpacing = 13; /* from IM:V.2-29 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5610 short dfltIconSideSpace = 23; /* from IM:V.2-29 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5611 short maximumWidth = 400; /* gut feeling */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5612 short maxButtonWidth = 175; /* gut feeling */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5613
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5614 short vertical;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5615 short dialogHeight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5616 short messageLines = 3;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5617 FontInfo textFontInfo;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5618
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5619 vgmDlgItm iconItm;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5620 vgmDlgItm messageItm;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5621 vgmDlgItm inputItm;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5622 vgmDlgItm buttonItm;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5623
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5624 WindowRef theWindow;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5625
1572
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5626 ModalFilterUPP dialogUPP;
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5627
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5628 /* Check 'v' flag in 'guioptions': vertical button placement. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5629 vertical = (vim_strchr(p_go, GO_VERTICAL) != NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5630
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5631 /* Create a new Dialog Box from template. */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5632 theDialog = GetNewDialog(129, nil, (WindowRef) -1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5633
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5634 /* Get the WindowRef */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5635 theWindow = GetDialogWindow(theDialog);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5636
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5637 /* Hide the window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5638 * 1. to avoid seeing slow drawing
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5639 * 2. to prevent a problem seen while moving dialog item
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5640 * within a visible window. (non-Carbon MacOS 9)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5641 * Could be avoided by changing the resource.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5642 */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5643 HideWindow(theWindow);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5644
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5645 /* Change the graphical port to the dialog,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5646 * so we can measure the text with the proper font */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5647 GetPort(&oldPort);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5648 SetPortDialogPort(theDialog);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5649
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5650 /* Get the info about the default text,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5651 * used to calculate the height of the message
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5652 * and of the text field */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5653 GetFontInfo(&textFontInfo);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5654
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5655 /* Set the dialog title */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5656 if (title != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5657 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5658 (void) C2PascalString(title, &PascalTitle);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5659 SetWTitle(theWindow, PascalTitle);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5660 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5661
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5662 /* Creates the buttons and add them to the Dialog Box. */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5663 buttonDITL = GetResource('DITL', 130);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5664 buttonChar = buttons;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5665 button = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5666
1572
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5667 /* initialize the hotkey mapping */
2215
cccb71c2c5c1 Fix uninit memory read in undo code. Fix uint32_t in proto file.
Bram Moolenaar <bram@vim.org>
parents: 1776
diff changeset
5668 vim_memset(hotKeys, 0, sizeof(hotKeys));
1572
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5669
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5670 for (;*buttonChar != 0;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5671 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5672 /* Get the name of the button */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5673 button++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5674 len = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5675 for (;((*buttonChar != DLG_BUTTON_SEP) && (*buttonChar != 0) && (len < 255)); buttonChar++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5676 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5677 if (*buttonChar != DLG_HOTKEY_CHAR)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5678 name[++len] = *buttonChar;
1572
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5679 else
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5680 {
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5681 aHotKey = (char_u)*(buttonChar+1);
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5682 if (aHotKey >= 'A' && aHotKey <= 'Z')
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5683 aHotKey = (char_u)((int)aHotKey + (int)'a' - (int)'A');
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5684 hotKeys[aHotKey] = button;
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5685 #ifdef DEBUG_MAC_DIALOG_HOTKEYS
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5686 printf("### hotKey for button %d is '%c'\n", button, aHotKey);
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5687 #endif
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5688 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5689 }
1572
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5690
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5691 if (*buttonChar != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5692 buttonChar++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5693 name[0] = len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5694
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5695 /* Add the button */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5696 AppendDITL(theDialog, buttonDITL, overlayDITL); /* appendDITLRight); */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5697
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5698 /* Change the button's name */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5699 macSetDialogItemText(theDialog, button, name);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5700
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5701 /* Resize the button to fit its name */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5702 width = StringWidth(name) + 2 * dfltButtonEdge;
4352
04736b4030ec updated for version 7.3.925
Bram Moolenaar <bram@vim.org>
parents: 3935
diff changeset
5703 /* Limit the size of any button to an acceptable value. */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5704 /* TODO: Should be based on the message width */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5705 if (width > maxButtonWidth)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5706 width = maxButtonWidth;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5707 macSizeDialogItem(theDialog, button, width, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5708
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5709 totalButtonWidth += width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5710
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5711 if (width > widestButton)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5712 widestButton = width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5713 }
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5714 ReleaseResource(buttonDITL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5715 lastButton = button;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5716
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5717 /* Add the icon to the Dialog Box. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5718 iconItm.idx = lastButton + 1;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5719 iconDITL = GetResource('DITL', 131);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5720 switch (type)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5721 {
2585
03d49a7c8319 updated for version 7.3.010
Bram Moolenaar <bram@vim.org>
parents: 2565
diff changeset
5722 case VIM_GENERIC:
03d49a7c8319 updated for version 7.3.010
Bram Moolenaar <bram@vim.org>
parents: 2565
diff changeset
5723 case VIM_INFO:
03d49a7c8319 updated for version 7.3.010
Bram Moolenaar <bram@vim.org>
parents: 2565
diff changeset
5724 case VIM_QUESTION: useIcon = kNoteIcon; break;
03d49a7c8319 updated for version 7.3.010
Bram Moolenaar <bram@vim.org>
parents: 2565
diff changeset
5725 case VIM_WARNING: useIcon = kCautionIcon; break;
03d49a7c8319 updated for version 7.3.010
Bram Moolenaar <bram@vim.org>
parents: 2565
diff changeset
5726 case VIM_ERROR: useIcon = kStopIcon; break;
3935
ee138f29259e updated for version 7.3.723
Bram Moolenaar <bram@vim.org>
parents: 3210
diff changeset
5727 default: useIcon = kStopIcon;
2585
03d49a7c8319 updated for version 7.3.010
Bram Moolenaar <bram@vim.org>
parents: 2565
diff changeset
5728 }
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5729 AppendDITL(theDialog, iconDITL, overlayDITL);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5730 ReleaseResource(iconDITL);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5731 GetDialogItem(theDialog, iconItm.idx, &itemType, &itemHandle, &box);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5732 /* TODO: Should the item be freed? */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5733 iconHandle = GetIcon(useIcon);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5734 SetDialogItem(theDialog, iconItm.idx, itemType, iconHandle, &box);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5735
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5736 /* Add the message to the Dialog box. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5737 messageItm.idx = lastButton + 2;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5738 messageDITL = GetResource('DITL', 132);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5739 AppendDITL(theDialog, messageDITL, overlayDITL);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5740 ReleaseResource(messageDITL);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5741 GetDialogItem(theDialog, messageItm.idx, &itemType, &itemHandle, &box);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5742 (void) C2PascalString(message, &name);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5743 SetDialogItemText(itemHandle, name);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5744 messageItm.width = StringWidth(name);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5745
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5746 /* Add the input box if needed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5747 if (textfield != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5748 {
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
5749 /* Cheat for now reuse the message and convert to text edit */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5750 inputItm.idx = lastButton + 3;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5751 inputDITL = GetResource('DITL', 132);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5752 AppendDITL(theDialog, inputDITL, overlayDITL);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5753 ReleaseResource(inputDITL);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5754 GetDialogItem(theDialog, inputItm.idx, &itemType, &itemHandle, &box);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5755 /* SetDialogItem(theDialog, inputItm.idx, kEditTextDialogItem, itemHandle, &box);*/
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5756 (void) C2PascalString(textfield, &name);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5757 SetDialogItemText(itemHandle, name);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5758 inputItm.width = StringWidth(name);
1572
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5759
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5760 /* Hotkeys don't make sense if there's a text field */
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5761 gDialogHotKeys = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5762 }
1572
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5763 else
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5764 /* Install hotkey table */
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5765 gDialogHotKeys = (short *)&hotKeys;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5766
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5767 /* Set the <ENTER> and <ESC> button. */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5768 SetDialogDefaultItem(theDialog, dfltbutton);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5769 SetDialogCancelItem(theDialog, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5770
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5771 /* Reposition element */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5772
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5773 /* Check if we need to force vertical */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5774 if (totalButtonWidth > maximumWidth)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5775 vertical = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5776
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5777 /* Place icon */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5778 macMoveDialogItem(theDialog, iconItm.idx, dfltIconSideSpace, dfltElementSpacing, &box);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5779 iconItm.box.right = box.right;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5780 iconItm.box.bottom = box.bottom;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5781
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5782 /* Place Message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5783 messageItm.box.left = iconItm.box.right + dfltIconSideSpace;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5784 macSizeDialogItem(theDialog, messageItm.idx, 0, messageLines * (textFontInfo.ascent + textFontInfo.descent));
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5785 macMoveDialogItem(theDialog, messageItm.idx, messageItm.box.left, dfltElementSpacing, &messageItm.box);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5786
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5787 /* Place Input */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5788 if (textfield != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5789 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5790 inputItm.box.left = messageItm.box.left;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5791 inputItm.box.top = messageItm.box.bottom + dfltElementSpacing;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5792 macSizeDialogItem(theDialog, inputItm.idx, 0, textFontInfo.ascent + textFontInfo.descent);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5793 macMoveDialogItem(theDialog, inputItm.idx, inputItm.box.left, inputItm.box.top, &inputItm.box);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5794 /* Convert the static text into a text edit.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5795 * For some reason this change need to be done last (Dany) */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5796 GetDialogItem(theDialog, inputItm.idx, &itemType, &itemHandle, &inputItm.box);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5797 SetDialogItem(theDialog, inputItm.idx, kEditTextDialogItem, itemHandle, &inputItm.box);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5798 SelectDialogItemText(theDialog, inputItm.idx, 0, 32767);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5799 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5800
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5801 /* Place Button */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5802 if (textfield != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5803 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5804 buttonItm.box.left = inputItm.box.left;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5805 buttonItm.box.top = inputItm.box.bottom + dfltElementSpacing;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5806 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5807 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5808 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5809 buttonItm.box.left = messageItm.box.left;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5810 buttonItm.box.top = messageItm.box.bottom + dfltElementSpacing;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5811 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5812
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5813 for (button=1; button <= lastButton; button++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5814 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5815
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5816 macMoveDialogItem(theDialog, button, buttonItm.box.left, buttonItm.box.top, &box);
1377
e2f5c1597829 updated for version 7.1-092
vimboss
parents: 1373
diff changeset
5817 /* With vertical, it's better to have all buttons the same length */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5818 if (vertical)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5819 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5820 macSizeDialogItem(theDialog, button, widestButton, 0);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5821 GetDialogItem(theDialog, button, &itemType, &itemHandle, &box);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5822 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5823 /* Calculate position of next button */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5824 if (vertical)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5825 buttonItm.box.top = box.bottom + dfltElementSpacing;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5826 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5827 buttonItm.box.left = box.right + dfltElementSpacing;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5828 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5829
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5830 /* Resize the dialog box */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5831 dialogHeight = box.bottom + dfltElementSpacing;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5832 SizeWindow(theWindow, maximumWidth, dialogHeight, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5833
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5834 /* Magic resize */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5835 AutoSizeDialog(theDialog);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5836 /* Need a horizontal resize anyway so not that useful */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5837
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5838 /* Display it */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5839 ShowWindow(theWindow);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5840 /* BringToFront(theWindow); */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5841 SelectWindow(theWindow);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5842
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5843 /* DrawDialog(theDialog); */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5844 #if 0
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5845 GetPort(&oldPort);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5846 SetPortDialogPort(theDialog);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5847 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5848
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
5849 #ifdef USE_CARBONKEYHANDLER
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
5850 /* Avoid that we use key events for the main window. */
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
5851 dialog_busy = TRUE;
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
5852 #endif
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
5853
1572
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5854 /* Prepare the shortcut-handling filterProc for handing to the dialog */
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5855 dialogUPP = NewModalFilterUPP(DialogHotkeyFilterProc);
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5856
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5857 /* Hang until one of the button is hit */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5858 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5859 {
1572
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5860 ModalDialog(dialogUPP, &itemHit);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5861 } while ((itemHit < 1) || (itemHit > lastButton));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5862
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
5863 #ifdef USE_CARBONKEYHANDLER
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
5864 dialog_busy = FALSE;
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
5865 #endif
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
5866
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5867 /* Copy back the text entered by the user into the param */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5868 if (textfield != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5869 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5870 GetDialogItem(theDialog, inputItm.idx, &itemType, &itemHandle, &box);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5871 GetDialogItemText(itemHandle, (char_u *) &name);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5872 #if IOSIZE < 256
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5873 /* Truncate the name to IOSIZE if needed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5874 if (name[0] > IOSIZE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5875 name[0] = IOSIZE - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5876 #endif
418
84825cc6f049 updated for version 7.0109
vimboss
parents: 308
diff changeset
5877 vim_strncpy(textfield, &name[1], name[0]);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5878 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5879
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5880 /* Restore the original graphical port */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5881 SetPort(oldPort);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5882
1572
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5883 /* Free the modal filterProc */
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5884 DisposeRoutineDescriptor(dialogUPP);
a9e353f7fcc4 updated for version 7.1-285
vimboss
parents: 1565
diff changeset
5885
4352
04736b4030ec updated for version 7.3.925
Bram Moolenaar <bram@vim.org>
parents: 3935
diff changeset
5886 /* Get ride of the dialog (free memory) */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5887 DisposeDialog(theDialog);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5888
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5889 return itemHit;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5890 /*
2585
03d49a7c8319 updated for version 7.3.010
Bram Moolenaar <bram@vim.org>
parents: 2565
diff changeset
5891 * Useful thing which could be used
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5892 * SetDialogTimeout(): Auto click a button after timeout
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5893 * SetDialogTracksCursor() : Get the I-beam cursor over input box
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5894 * MoveDialogItem(): Probably better than SetDialogItem
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5895 * SizeDialogItem(): (but is it Carbon Only?)
1373
88c68e59d39c updated for version 7.1-088
vimboss
parents: 1292
diff changeset
5896 * AutoSizeDialog(): Magic resize of dialog based on text length
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5897 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5898 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5899 #endif /* FEAT_DIALOG_GUI */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5900
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5901 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5902 * Display the saved error message(s).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5903 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5904 #ifdef USE_MCH_ERRMSG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5905 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5906 display_errors(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5907 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5908 char *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5909 char_u pError[256];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5910
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5911 if (error_ga.ga_data == NULL)
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5912 return;
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5913
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5914 /* avoid putting up a message box with blanks only */
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5915 for (p = (char *)error_ga.ga_data; *p; ++p)
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5916 if (!isspace(*p))
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5917 {
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5918 if (STRLEN(p) > 255)
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5919 pError[0] = 255;
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5920 else
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5921 pError[0] = STRLEN(p);
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5922
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5923 STRNCPY(&pError[1], p, pError[0]);
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5924 ParamText(pError, nil, nil, nil);
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5925 Alert(128, nil);
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5926 break;
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5927 /* TODO: handled message longer than 256 chars
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5928 * use auto-sizeable alert
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5929 * or dialog with scrollbars (TextEdit zone)
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5930 */
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5931 }
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5932 ga_clear(&error_ga);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5933 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5934 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5935
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5936 /*
87
014ba200db86 updated for version 7.0035
vimboss
parents: 44
diff changeset
5937 * Get current mouse coordinates in text window.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5938 */
95
a2081e6febb8 updated for version 7.0037
vimboss
parents: 87
diff changeset
5939 void
a2081e6febb8 updated for version 7.0037
vimboss
parents: 87
diff changeset
5940 gui_mch_getmouse(int *x, int *y)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5941 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5942 Point where;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5943
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5944 GetMouse(&where);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5945
87
014ba200db86 updated for version 7.0035
vimboss
parents: 44
diff changeset
5946 *x = where.h;
014ba200db86 updated for version 7.0035
vimboss
parents: 44
diff changeset
5947 *y = where.v;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5948 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5949
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5950 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5951 gui_mch_setmouse(int x, int y)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5952 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5953 /* TODO */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5954 #if 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5955 /* From FAQ 3-11 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5956
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5957 CursorDevicePtr myMouse;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5958 Point where;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5959
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5960 if ( NGetTrapAddress(_CursorDeviceDispatch, ToolTrap)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5961 != NGetTrapAddress(_Unimplemented, ToolTrap))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5962 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5963 /* New way */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5964
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5965 /*
4352
04736b4030ec updated for version 7.3.925
Bram Moolenaar <bram@vim.org>
parents: 3935
diff changeset
5966 * Get first device with one button.
04736b4030ec updated for version 7.3.925
Bram Moolenaar <bram@vim.org>
parents: 3935
diff changeset
5967 * This will probably be the standard mouse
04736b4030ec updated for version 7.3.925
Bram Moolenaar <bram@vim.org>
parents: 3935
diff changeset
5968 * start at head of cursor dev list
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5969 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5970 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5971
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5972 myMouse = nil;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5973
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5974 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5975 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5976 /* Get the next cursor device */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5977 CursorDeviceNextDevice(&myMouse);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5978 }
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5979 while ((myMouse != nil) && (myMouse->cntButtons != 1));
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5980
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5981 CursorDeviceMoveTo(myMouse, x, y);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5982 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5983 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5984 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5985 /* Old way */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5986 where.h = x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5987 where.v = y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5988
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5989 *(Point *)RawMouse = where;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5990 *(Point *)MTemp = where;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5991 *(Ptr) CrsrNew = 0xFFFF;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5992 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5993 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5994 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5995
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5996 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
5997 gui_mch_show_popupmenu(vimmenu_T *menu)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5998 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5999 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6000 * Clone PopUp to use menu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6001 * Create a object descriptor for the current selection
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6002 * Call the procedure
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6003 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6004
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6005 MenuHandle CntxMenu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6006 Point where;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6007 OSStatus status;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6008 UInt32 CntxType;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6009 SInt16 CntxMenuID;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6010 UInt16 CntxMenuItem;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6011 Str255 HelpName = "";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6012 GrafPtr savePort;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6013
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6014 /* Save Current Port: On MacOS X we seem to lose the port */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6015 GetPort(&savePort); /*OSX*/
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6016
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6017 GetMouse(&where);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6018 LocalToGlobal(&where); /*OSX*/
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6019 CntxMenu = menu->submenu_handle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6020
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6021 /* TODO: Get the text selection from Vim */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6022
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6023 /* Call to Handle Popup */
1089
965805580982 updated for version 7.0-215
vimboss
parents: 1012
diff changeset
6024 status = ContextualMenuSelect(CntxMenu, where, false, kCMHelpItemRemoveHelp,
1012
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
6025 HelpName, NULL, &CntxType, &CntxMenuID, &CntxMenuItem);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6026
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6027 if (status == noErr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6028 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6029 if (CntxType == kCMMenuItemSelected)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6030 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6031 /* Handle the menu CntxMenuID, CntxMenuItem */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6032 /* The submenu can be handle directly by gui_mac_handle_menu */
1012
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
6033 /* But what about the current menu, is the menu changed by
be8e2719caa6 updated for version 7.0-138
vimboss
parents: 939
diff changeset
6034 * ContextualMenuSelect */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6035 gui_mac_handle_menu((CntxMenuID << 16) + CntxMenuItem);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6036 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6037 else if (CntxMenuID == kCMShowHelpSelected)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6038 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6039 /* Should come up with the help */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6040 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6041 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6042
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6043 /* Restore original Port */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6044 SetPort(savePort); /*OSX*/
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6045 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6046
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6047 #if defined(FEAT_CW_EDITOR) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6048 /* TODO: Is it need for MACOS_X? (Dany) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6049 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6050 mch_post_buffer_write(buf_T *buf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6051 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6052 GetFSSpecFromPath(buf->b_ffname, &buf->b_FSSpec);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6053 Send_KAHL_MOD_AE(buf);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6054 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6055 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6056
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6057 #ifdef FEAT_TITLE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6058 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6059 * Set the window title and icon.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6060 * (The icon is not taken care of).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6061 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6062 void
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
6063 gui_mch_settitle(char_u *title, char_u *icon)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6064 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6065 /* TODO: Get vim to make sure maxlen (from p_titlelen) is smaller
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6066 * that 256. Even better get it to fit nicely in the titlebar.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6067 */
766
f0d0d3d3a1e2 updated for version 7.0225
vimboss
parents: 719
diff changeset
6068 #ifdef MACOS_CONVERT
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
6069 CFStringRef windowTitle;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
6070 size_t windowTitleLen;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
6071 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6072 char_u *pascalTitle;
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
6073 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6074
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6075 if (title == NULL) /* nothing to do */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6076 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6077
766
f0d0d3d3a1e2 updated for version 7.0225
vimboss
parents: 719
diff changeset
6078 #ifdef MACOS_CONVERT
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
6079 windowTitleLen = STRLEN(title);
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1572
diff changeset
6080 windowTitle = (CFStringRef)mac_enc_to_cfstring(title, windowTitleLen);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
6081
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
6082 if (windowTitle)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
6083 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
6084 SetWindowTitleWithCFString(gui.VimWindow, windowTitle);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
6085 CFRelease(windowTitle);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
6086 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
6087 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6088 pascalTitle = C2Pascal_save(title);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6089 if (pascalTitle != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6090 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6091 SetWTitle(gui.VimWindow, pascalTitle);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6092 vim_free(pascalTitle);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6093 }
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
6094 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6095 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6096 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6097
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6098 /*
2585
03d49a7c8319 updated for version 7.3.010
Bram Moolenaar <bram@vim.org>
parents: 2565
diff changeset
6099 * Transferred from os_mac.c for MacOS X using os_unix.c prep work
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6100 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6101
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6102 int
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
6103 C2PascalString(char_u *CString, Str255 *PascalString)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6104 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6105 char_u *PascalPtr = (char_u *) PascalString;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6106 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6107 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6108
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6109 PascalPtr[0] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6110 if (CString == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6111 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6112
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6113 len = STRLEN(CString);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6114 if (len > 255)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6115 len = 255;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6116
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6117 for (i = 0; i < len; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6118 PascalPtr[i+1] = CString[i];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6119
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6120 PascalPtr[0] = len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6121
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6122 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6123 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6124
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6125 int
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
6126 GetFSSpecFromPath(char_u *file, FSSpec *fileFSSpec)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6127 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6128 /* From FAQ 8-12 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6129 Str255 filePascal;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6130 CInfoPBRec myCPB;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6131 OSErr err;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6132
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6133 (void) C2PascalString(file, &filePascal);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6134
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6135 myCPB.dirInfo.ioNamePtr = filePascal;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6136 myCPB.dirInfo.ioVRefNum = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6137 myCPB.dirInfo.ioFDirIndex = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6138 myCPB.dirInfo.ioDrDirID = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6139
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6140 err= PBGetCatInfo(&myCPB, false);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6141
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6142 /* vRefNum, dirID, name */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6143 FSMakeFSSpec(0, 0, filePascal, fileFSSpec);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6144
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6145 /* TODO: Use an error code mechanism */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6146 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6147 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6148
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6149 /*
4352
04736b4030ec updated for version 7.3.925
Bram Moolenaar <bram@vim.org>
parents: 3935
diff changeset
6150 * Convert a FSSpec to a full path
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6151 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6152
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6153 char_u *FullPathFromFSSpec_save(FSSpec file)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6154 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6155 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6156 * TODO: Add protection for 256 char max.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6157 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6158
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6159 CInfoPBRec theCPB;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6160 char_u fname[256];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6161 char_u *filenamePtr = fname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6162 OSErr error;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6163 int folder = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6164 #ifdef USE_UNIXFILENAME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6165 SInt16 dfltVol_vRefNum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6166 SInt32 dfltVol_dirID;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6167 FSRef refFile;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6168 OSStatus status;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6169 UInt32 pathSize = 256;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6170 char_u pathname[256];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6171 char_u *path = pathname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6172 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6173 Str255 directoryName;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6174 char_u temporary[255];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6175 char_u *temporaryPtr = temporary;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6176 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6177
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6178 #ifdef USE_UNIXFILENAME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6179 /* Get the default volume */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6180 /* TODO: Remove as this only work if Vim is on the Boot Volume*/
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6181 error=HGetVol(NULL, &dfltVol_vRefNum, &dfltVol_dirID);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6182
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6183 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6184 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6185 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6186
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6187 /* Start filling fname with file.name */
418
84825cc6f049 updated for version 7.0109
vimboss
parents: 308
diff changeset
6188 vim_strncpy(filenamePtr, &file.name[1], file.name[0]);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6189
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6190 /* Get the info about the file specified in FSSpec */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6191 theCPB.dirInfo.ioFDirIndex = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6192 theCPB.dirInfo.ioNamePtr = file.name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6193 theCPB.dirInfo.ioVRefNum = file.vRefNum;
1106
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6194 /*theCPB.hFileInfo.ioDirID = 0;*/
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6195 theCPB.dirInfo.ioDrDirID = file.parID;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6196
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6197 /* As ioFDirIndex = 0, get the info of ioNamePtr,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6198 which is relative to ioVrefNum, ioDirID */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6199 error = PBGetCatInfo(&theCPB, false);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6200
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6201 /* If we are called for a new file we expect fnfErr */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6202 if ((error) && (error != fnfErr))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6203 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6204
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6205 /* Check if it's a file or folder */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6206 /* default to file if file don't exist */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6207 if (((theCPB.hFileInfo.ioFlAttrib & ioDirMask) == 0) || (error))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6208 folder = 0; /* It's not a folder */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6209 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6210 folder = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6211
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6212 #ifdef USE_UNIXFILENAME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6213 /*
4352
04736b4030ec updated for version 7.3.925
Bram Moolenaar <bram@vim.org>
parents: 3935
diff changeset
6214 * The functions used here are available in Carbon, but do nothing on
04736b4030ec updated for version 7.3.925
Bram Moolenaar <bram@vim.org>
parents: 3935
diff changeset
6215 * MacOS 8 and 9.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6216 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6217 if (error == fnfErr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6218 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6219 /* If the file to be saved does not already exist, it isn't possible
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6220 to convert its FSSpec into an FSRef. But we can construct an
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6221 FSSpec for the file's parent folder (since we have its volume and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6222 directory IDs), and since that folder does exist, we can convert
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6223 that FSSpec into an FSRef, convert the FSRef in turn into a path,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6224 and, finally, append the filename. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6225 FSSpec dirSpec;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6226 FSRef dirRef;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6227 Str255 emptyFilename = "\p";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6228 error = FSMakeFSSpec(theCPB.dirInfo.ioVRefNum,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6229 theCPB.dirInfo.ioDrDirID, emptyFilename, &dirSpec);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6230 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6231 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6232
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6233 error = FSpMakeFSRef(&dirSpec, &dirRef);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6234 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6235 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6236
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6237 status = FSRefMakePath(&dirRef, (UInt8*)path, pathSize);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6238 if (status)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6239 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6240
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6241 STRCAT(path, "/");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6242 STRCAT(path, filenamePtr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6243 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6244 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6245 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6246 /* If the file to be saved already exists, we can get its full path
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6247 by converting its FSSpec into an FSRef. */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6248 error=FSpMakeFSRef(&file, &refFile);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6249 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6250 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6251
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6252 status=FSRefMakePath(&refFile, (UInt8 *) path, pathSize);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6253 if (status)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6254 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6255 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6256
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6257 /* Add a slash at the end if needed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6258 if (folder)
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6259 STRCAT(path, "/");
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6260
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6261 return (vim_strsave(path));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6262 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6263 /* TODO: Get rid of all USE_UNIXFILENAME below */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6264 /* Set ioNamePtr, it's the same area which is always reused. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6265 theCPB.dirInfo.ioNamePtr = directoryName;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6266
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6267 /* Trick for first entry, set ioDrParID to the first value
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6268 * we want for ioDrDirID*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6269 theCPB.dirInfo.ioDrParID = file.parID;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6270 theCPB.dirInfo.ioDrDirID = file.parID;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6271
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6272 if ((TRUE) && (file.parID != fsRtDirID /*fsRtParID*/))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6273 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6274 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6275 theCPB.dirInfo.ioFDirIndex = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6276 /* theCPB.dirInfo.ioNamePtr = directoryName; Already done above. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6277 theCPB.dirInfo.ioVRefNum = file.vRefNum;
1212
e085b0f7b036 updated for version 7.1b
vimboss
parents: 1107
diff changeset
6278 /* theCPB.dirInfo.ioDirID = irrelevant when ioFDirIndex = -1 */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6279 theCPB.dirInfo.ioDrDirID = theCPB.dirInfo.ioDrParID;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6280
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6281 /* As ioFDirIndex = -1, get the info of ioDrDirID, */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6282 /* *ioNamePtr[0 TO 31] will be updated */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6283 error = PBGetCatInfo(&theCPB,false);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6284
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6285 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6286 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6287
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6288 /* Put the new directoryName in front of the current fname */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6289 STRCPY(temporaryPtr, filenamePtr);
418
84825cc6f049 updated for version 7.0109
vimboss
parents: 308
diff changeset
6290 vim_strncpy(filenamePtr, &directoryName[1], directoryName[0]);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6291 STRCAT(filenamePtr, ":");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6292 STRCAT(filenamePtr, temporaryPtr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6293 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6294 #if 1 /* def USE_UNIXFILENAME */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6295 while ((theCPB.dirInfo.ioDrParID != fsRtDirID) /* && */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6296 /* (theCPB.dirInfo.ioDrDirID != fsRtDirID)*/);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6297 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6298 while (theCPB.dirInfo.ioDrDirID != fsRtDirID);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6299 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6300
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6301 /* Get the information about the volume on which the file reside */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6302 theCPB.dirInfo.ioFDirIndex = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6303 /* theCPB.dirInfo.ioNamePtr = directoryName; Already done above. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6304 theCPB.dirInfo.ioVRefNum = file.vRefNum;
1212
e085b0f7b036 updated for version 7.1b
vimboss
parents: 1107
diff changeset
6305 /* theCPB.dirInfo.ioDirID = irrelevant when ioFDirIndex = -1 */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6306 theCPB.dirInfo.ioDrDirID = theCPB.dirInfo.ioDrParID;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6307
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6308 /* As ioFDirIndex = -1, get the info of ioDrDirID, */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6309 /* *ioNamePtr[0 TO 31] will be updated */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6310 error = PBGetCatInfo(&theCPB,false);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6311
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6312 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6313 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6314
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6315 /* For MacOS Classic always add the volume name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6316 /* For MacOS X add the volume name preceded by "Volumes" */
1212
e085b0f7b036 updated for version 7.1b
vimboss
parents: 1107
diff changeset
6317 /* when we are not referring to the boot volume */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6318 #ifdef USE_UNIXFILENAME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6319 if (file.vRefNum != dfltVol_vRefNum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6320 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6321 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6322 /* Add the volume name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6323 STRCPY(temporaryPtr, filenamePtr);
418
84825cc6f049 updated for version 7.0109
vimboss
parents: 308
diff changeset
6324 vim_strncpy(filenamePtr, &directoryName[1], directoryName[0]);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6325 STRCAT(filenamePtr, ":");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6326 STRCAT(filenamePtr, temporaryPtr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6327
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6328 #ifdef USE_UNIXFILENAME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6329 STRCPY(temporaryPtr, filenamePtr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6330 filenamePtr[0] = 0; /* NULL terminate the string */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6331 STRCAT(filenamePtr, "Volumes:");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6332 STRCAT(filenamePtr, temporaryPtr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6333 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6334 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6335
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6336 /* Append final path separator if it's a folder */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6337 if (folder)
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6338 STRCAT(fname, ":");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6339
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6340 /* As we use Unix File Name for MacOS X convert it */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6341 #ifdef USE_UNIXFILENAME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6342 /* Need to insert leading / */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6343 /* TODO: get the above code to use directly the / */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6344 STRCPY(&temporaryPtr[1], filenamePtr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6345 temporaryPtr[0] = '/';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6346 STRCPY(filenamePtr, temporaryPtr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6347 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6348 char *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6349 for (p = fname; *p; p++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6350 if (*p == ':')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6351 *p = '/';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6352 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6353 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6354
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6355 return (vim_strsave(fname));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6356 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6357 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6358
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6359 #if (defined(USE_IM_CONTROL) || defined(PROTO)) && defined(USE_CARBONKEYHANDLER)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6360 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6361 * Input Method Control functions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6362 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6363
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6364 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6365 * Notify cursor position to IM.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6366 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6367 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6368 im_set_position(int row, int col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6369 {
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6370 #if 0
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6371 /* TODO: Implement me! */
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6372 im_start_row = row;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6373 im_start_col = col;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6374 #endif
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6375 }
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6376
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6377 static ScriptLanguageRecord gTSLWindow;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6378 static ScriptLanguageRecord gTSLInsert;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6379 static ScriptLanguageRecord gTSLDefault = { 0, 0 };
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6380
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6381 static Component gTSCWindow;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6382 static Component gTSCInsert;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6383 static Component gTSCDefault;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6384
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6385 static int im_initialized = 0;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6386
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6387 static void
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6388 im_on_window_switch(int active)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6389 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6390 ScriptLanguageRecord *slptr = NULL;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6391 OSStatus err;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6392
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6393 if (! gui.in_use)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6394 return;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6395
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6396 if (im_initialized == 0)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6397 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6398 im_initialized = 1;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6399
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6400 /* save default TSM component (should be U.S.) to default */
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6401 GetDefaultInputMethodOfClass(&gTSCDefault, &gTSLDefault,
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6402 kKeyboardInputMethodClass);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6403 }
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6404
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6405 if (active == TRUE)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6406 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6407 im_is_active = TRUE;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6408 ActivateTSMDocument(gTSMDocument);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6409 slptr = &gTSLWindow;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6410
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6411 if (slptr)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6412 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6413 err = SetDefaultInputMethodOfClass(gTSCWindow, slptr,
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6414 kKeyboardInputMethodClass);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6415 if (err == noErr)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6416 err = SetTextServiceLanguage(slptr);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6417
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6418 if (err == noErr)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6419 KeyScript(slptr->fScript | smKeyForceKeyScriptMask);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6420 }
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6421 }
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6422 else
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6423 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6424 err = GetTextServiceLanguage(&gTSLWindow);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6425 if (err == noErr)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6426 slptr = &gTSLWindow;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6427
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6428 if (slptr)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6429 GetDefaultInputMethodOfClass(&gTSCWindow, slptr,
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6430 kKeyboardInputMethodClass);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6431
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6432 im_is_active = FALSE;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6433 DeactivateTSMDocument(gTSMDocument);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6434 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6435 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6436
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6437 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6438 * Set IM status on ("active" is TRUE) or off ("active" is FALSE).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6439 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6440 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6441 im_set_active(int active)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6442 {
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6443 ScriptLanguageRecord *slptr = NULL;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6444 OSStatus err;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6445
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6446 if (! gui.in_use)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6447 return;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6448
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6449 if (im_initialized == 0)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6450 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6451 im_initialized = 1;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6452
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6453 /* save default TSM component (should be U.S.) to default */
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6454 GetDefaultInputMethodOfClass(&gTSCDefault, &gTSLDefault,
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6455 kKeyboardInputMethodClass);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6456 }
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6457
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6458 if (active == TRUE)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6459 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6460 im_is_active = TRUE;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6461 ActivateTSMDocument(gTSMDocument);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6462 slptr = &gTSLInsert;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6463
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6464 if (slptr)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6465 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6466 err = SetDefaultInputMethodOfClass(gTSCInsert, slptr,
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6467 kKeyboardInputMethodClass);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6468 if (err == noErr)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6469 err = SetTextServiceLanguage(slptr);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6470
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6471 if (err == noErr)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6472 KeyScript(slptr->fScript | smKeyForceKeyScriptMask);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6473 }
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6474 }
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6475 else
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6476 {
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6477 err = GetTextServiceLanguage(&gTSLInsert);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6478 if (err == noErr)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6479 slptr = &gTSLInsert;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6480
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6481 if (slptr)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6482 GetDefaultInputMethodOfClass(&gTSCInsert, slptr,
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6483 kKeyboardInputMethodClass);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6484
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6485 /* restore to default when switch to normal mode, so than we could
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6486 * enter commands easier */
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6487 SetDefaultInputMethodOfClass(gTSCDefault, &gTSLDefault,
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6488 kKeyboardInputMethodClass);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6489 SetTextServiceLanguage(&gTSLDefault);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6490
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6491 im_is_active = FALSE;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6492 DeactivateTSMDocument(gTSMDocument);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6493 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6494 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6495
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6496 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6497 * Get IM status. When IM is on, return not 0. Else return 0.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6498 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6499 int
593
d220eb88e4e4 updated for version 7.0168
vimboss
parents: 563
diff changeset
6500 im_get_status(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6501 {
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6502 if (! gui.in_use)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6503 return 0;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6504
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6505 return im_is_active;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6506 }
1106
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6507
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6508 #endif /* defined(USE_IM_CONTROL) || defined(PROTO) */
1106
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6509
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6510
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6511
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6512
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6513 #if defined(FEAT_GUI_TABLINE) || defined(PROTO)
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6514 // drawer implementation
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6515 static MenuRef contextMenu = NULL;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6516 enum
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6517 {
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6518 kTabContextMenuId = 42,
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6519 };
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6520
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6521 // the caller has to CFRelease() the returned string
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6522 static CFStringRef
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6523 getTabLabel(tabpage_T *page)
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6524 {
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6525 get_tabline_label(page, FALSE);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6526 #ifdef MACOS_CONVERT
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1572
diff changeset
6527 return (CFStringRef)mac_enc_to_cfstring(NameBuff, STRLEN(NameBuff));
1106
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6528 #else
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6529 // TODO: check internal encoding?
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6530 return CFStringCreateWithCString(kCFAllocatorDefault, (char *)NameBuff,
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6531 kCFStringEncodingMacRoman);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6532 #endif
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6533 }
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6534
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6535
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6536 #define DRAWER_SIZE 150
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6537 #define DRAWER_INSET 16
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6538
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6539 static ControlRef dataBrowser = NULL;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6540
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6541 // when the tabline is hidden, vim doesn't call update_tabline(). When
2585
03d49a7c8319 updated for version 7.3.010
Bram Moolenaar <bram@vim.org>
parents: 2565
diff changeset
6542 // the tabline is shown again, show_tabline() is called before update_tabline(),
4352
04736b4030ec updated for version 7.3.925
Bram Moolenaar <bram@vim.org>
parents: 3935
diff changeset
6543 // and because of this, the tab labels and vim's internal tabs are out of sync
1106
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6544 // for a very short time. to prevent inconsistent state, we store the labels
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6545 // of the tabs, not pointers to the tabs (which are invalid for a short time).
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6546 static CFStringRef *tabLabels = NULL;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6547 static int tabLabelsSize = 0;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6548
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6549 enum
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6550 {
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6551 kTabsColumn = 'Tabs'
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6552 };
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6553
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6554 static int
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6555 getTabCount(void)
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6556 {
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6557 tabpage_T *tp;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6558 int numTabs = 0;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6559
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6560 for (tp = first_tabpage; tp != NULL; tp = tp->tp_next)
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6561 ++numTabs;
1106
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6562 return numTabs;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6563 }
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6564
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6565 // data browser item display callback
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6566 static OSStatus
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6567 dbItemDataCallback(ControlRef browser,
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6568 DataBrowserItemID itemID,
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6569 DataBrowserPropertyID property /* column id */,
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6570 DataBrowserItemDataRef itemData,
1106
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6571 Boolean changeValue)
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6572 {
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6573 OSStatus status = noErr;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6574
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6575 // assert(property == kTabsColumn); // why is this violated??
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6576
4352
04736b4030ec updated for version 7.3.925
Bram Moolenaar <bram@vim.org>
parents: 3935
diff changeset
6577 // changeValue is true if we have a modifiable list and data was changed.
1106
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6578 // In our case, it's always false.
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6579 // (that is: if (changeValue) updateInternalData(); else return
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6580 // internalData();
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6581 if (!changeValue)
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6582 {
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6583 CFStringRef str;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6584
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6585 assert(itemID - 1 >= 0 && itemID - 1 < tabLabelsSize);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6586 str = tabLabels[itemID - 1];
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6587 status = SetDataBrowserItemDataText(itemData, str);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6588 }
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6589 else
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6590 status = errDataBrowserPropertyNotSupported;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6591
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6592 return status;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6593 }
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6594
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6595 // data browser action callback
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6596 static void
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6597 dbItemNotificationCallback(ControlRef browser,
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6598 DataBrowserItemID item,
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6599 DataBrowserItemNotification message)
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6600 {
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6601 switch (message)
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6602 {
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6603 case kDataBrowserItemSelected:
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6604 send_tabline_event(item);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6605 break;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6606 }
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6607 }
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6608
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6609 // callbacks needed for contextual menu:
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6610 static void
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6611 dbGetContextualMenuCallback(ControlRef browser,
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6612 MenuRef *menu,
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6613 UInt32 *helpType,
1106
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6614 CFStringRef *helpItemString,
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6615 AEDesc *selection)
1106
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6616 {
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6617 // on mac os 9: kCMHelpItemNoHelp, but it's not the same
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6618 *helpType = kCMHelpItemRemoveHelp; // OS X only ;-)
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6619 *helpItemString = NULL;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6620
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6621 *menu = contextMenu;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6622 }
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6623
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6624 static void
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6625 dbSelectContextualMenuCallback(ControlRef browser,
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6626 MenuRef menu,
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6627 UInt32 selectionType,
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6628 SInt16 menuID,
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6629 MenuItemIndex menuItem)
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6630 {
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6631 if (selectionType == kCMMenuItemSelected)
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6632 {
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6633 MenuCommand command;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6634 GetMenuItemCommandID(menu, menuItem, &command);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6635
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6636 // get tab that was selected when the context menu appeared
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6637 // (there is always one tab selected). TODO: check if the context menu
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6638 // isn't opened on an item but on empty space (has to be possible some
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6639 // way, the finder does it too ;-) )
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6640 Handle items = NewHandle(0);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6641 if (items != NULL)
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6642 {
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6643 int numItems;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6644
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6645 GetDataBrowserItems(browser, kDataBrowserNoItem, false,
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6646 kDataBrowserItemIsSelected, items);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6647 numItems = GetHandleSize(items) / sizeof(DataBrowserItemID);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6648 if (numItems > 0)
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6649 {
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6650 int idx;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6651 DataBrowserItemID *itemsPtr;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6652
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6653 HLock(items);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6654 itemsPtr = (DataBrowserItemID *)*items;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6655 idx = itemsPtr[0];
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6656 HUnlock(items);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6657 send_tabline_menu_event(idx, command);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6658 }
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6659 DisposeHandle(items);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6660 }
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6661 }
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6662 }
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6663
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6664 // focus callback of the data browser to always leave focus in vim
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6665 static OSStatus
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6666 dbFocusCallback(EventHandlerCallRef handler, EventRef event, void *data)
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6667 {
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6668 assert(GetEventClass(event) == kEventClassControl
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6669 && GetEventKind(event) == kEventControlSetFocusPart);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6670
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6671 return paramErr;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6672 }
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6673
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6674
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6675 // drawer callback to resize data browser to drawer size
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6676 static OSStatus
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6677 drawerCallback(EventHandlerCallRef handler, EventRef event, void *data)
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6678 {
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6679 switch (GetEventKind(event))
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6680 {
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6681 case kEventWindowBoundsChanged: // move or resize
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6682 {
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6683 UInt32 attribs;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6684 GetEventParameter(event, kEventParamAttributes, typeUInt32,
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6685 NULL, sizeof(attribs), NULL, &attribs);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6686 if (attribs & kWindowBoundsChangeSizeChanged) // resize
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6687 {
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6688 Rect r;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6689 GetWindowBounds(drawer, kWindowContentRgn, &r);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6690 SetRect(&r, 0, 0, r.right - r.left, r.bottom - r.top);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6691 SetControlBounds(dataBrowser, &r);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6692 SetDataBrowserTableViewNamedColumnWidth(dataBrowser,
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6693 kTabsColumn, r.right);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6694 }
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6695 }
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6696 break;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6697 }
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6698
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6699 return eventNotHandledErr;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6700 }
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6701
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6702 // Load DataBrowserChangeAttributes() dynamically on tiger (and better).
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6703 // This way the code works on 10.2 and 10.3 as well (it doesn't have the
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6704 // blue highlights in the list view on these systems, though. Oh well.)
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6705
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6706
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6707 #import <mach-o/dyld.h>
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6708
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6709 enum { kMyDataBrowserAttributeListViewAlternatingRowColors = (1 << 1) };
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6710
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6711 static OSStatus
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6712 myDataBrowserChangeAttributes(ControlRef inDataBrowser,
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6713 OptionBits inAttributesToSet,
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6714 OptionBits inAttributesToClear)
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6715 {
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6716 long osVersion;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6717 char *symbolName;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6718 NSSymbol symbol = NULL;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6719 OSStatus (*dataBrowserChangeAttributes)(ControlRef inDataBrowser,
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6720 OptionBits inAttributesToSet, OptionBits inAttributesToClear);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6721
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6722 Gestalt(gestaltSystemVersion, &osVersion);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6723 if (osVersion < 0x1040) // only supported for 10.4 (and up)
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6724 return noErr;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6725
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6726 // C name mangling...
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6727 symbolName = "_DataBrowserChangeAttributes";
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6728 if (!NSIsSymbolNameDefined(symbolName)
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6729 || (symbol = NSLookupAndBindSymbol(symbolName)) == NULL)
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6730 return noErr;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6731
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6732 dataBrowserChangeAttributes = NSAddressOfSymbol(symbol);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6733 if (dataBrowserChangeAttributes == NULL)
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6734 return noErr; // well...
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6735 return dataBrowserChangeAttributes(inDataBrowser,
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6736 inAttributesToSet, inAttributesToClear);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6737 }
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6738
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6739 static void
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6740 initialise_tabline(void)
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6741 {
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6742 Rect drawerRect = { 0, 0, 0, DRAWER_SIZE };
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6743 DataBrowserCallbacks dbCallbacks;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6744 EventTypeSpec focusEvent = {kEventClassControl, kEventControlSetFocusPart};
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6745 EventTypeSpec resizeEvent = {kEventClassWindow, kEventWindowBoundsChanged};
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6746 DataBrowserListViewColumnDesc colDesc;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6747
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6748 // drawers have to have compositing enabled
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6749 CreateNewWindow(kDrawerWindowClass,
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6750 kWindowStandardHandlerAttribute
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6751 | kWindowCompositingAttribute
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6752 | kWindowResizableAttribute
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6753 | kWindowLiveResizeAttribute,
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6754 &drawerRect, &drawer);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6755
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6756 SetThemeWindowBackground(drawer, kThemeBrushDrawerBackground, true);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6757 SetDrawerParent(drawer, gui.VimWindow);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6758 SetDrawerOffsets(drawer, kWindowOffsetUnchanged, DRAWER_INSET);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6759
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6760
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6761 // create list view embedded in drawer
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6762 CreateDataBrowserControl(drawer, &drawerRect, kDataBrowserListView,
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6763 &dataBrowser);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6764
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6765 dbCallbacks.version = kDataBrowserLatestCallbacks;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6766 InitDataBrowserCallbacks(&dbCallbacks);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6767 dbCallbacks.u.v1.itemDataCallback =
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6768 NewDataBrowserItemDataUPP(dbItemDataCallback);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6769 dbCallbacks.u.v1.itemNotificationCallback =
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6770 NewDataBrowserItemNotificationUPP(dbItemNotificationCallback);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6771 dbCallbacks.u.v1.getContextualMenuCallback =
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6772 NewDataBrowserGetContextualMenuUPP(dbGetContextualMenuCallback);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6773 dbCallbacks.u.v1.selectContextualMenuCallback =
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6774 NewDataBrowserSelectContextualMenuUPP(dbSelectContextualMenuCallback);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6775
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6776 SetDataBrowserCallbacks(dataBrowser, &dbCallbacks);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6777
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6778 SetDataBrowserListViewHeaderBtnHeight(dataBrowser, 0); // no header
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6779 SetDataBrowserHasScrollBars(dataBrowser, false, true); // only vertical
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6780 SetDataBrowserSelectionFlags(dataBrowser,
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6781 kDataBrowserSelectOnlyOne | kDataBrowserNeverEmptySelectionSet);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6782 SetDataBrowserTableViewHiliteStyle(dataBrowser,
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6783 kDataBrowserTableViewFillHilite);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6784 Boolean b = false;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6785 SetControlData(dataBrowser, kControlEntireControl,
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6786 kControlDataBrowserIncludesFrameAndFocusTag, sizeof(b), &b);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6787
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6788 // enable blue background in data browser (this is only in 10.4 and vim
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6789 // has to support older osx versions as well, so we have to load this
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6790 // function dynamically)
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6791 myDataBrowserChangeAttributes(dataBrowser,
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6792 kMyDataBrowserAttributeListViewAlternatingRowColors, 0);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6793
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6794 // install callback that keeps focus in vim and away from the data browser
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6795 InstallControlEventHandler(dataBrowser, dbFocusCallback, 1, &focusEvent,
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6796 NULL, NULL);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6797
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6798 // install callback that keeps data browser at the size of the drawer
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6799 InstallWindowEventHandler(drawer, drawerCallback, 1, &resizeEvent,
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6800 NULL, NULL);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6801
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6802 // add "tabs" column to data browser
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6803 colDesc.propertyDesc.propertyID = kTabsColumn;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6804 colDesc.propertyDesc.propertyType = kDataBrowserTextType;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6805
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6806 // add if items can be selected (?): kDataBrowserListViewSelectionColumn
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6807 colDesc.propertyDesc.propertyFlags = kDataBrowserDefaultPropertyFlags;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6808
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6809 colDesc.headerBtnDesc.version = kDataBrowserListViewLatestHeaderDesc;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6810 colDesc.headerBtnDesc.minimumWidth = 100;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6811 colDesc.headerBtnDesc.maximumWidth = 150;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6812 colDesc.headerBtnDesc.titleOffset = 0;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6813 colDesc.headerBtnDesc.titleString = CFSTR("Tabs");
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6814 colDesc.headerBtnDesc.initialOrder = kDataBrowserOrderIncreasing;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6815 colDesc.headerBtnDesc.btnFontStyle.flags = 0; // use default font
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6816 colDesc.headerBtnDesc.btnContentInfo.contentType = kControlContentTextOnly;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6817
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6818 AddDataBrowserListViewColumn(dataBrowser, &colDesc, 0);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6819
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6820 // create tabline popup menu required by vim docs (see :he tabline-menu)
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6821 CreateNewMenu(kTabContextMenuId, 0, &contextMenu);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6822 AppendMenuItemTextWithCFString(contextMenu, CFSTR("Close"), 0,
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6823 TABLINE_MENU_CLOSE, NULL);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6824 AppendMenuItemTextWithCFString(contextMenu, CFSTR("New Tab"), 0,
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6825 TABLINE_MENU_NEW, NULL);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6826 AppendMenuItemTextWithCFString(contextMenu, CFSTR("Open Tab..."), 0,
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6827 TABLINE_MENU_OPEN, NULL);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6828 }
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6829
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6830
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6831 /*
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6832 * Show or hide the tabline.
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6833 */
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6834 void
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6835 gui_mch_show_tabline(int showit)
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6836 {
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6837 if (showit == 0)
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6838 CloseDrawer(drawer, true);
1106
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6839 else
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6840 OpenDrawer(drawer, kWindowEdgeRight, true);
1106
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6841 }
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6842
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6843 /*
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6844 * Return TRUE when tabline is displayed.
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6845 */
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6846 int
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6847 gui_mch_showing_tabline(void)
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6848 {
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6849 WindowDrawerState state = GetDrawerState(drawer);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6850
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6851 return state == kWindowDrawerOpen || state == kWindowDrawerOpening;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6852 }
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6853
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6854 /*
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6855 * Update the labels of the tabline.
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6856 */
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6857 void
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6858 gui_mch_update_tabline(void)
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6859 {
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6860 tabpage_T *tp;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6861 int numTabs = getTabCount();
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6862 int nr = 1;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6863 int curtabidx = 1;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6864
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6865 // adjust data browser
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6866 if (tabLabels != NULL)
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6867 {
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6868 int i;
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6869
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6870 for (i = 0; i < tabLabelsSize; ++i)
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6871 CFRelease(tabLabels[i]);
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6872 free(tabLabels);
1106
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6873 }
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6874 tabLabels = (CFStringRef *)malloc(numTabs * sizeof(CFStringRef));
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6875 tabLabelsSize = numTabs;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6876
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6877 for (tp = first_tabpage; tp != NULL; tp = tp->tp_next, ++nr)
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6878 {
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6879 if (tp == curtab)
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6880 curtabidx = nr;
1562
437fb19625c9 updated for version 7.1-275
vimboss
parents: 1409
diff changeset
6881 tabLabels[nr-1] = getTabLabel(tp);
1106
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6882 }
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6883
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6884 RemoveDataBrowserItems(dataBrowser, kDataBrowserNoItem, 0, NULL,
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6885 kDataBrowserItemNoProperty);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6886 // data browser uses ids 1, 2, 3, ... numTabs per default, so we
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6887 // can pass NULL for the id array
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6888 AddDataBrowserItems(dataBrowser, kDataBrowserNoItem, numTabs, NULL,
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6889 kDataBrowserItemNoProperty);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6890
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6891 DataBrowserItemID item = curtabidx;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6892 SetDataBrowserSelectedItems(dataBrowser, 1, &item, kDataBrowserItemsAssign);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6893 }
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6894
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6895 /*
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6896 * Set the current tab to "nr". First tab is 1.
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6897 */
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6898 void
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6899 gui_mch_set_curtab(nr)
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6900 int nr;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6901 {
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6902 DataBrowserItemID item = nr;
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6903 SetDataBrowserSelectedItems(dataBrowser, 1, &item, kDataBrowserItemsAssign);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6904
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6905 // TODO: call something like this?: (or restore scroll position, or...)
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6906 RevealDataBrowserItem(dataBrowser, item, kTabsColumn,
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6907 kDataBrowserRevealOnly);
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6908 }
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6909
6c4da3e24371 updated for version 7.0-232
vimboss
parents: 1089
diff changeset
6910 #endif // FEAT_GUI_TABLINE