Mercurial > vim
annotate src/gui_haiku.cc @ 32284:8a7a4c1f41e0 v9.0.1473
patch 9.0.1473: CI does not run sound tests
Commit: https://github.com/vim/vim/commit/017227079f104bd69483ee3d33e31490d7e52135
Author: ichizok <gclient.gaap@gmail.com>
Date: Fri Apr 21 17:46:57 2023 +0100
patch 9.0.1473: CI does not run sound tests
Problem: CI does not run sound tests.
Solution: Re-enable sound tests. Use "apt-get" instead of "apt". (Ozaki
Kiichi, closes #12280)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 21 Apr 2023 19:00:04 +0200 |
parents | e26c71f837f5 |
children | c0b3e3c7786c |
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 "version.h" | |
79 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
80 } // extern "C" |
19526 | 81 |
82 // ---------------- start of header part ---------------- | |
83 | |
84 //#include <Alert.h> | |
85 #include <Application.h> | |
86 #include <Beep.h> | |
87 #include <Bitmap.h> | |
88 #include <Box.h> | |
89 #include <Button.h> | |
90 #include <Clipboard.h> | |
91 #include <Debug.h> | |
92 //#include <Directory.h> | |
93 //#include <Entry.h> | |
94 #include <File.h> | |
95 #include <FilePanel.h> | |
96 #include <FindDirectory.h> | |
97 //#include <Font.h> | |
98 #include <IconUtils.h> | |
99 #include <Input.h> | |
100 #include <ListView.h> | |
101 #include <MenuBar.h> | |
102 #include <MenuItem.h> | |
103 //#include <MessageQueue.h> | |
104 //#include <OS.h> | |
105 #include <Path.h> | |
106 #include <PictureButton.h> | |
107 #include <PopUpMenu.h> | |
108 //#include <Region.h> | |
109 #include <Resources.h> | |
110 //#include <Roster.h> | |
111 #include <Screen.h> | |
112 #include <ScrollBar.h> | |
113 #include <ScrollView.h> | |
114 #include <String.h> | |
115 #include <StringView.h> | |
116 //#include <SupportDefs.h> | |
117 #include <TabView.h> | |
118 #include <TextControl.h> | |
119 #include <TextView.h> | |
120 #include <TranslationUtils.h> | |
121 #include <TranslatorFormats.h> | |
122 #include <View.h> | |
123 #include <Window.h> | |
124 | |
125 class VimApp; | |
126 class VimFormView; | |
127 class VimTextAreaView; | |
128 class VimWindow; | |
129 class VimToolbar; | |
130 class VimTabLine; | |
131 | |
132 extern key_map *keyMap; | |
133 extern char *keyMapChars; | |
134 | |
135 extern int main(int argc, char **argv); | |
136 | |
137 #ifndef B_MAX_PORT_COUNT | |
138 #define B_MAX_PORT_COUNT 255 | |
139 #endif | |
140 | |
141 // VimApp seems comparable to the X "vimShell" | |
142 class VimApp: public BApplication | |
143 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
144 typedef BApplication Inherited; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
145 public: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
146 VimApp(const char *appsig); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
147 ~VimApp(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
148 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
149 // callbacks: |
19526 | 150 #if 0 |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
151 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
|
152 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
153 m->PrintToStream(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
154 Inherited::DispatchMessage(m, h); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
155 } |
19526 | 156 #endif |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
157 virtual void ReadyToRun(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
158 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
|
159 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
|
160 virtual bool QuitRequested(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
161 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
|
162 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
163 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
|
164 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
165 sem_id fFilePanelSem; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
166 BFilePanel* fFilePanel; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
167 BPath fBrowsedPath; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
168 private: |
19526 | 169 }; |
170 | |
171 class VimWindow: public BWindow | |
172 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
173 typedef BWindow Inherited; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
174 public: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
175 VimWindow(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
176 ~VimWindow(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
177 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
178 // 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
|
179 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
|
180 virtual bool QuitRequested(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
181 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
182 VimFormView *formView; |
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 private: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
185 void init(); |
19526 | 186 |
187 }; | |
188 | |
189 class VimFormView: public BView | |
190 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
191 typedef BView Inherited; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
192 public: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
193 VimFormView(BRect frame); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
194 ~VimFormView(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
195 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
196 // callbacks: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
197 virtual void AllAttached(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
198 virtual void FrameResized(float new_width, float new_height); |
19526 | 199 |
200 #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
|
201 float MenuHeight() const |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
202 { 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
|
203 BMenuBar *MenuBar() const |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
204 { return menuBar; } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
205 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
206 private: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
207 void init(BRect); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
208 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
209 BMenuBar *menuBar; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
210 VimTextAreaView *textArea; |
19526 | 211 |
212 #ifdef FEAT_TOOLBAR | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
213 public: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
214 float ToolbarHeight() const; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
215 VimToolbar *ToolBar() const |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
216 { return toolBar; } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
217 private: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
218 VimToolbar *toolBar; |
19526 | 219 #endif |
220 | |
221 #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
|
222 public: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
223 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
|
224 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
|
225 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
|
226 float TablineHeight() const; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
227 private: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
228 VimTabLine *tabLine; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
229 int showingTabLine; |
19526 | 230 #endif |
231 }; | |
232 | |
233 class VimTextAreaView: public BView | |
234 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
235 typedef BView Inherited; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
236 public: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
237 VimTextAreaView(BRect frame); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
238 ~VimTextAreaView(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
239 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
240 // callbacks: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
241 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
|
242 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
|
243 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
|
244 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
|
245 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
|
246 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
|
247 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
248 // own functions: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
249 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
|
250 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
|
251 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
|
252 void mchClearAll(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
253 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
|
254 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
|
255 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
256 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
|
257 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
|
258 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
|
259 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
|
260 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
261 int32 mouseDragEventCount; |
19526 | 262 |
263 #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
|
264 void DrawIMString(void); |
19526 | 265 #endif |
266 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
267 private: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
268 void init(BRect); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
269 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
270 int_u vimMouseButton; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
271 int_u vimMouseModifiers; |
19526 | 272 |
273 #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
|
274 struct { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
275 BMessenger* messenger; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
276 BMessage* message; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
277 BPoint location; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
278 int row; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
279 int col; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
280 int count; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
281 } IMData; |
19526 | 282 #endif |
283 }; | |
284 | |
285 class VimScrollBar: public BScrollBar | |
286 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
287 typedef BScrollBar Inherited; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
288 public: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
289 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
|
290 ~VimScrollBar(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
291 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
292 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
|
293 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
|
294 void SetValue(float newval); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
295 scrollbar_T *getGsb() |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
296 { return gsb; } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
297 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
298 int32 scrollEventCount; |
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 private: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
301 scrollbar_T *gsb; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
302 float ignoreValue; |
19526 | 303 }; |
304 | |
305 | |
306 #ifdef FEAT_TOOLBAR | |
307 | |
308 class VimToolbar : public BBox | |
309 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
310 static BBitmap *normalButtonsBitmap; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
311 static BBitmap *grayedButtonsBitmap; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
312 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
313 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
|
314 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
|
315 bool ModifyBitmapToGrayed(BBitmap *bitmap); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
316 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
317 BList fButtonsList; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
318 void InvalidateLayout(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
319 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
320 public: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
321 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
|
322 ~VimToolbar(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
323 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
324 bool PrepareButtonBitmaps(); |
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 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
|
327 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
|
328 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
|
329 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
330 float ToolbarHeight() const; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
331 virtual void AttachedToWindow(); |
19526 | 332 }; |
333 | |
334 BBitmap *VimToolbar::normalButtonsBitmap = NULL; | |
335 BBitmap *VimToolbar::grayedButtonsBitmap = NULL; | |
336 | |
337 const float ToolbarMargin = 3.; | |
338 const float ButtonMargin = 3.; | |
339 | |
340 #endif //FEAT_TOOLBAR | |
341 | |
342 #ifdef FEAT_GUI_TABLINE | |
343 | |
344 class VimTabLine : public BTabView | |
345 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
346 public: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
347 class VimTab : public BTab { |
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 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
|
350 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
351 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
|
352 }; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
353 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
354 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
|
355 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
|
356 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
357 float TablineHeight() const; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
358 virtual void MouseDown(BPoint point); |
19526 | 359 }; |
360 | |
361 #endif //FEAT_GUI_TABLINE | |
362 | |
363 | |
364 // For caching the fonts that are used; | |
365 // Vim seems rather sloppy in this regard. | |
366 class VimFont: public BFont | |
367 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
368 typedef BFont Inherited; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
369 public: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
370 VimFont(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
371 VimFont(const VimFont *rhs); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
372 VimFont(const BFont *rhs); |
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(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
375 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
376 VimFont *next; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
377 int refcount; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
378 char_u *name; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
379 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
380 private: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
381 void init(); |
19526 | 382 }; |
383 | |
384 #if defined(FEAT_GUI_DIALOG) | |
385 | |
386 class VimDialog : public BWindow | |
387 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
388 typedef BWindow Inherited; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
389 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
390 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
|
391 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
392 public: |
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 class View : public BView { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
395 typedef BView Inherited; |
19526 | 396 |
397 public: | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
398 View(BRect frame); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
399 ~View(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
400 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
401 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
|
402 void InitIcon(int32 type); |
19526 | 403 |
404 private: | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
405 BBitmap* fIconBitmap; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
406 }; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
407 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
408 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
|
409 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
|
410 int ex_cmd); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
411 ~VimDialog(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
412 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
413 int Go(); |
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 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
|
416 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
417 private: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
418 sem_id fDialogSem; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
419 int fDialogValue; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
420 BList fButtonsList; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
421 BTextView* fMessageView; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
422 BTextControl* fInputControl; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
423 const char* fInputValue; |
19526 | 424 }; |
425 | |
426 class VimSelectFontDialog : public BWindow | |
427 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
428 typedef BWindow Inherited; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
429 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
430 void _CleanList(BListView* list); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
431 void _UpdateFontStyles(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
432 void _UpdateSizeInputPreview(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
433 void _UpdateFontPreview(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
434 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
|
435 public: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
436 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
437 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
|
438 ~VimSelectFontDialog(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
439 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
440 bool Go(); |
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 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
|
443 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
444 private: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
445 status_t fStatus; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
446 sem_id fDialogSem; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
447 bool fDialogValue; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
448 font_family* fFamily; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
449 font_style* fStyle; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
450 float* fSize; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
451 font_family fFontFamily; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
452 font_style fFontStyle; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
453 float fFontSize; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
454 BStringView* fPreview; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
455 BListView* fFamiliesList; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
456 BListView* fStylesList; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
457 BListView* fSizesList; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
458 BTextControl* fSizesInput; |
19526 | 459 }; |
460 | |
461 #endif // FEAT_GUI_DIALOG | |
462 | |
463 // ---------------- end of GUI classes ---------------- | |
464 | |
465 struct MainArgs { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
466 int argc; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
467 char **argv; |
19526 | 468 }; |
469 | |
470 // These messages are copied through the VDCMP. | |
471 // Therefore they ought not to have anything fancy. | |
472 // They must be of POD type (Plain Old Data) | |
473 // as the C++ standard calls them. | |
474 | |
475 #define KEY_MSG_BUFSIZ 7 | |
476 #if KEY_MSG_BUFSIZ < MAX_KEY_CODE_LEN | |
477 #error Increase KEY_MSG_BUFSIZ! | |
478 #endif | |
479 | |
480 struct VimKeyMsg { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
481 char_u length; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
482 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
|
483 bool csi_escape; |
19526 | 484 }; |
485 | |
486 struct VimResizeMsg { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
487 int width; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
488 int height; |
19526 | 489 }; |
490 | |
491 struct VimScrollBarMsg { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
492 VimScrollBar *sb; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
493 long value; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
494 int stillDragging; |
19526 | 495 }; |
496 | |
497 struct VimMenuMsg { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
498 vimmenu_T *guiMenu; |
19526 | 499 }; |
500 | |
501 struct VimMouseMsg { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
502 int button; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
503 int x; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
504 int y; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
505 int repeated_click; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
506 int_u modifiers; |
19526 | 507 }; |
508 | |
509 struct VimMouseMovedMsg { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
510 int x; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
511 int y; |
19526 | 512 }; |
513 | |
514 struct VimFocusMsg { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
515 bool active; |
19526 | 516 }; |
517 | |
518 struct VimRefsMsg { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
519 BMessage *message; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
520 bool changedir; |
19526 | 521 }; |
522 | |
523 struct VimTablineMsg { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
524 int index; |
19526 | 525 }; |
526 | |
527 struct VimTablineMenuMsg { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
528 int index; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
529 int event; |
19526 | 530 }; |
531 | |
532 struct VimMsg { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
533 enum VimMsgType { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
534 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
|
535 }; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
536 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
537 union { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
538 struct VimKeyMsg Key; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
539 struct VimResizeMsg NewSize; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
540 struct VimScrollBarMsg Scroll; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
541 struct VimMenuMsg Menu; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
542 struct VimMouseMsg Mouse; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
543 struct VimMouseMovedMsg MouseMoved; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
544 struct VimFocusMsg Focus; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
545 struct VimRefsMsg Refs; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
546 struct VimTablineMsg Tabline; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
547 struct VimTablineMenuMsg TablineMenu; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
548 } u; |
19526 | 549 }; |
550 | |
551 #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
|
552 #define GUI_TO_RGB(g) { (char_u)((g) >> 16), (char_u)((g) >> 8), (char_u)((g) >> 0), 255 } |
19526 | 553 |
554 // ---------------- end of header part ---------------- | |
555 | |
556 static struct specialkey | |
557 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
558 uint16 BeKeys; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
559 #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
|
560 #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
|
561 #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
|
562 char_u vim_code0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
563 char_u vim_code1; |
19526 | 564 } special_keys[] = |
565 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
566 {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
|
567 {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
|
568 {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
|
569 {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
|
570 {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
|
571 {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
|
572 {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
|
573 {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
|
574 {K(B_END), '@', '7'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
575 {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
|
576 {K(B_PAGE_DOWN), 'k', 'N'}, // XK_Next, |
19526 | 577 |
578 #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
|
579 {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
|
580 {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
|
581 {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
|
582 {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
|
583 {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
|
584 {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
|
585 {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
|
586 {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
|
587 {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
|
588 {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
|
589 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
590 {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
|
591 {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
|
592 // {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
|
593 // sysreq |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
594 {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
|
595 {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
|
596 // {XK_F16, 'F', '6'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
597 // {XK_F17, 'F', '7'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
598 // {XK_F18, 'F', '8'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
599 // {XK_F19, 'F', '9'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
600 // {XK_F20, 'F', 'A'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
601 // {XK_F21, 'F', 'B'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
602 // {XK_F22, 'F', 'C'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
603 // {XK_F23, 'F', 'D'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
604 // {XK_F24, 'F', 'E'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
605 // {XK_F25, 'F', 'F'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
606 // {XK_F26, 'F', 'G'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
607 // {XK_F27, 'F', 'H'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
608 // {XK_F28, 'F', 'I'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
609 // {XK_F29, 'F', 'J'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
610 // {XK_F30, 'F', 'K'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
611 // {XK_F31, 'F', 'L'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
612 // {XK_F32, 'F', 'M'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
613 // {XK_F33, 'F', 'N'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
614 // {XK_F34, 'F', 'O'}, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
615 // {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
|
616 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
617 // {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
|
618 {F(B_PRINT_KEY), '%', '9'}, |
19526 | 619 |
620 #if 0 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
621 // Keypad keys: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
622 {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
|
623 {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
|
624 {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
|
625 {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
|
626 {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
|
627 {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
|
628 {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
|
629 {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
|
630 {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
|
631 {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
|
632 {F(0x49), '&', '8'}, // XK_Undo, keypad 5 |
19526 | 633 #endif |
634 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
635 // End of list marker: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
636 {0, 0, 0} |
19526 | 637 }; |
638 | |
24768
7334bf933510
patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents:
23229
diff
changeset
|
639 #define NUM_SPECIAL_KEYS ARRAY_LENGTH(special_keys) |
19526 | 640 |
641 // ---------------- VimApp ---------------- | |
642 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
643 static void |
19526 | 644 docd(BPath &path) |
645 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
646 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
|
647 // 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
|
648 do_cmdline_cmd((char_u *)"cd ."); |
19526 | 649 } |
650 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
651 static void |
19526 | 652 drop_callback(void *cookie) |
653 { | |
654 // 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
|
655 // file (see src/gui_mac.c, deleted in 8.2.1422) |
19526 | 656 // 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
|
657 update_screen(UPD_NOT_VALID); |
19526 | 658 } |
659 | |
660 // 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
|
661 static void |
19526 | 662 RefsReceived(BMessage *m, bool changedir) |
663 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
664 uint32 type; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
665 int32 count; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
666 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
667 m->PrintToStream(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
668 switch (m->what) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
669 case B_REFS_RECEIVED: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
670 case B_SIMPLE_DATA: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
671 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
|
672 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
|
673 goto bad; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
674 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
675 case B_ARGV_RECEIVED: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
676 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
|
677 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
|
678 goto bad; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
679 if (changedir) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
680 char *dirname; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
681 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
|
682 chdir(dirname); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
683 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
|
684 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
685 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
686 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
687 default: |
19526 | 688 bad: |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
689 /*fprintf(stderr, "bad!\n"); */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
690 delete m; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
691 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
692 } |
19526 | 693 |
694 #ifdef FEAT_VISUAL | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
695 reset_VIsual(); |
19526 | 696 #endif |
697 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
698 char_u **fnames; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
699 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
|
700 int fname_index = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
701 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
702 switch (m->what) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
703 case B_REFS_RECEIVED: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
704 case B_SIMPLE_DATA: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
705 // 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
|
706 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
|
707 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
708 entry_ref ref; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
709 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
|
710 BEntry entry(&ref, false); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
711 BPath path; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
712 entry.GetPath(&path); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
713 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
714 // Change to parent directory? |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
715 if (changedir) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
716 BPath parentpath; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
717 path.GetParent(&parentpath); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
718 docd(parentpath); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
719 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
720 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
721 // 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
|
722 BDirectory bdir(&ref); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
723 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
|
724 // 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
|
725 if (!changedir) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
726 docd(path); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
727 } else { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
728 mch_dirname(IObuff, IOSIZE); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
729 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
|
730 if (fname == NULL) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
731 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
|
732 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
|
733 // 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
|
734 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
735 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
736 // 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
|
737 changedir = false; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
738 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
739 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
740 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
741 case B_ARGV_RECEIVED: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
742 // 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
|
743 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
|
744 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
745 char *fname; |
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 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
|
748 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
|
749 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
750 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
751 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
752 default: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
753 // 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
|
754 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
755 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
756 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
757 delete m; |
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 // 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
|
760 if (fname_index > 0) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
761 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
|
762 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
763 setcursor(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
764 out_flush(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
765 } else { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
766 vim_free(fnames); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
767 } |
19526 | 768 } |
769 | |
770 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
|
771 BApplication(appsig), |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
772 fFilePanelSem(-1), |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
773 fFilePanel(NULL) |
19526 | 774 { |
775 } | |
776 | |
777 VimApp::~VimApp() | |
778 { | |
779 } | |
780 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
781 void |
19526 | 782 VimApp::ReadyToRun() |
783 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
784 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
785 * 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
|
786 * 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
|
787 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
788 signal(SIGINT, SIG_IGN); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
789 signal(SIGQUIT, SIG_IGN); |
19526 | 790 } |
791 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
792 void |
19526 | 793 VimApp::ArgvReceived(int32 arg_argc, char **arg_argv) |
794 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
795 if (!IsLaunching()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
796 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
797 * 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
|
798 * 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
|
799 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
800 if (gui.vimWindow) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
801 gui.vimWindow->Minimize(false); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
802 BMessage *m = CurrentMessage(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
803 DetachCurrentMessage(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
804 SendRefs(m, true); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
805 } |
19526 | 806 } |
807 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
808 void |
19526 | 809 VimApp::RefsReceived(BMessage *m) |
810 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
811 // 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
|
812 // 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
|
813 // 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
|
814 // split instead of abandoned. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
815 int limit = 15; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
816 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
|
817 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
|
818 if (gui.vimWindow) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
819 gui.vimWindow->Minimize(false); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
820 DetachCurrentMessage(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
821 SendRefs(m, true); |
19526 | 822 } |
823 | |
824 /* | |
825 * Pass a BMessage on to the main() thread. | |
826 * Caller must have detached the message. | |
827 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
828 void |
19526 | 829 VimApp::SendRefs(BMessage *m, bool changedir) |
830 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
831 VimRefsMsg rm; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
832 rm.message = m; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
833 rm.changedir = changedir; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
834 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
835 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
|
836 // calls ::RefsReceived |
19526 | 837 } |
838 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
839 void |
19526 | 840 VimApp::MessageReceived(BMessage *m) |
841 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
842 switch (m->what) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
843 case 'save': |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
844 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
845 entry_ref refDirectory; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
846 m->FindRef("directory", &refDirectory); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
847 fBrowsedPath.SetTo(&refDirectory); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
848 BString strName; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
849 m->FindString("name", &strName); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
850 fBrowsedPath.Append(strName.String()); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
851 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
852 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
853 case 'open': |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
854 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
855 entry_ref ref; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
856 m->FindRef("refs", &ref); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
857 fBrowsedPath.SetTo(&ref); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
858 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
859 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
860 case B_CANCEL: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
861 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
862 BFilePanel *panel; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
863 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
|
864 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
|
865 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
866 delete_sem(fFilePanelSem); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
867 fFilePanelSem = -1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
868 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
869 |
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 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
872 default: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
873 Inherited::MessageReceived(m); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
874 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
875 } |
19526 | 876 } |
877 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
878 bool |
19526 | 879 VimApp::QuitRequested() |
880 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
881 (void)Inherited::QuitRequested(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
882 return false; |
19526 | 883 } |
884 | |
885 // ---------------- VimWindow ---------------- | |
886 | |
887 VimWindow::VimWindow(): | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
888 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
|
889 "Vim", |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
890 B_TITLED_WINDOW, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
891 0, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
892 B_CURRENT_WORKSPACE) |
19526 | 893 |
894 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
895 init(); |
19526 | 896 } |
897 | |
898 VimWindow::~VimWindow() | |
899 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
900 if (formView) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
901 RemoveChild(formView); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
902 delete formView; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
903 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
904 gui.vimWindow = NULL; |
19526 | 905 } |
906 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
907 void |
19526 | 908 VimWindow::init() |
909 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
910 // Attach the VimFormView |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
911 formView = new VimFormView(Bounds()); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
912 if (formView != NULL) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
913 AddChild(formView); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
914 } |
19526 | 915 } |
916 | |
917 #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
|
918 void |
19526 | 919 VimWindow::DispatchMessage(BMessage *m, BHandler *h) |
920 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
921 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
922 * 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
|
923 * 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
|
924 * intended future system behaviour. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
925 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
926 switch (m->what) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
927 case B_MOUSE_UP: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
928 // if (!h) h = PreferredHandler(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
929 // 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
|
930 // 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
|
931 // 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
|
932 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
933 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
|
934 if (v) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
935 // m->PrintToStream(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
936 BPoint where; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
937 m->FindPoint("where", &where); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
938 v->MouseUp(where); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
939 } else { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
940 Inherited::DispatchMessage(m, h); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
941 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
942 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
943 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
944 default: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
945 Inherited::DispatchMessage(m, h); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
946 } |
19526 | 947 } |
948 #endif | |
949 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
950 void |
19526 | 951 VimWindow::WindowActivated(bool active) |
952 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
953 Inherited::WindowActivated(active); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
954 // 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
|
955 if (active && gui.vimTextArea) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
956 gui.vimTextArea->MakeFocus(true); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
957 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
958 struct VimFocusMsg fm; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
959 fm.active = active; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
960 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
961 write_port(gui.vdcmp, VimMsg::Focus, &fm, sizeof(fm)); |
19526 | 962 } |
963 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
964 bool |
19526 | 965 VimWindow::QuitRequested() |
966 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
967 struct VimKeyMsg km; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
968 km.length = 5; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
969 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
|
970 km.csi_escape = false; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
971 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
|
972 return false; |
19526 | 973 } |
974 | |
975 // ---------------- VimFormView ---------------- | |
976 | |
977 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
|
978 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
|
979 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
|
980 menuBar(NULL), |
19526 | 981 #ifdef FEAT_TOOLBAR |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
982 toolBar(NULL), |
19526 | 983 #endif |
984 #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
|
985 // showingTabLine(false), |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
986 tabLine(NULL), |
19526 | 987 #endif |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
988 textArea(NULL) |
19526 | 989 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
990 init(frame); |
19526 | 991 } |
992 | |
993 VimFormView::~VimFormView() | |
994 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
995 if (menuBar) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
996 RemoveChild(menuBar); |
19526 | 997 #ifdef never |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
998 // 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
|
999 // 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
|
1000 delete menuBar; |
19526 | 1001 #endif |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1002 } |
19526 | 1003 |
1004 #ifdef FEAT_TOOLBAR | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1005 delete toolBar; |
19526 | 1006 #endif |
1007 | |
1008 #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
|
1009 delete tabLine; |
19526 | 1010 #endif |
1011 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1012 if (textArea) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1013 RemoveChild(textArea); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1014 delete textArea; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1015 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1016 gui.vimForm = NULL; |
19526 | 1017 } |
1018 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1019 void |
19526 | 1020 VimFormView::init(BRect frame) |
1021 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1022 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
|
1023 "VimMenuBar"); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1024 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1025 AddChild(menuBar); |
19526 | 1026 |
1027 #ifdef FEAT_TOOLBAR | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1028 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
|
1029 toolBar->PrepareButtonBitmaps(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1030 AddChild(toolBar); |
19526 | 1031 #endif |
1032 | |
1033 #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
|
1034 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
|
1035 // tabLine->PrepareButtonBitmaps(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1036 AddChild(tabLine); |
19526 | 1037 #endif |
1038 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1039 BRect remaining = frame; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1040 textArea = new VimTextAreaView(remaining); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1041 AddChild(textArea); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1042 // 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
|
1043 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1044 gui.vimForm = this; |
19526 | 1045 } |
1046 | |
1047 #ifdef FEAT_TOOLBAR | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1048 float |
19526 | 1049 VimFormView::ToolbarHeight() const |
1050 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1051 return toolBar ? toolBar->ToolbarHeight() : 0.; |
19526 | 1052 } |
1053 #endif | |
1054 | |
1055 #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
|
1056 float |
19526 | 1057 VimFormView::TablineHeight() const |
1058 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1059 return (tabLine && IsShowingTabLine()) ? tabLine->TablineHeight() : 0.; |
19526 | 1060 } |
1061 #endif | |
1062 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1063 void |
19526 | 1064 VimFormView::AllAttached() |
1065 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1066 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1067 * 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
|
1068 * 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
|
1069 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1070 signal(SIGINT, SIG_IGN); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1071 signal(SIGQUIT, SIG_IGN); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1072 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1073 if (menuBar && textArea) { |
19526 | 1074 /* |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1075 * 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
|
1076 * 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
|
1077 * menus are added to the menu bar. |
19526 | 1078 */ |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1079 BRect remaining = Bounds(); |
19526 | 1080 |
1081 #ifdef FEAT_MENU | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1082 remaining.top += MenuHeight(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1083 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
|
1084 gui.menu_height = (int) MenuHeight(); |
19526 | 1085 #endif |
1086 | |
1087 #ifdef FEAT_TOOLBAR | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1088 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
|
1089 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
|
1090 remaining.top += ToolbarHeight(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1091 gui.toolbar_height = ToolbarHeight(); |
19526 | 1092 #endif |
1093 | |
1094 #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
|
1095 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
|
1096 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
|
1097 remaining.top += TablineHeight(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1098 gui.tabline_height = TablineHeight(); |
19526 | 1099 #endif |
1100 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1101 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
|
1102 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
|
1103 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1104 |
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 Inherited::AllAttached(); |
19526 | 1107 } |
1108 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1109 void |
19526 | 1110 VimFormView::FrameResized(float new_width, float new_height) |
1111 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1112 struct VimResizeMsg sm; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1113 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
|
1114 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1115 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
|
1116 new_height += 1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1117 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1118 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
|
1119 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
|
1120 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
|
1121 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
|
1122 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1123 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
|
1124 sm.width -= adjust_w; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1125 sm.height -= adjust_h; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1126 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1127 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1128 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
|
1129 // 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
|
1130 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1131 return; |
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 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1134 * 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
|
1135 * 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
|
1136 * 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
|
1137 * 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
|
1138 */ |
19526 | 1139 } |
1140 | |
1141 // ---------------- VimTextAreaView ---------------- | |
1142 | |
1143 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
|
1144 BView(frame, "VimTextAreaView", B_FOLLOW_ALL_SIDES, |
19526 | 1145 #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
|
1146 B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_INPUT_METHOD_AWARE |
19526 | 1147 #else |
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 |
19526 | 1149 #endif |
20277
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
1150 ), |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1151 mouseDragEventCount(0) |
19526 | 1152 { |
1153 #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
|
1154 IMData.messenger = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1155 IMData.message = NULL; |
19526 | 1156 #endif |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1157 init(frame); |
19526 | 1158 } |
1159 | |
1160 VimTextAreaView::~VimTextAreaView() | |
1161 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1162 gui.vimTextArea = NULL; |
19526 | 1163 } |
1164 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1165 void |
19526 | 1166 VimTextAreaView::init(BRect frame) |
1167 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1168 // 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
|
1169 gui.vimTextArea = this; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1170 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1171 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1172 * 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
|
1173 * 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
|
1174 * (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
|
1175 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1176 SetViewColor(B_TRANSPARENT_32_BIT); |
19526 | 1177 #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
|
1178 SetPenSize(PEN_WIDTH); |
19526 | 1179 #define W_WIDTH(curwin) 0 |
1180 } | |
1181 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1182 void |
19526 | 1183 VimTextAreaView::Draw(BRect updateRect) |
1184 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1185 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1186 * 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
|
1187 * 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
|
1188 * 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
|
1189 * 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
|
1190 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1191 |
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 * 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
|
1194 * 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
|
1195 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1196 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
|
1197 SetLowColor(rgb); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1198 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
|
1199 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
|
1200 (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
|
1201 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1202 // 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
|
1203 SetLowColor(rgb); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1204 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1205 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
|
1206 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
|
1207 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
|
1208 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
|
1209 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
|
1210 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
|
1211 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
|
1212 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
|
1213 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
|
1214 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
|
1215 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
|
1216 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
|
1217 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1218 #ifdef FEAT_MBYTE_IME |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1219 DrawIMString(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1220 #endif |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1221 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1222 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1223 void |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1224 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
|
1225 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1226 struct VimKeyMsg km; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1227 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
|
1228 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1229 bool canHaveVimModifiers = false; |
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 BMessage *msg = Window()->CurrentMessage(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1232 assert(msg); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1233 // msg->PrintToStream(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1234 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1235 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1236 * 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
|
1237 * 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
|
1238 * 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
|
1239 * 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
|
1240 * 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
|
1241 * do... |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1242 * 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
|
1243 * 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
|
1244 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1245 if (numBytes > 1) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1246 // 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
|
1247 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
|
1248 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
|
1249 km.length = numBytes; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1250 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
|
1251 km.csi_escape = true; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1252 } else { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1253 int32 scancode = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1254 msg->FindInt32("key", &scancode); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1255 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1256 int32 beModifiers = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1257 msg->FindInt32("modifiers", &beModifiers); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1258 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1259 char_u string[3]; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1260 int len = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1261 km.length = 0; |
19526 | 1262 |
1263 /* | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1264 * 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
|
1265 * to check if they might be a special key. They aren't. |
19526 | 1266 */ |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1267 assert(B_BACKSPACE <= 0x20); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1268 assert(B_DELETE == 0x7F); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1269 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
|
1270 numBytes == 1) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1271 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1272 * 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
|
1273 * 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
|
1274 * 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
|
1275 * 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
|
1276 * 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
|
1277 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1278 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
|
1279 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
|
1280 int newNumBytes = keyMapChars[index]; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1281 char_u *newBytes = (char_u *)&keyMapChars[index + 1]; |
19526 | 1282 |
1283 /* | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1284 * 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
|
1285 * 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
|
1286 * 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
|
1287 * Otherwise we could simply have checked for equality. |
19526 | 1288 */ |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1289 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
|
1290 *newBytes != 0x7F )) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1291 goto notspecial; |
19526 | 1292 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1293 bytes = (char *)newBytes; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1294 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1295 canHaveVimModifiers = true; |
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 uint16 beoskey; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1298 int first, last; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1299 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1300 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1301 * 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
|
1302 * (does not happen yet) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1303 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1304 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
|
1305 beoskey = F(scancode); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1306 first = FIRST_FUNCTION_KEY; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1307 last = NUM_SPECIAL_KEYS; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1308 } 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
|
1309 // 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
|
1310 string[0] = '\r'; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1311 len = 1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1312 first = last = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1313 } else { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1314 beoskey = K(bytes[0]); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1315 first = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1316 last = FIRST_FUNCTION_KEY; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1317 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1318 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1319 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
|
1320 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
|
1321 string[0] = CSI; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1322 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
|
1323 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
|
1324 len = 3; |
19526 | 1325 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1326 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1327 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1328 notspecial: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1329 if (len == 0) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1330 string[0] = bytes[0]; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1331 len = 1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1332 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1333 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1334 // Special keys (and a few others) may have modifiers |
19526 | 1335 #if 0 |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1336 if (len == 3 || |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1337 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
|
1338 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
|
1339 bytes[0] == B_ESCAPE) |
19526 | 1340 #else |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1341 if (canHaveVimModifiers) |
19526 | 1342 #endif |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1343 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1344 int modifiers; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1345 modifiers = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1346 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
|
1347 modifiers |= MOD_MASK_SHIFT; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1348 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
|
1349 modifiers |= MOD_MASK_CTRL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1350 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
|
1351 modifiers |= MOD_MASK_ALT; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1352 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1353 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1354 * 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
|
1355 * 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
|
1356 * 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
|
1357 * string[0] == CSI...) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1358 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1359 int key; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1360 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
|
1361 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
|
1362 else |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1363 key = string[0]; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1364 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
|
1365 if (IS_SPECIAL(key)) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1366 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1367 string[0] = CSI; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1368 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
|
1369 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
|
1370 len = 3; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1371 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1372 else |
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 string[0] = key; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1375 len = 1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1376 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1377 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1378 if (modifiers) |
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 *dest++ = CSI; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1381 *dest++ = KS_MODIFIER; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1382 *dest++ = modifiers; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1383 km.length = 3; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1384 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1385 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1386 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
|
1387 km.length += len; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1388 km.csi_escape = false; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1389 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1390 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1391 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
|
1392 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1393 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1394 * 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
|
1395 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1396 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
|
1397 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1398 guiBlankMouse(true); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1399 gui.pointer_hidden = TRUE; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1400 } |
19526 | 1401 } |
1402 void | |
1403 VimTextAreaView::guiSendMouseEvent( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1404 int button, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1405 int x, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1406 int y, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1407 int repeated_click, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1408 int_u modifiers) |
19526 | 1409 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1410 VimMouseMsg mm; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1411 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1412 mm.button = button; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1413 mm.x = x; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1414 mm.y = y; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1415 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
|
1416 mm.modifiers = modifiers; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1417 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1418 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
|
1419 // 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
|
1420 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1421 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1422 * 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
|
1423 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1424 if (gui.pointer_hidden) |
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 guiBlankMouse(false); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1427 gui.pointer_hidden = FALSE; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1428 } |
19526 | 1429 } |
1430 | |
1431 void | |
1432 VimTextAreaView::guiMouseMoved( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1433 int x, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1434 int y) |
19526 | 1435 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1436 VimMouseMovedMsg mm; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1437 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1438 mm.x = x; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1439 mm.y = y; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1440 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1441 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
|
1442 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1443 if (gui.pointer_hidden) |
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 guiBlankMouse(false); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1446 gui.pointer_hidden = FALSE; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1447 } |
19526 | 1448 } |
1449 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1450 void |
19526 | 1451 VimTextAreaView::guiBlankMouse(bool should_hide) |
1452 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1453 if (should_hide) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1454 // gui.vimApp->HideCursor(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1455 gui.vimApp->ObscureCursor(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1456 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1457 * 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
|
1458 * 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
|
1459 * correspond to reality. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1460 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1461 } else { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1462 // gui.vimApp->ShowCursor(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1463 } |
19526 | 1464 } |
1465 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1466 int_u |
19526 | 1467 VimTextAreaView::mouseModifiersToVim(int32 beModifiers) |
1468 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1469 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
|
1470 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1471 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
|
1472 vim_modifiers |= MOUSE_SHIFT; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1473 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
|
1474 vim_modifiers |= MOUSE_CTRL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1475 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
|
1476 vim_modifiers |= MOUSE_ALT; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1477 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1478 return vim_modifiers; |
19526 | 1479 } |
1480 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1481 void |
19526 | 1482 VimTextAreaView::MouseDown(BPoint point) |
1483 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1484 BMessage *m = Window()->CurrentMessage(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1485 assert(m); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1486 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1487 int32 buttons = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1488 m->FindInt32("buttons", &buttons); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1489 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1490 int vimButton; |
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 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
|
1493 vimButton = MOUSE_LEFT; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1494 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
|
1495 vimButton = MOUSE_RIGHT; |
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_TERTIARY_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_MIDDLE; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1498 else |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1499 return; // Unknown button |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1500 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1501 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
|
1502 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1503 // Handle multiple clicks |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1504 int32 clicks = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1505 m->FindInt32("clicks", &clicks); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1506 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1507 int32 modifiers = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1508 m->FindInt32("modifiers", &modifiers); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1509 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1510 vimMouseModifiers = mouseModifiersToVim(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 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
|
1513 clicks > 1 /* = repeated_click*/, vimMouseModifiers); |
19526 | 1514 } |
1515 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1516 void |
19526 | 1517 VimTextAreaView::MouseUp(BPoint point) |
1518 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1519 vimMouseButton = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1520 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1521 BMessage *m = Window()->CurrentMessage(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1522 assert(m); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1523 // m->PrintToStream(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1524 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1525 int32 modifiers = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1526 m->FindInt32("modifiers", &modifiers); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1527 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1528 vimMouseModifiers = mouseModifiersToVim(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 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
|
1531 0 /* = repeated_click*/, vimMouseModifiers); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1532 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1533 Inherited::MouseUp(point); |
19526 | 1534 } |
1535 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1536 void |
19526 | 1537 VimTextAreaView::MouseMoved(BPoint point, uint32 transit, const BMessage *message) |
1538 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1539 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1540 * 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
|
1541 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1542 if (gui.pointer_hidden) |
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 guiBlankMouse(false); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1545 gui.pointer_hidden = FALSE; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1546 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1547 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1548 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
|
1549 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
|
1550 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1551 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1552 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1553 atomic_add(&mouseDragEventCount, 1); |
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 // 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
|
1556 guiSendMouseEvent(MOUSE_DRAG, point.x, point.y, 0, vimMouseModifiers); |
19526 | 1557 } |
1558 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1559 void |
19526 | 1560 VimTextAreaView::MessageReceived(BMessage *m) |
1561 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1562 switch (m->what) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1563 case 'menu': |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1564 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1565 VimMenuMsg mm; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1566 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
|
1567 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
|
1568 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
|
1569 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1570 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1571 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
|
1572 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1573 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
|
1574 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
|
1575 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
|
1576 scb->GetSteps(&small, &big); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1577 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
|
1578 scb->ValueChanged(scb->Value()); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1579 #if 0 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1580 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
|
1581 scb->GetSteps(&small, &big); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1582 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
|
1583 scb->ValueChanged(scb->Value()); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1584 #endif |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1585 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1586 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1587 #ifdef FEAT_MBYTE_IME |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1588 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
|
1589 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1590 int32 opcode; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1591 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
|
1592 switch(opcode) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1593 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1594 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
|
1595 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
|
1596 IMData.messenger = new BMessenger(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1597 m->FindMessenger("be:reply_to", IMData.messenger); |
19526 | 1598 break; |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1599 case B_INPUT_METHOD_CHANGED: |
19526 | 1600 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1601 BString str; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1602 bool confirmed; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1603 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
|
1604 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
|
1605 DrawIMString(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1606 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
|
1607 if (confirmed) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1608 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1609 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
|
1610 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
|
1611 struct VimKeyMsg km; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1612 km.csi_escape = true; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1613 int clen; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1614 int i = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1615 while (i < str.Length()) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1616 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1617 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
|
1618 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
|
1619 km.length = clen; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1620 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
|
1621 i += clen; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1622 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1623 } |
19526 | 1624 } |
1625 break; | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1626 case B_INPUT_METHOD_LOCATION_REQUEST: |
19526 | 1627 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1628 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
|
1629 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
|
1630 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
|
1631 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
|
1632 IMData.messenger->SendMessage(&msg); |
19526 | 1633 } |
1634 break; | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1635 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
|
1636 delete IMData.messenger; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1637 delete IMData.message; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1638 IMData.messenger = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1639 IMData.message = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1640 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1641 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1642 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1643 // TODO: sz: break here??? |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1644 #endif |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1645 default: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1646 if (m->WasDropped()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1647 BWindow *w = Window(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1648 w->DetachCurrentMessage(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1649 w->Minimize(false); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1650 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
|
1651 } else { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1652 Inherited::MessageReceived(m); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1653 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1654 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1655 } |
19526 | 1656 } |
1657 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1658 int |
19526 | 1659 VimTextAreaView::mchInitFont(char_u *name) |
1660 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1661 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
|
1662 if (newFont != NOFONT) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1663 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
|
1664 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
|
1665 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
|
1666 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
|
1667 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1668 SetDrawingMode(B_OP_COPY); |
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 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1671 * 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
|
1672 * 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
|
1673 * 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
|
1674 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1675 return OK; |
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 FAIL; |
19526 | 1678 } |
1679 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1680 void |
19526 | 1681 VimTextAreaView::mchDrawString(int row, int col, char_u *s, int len, int flags) |
1682 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1683 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1684 * 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
|
1685 * 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
|
1686 * 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
|
1687 * 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
|
1688 * (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
|
1689 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1690 if (!(flags & DRAW_TRANSP)) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1691 int cells; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1692 cells = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1693 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
|
1694 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
|
1695 if (cn<4) cells += cn; |
19526 | 1696 } |
1697 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1698 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
|
1699 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
|
1700 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
|
1701 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1702 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1703 BFont font; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1704 this->GetFont(&font); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1705 if (!font.IsFixed()) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1706 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1707 char* p = (char*)s; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1708 int32 clen, lastpos = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1709 BPoint where; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1710 int cells; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1711 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
|
1712 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
|
1713 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
|
1714 DrawString(p, clen, where); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1715 if (flags & DRAW_BOLD) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1716 where.x += 1.0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1717 SetDrawingMode(B_OP_BLEND); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1718 DrawString(p, clen, where); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1719 SetDrawingMode(B_OP_COPY); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1720 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1721 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
|
1722 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
|
1723 else lastpos++; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1724 p += clen; |
19526 | 1725 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1726 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1727 else |
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 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
|
1730 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
|
1731 if (flags & DRAW_BOLD) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1732 where.x += 1.0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1733 SetDrawingMode(B_OP_BLEND); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1734 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
|
1735 SetDrawingMode(B_OP_COPY); |
19526 | 1736 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1737 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1738 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1739 if (flags & DRAW_UNDERL) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1740 int cells; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1741 cells = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1742 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
|
1743 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
|
1744 if (cn<4) cells += cn; |
19526 | 1745 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1746 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1747 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
|
1748 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
|
1749 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1750 StrokeLine(start, end); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1751 } |
19526 | 1752 } |
1753 | |
1754 void | |
1755 VimTextAreaView::mchClearBlock( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1756 int row1, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1757 int col1, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1758 int row2, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1759 int col2) |
19526 | 1760 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1761 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
|
1762 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
|
1763 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
|
1764 FillRect(r, B_SOLID_LOW); |
19526 | 1765 } |
1766 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1767 void |
19526 | 1768 VimTextAreaView::mchClearAll() |
1769 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1770 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
|
1771 FillRect(Bounds(), B_SOLID_LOW); |
19526 | 1772 } |
1773 | |
1774 /* | |
1775 * mchDeleteLines() Lock()s the window by itself. | |
1776 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1777 void |
19526 | 1778 VimTextAreaView::mchDeleteLines(int row, int num_lines) |
1779 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1780 BRect source, dest; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1781 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
|
1782 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
|
1783 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
|
1784 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
|
1785 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1786 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
|
1787 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
|
1788 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
|
1789 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
|
1790 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1791 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1792 // 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
|
1793 CopyBits(source, dest); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1794 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
|
1795 gui.scroll_region_left, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1796 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
|
1797 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1798 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1799 gui.vimWindow->Unlock(); |
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 * 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
|
1802 * 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
|
1803 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1804 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1805 // 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
|
1806 // } |
19526 | 1807 } |
1808 | |
1809 /* | |
1810 * mchInsertLines() Lock()s the window by itself. | |
1811 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1812 void |
19526 | 1813 VimTextAreaView::mchInsertLines(int row, int num_lines) |
1814 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1815 BRect source, dest; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1816 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1817 // 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
|
1818 gui.vimWindow->UpdateIfNeeded(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1819 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
|
1820 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
|
1821 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
|
1822 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
|
1823 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1824 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
|
1825 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
|
1826 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
|
1827 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
|
1828 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1829 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1830 // 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
|
1831 CopyBits(source, dest); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1832 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
|
1833 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
|
1834 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1835 gui.vimWindow->Unlock(); |
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 * 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
|
1838 * 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
|
1839 * 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
|
1840 * 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
|
1841 * 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
|
1842 * 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
|
1843 * 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
|
1844 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1845 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1846 // 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
|
1847 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1848 } |
19526 | 1849 } |
1850 | |
1851 #ifdef FEAT_MBYTE_IME | |
1852 /* | |
1853 * DrawIMString draws string with IMData.message. | |
1854 */ | |
1855 void VimTextAreaView::DrawIMString(void) | |
1856 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1857 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
|
1858 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
|
1859 BString str; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1860 const char* s; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1861 int len; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1862 BMessage* msg = IMData.message; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1863 if (!msg) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1864 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1865 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
|
1866 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
|
1867 bool confirmed = false; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1868 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
|
1869 if (confirmed) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1870 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1871 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
|
1872 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
|
1873 s = str.String(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1874 len = str.Length(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1875 SetHighColor(0, 0, 0); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1876 IMData.row = gui.row; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1877 IMData.col = gui.col; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1878 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
|
1879 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
|
1880 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
|
1881 int clen, cn; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1882 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
|
1883 BRect r; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1884 BPoint where; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1885 IMData.location = ConvertToScreen( |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1886 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
|
1887 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
|
1888 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1889 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
|
1890 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
|
1891 if (pos.x + cn > W_WIDTH(curwin)) |
19526 | 1892 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1893 pos.y++; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1894 pos.x = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1895 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1896 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
|
1897 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1898 SetLowColor(r_highlight); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1899 IMData.location = ConvertToScreen( |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1900 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
|
1901 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1902 else |
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 SetLowColor(b_highlight); |
19526 | 1905 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1906 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
|
1907 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
|
1908 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
|
1909 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
|
1910 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
|
1911 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
|
1912 pos.x += cn; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1913 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1914 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
|
1915 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1916 SetHighColor(hcolor); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1917 SetLowColor(lcolor); |
19526 | 1918 } |
1919 #endif | |
1920 // ---------------- VimScrollBar ---------------- | |
1921 | |
1922 /* | |
1923 * BUG: XXX | |
1924 * It seems that BScrollBar determine their direction not from | |
1925 * "posture" but from if they are "tall" or "wide" in shape... | |
1926 * | |
1927 * Also, place them out of sight, because Vim enables them before | |
1928 * they are positioned. | |
1929 */ | |
1930 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
|
1931 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
|
1932 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
|
1933 "vim scrollbar", (BView *)NULL, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1934 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
|
1935 ignoreValue(-1), |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1936 scrollEventCount(0) |
19526 | 1937 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1938 gsb = g; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1939 SetResizingMode(B_FOLLOW_NONE); |
19526 | 1940 } |
1941 | |
1942 VimScrollBar::~VimScrollBar() | |
1943 { | |
1944 } | |
1945 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1946 void |
19526 | 1947 VimScrollBar::ValueChanged(float newValue) |
1948 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1949 if (ignoreValue >= 0.0 && newValue == ignoreValue) { |
19526 | 1950 ignoreValue = -1; |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1951 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1952 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1953 ignoreValue = -1; |
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 * 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
|
1956 * 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
|
1957 * 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
|
1958 * 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
|
1959 * 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
|
1960 * 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
|
1961 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1962 atomic_add(&scrollEventCount, 1); |
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 struct VimScrollBarMsg sm; |
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 sm.sb = this; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1967 sm.value = (long) newValue; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1968 sm.stillDragging = TRUE; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1969 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1970 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
|
1971 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1972 // calls gui_drag_scrollbar(sb, newValue, TRUE); |
19526 | 1973 } |
1974 | |
1975 /* | |
1976 * When the mouse goes up, report that scrolling has stopped. | |
1977 * MouseUp() is NOT called when the mouse-up occurs outside | |
1978 * the window, even though the thumb does move while the mouse | |
1979 * is outside... This has some funny effects... XXX | |
1980 * So we do special processing when the window de/activates. | |
1981 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1982 void |
19526 | 1983 VimScrollBar::MouseUp(BPoint where) |
1984 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1985 // BMessage *m = Window()->CurrentMessage(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1986 // m->PrintToStream(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1987 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1988 atomic_add(&scrollEventCount, 1); |
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 struct VimScrollBarMsg sm; |
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 sm.sb = this; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1993 sm.value = (long) Value(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1994 sm.stillDragging = FALSE; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1995 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1996 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
|
1997 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
1998 // 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
|
1999 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2000 Inherited::MouseUp(where); |
19526 | 2001 } |
2002 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2003 void |
19526 | 2004 VimScrollBar::SetValue(float newValue) |
2005 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2006 if (newValue == Value()) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2007 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2008 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2009 ignoreValue = newValue; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2010 Inherited::SetValue(newValue); |
19526 | 2011 } |
2012 | |
2013 // ---------------- VimFont ---------------- | |
2014 | |
2015 VimFont::VimFont(): BFont() | |
2016 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2017 init(); |
19526 | 2018 } |
2019 | |
2020 VimFont::VimFont(const VimFont *rhs): BFont(rhs) | |
2021 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2022 init(); |
19526 | 2023 } |
2024 | |
2025 VimFont::VimFont(const BFont *rhs): BFont(rhs) | |
2026 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2027 init(); |
19526 | 2028 } |
2029 | |
2030 VimFont::VimFont(const VimFont &rhs): BFont(rhs) | |
2031 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2032 init(); |
19526 | 2033 } |
2034 | |
2035 VimFont::~VimFont() | |
2036 { | |
2037 } | |
2038 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2039 void |
19526 | 2040 VimFont::init() |
2041 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2042 next = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2043 refcount = 1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2044 name = NULL; |
19526 | 2045 } |
2046 | |
2047 // ---------------- VimDialog ---------------- | |
2048 | |
2049 #if defined(FEAT_GUI_DIALOG) | |
2050 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2051 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
|
2052 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
|
2053 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
|
2054 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
|
2055 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
|
2056 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
|
2057 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
|
2058 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
|
2059 const BRect kDefaultRect = |
19526 | 2060 BRect(0, 0, kVimDialogMinimalWidth, kVimDialogMinimalHeight); |
2061 | |
2062 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
|
2063 const char *buttons, int dfltbutton, const char *textfield, int ex_cmd) |
19526 | 2064 : 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
|
2065 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
|
2066 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
|
2067 , fDialogSem(-1) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2068 , fDialogValue(dfltbutton) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2069 , fMessageView(NULL) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2070 , fInputControl(NULL) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2071 , fInputValue(textfield) |
19526 | 2072 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2073 // master view |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2074 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
|
2075 if (view == NULL) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2076 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2077 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2078 if (title == NULL) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2079 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
|
2080 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2081 AddChild(view); |
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 // icon |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2084 view->InitIcon(type); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2085 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2086 // buttons |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2087 int32 which = 1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2088 float maxButtonWidth = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2089 float maxButtonHeight = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2090 float buttonsWidth = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2091 float buttonsHeight = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2092 BString strButtons(buttons); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2093 strButtons.RemoveAll("&"); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2094 do { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2095 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
|
2096 if (end != B_ERROR) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2097 strButtons.SetByteAt(end, '\0'); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2098 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2099 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
|
2100 view->AddChild(button); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2101 fButtonsList.AddItem(button); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2102 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2103 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
|
2104 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
|
2105 buttonsWidth += button->Bounds().Width(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2106 buttonsHeight += button->Bounds().Height(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2107 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2108 if (end == B_ERROR) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2109 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2110 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2111 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
|
2112 } while (true); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2113 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2114 int32 buttonsCount = fButtonsList.CountItems(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2115 buttonsWidth += kVimDialogButtonsSpacingX * (buttonsCount - 1); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2116 buttonsHeight += kVimDialogButtonsSpacingY * (buttonsCount - 1); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2117 float dialogWidth = buttonsWidth + kVimDialogIconStripeWidth + |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2118 kVimDialogSpacingX * 2; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2119 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
|
2120 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2121 // 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
|
2122 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
|
2123 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
|
2124 if (vertical) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2125 dialogWidth -= buttonsWidth; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2126 dialogWidth += maxButtonWidth; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2127 dialogHeight -= maxButtonHeight; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2128 dialogHeight += buttonsHeight; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2129 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2130 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2131 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
|
2132 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2133 // message view |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2134 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
|
2135 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
|
2136 rect.top += kVimDialogSpacingY; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2137 rect.right -= kVimDialogSpacingX; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2138 rect.bottom = rect.top; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2139 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
|
2140 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
|
2141 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2142 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
|
2143 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
|
2144 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
|
2145 fMessageView->SetText(message); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2146 fMessageView->MakeEditable(false); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2147 fMessageView->MakeSelectable(false); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2148 fMessageView->SetWordWrap(true); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2149 AddChild(fMessageView); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2150 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2151 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
|
2152 fMessageView->ResizeBy(0, messageHeight); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2153 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
|
2154 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2155 dialogHeight += 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 // input view |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2158 if (fInputValue != NULL) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2159 rect.top = |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2160 rect.bottom += messageHeight + kVimDialogSpacingY; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2161 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
|
2162 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
|
2163 fInputControl->TextView()->SetText(fInputValue); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2164 fInputControl->TextView()->SetWordWrap(false); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2165 AddChild(fInputControl); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2166 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2167 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
|
2168 fInputControl->GetPreferredSize(&width, &height); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2169 fInputControl->MakeFocus(true); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2170 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2171 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
|
2172 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2173 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2174 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
|
2175 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2176 ResizeTo(dialogWidth, dialogHeight); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2177 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
|
2178 (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
|
2179 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2180 // adjust layout of buttons |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2181 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
|
2182 BPoint origin(dialogWidth, dialogHeight); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2183 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
|
2184 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
|
2185 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2186 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
|
2187 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
|
2188 button->MoveTo(origin); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2189 if (vertical) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2190 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
|
2191 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
|
2192 } else |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2193 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
|
2194 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2195 if (dfltbutton == i + 1) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2196 button->MakeDefault(true); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2197 button->MakeFocus(fInputControl == NULL); |
19526 | 2198 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2199 } |
19526 | 2200 } |
2201 | |
2202 VimDialog::~VimDialog() | |
2203 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2204 if (fDialogSem > B_OK) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2205 delete_sem(fDialogSem); |
19526 | 2206 } |
2207 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2208 int |
19526 | 2209 VimDialog::Go() |
2210 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2211 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
|
2212 if (fDialogSem < B_OK) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2213 Quit(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2214 return fDialogValue; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2215 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2216 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2217 Show(); |
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 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
|
2220 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2221 int retValue = fDialogValue; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2222 if (fInputValue != NULL) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2223 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
|
2224 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2225 if (Lock()) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2226 Quit(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2227 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2228 return retValue; |
19526 | 2229 } |
2230 | |
2231 void VimDialog::MessageReceived(BMessage *msg) | |
2232 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2233 int32 which = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2234 if (msg->what != kVimDialogButtonMsg || |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2235 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
|
2236 return BWindow::MessageReceived(msg); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2237 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2238 fDialogValue = which; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2239 delete_sem(fDialogSem); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2240 fDialogSem = -1; |
19526 | 2241 } |
2242 | |
2243 BButton* VimDialog::_CreateButton(int32 which, const char* label) | |
2244 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2245 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
|
2246 message->AddInt32("which", which); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2247 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2248 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
|
2249 BString name; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2250 name << "_b" << which << "_"; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2251 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2252 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
|
2253 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
|
2254 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2255 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
|
2256 button->GetPreferredSize(&width, &height); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2257 button->ResizeTo(width, height); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2258 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2259 return button; |
19526 | 2260 } |
2261 | |
2262 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
|
2263 : 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
|
2264 fIconBitmap(NULL) |
19526 | 2265 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2266 SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); |
19526 | 2267 } |
2268 | |
2269 VimDialog::View::~View() | |
2270 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2271 delete fIconBitmap; |
19526 | 2272 } |
2273 | |
2274 void VimDialog::View::Draw(BRect updateRect) | |
2275 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2276 BRect stripeRect = Bounds(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2277 stripeRect.right = kVimDialogIconStripeWidth; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2278 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
|
2279 FillRect(stripeRect); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2280 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2281 if (fIconBitmap == NULL) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2282 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2283 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2284 SetDrawingMode(B_OP_ALPHA); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2285 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
|
2286 DrawBitmapAsync(fIconBitmap, BPoint(18, 6)); |
19526 | 2287 } |
2288 | |
2289 void VimDialog::View::InitIcon(int32 type) | |
2290 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2291 if (type == VIM_GENERIC) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2292 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2293 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2294 BPath path; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2295 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
|
2296 if (status != B_OK) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2297 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
|
2298 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2299 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2300 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2301 path.Append("app_server"); |
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 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
|
2304 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
|
2305 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
|
2306 strerror(file.InitCheck())); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2307 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2308 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2309 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2310 BResources resources(&file); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2311 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
|
2312 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
|
2313 strerror(resources.InitCheck())); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2314 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2315 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2316 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2317 const char *name = ""; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2318 switch(type) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2319 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
|
2320 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
|
2321 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
|
2322 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
|
2323 default: return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2324 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2325 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2326 int32 iconSize = 32; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2327 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
|
2328 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
|
2329 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
|
2330 (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
|
2331 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2332 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2333 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2334 size_t size = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2335 const uint8* iconData = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2336 // try vector icon first? |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2337 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
|
2338 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
|
2339 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2340 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2341 // try bitmap icon now |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2342 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
|
2343 if (iconData == NULL) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2344 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
|
2345 delete fIconBitmap; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2346 fIconBitmap = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2347 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2348 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2349 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2350 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
|
2351 BIconUtils::ConvertFromCMAP8(iconData, iconSize, iconSize, iconSize, fIconBitmap); |
19526 | 2352 } |
2353 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2354 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
|
2355 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
|
2356 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
|
2357 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
|
2358 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
|
2359 const unsigned int kVimDialogSizeSelectMsg = 'MSSZ'; |
19526 | 2360 |
2361 VimSelectFontDialog::VimSelectFontDialog(font_family* family, font_style* style, float* size) | |
2362 : 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
|
2363 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
|
2364 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
|
2365 , fStatus(B_NO_INIT) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2366 , fDialogSem(-1) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2367 , fDialogValue(false) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2368 , fFamily(family) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2369 , fStyle(style) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2370 , fSize(size) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2371 , fFontSize(*size) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2372 , fPreview(0) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2373 , fFamiliesList(0) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2374 , fStylesList(0) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2375 , fSizesList(0) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2376 , fSizesInput(0) |
19526 | 2377 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2378 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
|
2379 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
|
2380 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2381 // "client" area view |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2382 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
|
2383 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
|
2384 B_PLAIN_BORDER); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2385 AddChild(clientBox); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2386 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2387 // client view |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2388 BRect RC = clientBox->Bounds(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2389 RC.InsetBy(kVimDialogSpacingX, kVimDialogSpacingY); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2390 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
|
2391 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2392 // 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
|
2393 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
|
2394 clientBox->AddChild(fPreview); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2395 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2396 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
|
2397 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
|
2398 clientBox->AddChild(boxDivider); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2399 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2400 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
|
2401 clientBox->AddChild(labelFamily); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2402 labelFamily->ResizeToPreferred(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2403 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2404 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
|
2405 clientBox->AddChild(labelStyle); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2406 labelStyle->ResizeToPreferred(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2407 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2408 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
|
2409 clientBox->AddChild(labelSize); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2410 labelSize->ResizeToPreferred(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2411 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2412 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
|
2413 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
|
2414 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
|
2415 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
|
2416 clientBox->AddChild(scrollFamilies); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2417 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2418 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
|
2419 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
|
2420 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
|
2421 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
|
2422 clientBox->AddChild(scrollStyles); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2423 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2424 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
|
2425 new BMessage(kVimDialogSizeInputMsg)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2426 clientBox->AddChild(fSizesInput); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2427 fSizesInput->ResizeToPreferred(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2428 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2429 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
|
2430 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
|
2431 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
|
2432 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
|
2433 clientBox->AddChild(scrollSizes); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2434 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2435 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
|
2436 new BMessage(kVimDialogOKButtonMsg)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2437 clientBox->AddChild(buttonOK); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2438 buttonOK->ResizeToPreferred(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2439 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2440 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
|
2441 new BMessage(kVimDialogCancelButtonMsg)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2442 clientBox->AddChild(buttonCancel); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2443 buttonCancel->ResizeToPreferred(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2444 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2445 // layout controls |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2446 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
|
2447 float previewHeight = lineHeight * 3; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2448 float offsetYLabels = previewHeight + kVimDialogSpacingY; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2449 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
|
2450 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
|
2451 float listsHeight = lineHeight * 9; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2452 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
|
2453 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
|
2454 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
|
2455 float offsetXStyles = familiesWidth + kVimDialogSpacingX; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2456 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
|
2457 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
|
2458 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
|
2459 float maxControlsWidth = offsetXSizes + sizesWidth; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2460 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2461 ResizeTo(maxControlsWidth + kVimDialogSpacingX * 2, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2462 maxControlsHeight + kVimDialogSpacingY * 2); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2463 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2464 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
|
2465 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
|
2466 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
|
2467 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2468 fPreview->ResizeTo(maxControlsWidth, previewHeight); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2469 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
|
2470 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2471 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
|
2472 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
|
2473 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2474 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
|
2475 labelStyle->MoveBy(offsetXStyles, offsetYLabels); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2476 labelSize->MoveBy(offsetXSizes, offsetYLabels); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2477 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2478 // text control alignment issues |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2479 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
|
2480 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
|
2481 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2482 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
|
2483 scrollStyles->MoveBy(offsetXStyles, offsetYLists); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2484 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
|
2485 scrollSizes->MoveBy(offsetXSizes, offsetYSizes); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2486 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2487 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
|
2488 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2489 scrollFamilies->ResizeTo(familiesWidth, listsHeight); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2490 scrollStyles->ResizeTo(stylesWidth, listsHeight); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2491 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
|
2492 scrollSizes->ResizeTo(sizesWidth, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2493 listsHeight - (offsetYSizes - offsetYLists)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2494 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2495 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
|
2496 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
|
2497 - 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
|
2498 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2499 // fill lists |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2500 int selIndex = -1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2501 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
|
2502 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
|
2503 font_family family; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2504 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
|
2505 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
|
2506 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
|
2507 selIndex = i; |
19526 | 2508 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2509 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2510 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2511 if (selIndex >= 0) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2512 fFamiliesList->Select(selIndex); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2513 fFamiliesList->ScrollToSelection(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2514 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2515 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2516 _UpdateFontStyles(); |
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 selIndex = -1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2519 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
|
2520 BString str; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2521 str << size; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2522 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
|
2523 if (size == fFontSize) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2524 selIndex = index; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2525 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2526 } |
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 if (selIndex >= 0) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2529 fSizesList->Select(selIndex); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2530 fSizesList->ScrollToSelection(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2531 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2532 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2533 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
|
2534 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
|
2535 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
|
2536 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
|
2537 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2538 _UpdateSizeInputPreview(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2539 _UpdateFontPreview(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2540 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2541 fStatus = B_OK; |
19526 | 2542 } |
2543 | |
2544 VimSelectFontDialog::~VimSelectFontDialog() | |
2545 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2546 _CleanList(fFamiliesList); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2547 _CleanList(fStylesList); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2548 _CleanList(fSizesList); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2549 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2550 if (fDialogSem > B_OK) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2551 delete_sem(fDialogSem); |
19526 | 2552 } |
2553 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2554 void |
19526 | 2555 VimSelectFontDialog::_CleanList(BListView* list) |
2556 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2557 while (0 < list->CountItems()) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2558 delete (dynamic_cast<BStringItem*>(list->RemoveItem((int32)0))); |
19526 | 2559 } |
2560 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2561 bool |
19526 | 2562 VimSelectFontDialog::Go() |
2563 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2564 if (fStatus != B_OK) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2565 Quit(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2566 return NOFONT; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2567 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2568 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2569 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
|
2570 if (fDialogSem < B_OK) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2571 Quit(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2572 return fDialogValue; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2573 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2574 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2575 Show(); |
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 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
|
2578 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2579 bool retValue = fDialogValue; |
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 if (Lock()) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2582 Quit(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2583 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2584 return retValue; |
19526 | 2585 } |
2586 | |
2587 | |
2588 void VimSelectFontDialog::_UpdateFontStyles() | |
2589 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2590 _CleanList(fStylesList); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2591 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2592 int32 selIndex = -1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2593 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
|
2594 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
|
2595 font_style style; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2596 uint32 flags = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2597 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
|
2598 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
|
2599 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
|
2600 selIndex = i; |
19526 | 2601 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2602 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2603 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2604 if (selIndex >= 0) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2605 fStylesList->Select(selIndex); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2606 fStylesList->ScrollToSelection(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2607 } else |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2608 fStylesList->Select(0); |
19526 | 2609 } |
2610 | |
2611 | |
2612 void VimSelectFontDialog::_UpdateSizeInputPreview() | |
2613 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2614 char buf[10] = {0}; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2615 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
|
2616 fSizesInput->SetText(buf); |
19526 | 2617 } |
2618 | |
2619 | |
2620 void VimSelectFontDialog::_UpdateFontPreview() | |
2621 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2622 BFont font; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2623 fPreview->GetFont(&font); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2624 font.SetSize(fFontSize); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2625 font.SetFamilyAndStyle(fFontFamily, fFontStyle); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2626 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
|
2627 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2628 BString str; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2629 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
|
2630 fPreview->SetText(str); |
19526 | 2631 } |
2632 | |
2633 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2634 bool |
19526 | 2635 VimSelectFontDialog::_UpdateFromListItem(BListView* list, char* text, int textSize) |
2636 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2637 int32 index = list->CurrentSelection(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2638 if (index < 0) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2639 return false; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2640 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
|
2641 if (item == NULL) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2642 return false; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2643 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
|
2644 return true; |
19526 | 2645 } |
2646 | |
2647 | |
2648 void VimSelectFontDialog::MessageReceived(BMessage *msg) | |
2649 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2650 switch (msg->what) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2651 case kVimDialogOKButtonMsg: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2652 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
|
2653 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
|
2654 *fSize = fFontSize; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2655 fDialogValue = true; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2656 case kVimDialogCancelButtonMsg: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2657 delete_sem(fDialogSem); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2658 fDialogSem = -1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2659 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2660 case B_KEY_UP: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2661 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2662 int32 key = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2663 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
|
2664 && key == B_ESCAPE) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2665 delete_sem(fDialogSem); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2666 fDialogSem = -1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2667 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2668 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2669 break; |
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 case kVimDialogFamilySelectMsg: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2672 if (_UpdateFromListItem(fFamiliesList, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2673 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
|
2674 _UpdateFontStyles(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2675 _UpdateFontPreview(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2676 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2677 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2678 case kVimDialogStyleSelectMsg: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2679 if (_UpdateFromListItem(fStylesList, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2680 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
|
2681 _UpdateFontPreview(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2682 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2683 case kVimDialogSizeSelectMsg: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2684 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2685 char buf[10] = {0}; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2686 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
|
2687 float size = atof(buf); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2688 if (size > 0.f) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2689 fFontSize = size; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2690 _UpdateSizeInputPreview(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2691 _UpdateFontPreview(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2692 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2693 } |
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 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2696 case kVimDialogSizeInputMsg: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2697 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2698 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
|
2699 if (size > 0.f) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2700 fFontSize = size; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2701 _UpdateFontPreview(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2702 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2703 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2704 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2705 default: |
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 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2708 return BWindow::MessageReceived(msg); |
19526 | 2709 } |
2710 | |
2711 #endif // FEAT_GUI_DIALOG | |
2712 | |
2713 #ifdef FEAT_TOOLBAR | |
2714 | |
2715 // some forward declaration required by toolbar functions... | |
2716 static BMessage * MenuMessage(vimmenu_T *menu); | |
2717 | |
2718 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
|
2719 BBox(frame, name, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_FRAME_EVENTS, B_PLAIN_BORDER) |
19526 | 2720 { |
2721 } | |
2722 | |
2723 VimToolbar::~VimToolbar() | |
2724 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2725 int32 count = fButtonsList.CountItems(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2726 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
|
2727 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
|
2728 fButtonsList.MakeEmpty(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2729 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2730 delete normalButtonsBitmap; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2731 delete grayedButtonsBitmap; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2732 normalButtonsBitmap = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2733 grayedButtonsBitmap = NULL; |
19526 | 2734 } |
2735 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2736 void |
19526 | 2737 VimToolbar::AttachedToWindow() |
2738 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2739 BBox::AttachedToWindow(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2740 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2741 SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); |
19526 | 2742 } |
2743 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2744 float |
19526 | 2745 VimToolbar::ToolbarHeight() const |
2746 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2747 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
|
2748 return size + ToolbarMargin * 2 + ButtonMargin * 2 + 1; |
19526 | 2749 } |
2750 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2751 bool |
19526 | 2752 VimToolbar::ModifyBitmapToGrayed(BBitmap *bitmap) |
2753 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2754 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
|
2755 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
|
2756 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2757 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
|
2758 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
|
2759 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
|
2760 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
|
2761 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
|
2762 bits[i].alpha /= 4; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2763 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2764 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2765 return true; |
19526 | 2766 } |
2767 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2768 bool |
19526 | 2769 VimToolbar::PrepareButtonBitmaps() |
2770 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2771 // 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
|
2772 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
|
2773 if (normalButtonsBitmap == NULL) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2774 // 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
|
2775 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
|
2776 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2777 if (normalButtonsBitmap == NULL) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2778 return false; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2779 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2780 BMessage archive; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2781 normalButtonsBitmap->Archive(&archive); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2782 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2783 grayedButtonsBitmap = new BBitmap(&archive); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2784 if (grayedButtonsBitmap == NULL) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2785 return false; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2786 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2787 // modify grayed bitmap |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2788 ModifyBitmapToGrayed(grayedButtonsBitmap); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2789 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2790 return true; |
19526 | 2791 } |
2792 | |
2793 BBitmap *VimToolbar::LoadVimBitmap(const char* fileName) | |
2794 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2795 BBitmap *bitmap = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2796 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2797 int mustfree = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2798 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
|
2799 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
|
2800 BString strPath((char*)runtimePath); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2801 strPath << "/bitmaps/" << fileName; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2802 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
|
2803 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2804 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2805 if (mustfree) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2806 vim_free(runtimePath); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2807 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2808 return bitmap; |
19526 | 2809 } |
2810 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2811 bool |
19526 | 2812 VimToolbar::GetPictureFromBitmap(BPicture *pictureTo, int32 index, BBitmap *bitmapFrom, bool pressed) |
2813 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2814 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
|
2815 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2816 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
|
2817 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2818 AddChild(&view); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2819 view.BeginPicture(pictureTo); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2820 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2821 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
|
2822 view.FillRect(view.Bounds()); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2823 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
|
2824 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2825 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
|
2826 BRect destination(source); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2827 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2828 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
|
2829 destination.OffsetBy(ButtonMargin, ButtonMargin); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2830 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2831 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
|
2832 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2833 if (pressed) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2834 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
|
2835 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
|
2836 size += ButtonMargin * 2 - 1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2837 view.BeginLineArray(4); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2838 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
|
2839 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
|
2840 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
|
2841 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
|
2842 view.EndLineArray(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2843 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2844 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2845 view.EndPicture(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2846 RemoveChild(&view); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2847 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2848 return true; |
19526 | 2849 } |
2850 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2851 bool |
19526 | 2852 VimToolbar::AddButton(int32 index, vimmenu_T *menu) |
2853 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2854 BPictureButton *button = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2855 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
|
2856 float size = normalButtonsBitmap ? |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2857 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
|
2858 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
|
2859 BPicture pictureOn; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2860 BPicture pictureOff; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2861 BPicture pictureGray; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2862 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2863 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
|
2864 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
|
2865 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
|
2866 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
|
2867 } else { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2868 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2869 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
|
2870 BBitmap *bitmap = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2871 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2872 if (menu->iconfile) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2873 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
|
2874 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
|
2875 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2876 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2877 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
|
2878 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
|
2879 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2880 if (bitmap == NULL) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2881 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
|
2882 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2883 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
|
2884 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
|
2885 ModifyBitmapToGrayed(bitmap); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2886 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
|
2887 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2888 delete bitmap; |
19526 | 2889 } |
2890 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2891 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
|
2892 &pictureOff, &pictureOn, MenuMessage(menu)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2893 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2894 button->SetDisabledOn(&pictureGray); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2895 button->SetDisabledOff(&pictureGray); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2896 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2897 button->SetTarget(gui.vimTextArea); |
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 AddChild(button); |
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 menu->button = 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 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2904 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
|
2905 InvalidateLayout(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2906 return result; |
19526 | 2907 } |
2908 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2909 bool |
19526 | 2910 VimToolbar::RemoveButton(vimmenu_T *menu) |
2911 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2912 if (menu->button) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2913 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
|
2914 delete menu->button; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2915 menu->button = NULL; |
19526 | 2916 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2917 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2918 return true; |
19526 | 2919 } |
2920 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2921 bool |
19526 | 2922 VimToolbar::GrayButton(vimmenu_T *menu, int grey) |
2923 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2924 if (menu->button) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2925 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
|
2926 if (index >= 0) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2927 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
|
2928 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2929 return true; |
19526 | 2930 } |
2931 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2932 void |
19526 | 2933 VimToolbar::InvalidateLayout() |
2934 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2935 int32 offset = ToolbarMargin; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2936 int32 count = fButtonsList.CountItems(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2937 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
|
2938 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
|
2939 if (button) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2940 button->MoveTo(offset, ToolbarMargin); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2941 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
|
2942 } else |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2943 offset += ToolbarMargin * 3; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2944 } |
19526 | 2945 } |
2946 | |
2947 #endif /*FEAT_TOOLBAR*/ | |
2948 | |
2949 #if defined(FEAT_GUI_TABLINE) | |
2950 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2951 float |
19526 | 2952 VimTabLine::TablineHeight() const |
2953 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2954 // 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
|
2955 // 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
|
2956 return TabHeight(); // + ToolbarMargin; |
19526 | 2957 } |
2958 | |
2959 void | |
2960 VimTabLine::MouseDown(BPoint point) | |
2961 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2962 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
|
2963 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2964 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2965 BMessage *m = Window()->CurrentMessage(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2966 assert(m); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2967 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2968 int32 buttons = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2969 m->FindInt32("buttons", &buttons); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2970 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2971 int32 clicks = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2972 m->FindInt32("clicks", &clicks); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2973 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2974 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
|
2975 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
|
2976 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
|
2977 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
|
2978 break; |
19526 | 2979 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2980 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2981 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2982 int event = -1; |
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 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
|
2985 // 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
|
2986 event = TABLINE_MENU_NEW; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2987 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2988 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
|
2989 // 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
|
2990 // 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
|
2991 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
|
2992 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
2993 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
|
2994 // 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
|
2995 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
|
2996 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
|
2997 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
|
2998 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
|
2999 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3000 ConvertToScreen(&point); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3001 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
|
3002 if (item != NULL) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3003 event = item->Command(); |
19526 | 3004 } |
3005 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3006 delete popUpMenu; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3007 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3008 } else { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3009 // default processing |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3010 BTabView::MouseDown(point); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3011 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3012 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3013 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3014 if (event < 0) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3015 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3016 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3017 VimTablineMenuMsg tmm; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3018 tmm.index = index; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3019 tmm.event = event; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3020 write_port(gui.vdcmp, VimMsg::TablineMenu, &tmm, sizeof(tmm)); |
19526 | 3021 } |
3022 | |
3023 void | |
3024 VimTabLine::VimTab::Select(BView* owner) | |
3025 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3026 BTab::Select(owner); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3027 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3028 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
|
3029 if (tabLine != NULL) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3030 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3031 int32 i = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3032 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
|
3033 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
|
3034 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3035 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3036 // 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
|
3037 if (i < tabLine->CountTabs()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3038 VimTablineMsg tm; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3039 tm.index = i + 1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3040 write_port(gui.vdcmp, VimMsg::Tabline, &tm, sizeof(tm)); |
19526 | 3041 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3042 } |
19526 | 3043 } |
3044 | |
3045 #endif // defined(FEAT_GUI_TABLINE) | |
3046 | |
3047 // ---------------- ---------------- | |
3048 | |
3049 // some global variables | |
3050 static char appsig[] = "application/x-vnd.Haiku-Vim-8"; | |
3051 key_map *keyMap; | |
3052 char *keyMapChars; | |
3053 int main_exitcode = 127; | |
3054 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3055 status_t |
19526 | 3056 gui_haiku_process_event(bigtime_t timeout) |
3057 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3058 struct VimMsg vm; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3059 int32 what; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3060 ssize_t size; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3061 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3062 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
|
3063 B_TIMEOUT, timeout); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3064 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3065 if (size >= 0) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3066 switch (what) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3067 case VimMsg::Key: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3068 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3069 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
|
3070 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
|
3071 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
|
3072 trash_input_buf(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3073 got_int = TRUE; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3074 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3075 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3076 if (vm.u.Key.csi_escape) |
19526 | 3077 #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
|
3078 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3079 int i; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3080 char_u buf[2]; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3081 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3082 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
|
3083 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3084 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
|
3085 if (string[i] == CSI) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3086 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3087 // 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
|
3088 buf[0] = KS_EXTRA; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3089 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
|
3090 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
|
3091 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3092 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3093 } |
19526 | 3094 #else |
20277
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
3095 add_to_input_buf_csi(string, len); |
19526 | 3096 #endif |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3097 else |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3098 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
|
3099 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3100 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3101 case VimMsg::Resize: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3102 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
|
3103 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3104 case VimMsg::ScrollBar: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3105 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3106 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3107 * 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
|
3108 * 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
|
3109 * 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
|
3110 * 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
|
3111 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3112 int32 oldCount = |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3113 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
|
3114 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
|
3115 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
|
3116 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
|
3117 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3118 break; |
19526 | 3119 #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
|
3120 case VimMsg::Menu: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3121 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
|
3122 break; |
19526 | 3123 #endif |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3124 case VimMsg::Mouse: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3125 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3126 int32 oldCount; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3127 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
|
3128 oldCount = |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3129 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
|
3130 else |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3131 oldCount = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3132 if (oldCount <= 1) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3133 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
|
3134 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
|
3135 vm.u.Mouse.modifiers); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3136 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3137 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3138 case VimMsg::MouseMoved: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3139 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3140 gui_mouse_moved(vm.u.MouseMoved.x, vm.u.MouseMoved.y); |
19526 | 3141 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3142 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3143 case VimMsg::Focus: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3144 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
|
3145 // 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
|
3146 // 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
|
3147 // 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
|
3148 if (gui.dragged_sb) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3149 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
|
3150 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3151 // 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
|
3152 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3153 case VimMsg::Refs: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3154 ::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
|
3155 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3156 case VimMsg::Tabline: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3157 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
|
3158 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3159 case VimMsg::TablineMenu: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3160 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
|
3161 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3162 default: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3163 // unrecognised message, ignore it |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3164 break; |
19526 | 3165 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3166 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3167 |
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 * 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
|
3170 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3171 return size; |
19526 | 3172 } |
3173 | |
3174 /* | |
3175 * Here are some functions to protect access to ScreenLines[] and | |
3176 * LineOffset[]. These are used from the window thread to respond | |
3177 * to a Draw() callback. When that occurs, the window is already | |
3178 * locked by the system. | |
3179 * | |
3180 * Other code that needs to lock is any code that changes these | |
3181 * variables. Other read-only access, or access merely to the | |
3182 * contents of the screen buffer, need not be locked. | |
3183 * | |
3184 * If there is no window, don't call Lock() but do succeed. | |
3185 */ | |
3186 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3187 int |
19526 | 3188 vim_lock_screen() |
3189 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3190 return !gui.vimWindow || gui.vimWindow->Lock(); |
19526 | 3191 } |
3192 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3193 void |
19526 | 3194 vim_unlock_screen() |
3195 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3196 if (gui.vimWindow) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3197 gui.vimWindow->Unlock(); |
19526 | 3198 } |
3199 | |
3200 #define RUN_BAPPLICATION_IN_NEW_THREAD 0 | |
3201 | |
3202 #if RUN_BAPPLICATION_IN_NEW_THREAD | |
3203 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3204 int32 |
19526 | 3205 run_vimapp(void *args) |
3206 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3207 VimApp app(appsig); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3208 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3209 gui.vimApp = &app; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3210 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
|
3211 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3212 return 0; |
19526 | 3213 } |
3214 | |
3215 #else | |
3216 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3217 int32 |
19526 | 3218 call_main(void *args) |
3219 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3220 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
|
3221 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3222 return main(ma->argc, ma->argv); |
19526 | 3223 } |
3224 #endif | |
3225 | |
3226 /* | |
3227 * Parse the GUI related command-line arguments. Any arguments used are | |
3228 * deleted from argv, and *argc is decremented accordingly. This is called | |
3229 * when vim is started, whether or not the GUI has been started. | |
3230 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3231 void |
19526 | 3232 gui_mch_prepare( |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3233 int *argc, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3234 char **argv) |
19526 | 3235 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3236 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3237 * 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
|
3238 * 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
|
3239 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3240 if (!gui.vimApp) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3241 thread_info tinfo; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3242 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
|
3243 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3244 // 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
|
3245 gui.vdcmp = create_port(B_MAX_PORT_COUNT, "vim VDCMP"); |
19526 | 3246 |
3247 #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
|
3248 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
|
3249 tinfo.priority, NULL); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3250 if (tid >= B_OK) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3251 resume_thread(tid); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3252 } else { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3253 getout(1); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3254 } |
19526 | 3255 #else |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3256 MainArgs ma = { *argc, argv }; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3257 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
|
3258 tinfo.priority, &ma); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3259 if (tid >= B_OK) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3260 VimApp app(appsig); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3261 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3262 gui.vimApp = &app; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3263 resume_thread(tid); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3264 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3265 * This is rather horrible. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3266 * 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
|
3267 * 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
|
3268 * 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
|
3269 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3270 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
|
3271 // 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
|
3272 status_t dummy_exitcode; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3273 (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
|
3274 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3275 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3276 * 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
|
3277 * 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
|
3278 * 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
|
3279 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3280 exit(main_exitcode); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3281 } |
19526 | 3282 #endif |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3283 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3284 // 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
|
3285 // 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
|
3286 gui.dofork = FALSE; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3287 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3288 * 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
|
3289 * 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
|
3290 * 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
|
3291 * 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
|
3292 * 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
|
3293 * of vim... |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3294 * 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
|
3295 * (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
|
3296 * 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
|
3297 * 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
|
3298 * 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
|
3299 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3300 if (!isatty(0)) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3301 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
|
3302 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3303 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
|
3304 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
|
3305 (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
|
3306 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
|
3307 gui.starting = TRUE; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3308 } |
19526 | 3309 } |
3310 | |
3311 /* | |
3312 * Check if the GUI can be started. Called before gvimrc is sourced. | |
3313 * Return OK or FAIL. | |
3314 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3315 int |
19526 | 3316 gui_mch_init_check(void) |
3317 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3318 return OK; // TODO: GUI can always be started? |
19526 | 3319 } |
3320 | |
3321 /* | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3322 * Initialise the GUI. Create all the windows, set up all the call-backs |
19526 | 3323 * etc. |
3324 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3325 int |
19526 | 3326 gui_mch_init() |
3327 { | |
3328 display_errors(); | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3329 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
|
3330 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
|
3331 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
|
3332 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
|
3333 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3334 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
|
3335 gui.scrollbar_height = (int) B_H_SCROLL_BAR_HEIGHT; |
19526 | 3336 #ifdef FEAT_MENU |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3337 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
|
3338 // correct for my default settings |
19526 | 3339 #endif |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3340 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
|
3341 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3342 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
|
3343 return FAIL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3344 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
|
3345 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3346 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
|
3347 if (!gui.vimWindow) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3348 return FAIL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3349 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3350 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
|
3351 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3352 // 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
|
3353 // file) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3354 set_normal_colors(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3355 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3356 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3357 * 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
|
3358 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3359 gui_check_colors(); |
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 // 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
|
3362 // changed them) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3363 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
|
3364 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3365 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
|
3366 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3367 return OK; |
19526 | 3368 } |
3369 | |
3370 /* | |
3371 * Called when the foreground or background color has been changed. | |
3372 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3373 void |
19526 | 3374 gui_mch_new_colors() |
3375 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3376 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
|
3377 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3378 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3379 gui.vimForm->SetViewColor(rgb); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3380 // 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
|
3381 gui.vimForm->Invalidate(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3382 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3383 } |
19526 | 3384 } |
3385 | |
3386 /* | |
3387 * Open the GUI window which was created by a call to gui_mch_init(). | |
3388 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3389 int |
19526 | 3390 gui_mch_open() |
3391 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3392 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
|
3393 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
|
3394 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3395 // Actually open the window |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3396 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3397 gui.vimWindow->Show(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3398 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3399 return OK; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3400 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3401 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3402 return FAIL; |
19526 | 3403 } |
3404 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3405 void |
19526 | 3406 gui_mch_exit(int vim_exitcode) |
3407 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3408 if (gui.vimWindow) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3409 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
|
3410 gui.vimWindow->Lock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3411 gui.vimWindow->Quit(); |
23229
b545334ae654
patch 8.2.2160: various typos
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
3412 // 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
|
3413 int32 exitcode; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3414 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
|
3415 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3416 delete_port(gui.vdcmp); |
19526 | 3417 #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
|
3418 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3419 * 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
|
3420 * 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
|
3421 * 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
|
3422 * 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
|
3423 */ |
19526 | 3424 #endif |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3425 if (gui.vimApp) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3426 VimTextAreaView::guiBlankMouse(false); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3427 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3428 main_exitcode = vim_exitcode; |
19526 | 3429 #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
|
3430 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
|
3431 int32 exitcode; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3432 gui.vimApp->Lock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3433 gui.vimApp->Quit(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3434 gui.vimApp->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3435 wait_for_thread(tid, &exitcode); |
19526 | 3436 #else |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3437 gui.vimApp->Lock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3438 gui.vimApp->Quit(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3439 gui.vimApp->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3440 // suicide |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3441 exit_thread(vim_exitcode); |
19526 | 3442 #endif |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3443 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3444 // If we are somehow still here, let mch_exit() handle things. |
19526 | 3445 } |
3446 | |
3447 /* | |
3448 * Get the position of the top left corner of the window. | |
3449 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3450 int |
19526 | 3451 gui_mch_get_winpos(int *x, int *y) |
3452 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3453 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3454 BRect r; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3455 r = gui.vimWindow->Frame(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3456 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3457 *x = (int)r.left; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3458 *y = (int)r.top; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3459 return OK; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3460 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3461 else |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3462 return FAIL; |
19526 | 3463 } |
3464 | |
3465 /* | |
3466 * Set the position of the top left corner of the window to the given | |
3467 * coordinates. | |
3468 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3469 void |
19526 | 3470 gui_mch_set_winpos(int x, int y) |
3471 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3472 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3473 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
|
3474 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3475 } |
19526 | 3476 } |
3477 | |
3478 /* | |
3479 * Set the size of the window to the given width and height in pixels. | |
3480 */ | |
3481 void | |
3482 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
|
3483 int width, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3484 int height, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3485 int min_width, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3486 int min_height, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3487 int base_width, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3488 int base_height, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3489 int direction) // TODO: utilize? |
19526 | 3490 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3491 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3492 * 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
|
3493 * 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
|
3494 * 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
|
3495 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3496 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3497 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
|
3498 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3499 // set size limits |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3500 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
|
3501 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3502 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
|
3503 &minHeight, &maxHeight); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3504 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
|
3505 min_height, maxHeight); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3506 |
19526 | 3507 /* |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3508 * Set the resizing alignment depending on font size. |
19526 | 3509 */ |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3510 gui.vimWindow->SetWindowAlignment( |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3511 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
|
3512 1, // int32 h, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3513 0, // int32 hOffset = 0, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3514 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
|
3515 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
|
3516 1, // int32 v = 0, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3517 0, // int32 vOffset = 0, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3518 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
|
3519 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
|
3520 ); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3521 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3522 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3523 } |
19526 | 3524 } |
3525 | |
3526 void | |
3527 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
|
3528 int *screen_w, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3529 int *screen_h) |
19526 | 3530 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3531 BRect frame; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3532 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3533 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3534 BScreen screen(gui.vimWindow); |
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 if (screen.IsValid()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3537 frame = screen.Frame(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3538 } else { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3539 frame.right = 640; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3540 frame.bottom = 480; |
19526 | 3541 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3542 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3543 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3544 // XXX approximations... |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3545 *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
|
3546 *screen_h = (int) frame.bottom - gui.scrollbar_height |
19526 | 3547 #ifdef FEAT_MENU |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3548 - gui.menu_height |
19526 | 3549 #endif |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3550 - 30; |
19526 | 3551 } |
3552 | |
3553 void | |
3554 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
|
3555 int x, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3556 int y, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3557 int w, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3558 int h) |
19526 | 3559 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3560 if (!gui.vimTextArea) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3561 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3562 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3563 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3564 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
|
3565 gui.vimTextArea->ResizeTo(w - PEN_WIDTH, h - PEN_WIDTH); |
19526 | 3566 |
20134
352701a626ed
patch 8.2.0622: Haiku: GUI does not compile
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
3567 #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
|
3568 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
|
3569 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
|
3570 } |
19526 | 3571 #endif // FEAT_GUI_TABLINE |
3572 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3573 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3574 } |
19526 | 3575 } |
3576 | |
3577 | |
3578 /* | |
3579 * Scrollbar stuff: | |
3580 */ | |
3581 | |
3582 void | |
3583 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
|
3584 scrollbar_T *sb, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3585 int flag) |
19526 | 3586 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3587 VimScrollBar *vsb = sb->id; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3588 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3589 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3590 * 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
|
3591 * 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
|
3592 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3593 if (flag) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3594 if (vsb->IsHidden()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3595 vsb->Show(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3596 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3597 } else { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3598 if (!vsb->IsHidden()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3599 vsb->Hide(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3600 } |
19526 | 3601 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3602 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3603 } |
19526 | 3604 } |
3605 | |
3606 void | |
3607 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
|
3608 scrollbar_T *sb, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3609 int val, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3610 int size, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3611 int max) |
19526 | 3612 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3613 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3614 VimScrollBar *s = sb->id; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3615 if (max == 0) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3616 s->SetValue(0); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3617 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
|
3618 } else { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3619 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
|
3620 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
|
3621 #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
|
3622 max = max + 1 - size; |
19526 | 3623 #endif |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3624 if (max < s->Value()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3625 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3626 * 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
|
3627 * 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
|
3628 * therefore a ValueChanged() call. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3629 * 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
|
3630 * it presumably is <= max. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3631 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3632 s->SetValue(val); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3633 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
|
3634 } else { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3635 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3636 * 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
|
3637 * 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
|
3638 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3639 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
|
3640 s->SetValue(val); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3641 } |
19526 | 3642 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3643 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3644 } |
19526 | 3645 } |
3646 | |
3647 void | |
3648 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
|
3649 scrollbar_T *sb, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3650 int x, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3651 int y, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3652 int w, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3653 int h) |
19526 | 3654 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3655 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3656 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
|
3657 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
|
3658 VimScrollBar *vsb = sb->id; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3659 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
|
3660 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
|
3661 vsb->MoveTo(vsbx, vsby); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3662 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3663 } |
19526 | 3664 } |
3665 | |
21355
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
20277
diff
changeset
|
3666 int |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
20277
diff
changeset
|
3667 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
|
3668 { |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
20277
diff
changeset
|
3669 // 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
|
3670 // 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
|
3671 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
|
3672 } |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
20277
diff
changeset
|
3673 |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
20277
diff
changeset
|
3674 int |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
20277
diff
changeset
|
3675 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
|
3676 { |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
20277
diff
changeset
|
3677 // 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
|
3678 // 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
|
3679 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
|
3680 } |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
20277
diff
changeset
|
3681 |
19526 | 3682 void |
3683 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
|
3684 scrollbar_T *sb, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3685 int orient) // SBAR_VERT or SBAR_HORIZ |
19526 | 3686 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3687 orientation posture = |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3688 (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
|
3689 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3690 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
|
3691 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3692 vsb->SetTarget(gui.vimTextArea); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3693 vsb->Hide(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3694 gui.vimForm->AddChild(vsb); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3695 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3696 } |
19526 | 3697 } |
3698 | |
20134
352701a626ed
patch 8.2.0622: Haiku: GUI does not compile
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
3699 #if defined(FEAT_WINDOWS) || defined(FEAT_GUI_HAIKU) || defined(PROTO) |
19526 | 3700 void |
3701 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
|
3702 scrollbar_T *sb) |
19526 | 3703 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3704 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3705 sb->id->RemoveSelf(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3706 delete sb->id; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3707 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3708 } |
19526 | 3709 } |
3710 #endif | |
3711 | |
3712 /* | |
3713 * Cursor does not flash | |
3714 */ | |
3715 int | |
3716 gui_mch_is_blink_off(void) | |
3717 { | |
3718 return FALSE; | |
3719 } | |
3720 | |
3721 /* | |
3722 * Cursor blink functions. | |
3723 * | |
3724 * This is a simple state machine: | |
3725 * BLINK_NONE not blinking at all | |
3726 * 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
|
3727 * BLINK_ON blinking, cursor is shown |
19526 | 3728 */ |
3729 | |
3730 #define BLINK_NONE 0 | |
3731 #define BLINK_OFF 1 | |
3732 #define BLINK_ON 2 | |
3733 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3734 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
|
3735 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
|
3736 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
|
3737 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
|
3738 static int blink_timer = 0; |
19526 | 3739 |
3740 void | |
3741 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
|
3742 long waittime, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3743 long on, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3744 long off) |
19526 | 3745 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3746 // TODO |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3747 blink_waittime = waittime; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3748 blink_ontime = on; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3749 blink_offtime = off; |
19526 | 3750 } |
3751 | |
3752 /* | |
3753 * Stop the cursor blinking. Show the cursor if it wasn't shown. | |
3754 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3755 void |
20134
352701a626ed
patch 8.2.0622: Haiku: GUI does not compile
Bram Moolenaar <Bram@vim.org>
parents:
19526
diff
changeset
|
3756 gui_mch_stop_blink(int may_call_gui_update_cursor) |
19526 | 3757 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3758 // TODO |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3759 if (blink_timer != 0) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3760 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3761 // XtRemoveTimeOut(blink_timer); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3762 blink_timer = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3763 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3764 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
|
3765 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
|
3766 blink_state = BLINK_NONE; |
19526 | 3767 } |
3768 | |
3769 /* | |
3770 * Start the cursor blinking. If it was already blinking, this restarts the | |
3771 * waiting time and shows the cursor. | |
3772 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3773 void |
19526 | 3774 gui_mch_start_blink() |
3775 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3776 // TODO |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3777 if (blink_timer != 0) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3778 ;// XtRemoveTimeOut(blink_timer); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3779 // 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
|
3780 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
|
3781 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3782 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
|
3783 blink_state = BLINK_ON; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3784 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
|
3785 } |
19526 | 3786 } |
3787 | |
3788 /* | |
3789 * Initialise vim to use the font with the given name. Return FAIL if the font | |
3790 * could not be loaded, OK otherwise. | |
3791 */ | |
3792 int | |
3793 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
|
3794 char_u *font_name, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3795 int fontset) |
19526 | 3796 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3797 if (gui.vimWindow->Lock()) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3798 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3799 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
|
3800 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3801 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3802 return rc; |
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 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3805 return FAIL; |
19526 | 3806 } |
3807 | |
3808 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3809 int |
19526 | 3810 gui_mch_adjust_charsize() |
3811 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3812 return FAIL; |
19526 | 3813 } |
3814 | |
3815 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3816 int |
19526 | 3817 gui_mch_font_dialog(font_family* family, font_style* style, float* size) |
3818 { | |
3819 #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
|
3820 // gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3821 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
|
3822 return dialog->Go(); |
19526 | 3823 #else |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3824 return NOFONT; |
19526 | 3825 #endif // FEAT_GUI_DIALOG |
3826 } | |
3827 | |
3828 | |
3829 GuiFont | |
3830 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
|
3831 char_u *name, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3832 int giveErrorIfMissing) |
19526 | 3833 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3834 static VimFont *fontList = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3835 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3836 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
|
3837 return NOFONT; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3838 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3839 // 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
|
3840 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
|
3841 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
|
3842 font_family family = {0}; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3843 font_style style = {0}; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3844 float size = 0.f; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3845 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3846 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
|
3847 if (giveErrorIfMissing) |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
3848 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
|
3849 return NOFONT; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3850 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3851 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3852 bool useSelectGUI = false; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3853 if (name != NULL) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3854 if (STRCMP(name, "*") == 0) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3855 useSelectGUI = true; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3856 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
|
3857 } else |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3858 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
|
3859 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3860 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
|
3861 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
|
3862 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
|
3863 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
|
3864 (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
|
3865 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3866 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3867 // replace underscores with spaces |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3868 char* end = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3869 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
|
3870 *end = ' '; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3871 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3872 // 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
|
3873 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
|
3874 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
|
3875 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
|
3876 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
|
3877 if (style_s != 0) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3878 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
|
3879 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
|
3880 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3881 if (useSelectGUI) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3882 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
|
3883 return FAIL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3884 // compose for further processing |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3885 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
|
3886 (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
|
3887 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
|
3888 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3889 // 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
|
3890 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
|
3891 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
|
3892 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
|
3893 vim_free(p_guifont); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3894 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
|
3895 // 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
|
3896 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
|
3897 if (*new_p_guifont == ' ') |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3898 *new_p_guifont = '_'; |
19526 | 3899 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3900 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3901 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3902 VimFont *flp; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3903 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
|
3904 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
|
3905 flp->refcount++; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3906 return (GuiFont)flp; |
19526 | 3907 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3908 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3909 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3910 VimFont *font = new VimFont(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3911 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
|
3912 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3913 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
|
3914 if (giveErrorIfMissing) |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
3915 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
|
3916 delete font; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3917 return NOFONT; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3918 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3919 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3920 // 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
|
3921 font->next = fontList; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3922 fontList = font; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3923 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3924 font->SetFamilyAndStyle(family, style); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3925 if (size > 0.f) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3926 font->SetSize(size); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3927 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3928 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
|
3929 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
|
3930 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3931 return (GuiFont)font; |
19526 | 3932 } |
3933 | |
3934 /* | |
3935 * Set the current text font. | |
3936 */ | |
3937 void | |
3938 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
|
3939 GuiFont font) |
19526 | 3940 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3941 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3942 VimFont *vf = (VimFont *)font; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3943 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3944 gui.vimTextArea->SetFont(vf); |
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.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
|
3947 font_height fh; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3948 vf->GetHeight(&fh); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3949 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
|
3950 + (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
|
3951 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
|
3952 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3953 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3954 } |
19526 | 3955 } |
3956 | |
3957 // XXX TODO This is apparently never called... | |
3958 void | |
3959 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
|
3960 GuiFont font) |
19526 | 3961 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3962 if (font == NOFONT) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3963 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3964 VimFont *f = (VimFont *)font; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3965 if (--f->refcount <= 0) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3966 if (f->refcount < 0) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3967 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
|
3968 delete f; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3969 } |
19526 | 3970 } |
3971 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3972 char_u * |
19526 | 3973 gui_mch_get_fontname(GuiFont font, char_u *name) |
3974 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3975 if (name == NULL) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3976 return NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3977 return vim_strsave(name); |
19526 | 3978 } |
3979 | |
3980 /* | |
3981 * Adjust gui.char_height (after 'linespace' was changed). | |
3982 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3983 int |
19526 | 3984 gui_mch_adjust_charheight() |
3985 { | |
3986 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3987 // TODO: linespace support? |
19526 | 3988 |
3989 // #ifdef FEAT_XFONTSET | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3990 // if (gui.fontset != NOFONTSET) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3991 // { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3992 // 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
|
3993 // 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
|
3994 // + p_linespace / 2; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3995 // } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3996 // else |
19526 | 3997 // #endif |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3998 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
3999 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
|
4000 font_height fh = {0}; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4001 font->GetHeight(&fh); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4002 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
|
4003 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
|
4004 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4005 return OK; |
19526 | 4006 } |
4007 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4008 void |
19526 | 4009 gui_mch_getmouse(int *x, int *y) |
4010 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4011 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
|
4012 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4013 /*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
|
4014 Window root, child; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4015 unsigned int mask; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4016 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4017 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
|
4018 &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
|
4019 *x = winx; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4020 *y = winy; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4021 } else*/ { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4022 *x = -1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4023 *y = -1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4024 } |
19526 | 4025 } |
4026 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4027 void |
19526 | 4028 gui_mch_mousehide(int hide) |
4029 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4030 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
|
4031 // TODO |
19526 | 4032 } |
4033 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4034 static int |
19526 | 4035 hex_digit(int c) |
4036 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4037 if (isdigit(c)) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4038 return c - '0'; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4039 c = TOLOWER_ASC(c); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4040 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
|
4041 return c - 'a' + 10; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4042 return -1000; |
19526 | 4043 } |
4044 | |
4045 /* | |
4046 * This function has been lifted from gui_w32.c and extended a bit. | |
4047 * | |
4048 * Return the Pixel value (color) for the given color name. | |
4049 * Return INVALCOLOR for error. | |
4050 */ | |
4051 guicolor_T | |
4052 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
|
4053 char_u *name) |
19526 | 4054 { |
26057
92c424550367
patch 8.2.3562: cannot add color names
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
4055 return gui_get_color_cmn(name); |
19526 | 4056 } |
4057 | |
4058 /* | |
4059 * Set the current text foreground color. | |
4060 */ | |
4061 void | |
4062 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
|
4063 guicolor_T color) |
19526 | 4064 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4065 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
|
4066 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4067 gui.vimTextArea->SetHighColor(rgb); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4068 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4069 } |
19526 | 4070 } |
4071 | |
4072 /* | |
4073 * Set the current text background color. | |
4074 */ | |
4075 void | |
4076 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
|
4077 guicolor_T color) |
19526 | 4078 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4079 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
|
4080 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4081 gui.vimTextArea->SetLowColor(rgb); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4082 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4083 } |
19526 | 4084 } |
4085 | |
4086 /* | |
4087 * Set the current text special color. | |
4088 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4089 void |
19526 | 4090 gui_mch_set_sp_color(guicolor_T color) |
4091 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4092 // prev_sp_color = color; |
19526 | 4093 } |
4094 | |
4095 void | |
4096 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
|
4097 int row, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4098 int col, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4099 char_u *s, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4100 int len, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4101 int flags) |
19526 | 4102 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4103 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4104 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
|
4105 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4106 } |
19526 | 4107 } |
4108 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4109 guicolor_T |
19526 | 4110 gui_mch_get_rgb_color(int r, int g, int b) |
4111 { | |
4112 return gui_get_rgb_color_cmn(r, g, b); | |
4113 } | |
4114 | |
4115 | |
4116 // Return OK if the key with the termcap name "name" is supported. | |
4117 int | |
4118 gui_mch_haskey( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4119 char_u *name) |
19526 | 4120 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4121 int i; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4122 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4123 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
|
4124 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
|
4125 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
|
4126 return OK; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4127 return FAIL; |
19526 | 4128 } |
4129 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4130 void |
19526 | 4131 gui_mch_beep() |
4132 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4133 ::beep(); |
19526 | 4134 } |
4135 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4136 void |
19526 | 4137 gui_mch_flash(int msec) |
4138 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4139 // 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
|
4140 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4141 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4142 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
|
4143 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4144 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
|
4145 gui.vimTextArea->FillRect(rect); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4146 gui.vimTextArea->Sync(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4147 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
|
4148 gui.vimTextArea->FillRect(rect); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4149 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
|
4150 gui.vimTextArea->Flush(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4151 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4152 } |
19526 | 4153 } |
4154 | |
4155 /* | |
4156 * Invert a rectangle from row r, column c, for nr rows and nc columns. | |
4157 */ | |
4158 void | |
4159 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
|
4160 int r, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4161 int c, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4162 int nr, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4163 int nc) |
19526 | 4164 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4165 BRect rect; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4166 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
|
4167 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
|
4168 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
|
4169 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
|
4170 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4171 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4172 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
|
4173 gui.vimTextArea->FillRect(rect); |
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_COPY); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4175 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4176 } |
19526 | 4177 } |
4178 | |
4179 /* | |
4180 * Iconify the GUI window. | |
4181 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4182 void |
19526 | 4183 gui_mch_iconify() |
4184 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4185 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4186 gui.vimWindow->Minimize(true); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4187 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4188 } |
19526 | 4189 } |
4190 | |
4191 #if defined(FEAT_EVAL) || defined(PROTO) | |
4192 /* | |
4193 * Bring the Vim window to the foreground. | |
4194 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4195 void |
19526 | 4196 gui_mch_set_foreground(void) |
4197 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4198 // TODO |
19526 | 4199 } |
4200 #endif | |
4201 | |
4202 /* | |
4203 * Set the window title | |
4204 */ | |
4205 void | |
4206 gui_mch_settitle( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4207 char_u *title, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4208 char_u *icon) |
19526 | 4209 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4210 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4211 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
|
4212 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4213 } |
19526 | 4214 } |
4215 | |
4216 /* | |
4217 * Draw a cursor without focus. | |
4218 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4219 void |
19526 | 4220 gui_mch_draw_hollow_cursor(guicolor_T color) |
4221 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4222 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
|
4223 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4224 BRect r; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4225 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
|
4226 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
|
4227 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
|
4228 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
|
4229 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
|
4230 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
|
4231 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4232 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4233 gui.vimTextArea->StrokeRect(r); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4234 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4235 // gui_mch_flush(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4236 } |
19526 | 4237 } |
4238 | |
4239 /* | |
4240 * Draw part of a cursor, only w pixels wide, and h pixels high. | |
4241 */ | |
4242 void | |
4243 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
|
4244 int w, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4245 int h, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4246 guicolor_T color) |
19526 | 4247 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4248 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
|
4249 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4250 BRect r; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4251 r.left = |
19526 | 4252 #ifdef FEAT_RIGHTLEFT |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4253 // 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
|
4254 CURSOR_BAR_RIGHT ? FILL_X(gui.col + 1) - w : |
19526 | 4255 #endif |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4256 FILL_X(gui.col); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4257 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
|
4258 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
|
4259 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
|
4260 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4261 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4262 gui.vimTextArea->FillRect(r); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4263 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4264 // gui_mch_flush(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4265 } |
19526 | 4266 } |
4267 | |
4268 /* | |
4269 * Catch up with any queued events. This may put keyboard input into the | |
4270 * input buffer, call resize call-backs, trigger timers etc. If there is | |
4271 * nothing in the event queue (& no timers pending), then we return | |
4272 * immediately. | |
4273 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4274 void |
19526 | 4275 gui_mch_update() |
4276 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4277 gui_mch_flush(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4278 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
|
4279 !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
|
4280 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
|
4281 /* nothing */ ; |
19526 | 4282 } |
4283 | |
4284 /* | |
4285 * GUI input routine called by gui_wait_for_chars(). Waits for a character | |
4286 * from the keyboard. | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4287 * wtime == -1 Wait forever. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4288 * 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
|
4289 * wtime > 0 Wait wtime milliseconds for a character. |
19526 | 4290 * Returns OK if a character was found to be available within the given time, |
4291 * or FAIL otherwise. | |
4292 */ | |
4293 int | |
4294 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
|
4295 int wtime) |
19526 | 4296 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4297 int focus; |
20277
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4298 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
|
4299 status_t st; |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4300 |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4301 if (wtime >= 0) |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4302 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4303 timeout = wtime * 1000; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4304 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
|
4305 } |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4306 else |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4307 timeout = B_INFINITE_TIMEOUT; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4308 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4309 focus = gui.in_focus; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4310 for (;;) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4311 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4312 // 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
|
4313 if (gui.in_focus != focus) |
19526 | 4314 { |
20152
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) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4316 gui_mch_start_blink(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4317 else |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4318 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
|
4319 focus = gui.in_focus; |
19526 | 4320 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4321 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4322 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
|
4323 |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4324 #ifdef MESSAGE_QUEUE |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4325 # ifdef FEAT_TIMERS |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4326 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
|
4327 # endif |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4328 parse_queued_messages(); |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4329 # ifdef FEAT_TIMERS |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4330 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
|
4331 // 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
|
4332 break; |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4333 # endif |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4334 # 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
|
4335 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
|
4336 { |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4337 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
|
4338 timeout = 20000; |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4339 } |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4340 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
|
4341 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
|
4342 # endif |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4343 #endif |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4344 |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4345 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4346 * 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
|
4347 * 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
|
4348 * 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
|
4349 * 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
|
4350 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4351 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
|
4352 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4353 if (input_available()) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4354 return OK; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4355 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
|
4356 return FAIL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4357 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4358 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4359 * 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
|
4360 * next event. |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4361 */ |
20277
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4362 if (wtime >= 0) |
8a694c9447d7
patch 8.2.0694: Haiku: channel and terminal do not work
Bram Moolenaar <Bram@vim.org>
parents:
20231
diff
changeset
|
4363 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4364 timeout = until - system_time(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4365 if (timeout < 0) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4366 break; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4367 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4368 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4369 return FAIL; |
19526 | 4370 |
4371 } | |
4372 | |
4373 /* | |
4374 * Output routines. | |
4375 */ | |
4376 | |
4377 /* | |
4378 * Flush any output to the screen. This is typically called before | |
4379 * the app goes to sleep. | |
4380 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4381 void |
19526 | 4382 gui_mch_flush() |
4383 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4384 // 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
|
4385 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4386 gui.vimWindow->Flush(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4387 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4388 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4389 return; |
19526 | 4390 } |
4391 | |
4392 /* | |
4393 * Clear a rectangular region of the screen from text pos (row1, col1) to | |
4394 * (row2, col2) inclusive. | |
4395 */ | |
4396 void | |
4397 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
|
4398 int row1, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4399 int col1, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4400 int row2, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4401 int col2) |
19526 | 4402 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4403 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4404 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
|
4405 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4406 } |
19526 | 4407 } |
4408 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4409 void |
19526 | 4410 gui_mch_clear_all() |
4411 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4412 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4413 gui.vimTextArea->mchClearAll(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4414 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4415 } |
19526 | 4416 } |
4417 | |
4418 /* | |
4419 * Delete the given number of lines from the given row, scrolling up any | |
4420 * text further down within the scroll region. | |
4421 */ | |
4422 void | |
4423 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
|
4424 int row, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4425 int num_lines) |
19526 | 4426 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4427 gui.vimTextArea->mchDeleteLines(row, num_lines); |
19526 | 4428 } |
4429 | |
4430 /* | |
4431 * Insert the given number of lines before the given row, scrolling down any | |
4432 * following text within the scroll region. | |
4433 */ | |
4434 void | |
4435 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
|
4436 int row, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4437 int num_lines) |
19526 | 4438 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4439 gui.vimTextArea->mchInsertLines(row, num_lines); |
19526 | 4440 } |
4441 | |
4442 #if defined(FEAT_MENU) || defined(PROTO) | |
4443 /* | |
4444 * Menu stuff. | |
4445 */ | |
4446 | |
4447 void | |
4448 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
|
4449 int flag) |
19526 | 4450 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4451 if (gui.vimWindow->Lock()) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4452 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4453 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
|
4454 menubar->SetEnabled(flag); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4455 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4456 } |
19526 | 4457 } |
4458 | |
4459 void | |
4460 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
|
4461 int x, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4462 int y, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4463 int w, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4464 int h) |
19526 | 4465 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4466 // It will be in the right place anyway |
19526 | 4467 } |
4468 | |
4469 /* | |
4470 * Add a sub menu to the menu bar. | |
4471 */ | |
4472 void | |
4473 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
|
4474 vimmenu_T *menu, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4475 int idx) |
19526 | 4476 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4477 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
|
4478 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4479 // 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
|
4480 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
|
4481 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
|
4482 menu->submenu_id = popUpMenu; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4483 menu->id = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4484 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4485 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4486 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4487 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
|
4488 || (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
|
4489 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4490 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4491 if (gui.vimWindow->Lock()) |
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 // 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
|
4494 // 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
|
4495 // |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4496 // 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
|
4497 // 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
|
4498 // |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4499 // 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
|
4500 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4501 BMenu *tmp; |
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 if ( parent ) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4504 tmp = parent->submenu_id; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4505 else |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4506 tmp = gui.vimForm->MenuBar(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4507 // 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
|
4508 // 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
|
4509 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4510 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
|
4511 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4512 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
|
4513 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4514 menu->submenu_id = bmenu; |
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 // 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
|
4517 tmp->AddItem(bmenu); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4518 |
32244
533e36e02a68
patch 9.0.1453: typos in source code and tests
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
4519 // Now it's safe to query the menu for the associated MenuItem... |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4520 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
|
4521 |
19526 | 4522 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4523 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4524 } |
19526 | 4525 } |
4526 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4527 void |
19526 | 4528 gui_mch_toggle_tearoffs(int enable) |
4529 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4530 // no tearoff menus |
19526 | 4531 } |
4532 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4533 static BMessage * |
19526 | 4534 MenuMessage(vimmenu_T *menu) |
4535 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4536 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
|
4537 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
|
4538 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4539 return m; |
19526 | 4540 } |
4541 | |
4542 /* | |
4543 * Add a menu item to a menu | |
4544 */ | |
4545 void | |
4546 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
|
4547 vimmenu_T *menu, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4548 int idx) |
19526 | 4549 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4550 int mnemonic = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4551 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
|
4552 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4553 // TODO: use menu->actext |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4554 // 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
|
4555 // 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
|
4556 // |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4557 // Punt for Now... |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4558 // 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
|
4559 if (gui.vimWindow->Lock()) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4560 { |
19526 | 4561 #ifdef FEAT_TOOLBAR |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4562 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
|
4563 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
|
4564 if (toolbar != NULL) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4565 toolbar->AddButton(idx, menu); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4566 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4567 } else |
19526 | 4568 #endif |
4569 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4570 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
|
4571 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
|
4572 BSeparatorItem *item = new BSeparatorItem(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4573 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
|
4574 menu->id = item; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4575 menu->submenu_id = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4576 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4577 else { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4578 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
|
4579 MenuMessage(menu)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4580 item->SetTarget(gui.vimTextArea); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4581 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
|
4582 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
|
4583 menu->id = item; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4584 menu->submenu_id = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4585 } |
19526 | 4586 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4587 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4588 } |
19526 | 4589 } |
4590 | |
4591 /* | |
4592 * Destroy the machine specific menu widget. | |
4593 */ | |
4594 void | |
4595 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
|
4596 vimmenu_T *menu) |
19526 | 4597 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4598 if (gui.vimWindow->Lock()) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4599 { |
19526 | 4600 #ifdef FEAT_TOOLBAR |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4601 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
|
4602 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
|
4603 if (toolbar != NULL) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4604 toolbar->RemoveButton(menu); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4605 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4606 } else |
19526 | 4607 #endif |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4608 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4609 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
|
4610 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4611 * 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
|
4612 * 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
|
4613 * 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
|
4614 * (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
|
4615 * removed and deleted before). |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4616 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4617 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
|
4618 if (bmenu) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4619 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4620 bmenu->RemoveItem(menu->id); |
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 * 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
|
4623 * 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
|
4624 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4625 if (bmenu == gui.vimForm->MenuBar() && bmenu->CountItems() == 0) |
19526 | 4626 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4627 bmenu->ResizeTo(-MENUBAR_MARGIN, -MENUBAR_MARGIN); |
19526 | 4628 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4629 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4630 delete menu->id; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4631 menu->id = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4632 menu->submenu_id = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4633 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4634 gui.menu_height = (int) gui.vimForm->MenuHeight(); |
19526 | 4635 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4636 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4637 } |
19526 | 4638 } |
4639 | |
4640 /* | |
4641 * Make a menu either grey or not grey. | |
4642 */ | |
4643 void | |
4644 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
|
4645 vimmenu_T *menu, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4646 int grey) |
19526 | 4647 { |
4648 #ifdef FEAT_TOOLBAR | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4649 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
|
4650 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4651 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
|
4652 if (toolbar != NULL) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4653 toolbar->GrayButton(menu, grey); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4654 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4655 gui.vimWindow->Unlock(); |
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 } else |
19526 | 4658 #endif |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4659 if (menu->id != NULL) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4660 menu->id->SetEnabled(!grey); |
19526 | 4661 } |
4662 | |
4663 /* | |
4664 * Make menu item hidden or not hidden | |
4665 */ | |
4666 void | |
4667 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
|
4668 vimmenu_T *menu, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4669 int hidden) |
19526 | 4670 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4671 if (menu->id != NULL) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4672 menu->id->SetEnabled(!hidden); |
19526 | 4673 } |
4674 | |
4675 /* | |
4676 * This is called after setting all the menus to grey/hidden or not. | |
4677 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4678 void |
19526 | 4679 gui_mch_draw_menubar() |
4680 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4681 // Nothing to do in BeOS |
19526 | 4682 } |
4683 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4684 void |
19526 | 4685 gui_mch_show_popupmenu(vimmenu_T *menu) |
4686 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4687 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
|
4688 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4689 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4690 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
|
4691 if (popupMenu == NULL) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4692 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4693 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4694 BPoint point; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4695 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4696 uint32 buttons = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4697 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
|
4698 gui.vimTextArea->ConvertToScreen(&point); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4699 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4700 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4701 popupMenu->Go(point, true); |
19526 | 4702 } |
4703 | |
4704 #endif // FEAT_MENU | |
4705 | |
4706 // Mouse stuff | |
4707 | |
4708 #ifdef FEAT_CLIPBOARD | |
4709 /* | |
4710 * Clipboard stuff, for cutting and pasting text to other windows. | |
4711 */ | |
4712 char textplain[] = "text/plain"; | |
4713 char vimselectiontype[] = "application/x-vnd.Rhialto-Vim-selectiontype"; | |
4714 | |
4715 /* | |
4716 * Get the current selection and put it in the clipboard register. | |
4717 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4718 void |
19526 | 4719 clip_mch_request_selection(Clipboard_T *cbd) |
4720 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4721 if (be_clipboard->Lock()) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4722 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4723 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
|
4724 // m->PrintToStream(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4725 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4726 char_u *string = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4727 ssize_t stringlen = -1; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4728 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4729 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
|
4730 (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
|
4731 || m->FindString("text", (const char **)&string) == B_OK) |
19526 | 4732 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4733 if (stringlen == -1) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4734 stringlen = STRLEN(string); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4735 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4736 int type; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4737 char *seltype; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4738 ssize_t seltypelen; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4739 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4740 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4741 * 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
|
4742 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4743 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
|
4744 (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
|
4745 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4746 switch (*seltype) |
19526 | 4747 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4748 default: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4749 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
|
4750 case 'C': type = MCHAR; break; |
19526 | 4751 #ifdef FEAT_VISUAL |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4752 case 'B': type = MBLOCK; break; |
19526 | 4753 #endif |
4754 } | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4755 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4756 else |
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 // 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
|
4759 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
|
4760 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4761 clip_yank_selection(type, string, (long)stringlen, cbd); |
19526 | 4762 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4763 be_clipboard->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4764 } |
19526 | 4765 } |
4766 /* | |
4767 * Make vim the owner of the current selection. | |
4768 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4769 void |
19526 | 4770 clip_mch_lose_selection(Clipboard_T *cbd) |
4771 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4772 // Nothing needs to be done here |
19526 | 4773 } |
4774 | |
4775 /* | |
4776 * Make vim the owner of the current selection. Return OK upon success. | |
4777 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4778 int |
19526 | 4779 clip_mch_own_selection(Clipboard_T *cbd) |
4780 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4781 /* |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4782 * 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
|
4783 * 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
|
4784 */ |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4785 return FAIL; |
19526 | 4786 } |
4787 | |
4788 /* | |
4789 * Send the current selection to the clipboard. | |
4790 */ | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4791 void |
19526 | 4792 clip_mch_set_selection(Clipboard_T *cbd) |
4793 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4794 if (be_clipboard->Lock()) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4795 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4796 be_clipboard->Clear(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4797 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
|
4798 assert(m); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4799 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4800 // 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
|
4801 cbd->owned = TRUE; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4802 clip_get_selection(cbd); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4803 cbd->owned = FALSE; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4804 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4805 char_u *str = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4806 long_u count; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4807 int type; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4808 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4809 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
|
4810 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4811 if (type < 0) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4812 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4813 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4814 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
|
4815 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4816 // Add type of selection |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4817 char vtype; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4818 switch (type) |
19526 | 4819 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4820 default: |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4821 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
|
4822 case MCHAR: vtype = 'C'; break; |
19526 | 4823 #ifdef FEAT_VISUAL |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4824 case MBLOCK: vtype = 'B'; break; |
19526 | 4825 #endif |
4826 } | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4827 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
|
4828 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4829 vim_free(str); |
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 be_clipboard->Commit(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4832 be_clipboard->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4833 } |
19526 | 4834 } |
4835 | |
4836 #endif // FEAT_CLIPBOARD | |
4837 | |
4838 #ifdef FEAT_BROWSE | |
4839 /* | |
4840 * Pop open a file browser and return the file selected, in allocated memory, | |
4841 * or NULL if Cancel is hit. | |
4842 * saving - TRUE if the file will be saved to, FALSE if it will be opened. | |
4843 * title - Title message for the file browser dialog. | |
4844 * dflt - Default name of file. | |
4845 * ext - Default extension to be added to files without extensions. | |
4846 * initdir - directory in which to open the browser (NULL = current dir) | |
4847 * filter - Filter for matched files to choose from. | |
4848 * Has a format like this: | |
4849 * "C Files (*.c)\0*.c\0" | |
4850 * "All Files\0*.*\0\0" | |
4851 * If these two strings were concatenated, then a choice of two file | |
4852 * filters will be selectable to the user. Then only matching files will | |
4853 * be shown in the browser. If NULL, the default allows all files. | |
4854 * | |
4855 * *NOTE* - the filter string must be terminated with TWO nulls. | |
4856 */ | |
4857 char_u * | |
4858 gui_mch_browse( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4859 int saving, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4860 char_u *title, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4861 char_u *dflt, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4862 char_u *ext, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4863 char_u *initdir, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4864 char_u *filter) |
19526 | 4865 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4866 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
|
4867 NULL, NULL, 0, false, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4868 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
|
4869 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4870 gui.vimApp->fBrowsedPath.Unset(); |
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->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
|
4873 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
|
4874 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4875 gui.vimApp->fFilePanel->Show(); |
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->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
|
4878 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4879 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
|
4880 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4881 char_u *fileName = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4882 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
|
4883 if (result == B_OK) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4884 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
|
4885 } else |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4886 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
|
4887 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
|
4888 result, strerror(result)); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4889 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4890 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4891 delete gui.vimApp->fFilePanel; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4892 gui.vimApp->fFilePanel = NULL; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4893 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4894 return fileName; |
19526 | 4895 } |
4896 #endif // FEAT_BROWSE | |
4897 | |
4898 | |
4899 #if defined(FEAT_GUI_DIALOG) | |
4900 | |
4901 /* | |
4902 * 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
|
4903 * 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
|
4904 * 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
|
4905 * 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
|
4906 * buttons = '\n' separated list of button captions, default first. |
19526 | 4907 * dfltbutton = number of default button. |
4908 * | |
4909 * 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
|
4910 * 2 for the second, etc. |
19526 | 4911 * |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4912 * 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
|
4913 * -1 for unexpected error |
19526 | 4914 * |
4915 * If stubbing out this fn, return 1. | |
4916 */ | |
4917 | |
4918 int | |
4919 gui_mch_dialog( | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4920 int type, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4921 char_u *title, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4922 char_u *message, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4923 char_u *buttons, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4924 int dfltbutton, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4925 char_u *textfield, |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4926 int ex_cmd) |
19526 | 4927 { |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4928 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
|
4929 (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
|
4930 return dialog->Go(); |
19526 | 4931 } |
4932 | |
4933 #endif // FEAT_GUI_DIALOG | |
4934 | |
4935 | |
4936 /* | |
4937 * Return the RGB value of a pixel as long. | |
4938 */ | |
4939 guicolor_T | |
4940 gui_mch_get_rgb(guicolor_T pixel) | |
4941 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4942 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
|
4943 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4944 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
|
4945 + (rgb.blue & 0xff); |
19526 | 4946 } |
4947 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4948 void |
19526 | 4949 gui_mch_setmouse(int x, int y) |
4950 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4951 TRACE(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4952 // TODO |
19526 | 4953 } |
4954 | |
4955 #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
|
4956 void |
19526 | 4957 im_set_position(int row, int col) |
4958 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4959 if (gui.vimWindow->Lock()) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4960 { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4961 gui.vimTextArea->DrawIMString(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4962 gui.vimWindow->Unlock(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4963 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4964 return; |
19526 | 4965 } |
4966 #endif | |
4967 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4968 void |
19526 | 4969 gui_mch_show_toolbar(int showit) |
4970 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4971 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
|
4972 gui.toolbar_height = (toolbar && showit) ? toolbar->ToolbarHeight() : 0.; |
19526 | 4973 } |
4974 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4975 void |
19526 | 4976 gui_mch_set_toolbar_pos(int x, int y, int w, int h) |
4977 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4978 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
|
4979 if (toolbar != NULL) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4980 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4981 toolbar->MoveTo(x, y); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4982 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
|
4983 gui.vimWindow->Unlock(); |
19526 | 4984 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4985 } |
19526 | 4986 } |
4987 | |
4988 #if defined(FEAT_GUI_TABLINE) || defined(PROTO) | |
4989 | |
4990 /* | |
4991 * Show or hide the tabline. | |
4992 */ | |
4993 void | |
4994 gui_mch_show_tabline(int showit) | |
4995 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4996 VimTabLine *tabLine = gui.vimForm->TabLine(); |
19526 | 4997 |
4998 if (tabLine == NULL) | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
4999 return; |
19526 | 5000 |
5001 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
|
5002 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
|
5003 gui.tabline_height = gui.vimForm->TablineHeight(); |
19526 | 5004 } |
5005 } | |
5006 | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5007 void |
19526 | 5008 gui_mch_set_tabline_pos(int x, int y, int w, int h) |
5009 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5010 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
|
5011 if (tabLine != NULL) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5012 if (gui.vimWindow->Lock()) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5013 tabLine->MoveTo(x, y); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5014 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
|
5015 gui.vimWindow->Unlock(); |
19526 | 5016 } |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5017 } |
19526 | 5018 } |
5019 | |
5020 /* | |
5021 * Return TRUE when tabline is displayed. | |
5022 */ | |
5023 int | |
5024 gui_mch_showing_tabline() | |
5025 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5026 VimTabLine *tabLine = gui.vimForm->TabLine(); |
19526 | 5027 return tabLine != NULL && gui.vimForm->IsShowingTabLine(); |
5028 } | |
5029 | |
5030 /* | |
5031 * Update the labels of the tabline. | |
5032 */ | |
5033 void | |
5034 gui_mch_update_tabline() | |
5035 { | |
5036 tabpage_T *tp; | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5037 int nr = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5038 int curtabidx = 0; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5039 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5040 VimTabLine *tabLine = gui.vimForm->TabLine(); |
19526 | 5041 |
5042 if (tabLine == NULL) | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5043 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5044 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5045 gui.vimWindow->Lock(); |
19526 | 5046 |
5047 // Add a label for each tab page. They all contain the same text area. | |
5048 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
|
5049 if (tp == curtab) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5050 curtabidx = nr; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5051 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5052 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
|
5053 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5054 if (tab == NULL) { |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5055 tab = new VimTabLine::VimTab(); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5056 tabLine->AddTab(NULL, tab); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5057 } |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5058 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5059 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
|
5060 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
|
5061 tabLine->Invalidate(); |
19526 | 5062 } |
5063 | |
5064 // 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
|
5065 while (nr < tabLine->CountTabs()) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5066 tabLine->RemoveTab(nr); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5067 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5068 if (tabLine->Selection() != curtabidx) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5069 tabLine->Select(curtabidx); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5070 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5071 gui.vimWindow->Unlock(); |
19526 | 5072 } |
5073 | |
5074 /* | |
5075 * Set the current tab to "nr". First tab is 1. | |
5076 */ | |
5077 void | |
5078 gui_mch_set_curtab(int nr) | |
5079 { | |
20152
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5080 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
|
5081 if (tabLine == NULL) |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5082 return; |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5083 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5084 gui.vimWindow->Lock(); |
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 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
|
5087 tabLine->Select(nr -1); |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5088 |
bac01efdf059
patch 8.2.0631: Haiku file formatted with wrong tabstop
Bram Moolenaar <Bram@vim.org>
parents:
20134
diff
changeset
|
5089 gui.vimWindow->Unlock(); |
19526 | 5090 } |
5091 | |
5092 #endif // FEAT_GUI_TABLINE |