Mercurial > vim
annotate src/gui_haiku.cc @ 31825:0d27ddce621d v9.0.1245
patch 9.0.1245: code is indented more than necessary
Commit: https://github.com/vim/vim/commit/032713f8299abd92fcfb1e490d1ae5c1ecadde41
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Wed Jan 25 21:05:38 2023 +0000
patch 9.0.1245: code is indented more than necessary
Problem: Code is indented more than necessary.
Solution: Use an early return where it makes sense. (Yegappan Lakshmanan,
closes #11879)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 25 Jan 2023 22:15:03 +0100 |
parents | 89e1d67814a9 |
children | 533e36e02a68 |
rev | line source |
---|---|
19526 | 1 /* vi:set ts=8 sts=4 sw=4: |
2 * | |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * BeBox GUI support Copyright 1998 by Olaf Seibert. | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5 * All Rights Reserved. |
19526 | 6 * |
7 * Do ":help uganda" in Vim to read copying and usage conditions. | |
8 * Do ":help credits" in Vim to see a list of people who contributed. | |
9 * | |
10 * Based on "GUI support for the Buzzword Enhanced Operating System." | |
11 * | |
12 * Ported to R4 by Richard Offer <richard@whitequeen.com> Jul 99 | |
13 * | |
14 * Haiku support by Siarzhuk Zharski <imker@gmx.li> Apr-Mai 2009 | |
15 * | |
16 */ | |
17 | |
18 /* | |
19 * Structure of the Haiku GUI code: | |
20 * | |
21 * There are 3 threads. | |
22 * 1. The initial thread. In gui_mch_prepare() this gets to run the | |
23 * BApplication message loop. But before it starts doing that, | |
24 * it creates thread 2 | |
25 * 2. The main() thread. This thread is created in gui_mch_prepare() | |
26 * and its purpose in life is to call main(argc, argv) again. | |
27 * This thread is doing the bulk of the work. | |
28 * 3. Sooner or later, a window is opened by the main() thread. This | |
29 * causes a second message loop to be created: the window thread. | |
30 * | |
31 * == alternatively === | |
32 * | |
33 * #if RUN_BAPPLICATION_IN_NEW_THREAD... | |
34 * | |
35 * 1. The initial thread. In gui_mch_prepare() this gets to spawn | |
36 * thread 2. After doing that, it returns to main() to do the | |
37 * bulk of the work, being the main() thread. | |
38 * 2. Runs the BApplication. | |
39 * 3. The window thread, just like in the first case. | |
40 * | |
41 * This second alternative is cleaner from Vim's viewpoint. However, | |
42 * the BeBook seems to assume everywhere that the BApplication *must* | |
43 * run in the initial thread. So perhaps doing otherwise is very wrong. | |
44 * | |
45 * However, from a B_SINGLE_LAUNCH viewpoint, the first is better. | |
46 * If Vim is marked "Single Launch" in its application resources, | |
47 * and a file is dropped on the Vim icon, and another Vim is already | |
48 * running, the file is passed on to the earlier Vim. This happens | |
49 * in BApplication::Run(). So we want Vim to terminate if | |
50 * BApplication::Run() terminates. (See the BeBook, on BApplication. | |
51 * However, it seems that the second copy of Vim isn't even started | |
52 * in this case... which is for the better since I wouldn't know how | |
53 * to detect this case.) | |
54 * | |
55 * Communication between these threads occurs mostly by translating | |
56 * BMessages that come in and posting an appropriate translation on | |
57 * the VDCMP (Vim Direct Communication Message Port). Therefore the | |
58 * actions required for keypresses and window resizes, etc, are mostly | |
59 * performed in the main() thread. | |
60 * | |
61 * A notable exception to this is the Draw() event. The redrawing of | |
62 * the window contents is performed asynchronously from the window | |
63 * thread. To make this work correctly, a locking protocol is used when | |
64 * any thread is accessing the essential variables that are used by | |
65 * the window thread. | |
66 * | |
67 * This locking protocol consists of locking Vim's window. This is both | |
68 * convenient and necessary. | |
69 */ | |
70 | |
71 extern "C" { | |
72 | |
73 #include <assert.h> | |
74 #include <float.h> | |
75 #include <syslog.h> | |
76 | |
77 #include "vim.h" | |
78 #include "globals.h" | |
79 #include "proto.h" | |
80 #include "version.h" | |
81 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
82 } // extern "C" |
19526 | 83 |
84 // ---------------- start of header part ---------------- | |
85 | |
86 //#include <Alert.h> | |
87 #include <Application.h> | |
88 #include <Beep.h> | |
89 #include <Bitmap.h> | |
90 #include <Box.h> | |
91 #include <Button.h> | |
92 #include <Clipboard.h> | |
93 #include <Debug.h> | |
94 //#include <Directory.h> | |
95 //#include <Entry.h> | |
96 #include <File.h> | |
97 #include <FilePanel.h> | |
98 #include <FindDirectory.h> | |
99 //#include <Font.h> | |
100 #include <IconUtils.h> | |
101 #include <Input.h> | |
102 #include <ListView.h> | |
103 #include <MenuBar.h> | |
104 #include <MenuItem.h> | |
105 //#include <MessageQueue.h> | |
106 //#include <OS.h> | |
107 #include <Path.h> | |
108 #include <PictureButton.h> | |
109 #include <PopUpMenu.h> | |
110 //#include <Region.h> | |
111 #include <Resources.h> | |
112 //#include <Roster.h> | |
113 #include <Screen.h> | |
114 #include <ScrollBar.h> | |
115 #include <ScrollView.h> | |
116 #include <String.h> | |
117 #include <StringView.h> | |
118 //#include <SupportDefs.h> | |
119 #include <TabView.h> | |
120 #include <TextControl.h> | |
121 #include <TextView.h> | |
122 #include <TranslationUtils.h> | |
123 #include <TranslatorFormats.h> | |
124 #include <View.h> | |
125 #include <Window.h> | |
126 | |
127 class VimApp; | |
128 class VimFormView; | |
129 class VimTextAreaView; | |
130 class VimWindow; | |
131 class VimToolbar; | |
132 class VimTabLine; | |
133 | |
134 extern key_map *keyMap; | |
135 extern char *keyMapChars; | |
136 | |
137 extern int main(int argc, char **argv); | |
138 | |
139 #ifndef B_MAX_PORT_COUNT | |
140 #define B_MAX_PORT_COUNT 255 | |
141 #endif | |
142 | |
143 // VimApp seems comparable to the X "vimShell" | |
144 class VimApp: public BApplication | |
145 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
146 typedef BApplication Inherited; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
147 public: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
148 VimApp(const char *appsig); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
149 ~VimApp(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
150 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
151 // callbacks: |
19526 | 152 #if 0 |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
153 virtual void DispatchMessage(BMessage *m, BHandler *h) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
154 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
155 m->PrintToStream(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
156 Inherited::DispatchMessage(m, h); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
157 } |
19526 | 158 #endif |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
159 virtual void ReadyToRun(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
160 virtual void ArgvReceived(int32 argc, char **argv); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
161 virtual void RefsReceived(BMessage *m); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
162 virtual bool QuitRequested(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
163 virtual void MessageReceived(BMessage *m); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
164 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
165 static void SendRefs(BMessage *m, bool changedir); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
166 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
167 sem_id fFilePanelSem; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
168 BFilePanel* fFilePanel; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
169 BPath fBrowsedPath; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
170 private: |
19526 | 171 }; |
172 | |
173 class VimWindow: public BWindow | |
174 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
175 typedef BWindow Inherited; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
176 public: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
177 VimWindow(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
178 ~VimWindow(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
179 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
180 // virtual void DispatchMessage(BMessage *m, BHandler *h); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
181 virtual void WindowActivated(bool active); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
182 virtual bool QuitRequested(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
183 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
184 VimFormView *formView; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
185 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
186 private: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
187 void init(); |
19526 | 188 |
189 }; | |
190 | |
191 class VimFormView: public BView | |
192 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
193 typedef BView Inherited; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
194 public: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
195 VimFormView(BRect frame); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
196 ~VimFormView(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
197 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
198 // callbacks: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
199 virtual void AllAttached(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
200 virtual void FrameResized(float new_width, float new_height); |
19526 | 201 |
202 #define MENUBAR_MARGIN 1 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
203 float MenuHeight() const |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
204 { return menuBar ? menuBar->Frame().Height() + MENUBAR_MARGIN: 0; } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
205 BMenuBar *MenuBar() const |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
206 { return menuBar; } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
207 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
208 private: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
209 void init(BRect); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
210 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
211 BMenuBar *menuBar; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
212 VimTextAreaView *textArea; |
19526 | 213 |
214 #ifdef FEAT_TOOLBAR | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
215 public: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
216 float ToolbarHeight() const; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
217 VimToolbar *ToolBar() const |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
218 { return toolBar; } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
219 private: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
220 VimToolbar *toolBar; |
19526 | 221 #endif |
222 | |
223 #ifdef FEAT_GUI_TABLINE | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
224 public: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
225 VimTabLine *TabLine() const { return tabLine; } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
226 bool IsShowingTabLine() const { return showingTabLine; } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
227 void SetShowingTabLine(bool showing) { showingTabLine = showing; } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
228 float TablineHeight() const; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
229 private: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
230 VimTabLine *tabLine; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
231 int showingTabLine; |
19526 | 232 #endif |
233 }; | |
234 | |
235 class VimTextAreaView: public BView | |
236 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
237 typedef BView Inherited; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
238 public: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
239 VimTextAreaView(BRect frame); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
240 ~VimTextAreaView(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
241 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
242 // callbacks: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
243 virtual void Draw(BRect updateRect); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
244 virtual void KeyDown(const char *bytes, int32 numBytes); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
245 virtual void MouseDown(BPoint point); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
246 virtual void MouseUp(BPoint point); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
247 virtual void MouseMoved(BPoint point, uint32 transit, const BMessage *message); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
248 virtual void MessageReceived(BMessage *m); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
249 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
250 // own functions: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
251 int mchInitFont(char_u *name); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
252 void mchDrawString(int row, int col, char_u *s, int len, int flags); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
253 void mchClearBlock(int row1, int col1, int row2, int col2); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
254 void mchClearAll(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
255 void mchDeleteLines(int row, int num_lines); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
256 void mchInsertLines(int row, int num_lines); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
257 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
258 static void guiSendMouseEvent(int button, int x, int y, int repeated_click, int_u modifiers); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
259 static void guiMouseMoved(int x, int y); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
260 static void guiBlankMouse(bool should_hide); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
261 static int_u mouseModifiersToVim(int32 beModifiers); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
262 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
263 int32 mouseDragEventCount; |
19526 | 264 |
265 #ifdef FEAT_MBYTE_IME | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
266 void DrawIMString(void); |
19526 | 267 #endif |
268 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
269 private: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
270 void init(BRect); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
271 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
272 int_u vimMouseButton; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
273 int_u vimMouseModifiers; |
19526 | 274 |
275 #ifdef FEAT_MBYTE_IME | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
276 struct { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
277 BMessenger* messenger; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
278 BMessage* message; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
279 BPoint location; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
280 int row; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
281 int col; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
282 int count; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
283 } IMData; |
19526 | 284 #endif |
285 }; | |
286 | |
287 class VimScrollBar: public BScrollBar | |
288 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
289 typedef BScrollBar Inherited; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
290 public: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
291 VimScrollBar(scrollbar_T *gsb, orientation posture); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
292 ~VimScrollBar(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
293 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
294 virtual void ValueChanged(float newValue); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
295 virtual void MouseUp(BPoint where); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
296 void SetValue(float newval); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
297 scrollbar_T *getGsb() |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
298 { return gsb; } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
299 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
300 int32 scrollEventCount; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
301 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
302 private: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
303 scrollbar_T *gsb; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
304 float ignoreValue; |
19526 | 305 }; |
306 | |
307 | |
308 #ifdef FEAT_TOOLBAR | |
309 | |
310 class VimToolbar : public BBox | |
311 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
312 static BBitmap *normalButtonsBitmap; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
313 static BBitmap *grayedButtonsBitmap; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
314 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
315 BBitmap *LoadVimBitmap(const char* fileName); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
316 bool GetPictureFromBitmap(BPicture *pictureTo, int32 index, BBitmap *bitmapFrom, bool pressed); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
317 bool ModifyBitmapToGrayed(BBitmap *bitmap); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
318 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
319 BList fButtonsList; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
320 void InvalidateLayout(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
321 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
322 public: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
323 VimToolbar(BRect frame, const char * name); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
324 ~VimToolbar(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
325 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
326 bool PrepareButtonBitmaps(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
327 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
328 bool AddButton(int32 index, vimmenu_T *menu); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
329 bool RemoveButton(vimmenu_T *menu); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
330 bool GrayButton(vimmenu_T *menu, int grey); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
331 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
332 float ToolbarHeight() const; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
333 virtual void AttachedToWindow(); |
19526 | 334 }; |
335 | |
336 BBitmap *VimToolbar::normalButtonsBitmap = NULL; | |
337 BBitmap *VimToolbar::grayedButtonsBitmap = NULL; | |
338 | |
339 const float ToolbarMargin = 3.; | |
340 const float ButtonMargin = 3.; | |
341 | |
342 #endif //FEAT_TOOLBAR | |
343 | |
344 #ifdef FEAT_GUI_TABLINE | |
345 | |
346 class VimTabLine : public BTabView | |
347 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
348 public: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
349 class VimTab : public BTab { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
350 public: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
351 VimTab() : BTab(new BView(BRect(), "-Empty-", 0, 0)) {} |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
352 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
353 virtual void Select(BView* owner); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
354 }; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
355 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
356 VimTabLine(BRect r) : BTabView(r, "vimTabLine", B_WIDTH_FROM_LABEL, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
357 B_FOLLOW_LEFT | B_FOLLOW_TOP | B_FOLLOW_RIGHT, B_WILL_DRAW | B_FRAME_EVENTS) {} |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
358 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
359 float TablineHeight() const; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
360 virtual void MouseDown(BPoint point); |
19526 | 361 }; |
362 | |
363 #endif //FEAT_GUI_TABLINE | |
364 | |
365 | |
366 // For caching the fonts that are used; | |
367 // Vim seems rather sloppy in this regard. | |
368 class VimFont: public BFont | |
369 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
370 typedef BFont Inherited; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
371 public: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
372 VimFont(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
373 VimFont(const VimFont *rhs); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
374 VimFont(const BFont *rhs); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
375 VimFont(const VimFont &rhs); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
376 ~VimFont(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
377 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
378 VimFont *next; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
379 int refcount; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
380 char_u *name; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
381 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
382 private: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
383 void init(); |
19526 | 384 }; |
385 | |
386 #if defined(FEAT_GUI_DIALOG) | |
387 | |
388 class VimDialog : public BWindow | |
389 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
390 typedef BWindow Inherited; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
391 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
392 BButton* _CreateButton(int32 which, const char* label); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
393 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
394 public: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
395 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
396 class View : public BView { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
397 typedef BView Inherited; |
19526 | 398 |
399 public: | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
400 View(BRect frame); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
401 ~View(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
402 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
403 virtual void Draw(BRect updateRect); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
404 void InitIcon(int32 type); |
19526 | 405 |
406 private: | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
407 BBitmap* fIconBitmap; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
408 }; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
409 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
410 VimDialog(int type, const char *title, const char *message, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
411 const char *buttons, int dfltbutton, const char *textfield, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
412 int ex_cmd); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
413 ~VimDialog(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
414 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
415 int Go(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
416 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
417 virtual void MessageReceived(BMessage *msg); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
418 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
419 private: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
420 sem_id fDialogSem; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
421 int fDialogValue; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
422 BList fButtonsList; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
423 BTextView* fMessageView; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
424 BTextControl* fInputControl; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
425 const char* fInputValue; |
19526 | 426 }; |
427 | |
428 class VimSelectFontDialog : public BWindow | |
429 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
430 typedef BWindow Inherited; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
431 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
432 void _CleanList(BListView* list); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
433 void _UpdateFontStyles(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
434 void _UpdateSizeInputPreview(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
435 void _UpdateFontPreview(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
436 bool _UpdateFromListItem(BListView* list, char* text, int textSize); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
437 public: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
438 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
439 VimSelectFontDialog(font_family* family, font_style* style, float* size); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
440 ~VimSelectFontDialog(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
441 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
442 bool Go(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
443 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
444 virtual void MessageReceived(BMessage *msg); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
445 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
446 private: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
447 status_t fStatus; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
448 sem_id fDialogSem; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
449 bool fDialogValue; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
450 font_family* fFamily; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
451 font_style* fStyle; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
452 float* fSize; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
453 font_family fFontFamily; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
454 font_style fFontStyle; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
455 float fFontSize; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
456 BStringView* fPreview; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
457 BListView* fFamiliesList; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
458 BListView* fStylesList; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
459 BListView* fSizesList; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
460 BTextControl* fSizesInput; |
19526 | 461 }; |
462 | |
463 #endif // FEAT_GUI_DIALOG | |
464 | |
465 // ---------------- end of GUI classes ---------------- | |
466 | |
467 struct MainArgs { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
468 int argc; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
469 char **argv; |
19526 | 470 }; |
471 | |
472 // These messages are copied through the VDCMP. | |
473 // Therefore they ought not to have anything fancy. | |
474 // They must be of POD type (Plain Old Data) | |
475 // as the C++ standard calls them. | |
476 | |
477 #define KEY_MSG_BUFSIZ 7 | |
478 #if KEY_MSG_BUFSIZ < MAX_KEY_CODE_LEN | |
479 #error Increase KEY_MSG_BUFSIZ! | |
480 #endif | |
481 | |
482 struct VimKeyMsg { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
483 char_u length; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
484 char_u chars[KEY_MSG_BUFSIZ]; // contains Vim encoding |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
485 bool csi_escape; |
19526 | 486 }; |
487 | |
488 struct VimResizeMsg { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
489 int width; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
490 int height; |
19526 | 491 }; |
492 | |
493 struct VimScrollBarMsg { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
494 VimScrollBar *sb; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
495 long value; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
496 int stillDragging; |
19526 | 497 }; |
498 | |
499 struct VimMenuMsg { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
500 vimmenu_T *guiMenu; |
19526 | 501 }; |
502 | |
503 struct VimMouseMsg { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
504 int button; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
505 int x; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
506 int y; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
507 int repeated_click; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
508 int_u modifiers; |
19526 | 509 }; |
510 | |
511 struct VimMouseMovedMsg { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
512 int x; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
513 int y; |
19526 | 514 }; |
515 | |
516 struct VimFocusMsg { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
517 bool active; |
19526 | 518 }; |
519 | |
520 struct VimRefsMsg { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
521 BMessage *message; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
522 bool changedir; |
19526 | 523 }; |
524 | |
525 struct VimTablineMsg { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
526 int index; |
19526 | 527 }; |
528 | |
529 struct VimTablineMenuMsg { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
530 int index; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
531 int event; |
19526 | 532 }; |
533 | |
534 struct VimMsg { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
535 enum VimMsgType { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
536 Key, Resize, ScrollBar, Menu, Mouse, MouseMoved, Focus, Refs, Tabline, TablineMenu |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
537 }; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
538 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
539 union { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
540 struct VimKeyMsg Key; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
541 struct VimResizeMsg NewSize; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
542 struct VimScrollBarMsg Scroll; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
543 struct VimMenuMsg Menu; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
544 struct VimMouseMsg Mouse; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
545 struct VimMouseMovedMsg MouseMoved; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
546 struct VimFocusMsg Focus; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
547 struct VimRefsMsg Refs; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
548 struct VimTablineMsg Tabline; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
549 struct VimTablineMenuMsg TablineMenu; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
550 } u; |
19526 | 551 }; |
552 | |
553 #define RGB(r, g, b) ((char_u)(r) << 16 | (char_u)(g) << 8 | (char_u)(b) << 0) | |
20231
993d820196b9
patch 8.2.0671: Haiku: compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
20152
diff
changeset
|
554 #define GUI_TO_RGB(g) { (char_u)((g) >> 16), (char_u)((g) >> 8), (char_u)((g) >> 0), 255 } |
19526 | 555 |
556 // ---------------- end of header part ---------------- | |
557 | |
558 static struct specialkey | |
559 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
560 uint16 BeKeys; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
561 #define KEY(a,b) ((a)<<8|(b)) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
562 #define K(a) KEY(0,a) // for ASCII codes |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
563 #define F(b) KEY(1,b) // for scancodes |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
564 char_u vim_code0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
565 char_u vim_code1; |
19526 | 566 } special_keys[] = |
567 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
568 {K(B_UP_ARROW), 'k', 'u'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
569 {K(B_DOWN_ARROW), 'k', 'd'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
570 {K(B_LEFT_ARROW), 'k', 'l'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
571 {K(B_RIGHT_ARROW), 'k', 'r'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
572 {K(B_BACKSPACE), 'k', 'b'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
573 {K(B_INSERT), 'k', 'I'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
574 {K(B_DELETE), 'k', 'D'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
575 {K(B_HOME), 'k', 'h'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
576 {K(B_END), '@', '7'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
577 {K(B_PAGE_UP), 'k', 'P'}, // XK_Prior |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
578 {K(B_PAGE_DOWN), 'k', 'N'}, // XK_Next, |
19526 | 579 |
580 #define FIRST_FUNCTION_KEY 11 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
581 {F(B_F1_KEY), 'k', '1'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
582 {F(B_F2_KEY), 'k', '2'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
583 {F(B_F3_KEY), 'k', '3'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
584 {F(B_F4_KEY), 'k', '4'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
585 {F(B_F5_KEY), 'k', '5'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
586 {F(B_F6_KEY), 'k', '6'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
587 {F(B_F7_KEY), 'k', '7'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
588 {F(B_F8_KEY), 'k', '8'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
589 {F(B_F9_KEY), 'k', '9'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
590 {F(B_F10_KEY), 'k', ';'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
591 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
592 {F(B_F11_KEY), 'F', '1'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
593 {F(B_F12_KEY), 'F', '2'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
594 // {XK_F13, 'F', '3'}, // would be print screen |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
595 // sysreq |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
596 {F(0x0F), 'F', '4'}, // scroll lock |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
597 {F(0x10), 'F', '5'}, // pause/break |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
598 // {XK_F16, 'F', '6'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
599 // {XK_F17, 'F', '7'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
600 // {XK_F18, 'F', '8'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
601 // {XK_F19, 'F', '9'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
602 // {XK_F20, 'F', 'A'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
603 // {XK_F21, 'F', 'B'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
604 // {XK_F22, 'F', 'C'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
605 // {XK_F23, 'F', 'D'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
606 // {XK_F24, 'F', 'E'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
607 // {XK_F25, 'F', 'F'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
608 // {XK_F26, 'F', 'G'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
609 // {XK_F27, 'F', 'H'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
610 // {XK_F28, 'F', 'I'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
611 // {XK_F29, 'F', 'J'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
612 // {XK_F30, 'F', 'K'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
613 // {XK_F31, 'F', 'L'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
614 // {XK_F32, 'F', 'M'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
615 // {XK_F33, 'F', 'N'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
616 // {XK_F34, 'F', 'O'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
617 // {XK_F35, 'F', 'P'}, // keysymdef.h defines up to F35 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
618 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
619 // {XK_Help, '%', '1'}, // XK_Help |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
620 {F(B_PRINT_KEY), '%', '9'}, |
19526 | 621 |
622 #if 0 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
623 // Keypad keys: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
624 {F(0x48), 'k', 'l'}, // XK_KP_Left |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
625 {F(0x4A), 'k', 'r'}, // XK_KP_Right |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
626 {F(0x38), 'k', 'u'}, // XK_KP_Up |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
627 {F(0x59), 'k', 'd'}, // XK_KP_Down |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
628 {F(0x64), 'k', 'I'}, // XK_KP_Insert |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
629 {F(0x65), 'k', 'D'}, // XK_KP_Delete |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
630 {F(0x37), 'k', 'h'}, // XK_KP_Home |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
631 {F(0x58), '@', '7'}, // XK_KP_End |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
632 {F(0x39), 'k', 'P'}, // XK_KP_Prior |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
633 {F(0x60), 'k', 'N'}, // XK_KP_Next |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
634 {F(0x49), '&', '8'}, // XK_Undo, keypad 5 |
19526 | 635 #endif |
636 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
637 // End of list marker: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
638 {0, 0, 0} |
19526 | 639 }; |
640 | |
24768
7334bf933510
patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
641 #define NUM_SPECIAL_KEYS ARRAY_LENGTH(special_keys) |
19526 | 642 |
643 // ---------------- VimApp ---------------- | |
644 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
645 static void |
19526 | 646 docd(BPath &path) |
647 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
648 mch_chdir((char *)path.Path()); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
649 // Do this to get the side effects of a :cd command |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
650 do_cmdline_cmd((char_u *)"cd ."); |
19526 | 651 } |
652 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
653 static void |
19526 | 654 drop_callback(void *cookie) |
655 { | |
656 // TODO here we could handle going to a specific position in the dropped | |
21785
c346db463a59
patch 8.2.1442: outdated references to the Mac Carbon GUI
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
657 // file (see src/gui_mac.c, deleted in 8.2.1422) |
19526 | 658 // Update the screen display |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
659 update_screen(UPD_NOT_VALID); |
19526 | 660 } |
661 | |
662 // Really handle dropped files and folders. | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
663 static void |
19526 | 664 RefsReceived(BMessage *m, bool changedir) |
665 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
666 uint32 type; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
667 int32 count; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
668 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
669 m->PrintToStream(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
670 switch (m->what) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
671 case B_REFS_RECEIVED: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
672 case B_SIMPLE_DATA: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
673 m->GetInfo("refs", &type, &count); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
674 if (type != B_REF_TYPE) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
675 goto bad; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
676 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
677 case B_ARGV_RECEIVED: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
678 m->GetInfo("argv", &type, &count); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
679 if (type != B_STRING_TYPE) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
680 goto bad; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
681 if (changedir) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
682 char *dirname; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
683 if (m->FindString("cwd", (const char **) &dirname) == B_OK) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
684 chdir(dirname); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
685 do_cmdline_cmd((char_u *)"cd ."); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
686 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
687 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
688 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
689 default: |
19526 | 690 bad: |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
691 /*fprintf(stderr, "bad!\n"); */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
692 delete m; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
693 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
694 } |
19526 | 695 |
696 #ifdef FEAT_VISUAL | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
697 reset_VIsual(); |
19526 | 698 #endif |
699 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
700 char_u **fnames; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
701 fnames = (char_u **) alloc(count * sizeof(char_u *)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
702 int fname_index = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
703 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
704 switch (m->what) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
705 case B_REFS_RECEIVED: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
706 case B_SIMPLE_DATA: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
707 // fprintf(stderr, "case B_REFS_RECEIVED\n"); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
708 for (int i = 0; i < count; ++i) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
709 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
710 entry_ref ref; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
711 if (m->FindRef("refs", i, &ref) == B_OK) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
712 BEntry entry(&ref, false); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
713 BPath path; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
714 entry.GetPath(&path); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
715 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
716 // Change to parent directory? |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
717 if (changedir) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
718 BPath parentpath; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
719 path.GetParent(&parentpath); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
720 docd(parentpath); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
721 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
722 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
723 // Is it a directory? If so, cd into it. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
724 BDirectory bdir(&ref); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
725 if (bdir.InitCheck() == B_OK) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
726 // don't cd if we already did it |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
727 if (!changedir) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
728 docd(path); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
729 } else { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
730 mch_dirname(IObuff, IOSIZE); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
731 char_u *fname = shorten_fname((char_u *)path.Path(), IObuff); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
732 if (fname == NULL) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
733 fname = (char_u *)path.Path(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
734 fnames[fname_index++] = vim_strsave(fname); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
735 // fprintf(stderr, "%s\n", fname); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
736 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
737 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
738 // Only do it for the first file/dir |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
739 changedir = false; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
740 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
741 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
742 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
743 case B_ARGV_RECEIVED: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
744 // fprintf(stderr, "case B_ARGV_RECEIVED\n"); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
745 for (int i = 1; i < count; ++i) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
746 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
747 char *fname; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
748 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
749 if (m->FindString("argv", i, (const char **) &fname) == B_OK) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
750 fnames[fname_index++] = vim_strsave((char_u *)fname); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
751 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
752 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
753 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
754 default: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
755 // fprintf(stderr, "case default\n"); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
756 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
757 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
758 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
759 delete m; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
760 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
761 // Handle the drop, :edit to get to the file |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
762 if (fname_index > 0) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
763 handle_drop(fname_index, fnames, FALSE, drop_callback, NULL); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
764 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
765 setcursor(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
766 out_flush(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
767 } else { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
768 vim_free(fnames); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
769 } |
19526 | 770 } |
771 | |
772 VimApp::VimApp(const char *appsig): | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
773 BApplication(appsig), |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
774 fFilePanelSem(-1), |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
775 fFilePanel(NULL) |
19526 | 776 { |
777 } | |
778 | |
779 VimApp::~VimApp() | |
780 { | |
781 } | |
782 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
783 void |
19526 | 784 VimApp::ReadyToRun() |
785 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
786 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
787 * Apparently signals are inherited by the created thread - |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
788 * disable the most annoying ones. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
789 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
790 signal(SIGINT, SIG_IGN); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
791 signal(SIGQUIT, SIG_IGN); |
19526 | 792 } |
793 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
794 void |
19526 | 795 VimApp::ArgvReceived(int32 arg_argc, char **arg_argv) |
796 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
797 if (!IsLaunching()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
798 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
799 * This can happen if we are set to Single or Exclusive |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
800 * Launch. Be nice and open the file(s). |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
801 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
802 if (gui.vimWindow) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
803 gui.vimWindow->Minimize(false); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
804 BMessage *m = CurrentMessage(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
805 DetachCurrentMessage(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
806 SendRefs(m, true); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
807 } |
19526 | 808 } |
809 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
810 void |
19526 | 811 VimApp::RefsReceived(BMessage *m) |
812 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
813 // Horrible hack!!! XXX XXX XXX |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
814 // The real problem is that b_start_ffc is set too late for |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
815 // the initial empty buffer. As a result the window will be |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
816 // split instead of abandoned. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
817 int limit = 15; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
818 while (--limit >= 0 && (curbuf == NULL || curbuf->b_start_ffc == 0)) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
819 snooze(100000); // 0.1 s |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
820 if (gui.vimWindow) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
821 gui.vimWindow->Minimize(false); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
822 DetachCurrentMessage(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
823 SendRefs(m, true); |
19526 | 824 } |
825 | |
826 /* | |
827 * Pass a BMessage on to the main() thread. | |
828 * Caller must have detached the message. | |
829 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
830 void |
19526 | 831 VimApp::SendRefs(BMessage *m, bool changedir) |
832 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
833 VimRefsMsg rm; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
834 rm.message = m; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
835 rm.changedir = changedir; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
836 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
837 write_port(gui.vdcmp, VimMsg::Refs, &rm, sizeof(rm)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
838 // calls ::RefsReceived |
19526 | 839 } |
840 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
841 void |
19526 | 842 VimApp::MessageReceived(BMessage *m) |
843 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
844 switch (m->what) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
845 case 'save': |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
846 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
847 entry_ref refDirectory; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
848 m->FindRef("directory", &refDirectory); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
849 fBrowsedPath.SetTo(&refDirectory); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
850 BString strName; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
851 m->FindString("name", &strName); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
852 fBrowsedPath.Append(strName.String()); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
853 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
854 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
855 case 'open': |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
856 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
857 entry_ref ref; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
858 m->FindRef("refs", &ref); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
859 fBrowsedPath.SetTo(&ref); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
860 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
861 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
862 case B_CANCEL: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
863 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
864 BFilePanel *panel; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
865 m->FindPointer("source", (void**)&panel); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
866 if (fFilePanelSem != -1 && panel == fFilePanel) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
867 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
868 delete_sem(fFilePanelSem); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
869 fFilePanelSem = -1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
870 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
871 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
872 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
873 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
874 default: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
875 Inherited::MessageReceived(m); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
876 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
877 } |
19526 | 878 } |
879 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
880 bool |
19526 | 881 VimApp::QuitRequested() |
882 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
883 (void)Inherited::QuitRequested(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
884 return false; |
19526 | 885 } |
886 | |
887 // ---------------- VimWindow ---------------- | |
888 | |
889 VimWindow::VimWindow(): | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
890 BWindow(BRect(40, 40, 150, 150), |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
891 "Vim", |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
892 B_TITLED_WINDOW, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
893 0, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
894 B_CURRENT_WORKSPACE) |
19526 | 895 |
896 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
897 init(); |
19526 | 898 } |
899 | |
900 VimWindow::~VimWindow() | |
901 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
902 if (formView) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
903 RemoveChild(formView); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
904 delete formView; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
905 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
906 gui.vimWindow = NULL; |
19526 | 907 } |
908 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
909 void |
19526 | 910 VimWindow::init() |
911 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
912 // Attach the VimFormView |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
913 formView = new VimFormView(Bounds()); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
914 if (formView != NULL) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
915 AddChild(formView); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
916 } |
19526 | 917 } |
918 | |
919 #if 0 // disabled in zeta patch | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
920 void |
19526 | 921 VimWindow::DispatchMessage(BMessage *m, BHandler *h) |
922 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
923 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
924 * Route B_MOUSE_UP messages to MouseUp(), in |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
925 * a manner that should be compatible with the |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
926 * intended future system behaviour. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
927 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
928 switch (m->what) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
929 case B_MOUSE_UP: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
930 // if (!h) h = PreferredHandler(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
931 // gcc isn't happy without this extra set of braces, complains about |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
932 // jump to case label crosses init of 'class BView * v' |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
933 // richard@whitequeen.com jul 99 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
934 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
935 BView *v = dynamic_cast<BView *>(h); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
936 if (v) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
937 // m->PrintToStream(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
938 BPoint where; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
939 m->FindPoint("where", &where); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
940 v->MouseUp(where); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
941 } else { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
942 Inherited::DispatchMessage(m, h); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
943 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
944 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
945 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
946 default: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
947 Inherited::DispatchMessage(m, h); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
948 } |
19526 | 949 } |
950 #endif | |
951 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
952 void |
19526 | 953 VimWindow::WindowActivated(bool active) |
954 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
955 Inherited::WindowActivated(active); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
956 // the textArea gets the keyboard action |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
957 if (active && gui.vimTextArea) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
958 gui.vimTextArea->MakeFocus(true); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
959 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
960 struct VimFocusMsg fm; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
961 fm.active = active; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
962 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
963 write_port(gui.vdcmp, VimMsg::Focus, &fm, sizeof(fm)); |
19526 | 964 } |
965 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
966 bool |
19526 | 967 VimWindow::QuitRequested() |
968 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
969 struct VimKeyMsg km; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
970 km.length = 5; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
971 memcpy((char *)km.chars, "\033:qa\r", km.length); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
972 km.csi_escape = false; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
973 write_port(gui.vdcmp, VimMsg::Key, &km, sizeof(km)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
974 return false; |
19526 | 975 } |
976 | |
977 // ---------------- VimFormView ---------------- | |
978 | |
979 VimFormView::VimFormView(BRect frame): | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
980 BView(frame, "VimFormView", B_FOLLOW_ALL_SIDES, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
981 B_WILL_DRAW | B_FRAME_EVENTS), |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
982 menuBar(NULL), |
19526 | 983 #ifdef FEAT_TOOLBAR |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
984 toolBar(NULL), |
19526 | 985 #endif |
986 #ifdef FEAT_GUI_TABLINE | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
987 // showingTabLine(false), |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
988 tabLine(NULL), |
19526 | 989 #endif |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
990 textArea(NULL) |
19526 | 991 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
992 init(frame); |
19526 | 993 } |
994 | |
995 VimFormView::~VimFormView() | |
996 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
997 if (menuBar) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
998 RemoveChild(menuBar); |
19526 | 999 #ifdef never |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1000 // deleting the menuBar leads to SEGV on exit |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1001 // richard@whitequeen.com Jul 99 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1002 delete menuBar; |
19526 | 1003 #endif |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1004 } |
19526 | 1005 |
1006 #ifdef FEAT_TOOLBAR | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1007 delete toolBar; |
19526 | 1008 #endif |
1009 | |
1010 #ifdef FEAT_GUI_TABLINE | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1011 delete tabLine; |
19526 | 1012 #endif |
1013 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1014 if (textArea) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1015 RemoveChild(textArea); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1016 delete textArea; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1017 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1018 gui.vimForm = NULL; |
19526 | 1019 } |
1020 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1021 void |
19526 | 1022 VimFormView::init(BRect frame) |
1023 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1024 menuBar = new BMenuBar(BRect(0,0,-MENUBAR_MARGIN,-MENUBAR_MARGIN), |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1025 "VimMenuBar"); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1026 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1027 AddChild(menuBar); |
19526 | 1028 |
1029 #ifdef FEAT_TOOLBAR | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1030 toolBar = new VimToolbar(BRect(0,0,0,0), "VimToolBar"); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1031 toolBar->PrepareButtonBitmaps(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1032 AddChild(toolBar); |
19526 | 1033 #endif |
1034 | |
1035 #ifdef FEAT_GUI_TABLINE | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1036 tabLine = new VimTabLine(BRect(0,0,0,0)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1037 // tabLine->PrepareButtonBitmaps(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1038 AddChild(tabLine); |
19526 | 1039 #endif |
1040 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1041 BRect remaining = frame; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1042 textArea = new VimTextAreaView(remaining); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1043 AddChild(textArea); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1044 // The textArea will be resized later when menus are added |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1045 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1046 gui.vimForm = this; |
19526 | 1047 } |
1048 | |
1049 #ifdef FEAT_TOOLBAR | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1050 float |
19526 | 1051 VimFormView::ToolbarHeight() const |
1052 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1053 return toolBar ? toolBar->ToolbarHeight() : 0.; |
19526 | 1054 } |
1055 #endif | |
1056 | |
1057 #ifdef FEAT_GUI_TABLINE | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1058 float |
19526 | 1059 VimFormView::TablineHeight() const |
1060 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1061 return (tabLine && IsShowingTabLine()) ? tabLine->TablineHeight() : 0.; |
19526 | 1062 } |
1063 #endif | |
1064 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1065 void |
19526 | 1066 VimFormView::AllAttached() |
1067 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1068 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1069 * Apparently signals are inherited by the created thread - |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1070 * disable the most annoying ones. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1071 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1072 signal(SIGINT, SIG_IGN); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1073 signal(SIGQUIT, SIG_IGN); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1074 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1075 if (menuBar && textArea) { |
19526 | 1076 /* |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1077 * Resize the textArea to fill the space left over by the menu. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1078 * This is somewhat futile since it will be done again once |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1079 * menus are added to the menu bar. |
19526 | 1080 */ |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1081 BRect remaining = Bounds(); |
19526 | 1082 |
1083 #ifdef FEAT_MENU | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1084 remaining.top += MenuHeight(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1085 menuBar->ResizeTo(remaining.right, remaining.top); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1086 gui.menu_height = (int) MenuHeight(); |
19526 | 1087 #endif |
1088 | |
1089 #ifdef FEAT_TOOLBAR | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1090 toolBar->MoveTo(remaining.left, remaining.top); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1091 toolBar->ResizeTo(remaining.right, ToolbarHeight()); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1092 remaining.top += ToolbarHeight(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1093 gui.toolbar_height = ToolbarHeight(); |
19526 | 1094 #endif |
1095 | |
1096 #ifdef FEAT_GUI_TABLINE | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1097 tabLine->MoveTo(remaining.left, remaining.top); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1098 tabLine->ResizeTo(remaining.right + 1, TablineHeight()); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1099 remaining.top += TablineHeight(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1100 gui.tabline_height = TablineHeight(); |
19526 | 1101 #endif |
1102 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1103 textArea->ResizeTo(remaining.Width(), remaining.Height()); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1104 textArea->MoveTo(remaining.left, remaining.top); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1105 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1106 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1107 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1108 Inherited::AllAttached(); |
19526 | 1109 } |
1110 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1111 void |
19526 | 1112 VimFormView::FrameResized(float new_width, float new_height) |
1113 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1114 struct VimResizeMsg sm; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1115 int adjust_h, adjust_w; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1116 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1117 new_width += 1; // adjust from width to number of pixels occupied |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1118 new_height += 1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1119 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1120 sm.width = (int) new_width; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1121 sm.height = (int) new_height; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1122 adjust_w = ((int)new_width - gui_get_base_width()) % gui.char_width; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1123 adjust_h = ((int)new_height - gui_get_base_height()) % gui.char_height; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1124 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1125 if (adjust_w > 0 || adjust_h > 0) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1126 sm.width -= adjust_w; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1127 sm.height -= adjust_h; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1128 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1129 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1130 write_port(gui.vdcmp, VimMsg::Resize, &sm, sizeof(sm)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1131 // calls gui_resize_shell(new_width, new_height); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1132 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1133 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1134 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1135 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1136 * The area below the vertical scrollbar is erased to the colour |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1137 * set with SetViewColor() automatically, because we had set |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1138 * B_WILL_DRAW. Resizing the window tight around the vertical |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1139 * scroll bar also helps to avoid debris. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1140 */ |
19526 | 1141 } |
1142 | |
1143 // ---------------- VimTextAreaView ---------------- | |
1144 | |
1145 VimTextAreaView::VimTextAreaView(BRect frame): | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1146 BView(frame, "VimTextAreaView", B_FOLLOW_ALL_SIDES, |
19526 | 1147 #ifdef FEAT_MBYTE_IME |
20277
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
1148 B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_INPUT_METHOD_AWARE |
19526 | 1149 #else |
20277
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
1150 B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE |
19526 | 1151 #endif |
20277
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
1152 ), |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1153 mouseDragEventCount(0) |
19526 | 1154 { |
1155 #ifdef FEAT_MBYTE_IME | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1156 IMData.messenger = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1157 IMData.message = NULL; |
19526 | 1158 #endif |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1159 init(frame); |
19526 | 1160 } |
1161 | |
1162 VimTextAreaView::~VimTextAreaView() | |
1163 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1164 gui.vimTextArea = NULL; |
19526 | 1165 } |
1166 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1167 void |
19526 | 1168 VimTextAreaView::init(BRect frame) |
1169 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1170 // set up global var for fast access |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1171 gui.vimTextArea = this; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1172 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1173 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1174 * Tell the app server not to erase the view: we will |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1175 * fill it in completely by ourselves. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1176 * (Does this really work? Even if not, it won't harm either.) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1177 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1178 SetViewColor(B_TRANSPARENT_32_BIT); |
19526 | 1179 #define PEN_WIDTH 1 |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1180 SetPenSize(PEN_WIDTH); |
19526 | 1181 #define W_WIDTH(curwin) 0 |
1182 } | |
1183 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1184 void |
19526 | 1185 VimTextAreaView::Draw(BRect updateRect) |
1186 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1187 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1188 * XXX Other ports call here: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1189 * out_flush(); * make sure all output has been processed * |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1190 * but we can't do that, since it involves too much information |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1191 * that is owned by other threads... |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1192 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1193 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1194 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1195 * No need to use gui.vimWindow->Lock(): we are locked already. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1196 * However, it would not hurt. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1197 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1198 rgb_color rgb = GUI_TO_RGB(gui.back_pixel); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1199 SetLowColor(rgb); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1200 FillRect(updateRect, B_SOLID_LOW); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1201 gui_redraw((int) updateRect.left, (int) updateRect.top, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1202 (int) (updateRect.Width() + PEN_WIDTH), (int) (updateRect.Height() + PEN_WIDTH)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1203 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1204 // Clear the border areas if needed |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1205 SetLowColor(rgb); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1206 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1207 if (updateRect.left < FILL_X(0)) // left border |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1208 FillRect(BRect(updateRect.left, updateRect.top, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1209 FILL_X(0)-PEN_WIDTH, updateRect.bottom), B_SOLID_LOW); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1210 if (updateRect.top < FILL_Y(0)) // top border |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1211 FillRect(BRect(updateRect.left, updateRect.top, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1212 updateRect.right, FILL_Y(0)-PEN_WIDTH), B_SOLID_LOW); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1213 if (updateRect.right >= FILL_X(Columns)) // right border |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1214 FillRect(BRect(FILL_X((int)Columns), updateRect.top, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1215 updateRect.right, updateRect.bottom), B_SOLID_LOW); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1216 if (updateRect.bottom >= FILL_Y(Rows)) // bottom border |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1217 FillRect(BRect(updateRect.left, FILL_Y((int)Rows), |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1218 updateRect.right, updateRect.bottom), B_SOLID_LOW); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1219 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1220 #ifdef FEAT_MBYTE_IME |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1221 DrawIMString(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1222 #endif |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1223 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1224 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1225 void |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1226 VimTextAreaView::KeyDown(const char *bytes, int32 numBytes) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1227 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1228 struct VimKeyMsg km; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1229 char_u *dest = km.chars; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1230 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1231 bool canHaveVimModifiers = false; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1232 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1233 BMessage *msg = Window()->CurrentMessage(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1234 assert(msg); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1235 // msg->PrintToStream(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1236 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1237 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1238 * Convert special keys to Vim codes. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1239 * I think it is better to do it in the window thread |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1240 * so we use at least a little bit of the potential |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1241 * of our 2 CPUs. Besides, due to the fantastic mapping |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1242 * of special keys to UTF-8, we have quite some work to |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1243 * do... |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1244 * TODO: I'm not quite happy with detection of special |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1245 * keys. Perhaps I should use scan codes after all... |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1246 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1247 if (numBytes > 1) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1248 // This cannot be a special key |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1249 if (numBytes > KEY_MSG_BUFSIZ) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1250 numBytes = KEY_MSG_BUFSIZ; // should never happen... ??? |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1251 km.length = numBytes; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1252 memcpy((char *)dest, bytes, numBytes); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1253 km.csi_escape = true; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1254 } else { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1255 int32 scancode = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1256 msg->FindInt32("key", &scancode); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1257 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1258 int32 beModifiers = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1259 msg->FindInt32("modifiers", &beModifiers); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1260 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1261 char_u string[3]; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1262 int len = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1263 km.length = 0; |
19526 | 1264 |
1265 /* | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1266 * For normal, printable ASCII characters, don't look them up |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1267 * to check if they might be a special key. They aren't. |
19526 | 1268 */ |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1269 assert(B_BACKSPACE <= 0x20); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1270 assert(B_DELETE == 0x7F); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1271 if (((char_u)bytes[0] <= 0x20 || (char_u)bytes[0] == 0x7F) && |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1272 numBytes == 1) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1273 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1274 * Due to the great nature of Be's mapping of special keys, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1275 * viz. into the range of the control characters, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1276 * we can only be sure it is *really* a special key if |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1277 * if it is special without using ctrl. So, only if ctrl is |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1278 * used, we need to check it unmodified. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1279 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1280 if (beModifiers & B_CONTROL_KEY) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1281 int index = keyMap->normal_map[scancode]; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1282 int newNumBytes = keyMapChars[index]; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1283 char_u *newBytes = (char_u *)&keyMapChars[index + 1]; |
19526 | 1284 |
1285 /* | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1286 * Check if still special without the control key. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1287 * This is needed for BACKSPACE: that key does produce |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1288 * different values with modifiers (DEL). |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1289 * Otherwise we could simply have checked for equality. |
19526 | 1290 */ |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1291 if (newNumBytes != 1 || (*newBytes > 0x20 && |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1292 *newBytes != 0x7F )) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1293 goto notspecial; |
19526 | 1294 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1295 bytes = (char *)newBytes; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1296 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1297 canHaveVimModifiers = true; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1298 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1299 uint16 beoskey; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1300 int first, last; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1301 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1302 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1303 * If numBytes == 0 that probably always indicates a special key. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1304 * (does not happen yet) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1305 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1306 if (numBytes == 0 || bytes[0] == B_FUNCTION_KEY) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1307 beoskey = F(scancode); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1308 first = FIRST_FUNCTION_KEY; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1309 last = NUM_SPECIAL_KEYS; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1310 } else if (*bytes == '\n' && scancode == 0x47) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1311 // remap the (non-keypad) ENTER key from \n to \r. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1312 string[0] = '\r'; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1313 len = 1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1314 first = last = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1315 } else { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1316 beoskey = K(bytes[0]); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1317 first = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1318 last = FIRST_FUNCTION_KEY; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1319 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1320 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1321 for (int i = first; i < last; i++) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1322 if (special_keys[i].BeKeys == beoskey) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1323 string[0] = CSI; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1324 string[1] = special_keys[i].vim_code0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1325 string[2] = special_keys[i].vim_code1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1326 len = 3; |
19526 | 1327 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1328 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1329 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1330 notspecial: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1331 if (len == 0) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1332 string[0] = bytes[0]; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1333 len = 1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1334 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1335 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1336 // Special keys (and a few others) may have modifiers |
19526 | 1337 #if 0 |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1338 if (len == 3 || |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1339 bytes[0] == B_SPACE || bytes[0] == B_TAB || |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1340 bytes[0] == B_RETURN || bytes[0] == '\r' || |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1341 bytes[0] == B_ESCAPE) |
19526 | 1342 #else |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1343 if (canHaveVimModifiers) |
19526 | 1344 #endif |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1345 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1346 int modifiers; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1347 modifiers = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1348 if (beModifiers & B_SHIFT_KEY) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1349 modifiers |= MOD_MASK_SHIFT; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1350 if (beModifiers & B_CONTROL_KEY) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1351 modifiers |= MOD_MASK_CTRL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1352 if (beModifiers & B_OPTION_KEY) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1353 modifiers |= MOD_MASK_ALT; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1354 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1355 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1356 * For some keys a shift modifier is translated into another key |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1357 * code. Do we need to handle the case where len != 1 and |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1358 * string[0] != CSI? (Not for BeOS, since len == 3 implies |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1359 * string[0] == CSI...) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1360 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1361 int key; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1362 if (string[0] == CSI && len == 3) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1363 key = TO_SPECIAL(string[1], string[2]); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1364 else |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1365 key = string[0]; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1366 key = simplify_key(key, &modifiers); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1367 if (IS_SPECIAL(key)) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1368 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1369 string[0] = CSI; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1370 string[1] = K_SECOND(key); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1371 string[2] = K_THIRD(key); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1372 len = 3; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1373 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1374 else |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1375 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1376 string[0] = key; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1377 len = 1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1378 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1379 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1380 if (modifiers) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1381 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1382 *dest++ = CSI; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1383 *dest++ = KS_MODIFIER; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1384 *dest++ = modifiers; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1385 km.length = 3; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1386 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1387 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1388 memcpy((char *)dest, string, len); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1389 km.length += len; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1390 km.csi_escape = false; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1391 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1392 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1393 write_port(gui.vdcmp, VimMsg::Key, &km, sizeof(km)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1394 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1395 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1396 * blank out the pointer if necessary |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1397 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1398 if (p_mh && !gui.pointer_hidden) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1399 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1400 guiBlankMouse(true); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1401 gui.pointer_hidden = TRUE; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1402 } |
19526 | 1403 } |
1404 void | |
1405 VimTextAreaView::guiSendMouseEvent( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1406 int button, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1407 int x, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1408 int y, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1409 int repeated_click, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1410 int_u modifiers) |
19526 | 1411 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1412 VimMouseMsg mm; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1413 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1414 mm.button = button; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1415 mm.x = x; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1416 mm.y = y; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1417 mm.repeated_click = repeated_click; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1418 mm.modifiers = modifiers; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1419 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1420 write_port(gui.vdcmp, VimMsg::Mouse, &mm, sizeof(mm)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1421 // calls gui_send_mouse_event() |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1422 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1423 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1424 * if our pointer is currently hidden, then we should show it. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1425 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1426 if (gui.pointer_hidden) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1427 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1428 guiBlankMouse(false); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1429 gui.pointer_hidden = FALSE; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1430 } |
19526 | 1431 } |
1432 | |
1433 void | |
1434 VimTextAreaView::guiMouseMoved( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1435 int x, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1436 int y) |
19526 | 1437 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1438 VimMouseMovedMsg mm; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1439 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1440 mm.x = x; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1441 mm.y = y; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1442 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1443 write_port(gui.vdcmp, VimMsg::MouseMoved, &mm, sizeof(mm)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1444 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1445 if (gui.pointer_hidden) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1446 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1447 guiBlankMouse(false); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1448 gui.pointer_hidden = FALSE; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1449 } |
19526 | 1450 } |
1451 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1452 void |
19526 | 1453 VimTextAreaView::guiBlankMouse(bool should_hide) |
1454 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1455 if (should_hide) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1456 // gui.vimApp->HideCursor(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1457 gui.vimApp->ObscureCursor(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1458 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1459 * ObscureCursor() would even be easier, but then |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1460 * Vim's idea of mouse visibility does not necessarily |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1461 * correspond to reality. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1462 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1463 } else { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1464 // gui.vimApp->ShowCursor(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1465 } |
19526 | 1466 } |
1467 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1468 int_u |
19526 | 1469 VimTextAreaView::mouseModifiersToVim(int32 beModifiers) |
1470 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1471 int_u vim_modifiers = 0x0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1472 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1473 if (beModifiers & B_SHIFT_KEY) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1474 vim_modifiers |= MOUSE_SHIFT; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1475 if (beModifiers & B_CONTROL_KEY) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1476 vim_modifiers |= MOUSE_CTRL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1477 if (beModifiers & B_OPTION_KEY) // Alt or Meta key |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1478 vim_modifiers |= MOUSE_ALT; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1479 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1480 return vim_modifiers; |
19526 | 1481 } |
1482 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1483 void |
19526 | 1484 VimTextAreaView::MouseDown(BPoint point) |
1485 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1486 BMessage *m = Window()->CurrentMessage(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1487 assert(m); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1488 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1489 int32 buttons = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1490 m->FindInt32("buttons", &buttons); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1491 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1492 int vimButton; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1493 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1494 if (buttons & B_PRIMARY_MOUSE_BUTTON) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1495 vimButton = MOUSE_LEFT; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1496 else if (buttons & B_SECONDARY_MOUSE_BUTTON) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1497 vimButton = MOUSE_RIGHT; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1498 else if (buttons & B_TERTIARY_MOUSE_BUTTON) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1499 vimButton = MOUSE_MIDDLE; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1500 else |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1501 return; // Unknown button |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1502 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1503 vimMouseButton = 1; // don't care which one |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1504 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1505 // Handle multiple clicks |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1506 int32 clicks = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1507 m->FindInt32("clicks", &clicks); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1508 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1509 int32 modifiers = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1510 m->FindInt32("modifiers", &modifiers); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1511 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1512 vimMouseModifiers = mouseModifiersToVim(modifiers); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1513 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1514 guiSendMouseEvent(vimButton, point.x, point.y, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1515 clicks > 1 /* = repeated_click*/, vimMouseModifiers); |
19526 | 1516 } |
1517 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1518 void |
19526 | 1519 VimTextAreaView::MouseUp(BPoint point) |
1520 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1521 vimMouseButton = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1522 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1523 BMessage *m = Window()->CurrentMessage(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1524 assert(m); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1525 // m->PrintToStream(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1526 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1527 int32 modifiers = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1528 m->FindInt32("modifiers", &modifiers); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1529 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1530 vimMouseModifiers = mouseModifiersToVim(modifiers); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1531 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1532 guiSendMouseEvent(MOUSE_RELEASE, point.x, point.y, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1533 0 /* = repeated_click*/, vimMouseModifiers); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1534 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1535 Inherited::MouseUp(point); |
19526 | 1536 } |
1537 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1538 void |
19526 | 1539 VimTextAreaView::MouseMoved(BPoint point, uint32 transit, const BMessage *message) |
1540 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1541 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1542 * if our pointer is currently hidden, then we should show it. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1543 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1544 if (gui.pointer_hidden) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1545 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1546 guiBlankMouse(false); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1547 gui.pointer_hidden = FALSE; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1548 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1549 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1550 if (!vimMouseButton) { // could also check m->"buttons" |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1551 guiMouseMoved(point.x, point.y); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1552 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1553 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1554 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1555 atomic_add(&mouseDragEventCount, 1); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1556 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1557 // Don't care much about "transit" |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1558 guiSendMouseEvent(MOUSE_DRAG, point.x, point.y, 0, vimMouseModifiers); |
19526 | 1559 } |
1560 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1561 void |
19526 | 1562 VimTextAreaView::MessageReceived(BMessage *m) |
1563 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1564 switch (m->what) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1565 case 'menu': |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1566 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1567 VimMenuMsg mm; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1568 mm.guiMenu = NULL; // in case no pointer in msg |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1569 m->FindPointer("VimMenu", (void **)&mm.guiMenu); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1570 write_port(gui.vdcmp, VimMsg::Menu, &mm, sizeof(mm)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1571 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1572 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1573 case B_MOUSE_WHEEL_CHANGED: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1574 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1575 VimScrollBar* scb = curwin->w_scrollbars[1].id; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1576 float small=0, big=0, dy=0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1577 m->FindFloat("be:wheel_delta_y", &dy); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1578 scb->GetSteps(&small, &big); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1579 scb->SetValue(scb->Value()+small*dy*3); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1580 scb->ValueChanged(scb->Value()); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1581 #if 0 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1582 scb = curwin->w_scrollbars[0].id; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1583 scb->GetSteps(&small, &big); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1584 scb->SetValue(scb->Value()+small*dy); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1585 scb->ValueChanged(scb->Value()); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1586 #endif |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1587 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1588 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1589 #ifdef FEAT_MBYTE_IME |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1590 case B_INPUT_METHOD_EVENT: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1591 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1592 int32 opcode; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1593 m->FindInt32("be:opcode", &opcode); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1594 switch(opcode) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1595 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1596 case B_INPUT_METHOD_STARTED: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1597 if (!IMData.messenger) delete IMData.messenger; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1598 IMData.messenger = new BMessenger(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1599 m->FindMessenger("be:reply_to", IMData.messenger); |
19526 | 1600 break; |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1601 case B_INPUT_METHOD_CHANGED: |
19526 | 1602 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1603 BString str; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1604 bool confirmed; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1605 if (IMData.message) *(IMData.message) = *m; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1606 else IMData.message = new BMessage(*m); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1607 DrawIMString(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1608 m->FindBool("be:confirmed", &confirmed); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1609 if (confirmed) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1610 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1611 m->FindString("be:string", &str); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1612 char_u *chars = (char_u*)str.String(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1613 struct VimKeyMsg km; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1614 km.csi_escape = true; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1615 int clen; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1616 int i = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1617 while (i < str.Length()) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1618 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1619 clen = utf_ptr2len(chars+i); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1620 memcpy(km.chars, chars+i, clen); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1621 km.length = clen; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1622 write_port(gui.vdcmp, VimMsg::Key, &km, sizeof(km)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1623 i += clen; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1624 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1625 } |
19526 | 1626 } |
1627 break; | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1628 case B_INPUT_METHOD_LOCATION_REQUEST: |
19526 | 1629 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1630 BMessage msg(B_INPUT_METHOD_EVENT); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1631 msg.AddInt32("be:opcode", B_INPUT_METHOD_LOCATION_REQUEST); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1632 msg.AddPoint("be:location_reply", IMData.location); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1633 msg.AddFloat("be:height_reply", FILL_Y(1)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1634 IMData.messenger->SendMessage(&msg); |
19526 | 1635 } |
1636 break; | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1637 case B_INPUT_METHOD_STOPPED: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1638 delete IMData.messenger; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1639 delete IMData.message; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1640 IMData.messenger = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1641 IMData.message = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1642 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1643 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1644 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1645 // TODO: sz: break here??? |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1646 #endif |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1647 default: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1648 if (m->WasDropped()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1649 BWindow *w = Window(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1650 w->DetachCurrentMessage(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1651 w->Minimize(false); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1652 VimApp::SendRefs(m, (modifiers() & B_SHIFT_KEY) != 0); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1653 } else { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1654 Inherited::MessageReceived(m); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1655 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1656 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1657 } |
19526 | 1658 } |
1659 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1660 int |
19526 | 1661 VimTextAreaView::mchInitFont(char_u *name) |
1662 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1663 VimFont *newFont = (VimFont *)gui_mch_get_font(name, 1); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1664 if (newFont != NOFONT) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1665 gui.norm_font = (GuiFont)newFont; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1666 gui_mch_set_font((GuiFont)newFont); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1667 if (name && STRCMP(name, "*") != 0) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1668 hl_set_font_name(name); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1669 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1670 SetDrawingMode(B_OP_COPY); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1671 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1672 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1673 * Try to load other fonts for bold, italic, and bold-italic. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1674 * We should also try to work out what font to use for these when they are |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1675 * not specified by X resources, but we don't yet. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1676 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1677 return OK; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1678 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1679 return FAIL; |
19526 | 1680 } |
1681 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1682 void |
19526 | 1683 VimTextAreaView::mchDrawString(int row, int col, char_u *s, int len, int flags) |
1684 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1685 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1686 * First we must erase the area, because DrawString won't do |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1687 * that for us. XXX Most of the time this is a waste of effort |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1688 * since the bachground has been erased already... DRAW_TRANSP |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1689 * should be set when appropriate!!! |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1690 * (Rectangles include the bottom and right edge) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1691 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1692 if (!(flags & DRAW_TRANSP)) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1693 int cells; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1694 cells = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1695 for (int i=0; i<len; i++) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1696 int cn = utf_ptr2cells((char_u *)(s+i)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1697 if (cn<4) cells += cn; |
19526 | 1698 } |
1699 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1700 BRect r(FILL_X(col), FILL_Y(row), |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1701 FILL_X(col + cells) - PEN_WIDTH, FILL_Y(row + 1) - PEN_WIDTH); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1702 FillRect(r, B_SOLID_LOW); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1703 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1704 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1705 BFont font; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1706 this->GetFont(&font); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1707 if (!font.IsFixed()) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1708 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1709 char* p = (char*)s; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1710 int32 clen, lastpos = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1711 BPoint where; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1712 int cells; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1713 while ((p - (char*)s) < len) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1714 clen = utf_ptr2len((u_char*)p); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1715 where.Set(TEXT_X(col+lastpos), TEXT_Y(row)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1716 DrawString(p, clen, where); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1717 if (flags & DRAW_BOLD) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1718 where.x += 1.0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1719 SetDrawingMode(B_OP_BLEND); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1720 DrawString(p, clen, where); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1721 SetDrawingMode(B_OP_COPY); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1722 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1723 cells = utf_ptr2cells((char_u *)p); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1724 if (cells<4) lastpos += cells; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1725 else lastpos++; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1726 p += clen; |
19526 | 1727 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1728 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1729 else |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1730 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1731 BPoint where(TEXT_X(col), TEXT_Y(row)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1732 DrawString((char*)s, len, where); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1733 if (flags & DRAW_BOLD) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1734 where.x += 1.0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1735 SetDrawingMode(B_OP_BLEND); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1736 DrawString((char*)s, len, where); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1737 SetDrawingMode(B_OP_COPY); |
19526 | 1738 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1739 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1740 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1741 if (flags & DRAW_UNDERL) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1742 int cells; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1743 cells = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1744 for (int i=0; i<len; i++) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1745 int cn = utf_ptr2cells((char_u *)(s+i)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1746 if (cn<4) cells += cn; |
19526 | 1747 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1748 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1749 BPoint start(FILL_X(col), FILL_Y(row + 1) - PEN_WIDTH); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1750 BPoint end(FILL_X(col + cells) - PEN_WIDTH, start.y); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1751 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1752 StrokeLine(start, end); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1753 } |
19526 | 1754 } |
1755 | |
1756 void | |
1757 VimTextAreaView::mchClearBlock( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1758 int row1, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1759 int col1, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1760 int row2, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1761 int col2) |
19526 | 1762 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1763 BRect r(FILL_X(col1), FILL_Y(row1), |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1764 FILL_X(col2 + 1) - PEN_WIDTH, FILL_Y(row2 + 1) - PEN_WIDTH); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1765 gui_mch_set_bg_color(gui.back_pixel); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1766 FillRect(r, B_SOLID_LOW); |
19526 | 1767 } |
1768 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1769 void |
19526 | 1770 VimTextAreaView::mchClearAll() |
1771 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1772 gui_mch_set_bg_color(gui.back_pixel); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1773 FillRect(Bounds(), B_SOLID_LOW); |
19526 | 1774 } |
1775 | |
1776 /* | |
1777 * mchDeleteLines() Lock()s the window by itself. | |
1778 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1779 void |
19526 | 1780 VimTextAreaView::mchDeleteLines(int row, int num_lines) |
1781 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1782 BRect source, dest; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1783 source.left = FILL_X(gui.scroll_region_left); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1784 source.top = FILL_Y(row + num_lines); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1785 source.right = FILL_X(gui.scroll_region_right + 1) - PEN_WIDTH; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1786 source.bottom = FILL_Y(gui.scroll_region_bot + 1) - PEN_WIDTH; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1787 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1788 dest.left = FILL_X(gui.scroll_region_left); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1789 dest.top = FILL_Y(row); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1790 dest.right = FILL_X(gui.scroll_region_right + 1) - PEN_WIDTH; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1791 dest.bottom = FILL_Y(gui.scroll_region_bot - num_lines + 1) - PEN_WIDTH; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1792 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1793 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1794 // Clear one column more for when bold has spilled over |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1795 CopyBits(source, dest); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1796 gui_clear_block(gui.scroll_region_bot - num_lines + 1, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1797 gui.scroll_region_left, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1798 gui.scroll_region_bot, gui.scroll_region_right); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1799 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1800 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1801 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1802 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1803 * The Draw() callback will be called now if some of the source |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1804 * bits were not in the visible region. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1805 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1806 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1807 // gui_x11_check_copy_area(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1808 // } |
19526 | 1809 } |
1810 | |
1811 /* | |
1812 * mchInsertLines() Lock()s the window by itself. | |
1813 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1814 void |
19526 | 1815 VimTextAreaView::mchInsertLines(int row, int num_lines) |
1816 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1817 BRect source, dest; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1818 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1819 // XXX Attempt at a hack: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1820 gui.vimWindow->UpdateIfNeeded(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1821 source.left = FILL_X(gui.scroll_region_left); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1822 source.top = FILL_Y(row); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1823 source.right = FILL_X(gui.scroll_region_right + 1) - PEN_WIDTH; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1824 source.bottom = FILL_Y(gui.scroll_region_bot - num_lines + 1) - PEN_WIDTH; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1825 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1826 dest.left = FILL_X(gui.scroll_region_left); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1827 dest.top = FILL_Y(row + num_lines); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1828 dest.right = FILL_X(gui.scroll_region_right + 1) - PEN_WIDTH; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1829 dest.bottom = FILL_Y(gui.scroll_region_bot + 1) - PEN_WIDTH; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1830 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1831 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1832 // Clear one column more for when bold has spilled over |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1833 CopyBits(source, dest); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1834 gui_clear_block(row, gui.scroll_region_left, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1835 row + num_lines - 1, gui.scroll_region_right); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1836 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1837 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1838 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1839 * The Draw() callback will be called now if some of the source |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1840 * bits were not in the visible region. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1841 * However, if we scroll too fast it can't keep up and the |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1842 * update region gets messed up. This seems to be because copying |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1843 * un-Draw()n bits does not generate Draw() calls for the copy... |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1844 * I moved the hack to before the CopyBits() to reduce the |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1845 * amount of additional waiting needed. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1846 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1847 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1848 // gui_x11_check_copy_area(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1849 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1850 } |
19526 | 1851 } |
1852 | |
1853 #ifdef FEAT_MBYTE_IME | |
1854 /* | |
1855 * DrawIMString draws string with IMData.message. | |
1856 */ | |
1857 void VimTextAreaView::DrawIMString(void) | |
1858 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1859 static const rgb_color r_highlight = {255, 152, 152, 255}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1860 b_highlight = {152, 203, 255, 255}; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1861 BString str; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1862 const char* s; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1863 int len; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1864 BMessage* msg = IMData.message; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1865 if (!msg) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1866 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1867 gui_redraw_block(IMData.row, 0, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1868 IMData.row + IMData.count, W_WIDTH(curwin), GUI_MON_NOCLEAR); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1869 bool confirmed = false; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1870 msg->FindBool("be:confirmed", &confirmed); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1871 if (confirmed) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1872 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1873 rgb_color hcolor = HighColor(), lcolor = LowColor(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1874 msg->FindString("be:string", &str); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1875 s = str.String(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1876 len = str.Length(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1877 SetHighColor(0, 0, 0); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1878 IMData.row = gui.row; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1879 IMData.col = gui.col; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1880 int32 sel_start = 0, sel_end = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1881 msg->FindInt32("be:selection", 0, &sel_start); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1882 msg->FindInt32("be:selection", 1, &sel_end); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1883 int clen, cn; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1884 BPoint pos(IMData.col, 0); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1885 BRect r; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1886 BPoint where; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1887 IMData.location = ConvertToScreen( |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1888 BPoint(FILL_X(pos.x), FILL_Y(IMData.row + pos.y))); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1889 for (int i=0; i<len; i+=clen) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1890 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1891 cn = utf_ptr2cells((char_u *)(s+i)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1892 clen = utf_ptr2len((char_u *)(s+i)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1893 if (pos.x + cn > W_WIDTH(curwin)) |
19526 | 1894 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1895 pos.y++; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1896 pos.x = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1897 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1898 if (sel_start<=i && i<sel_end) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1899 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1900 SetLowColor(r_highlight); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1901 IMData.location = ConvertToScreen( |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1902 BPoint(FILL_X(pos.x), FILL_Y(IMData.row + pos.y))); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1903 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1904 else |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1905 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1906 SetLowColor(b_highlight); |
19526 | 1907 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1908 r.Set(FILL_X(pos.x), FILL_Y(IMData.row + pos.y), |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1909 FILL_X(pos.x + cn) - PEN_WIDTH, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1910 FILL_Y(IMData.row + pos.y + 1) - PEN_WIDTH); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1911 FillRect(r, B_SOLID_LOW); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1912 where.Set(TEXT_X(pos.x), TEXT_Y(IMData.row + pos.y)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1913 DrawString((s+i), clen, where); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1914 pos.x += cn; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1915 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1916 IMData.count = (int)pos.y; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1917 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1918 SetHighColor(hcolor); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1919 SetLowColor(lcolor); |
19526 | 1920 } |
1921 #endif | |
1922 // ---------------- VimScrollBar ---------------- | |
1923 | |
1924 /* | |
1925 * BUG: XXX | |
1926 * It seems that BScrollBar determine their direction not from | |
1927 * "posture" but from if they are "tall" or "wide" in shape... | |
1928 * | |
1929 * Also, place them out of sight, because Vim enables them before | |
1930 * they are positioned. | |
1931 */ | |
1932 VimScrollBar::VimScrollBar(scrollbar_T *g, orientation posture): | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1933 BScrollBar(posture == B_HORIZONTAL ? BRect(-100,-100,-10,-90) : |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1934 BRect(-100,-100,-90,-10), |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1935 "vim scrollbar", (BView *)NULL, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1936 0.0, 10.0, posture), |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1937 ignoreValue(-1), |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1938 scrollEventCount(0) |
19526 | 1939 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1940 gsb = g; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1941 SetResizingMode(B_FOLLOW_NONE); |
19526 | 1942 } |
1943 | |
1944 VimScrollBar::~VimScrollBar() | |
1945 { | |
1946 } | |
1947 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1948 void |
19526 | 1949 VimScrollBar::ValueChanged(float newValue) |
1950 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1951 if (ignoreValue >= 0.0 && newValue == ignoreValue) { |
19526 | 1952 ignoreValue = -1; |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1953 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1954 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1955 ignoreValue = -1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1956 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1957 * We want to throttle the amount of scroll messages generated. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1958 * Normally I presume you won't get a new message before we've |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1959 * handled the previous one, but because we're passing them on this |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1960 * happens very quickly. So instead we keep a counter of how many |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1961 * scroll events there are (or will be) in the VDCMP, and the |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1962 * throttling happens at the receiving end. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1963 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1964 atomic_add(&scrollEventCount, 1); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1965 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1966 struct VimScrollBarMsg sm; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1967 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1968 sm.sb = this; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1969 sm.value = (long) newValue; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1970 sm.stillDragging = TRUE; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1971 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1972 write_port(gui.vdcmp, VimMsg::ScrollBar, &sm, sizeof(sm)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1973 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1974 // calls gui_drag_scrollbar(sb, newValue, TRUE); |
19526 | 1975 } |
1976 | |
1977 /* | |
1978 * When the mouse goes up, report that scrolling has stopped. | |
1979 * MouseUp() is NOT called when the mouse-up occurs outside | |
1980 * the window, even though the thumb does move while the mouse | |
1981 * is outside... This has some funny effects... XXX | |
1982 * So we do special processing when the window de/activates. | |
1983 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1984 void |
19526 | 1985 VimScrollBar::MouseUp(BPoint where) |
1986 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1987 // BMessage *m = Window()->CurrentMessage(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1988 // m->PrintToStream(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1989 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1990 atomic_add(&scrollEventCount, 1); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1991 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1992 struct VimScrollBarMsg sm; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1993 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1994 sm.sb = this; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1995 sm.value = (long) Value(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1996 sm.stillDragging = FALSE; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1997 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1998 write_port(gui.vdcmp, VimMsg::ScrollBar, &sm, sizeof(sm)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1999 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2000 // calls gui_drag_scrollbar(sb, newValue, FALSE); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2001 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2002 Inherited::MouseUp(where); |
19526 | 2003 } |
2004 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2005 void |
19526 | 2006 VimScrollBar::SetValue(float newValue) |
2007 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2008 if (newValue == Value()) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2009 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2010 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2011 ignoreValue = newValue; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2012 Inherited::SetValue(newValue); |
19526 | 2013 } |
2014 | |
2015 // ---------------- VimFont ---------------- | |
2016 | |
2017 VimFont::VimFont(): BFont() | |
2018 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2019 init(); |
19526 | 2020 } |
2021 | |
2022 VimFont::VimFont(const VimFont *rhs): BFont(rhs) | |
2023 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2024 init(); |
19526 | 2025 } |
2026 | |
2027 VimFont::VimFont(const BFont *rhs): BFont(rhs) | |
2028 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2029 init(); |
19526 | 2030 } |
2031 | |
2032 VimFont::VimFont(const VimFont &rhs): BFont(rhs) | |
2033 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2034 init(); |
19526 | 2035 } |
2036 | |
2037 VimFont::~VimFont() | |
2038 { | |
2039 } | |
2040 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2041 void |
19526 | 2042 VimFont::init() |
2043 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2044 next = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2045 refcount = 1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2046 name = NULL; |
19526 | 2047 } |
2048 | |
2049 // ---------------- VimDialog ---------------- | |
2050 | |
2051 #if defined(FEAT_GUI_DIALOG) | |
2052 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2053 const unsigned int kVimDialogButtonMsg = 'VMDB'; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2054 const unsigned int kVimDialogIconStripeWidth = 30; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2055 const unsigned int kVimDialogButtonsSpacingX = 9; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2056 const unsigned int kVimDialogButtonsSpacingY = 4; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2057 const unsigned int kVimDialogSpacingX = 6; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2058 const unsigned int kVimDialogSpacingY = 10; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2059 const unsigned int kVimDialogMinimalWidth = 310; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2060 const unsigned int kVimDialogMinimalHeight = 75; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2061 const BRect kDefaultRect = |
19526 | 2062 BRect(0, 0, kVimDialogMinimalWidth, kVimDialogMinimalHeight); |
2063 | |
2064 VimDialog::VimDialog(int type, const char *title, const char *message, | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2065 const char *buttons, int dfltbutton, const char *textfield, int ex_cmd) |
19526 | 2066 : BWindow(kDefaultRect, title, B_TITLED_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL, |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2067 B_NOT_CLOSABLE | B_NOT_RESIZABLE | |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2068 B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_ASYNCHRONOUS_CONTROLS) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2069 , fDialogSem(-1) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2070 , fDialogValue(dfltbutton) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2071 , fMessageView(NULL) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2072 , fInputControl(NULL) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2073 , fInputValue(textfield) |
19526 | 2074 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2075 // master view |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2076 VimDialog::View* view = new VimDialog::View(Bounds()); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2077 if (view == NULL) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2078 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2079 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2080 if (title == NULL) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2081 SetTitle("Vim " VIM_VERSION_MEDIUM); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2082 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2083 AddChild(view); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2084 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2085 // icon |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2086 view->InitIcon(type); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2087 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2088 // buttons |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2089 int32 which = 1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2090 float maxButtonWidth = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2091 float maxButtonHeight = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2092 float buttonsWidth = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2093 float buttonsHeight = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2094 BString strButtons(buttons); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2095 strButtons.RemoveAll("&"); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2096 do { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2097 int32 end = strButtons.FindFirst('\n'); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2098 if (end != B_ERROR) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2099 strButtons.SetByteAt(end, '\0'); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2100 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2101 BButton *button = _CreateButton(which++, strButtons.String()); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2102 view->AddChild(button); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2103 fButtonsList.AddItem(button); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2104 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2105 maxButtonWidth = max_c(maxButtonWidth, button->Bounds().Width()); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2106 maxButtonHeight = max_c(maxButtonHeight, button->Bounds().Height()); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2107 buttonsWidth += button->Bounds().Width(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2108 buttonsHeight += button->Bounds().Height(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2109 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2110 if (end == B_ERROR) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2111 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2112 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2113 strButtons.Remove(0, end + 1); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2114 } while (true); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2115 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2116 int32 buttonsCount = fButtonsList.CountItems(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2117 buttonsWidth += kVimDialogButtonsSpacingX * (buttonsCount - 1); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2118 buttonsHeight += kVimDialogButtonsSpacingY * (buttonsCount - 1); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2119 float dialogWidth = buttonsWidth + kVimDialogIconStripeWidth + |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2120 kVimDialogSpacingX * 2; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2121 float dialogHeight = maxButtonHeight + kVimDialogSpacingY * 3; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2122 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2123 // Check 'v' flag in 'guioptions': vertical button placement. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2124 bool vertical = (vim_strchr(p_go, GO_VERTICAL) != NULL) || |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2125 dialogWidth >= gui.vimWindow->Bounds().Width(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2126 if (vertical) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2127 dialogWidth -= buttonsWidth; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2128 dialogWidth += maxButtonWidth; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2129 dialogHeight -= maxButtonHeight; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2130 dialogHeight += buttonsHeight; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2131 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2132 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2133 dialogWidth = max_c(dialogWidth, kVimDialogMinimalWidth); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2134 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2135 // message view |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2136 BRect rect(0, 0, dialogWidth, 0); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2137 rect.left += kVimDialogIconStripeWidth + 16 + kVimDialogSpacingX; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2138 rect.top += kVimDialogSpacingY; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2139 rect.right -= kVimDialogSpacingX; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2140 rect.bottom = rect.top; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2141 fMessageView = new BTextView(rect, "_tv_", rect.OffsetByCopy(B_ORIGIN), |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2142 B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2143 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2144 fMessageView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2145 rgb_color textColor = ui_color(B_PANEL_TEXT_COLOR); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2146 fMessageView->SetFontAndColor(be_plain_font, B_FONT_ALL, &textColor); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2147 fMessageView->SetText(message); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2148 fMessageView->MakeEditable(false); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2149 fMessageView->MakeSelectable(false); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2150 fMessageView->SetWordWrap(true); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2151 AddChild(fMessageView); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2152 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2153 float messageHeight = fMessageView->TextHeight(0, fMessageView->CountLines()); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2154 fMessageView->ResizeBy(0, messageHeight); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2155 fMessageView->SetTextRect(BRect(0, 0, rect.Width(), messageHeight)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2156 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2157 dialogHeight += messageHeight; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2158 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2159 // input view |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2160 if (fInputValue != NULL) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2161 rect.top = |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2162 rect.bottom += messageHeight + kVimDialogSpacingY; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2163 fInputControl = new BTextControl(rect, "_iv_", NULL, fInputValue, NULL, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2164 B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE | B_PULSE_NEEDED); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2165 fInputControl->TextView()->SetText(fInputValue); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2166 fInputControl->TextView()->SetWordWrap(false); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2167 AddChild(fInputControl); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2168 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2169 float width = 0.f, height = 0.f; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2170 fInputControl->GetPreferredSize(&width, &height); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2171 fInputControl->MakeFocus(true); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2172 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2173 dialogHeight += height + kVimDialogSpacingY * 1.5; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2174 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2175 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2176 dialogHeight = max_c(dialogHeight, kVimDialogMinimalHeight); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2177 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2178 ResizeTo(dialogWidth, dialogHeight); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2179 MoveTo((gui.vimWindow->Bounds().Width() - dialogWidth) / 2, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2180 (gui.vimWindow->Bounds().Height() - dialogHeight) / 2); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2181 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2182 // adjust layout of buttons |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2183 float buttonWidth = max_c(maxButtonWidth, rect.Width() * 0.66); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2184 BPoint origin(dialogWidth, dialogHeight); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2185 origin.x -= kVimDialogSpacingX + (vertical ? buttonWidth : buttonsWidth); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2186 origin.y -= kVimDialogSpacingY + (vertical ? buttonsHeight : maxButtonHeight); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2187 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2188 for (int32 i = 0 ; i < buttonsCount; i++) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2189 BButton *button = (BButton*)fButtonsList.ItemAt(i); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2190 button->MoveTo(origin); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2191 if (vertical) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2192 origin.y += button->Frame().Height() + kVimDialogButtonsSpacingY; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2193 button->ResizeTo(buttonWidth, button->Frame().Height()); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2194 } else |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2195 origin.x += button->Frame().Width() + kVimDialogButtonsSpacingX; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2196 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2197 if (dfltbutton == i + 1) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2198 button->MakeDefault(true); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2199 button->MakeFocus(fInputControl == NULL); |
19526 | 2200 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2201 } |
19526 | 2202 } |
2203 | |
2204 VimDialog::~VimDialog() | |
2205 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2206 if (fDialogSem > B_OK) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2207 delete_sem(fDialogSem); |
19526 | 2208 } |
2209 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2210 int |
19526 | 2211 VimDialog::Go() |
2212 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2213 fDialogSem = create_sem(0, "VimDialogSem"); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2214 if (fDialogSem < B_OK) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2215 Quit(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2216 return fDialogValue; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2217 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2218 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2219 Show(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2220 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2221 while (acquire_sem(fDialogSem) == B_INTERRUPTED); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2222 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2223 int retValue = fDialogValue; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2224 if (fInputValue != NULL) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2225 vim_strncpy((char_u*)fInputValue, (char_u*)fInputControl->Text(), IOSIZE - 1); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2226 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2227 if (Lock()) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2228 Quit(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2229 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2230 return retValue; |
19526 | 2231 } |
2232 | |
2233 void VimDialog::MessageReceived(BMessage *msg) | |
2234 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2235 int32 which = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2236 if (msg->what != kVimDialogButtonMsg || |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2237 msg->FindInt32("which", &which) != B_OK) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2238 return BWindow::MessageReceived(msg); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2239 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2240 fDialogValue = which; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2241 delete_sem(fDialogSem); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2242 fDialogSem = -1; |
19526 | 2243 } |
2244 | |
2245 BButton* VimDialog::_CreateButton(int32 which, const char* label) | |
2246 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2247 BMessage *message = new BMessage(kVimDialogButtonMsg); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2248 message->AddInt32("which", which); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2249 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2250 BRect rect(0, 0, 0, 0); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2251 BString name; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2252 name << "_b" << which << "_"; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2253 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2254 BButton* button = new BButton(rect, name.String(), label, message, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2255 B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2256 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2257 float width = 0.f, height = 0.f; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2258 button->GetPreferredSize(&width, &height); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2259 button->ResizeTo(width, height); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2260 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2261 return button; |
19526 | 2262 } |
2263 | |
2264 VimDialog::View::View(BRect frame) | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2265 : BView(frame, "VimDialogView", B_FOLLOW_ALL_SIDES, B_WILL_DRAW), |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2266 fIconBitmap(NULL) |
19526 | 2267 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2268 SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); |
19526 | 2269 } |
2270 | |
2271 VimDialog::View::~View() | |
2272 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2273 delete fIconBitmap; |
19526 | 2274 } |
2275 | |
2276 void VimDialog::View::Draw(BRect updateRect) | |
2277 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2278 BRect stripeRect = Bounds(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2279 stripeRect.right = kVimDialogIconStripeWidth; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2280 SetHighColor(tint_color(ViewColor(), B_DARKEN_1_TINT)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2281 FillRect(stripeRect); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2282 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2283 if (fIconBitmap == NULL) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2284 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2285 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2286 SetDrawingMode(B_OP_ALPHA); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2287 SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2288 DrawBitmapAsync(fIconBitmap, BPoint(18, 6)); |
19526 | 2289 } |
2290 | |
2291 void VimDialog::View::InitIcon(int32 type) | |
2292 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2293 if (type == VIM_GENERIC) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2294 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2295 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2296 BPath path; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2297 status_t status = find_directory(B_BEOS_SERVERS_DIRECTORY, &path); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2298 if (status != B_OK) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2299 fprintf(stderr, "Cannot retrieve app info:%s\n", strerror(status)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2300 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2301 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2302 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2303 path.Append("app_server"); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2304 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2305 BFile file(path.Path(), O_RDONLY); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2306 if (file.InitCheck() != B_OK) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2307 fprintf(stderr, "App file assignment failed:%s\n", |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2308 strerror(file.InitCheck())); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2309 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2310 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2311 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2312 BResources resources(&file); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2313 if (resources.InitCheck() != B_OK) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2314 fprintf(stderr, "App server resources assignment failed:%s\n", |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2315 strerror(resources.InitCheck())); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2316 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2317 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2318 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2319 const char *name = ""; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2320 switch(type) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2321 case VIM_ERROR: name = "stop"; break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2322 case VIM_WARNING: name = "warn"; break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2323 case VIM_INFO: name = "info"; break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2324 case VIM_QUESTION: name = "idea"; break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2325 default: return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2326 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2327 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2328 int32 iconSize = 32; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2329 fIconBitmap = new BBitmap(BRect(0, 0, iconSize - 1, iconSize - 1), 0, B_RGBA32); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2330 if (fIconBitmap == NULL || fIconBitmap->InitCheck() != B_OK) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2331 fprintf(stderr, "Icon bitmap allocation failed:%s\n", |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2332 (fIconBitmap == NULL) ? "null" : strerror(fIconBitmap->InitCheck())); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2333 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2334 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2335 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2336 size_t size = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2337 const uint8* iconData = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2338 // try vector icon first? |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2339 iconData = (const uint8*)resources.LoadResource(B_VECTOR_ICON_TYPE, name, &size); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2340 if (iconData != NULL && BIconUtils::GetVectorIcon(iconData, size, fIconBitmap) == B_OK) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2341 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2342 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2343 // try bitmap icon now |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2344 iconData = (const uint8*)resources.LoadResource(B_LARGE_ICON_TYPE, name, &size); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2345 if (iconData == NULL) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2346 fprintf(stderr, "Bitmap icon resource not found\n"); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2347 delete fIconBitmap; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2348 fIconBitmap = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2349 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2350 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2351 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2352 if (fIconBitmap->ColorSpace() != B_CMAP8) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2353 BIconUtils::ConvertFromCMAP8(iconData, iconSize, iconSize, iconSize, fIconBitmap); |
19526 | 2354 } |
2355 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2356 const unsigned int kVimDialogOKButtonMsg = 'FDOK'; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2357 const unsigned int kVimDialogCancelButtonMsg = 'FDCN'; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2358 const unsigned int kVimDialogSizeInputMsg = 'SICH'; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2359 const unsigned int kVimDialogFamilySelectMsg = 'MSFM'; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2360 const unsigned int kVimDialogStyleSelectMsg = 'MSST'; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2361 const unsigned int kVimDialogSizeSelectMsg = 'MSSZ'; |
19526 | 2362 |
2363 VimSelectFontDialog::VimSelectFontDialog(font_family* family, font_style* style, float* size) | |
2364 : BWindow(kDefaultRect, "Font Selection", B_TITLED_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL, | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2365 B_NOT_CLOSABLE | B_NOT_RESIZABLE | |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2366 B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_ASYNCHRONOUS_CONTROLS) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2367 , fStatus(B_NO_INIT) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2368 , fDialogSem(-1) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2369 , fDialogValue(false) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2370 , fFamily(family) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2371 , fStyle(style) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2372 , fSize(size) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2373 , fFontSize(*size) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2374 , fPreview(0) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2375 , fFamiliesList(0) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2376 , fStylesList(0) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2377 , fSizesList(0) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2378 , fSizesInput(0) |
19526 | 2379 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2380 strncpy(fFontFamily, *family, B_FONT_FAMILY_LENGTH); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2381 strncpy(fFontStyle, *style, B_FONT_STYLE_LENGTH); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2382 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2383 // "client" area view |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2384 BBox *clientBox = new BBox(Bounds(), B_EMPTY_STRING, B_FOLLOW_ALL_SIDES, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2385 B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP | B_PULSE_NEEDED, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2386 B_PLAIN_BORDER); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2387 AddChild(clientBox); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2388 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2389 // client view |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2390 BRect RC = clientBox->Bounds(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2391 RC.InsetBy(kVimDialogSpacingX, kVimDialogSpacingY); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2392 BRect rc(RC.LeftTop(), RC.LeftTop()); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2393 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2394 // at first create all controls |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2395 fPreview = new BStringView(rc, "preview", "DejaVu Sans Mono"); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2396 clientBox->AddChild(fPreview); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2397 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2398 BBox* boxDivider = new BBox(rc, B_EMPTY_STRING, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2399 B_FOLLOW_NONE, B_WILL_DRAW, B_FANCY_BORDER); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2400 clientBox->AddChild(boxDivider); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2401 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2402 BStringView *labelFamily = new BStringView(rc, "labelFamily", "Family:"); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2403 clientBox->AddChild(labelFamily); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2404 labelFamily->ResizeToPreferred(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2405 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2406 BStringView *labelStyle = new BStringView(rc, "labelStyle", "Style:"); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2407 clientBox->AddChild(labelStyle); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2408 labelStyle->ResizeToPreferred(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2409 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2410 BStringView *labelSize = new BStringView(rc, "labelSize", "Size:"); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2411 clientBox->AddChild(labelSize); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2412 labelSize->ResizeToPreferred(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2413 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2414 fFamiliesList = new BListView(rc, "listFamily", |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2415 B_SINGLE_SELECTION_LIST, B_FOLLOW_ALL_SIDES); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2416 BScrollView *scrollFamilies = new BScrollView("scrollFamily", |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2417 fFamiliesList, B_FOLLOW_LEFT_RIGHT, 0, false, true); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2418 clientBox->AddChild(scrollFamilies); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2419 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2420 fStylesList= new BListView(rc, "listStyles", |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2421 B_SINGLE_SELECTION_LIST, B_FOLLOW_ALL_SIDES); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2422 BScrollView *scrollStyles = new BScrollView("scrollStyle", |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2423 fStylesList, B_FOLLOW_LEFT_RIGHT, 0, false, true); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2424 clientBox->AddChild(scrollStyles); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2425 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2426 fSizesInput = new BTextControl(rc, "inputSize", NULL, "???", |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2427 new BMessage(kVimDialogSizeInputMsg)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2428 clientBox->AddChild(fSizesInput); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2429 fSizesInput->ResizeToPreferred(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2430 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2431 fSizesList = new BListView(rc, "listSizes", |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2432 B_SINGLE_SELECTION_LIST, B_FOLLOW_ALL_SIDES); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2433 BScrollView *scrollSizes = new BScrollView("scrollSize", |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2434 fSizesList, B_FOLLOW_LEFT_RIGHT, 0, false, true); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2435 clientBox->AddChild(scrollSizes); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2436 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2437 BButton *buttonOK = new BButton(rc, "buttonOK", "OK", |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2438 new BMessage(kVimDialogOKButtonMsg)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2439 clientBox->AddChild(buttonOK); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2440 buttonOK->ResizeToPreferred(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2441 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2442 BButton *buttonCancel = new BButton(rc, "buttonCancel", "Cancel", |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2443 new BMessage(kVimDialogCancelButtonMsg)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2444 clientBox->AddChild(buttonCancel); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2445 buttonCancel->ResizeToPreferred(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2446 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2447 // layout controls |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2448 float lineHeight = labelFamily->Bounds().Height(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2449 float previewHeight = lineHeight * 3; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2450 float offsetYLabels = previewHeight + kVimDialogSpacingY; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2451 float offsetYLists = offsetYLabels + lineHeight + kVimDialogSpacingY / 2; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2452 float offsetYSizes = offsetYLists + fSizesInput->Bounds().Height() + kVimDialogSpacingY / 2; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2453 float listsHeight = lineHeight * 9; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2454 float offsetYButtons = offsetYLists + listsHeight + kVimDialogSpacingY; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2455 float maxControlsHeight = offsetYButtons + buttonOK->Bounds().Height(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2456 float familiesWidth = labelFamily->Bounds().Width() * 5; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2457 float offsetXStyles = familiesWidth + kVimDialogSpacingX; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2458 float stylesWidth = labelStyle->Bounds().Width() * 4; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2459 float offsetXSizes = offsetXStyles + stylesWidth + kVimDialogSpacingX; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2460 float sizesWidth = labelSize->Bounds().Width() * 2; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2461 float maxControlsWidth = offsetXSizes + sizesWidth; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2462 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2463 ResizeTo(maxControlsWidth + kVimDialogSpacingX * 2, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2464 maxControlsHeight + kVimDialogSpacingY * 2); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2465 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2466 BRect rcVim = gui.vimWindow->Frame(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2467 MoveTo(rcVim.left + (rcVim.Width() - Frame().Width()) / 2, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2468 rcVim.top + (rcVim.Height() - Frame().Height()) / 2); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2469 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2470 fPreview->ResizeTo(maxControlsWidth, previewHeight); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2471 fPreview->SetAlignment(B_ALIGN_CENTER); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2472 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2473 boxDivider->MoveBy(0.f, previewHeight + kVimDialogSpacingY / 2); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2474 boxDivider->ResizeTo(maxControlsWidth, 1.f); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2475 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2476 labelFamily->MoveBy(0.f, offsetYLabels); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2477 labelStyle->MoveBy(offsetXStyles, offsetYLabels); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2478 labelSize->MoveBy(offsetXSizes, offsetYLabels); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2479 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2480 // text control alignment issues |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2481 float insetX = fSizesInput->TextView()->Bounds().Width() - fSizesInput->Bounds().Width(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2482 float insetY = fSizesInput->TextView()->Bounds().Width() - fSizesInput->Bounds().Width(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2483 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2484 scrollFamilies->MoveBy(0.f, offsetYLists); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2485 scrollStyles->MoveBy(offsetXStyles, offsetYLists); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2486 fSizesInput->MoveBy(offsetXSizes + insetX / 2, offsetYLists + insetY / 2); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2487 scrollSizes->MoveBy(offsetXSizes, offsetYSizes); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2488 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2489 fSizesInput->SetAlignment(B_ALIGN_CENTER, B_ALIGN_CENTER); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2490 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2491 scrollFamilies->ResizeTo(familiesWidth, listsHeight); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2492 scrollStyles->ResizeTo(stylesWidth, listsHeight); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2493 fSizesInput->ResizeTo(sizesWidth, fSizesInput->Bounds().Height()); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2494 scrollSizes->ResizeTo(sizesWidth, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2495 listsHeight - (offsetYSizes - offsetYLists)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2496 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2497 buttonOK->MoveBy(maxControlsWidth - buttonOK->Bounds().Width(), offsetYButtons); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2498 buttonCancel->MoveBy(maxControlsWidth - buttonOK->Bounds().Width() |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2499 - buttonCancel->Bounds().Width() - kVimDialogSpacingX, offsetYButtons); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2500 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2501 // fill lists |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2502 int selIndex = -1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2503 int count = count_font_families(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2504 for (int i = 0; i < count; i++) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2505 font_family family; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2506 if (get_font_family(i, &family ) == B_OK) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2507 fFamiliesList->AddItem(new BStringItem((const char*)family)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2508 if (strncmp(family, fFontFamily, B_FONT_FAMILY_LENGTH) == 0) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2509 selIndex = i; |
19526 | 2510 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2511 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2512 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2513 if (selIndex >= 0) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2514 fFamiliesList->Select(selIndex); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2515 fFamiliesList->ScrollToSelection(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2516 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2517 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2518 _UpdateFontStyles(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2519 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2520 selIndex = -1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2521 for (int size = 8, index = 0; size <= 18; size++, index++) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2522 BString str; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2523 str << size; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2524 fSizesList->AddItem(new BStringItem(str)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2525 if (size == fFontSize) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2526 selIndex = index; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2527 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2528 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2529 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2530 if (selIndex >= 0) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2531 fSizesList->Select(selIndex); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2532 fSizesList->ScrollToSelection(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2533 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2534 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2535 fFamiliesList->SetSelectionMessage(new BMessage(kVimDialogFamilySelectMsg)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2536 fStylesList->SetSelectionMessage(new BMessage(kVimDialogStyleSelectMsg)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2537 fSizesList->SetSelectionMessage(new BMessage(kVimDialogSizeSelectMsg)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2538 fSizesInput->SetModificationMessage(new BMessage(kVimDialogSizeInputMsg)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2539 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2540 _UpdateSizeInputPreview(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2541 _UpdateFontPreview(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2542 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2543 fStatus = B_OK; |
19526 | 2544 } |
2545 | |
2546 VimSelectFontDialog::~VimSelectFontDialog() | |
2547 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2548 _CleanList(fFamiliesList); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2549 _CleanList(fStylesList); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2550 _CleanList(fSizesList); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2551 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2552 if (fDialogSem > B_OK) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2553 delete_sem(fDialogSem); |
19526 | 2554 } |
2555 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2556 void |
19526 | 2557 VimSelectFontDialog::_CleanList(BListView* list) |
2558 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2559 while (0 < list->CountItems()) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2560 delete (dynamic_cast<BStringItem*>(list->RemoveItem((int32)0))); |
19526 | 2561 } |
2562 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2563 bool |
19526 | 2564 VimSelectFontDialog::Go() |
2565 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2566 if (fStatus != B_OK) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2567 Quit(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2568 return NOFONT; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2569 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2570 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2571 fDialogSem = create_sem(0, "VimFontSelectDialogSem"); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2572 if (fDialogSem < B_OK) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2573 Quit(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2574 return fDialogValue; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2575 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2576 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2577 Show(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2578 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2579 while (acquire_sem(fDialogSem) == B_INTERRUPTED); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2580 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2581 bool retValue = fDialogValue; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2582 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2583 if (Lock()) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2584 Quit(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2585 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2586 return retValue; |
19526 | 2587 } |
2588 | |
2589 | |
2590 void VimSelectFontDialog::_UpdateFontStyles() | |
2591 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2592 _CleanList(fStylesList); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2593 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2594 int32 selIndex = -1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2595 int32 count = count_font_styles(fFontFamily); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2596 for (int32 i = 0; i < count; i++) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2597 font_style style; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2598 uint32 flags = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2599 if (get_font_style(fFontFamily, i, &style, &flags) == B_OK) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2600 fStylesList->AddItem(new BStringItem((const char*)style)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2601 if (strncmp(style, fFontStyle, B_FONT_STYLE_LENGTH) == 0) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2602 selIndex = i; |
19526 | 2603 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2604 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2605 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2606 if (selIndex >= 0) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2607 fStylesList->Select(selIndex); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2608 fStylesList->ScrollToSelection(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2609 } else |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2610 fStylesList->Select(0); |
19526 | 2611 } |
2612 | |
2613 | |
2614 void VimSelectFontDialog::_UpdateSizeInputPreview() | |
2615 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2616 char buf[10] = {0}; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2617 vim_snprintf(buf, sizeof(buf), (char*)"%.0f", fFontSize); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2618 fSizesInput->SetText(buf); |
19526 | 2619 } |
2620 | |
2621 | |
2622 void VimSelectFontDialog::_UpdateFontPreview() | |
2623 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2624 BFont font; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2625 fPreview->GetFont(&font); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2626 font.SetSize(fFontSize); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2627 font.SetFamilyAndStyle(fFontFamily, fFontStyle); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2628 fPreview->SetFont(&font, B_FONT_FAMILY_AND_STYLE | B_FONT_SIZE); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2629 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2630 BString str; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2631 str << fFontFamily << " " << fFontStyle << ", " << (int)fFontSize << " pt."; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2632 fPreview->SetText(str); |
19526 | 2633 } |
2634 | |
2635 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2636 bool |
19526 | 2637 VimSelectFontDialog::_UpdateFromListItem(BListView* list, char* text, int textSize) |
2638 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2639 int32 index = list->CurrentSelection(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2640 if (index < 0) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2641 return false; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2642 BStringItem* item = (BStringItem*)list->ItemAt(index); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2643 if (item == NULL) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2644 return false; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2645 strncpy(text, item->Text(), textSize); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2646 return true; |
19526 | 2647 } |
2648 | |
2649 | |
2650 void VimSelectFontDialog::MessageReceived(BMessage *msg) | |
2651 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2652 switch (msg->what) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2653 case kVimDialogOKButtonMsg: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2654 strncpy(*fFamily, fFontFamily, B_FONT_FAMILY_LENGTH); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2655 strncpy(*fStyle, fFontStyle, B_FONT_STYLE_LENGTH); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2656 *fSize = fFontSize; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2657 fDialogValue = true; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2658 case kVimDialogCancelButtonMsg: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2659 delete_sem(fDialogSem); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2660 fDialogSem = -1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2661 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2662 case B_KEY_UP: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2663 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2664 int32 key = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2665 if (msg->FindInt32("raw_char", &key) == B_OK |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2666 && key == B_ESCAPE) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2667 delete_sem(fDialogSem); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2668 fDialogSem = -1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2669 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2670 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2671 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2672 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2673 case kVimDialogFamilySelectMsg: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2674 if (_UpdateFromListItem(fFamiliesList, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2675 fFontFamily, B_FONT_FAMILY_LENGTH)) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2676 _UpdateFontStyles(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2677 _UpdateFontPreview(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2678 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2679 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2680 case kVimDialogStyleSelectMsg: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2681 if (_UpdateFromListItem(fStylesList, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2682 fFontStyle, B_FONT_STYLE_LENGTH)) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2683 _UpdateFontPreview(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2684 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2685 case kVimDialogSizeSelectMsg: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2686 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2687 char buf[10] = {0}; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2688 if (_UpdateFromListItem(fSizesList, buf, sizeof(buf))) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2689 float size = atof(buf); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2690 if (size > 0.f) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2691 fFontSize = size; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2692 _UpdateSizeInputPreview(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2693 _UpdateFontPreview(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2694 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2695 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2696 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2697 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2698 case kVimDialogSizeInputMsg: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2699 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2700 float size = atof(fSizesInput->Text()); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2701 if (size > 0.f) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2702 fFontSize = size; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2703 _UpdateFontPreview(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2704 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2705 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2706 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2707 default: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2708 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2709 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2710 return BWindow::MessageReceived(msg); |
19526 | 2711 } |
2712 | |
2713 #endif // FEAT_GUI_DIALOG | |
2714 | |
2715 #ifdef FEAT_TOOLBAR | |
2716 | |
2717 // some forward declaration required by toolbar functions... | |
2718 static BMessage * MenuMessage(vimmenu_T *menu); | |
2719 | |
2720 VimToolbar::VimToolbar(BRect frame, const char *name) : | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2721 BBox(frame, name, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_FRAME_EVENTS, B_PLAIN_BORDER) |
19526 | 2722 { |
2723 } | |
2724 | |
2725 VimToolbar::~VimToolbar() | |
2726 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2727 int32 count = fButtonsList.CountItems(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2728 for (int32 i = 0; i < count; i++) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2729 delete (BPictureButton*)fButtonsList.ItemAt(i); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2730 fButtonsList.MakeEmpty(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2731 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2732 delete normalButtonsBitmap; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2733 delete grayedButtonsBitmap; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2734 normalButtonsBitmap = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2735 grayedButtonsBitmap = NULL; |
19526 | 2736 } |
2737 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2738 void |
19526 | 2739 VimToolbar::AttachedToWindow() |
2740 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2741 BBox::AttachedToWindow(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2742 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2743 SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); |
19526 | 2744 } |
2745 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2746 float |
19526 | 2747 VimToolbar::ToolbarHeight() const |
2748 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2749 float size = NULL == normalButtonsBitmap ? 18. : normalButtonsBitmap->Bounds().Height(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2750 return size + ToolbarMargin * 2 + ButtonMargin * 2 + 1; |
19526 | 2751 } |
2752 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2753 bool |
19526 | 2754 VimToolbar::ModifyBitmapToGrayed(BBitmap *bitmap) |
2755 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2756 float height = bitmap->Bounds().Height(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2757 float width = bitmap->Bounds().Width(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2758 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2759 rgb_color *bits = (rgb_color*)bitmap->Bits(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2760 int32 pixels = bitmap->BitsLength() / 4; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2761 for (int32 i = 0; i < pixels; i++) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2762 bits[i].red = bits[i].green = |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2763 bits[i].blue = ((uint32)bits[i].red + bits[i].green + bits[i].blue) / 3; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2764 bits[i].alpha /= 4; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2765 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2766 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2767 return true; |
19526 | 2768 } |
2769 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2770 bool |
19526 | 2771 VimToolbar::PrepareButtonBitmaps() |
2772 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2773 // first try to load potentially customized $VIRUNTIME/bitmaps/builtin-tools.png |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2774 normalButtonsBitmap = LoadVimBitmap("builtin-tools.png"); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2775 if (normalButtonsBitmap == NULL) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2776 // customized not found? dig application resources for "builtin-tools" one |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2777 normalButtonsBitmap = BTranslationUtils::GetBitmap(B_PNG_FORMAT, "builtin-tools"); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2778 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2779 if (normalButtonsBitmap == NULL) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2780 return false; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2781 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2782 BMessage archive; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2783 normalButtonsBitmap->Archive(&archive); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2784 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2785 grayedButtonsBitmap = new BBitmap(&archive); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2786 if (grayedButtonsBitmap == NULL) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2787 return false; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2788 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2789 // modify grayed bitmap |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2790 ModifyBitmapToGrayed(grayedButtonsBitmap); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2791 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2792 return true; |
19526 | 2793 } |
2794 | |
2795 BBitmap *VimToolbar::LoadVimBitmap(const char* fileName) | |
2796 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2797 BBitmap *bitmap = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2798 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2799 int mustfree = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2800 char_u* runtimePath = vim_getenv((char_u*)"VIMRUNTIME", &mustfree); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2801 if (runtimePath != NULL && fileName != NULL) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2802 BString strPath((char*)runtimePath); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2803 strPath << "/bitmaps/" << fileName; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2804 bitmap = BTranslationUtils::GetBitmap(strPath.String()); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2805 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2806 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2807 if (mustfree) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2808 vim_free(runtimePath); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2809 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2810 return bitmap; |
19526 | 2811 } |
2812 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2813 bool |
19526 | 2814 VimToolbar::GetPictureFromBitmap(BPicture *pictureTo, int32 index, BBitmap *bitmapFrom, bool pressed) |
2815 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2816 float size = bitmapFrom->Bounds().Height() + 1.; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2817 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2818 BView view(BRect(0, 0, size, size), "", 0, 0); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2819 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2820 AddChild(&view); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2821 view.BeginPicture(pictureTo); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2822 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2823 view.SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2824 view.FillRect(view.Bounds()); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2825 view.SetDrawingMode(B_OP_OVER); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2826 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2827 BRect source(0, 0, size - 1, size - 1); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2828 BRect destination(source); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2829 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2830 source.OffsetBy(size * index, 0); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2831 destination.OffsetBy(ButtonMargin, ButtonMargin); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2832 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2833 view.DrawBitmap(bitmapFrom, source, destination); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2834 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2835 if (pressed) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2836 rgb_color shineColor = ui_color(B_SHINE_COLOR); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2837 rgb_color shadowColor = ui_color(B_SHADOW_COLOR); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2838 size += ButtonMargin * 2 - 1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2839 view.BeginLineArray(4); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2840 view.AddLine(BPoint(0, 0), BPoint(size, 0), shadowColor); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2841 view.AddLine(BPoint(size, 0), BPoint(size, size), shineColor); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2842 view.AddLine(BPoint(size, size), BPoint(0, size), shineColor); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2843 view.AddLine(BPoint(0, size), BPoint(0, 0), shadowColor); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2844 view.EndLineArray(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2845 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2846 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2847 view.EndPicture(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2848 RemoveChild(&view); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2849 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2850 return true; |
19526 | 2851 } |
2852 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2853 bool |
19526 | 2854 VimToolbar::AddButton(int32 index, vimmenu_T *menu) |
2855 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2856 BPictureButton *button = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2857 if (!menu_is_separator(menu->name)) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2858 float size = normalButtonsBitmap ? |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2859 normalButtonsBitmap->Bounds().Height() + 1. + ButtonMargin * 2 : 18.; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2860 BRect frame(0, 0, size, size); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2861 BPicture pictureOn; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2862 BPicture pictureOff; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2863 BPicture pictureGray; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2864 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2865 if (menu->iconfile == NULL && menu->iconidx >= 0 && normalButtonsBitmap) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2866 GetPictureFromBitmap(&pictureOn, menu->iconidx, normalButtonsBitmap, true); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2867 GetPictureFromBitmap(&pictureOff, menu->iconidx, normalButtonsBitmap, false); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2868 GetPictureFromBitmap(&pictureGray, menu->iconidx, grayedButtonsBitmap, false); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2869 } else { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2870 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2871 char_u buffer[MAXPATHL] = {0}; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2872 BBitmap *bitmap = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2873 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2874 if (menu->iconfile) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2875 gui_find_iconfile(menu->iconfile, buffer, (char*)"png"); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2876 bitmap = BTranslationUtils::GetBitmap((char*)buffer); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2877 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2878 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2879 if (bitmap == NULL && gui_find_bitmap(menu->name, buffer, (char*)"png") == OK) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2880 bitmap = BTranslationUtils::GetBitmap((char*)buffer); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2881 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2882 if (bitmap == NULL) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2883 bitmap = new BBitmap(BRect(0, 0, size, size), B_RGB32); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2884 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2885 GetPictureFromBitmap(&pictureOn, 0, bitmap, true); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2886 GetPictureFromBitmap(&pictureOff, 0, bitmap, false); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2887 ModifyBitmapToGrayed(bitmap); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2888 GetPictureFromBitmap(&pictureGray, 0, bitmap, false); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2889 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2890 delete bitmap; |
19526 | 2891 } |
2892 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2893 button = new BPictureButton(frame, (char*)menu->name, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2894 &pictureOff, &pictureOn, MenuMessage(menu)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2895 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2896 button->SetDisabledOn(&pictureGray); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2897 button->SetDisabledOff(&pictureGray); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2898 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2899 button->SetTarget(gui.vimTextArea); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2900 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2901 AddChild(button); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2902 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2903 menu->button = button; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2904 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2905 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2906 bool result = fButtonsList.AddItem(button, index); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2907 InvalidateLayout(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2908 return result; |
19526 | 2909 } |
2910 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2911 bool |
19526 | 2912 VimToolbar::RemoveButton(vimmenu_T *menu) |
2913 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2914 if (menu->button) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2915 if (fButtonsList.RemoveItem(menu->button)) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2916 delete menu->button; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2917 menu->button = NULL; |
19526 | 2918 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2919 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2920 return true; |
19526 | 2921 } |
2922 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2923 bool |
19526 | 2924 VimToolbar::GrayButton(vimmenu_T *menu, int grey) |
2925 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2926 if (menu->button) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2927 int32 index = fButtonsList.IndexOf(menu->button); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2928 if (index >= 0) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2929 menu->button->SetEnabled(grey ? false : true); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2930 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2931 return true; |
19526 | 2932 } |
2933 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2934 void |
19526 | 2935 VimToolbar::InvalidateLayout() |
2936 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2937 int32 offset = ToolbarMargin; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2938 int32 count = fButtonsList.CountItems(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2939 for (int32 i = 0; i < count; i++) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2940 BPictureButton *button = (BPictureButton *)fButtonsList.ItemAt(i); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2941 if (button) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2942 button->MoveTo(offset, ToolbarMargin); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2943 offset += button->Bounds().Width() + ToolbarMargin; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2944 } else |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2945 offset += ToolbarMargin * 3; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2946 } |
19526 | 2947 } |
2948 | |
2949 #endif /*FEAT_TOOLBAR*/ | |
2950 | |
2951 #if defined(FEAT_GUI_TABLINE) | |
2952 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2953 float |
19526 | 2954 VimTabLine::TablineHeight() const |
2955 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2956 // float size = NULL == normalButtonsBitmap ? 18. : normalButtonsBitmap->Bounds().Height(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2957 // return size + ToolbarMargin * 2 + ButtonMargin * 2 + 1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2958 return TabHeight(); // + ToolbarMargin; |
19526 | 2959 } |
2960 | |
2961 void | |
2962 VimTabLine::MouseDown(BPoint point) | |
2963 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2964 if (!gui_mch_showing_tabline()) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2965 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2966 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2967 BMessage *m = Window()->CurrentMessage(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2968 assert(m); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2969 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2970 int32 buttons = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2971 m->FindInt32("buttons", &buttons); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2972 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2973 int32 clicks = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2974 m->FindInt32("clicks", &clicks); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2975 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2976 int index = 0; // 0 means here - no tab found |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2977 for (int i = 0; i < CountTabs(); i++) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2978 if (TabFrame(i).Contains(point)) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2979 index = i + 1; // indexes are 1-based |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2980 break; |
19526 | 2981 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2982 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2983 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2984 int event = -1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2985 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2986 if ((buttons & B_PRIMARY_MOUSE_BUTTON) && clicks > 1) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2987 // left button double click on - create new tab |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2988 event = TABLINE_MENU_NEW; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2989 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2990 else if (buttons & B_TERTIARY_MOUSE_BUTTON) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2991 // middle button click - close the pointed tab |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2992 // or create new one in case empty space |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2993 event = index > 0 ? TABLINE_MENU_CLOSE : TABLINE_MENU_NEW; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2994 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2995 else if (buttons & B_SECONDARY_MOUSE_BUTTON) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2996 // right button click - show context menu |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2997 BPopUpMenu* popUpMenu = new BPopUpMenu("tabLineContextMenu", false, false); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2998 popUpMenu->AddItem(new BMenuItem(_("Close tabi R"), new BMessage(TABLINE_MENU_CLOSE))); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2999 popUpMenu->AddItem(new BMenuItem(_("New tab T"), new BMessage(TABLINE_MENU_NEW))); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3000 popUpMenu->AddItem(new BMenuItem(_("Open tab..."), new BMessage(TABLINE_MENU_OPEN))); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3001 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3002 ConvertToScreen(&point); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3003 BMenuItem* item = popUpMenu->Go(point); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3004 if (item != NULL) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3005 event = item->Command(); |
19526 | 3006 } |
3007 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3008 delete popUpMenu; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3009 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3010 } else { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3011 // default processing |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3012 BTabView::MouseDown(point); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3013 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3014 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3015 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3016 if (event < 0) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3017 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3018 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3019 VimTablineMenuMsg tmm; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3020 tmm.index = index; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3021 tmm.event = event; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3022 write_port(gui.vdcmp, VimMsg::TablineMenu, &tmm, sizeof(tmm)); |
19526 | 3023 } |
3024 | |
3025 void | |
3026 VimTabLine::VimTab::Select(BView* owner) | |
3027 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3028 BTab::Select(owner); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3029 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3030 VimTabLine *tabLine = gui.vimForm->TabLine(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3031 if (tabLine != NULL) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3032 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3033 int32 i = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3034 for (; i < tabLine->CountTabs(); i++) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3035 if (this == tabLine->TabAt(i)) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3036 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3037 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3038 // printf("%d:%d:%s\n", i, tabLine->CountTabs(), tabLine->TabAt(i)->Label()); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3039 if (i < tabLine->CountTabs()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3040 VimTablineMsg tm; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3041 tm.index = i + 1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3042 write_port(gui.vdcmp, VimMsg::Tabline, &tm, sizeof(tm)); |
19526 | 3043 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3044 } |
19526 | 3045 } |
3046 | |
3047 #endif // defined(FEAT_GUI_TABLINE) | |
3048 | |
3049 // ---------------- ---------------- | |
3050 | |
3051 // some global variables | |
3052 static char appsig[] = "application/x-vnd.Haiku-Vim-8"; | |
3053 key_map *keyMap; | |
3054 char *keyMapChars; | |
3055 int main_exitcode = 127; | |
3056 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3057 status_t |
19526 | 3058 gui_haiku_process_event(bigtime_t timeout) |
3059 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3060 struct VimMsg vm; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3061 int32 what; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3062 ssize_t size; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3063 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3064 size = read_port_etc(gui.vdcmp, &what, &vm, sizeof(vm), |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3065 B_TIMEOUT, timeout); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3066 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3067 if (size >= 0) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3068 switch (what) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3069 case VimMsg::Key: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3070 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3071 char_u *string = vm.u.Key.chars; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3072 int len = vm.u.Key.length; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3073 if (len == 1 && string[0] == Ctrl_chr('C')) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3074 trash_input_buf(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3075 got_int = TRUE; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3076 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3077 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3078 if (vm.u.Key.csi_escape) |
19526 | 3079 #ifndef FEAT_MBYTE_IME |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3080 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3081 int i; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3082 char_u buf[2]; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3083 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3084 for (i = 0; i < len; ++i) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3085 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3086 add_to_input_buf(string + i, 1); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3087 if (string[i] == CSI) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3088 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3089 // Turn CSI into K_CSI. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3090 buf[0] = KS_EXTRA; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3091 buf[1] = (int)KE_CSI; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3092 add_to_input_buf(buf, 2); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3093 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3094 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3095 } |
19526 | 3096 #else |
20277
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
3097 add_to_input_buf_csi(string, len); |
19526 | 3098 #endif |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3099 else |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3100 add_to_input_buf(string, len); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3101 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3102 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3103 case VimMsg::Resize: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3104 gui_resize_shell(vm.u.NewSize.width, vm.u.NewSize.height); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3105 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3106 case VimMsg::ScrollBar: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3107 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3108 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3109 * If loads of scroll messages queue up, use only the last |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3110 * one. Always report when the scrollbar stops dragging. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3111 * This is not perfect yet anyway: these events are queued |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3112 * yet again, this time in the keyboard input buffer. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3113 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3114 int32 oldCount = |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3115 atomic_add(&vm.u.Scroll.sb->scrollEventCount, -1); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3116 if (oldCount <= 1 || !vm.u.Scroll.stillDragging) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3117 gui_drag_scrollbar(vm.u.Scroll.sb->getGsb(), |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3118 vm.u.Scroll.value, vm.u.Scroll.stillDragging); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3119 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3120 break; |
19526 | 3121 #if defined(FEAT_MENU) |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3122 case VimMsg::Menu: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3123 gui_menu_cb(vm.u.Menu.guiMenu); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3124 break; |
19526 | 3125 #endif |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3126 case VimMsg::Mouse: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3127 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3128 int32 oldCount; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3129 if (vm.u.Mouse.button == MOUSE_DRAG) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3130 oldCount = |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3131 atomic_add(&gui.vimTextArea->mouseDragEventCount, -1); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3132 else |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3133 oldCount = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3134 if (oldCount <= 1) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3135 gui_send_mouse_event(vm.u.Mouse.button, vm.u.Mouse.x, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3136 vm.u.Mouse.y, vm.u.Mouse.repeated_click, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3137 vm.u.Mouse.modifiers); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3138 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3139 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3140 case VimMsg::MouseMoved: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3141 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3142 gui_mouse_moved(vm.u.MouseMoved.x, vm.u.MouseMoved.y); |
19526 | 3143 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3144 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3145 case VimMsg::Focus: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3146 gui.in_focus = vm.u.Focus.active; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3147 // XXX Signal that scrollbar dragging has stopped? |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3148 // This is needed because we don't get a MouseUp if |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3149 // that happens while outside the window... :-( |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3150 if (gui.dragged_sb) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3151 gui.dragged_sb = SBAR_NONE; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3152 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3153 // gui_update_cursor(TRUE, FALSE); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3154 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3155 case VimMsg::Refs: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3156 ::RefsReceived(vm.u.Refs.message, vm.u.Refs.changedir); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3157 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3158 case VimMsg::Tabline: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3159 send_tabline_event(vm.u.Tabline.index); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3160 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3161 case VimMsg::TablineMenu: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3162 send_tabline_menu_event(vm.u.TablineMenu.index, vm.u.TablineMenu.event); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3163 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3164 default: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3165 // unrecognised message, ignore it |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3166 break; |
19526 | 3167 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3168 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3169 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3170 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3171 * If size < B_OK, it is an error code. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3172 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3173 return size; |
19526 | 3174 } |
3175 | |
3176 /* | |
3177 * Here are some functions to protect access to ScreenLines[] and | |
3178 * LineOffset[]. These are used from the window thread to respond | |
3179 * to a Draw() callback. When that occurs, the window is already | |
3180 * locked by the system. | |
3181 * | |
3182 * Other code that needs to lock is any code that changes these | |
3183 * variables. Other read-only access, or access merely to the | |
3184 * contents of the screen buffer, need not be locked. | |
3185 * | |
3186 * If there is no window, don't call Lock() but do succeed. | |
3187 */ | |
3188 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3189 int |
19526 | 3190 vim_lock_screen() |
3191 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3192 return !gui.vimWindow || gui.vimWindow->Lock(); |
19526 | 3193 } |
3194 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3195 void |
19526 | 3196 vim_unlock_screen() |
3197 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3198 if (gui.vimWindow) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3199 gui.vimWindow->Unlock(); |
19526 | 3200 } |
3201 | |
3202 #define RUN_BAPPLICATION_IN_NEW_THREAD 0 | |
3203 | |
3204 #if RUN_BAPPLICATION_IN_NEW_THREAD | |
3205 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3206 int32 |
19526 | 3207 run_vimapp(void *args) |
3208 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3209 VimApp app(appsig); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3210 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3211 gui.vimApp = &app; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3212 app.Run(); // Run until Quit() called |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3213 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3214 return 0; |
19526 | 3215 } |
3216 | |
3217 #else | |
3218 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3219 int32 |
19526 | 3220 call_main(void *args) |
3221 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3222 struct MainArgs *ma = (MainArgs *)args; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3223 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3224 return main(ma->argc, ma->argv); |
19526 | 3225 } |
3226 #endif | |
3227 | |
3228 /* | |
3229 * Parse the GUI related command-line arguments. Any arguments used are | |
3230 * deleted from argv, and *argc is decremented accordingly. This is called | |
3231 * when vim is started, whether or not the GUI has been started. | |
3232 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3233 void |
19526 | 3234 gui_mch_prepare( |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3235 int *argc, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3236 char **argv) |
19526 | 3237 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3238 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3239 * We don't have any command line arguments for the BeOS GUI yet, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3240 * but this is an excellent place to create our Application object. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3241 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3242 if (!gui.vimApp) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3243 thread_info tinfo; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3244 get_thread_info(find_thread(NULL), &tinfo); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3245 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3246 // May need the port very early on to process RefsReceived() |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3247 gui.vdcmp = create_port(B_MAX_PORT_COUNT, "vim VDCMP"); |
19526 | 3248 |
3249 #if RUN_BAPPLICATION_IN_NEW_THREAD | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3250 thread_id tid = spawn_thread(run_vimapp, "vim VimApp", |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3251 tinfo.priority, NULL); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3252 if (tid >= B_OK) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3253 resume_thread(tid); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3254 } else { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3255 getout(1); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3256 } |
19526 | 3257 #else |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3258 MainArgs ma = { *argc, argv }; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3259 thread_id tid = spawn_thread(call_main, "vim main()", |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3260 tinfo.priority, &ma); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3261 if (tid >= B_OK) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3262 VimApp app(appsig); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3263 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3264 gui.vimApp = &app; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3265 resume_thread(tid); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3266 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3267 * This is rather horrible. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3268 * call_main will call main() again... |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3269 * There will be no infinite recursion since |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3270 * gui.vimApp is set now. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3271 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3272 app.Run(); // Run until Quit() called |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3273 // fprintf(stderr, "app.Run() returned...\n"); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3274 status_t dummy_exitcode; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3275 (void)wait_for_thread(tid, &dummy_exitcode); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3276 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3277 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3278 * This path should be the normal one taken to exit Vim. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3279 * The main() thread calls mch_exit() which calls |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3280 * gui_mch_exit() which terminates its thread. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3281 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3282 exit(main_exitcode); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3283 } |
19526 | 3284 #endif |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3285 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3286 // Don't fork() when starting the GUI. Spawned threads are not |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3287 // duplicated with a fork(). The result is a mess. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3288 gui.dofork = FALSE; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3289 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3290 * XXX Try to determine whether we were started from |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3291 * the Tracker or the terminal. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3292 * It would be nice to have this work, because the Tracker |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3293 * follows symlinks, so even if you double-click on gvim, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3294 * when it is a link to vim it will still pass a command name |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3295 * of vim... |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3296 * We try here to see if stdin comes from /dev/null. If so, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3297 * (or if there is an error, which should never happen) start the GUI. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3298 * This does the wrong thing for vim - </dev/null, and we're |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3299 * too early to see the command line parsing. Tough. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3300 * On the other hand, it starts the gui for vim file & which is nice. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3301 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3302 if (!isatty(0)) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3303 struct stat stat_stdin, stat_dev_null; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3304 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3305 if (fstat(0, &stat_stdin) == -1 || |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3306 stat("/dev/null", &stat_dev_null) == -1 || |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3307 (stat_stdin.st_dev == stat_dev_null.st_dev && |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3308 stat_stdin.st_ino == stat_dev_null.st_ino)) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3309 gui.starting = TRUE; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3310 } |
19526 | 3311 } |
3312 | |
3313 /* | |
3314 * Check if the GUI can be started. Called before gvimrc is sourced. | |
3315 * Return OK or FAIL. | |
3316 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3317 int |
19526 | 3318 gui_mch_init_check(void) |
3319 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3320 return OK; // TODO: GUI can always be started? |
19526 | 3321 } |
3322 | |
3323 /* | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3324 * Initialise the GUI. Create all the windows, set up all the call-backs |
19526 | 3325 * etc. |
3326 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3327 int |
19526 | 3328 gui_mch_init() |
3329 { | |
3330 display_errors(); | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3331 gui.def_norm_pixel = RGB(0x00, 0x00, 0x00); // black |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3332 gui.def_back_pixel = RGB(0xFF, 0xFF, 0xFF); // white |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3333 gui.norm_pixel = gui.def_norm_pixel; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3334 gui.back_pixel = gui.def_back_pixel; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3335 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3336 gui.scrollbar_width = (int) B_V_SCROLL_BAR_WIDTH; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3337 gui.scrollbar_height = (int) B_H_SCROLL_BAR_HEIGHT; |
19526 | 3338 #ifdef FEAT_MENU |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3339 gui.menu_height = 19; // initial guess - |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3340 // correct for my default settings |
19526 | 3341 #endif |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3342 gui.border_offset = 3; // coordinates are inside window borders |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3343 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3344 if (gui.vdcmp < B_OK) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3345 return FAIL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3346 get_key_map(&keyMap, &keyMapChars); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3347 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3348 gui.vimWindow = new VimWindow(); // hidden and locked |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3349 if (!gui.vimWindow) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3350 return FAIL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3351 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3352 gui.vimWindow->Run(); // Run() unlocks but does not show |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3353 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3354 // Get the colors from the "Normal" group (set in syntax.c or in a vimrc |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3355 // file) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3356 set_normal_colors(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3357 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3358 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3359 * Check that none of the colors are the same as the background color |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3360 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3361 gui_check_colors(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3362 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3363 // Get the colors for the highlight groups (gui_check_colors() might have |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3364 // changed them) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3365 highlight_gui_started(); // re-init colors and fonts |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3366 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3367 gui_mch_new_colors(); // window must exist for this |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3368 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3369 return OK; |
19526 | 3370 } |
3371 | |
3372 /* | |
3373 * Called when the foreground or background color has been changed. | |
3374 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3375 void |
19526 | 3376 gui_mch_new_colors() |
3377 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3378 rgb_color rgb = GUI_TO_RGB(gui.back_pixel); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3379 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3380 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3381 gui.vimForm->SetViewColor(rgb); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3382 // Does this not have too much effect for those small rectangles? |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3383 gui.vimForm->Invalidate(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3384 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3385 } |
19526 | 3386 } |
3387 | |
3388 /* | |
3389 * Open the GUI window which was created by a call to gui_mch_init(). | |
3390 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3391 int |
19526 | 3392 gui_mch_open() |
3393 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3394 if (gui_win_x != -1 && gui_win_y != -1) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3395 gui_mch_set_winpos(gui_win_x, gui_win_y); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3396 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3397 // Actually open the window |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3398 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3399 gui.vimWindow->Show(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3400 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3401 return OK; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3402 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3403 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3404 return FAIL; |
19526 | 3405 } |
3406 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3407 void |
19526 | 3408 gui_mch_exit(int vim_exitcode) |
3409 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3410 if (gui.vimWindow) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3411 thread_id tid = gui.vimWindow->Thread(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3412 gui.vimWindow->Lock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3413 gui.vimWindow->Quit(); |
23229
b545334ae654
patch 8.2.2160: various typos
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
3414 // Wait until it is truly gone |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3415 int32 exitcode; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3416 wait_for_thread(tid, &exitcode); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3417 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3418 delete_port(gui.vdcmp); |
19526 | 3419 #if !RUN_BAPPLICATION_IN_NEW_THREAD |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3420 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3421 * We are in the main() thread - quit the App thread and |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3422 * quit ourselves (passing on the exitcode). Use a global since the |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3423 * value from exit_thread() is only used if wait_for_thread() is |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3424 * called in time (race condition). |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3425 */ |
19526 | 3426 #endif |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3427 if (gui.vimApp) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3428 VimTextAreaView::guiBlankMouse(false); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3429 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3430 main_exitcode = vim_exitcode; |
19526 | 3431 #if RUN_BAPPLICATION_IN_NEW_THREAD |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3432 thread_id tid = gui.vimApp->Thread(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3433 int32 exitcode; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3434 gui.vimApp->Lock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3435 gui.vimApp->Quit(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3436 gui.vimApp->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3437 wait_for_thread(tid, &exitcode); |
19526 | 3438 #else |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3439 gui.vimApp->Lock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3440 gui.vimApp->Quit(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3441 gui.vimApp->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3442 // suicide |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3443 exit_thread(vim_exitcode); |
19526 | 3444 #endif |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3445 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3446 // If we are somehow still here, let mch_exit() handle things. |
19526 | 3447 } |
3448 | |
3449 /* | |
3450 * Get the position of the top left corner of the window. | |
3451 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3452 int |
19526 | 3453 gui_mch_get_winpos(int *x, int *y) |
3454 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3455 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3456 BRect r; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3457 r = gui.vimWindow->Frame(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3458 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3459 *x = (int)r.left; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3460 *y = (int)r.top; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3461 return OK; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3462 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3463 else |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3464 return FAIL; |
19526 | 3465 } |
3466 | |
3467 /* | |
3468 * Set the position of the top left corner of the window to the given | |
3469 * coordinates. | |
3470 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3471 void |
19526 | 3472 gui_mch_set_winpos(int x, int y) |
3473 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3474 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3475 gui.vimWindow->MoveTo(x, y); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3476 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3477 } |
19526 | 3478 } |
3479 | |
3480 /* | |
3481 * Set the size of the window to the given width and height in pixels. | |
3482 */ | |
3483 void | |
3484 gui_mch_set_shellsize( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3485 int width, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3486 int height, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3487 int min_width, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3488 int min_height, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3489 int base_width, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3490 int base_height, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3491 int direction) // TODO: utilize? |
19526 | 3492 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3493 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3494 * We are basically given the size of the VimForm, if I understand |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3495 * correctly. Since it fills the window completely, this will also |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3496 * be the size of the window. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3497 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3498 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3499 gui.vimWindow->ResizeTo(width - PEN_WIDTH, height - PEN_WIDTH); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3500 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3501 // set size limits |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3502 float minWidth, maxWidth, minHeight, maxHeight; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3503 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3504 gui.vimWindow->GetSizeLimits(&minWidth, &maxWidth, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3505 &minHeight, &maxHeight); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3506 gui.vimWindow->SetSizeLimits(min_width, maxWidth, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3507 min_height, maxHeight); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3508 |
19526 | 3509 /* |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3510 * Set the resizing alignment depending on font size. |
19526 | 3511 */ |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3512 gui.vimWindow->SetWindowAlignment( |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3513 B_PIXEL_ALIGNMENT, // window_alignment mode, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3514 1, // int32 h, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3515 0, // int32 hOffset = 0, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3516 gui.char_width, // int32 width = 0, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3517 base_width, // int32 widthOffset = 0, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3518 1, // int32 v = 0, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3519 0, // int32 vOffset = 0, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3520 gui.char_height, // int32 height = 0, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3521 base_height // int32 heightOffset = 0 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3522 ); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3523 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3524 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3525 } |
19526 | 3526 } |
3527 | |
3528 void | |
3529 gui_mch_get_screen_dimensions( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3530 int *screen_w, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3531 int *screen_h) |
19526 | 3532 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3533 BRect frame; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3534 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3535 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3536 BScreen screen(gui.vimWindow); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3537 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3538 if (screen.IsValid()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3539 frame = screen.Frame(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3540 } else { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3541 frame.right = 640; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3542 frame.bottom = 480; |
19526 | 3543 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3544 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3545 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3546 // XXX approximations... |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3547 *screen_w = (int) frame.right - 2 * gui.scrollbar_width - 20; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3548 *screen_h = (int) frame.bottom - gui.scrollbar_height |
19526 | 3549 #ifdef FEAT_MENU |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3550 - gui.menu_height |
19526 | 3551 #endif |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3552 - 30; |
19526 | 3553 } |
3554 | |
3555 void | |
3556 gui_mch_set_text_area_pos( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3557 int x, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3558 int y, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3559 int w, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3560 int h) |
19526 | 3561 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3562 if (!gui.vimTextArea) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3563 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3564 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3565 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3566 gui.vimTextArea->MoveTo(x, y); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3567 gui.vimTextArea->ResizeTo(w - PEN_WIDTH, h - PEN_WIDTH); |
19526 | 3568 |
20134
352701a626ed
patch 8.2.0622: Haiku: GUI does not compile
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
3569 #ifdef FEAT_GUI_TABLINE |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3570 if (gui.vimForm->TabLine() != NULL) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3571 gui.vimForm->TabLine()->ResizeTo(w, gui.vimForm->TablineHeight()); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3572 } |
19526 | 3573 #endif // FEAT_GUI_TABLINE |
3574 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3575 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3576 } |
19526 | 3577 } |
3578 | |
3579 | |
3580 /* | |
3581 * Scrollbar stuff: | |
3582 */ | |
3583 | |
3584 void | |
3585 gui_mch_enable_scrollbar( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3586 scrollbar_T *sb, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3587 int flag) |
19526 | 3588 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3589 VimScrollBar *vsb = sb->id; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3590 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3591 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3592 * This function is supposed to be idempotent, but Show()/Hide() |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3593 * is not. Therefore we test if they are needed. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3594 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3595 if (flag) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3596 if (vsb->IsHidden()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3597 vsb->Show(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3598 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3599 } else { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3600 if (!vsb->IsHidden()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3601 vsb->Hide(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3602 } |
19526 | 3603 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3604 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3605 } |
19526 | 3606 } |
3607 | |
3608 void | |
3609 gui_mch_set_scrollbar_thumb( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3610 scrollbar_T *sb, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3611 int val, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3612 int size, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3613 int max) |
19526 | 3614 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3615 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3616 VimScrollBar *s = sb->id; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3617 if (max == 0) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3618 s->SetValue(0); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3619 s->SetRange(0.0, 0.0); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3620 } else { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3621 s->SetProportion((float)size / (max + 1.0)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3622 s->SetSteps(1.0, size > 5 ? size - 2 : size); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3623 #ifndef SCROLL_PAST_END // really only defined in gui.c... |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3624 max = max + 1 - size; |
19526 | 3625 #endif |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3626 if (max < s->Value()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3627 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3628 * If the new maximum is lower than the current value, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3629 * setting it would cause the value to be clipped and |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3630 * therefore a ValueChanged() call. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3631 * We avoid this by setting the value first, because |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3632 * it presumably is <= max. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3633 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3634 s->SetValue(val); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3635 s->SetRange(0.0, max); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3636 } else { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3637 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3638 * In the other case, set the range first, since the |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3639 * new value might be higher than the current max. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3640 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3641 s->SetRange(0.0, max); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3642 s->SetValue(val); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3643 } |
19526 | 3644 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3645 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3646 } |
19526 | 3647 } |
3648 | |
3649 void | |
3650 gui_mch_set_scrollbar_pos( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3651 scrollbar_T *sb, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3652 int x, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3653 int y, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3654 int w, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3655 int h) |
19526 | 3656 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3657 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3658 BRect winb = gui.vimWindow->Bounds(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3659 float vsbx = x, vsby = y; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3660 VimScrollBar *vsb = sb->id; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3661 vsb->ResizeTo(w - PEN_WIDTH, h - PEN_WIDTH); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3662 if (winb.right-(x+w)<w) vsbx = winb.right - (w - PEN_WIDTH); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3663 vsb->MoveTo(vsbx, vsby); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3664 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3665 } |
19526 | 3666 } |
3667 | |
21355
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
20277
diff
changeset
|
3668 int |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
20277
diff
changeset
|
3669 gui_mch_get_scrollbar_xpadding(void) |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
20277
diff
changeset
|
3670 { |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
20277
diff
changeset
|
3671 // TODO: Calculate the padding for adjust scrollbar position when the |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
20277
diff
changeset
|
3672 // Window is maximized. |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
20277
diff
changeset
|
3673 return 0; |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
20277
diff
changeset
|
3674 } |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
20277
diff
changeset
|
3675 |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
20277
diff
changeset
|
3676 int |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
20277
diff
changeset
|
3677 gui_mch_get_scrollbar_ypadding(void) |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
20277
diff
changeset
|
3678 { |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
20277
diff
changeset
|
3679 // TODO: Calculate the padding for adjust scrollbar position when the |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
20277
diff
changeset
|
3680 // Window is maximized. |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
20277
diff
changeset
|
3681 return 0; |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
20277
diff
changeset
|
3682 } |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
20277
diff
changeset
|
3683 |
19526 | 3684 void |
3685 gui_mch_create_scrollbar( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3686 scrollbar_T *sb, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3687 int orient) // SBAR_VERT or SBAR_HORIZ |
19526 | 3688 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3689 orientation posture = |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3690 (orient == SBAR_HORIZ) ? B_HORIZONTAL : B_VERTICAL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3691 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3692 VimScrollBar *vsb = sb->id = new VimScrollBar(sb, posture); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3693 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3694 vsb->SetTarget(gui.vimTextArea); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3695 vsb->Hide(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3696 gui.vimForm->AddChild(vsb); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3697 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3698 } |
19526 | 3699 } |
3700 | |
20134
352701a626ed
patch 8.2.0622: Haiku: GUI does not compile
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
3701 #if defined(FEAT_WINDOWS) || defined(FEAT_GUI_HAIKU) || defined(PROTO) |
19526 | 3702 void |
3703 gui_mch_destroy_scrollbar( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3704 scrollbar_T *sb) |
19526 | 3705 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3706 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3707 sb->id->RemoveSelf(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3708 delete sb->id; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3709 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3710 } |
19526 | 3711 } |
3712 #endif | |
3713 | |
3714 /* | |
3715 * Cursor does not flash | |
3716 */ | |
3717 int | |
3718 gui_mch_is_blink_off(void) | |
3719 { | |
3720 return FALSE; | |
3721 } | |
3722 | |
3723 /* | |
3724 * Cursor blink functions. | |
3725 * | |
3726 * This is a simple state machine: | |
3727 * BLINK_NONE not blinking at all | |
3728 * BLINK_OFF blinking, cursor is not shown | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3729 * BLINK_ON blinking, cursor is shown |
19526 | 3730 */ |
3731 | |
3732 #define BLINK_NONE 0 | |
3733 #define BLINK_OFF 1 | |
3734 #define BLINK_ON 2 | |
3735 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3736 static int blink_state = BLINK_NONE; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3737 static long_u blink_waittime = 700; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3738 static long_u blink_ontime = 400; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3739 static long_u blink_offtime = 250; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3740 static int blink_timer = 0; |
19526 | 3741 |
3742 void | |
3743 gui_mch_set_blinking( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3744 long waittime, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3745 long on, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3746 long off) |
19526 | 3747 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3748 // TODO |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3749 blink_waittime = waittime; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3750 blink_ontime = on; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3751 blink_offtime = off; |
19526 | 3752 } |
3753 | |
3754 /* | |
3755 * Stop the cursor blinking. Show the cursor if it wasn't shown. | |
3756 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3757 void |
20134
352701a626ed
patch 8.2.0622: Haiku: GUI does not compile
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
3758 gui_mch_stop_blink(int may_call_gui_update_cursor) |
19526 | 3759 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3760 // TODO |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3761 if (blink_timer != 0) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3762 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3763 // XtRemoveTimeOut(blink_timer); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3764 blink_timer = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3765 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3766 if (blink_state == BLINK_OFF) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3767 gui_update_cursor(TRUE, FALSE); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3768 blink_state = BLINK_NONE; |
19526 | 3769 } |
3770 | |
3771 /* | |
3772 * Start the cursor blinking. If it was already blinking, this restarts the | |
3773 * waiting time and shows the cursor. | |
3774 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3775 void |
19526 | 3776 gui_mch_start_blink() |
3777 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3778 // TODO |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3779 if (blink_timer != 0) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3780 ;// XtRemoveTimeOut(blink_timer); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3781 // Only switch blinking on if none of the times is zero |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3782 if (blink_waittime && blink_ontime && blink_offtime && gui.in_focus) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3783 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3784 blink_timer = 1; // XtAppAddTimeOut(app_context, blink_waittime, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3785 blink_state = BLINK_ON; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3786 gui_update_cursor(TRUE, FALSE); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3787 } |
19526 | 3788 } |
3789 | |
3790 /* | |
3791 * Initialise vim to use the font with the given name. Return FAIL if the font | |
3792 * could not be loaded, OK otherwise. | |
3793 */ | |
3794 int | |
3795 gui_mch_init_font( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3796 char_u *font_name, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3797 int fontset) |
19526 | 3798 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3799 if (gui.vimWindow->Lock()) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3800 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3801 int rc = gui.vimTextArea->mchInitFont(font_name); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3802 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3803 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3804 return rc; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3805 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3806 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3807 return FAIL; |
19526 | 3808 } |
3809 | |
3810 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3811 int |
19526 | 3812 gui_mch_adjust_charsize() |
3813 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3814 return FAIL; |
19526 | 3815 } |
3816 | |
3817 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3818 int |
19526 | 3819 gui_mch_font_dialog(font_family* family, font_style* style, float* size) |
3820 { | |
3821 #if defined(FEAT_GUI_DIALOG) | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3822 // gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3823 VimSelectFontDialog *dialog = new VimSelectFontDialog(family, style, size); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3824 return dialog->Go(); |
19526 | 3825 #else |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3826 return NOFONT; |
19526 | 3827 #endif // FEAT_GUI_DIALOG |
3828 } | |
3829 | |
3830 | |
3831 GuiFont | |
3832 gui_mch_get_font( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3833 char_u *name, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3834 int giveErrorIfMissing) |
19526 | 3835 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3836 static VimFont *fontList = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3837 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3838 if (!gui.in_use) // can't do this when GUI not running |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3839 return NOFONT; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3840 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3841 // storage for locally modified name; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3842 const int buff_size = B_FONT_FAMILY_LENGTH + B_FONT_STYLE_LENGTH + 20; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3843 static char font_name[buff_size] = {0}; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3844 font_family family = {0}; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3845 font_style style = {0}; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3846 float size = 0.f; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3847 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3848 if (name == 0 && be_fixed_font == 0) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3849 if (giveErrorIfMissing) |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
3850 semsg(_(e_unknown_font_str), name); |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3851 return NOFONT; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3852 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3853 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3854 bool useSelectGUI = false; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3855 if (name != NULL) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3856 if (STRCMP(name, "*") == 0) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3857 useSelectGUI = true; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3858 STRNCPY(font_name, hl_get_font_name(), buff_size); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3859 } else |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3860 STRNCPY(font_name, name, buff_size); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3861 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3862 if (font_name[0] == 0) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3863 be_fixed_font->GetFamilyAndStyle(&family, &style); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3864 size = be_fixed_font->Size(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3865 vim_snprintf(font_name, buff_size, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3866 (char*)"%s/%s/%.0f", family, style, size); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3867 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3868 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3869 // replace underscores with spaces |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3870 char* end = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3871 while (end = strchr((char *)font_name, '_')) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3872 *end = ' '; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3873 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3874 // store the name before strtok corrupt the buffer ;-) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3875 static char buff[buff_size] = {0}; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3876 STRNCPY(buff, font_name, buff_size); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3877 STRNCPY(family, strtok(buff, "/\0"), B_FONT_FAMILY_LENGTH); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3878 char* style_s = strtok(0, "/\0"); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3879 if (style_s != 0) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3880 STRNCPY(style, style_s, B_FONT_STYLE_LENGTH); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3881 size = atof((style_s != 0) ? strtok(0, "/\0") : "0"); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3882 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3883 if (useSelectGUI) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3884 if (gui_mch_font_dialog(&family, &style, &size) == NOFONT) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3885 return FAIL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3886 // compose for further processing |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3887 vim_snprintf(font_name, buff_size, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3888 (char*)"%s/%s/%.0f", family, style, size); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3889 hl_set_font_name((char_u*)font_name); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3890 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3891 // Set guifont to the name of the selected font. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3892 char_u* new_p_guifont = (char_u*)alloc(STRLEN(font_name) + 1); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3893 if (new_p_guifont != NULL) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3894 STRCPY(new_p_guifont, font_name); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3895 vim_free(p_guifont); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3896 p_guifont = new_p_guifont; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3897 // Replace spaces in the font name with underscores. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3898 for ( ; *new_p_guifont; ++new_p_guifont) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3899 if (*new_p_guifont == ' ') |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3900 *new_p_guifont = '_'; |
19526 | 3901 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3902 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3903 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3904 VimFont *flp; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3905 for (flp = fontList; flp; flp = flp->next) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3906 if (STRCMP(font_name, flp->name) == 0) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3907 flp->refcount++; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3908 return (GuiFont)flp; |
19526 | 3909 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3910 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3911 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3912 VimFont *font = new VimFont(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3913 font->name = vim_strsave((char_u*)font_name); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3914 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3915 if (count_font_styles(family) <= 0) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3916 if (giveErrorIfMissing) |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
3917 semsg(_(e_unknown_font_str), font->name); |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3918 delete font; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3919 return NOFONT; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3920 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3921 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3922 // Remember font in the static list for later use |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3923 font->next = fontList; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3924 fontList = font; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3925 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3926 font->SetFamilyAndStyle(family, style); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3927 if (size > 0.f) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3928 font->SetSize(size); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3929 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3930 font->SetSpacing(B_FIXED_SPACING); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3931 font->SetEncoding(B_UNICODE_UTF8); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3932 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3933 return (GuiFont)font; |
19526 | 3934 } |
3935 | |
3936 /* | |
3937 * Set the current text font. | |
3938 */ | |
3939 void | |
3940 gui_mch_set_font( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3941 GuiFont font) |
19526 | 3942 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3943 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3944 VimFont *vf = (VimFont *)font; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3945 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3946 gui.vimTextArea->SetFont(vf); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3947 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3948 gui.char_width = (int) vf->StringWidth("n"); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3949 font_height fh; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3950 vf->GetHeight(&fh); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3951 gui.char_height = (int)(fh.ascent + 0.9999) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3952 + (int)(fh.descent + 0.9999) + (int)(fh.leading + 0.9999); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3953 gui.char_ascent = (int)(fh.ascent + 0.9999); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3954 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3955 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3956 } |
19526 | 3957 } |
3958 | |
3959 // XXX TODO This is apparently never called... | |
3960 void | |
3961 gui_mch_free_font( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3962 GuiFont font) |
19526 | 3963 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3964 if (font == NOFONT) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3965 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3966 VimFont *f = (VimFont *)font; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3967 if (--f->refcount <= 0) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3968 if (f->refcount < 0) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3969 fprintf(stderr, "VimFont: refcount < 0\n"); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3970 delete f; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3971 } |
19526 | 3972 } |
3973 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3974 char_u * |
19526 | 3975 gui_mch_get_fontname(GuiFont font, char_u *name) |
3976 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3977 if (name == NULL) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3978 return NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3979 return vim_strsave(name); |
19526 | 3980 } |
3981 | |
3982 /* | |
3983 * Adjust gui.char_height (after 'linespace' was changed). | |
3984 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3985 int |
19526 | 3986 gui_mch_adjust_charheight() |
3987 { | |
3988 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3989 // TODO: linespace support? |
19526 | 3990 |
3991 // #ifdef FEAT_XFONTSET | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3992 // if (gui.fontset != NOFONTSET) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3993 // { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3994 // gui.char_height = fontset_height((XFontSet)gui.fontset) + p_linespace; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3995 // gui.char_ascent = fontset_ascent((XFontSet)gui.fontset) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3996 // + p_linespace / 2; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3997 // } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3998 // else |
19526 | 3999 // #endif |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4000 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4001 VimFont *font = (VimFont *)gui.norm_font; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4002 font_height fh = {0}; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4003 font->GetHeight(&fh); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4004 gui.char_height = (int)(fh.ascent + fh.descent + 0.5) + p_linespace; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4005 gui.char_ascent = (int)(fh.ascent + 0.5) + p_linespace / 2; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4006 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4007 return OK; |
19526 | 4008 } |
4009 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4010 void |
19526 | 4011 gui_mch_getmouse(int *x, int *y) |
4012 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4013 fprintf(stderr, "gui_mch_getmouse"); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4014 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4015 /*int rootx, rooty, winx, winy; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4016 Window root, child; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4017 unsigned int mask; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4018 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4019 if (gui.wid && XQueryPointer(gui.dpy, gui.wid, &root, &child, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4020 &rootx, &rooty, &winx, &winy, &mask)) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4021 *x = winx; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4022 *y = winy; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4023 } else*/ { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4024 *x = -1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4025 *y = -1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4026 } |
19526 | 4027 } |
4028 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4029 void |
19526 | 4030 gui_mch_mousehide(int hide) |
4031 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4032 fprintf(stderr, "gui_mch_getmouse"); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4033 // TODO |
19526 | 4034 } |
4035 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4036 static int |
19526 | 4037 hex_digit(int c) |
4038 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4039 if (isdigit(c)) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4040 return c - '0'; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4041 c = TOLOWER_ASC(c); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4042 if (c >= 'a' && c <= 'f') |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4043 return c - 'a' + 10; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4044 return -1000; |
19526 | 4045 } |
4046 | |
4047 /* | |
4048 * This function has been lifted from gui_w32.c and extended a bit. | |
4049 * | |
4050 * Return the Pixel value (color) for the given color name. | |
4051 * Return INVALCOLOR for error. | |
4052 */ | |
4053 guicolor_T | |
4054 gui_mch_get_color( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4055 char_u *name) |
19526 | 4056 { |
26057
92c424550367
patch 8.2.3562: cannot add color names
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
4057 return gui_get_color_cmn(name); |
19526 | 4058 } |
4059 | |
4060 /* | |
4061 * Set the current text foreground color. | |
4062 */ | |
4063 void | |
4064 gui_mch_set_fg_color( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4065 guicolor_T color) |
19526 | 4066 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4067 rgb_color rgb = GUI_TO_RGB(color); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4068 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4069 gui.vimTextArea->SetHighColor(rgb); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4070 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4071 } |
19526 | 4072 } |
4073 | |
4074 /* | |
4075 * Set the current text background color. | |
4076 */ | |
4077 void | |
4078 gui_mch_set_bg_color( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4079 guicolor_T color) |
19526 | 4080 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4081 rgb_color rgb = GUI_TO_RGB(color); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4082 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4083 gui.vimTextArea->SetLowColor(rgb); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4084 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4085 } |
19526 | 4086 } |
4087 | |
4088 /* | |
4089 * Set the current text special color. | |
4090 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4091 void |
19526 | 4092 gui_mch_set_sp_color(guicolor_T color) |
4093 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4094 // prev_sp_color = color; |
19526 | 4095 } |
4096 | |
4097 void | |
4098 gui_mch_draw_string( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4099 int row, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4100 int col, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4101 char_u *s, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4102 int len, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4103 int flags) |
19526 | 4104 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4105 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4106 gui.vimTextArea->mchDrawString(row, col, s, len, flags); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4107 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4108 } |
19526 | 4109 } |
4110 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4111 guicolor_T |
19526 | 4112 gui_mch_get_rgb_color(int r, int g, int b) |
4113 { | |
4114 return gui_get_rgb_color_cmn(r, g, b); | |
4115 } | |
4116 | |
4117 | |
4118 // Return OK if the key with the termcap name "name" is supported. | |
4119 int | |
4120 gui_mch_haskey( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4121 char_u *name) |
19526 | 4122 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4123 int i; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4124 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4125 for (i = 0; special_keys[i].BeKeys != 0; i++) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4126 if (name[0] == special_keys[i].vim_code0 && |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4127 name[1] == special_keys[i].vim_code1) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4128 return OK; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4129 return FAIL; |
19526 | 4130 } |
4131 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4132 void |
19526 | 4133 gui_mch_beep() |
4134 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4135 ::beep(); |
19526 | 4136 } |
4137 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4138 void |
19526 | 4139 gui_mch_flash(int msec) |
4140 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4141 // Do a visual beep by reversing the foreground and background colors |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4142 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4143 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4144 BRect rect = gui.vimTextArea->Bounds(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4145 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4146 gui.vimTextArea->SetDrawingMode(B_OP_INVERT); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4147 gui.vimTextArea->FillRect(rect); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4148 gui.vimTextArea->Sync(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4149 snooze(msec * 1000); // wait for a few msec |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4150 gui.vimTextArea->FillRect(rect); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4151 gui.vimTextArea->SetDrawingMode(B_OP_COPY); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4152 gui.vimTextArea->Flush(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4153 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4154 } |
19526 | 4155 } |
4156 | |
4157 /* | |
4158 * Invert a rectangle from row r, column c, for nr rows and nc columns. | |
4159 */ | |
4160 void | |
4161 gui_mch_invert_rectangle( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4162 int r, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4163 int c, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4164 int nr, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4165 int nc) |
19526 | 4166 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4167 BRect rect; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4168 rect.left = FILL_X(c); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4169 rect.top = FILL_Y(r); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4170 rect.right = rect.left + nc * gui.char_width - PEN_WIDTH; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4171 rect.bottom = rect.top + nr * gui.char_height - PEN_WIDTH; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4172 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4173 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4174 gui.vimTextArea->SetDrawingMode(B_OP_INVERT); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4175 gui.vimTextArea->FillRect(rect); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4176 gui.vimTextArea->SetDrawingMode(B_OP_COPY); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4177 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4178 } |
19526 | 4179 } |
4180 | |
4181 /* | |
4182 * Iconify the GUI window. | |
4183 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4184 void |
19526 | 4185 gui_mch_iconify() |
4186 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4187 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4188 gui.vimWindow->Minimize(true); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4189 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4190 } |
19526 | 4191 } |
4192 | |
4193 #if defined(FEAT_EVAL) || defined(PROTO) | |
4194 /* | |
4195 * Bring the Vim window to the foreground. | |
4196 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4197 void |
19526 | 4198 gui_mch_set_foreground(void) |
4199 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4200 // TODO |
19526 | 4201 } |
4202 #endif | |
4203 | |
4204 /* | |
4205 * Set the window title | |
4206 */ | |
4207 void | |
4208 gui_mch_settitle( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4209 char_u *title, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4210 char_u *icon) |
19526 | 4211 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4212 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4213 gui.vimWindow->SetTitle((char *)title); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4214 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4215 } |
19526 | 4216 } |
4217 | |
4218 /* | |
4219 * Draw a cursor without focus. | |
4220 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4221 void |
19526 | 4222 gui_mch_draw_hollow_cursor(guicolor_T color) |
4223 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4224 gui_mch_set_fg_color(color); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4225 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4226 BRect r; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4227 r.left = FILL_X(gui.col); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4228 r.top = FILL_Y(gui.row); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4229 int cells = utf_off2cells(LineOffset[gui.row] + gui.col, 100); // TODO-TODO |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4230 if (cells>=4) cells = 1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4231 r.right = r.left + cells*gui.char_width - PEN_WIDTH; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4232 r.bottom = r.top + gui.char_height - PEN_WIDTH; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4233 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4234 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4235 gui.vimTextArea->StrokeRect(r); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4236 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4237 // gui_mch_flush(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4238 } |
19526 | 4239 } |
4240 | |
4241 /* | |
4242 * Draw part of a cursor, only w pixels wide, and h pixels high. | |
4243 */ | |
4244 void | |
4245 gui_mch_draw_part_cursor( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4246 int w, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4247 int h, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4248 guicolor_T color) |
19526 | 4249 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4250 gui_mch_set_fg_color(color); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4251 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4252 BRect r; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4253 r.left = |
19526 | 4254 #ifdef FEAT_RIGHTLEFT |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4255 // vertical line should be on the right of current point |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4256 CURSOR_BAR_RIGHT ? FILL_X(gui.col + 1) - w : |
19526 | 4257 #endif |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4258 FILL_X(gui.col); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4259 r.right = r.left + w - PEN_WIDTH; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4260 r.bottom = FILL_Y(gui.row + 1) - PEN_WIDTH; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4261 r.top = r.bottom - h + PEN_WIDTH; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4262 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4263 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4264 gui.vimTextArea->FillRect(r); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4265 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4266 // gui_mch_flush(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4267 } |
19526 | 4268 } |
4269 | |
4270 /* | |
4271 * Catch up with any queued events. This may put keyboard input into the | |
4272 * input buffer, call resize call-backs, trigger timers etc. If there is | |
4273 * nothing in the event queue (& no timers pending), then we return | |
4274 * immediately. | |
4275 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4276 void |
19526 | 4277 gui_mch_update() |
4278 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4279 gui_mch_flush(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4280 while (port_count(gui.vdcmp) > 0 && |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4281 !vim_is_input_buf_full() && |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4282 gui_haiku_process_event(0) >= B_OK) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4283 /* nothing */ ; |
19526 | 4284 } |
4285 | |
4286 /* | |
4287 * GUI input routine called by gui_wait_for_chars(). Waits for a character | |
4288 * from the keyboard. | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4289 * wtime == -1 Wait forever. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4290 * wtime == 0 This should never happen. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4291 * wtime > 0 Wait wtime milliseconds for a character. |
19526 | 4292 * Returns OK if a character was found to be available within the given time, |
4293 * or FAIL otherwise. | |
4294 */ | |
4295 int | |
4296 gui_mch_wait_for_chars( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4297 int wtime) |
19526 | 4298 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4299 int focus; |
20277
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4300 bigtime_t until, timeout; |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4301 status_t st; |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4302 |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4303 if (wtime >= 0) |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4304 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4305 timeout = wtime * 1000; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4306 until = system_time() + timeout; |
20277
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4307 } |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4308 else |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4309 timeout = B_INFINITE_TIMEOUT; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4310 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4311 focus = gui.in_focus; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4312 for (;;) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4313 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4314 // Stop or start blinking when focus changes |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4315 if (gui.in_focus != focus) |
19526 | 4316 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4317 if (gui.in_focus) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4318 gui_mch_start_blink(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4319 else |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4320 gui_mch_stop_blink(TRUE); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4321 focus = gui.in_focus; |
19526 | 4322 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4323 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4324 gui_mch_flush(); |
20277
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4325 |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4326 #ifdef MESSAGE_QUEUE |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4327 # ifdef FEAT_TIMERS |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4328 did_add_timer = FALSE; |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4329 # endif |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4330 parse_queued_messages(); |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4331 # ifdef FEAT_TIMERS |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4332 if (did_add_timer) |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4333 // Need to recompute the waiting time. |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4334 break; |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4335 # endif |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4336 # ifdef FEAT_JOB_CHANNEL |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4337 if (has_any_channel()) |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4338 { |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4339 if (wtime < 0 || timeout > 20000) |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4340 timeout = 20000; |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4341 } |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4342 else if (wtime < 0) |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4343 timeout = B_INFINITE_TIMEOUT; |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4344 # endif |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4345 #endif |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4346 |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4347 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4348 * Don't use gui_mch_update() because then we will spin-lock until a |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4349 * char arrives, instead we use gui_haiku_process_event() to hang until |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4350 * an event arrives. No need to check for input_buf_full because we |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4351 * are returning as soon as it contains a single char. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4352 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4353 st = gui_haiku_process_event(timeout); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4354 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4355 if (input_available()) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4356 return OK; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4357 if (st < B_OK) // includes B_TIMED_OUT |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4358 return FAIL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4359 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4360 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4361 * Calculate how much longer we're willing to wait for the |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4362 * next event. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4363 */ |
20277
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4364 if (wtime >= 0) |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4365 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4366 timeout = until - system_time(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4367 if (timeout < 0) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4368 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4369 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4370 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4371 return FAIL; |
19526 | 4372 |
4373 } | |
4374 | |
4375 /* | |
4376 * Output routines. | |
4377 */ | |
4378 | |
4379 /* | |
4380 * Flush any output to the screen. This is typically called before | |
4381 * the app goes to sleep. | |
4382 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4383 void |
19526 | 4384 gui_mch_flush() |
4385 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4386 // does this need to lock the window? Apparently not but be safe. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4387 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4388 gui.vimWindow->Flush(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4389 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4390 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4391 return; |
19526 | 4392 } |
4393 | |
4394 /* | |
4395 * Clear a rectangular region of the screen from text pos (row1, col1) to | |
4396 * (row2, col2) inclusive. | |
4397 */ | |
4398 void | |
4399 gui_mch_clear_block( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4400 int row1, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4401 int col1, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4402 int row2, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4403 int col2) |
19526 | 4404 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4405 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4406 gui.vimTextArea->mchClearBlock(row1, col1, row2, col2); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4407 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4408 } |
19526 | 4409 } |
4410 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4411 void |
19526 | 4412 gui_mch_clear_all() |
4413 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4414 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4415 gui.vimTextArea->mchClearAll(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4416 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4417 } |
19526 | 4418 } |
4419 | |
4420 /* | |
4421 * Delete the given number of lines from the given row, scrolling up any | |
4422 * text further down within the scroll region. | |
4423 */ | |
4424 void | |
4425 gui_mch_delete_lines( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4426 int row, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4427 int num_lines) |
19526 | 4428 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4429 gui.vimTextArea->mchDeleteLines(row, num_lines); |
19526 | 4430 } |
4431 | |
4432 /* | |
4433 * Insert the given number of lines before the given row, scrolling down any | |
4434 * following text within the scroll region. | |
4435 */ | |
4436 void | |
4437 gui_mch_insert_lines( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4438 int row, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4439 int num_lines) |
19526 | 4440 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4441 gui.vimTextArea->mchInsertLines(row, num_lines); |
19526 | 4442 } |
4443 | |
4444 #if defined(FEAT_MENU) || defined(PROTO) | |
4445 /* | |
4446 * Menu stuff. | |
4447 */ | |
4448 | |
4449 void | |
4450 gui_mch_enable_menu( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4451 int flag) |
19526 | 4452 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4453 if (gui.vimWindow->Lock()) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4454 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4455 BMenuBar *menubar = gui.vimForm->MenuBar(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4456 menubar->SetEnabled(flag); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4457 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4458 } |
19526 | 4459 } |
4460 | |
4461 void | |
4462 gui_mch_set_menu_pos( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4463 int x, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4464 int y, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4465 int w, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4466 int h) |
19526 | 4467 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4468 // It will be in the right place anyway |
19526 | 4469 } |
4470 | |
4471 /* | |
4472 * Add a sub menu to the menu bar. | |
4473 */ | |
4474 void | |
4475 gui_mch_add_menu( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4476 vimmenu_T *menu, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4477 int idx) |
19526 | 4478 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4479 vimmenu_T *parent = menu->parent; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4480 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4481 // popup menu - just create it unattached |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4482 if (menu_is_popup(menu->name) && parent == NULL) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4483 BPopUpMenu* popUpMenu = new BPopUpMenu((const char*)menu->name, false, false); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4484 menu->submenu_id = popUpMenu; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4485 menu->id = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4486 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4487 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4488 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4489 if (!menu_is_menubar(menu->name) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4490 || (parent != NULL && parent->submenu_id == NULL)) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4491 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4492 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4493 if (gui.vimWindow->Lock()) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4494 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4495 // Major re-write of the menu code, it was failing with memory corruption when |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4496 // we started loading multiple files (the Buffer menu) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4497 // |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4498 // Note we don't use the preference values yet, all are inserted into the |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4499 // menubar on a first come-first served basis... |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4500 // |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4501 // richard@whitequeen.com jul 99 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4502 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4503 BMenu *tmp; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4504 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4505 if ( parent ) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4506 tmp = parent->submenu_id; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4507 else |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4508 tmp = gui.vimForm->MenuBar(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4509 // make sure we don't try and add the same menu twice. The Buffers menu tries to |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4510 // do this and Be starts to crash... |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4511 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4512 if ( ! tmp->FindItem((const char *) menu->dname)) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4513 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4514 BMenu *bmenu = new BMenu((char *)menu->dname); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4515 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4516 menu->submenu_id = bmenu; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4517 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4518 // when we add a BMenu to another Menu, it creates the interconnecting BMenuItem |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4519 tmp->AddItem(bmenu); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4520 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4521 // Now its safe to query the menu for the associated MenuItem.... |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4522 menu->id = tmp->FindItem((const char *) menu->dname); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4523 |
19526 | 4524 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4525 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4526 } |
19526 | 4527 } |
4528 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4529 void |
19526 | 4530 gui_mch_toggle_tearoffs(int enable) |
4531 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4532 // no tearoff menus |
19526 | 4533 } |
4534 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4535 static BMessage * |
19526 | 4536 MenuMessage(vimmenu_T *menu) |
4537 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4538 BMessage *m = new BMessage('menu'); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4539 m->AddPointer("VimMenu", (void *)menu); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4540 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4541 return m; |
19526 | 4542 } |
4543 | |
4544 /* | |
4545 * Add a menu item to a menu | |
4546 */ | |
4547 void | |
4548 gui_mch_add_menu_item( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4549 vimmenu_T *menu, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4550 int idx) |
19526 | 4551 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4552 int mnemonic = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4553 vimmenu_T *parent = menu->parent; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4554 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4555 // TODO: use menu->actext |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4556 // This is difficult, since on Be, an accelerator must be a single char |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4557 // and a lot of Vim ones are the standard VI commands. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4558 // |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4559 // Punt for Now... |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4560 // richard@whiequeen.com jul 99 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4561 if (gui.vimWindow->Lock()) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4562 { |
19526 | 4563 #ifdef FEAT_TOOLBAR |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4564 if (menu_is_toolbar(parent->name)) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4565 VimToolbar *toolbar = gui.vimForm->ToolBar(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4566 if (toolbar != NULL) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4567 toolbar->AddButton(idx, menu); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4568 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4569 } else |
19526 | 4570 #endif |
4571 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4572 if (parent->submenu_id != NULL || menu_is_popup(parent->name)) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4573 if (menu_is_separator(menu->name)) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4574 BSeparatorItem *item = new BSeparatorItem(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4575 parent->submenu_id->AddItem(item); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4576 menu->id = item; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4577 menu->submenu_id = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4578 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4579 else { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4580 BMenuItem *item = new BMenuItem((char *)menu->dname, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4581 MenuMessage(menu)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4582 item->SetTarget(gui.vimTextArea); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4583 item->SetTrigger((char) menu->mnemonic); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4584 parent->submenu_id->AddItem(item); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4585 menu->id = item; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4586 menu->submenu_id = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4587 } |
19526 | 4588 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4589 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4590 } |
19526 | 4591 } |
4592 | |
4593 /* | |
4594 * Destroy the machine specific menu widget. | |
4595 */ | |
4596 void | |
4597 gui_mch_destroy_menu( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4598 vimmenu_T *menu) |
19526 | 4599 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4600 if (gui.vimWindow->Lock()) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4601 { |
19526 | 4602 #ifdef FEAT_TOOLBAR |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4603 if (menu->parent && menu_is_toolbar(menu->parent->name)) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4604 VimToolbar *toolbar = gui.vimForm->ToolBar(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4605 if (toolbar != NULL) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4606 toolbar->RemoveButton(menu); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4607 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4608 } else |
19526 | 4609 #endif |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4610 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4611 assert(menu->submenu_id == NULL || menu->submenu_id->CountItems() == 0); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4612 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4613 * Detach this menu from its parent, so that it is not deleted |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4614 * twice once we get to delete that parent. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4615 * Deleting a BMenuItem also deletes the associated BMenu, if any |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4616 * (which does not have any items anymore since they were |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4617 * removed and deleted before). |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4618 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4619 BMenu *bmenu = menu->id->Menu(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4620 if (bmenu) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4621 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4622 bmenu->RemoveItem(menu->id); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4623 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4624 * If we removed the last item from the menu bar, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4625 * resize it out of sight. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4626 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4627 if (bmenu == gui.vimForm->MenuBar() && bmenu->CountItems() == 0) |
19526 | 4628 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4629 bmenu->ResizeTo(-MENUBAR_MARGIN, -MENUBAR_MARGIN); |
19526 | 4630 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4631 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4632 delete menu->id; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4633 menu->id = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4634 menu->submenu_id = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4635 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4636 gui.menu_height = (int) gui.vimForm->MenuHeight(); |
19526 | 4637 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4638 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4639 } |
19526 | 4640 } |
4641 | |
4642 /* | |
4643 * Make a menu either grey or not grey. | |
4644 */ | |
4645 void | |
4646 gui_mch_menu_grey( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4647 vimmenu_T *menu, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4648 int grey) |
19526 | 4649 { |
4650 #ifdef FEAT_TOOLBAR | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4651 if (menu->parent && menu_is_toolbar(menu->parent->name)) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4652 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4653 VimToolbar *toolbar = gui.vimForm->ToolBar(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4654 if (toolbar != NULL) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4655 toolbar->GrayButton(menu, grey); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4656 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4657 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4658 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4659 } else |
19526 | 4660 #endif |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4661 if (menu->id != NULL) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4662 menu->id->SetEnabled(!grey); |
19526 | 4663 } |
4664 | |
4665 /* | |
4666 * Make menu item hidden or not hidden | |
4667 */ | |
4668 void | |
4669 gui_mch_menu_hidden( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4670 vimmenu_T *menu, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4671 int hidden) |
19526 | 4672 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4673 if (menu->id != NULL) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4674 menu->id->SetEnabled(!hidden); |
19526 | 4675 } |
4676 | |
4677 /* | |
4678 * This is called after setting all the menus to grey/hidden or not. | |
4679 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4680 void |
19526 | 4681 gui_mch_draw_menubar() |
4682 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4683 // Nothing to do in BeOS |
19526 | 4684 } |
4685 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4686 void |
19526 | 4687 gui_mch_show_popupmenu(vimmenu_T *menu) |
4688 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4689 if (!menu_is_popup(menu->name) || menu->submenu_id == NULL) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4690 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4691 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4692 BPopUpMenu* popupMenu = dynamic_cast<BPopUpMenu*>(menu->submenu_id); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4693 if (popupMenu == NULL) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4694 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4695 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4696 BPoint point; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4697 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4698 uint32 buttons = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4699 gui.vimTextArea->GetMouse(&point, &buttons); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4700 gui.vimTextArea->ConvertToScreen(&point); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4701 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4702 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4703 popupMenu->Go(point, true); |
19526 | 4704 } |
4705 | |
4706 #endif // FEAT_MENU | |
4707 | |
4708 // Mouse stuff | |
4709 | |
4710 #ifdef FEAT_CLIPBOARD | |
4711 /* | |
4712 * Clipboard stuff, for cutting and pasting text to other windows. | |
4713 */ | |
4714 char textplain[] = "text/plain"; | |
4715 char vimselectiontype[] = "application/x-vnd.Rhialto-Vim-selectiontype"; | |
4716 | |
4717 /* | |
4718 * Get the current selection and put it in the clipboard register. | |
4719 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4720 void |
19526 | 4721 clip_mch_request_selection(Clipboard_T *cbd) |
4722 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4723 if (be_clipboard->Lock()) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4724 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4725 BMessage *m = be_clipboard->Data(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4726 // m->PrintToStream(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4727 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4728 char_u *string = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4729 ssize_t stringlen = -1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4730 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4731 if (m->FindData(textplain, B_MIME_TYPE, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4732 (const void **)&string, &stringlen) == B_OK |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4733 || m->FindString("text", (const char **)&string) == B_OK) |
19526 | 4734 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4735 if (stringlen == -1) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4736 stringlen = STRLEN(string); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4737 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4738 int type; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4739 char *seltype; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4740 ssize_t seltypelen; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4741 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4742 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4743 * Try to get the special vim selection type first |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4744 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4745 if (m->FindData(vimselectiontype, B_MIME_TYPE, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4746 (const void **)&seltype, &seltypelen) == B_OK) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4747 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4748 switch (*seltype) |
19526 | 4749 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4750 default: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4751 case 'L': type = MLINE; break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4752 case 'C': type = MCHAR; break; |
19526 | 4753 #ifdef FEAT_VISUAL |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4754 case 'B': type = MBLOCK; break; |
19526 | 4755 #endif |
4756 } | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4757 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4758 else |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4759 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4760 // Otherwise use heuristic as documented |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4761 type = memchr(string, stringlen, '\n') ? MLINE : MCHAR; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4762 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4763 clip_yank_selection(type, string, (long)stringlen, cbd); |
19526 | 4764 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4765 be_clipboard->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4766 } |
19526 | 4767 } |
4768 /* | |
4769 * Make vim the owner of the current selection. | |
4770 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4771 void |
19526 | 4772 clip_mch_lose_selection(Clipboard_T *cbd) |
4773 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4774 // Nothing needs to be done here |
19526 | 4775 } |
4776 | |
4777 /* | |
4778 * Make vim the owner of the current selection. Return OK upon success. | |
4779 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4780 int |
19526 | 4781 clip_mch_own_selection(Clipboard_T *cbd) |
4782 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4783 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4784 * Never actually own the clipboard. If another application sets the |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4785 * clipboard, we don't want to think that we still own it. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4786 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4787 return FAIL; |
19526 | 4788 } |
4789 | |
4790 /* | |
4791 * Send the current selection to the clipboard. | |
4792 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4793 void |
19526 | 4794 clip_mch_set_selection(Clipboard_T *cbd) |
4795 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4796 if (be_clipboard->Lock()) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4797 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4798 be_clipboard->Clear(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4799 BMessage *m = be_clipboard->Data(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4800 assert(m); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4801 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4802 // If the '*' register isn't already filled in, fill it in now |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4803 cbd->owned = TRUE; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4804 clip_get_selection(cbd); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4805 cbd->owned = FALSE; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4806 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4807 char_u *str = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4808 long_u count; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4809 int type; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4810 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4811 type = clip_convert_selection(&str, &count, cbd); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4812 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4813 if (type < 0) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4814 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4815 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4816 m->AddData(textplain, B_MIME_TYPE, (void *)str, count); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4817 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4818 // Add type of selection |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4819 char vtype; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4820 switch (type) |
19526 | 4821 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4822 default: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4823 case MLINE: vtype = 'L'; break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4824 case MCHAR: vtype = 'C'; break; |
19526 | 4825 #ifdef FEAT_VISUAL |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4826 case MBLOCK: vtype = 'B'; break; |
19526 | 4827 #endif |
4828 } | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4829 m->AddData(vimselectiontype, B_MIME_TYPE, (void *)&vtype, 1); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4830 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4831 vim_free(str); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4832 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4833 be_clipboard->Commit(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4834 be_clipboard->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4835 } |
19526 | 4836 } |
4837 | |
4838 #endif // FEAT_CLIPBOARD | |
4839 | |
4840 #ifdef FEAT_BROWSE | |
4841 /* | |
4842 * Pop open a file browser and return the file selected, in allocated memory, | |
4843 * or NULL if Cancel is hit. | |
4844 * saving - TRUE if the file will be saved to, FALSE if it will be opened. | |
4845 * title - Title message for the file browser dialog. | |
4846 * dflt - Default name of file. | |
4847 * ext - Default extension to be added to files without extensions. | |
4848 * initdir - directory in which to open the browser (NULL = current dir) | |
4849 * filter - Filter for matched files to choose from. | |
4850 * Has a format like this: | |
4851 * "C Files (*.c)\0*.c\0" | |
4852 * "All Files\0*.*\0\0" | |
4853 * If these two strings were concatenated, then a choice of two file | |
4854 * filters will be selectable to the user. Then only matching files will | |
4855 * be shown in the browser. If NULL, the default allows all files. | |
4856 * | |
4857 * *NOTE* - the filter string must be terminated with TWO nulls. | |
4858 */ | |
4859 char_u * | |
4860 gui_mch_browse( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4861 int saving, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4862 char_u *title, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4863 char_u *dflt, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4864 char_u *ext, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4865 char_u *initdir, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4866 char_u *filter) |
19526 | 4867 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4868 gui.vimApp->fFilePanel = new BFilePanel((saving == TRUE) ? B_SAVE_PANEL : B_OPEN_PANEL, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4869 NULL, NULL, 0, false, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4870 new BMessage((saving == TRUE) ? 'save' : 'open'), NULL, true); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4871 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4872 gui.vimApp->fBrowsedPath.Unset(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4873 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4874 gui.vimApp->fFilePanel->Window()->SetTitle((char*)title); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4875 gui.vimApp->fFilePanel->SetPanelDirectory((const char*)initdir); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4876 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4877 gui.vimApp->fFilePanel->Show(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4878 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4879 gui.vimApp->fFilePanelSem = create_sem(0, "FilePanelSem"); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4880 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4881 while (acquire_sem(gui.vimApp->fFilePanelSem) == B_INTERRUPTED); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4882 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4883 char_u *fileName = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4884 status_t result = gui.vimApp->fBrowsedPath.InitCheck(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4885 if (result == B_OK) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4886 fileName = vim_strsave((char_u*)gui.vimApp->fBrowsedPath.Path()); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4887 } else |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4888 if (result != B_NO_INIT) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4889 fprintf(stderr, "gui_mch_browse: BPath error: %#08x (%s)\n", |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4890 result, strerror(result)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4891 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4892 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4893 delete gui.vimApp->fFilePanel; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4894 gui.vimApp->fFilePanel = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4895 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4896 return fileName; |
19526 | 4897 } |
4898 #endif // FEAT_BROWSE | |
4899 | |
4900 | |
4901 #if defined(FEAT_GUI_DIALOG) | |
4902 | |
4903 /* | |
4904 * Create a dialog dynamically from the parameter strings. | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4905 * type = type of dialog (question, alert, etc.) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4906 * title = dialog title. may be NULL for default title. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4907 * message = text to display. Dialog sizes to accommodate it. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4908 * buttons = '\n' separated list of button captions, default first. |
19526 | 4909 * dfltbutton = number of default button. |
4910 * | |
4911 * This routine returns 1 if the first button is pressed, | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4912 * 2 for the second, etc. |
19526 | 4913 * |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4914 * 0 indicates Esc was pressed. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4915 * -1 for unexpected error |
19526 | 4916 * |
4917 * If stubbing out this fn, return 1. | |
4918 */ | |
4919 | |
4920 int | |
4921 gui_mch_dialog( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4922 int type, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4923 char_u *title, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4924 char_u *message, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4925 char_u *buttons, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4926 int dfltbutton, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4927 char_u *textfield, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4928 int ex_cmd) |
19526 | 4929 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4930 VimDialog *dialog = new VimDialog(type, (char*)title, (char*)message, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4931 (char*)buttons, dfltbutton, (char*)textfield, ex_cmd); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4932 return dialog->Go(); |
19526 | 4933 } |
4934 | |
4935 #endif // FEAT_GUI_DIALOG | |
4936 | |
4937 | |
4938 /* | |
4939 * Return the RGB value of a pixel as long. | |
4940 */ | |
4941 guicolor_T | |
4942 gui_mch_get_rgb(guicolor_T pixel) | |
4943 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4944 rgb_color rgb = GUI_TO_RGB(pixel); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4945 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4946 return ((rgb.red & 0xff) << 16) + ((rgb.green & 0xff) << 8) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4947 + (rgb.blue & 0xff); |
19526 | 4948 } |
4949 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4950 void |
19526 | 4951 gui_mch_setmouse(int x, int y) |
4952 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4953 TRACE(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4954 // TODO |
19526 | 4955 } |
4956 | |
4957 #ifdef FEAT_MBYTE_IME | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4958 void |
19526 | 4959 im_set_position(int row, int col) |
4960 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4961 if (gui.vimWindow->Lock()) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4962 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4963 gui.vimTextArea->DrawIMString(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4964 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4965 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4966 return; |
19526 | 4967 } |
4968 #endif | |
4969 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4970 void |
19526 | 4971 gui_mch_show_toolbar(int showit) |
4972 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4973 VimToolbar *toolbar = gui.vimForm->ToolBar(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4974 gui.toolbar_height = (toolbar && showit) ? toolbar->ToolbarHeight() : 0.; |
19526 | 4975 } |
4976 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4977 void |
19526 | 4978 gui_mch_set_toolbar_pos(int x, int y, int w, int h) |
4979 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4980 VimToolbar *toolbar = gui.vimForm->ToolBar(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4981 if (toolbar != NULL) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4982 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4983 toolbar->MoveTo(x, y); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4984 toolbar->ResizeTo(w - 1, h - 1); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4985 gui.vimWindow->Unlock(); |
19526 | 4986 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4987 } |
19526 | 4988 } |
4989 | |
4990 #if defined(FEAT_GUI_TABLINE) || defined(PROTO) | |
4991 | |
4992 /* | |
4993 * Show or hide the tabline. | |
4994 */ | |
4995 void | |
4996 gui_mch_show_tabline(int showit) | |
4997 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4998 VimTabLine *tabLine = gui.vimForm->TabLine(); |
19526 | 4999 |
5000 if (tabLine == NULL) | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5001 return; |
19526 | 5002 |
5003 if (!showit != !gui.vimForm->IsShowingTabLine()) { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5004 gui.vimForm->SetShowingTabLine(showit != 0); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5005 gui.tabline_height = gui.vimForm->TablineHeight(); |
19526 | 5006 } |
5007 } | |
5008 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5009 void |
19526 | 5010 gui_mch_set_tabline_pos(int x, int y, int w, int h) |
5011 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5012 VimTabLine *tabLine = gui.vimForm->TabLine(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5013 if (tabLine != NULL) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5014 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5015 tabLine->MoveTo(x, y); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5016 tabLine->ResizeTo(w - 1, h - 1); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5017 gui.vimWindow->Unlock(); |
19526 | 5018 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5019 } |
19526 | 5020 } |
5021 | |
5022 /* | |
5023 * Return TRUE when tabline is displayed. | |
5024 */ | |
5025 int | |
5026 gui_mch_showing_tabline() | |
5027 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5028 VimTabLine *tabLine = gui.vimForm->TabLine(); |
19526 | 5029 return tabLine != NULL && gui.vimForm->IsShowingTabLine(); |
5030 } | |
5031 | |
5032 /* | |
5033 * Update the labels of the tabline. | |
5034 */ | |
5035 void | |
5036 gui_mch_update_tabline() | |
5037 { | |
5038 tabpage_T *tp; | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5039 int nr = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5040 int curtabidx = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5041 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5042 VimTabLine *tabLine = gui.vimForm->TabLine(); |
19526 | 5043 |
5044 if (tabLine == NULL) | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5045 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5046 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5047 gui.vimWindow->Lock(); |
19526 | 5048 |
5049 // Add a label for each tab page. They all contain the same text area. | |
5050 for (tp = first_tabpage; tp != NULL; tp = tp->tp_next, ++nr) { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5051 if (tp == curtab) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5052 curtabidx = nr; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5053 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5054 BTab* tab = tabLine->TabAt(nr); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5055 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5056 if (tab == NULL) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5057 tab = new VimTabLine::VimTab(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5058 tabLine->AddTab(NULL, tab); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5059 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5060 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5061 get_tabline_label(tp, FALSE); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5062 tab->SetLabel((const char*)NameBuff); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5063 tabLine->Invalidate(); |
19526 | 5064 } |
5065 | |
5066 // Remove any old labels. | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5067 while (nr < tabLine->CountTabs()) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5068 tabLine->RemoveTab(nr); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5069 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5070 if (tabLine->Selection() != curtabidx) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5071 tabLine->Select(curtabidx); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5072 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5073 gui.vimWindow->Unlock(); |
19526 | 5074 } |
5075 | |
5076 /* | |
5077 * Set the current tab to "nr". First tab is 1. | |
5078 */ | |
5079 void | |
5080 gui_mch_set_curtab(int nr) | |
5081 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5082 VimTabLine *tabLine = gui.vimForm->TabLine(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5083 if (tabLine == NULL) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5084 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5085 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5086 gui.vimWindow->Lock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5087 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5088 if (tabLine->Selection() != nr -1) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5089 tabLine->Select(nr -1); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5090 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5091 gui.vimWindow->Unlock(); |
19526 | 5092 } |
5093 | |
5094 #endif // FEAT_GUI_TABLINE |